2008年1月1日 星期二

per packet power control

For per packet power control, transmit power needsto be associated with every packet. An appropriate place for this is hdr_cmn in common/packet.h, which is somewhat analogous to struct skbuff in the Linux kernel. We add a new field txpower_ in hdr_cmn, which is an integer denoting the powerlevel.

Code is added in WirelessPhy::sendDown() to extract the power level from the common header and set Pt_ equal to the transmit power corresponding to that power level. The mapping between power levels and the exact value in watts is controlled by the variables TxPowerVal_x_ (x=1 to 6), which can be set from tcl space. Another variable DefaultTxPowerLevel_ can be set from tcl for everynode which is used for setting the Pt_ for those packets in which txpower_ in hdr_cmn is set to zero.

set the power level of different nodes

The power level of a packet in NS is determined by the Pt_ variable which is amember of Phy/WirelessPhy defined in mac/wireless-phy.h. The power level can bechanged to x Watts for all nodes globally in tcl through the command,"Phy/WirelessPhy set Pt_ xW".

To set the power level of different nodes to different values one has to access the WirelessPhy class from a node's array of interfaces (netif_) and then set the corresponding Pt_ to the desired value.
For example, the following command sets the power level of node node_(0) to 0.5 W.
[[lindex [$node_(0) array get netif_] 1] set Pt_ 0.5]