⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pimdm.tcl

📁 NS的一些例子
💻 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 DM                                # all nodes will contain multicast protocol agents;set mrthandle [$ns mrtproto $mproto]         set 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 + -