?? ring.tcl
字號:
# tcl script for AntNet algorithm on ring topology of 3 nodes#number of nodesset sz 3#Create event Schedularset ns [ new Simulator ]#Open the Trace fileset tf [open antnet_trace.out w]$ns trace-all $tf#Create 3 nodesfor {set i 0} {$i < $sz} {incr i} { set n($i) [$ns node]}#Create links between the nodesfor {set i 0} {$i < $sz} {incr i} { for {set j 0} {$j < $sz} {incr j} { if {$i != $j} { $ns duplex-link $n($i) $n($j) 512Mb 155ms DropTail } }}#Create Antnet agentsfor {set i 0} {$i < $sz} {incr i} { set nn($i) [ new Agent/Antnet $i]}#Attach each node with Antnet agentfor {set i 0} {$i < $sz} {incr i} { $ns attach-agent $n($i) $nn($i)}#Create connection between the nodesfor {set i 0} {$i < $sz} {incr i} { for {set j 0} {$j < $sz} {incr j} { if {$i != $j} { $ns connect $nn($i) $nn($j) $ns connect $nn($j) $nn($i) } }}#Add neighborsfor {set j 1} {$j < $sz} {incr j} { $ns at now "$nn(0) add-neighbor $n(0) $n($j)"}$ns at now "$nn(0) add-neighbor $n(1) $n(2)"#Set parameters and start time for AntNet algorithmfor {set i 0} {$i < $sz} {incr i} { $nn($i) set num_nodes_ $sz $nn($i) set timer_ant_ 0.001 $nn($i) set r_factor_ 0.05 $ns at 1.0 "$nn($i) start"}#Set stop time for AntNet algorithmfor {set i 0} {$i < $sz} {incr i} { $ns at 3.0 "$nn($i) stop"}#Print routing tables generated by AntNetfor {set i 0} {$i < $sz} {incr i} { $ns at 4.5 "$nn($i) print_rtable"}# Final Wrap upproc Finish {} { global ns tf $ns flush-trace #Close the Trace file close $tf}$ns at 5.0 "Finish"# Start the simulator$ns run
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -