Thursday, August 1, 2013

Set different initial energy for nodes in ns2

The following script can be used to initialize different nodes with different energy levels. You can also create an array of nodes and initialize different nodes at different energy levels inside a loop if you want.

# set initial energy for first node
$ns node-config -initialEnergy 50
set node_(0) [$ns node]

# set initial energy for second node
$ns node-config -initialEnergy 100

set node_(1) [$ns node]



# set initial energy for third node

$ns node-config -initialEnergy 70
set node_(2) [$ns node]


and so on for the other nodes.

0 comments:

Post a Comment