$cbr2 attach-agent $udp2
$cbr2 set type_ CBR
$cbr2 set packet_size_ 300
$cbr2 set rate_ 1mb
$cbr2 set random_ false
set udp3 [new Agent/UDP]
$ns attach-agent $n3 $udp3
set null0 [new Agent/Null]
$ns attach-agent $n6 $null0
$ns connect $udp3 $null0
set cbr3 [new Application/Traffic/CBR]
$cbr3 attach-agent $udp3
$cbr3 set type_ CBR
$cbr3 set packet_size_ 300
$cbr3 set rate_ 1mb
$cbr3 set random_ false
set udp4 [new Agent/UDP]
$ns attach-agent $n4 $udp4
set null0 [new Agent/Null]
$ns attach-agent $n6 $null0
$ns connect $udp4 $null0
set cbr4 [new Application/Traffic/CBR]
$cbr4 attach-agent $udp4
$cbr4 set type_ CBR
$cbr4 set packet_size_ 300
$cbr4 set rate_ 1mb
$cbr4 set random_ false
#建立一个代理并且把它附加到节点n6
set sink0 [new Agent/LossMonitor]
$ns attach-agent $n6 $sink0
#把流量来源与接点相连接
$ns connect $udp0 $sink0
$ns connect $udp1 $sink0
$ns connect $udp2 $sink0
$ns connect $udp3 $sink0
$ns connect $udp4 $sink0
#设定CBR资料传送开始和结束时间
$ns at 0.1 "$cbr0 start"
$ns at 0.1 "$cbr1 start"
$ns at 0.1 "$cbr2 start"
$ns at 0.1 "$cbr3 start"
$ns at 0.1 "$cbr4 start"
$ns at 4.0 "$cbr4 stop"
$ns at 4.0 "$cbr3 stop"
$ns at 4.0 "$cbr2 stop"
$ns at 4.0 "$cbr1 stop"
$ns at 4.0 "$cbr0 stop"
#在模拟环境中,5秒后去呼叫finish来结束模拟
$ns at 5.0 "finish"
#执行模拟
$ns run
<< 上一页 [11] [12] [13] [14] [15] [16] [17] 下一页