Wednesday, November 24, 2010

The corresponding variable in OTCL node class of protocols in NS2

When we configure node in NS2, we set up the protocol stack of the node as follows

$ns_ node-config -adhocRouting $opt(adhocRouting) \
-llType $opt(ll) \
-macType $opt(mac) \
-ifqType $opt(ifq) \
-ifqLen $opt(ifqlen) \
-antType $opt(ant) \
-propType $opt(prop) \
-phyType $opt(netif) \
-agentTrace OFF \
-routerTrace ON \
-macTrace ON\
-topoInstance $topo\
-energyModel $opt(energy)\
-txPower $opt(txpower)\
-rxPower $opt(rxpower)\
-initialEnergy $opt(initialenergy)\
-idlePower $opt(idlepower)\
-channel $chan_1_ \
-movementTrace OFF

Then, for each node, the instance of declared protocols is generated. Accrodingly, a corresponding variable in OTCL class Node is bound to the instance.

Sometimes, we need to setup the attribute of the protocol on each node individually. In this case, we should access the corresponding variable of the protocol. For example, we access routing protocol instance using

set rt [$node_($i) set ragent_]

then, we can use $rt to call the command designed for the routing protocol or set its C++ variables.


Following are some otcl variables in class Node

arptable_
nifs_ #number of interfaces
netif_
mac_
ifq_
ll_
imep_

For each of the last 5 variables, we totally have nifs_ elements. Thus, we should use index to specify which interface it is on. For example, we use the following command to access the mac protocol object on the first interface.

set mac [$node_($i) set mac_(0)]

No comments:

Post a Comment