Hi, i want to set different energies for different nodes in the tcl file below:
set val(chan) Channel/WirelessChannel ;# channel type set val(prop) Propagation/TwoRayGround ;# radio-propagation model set val(netif) Phy/WirelessPhy ;# network interface type set val(mac) Mac/802_11 ;# MAC type set val(ifq) Queue/DropTail/PriQueue ;# interface queue type set val(ll) LL ;# link layer type set val(ant) Antenna/OmniAntenna ;# antenna model set val(ifqlen) 50 ;# max packet in ifq set val(nn) 9 ;# number of mobilenodes set val(rp) ENFAT ;# routing protocol set val(energymodel) EnergyModel ; set val(initialenergy) 100 ; # ====================================================================== # Main Program # ====================================================================== # # Initialize Global Variables # set ns_ [new Simulator] set tracefd [open simple.tr w] $ns_ trace-all $tracefd set Time [open time.tr w] set cwnd1 [open cwnd1.tr w] set b1 [open b1.tr w] # set up topography object set topo [new Topography] set namfile [open ENFAT.nam w] $topo load_flatgrid 3000 1600 $ns_ namtrace-all $namfile set wireless_tracefile [open ENFAT.trace w] set topography [new Topography] $ns_ trace-all $wireless_tracefile $ns_ namtrace-all-wireless $namfile 500 500 # # Create God # create-god $val(nn) global TN set TN 8 # # Create the specified number of mobilenodes [$val(nn)] and "attach" them # to the channel. # Here two nodes are created : node(0) and node(1) # configure node $ns_ node-config -adhocRouting $val(rp) \ -llType $val(ll) \ -macType $val(mac) \ -ifqType $val(ifq) \ -ifqLen $val(ifqlen) \ -antType $val(ant) \ -propType $val(prop) \ -phyType $val(netif) \ -channelType $val(chan) \ -topoInstance $topo \ -agentTrace ON \ -routerTrace ON \ -macTrace OFF \ -movementTrace OFF \ -energyModel $val(energymodel) \ -initialEnergy $val(initialenergy) \ -rxPower 35.28e-3 \ -txPower 712e-6 \ -sleepPower 144e-9 for {set i 0} {$i < $val(nn) } {incr i} { set node_($i) [$ns_ node] $node_($i) random-motion 0 ;# disable random motion } for {set j 0} {$j < $TN} {incr j} { set Tcp($j) [new Agent/TCP] $ns_ attach-agent $node_($j) $Tcp($j) $ns_ color 1 "black" $Tcp($j) set fid_ $j $Tcp($j) set packetSize_ 512 $Tcp($j) set window_ 20 $Tcp($j) set windowInit_ 1 $Tcp($j) set maxcwnd_ 0 #Set TCPSink set TcpSink($j) [new Agent/TCPSink] $ns_ attach-agent $node_($j) $TcpSink($j) $TcpSink($j) set packetSize_ 210 #Set Trafic Source set Ftp($j) [new Application/FTP] $Ftp($j) attach-agent $Tcp($j) } # # Provide initial (X,Y, for now Z=0) co-ordinates for mobilenodes # set x1 200 set y1 400 set x2 400 set y2 600 set x3 400 set y3 400 set x4 400 set y4 300 set x5 600 set y5 600 set x6 600 set y6 400 set x7 600 set y7 300 set x8 800 set y8 400 #Setting node position block for {set i 0} {$i < $TN} {incr i} { set node($i) [$ns_ node] $node($i) random-motion 0 $ns_ at 0.0 "$node($i) label Node_($i)" $ns_ initial_node_pos $node($i) 50.000000 } for {set j 0} {$j < $TN} {incr j} { set Tcp($j) [new Agent/TCP] $ns_ attach-agent $node($j) $Tcp($j) $ns_ color 1 "black" $Tcp($j) set fid_ $j $Tcp($j) set packetSize_ 512 $Tcp($j) set window_ 20 $Tcp($j) set windowInit_ 1 $Tcp($j) set maxcwnd_ 0 #Set TCPSink set TcpSink($j) [new Agent/TCPSink] $ns_ attach-agent $node($j) $TcpSink($j) $TcpSink($j) set packetSize_ 210 #Set Trafic Source set Ftp($j) [new Application/FTP] $Ftp($j) attach-agent $Tcp($j) $Ftp($j) set maxpkts_ 2048 } for {set j1 0} {$j1 < $TN} {incr j1 7} { incr x1 0 incr y1 15 $node($j1) set X_ $x1 $node($j1) set Y_ $y1 $node($j1) set Z_ 0 $node($j1) color "blue" $ns_ at 0.000000 "$node($j1) setdest $x1 $y1 0.00" } for {set j2 1} {$j2 < $TN} {incr j2 7} { incr x2 0 incr y2 14 $node($j2) set X_ $x2 $node($j2) set Y_ $y2 $node($j2) set Z_ 0 $node($j2) color "blue" $ns_ at 0.000000 "$node($j2) setdest $x2 $y2 0.00" } for {set j3 2} {$j3 < $TN} {incr j3 7} { incr x3 0 incr y3 14 $node($j3) set X_ $x3 $node($j3) set Y_ $y3 $node($j3) set Z_ 0 $node($j3) color "red" $ns_ at 0.000000 "$node($j3) setdest $x3 $y3 0.00" } for {set j4 3} {$j4 < $TN} {incr j4 7} { incr x4 0 incr y4 15 $node($j4) set X_ $x4 $node($j4) set Y_ $y4 $node($j4) set Z_ 0 $node($j4) color "blue" } for {set j5 4} {$j5 < $TN} {incr j5 7} { incr x5 0 incr y5 14 $node($j5) set X_ $x5 $node($j5) set Y_ $y5 $node($j5) set Z_ 0 $node($j5) color "black" $ns_ at 0.000000 "$node($j5) setdest $x5 $y5 0.00" } for {set j6 5} {$j6 < $TN} {incr j6 7} { incr x6 0 incr y6 15 $node($j6) set X_ $x6 $node($j6) set Y_ $y6 $node($j6) set Z_ 0 $node($j6) color "blue" $ns_ at 0.000000 "$node($j6) setdest $x6 $y6 0.00" } # set initial energy for second node $ns_ node-config -initialEnergy 0.500000001 set node_(5) [$ns_ node] for {set j7 6} {$j7 < $TN} {incr j7 7} { incr x7 0 incr y7 14 $node($j7) set X_ $x7 $node($j7) set Y_ $y7 $node($j7) set Z_ 0 $node($j7) color "blue" $ns_ at 0.000000 "$node($j7) setdest $x7 $y7 0.00" } for {set j8 7} {$j8 <= $TN} {incr j8 7} { incr x8 0 incr y8 15 $node($j8) set X_ $x8 $node($j8) set Y_ $y8 $node($j8) set Z_ 0 $node($j8) color "blue" $ns_ at 0.000000 "$node($j8) setdest $x8 $y8 0.00" } # Setup traffic flow between nodes # TCP connections between node_(0) and node_(1) $ns_ connect $Tcp(0) $TcpSink(7) $ns_ at 0.020000 "$Ftp(0) start" # # Tell nodes when the simulation ends # for {set i 0} {$i < $val(nn) } {incr i} { $ns_ at 50.0 "$node_($i) reset"; } $ns_ at 50.0 "stop" $ns_ at 50.01 "puts \"NS EXITING...\" ; $ns_ halt" proc stop {} { global ns_ tracefd $ns_ flush-trace close $tracefd } puts "Starting Simulation..." $ns_ run please help me to get a solution, and thanks in advance