0% found this document useful (0 votes)
11 views

Lab Program 1

Uploaded by

shilpakv2024
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views

Lab Program 1

Uploaded by

shilpakv2024
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

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 tf [ open lab1.tr w ]


$ns trace-all $tf

set nf [ open lab1.nam w ]


$ns namtrace-all $nf

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

set null [new Agent/Null]


$ns attach-agent $n3 $null

$ns connect $udp0 $null

set cbr0 [new Application/Traffic/CBR]


$cbr0 attach-agent $udp0

$cbr0 set packetSize_ 10000MB


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

$ns connect $udp1 $null

set cbr1 [new Application/Traffic/CBR]


$cbr1 attach-agent $udp1

$cbr1 set packetSize_ 10000MB


$cbr1 set interval_ 0.05

$ns at 0.1 "$cbr0 start"


$ns at 0.1 "$cbr1 start"

$ns at 5.0 "finish"


$ns run

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

You might also like