Part - A
Setting up a local area network with ns2 In this exercise you will be simulating a CSMA/CD based LAN with ns2. Consider the LAN with seven nodes to be an isolated one i.e. not connected to the Internet. Node # 0 in the LAN act as a UDP traffic source, and node # 6 is the destination node. Assume CBR traffic to be flowing between the nodes. The simulation lasts for 25 seconds. In Ethernet a packet is broadcasted in the shared medium, and only the destination node accepts the packet. Other nodes simply drop it.
TCL Script:
set ns [new Simulator]
set namfile [open ex_03.nam w]
$ns namtrace-all $namfile
set tracefile [open ex_03.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 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 $n0 $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_03.nam &
exit 0
}
$ns at 0.25 "finish" $ns run
Setting up a local area network with ns2 In this exercise you will be simulating a CSMA/CD based LAN with ns2. Consider the LAN with seven nodes to be an isolated one i.e. not connected to the Internet. Node # 0 in the LAN act as a UDP traffic source, and node # 6 is the destination node. Assume CBR traffic to be flowing between the nodes. The simulation lasts for 25 seconds. In Ethernet a packet is broadcasted in the shared medium, and only the destination node accepts the packet. Other nodes simply drop it.
TCL Script:
set ns [new Simulator]
set namfile [open ex_03.nam w]
$ns namtrace-all $namfile
set tracefile [open ex_03.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 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 $n0 $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_03.nam &
exit 0
}
$ns at 0.25 "finish" $ns run
No comments:
Post a Comment