?? ctr.tcl
字號:
set ns [new Simulator]$ns multicastset f [open out.tr w]$ns trace-all $f$ns namtrace-all [open out.nam w]$ns color 1 red# the nam colors for the prune packets$ns color 30 purple# the nam colors for the graft packets$ns color 31 green# allocate a multicast address;set group [Node allocaddr] # nod is the number of nodesset nod 6 # create multicast capable nodes;for {set i 1} {$i <= $nod} {incr i} { set n($i) [$ns node] }#Create links between the nodes$ns duplex-link $n(1) $n(2) 0.3Mb 10ms DropTail $ns duplex-link $n(2) $n(3) 0.3Mb 10ms DropTail$ns duplex-link $n(2) $n(4) 0.5Mb 10ms DropTail$ns duplex-link $n(2) $n(5) 0.3Mb 10ms DropTail$ns duplex-link $n(3) $n(4) 0.3Mb 10ms DropTail$ns duplex-link $n(4) $n(5) 0.5Mb 10ms DropTail$ns duplex-link $n(4) $n(6) 0.5Mb 10ms DropTail$ns duplex-link $n(5) $n(6) 0.5Mb 10ms DropTail# configure multicast protocol;set mproto CtrMcast# all nodes will contain multicast protocol agents;set mrthandle [$ns mrtproto $mproto] # set RV and bootstrap points$mrthandle set_c_rp $n(5)# $mrthandle set_c_bsr $n(1):0 $n(3):1set udp1 [new Agent/UDP] set udp2 [new Agent/UDP] $ns attach-agent $n(1) $udp1$ns attach-agent $n(2) $udp2set src1 [new Application/Traffic/CBR]$src1 attach-agent $udp1$udp1 set dst_addr_ $group$udp1 set dst_port_ 0$src1 set random_ falseset src2 [new Application/Traffic/CBR]$src2 attach-agent $udp2$udp2 set dst_addr_ $group$udp2 set dst_port_ 1$src2 set random_ false# create receiver agentsset rcvr [new Agent/LossMonitor] # joining and leaving the group;$ns at 0.6 "$n(3) join-group $rcvr $group"$ns at 1.3 "$n(4) join-group $rcvr $group"$ns at 1.6 "$n(5) join-group $rcvr $group"$ns at 1.9 "$n(4) leave-group $rcvr $group"$ns at 2.3 "$n(6) join-group $rcvr $group"$ns at 3.5 "$n(3) leave-group $rcvr $group"$ns at 0.4 "$src1 start"$ns at 2.0 "$src2 start"$ns at 4.0 "finish"proc finish {} { global ns $ns flush-trace exec nam out.nam & exit 0}$ns run
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -