You are on page 1of 6

IT315

14IT066

Practical: 10
Aim: Simulate the Below scenario and find out value of ?? i.e. there is no packet drop
prove it by supporting graph.

Set the following parameters for application traffic.


CBR1:
Packet size: 1500
Rate : 2.51
Total Simulation: 60 sec.

Program:
set ns [new Simulator]

$ns color 1 Blue


$ns color 2 Red

set nf [open 14IT066.nam w]


$ns namtrace-all $nf
set tf [open 14IT066.tr w]
$ns trace-all $tf
proc finish {} {
global ns nf
global tf
$ns flush-trace
close $nf
close $tf
#exec nam 14IT066.nam &
exit 0
}
set n0 [$ns node]
set n1 [$ns node]
set n2 [$ns node]
set n3 [$ns node]
set n4 [$ns node]
set n5 [$ns node]

#n0 to n2
$ns duplex-link $n0 $n2 10.0Mb 10ms DropTail
$ns queue-limit $n0 $n2 50
#n1 to n2
$ns duplex-link $n1 $n2 10.0Mb 10ms DropTail
$ns queue-limit $n1 $n2 50
#n2 to n3

CSPIT 1
IT315
14IT066

$ns duplex-link $n2 $n3 5.0Mb 10ms DropTail


$ns queue-limit $n2 $n3 200
#n3 to n4
$ns duplex-link $n3 $n4 10.0Mb 10ms DropTail
$ns queue-limit $n3 $n4 50
#n3 to n5
$ns duplex-link $n3 $n5 10.0Mb 10ms DropTail
$ns queue-limit $n3 $n5 50

$ns duplex-link-op $n2 $n0 orient left-up


$ns duplex-link-op $n2 $n1 orient left-down
$ns duplex-link-op $n2 $n3 orient right
$ns duplex-link-op $n3 $n4 orient right-up
$ns duplex-link-op $n3 $n5 orient right-down

set udp [new Agent/UDP]


$ns attach-agent $n1 $udp
$udp set fid_ 2

set cbr [new Application/Traffic/CBR]


$cbr attach-agent $udp
$cbr set type_ CBR
$cbr set packetSize_ 1500
$cbr set rate_ 2.51Mb
#$cbr set interval_ 0.05

set udp0 [new Agent/UDP]


$ns attach-agent $n0 $udp0
$udp set fid_ 1

set cbr0 [new Application/Traffic/CBR]


$cbr0 attach-agent $udp0
$cbr0 set type_ CBR
$cbr0 set packetSize_ 1500
$cbr0 set rate_ 2.51Mb
#$cbr0 set interval_ 0.05

set null [new Agent/Null]


$ns attach-agent $n5 $null
$ns connect $udp $null

set null0 [new Agent/Null]


$ns attach-agent $n4 $null0
$ns connect $udp0 $null0
$ns at 0.1 "$cbr start"
$ns at 0.2 "$cbr0 start"
$ns at 59.0 "$cbr0 stop"
$ns at 59.5 "$cbr stop"
$ns at 60.0 "finish"

CSPIT 2
IT315
14IT066

puts "CBR packet size = [$cbr set packet_size_]"


puts "CBR rate = [$cbr set rate_]"
puts "Time Interval = [$cbr0 set interval_]"
puts "Time Interval = [$cbr set interval_]"

$ns run

Output:

AWK Script: p9.awk


BEGIN{
a=0;
b=0;
}{
if( $1 == "r" ){
a=a+1;
}
else if( $1 == "d" ){
b=b+1;
}
}
END{
print "files received:" a;
print "files dropped:" b;
}

Out Put :

CSPIT 3
IT315
14IT066
AWK Script: jit10.awk
BEGIN {
recvdSize = 0
startTime = 1e6
stopTime = 0
r=0;
}
{

event = $1
time = $2
flow_id = $8
pkt_id = $12
pkt_size = $6
flow_t = $5

if (event == "+" || event == "s") {


if (time < startTime) {
startTime = time
}
sendTime[pkt_id] = time
this_flow = flow_t
}

if (event == "r" ) {
if (time > stopTime) {
stopTime = time

r++;
recvdSize += pkt_size

recvTime[pkt_id] = time
}

END {

delay = avg_delay = recvdNum = 0


for (i in recvTime) {
if (sendTime[i] == 0) {
printf("\nError in delay.awk: receiving a packet that wasn't sent
%g\n",i)
}
delay += recvTime[i] - sendTime[i]
recvdNum ++
}
if (recvdNum != 0) {

CSPIT 4
IT315
14IT066
avg_delay = delay / r
} else {
avg_delay = 0
}

jitter1 = 0
prev_time = delay = prev_delay = 0
prev_delay = -1
for (i=0; i<r; i++) {
if(recvTime[i] != 0) {
if(prev_time != 0) {
delay = recvTime[i] - prev_time
e2eDelay = recvTime[i] - sendTime[i]
if(delay < 0) delay = 0
if(prev_delay != -1) {
jitter1 += abs(e2eDelay - prev_e2eDelay)

}
prev_delay = delay
prev_e2eDelay = e2eDelay
}
prev_time = recvTime[i]

}
}
if (recvdNum != 0) {
jitter1 = jitter1*1000/r

printf("\n")
printf(" %15s: %f\n", "startTime", startTime)
printf(" %15s: %f\n", "stopTime", stopTime)
printf(" %15s: %g\n", "receivedPkts", r)
printf(" %15s: %g\n", "avgJitter[ms]", jitter1)

function abs(value) {
if (value < 0) value = 0-value
return value
}

CSPIT 5
IT315
14IT066
Output:

Xgraph:

TitleText: Drop vs Queue


XUnitText: Queue Size
YUnitText: DropPackets

"DROPTAIL"

285 10
255 30
224 50
209 60
179 80
149 100
0 200

Output:

Conclusion:
In this practical, weve learnt Droptail queueing mechanism.

CSPIT 6

You might also like