set ns [ new Simulator ]
set trf [ open 1.tr w ]
$ns trace-all $trf
set namf [ open 1.nam w ]
$ns namtrace-all $namf
#以下代码用于创建节点。
set n0 [$ns node]
set n1 [$ns node]
set n2 [$ns node]
$ns color 1 "red"
$ns color 2 "green"
$n0 label "Source/udp0"
$n1 label "Source/udp1"
$n2 label “destination”
$ns duplex-link $n0 $n2 10Kb 100ms DropTail
$ns duplex-link $n1 $n2 5Mb 200ms DropTail
$ns set queue-limit $n0 $n2 10
set cbr1 [new Application/Traffic/CBR]
$cbr1 attach-agent $udp1
$udp0 set class_ 1
$udp1 set class_ 2
$ns connect $udp0 $null3
$ns connect $udp1 $null3
$cbr1 set packetSize_ 500Mb
$cbr1 set interval_ 0.001
proc finish { } {
global ns namf trf
$ns flush-trace
exec nam 1.nam &
close $trf
close $namf
exit 0
}
$ns at 0.1 "$cbr0 start"
$ns at 0.1 "$cbr1 start"
$ns at 10.0 "finish"
$ns run
答案 0 :(得分:0)
您需要设置代理,然后将其附加到节点
set udp0 [new Agent/UDP]
$ns attach-agent $n0 $udp0