Program 1


1.Implement three nodes point to point network with duplex links between them. Set the queue size, vary the bandwidth and find the number of packets dropped.

set ns [new Simulator]
set nf [open lab1.nam w]
$ns namtrace-all $nf
set tf [open lab1.tr w]
$ns trace-all $tf


set n0 [$ns node]
set n1 [$ns node]
set n2 [$ns node]

$ns duplex-link $n0 $n2 100Mb 10ms DropTail
$ns duplex-link $n1 $n2 50Mb 5ms DropTail

$ns queue-limit $n0 $n2 50
$ns queue-limit $n1 $n2 50

set udp0 [new Agent/UDP]
$ns attach-agent $n0 $udp0

set cbr0 [new Application/Traffic/CBR]
$cbr0 set packetSize_ 500
$cbr0 set interval_ 0.0005
$cbr0 attach-agent $udp0

set udp1 [new Agent/UDP]
$ns attach-agent $n1 $udp1

set cbr1 [new Application/Traffic/CBR]
$cbr1 attach-agent $udp1

set null0 [new Agent/Null]
$ns attach-agent $n2 $null0

$ns connect $udp0 $null0
$ns connect $udp1 $null0

proc finish {} {
global ns tf nf
$ns flush-trace
close $nf
close $tf
exec nam lab1.nam &
exit 0
}

$ns at 0.1 "$cbr0 start"
$ns at 0.2 "$cbr0 stop"
$ns at 1 "finish"

$ns run
end

AWK file (Open a new editor using “gedit command” and write awk file and save with “.awk” extension)

BEGIN {
c=0;
}
{
if ($1=="d")
{
c++;
}
}
END {
printf ("Packets Dropped = %d",c);
}


No comments:

Post a Comment