Suppose the above LAN is to be connected to the Internet. Add node # 7 into the network so that it act as the gateway. Connect node # 0 and # 7 with a 1 Mb wired link. Move the UDP source to node # 7.
TCL Script:
set ns [new Simulator]
set namfile [open ex_03at.nam w]
$ns namtrace-all $namfile
set tracefile [open ex_03at.tr w]
$ns trace-all $tracefile
set n0 [$ns node]
set n1 [$ns node]
set n2 [$ns node]
set n3 [$ns node]
set n4 [$ns node]
set n5 [$ns node]
set n6 [$ns node]
set n7 [$ns node]
set lan [$ns newLan "$n0 $n1 $n2 $n3 $n4 $n5 $n6" 100Mb 0.5ms LL Queue/DropTail Mac/802_3 Channel Phy/WiredPhy]
set udp [new Agent/UDP]
$ns attach-agent $n7 $udp
set null [new Agent/Null]
$ns attach-agent $n6 $null
$ns connect $udp $null
set cbr [new Application/Traffic/CBR]
$cbr set packetSize_ 500
$cbr set interval_ 0.005
$cbr attach-agent $udp
$ns at 0.0 "$cbr start"
$ns at 9.0 "$cbr stop"
proc finish {}
{
global ns namfile tracefile
$ns flush-trace
close $namfile
close $tracefile
exec nam ex_03at.nam &
exit 0
}
$ns duplex-link $n7 $n0 1Mb 10ms DropTail
$ns at 10.0 "finish"
$ns run
TCL Script:
set ns [new Simulator]
set namfile [open ex_03at.nam w]
$ns namtrace-all $namfile
set tracefile [open ex_03at.tr w]
$ns trace-all $tracefile
set n0 [$ns node]
set n1 [$ns node]
set n2 [$ns node]
set n3 [$ns node]
set n4 [$ns node]
set n5 [$ns node]
set n6 [$ns node]
set n7 [$ns node]
set lan [$ns newLan "$n0 $n1 $n2 $n3 $n4 $n5 $n6" 100Mb 0.5ms LL Queue/DropTail Mac/802_3 Channel Phy/WiredPhy]
set udp [new Agent/UDP]
$ns attach-agent $n7 $udp
set null [new Agent/Null]
$ns attach-agent $n6 $null
$ns connect $udp $null
set cbr [new Application/Traffic/CBR]
$cbr set packetSize_ 500
$cbr set interval_ 0.005
$cbr attach-agent $udp
$ns at 0.0 "$cbr start"
$ns at 9.0 "$cbr stop"
proc finish {}
{
global ns namfile tracefile
$ns flush-trace
close $namfile
close $tracefile
exec nam ex_03at.nam &
exit 0
}
$ns duplex-link $n7 $n0 1Mb 10ms DropTail
$ns at 10.0 "finish"
$ns run
No comments:
Post a Comment