Lab Program 1
Lab Program 1
Set the queue size, vary the bandwidth and find the number of packets dropped.
proc finish { } {
global ns nf tf
$ns flush-trace
close $tf
close $nf
exec nam lab1.nam &
exit 0
}
# The below code is used to create the nodes.
set n0 [$ns node]
set n1 [$ns node]
set n2 [$ns node]
set n3 [$ns node]
#Vary the below Bandwidth and see the number of packets dropped.
$ns duplex-link $n0 $n2 10Mb 300ms DropTail
$ns duplex-link $n1 $n2 10Mb 300ms DropTail
$ns duplex-link $n2 $n3 1Mb 300ms DropTail
#The below code is used to set the queue size b/w the nodes
$ns set queue-limit $n0 $n2 10
$ns set queue-limit $n1 $n2 10
$ns set queue-limit $n2 $n3 5
#The below code is used to attach an UDP agent to n0, UDP #agent to n1 and null agent
to n3.
set udp0 [new Agent/UDP]
$ns attach-agent $n0 $udp0
AWK Script:
BEGIN {
#include<stdio.h>
count=0;
}
{
if($1=="d") #d stands for the packets drops.
count++
}
END {
printf("The Total no of Packets Dropped due to Congestion : %d\n\n", count)
}
Link Bandwidth Packet Size Queue Size No. of Packets
(Mb) (MB) Dropped
N0-N2 10 10
N1-N2 10 10000 10
N2-N3 1 5
N0-N2 25 10
N1-N2 25 20000 10
N2-N3 8 5
N0-N2 50 10
N1-N2 50 35000 10
N2-N3 10 5