A. Single-radio multi-channel
The following four components should be added by user to create the multi-channel environments. The channels created in this part have identical spectrum parameters. Please note that if you are using GUI provided by this simulator, this section can be skipped.
Component 1.Define the channel number in TCL script |
set val(channum) 2 ;# 2 channels are available in the network |
Component 2. New channel objects according to the interface number provided in Component 1. |
for {set i 0 } { $i < $val(channum)} {incr i} { set chan_($i) [new $val(chan)] ; #new channel objects } |
Component 3. Configure the multiple channel option |
$ns_ node-config -adhocRouting $val(rp) \
-ChannelNum $val(channum)\ ;# configure channel number -channel $chan_(0) ;#configure the first channel object
|
Component 4. Assign the channel objects to the channel array of the simulator |
for {set i 0} {$i < $val(ni) } {incr i} { $ns_ add-channel $i $chan_($i) ; # initialize the channel array with channel objects }
|
B. Multi-radio multi-channel
The following four components should be added by user to
create the multi-radio, multi-channel environments for
Component 1.Define the radio and channel number in TCL script |
set val(ni) 2 ;# number of radios set val(channum) 2 ;# 2 channels are available for each radio |
Component 2. New channel objects according to the radio and channel number provided in Component 1. |
for {set i 0} { $i < [expr $val(ni)*$val(channum)]} {incr i} { set chan_($i) [new $val(chan)] } |
Component 3. Configure the multiple radio and channel option |
$ns_ node-config -ifNum $val(ni) -channel $chan_(0) $ns_ node-config -ChannelNum $val(channum) |
Component 4. Assign the channel objects to the channel array of the simulator |
for {set i 0} {$i < [expr $val(ni)*$val(channum)] } {incr i} { $ns_ add-channel $i $chan_($i) } |
The channel decision from CR
Module packet.h: |
struct hdr_cmn {
int channelindex_;
} |
The code as follow should be added in the sendDown function for wirelessphy.
In our design, multiple channel object pointer is used to index the channel
object. Hence, it is appropriate to use channel index derived in CR
Module WirelessPhy:
Interface for channel decision in |
void WirelessPhy::sendDown(Packet *p) {
// Send the packet //channel_->recv(p, this); //send packet over the channel specified by channel index. multichannel[hdr_cmn::access(p)->channelindex_]->recv(p, this);
} |
If users
If users
Packet will be transmitted using the default transmission power
if transmission power is not specified in simulation script. However, as CR
The DSA algorithm can be implemented in the following functions, which are in bold.
Module Mobilenode: Interface for obtaining the transmission power from DSA algorithms. |
Class PacketPr{ public:
//Obtain DSA decision according to different input parameters. double getDSAPr(int receivernode);
double getDSAPr(int receivernode, int channelindex);
} |
Then, add the following interface for controlling the maximum transmission power and obtaining DSA power decision. Please note that other physical layer can be modified in the similar way.
Module WirelessPhy:
Interface for channel decision in |
int WirelessPhy::sendUp(Packet *p) {
double DSAPr= (MobileNode*)node()->PacketPr_.getDSAPr(); //if the Pr is within the limit range of user, assign DSAPr to Pr. Pr=DSAPr;
} |
To determine the txpower, the DSA algorithms need to know the identity of sender and receiver. In some DSA algorithms (such as game based), sender and receiver has negotiated the channel decision, and thus the power control algorithm compute the txpower over the negotiated channel.
A. Interference information
The interference information is associated with each node
over each channel. Several kinds of interference information are provided: (1)
Channel that has minimum interference, (2) Current interference value over a
specific channel, and (3) Historical interference information. Users can use
the corresponding
(1)Channel that has minimum interferences
Interface for obtaining channel number with minimum interference around one node. Use the following method to obtain channel number which has minimum interference.
Module Mobilenode: obtain channel with minimum interference |
Class PacketPr{
//return the channel id with minimum interference. int ChannelwithMinimumIf{ return chanwithminiIf;}
} |
(2)Current interference value over a specific channel.
Use the following method to obtain interference value. Please note the interference value is sometimes too small and you may need to scale it by some factor to see the result.
Module Mobilenode:
Interface for channel decision in |
Class PacketPr {
//obtain the interference information for current node double getInterference(int channelno);
} |
(3)Historical interference information
To obtain the historical information of node i, the following option to select whether to record interference on node i should be added in simulation script by the user.
TCL script: add the interference option |
for {set i 0} {$i < $val(nn) } {incr i} { set node_($i) [$ns_ node] $node_($i) set SingleIfMultiChan 1 ; $node_($i)
set recordIfall 1 ; # enable interference information collection $node_($i) random-motion 0 ;# disable random motion } |
If this option is added, the interference information about node i is provided. If using GUI, the interference information for all nodes is provided by default.
Besides obtaining the channel with minimum interference, the interference information over each channel around can be obtained through the ITfile generated by the simulator. The format of the ITfile is as follow. User can obtain their information through ITfile according to this format.
ITfile format |
Timestamp node id interference channel id |
B. Noise
TCL command for setting noise for physical layer is as follow. This should be added in the simulation script if you want to define the noise.
TCL command: setting noise for physical layer |
Phy/WirelessPhy noise_ 0.1 ;# 0.1 can be replaced by any other noise value |
With the noise information and interference information,
user can change the physical layer of NS-2 to use SINR/
C. Traffic information
For intelligent based
(1)Obtaining the current traffic information
Use the following function in bold to obtain traffic information.
Module Mobilenode: obtain traffic information |
class PacketPr { public:
int getTrafficCount() {return trafficcount;}
} |
Users can access this function through the pointer to mobilenode. For example, in the
Module Mobilenode: obtain traffic information |
int traffic= ((MobileNode*)(netif_->node()))->PacketPr_.getTrafficCount();
|
(2)Obtaining the historical traffic information
The historical traffic information is stored in the Trafficfile. User can obtain this information based on the format provided.
Trafficfile format |
Timestamp node id traffic information |
Previous: CR MAC Overview
Next: Software and
Installation
Return to Main