?? simple_test.tcl
字號:
#Create a simulator objectset ns [new Simulator]#set ch [new Channel]#$ch set delay_ 1us#set mcl [new Classifier/Mac]#$ch target $mcl#Open a trace fileset nf [open out.nam w]$ns namtrace-all $nf#Define a 'finish' procedureproc finish {} { global ns nf $ns flush-trace close $nf# exec ../../../nam-1.0a10/nam out.nam & exit 0}#Create three nodesset n0 [$ns node]set n1 [$ns node]set n2 [$ns node]set n3 [$ns node]set n4 [$ns node]#Create a IEEE1394 'LAN'#set lan0 [$ns make-lan "$n0 $n1 $n2" 1Mb 10us LL/ieee1394 Queue/DropTail Mac/ieee1394]#set lan0 [$ns make-lan "$n0 $n1 $n2 $n3 $n4" 1Mb 10us LL Queue/DropTail Mac/802_3]#set lan0 [$ns make-lan "$n0 $n1 $n2" 1Mb 10us LL Queue/DropTail Mac/ieee1394]#set lan0 [$ns make-lan "$n0 $n1 $n2 $n3 $n4" 1Mb 10us LL/ieee1394 Queue/DropTail Mac/ieee1394 Classifier/Mac/ieee1394]#set lan0 [$ns make-lan "$n0 $n1 $n2 $n3 $n4" 1Mb 10us LL Queue/DropTail Mac Classifier/Mac/ieee1394]#set lan0 [$ns make-lan "$n0 $n1 $n2 $n3 $n4" 1Mb 1us LL Queue/DropTail Mac]#set lan0 [$ns make-lan "$n0 $n1 $n2 $n3 $n4" 1Mb 10us LL Queue/DropTail Mac/ieee1394] puts "$n0 $n1 $n2 $n3 $n4" set lan0 [$ns newLan "$n0 $n1 $n2 $n3 $n4" 10Mb 5us \ -llType LL -ifqType Queue/DropTail -macType Mac/802_3 \ -chanType Channel -phyType Phy/WiredPhy -mactrace false]#Connect the nodes with two links#$ns duplex-link $n0 $n1 1Mb 10ms DropTail#$ns duplex-link $n1 $n2 1Mb 10ms DropTail#Define a 'recv' function for the class 'Agent/ieee1394'Agent/ieee1394 instproc recv {from} { $self instvar node_ puts "node [$node_ id] received answer."}proc create-slan {num_nodes start_time end_time interval pkt_size} { global ns sink0 create-trace-files $num_nodes $start_time $end_time $interval $pkt_size for {set i 0} {$i < 5} {incr i} { set node($i) [$ns node] lappend nodelist $node($i) } # set n0 [$ns node]# set n1 [$ns node]# set n2 [$ns node]# set n3 [$ns node]# set n4 [$ns node] puts "$nodelist" set lan0 [$ns newLan "$nodelist" 10Mb 5us \ -llType LL -ifqType Queue/DropTail -macType Mac/802_3 \ -chanType Channel -phyType Phy/WiredPhy -mactrace false] #Create two ieee1394 agents and attach them to the nodes n0 and n2# set p0 [new Agent/ieee1394] set p0 [new Agent/LossMonitor] $ns attach-agent $node(0) $p0# set p1 [new Agent/ieee1394] set p1 [new Agent/UDP] $ns attach-agent $node(4) $p1 #Connect the two agents $ns connect $p0 $p1 #Schedule events $ns at 0.2 "$p1 send 500" $ns at 0.4 "$p1 send 400" $ns at 0.6 "$p1 send 500" $ns at 0.6 "$p1 send 400" return $lan0}#Create two ieee1394 agents and attach them to the nodes n0 and n2set p0 [new Agent/ieee1394]$ns attach-agent $n0 $p0set p1 [new Agent/ieee1394]$ns attach-agent $n4 $p1#Connect the two agents$ns connect $p0 $p1#Schedule events$ns at 0.2 "$p0 send"$ns at 0.4 "$p1 send"$ns at 0.6 "$p0 send"$ns at 0.6 "$p1 send"$ns at 1.0 "finish"#Run the simulation$ns run
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -