📄 test-suite-mcast.tcl
字号:
$ns multi-link-of-interfaces [list $node_(n5) $node_(n2) $node_(n3)] 1.5Mb 10ms DropTail $ns duplex-link $node_(n1) $node_(n2) 1.5Mb 10ms DropTail $ns duplex-link $node_(n4) $node_(n3) 1.5Mb 10ms DropTail $ns duplex-link $node_(n5) $node_(n0) 1.5Mb 10ms DropTail if {[$class info instprocs config] != ""} { $self config $ns }}Class NodeTopology/8nodes -superclass SkelTopologyNodeTopology/8nodes instproc init ns { $self next $self instvar node_ set node_(n0) [$ns node] set node_(n1) [$ns node] set node_(n2) [$ns node] set node_(n3) [$ns node] set node_(n4) [$ns node] set node_(n5) [$ns node] set node_(n6) [$ns node] set node_(n7) [$ns node]}Class Topology/net8a -superclass NodeTopology/8nodes# 8 node topology with nodes n2, n3, n4 and n5 on a LAN.## n0----n1 # | |# n2 n3# | |# --------------# | |# n4 n5# | |# n6 n7## All point-to-point links have 1.5Mbps Bandwidth, 10ms latency.#Topology/net8a instproc init ns { $self next $ns $self instvar node_ $ns multi-link-of-interfaces [list $node_(n2) $node_(n3) $node_(n4) $node_(n5)] 1.5Mb 10ms DropTail $ns duplex-link $node_(n0) $node_(n1) 1.5Mb 10ms DropTail $ns duplex-link $node_(n0) $node_(n2) 1.5Mb 10ms DropTail $ns duplex-link $node_(n1) $node_(n3) 1.5Mb 10ms DropTail $ns duplex-link $node_(n4) $node_(n6) 1.5Mb 10ms DropTail $ns duplex-link $node_(n5) $node_(n7) 1.5Mb 10ms DropTail if {[$class info instprocs config] != ""} { $self config $ns }}# Definition of test-suite tests# Testing group join/leave in a simple topologyClass Test/DM1 -superclass TestSuiteTest/DM1 instproc init topo { source ../mcast/DM.tcl $self instvar net_ defNet_ test_ set net_ $topo set defNet_ net4a set test_ DM1 $self next}Test/DM1 instproc run {} { $self instvar ns_ node_ testName_ set mproto DM set mrthandle [$ns_ mrtproto $mproto {}] set udp0 [new Agent/UDP] $ns_ attach-agent $node_(n1) $udp0 $udp0 set dst_ 0x8001 set cbr0 [new Application/Traffic/CBR] $cbr0 attach-agent $udp0 set udp1 [new Agent/UDP] $ns_ attach-agent $node_(n3) $udp1 $udp1 set dst_ 0x8002 $udp1 set class_ 1 set cbr1 [new Application/Traffic/CBR] $cbr1 attach-agent $udp1 set rcvr [new Agent/LossMonitor] $ns_ attach-agent $node_(n2) $rcvr $ns_ at 1.2 "$node_(n2) join-group $rcvr 0x8002" $ns_ at 1.25 "$node_(n2) leave-group $rcvr 0x8002" $ns_ at 1.3 "$node_(n2) join-group $rcvr 0x8002" $ns_ at 1.35 "$node_(n2) join-group $rcvr 0x8001" $ns_ at 1.0 "$cbr0 start" $ns_ at 1.1 "$cbr1 start" $ns_ at 1.8 "$self finish 4a-nam" $ns_ run}# Testing group join/leave in a richer topology. Testing rcvr join before# the source starts sending pkts to the group.Class Test/DM2 -superclass TestSuiteTest/DM2 instproc init topo { source ../mcast/DM.tcl $self instvar net_ defNet_ test_ set net_ $topo set defNet_ net6a set test_ DM2 $self next}Test/DM2 instproc run {} { $self instvar ns_ node_ testName_ ### Start multicast configuration DM set PruneTimeout 0.3 set mproto DM set mrthandle [$ns_ mrtproto $mproto {}] ### End of multicast config set udp0 [new Agent/UDP] $ns_ attach-agent $node_(n0) $udp0 $udp0 set dst_ 0x8002 set cbr0 [new Application/Traffic/CBR] $cbr0 attach-agent $udp0 set rcvr [new Agent/LossMonitor] $ns_ attach-agent $node_(n3) $rcvr $ns_ attach-agent $node_(n4) $rcvr $ns_ attach-agent $node_(n5) $rcvr $ns_ at 0.2 "$node_(n3) join-group $rcvr 0x8002" $ns_ at 0.4 "$node_(n4) join-group $rcvr 0x8002" $ns_ at 0.6 "$node_(n3) leave-group $rcvr 0x8002" $ns_ at 0.7 "$node_(n5) join-group $rcvr 0x8002" $ns_ at 0.95 "$node_(n3) join-group $rcvr 0x8002" $ns_ at 0.3 "$cbr0 start" $ns_ at 1.0 "$self finish 6a-nam" $ns_ run}#Same as DM2 but with dvmrp-like cache miss rulesClass Test/DM3 -superclass TestSuiteTest/DM3 instproc init topo { source ../mcast/DM.tcl $self instvar net_ defNet_ test_ set net_ $topo set defNet_ net6a set test_ DM3 $self next}Test/DM3 instproc run {} { $self instvar ns_ node_ testName_ ### Start multicast configuration DM set PruneTimeout 0.3 DM set CacheMissMode dvmrp set mproto DM set mrthandle [$ns_ mrtproto $mproto {}] ### End of multicast config set udp0 [new Agent/UDP] $ns_ attach-agent $node_(n0) $udp0 $udp0 set dst_ 0x8002 set cbr0 [new Application/Traffic/CBR] $cbr0 attach-agent $udp0 set rcvr [new Agent/LossMonitor] $ns_ attach-agent $node_(n3) $rcvr $ns_ attach-agent $node_(n4) $rcvr $ns_ attach-agent $node_(n5) $rcvr $ns_ at 0.2 "$node_(n3) join-group $rcvr 0x8002" $ns_ at 0.4 "$node_(n4) join-group $rcvr 0x8002" $ns_ at 0.6 "$node_(n3) leave-group $rcvr 0x8002" $ns_ at 0.7 "$node_(n5) join-group $rcvr 0x8002" $ns_ at 0.95 "$node_(n3) join-group $rcvr 0x8002" $ns_ at 0.3 "$cbr0 start" $ns_ at 1.0 "$self finish 6a-nam" $ns_ run}# Testing dynamics of links going up/down.Class Test/DM4 -superclass TestSuiteTest/DM4 instproc init topo { source ../mcast/DM.tcl $self instvar net_ defNet_ test_ set net_ $topo set defNet_ net6a set test_ DM4 $self next}Test/DM4 instproc run {} { $self instvar ns_ node_ testName_ $ns_ rtproto Session ### Start multicast configuration DM set PruneTimeout 0.3 set mproto DM set mrthandle [$ns_ mrtproto $mproto {}] ### End of multicast config set udp0 [new Agent/UDP] $ns_ attach-agent $node_(n0) $udp0 $udp0 set dst_ 0x8002 set cbr0 [new Application/Traffic/CBR] $cbr0 attach-agent $udp0 set rcvr [new Agent/LossMonitor] $ns_ attach-agent $node_(n3) $rcvr $ns_ attach-agent $node_(n4) $rcvr $ns_ attach-agent $node_(n5) $rcvr $ns_ at 0.2 "$node_(n3) join-group $rcvr 0x8002" $ns_ at 0.4 "$node_(n4) join-group $rcvr 0x8002" $ns_ at 0.6 "$node_(n3) leave-group $rcvr 0x8002" $ns_ at 0.7 "$node_(n5) join-group $rcvr 0x8002" $ns_ at 0.8 "$node_(n3) join-group $rcvr 0x8002" #### Link between n0 & n1 down at 1.0, up at 1.2 $ns_ rtmodel-at 1.0 down $node_(n0) $node_(n1) $ns_ rtmodel-at 1.2 up $node_(n0) $node_(n1) #### $ns_ at 0.1 "$cbr0 start" $ns_ at 1.6 "$self finish 6a-nam" $ns_ run}# testing lan topologies#Class Test/DM5 -superclass TestSuite#Test/DM5 instproc init topo { #source ../mcast/DM.tcl #$self instvar net_ defNet_ test_ #set net_ $topo #set defNet_ net5e #set test_ DM5 #$self next#}#Test/DM5 instproc run {} { #$self instvar ns_ node_ testName_ #$ns_ rtproto Session #### Start multicast configuration #DM set PruneTimeout 0.3 #DM set CacheMissMode dvmrp #set mproto DM #set mrthandle [$ns_ mrtproto $mproto {}] ### End of multicast config #set udp0 [new Agent/UDP] #$ns_ attach-agent $node_(n4) $udp0 #$udp0 set dst_ 0x8002 #set cbr0 [new Application/Traffic/CBR] #$cbr0 attach-agent $udp0 #set rcvr [new Agent/LossMonitor] #$ns_ attach-agent $node_(n0) $rcvr #$ns_ attach-agent $node_(n1) $rcvr #$ns_ attach-agent $node_(n2) $rcvr #$ns_ at 0.2 "$node_(n0) join-group $rcvr 0x8002" #$ns_ at 0.3 "$node_(n1) join-group $rcvr 0x8002" #$ns_ at 0.4 "$node_(n1) leave-group $rcvr 0x8002" #$ns_ at 0.5 "$node_(n2) join-group $rcvr 0x8002" #$ns_ at 0.6 "$node_(n2) leave-group $rcvr 0x8002" #$ns_ at 0.7 "$node_(n0) leave-group $rcvr 0x8002" #### #$ns_ at 0.1 "$cbr0 start"# #$ns_ at 0.11 "$node_(n4) dump-routes stdout"# #$ns_ at 0.25 "$node_(n0) dump-routes stdout" #$ns_ at 1.0 "$self finish 5e-nam" #$ns_ run#}# Testing group join/leave in a simple topology, changing the RP set. # The RP node also has a source.Class Test/CtrMcast1 -superclass TestSuiteTest/CtrMcast1 instproc init topo { source ../ctr-mcast/CtrMcast.tcl $self instvar net_ defNet_ test_ set net_ $topo set defNet_ net4a set test_ CtrMcast1 $self next}# source and RP on same nodeTest/CtrMcast1 instproc run {} { $self instvar ns_ node_ testName_ set mproto CtrMcast set mrthandle [$ns_ mrtproto $mproto {}] set rp [list $node_(n2)] $mrthandle set_c_rp $rp set udp1 [new Agent/UDP] $ns_ attach-agent $node_(n2) $udp1 set grp [Node allocaddr] $udp1 set dst_ $grp $udp1 set class_ 1 ##$udp1 set dst_ 0x8003 set cbr1 [new Application/Traffic/CBR] $cbr1 attach-agent $udp1 set udp2 [new Agent/UDP] $ns_ attach-agent $node_(n3) $udp2 $udp2 set dst_ $grp $udp2 set class_ 2 ##$udp2 set dst_ 0x8003 set cbr2 [new Application/Traffic/CBR] $cbr2 attach-agent $udp2 set rcvr0 [new Agent/Null] $ns_ attach-agent $node_(n0) $rcvr0 set rcvr1 [new Agent/Null] $ns_ attach-agent $node_(n1) $rcvr1 set rcvr2 [new Agent/Null] $ns_ attach-agent $node_(n2) $rcvr2 set rcvr3 [new Agent/Null] $ns_ attach-agent $node_(n3) $rcvr3 $ns_ at 0.2 "$cbr1 start" $ns_ at 0.25 "$cbr2 start" $ns_ at 0.3 "$node_(n1) join-group $rcvr1 $grp" $ns_ at 0.4 "$node_(n0) join-group $rcvr0 $grp" $ns_ at 0.45 "$mrthandle switch-treetype $grp" $ns_ at 0.5 "$node_(n3) join-group $rcvr3 $grp" $ns_ at 0.65 "$node_(n2) join-group $rcvr2 $grp" $ns_ at 0.7 "$node_(n0) leave-group $rcvr0 $grp" $ns_ at 0.8 "$node_(n2) leave-group $rcvr2 $grp" $ns_ at 0.9 "$node_(n3) leave-group $rcvr3 $grp" $ns_ at 1.0 "$node_(n1) leave-group $rcvr1 $grp" $ns_ at 1.1 "$node_(n1) join-group $rcvr1 $grp" $ns_ at 1.2 "$self finish 4a-nam" $ns_ run}# Testing performance in the presence of dynamics. Also testing a rcvr joining# a group before the src starts sending pkts to the group.Class Test/CtrMcast2 -superclass TestSuiteTest/CtrMcast2 instproc init topo { $self instvar net_ defNet_ test_ set net_ $topo set defNet_ net6a set test_ CtrMcast2 $self next}Test/CtrMcast2 instproc run {} { $self instvar ns_ node_ testName_ $ns_ rtproto Session set mproto CtrMcast set mrthandle [$ns_ mrtproto $mproto {}] set udp0 [new Agent/UDP] $ns_ attach-agent $node_(n0) $udp0 $udp0 set dst_ 0x8003 $udp0 set class_ 1 set cbr0 [new Application/Traffic/CBR] $cbr0 attach-agent $udp0 set rcvr [new Agent/Null] $ns_ attach-agent $node_(n3) $rcvr $ns_ attach-agent $node_(n4) $rcvr $ns_ attach-agent $node_(n5) $rcvr $ns_ at 0.3 "$node_(n3) join-group $rcvr 0x8003" $ns_ at 0.35 "$cbr0 start" $ns_ at 0.4 "$node_(n4) join-group $rcvr 0x8003" $ns_ at 0.5 "$node_(n5) join-group $rcvr 0x8003" ### Link between n2 & n4 down at 0.6, up at 1.2 $ns_ rtmodel-at 0.6 down $node_(n2) $node_(n4) $ns_ rtmodel-at 0.8 up $node_(n2) $node_(n4) ### $ns_ at 1.2 "$mrthandle switch-treetype 0x8003" ### Link between n0 & n1 down at 1.5, up at 2.0 $ns_ rtmodel-at 1.0 down $node_(n0) $node_(n1) $ns_ rtmodel-at 1.4 up $node_(n0) $node_(n1) ### $ns_ at 1.5 "$self finish 6a-nam" $ns_ run}# Testing dynamics of joining and leaving for shared treeClass Test/ST1 -superclass TestSuiteTest/ST1 instproc init topo { source ../mcast/ST.tcl global quiet if { $quiet } { ST instproc dbg arg {} } $self instvar net_ defNet_ test_ set net_ $topo set defNet_ net6a set test_ ST1 $self next}Test/ST1 instproc run {} { $self instvar ns_ node_ testName_ set udp3 [new Agent/UDP] $ns_ attach-agent $node_(n3) $udp3 $udp3 set dst_ 0x8002 set cbr3 [new Application/Traffic/CBR] $cbr3 attach-agent $udp3 $cbr3 set interval_ 30ms set rcvr2 [new Agent/LossMonitor] set rcvr4 [new Agent/LossMonitor] set rcvr5 [new Agent/LossMonitor] $ns_ attach-agent $node_(n2) $rcvr2 $ns_ attach-agent $node_(n4) $rcvr4 $ns_ attach-agent $node_(n5) $rcvr5 ### Start multicast configuration ST set RP_(0x8002) $node_(n0) $ns_ mrtproto ST "" ### End of multicast config $ns_ at 0.1 "$cbr3 start" $ns_ at 0.2 "$node_(n2) join-group $rcvr2 0x8002" $ns_ at 0.4 "$node_(n4) join-group $rcvr4 0x8002" $ns_ at 0.6 "$node_(n2) leave-group $rcvr2 0x8002" $ns_ at 0.7 "$node_(n5) join-group $rcvr5 0x8002" $ns_ at 0.8 "$node_(n2) join-group $rcvr2 0x8002" #### $ns_ at 1.6 "$self finish 6a-nam" $ns_ run}TestSuite runTest### Local Variables:### mode: tcl### tcl-indent-level: 8### tcl-default-application: ns### End:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -