Monday, September 26, 2016

Program No 5

Measuring Network Performances ­ Bottleneck in the network Consider a dumbbell topology with eight nodes as shown as in the following figure. Consider nodes# 2 and 3 to be two routers   connecting   two   different   networks.   When   the bandwidth of the link 2­3 is much lower than the sum of bandwidths of the other links in the network, it act as a bottleneck. Assume node # 0 running a FTP application (over TCP) and sending data to node # 6. Node # 1 is sending CBR data node # 7. Assume all the links except 2­3 has a bandwidth of 1 Mb, propagation delay of 10ms and queue type as DropTail. (All are duplex links).  Tasks:   The link 2­3 has a propagation delay of 10 ms. Vary it's bandwidth from 0.5 Mb to 2.5 Mb in steps of 0.25Mb.    Compute the throughput for node # 3 in each case    Plot the throughput vs. bandwidth data in the "Cu stom Plot" section below    Based on the above plots, suggest what should be the recommended bandwidth of the link 2­3. Now, plot the end­to­ end delay between nodes 0 and 6 for the above chosen values of link 2­3  bandwidth. Revisit your previous answer (i.e. optimum bandwidth of link 2­3) based on these graphs.

TCL Script:

set ns [new Simulator]
set namfile [open ex_05a.nam w]
$ns namtrace-all $namfile

set tracefile [open ex_05a.tr w]
$ns trace-all $tracefile    
Agent/TCP set packetSize_ 1460

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 n7 [$ns node]

$n1 color blue
$n1 shape box
$n0 color red

$ns duplex-link $n0 $n2 1Mb 10ms DropTail
$ns duplex-link-op $n0 $n2 orient right-down
$ns duplex-link $n1 $n2 1Mb 10ms DropTail
$ns duplex-link-op $n1 $n2 orient right-up
$ns duplex-link $n2 $n3 0.5Mb 10ms DropTail
$ns duplex-link-op $n2 $n3 orient right
$ns duplex-link $n3 $n4 1Mb 10ms DropTail
$ns duplex-link-op $n3 $n4 orient right-up
$ns duplex-link $n3 $n5 1Mb 10ms DropTail
$ns duplex-link-op $n3 $n5 orient right-down
$ns duplex-link $n4 $n6 1Mb 10ms DropTail
$ns duplex-link-op $n4 $n6 orient right
$ns duplex-link $n5 $n7 1Mb 10ms DropTail
$ns duplex-link-op $n5 $n7 orient right

set tcp [new Agent/TCP]
$ns attach-agent $n0 $tcp

set sink [new Agent/TCPSink]
$ns attach-agent $n6 $sink
 
$ns connect $tcp $sink

set ftp [new Application/FTP]
$ftp attach-agent $tcp

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

set null [new Agent/Null]
$ns attach-agent $n7 $null

$ns connect $udp $null

$udp set class_ 1
$ns color 1 Blue
$tcp set class_ 2
$ns color 2 Red

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"
set filesize [expr 4*1024*1024]
$ns at 0.0 "$ftp send $filesize"

proc finish {}
{    
global ns namfile tracefile
$ns flush-trace
close $namfile
close $tracefile

exec nam ex_05a.nam &
exit 0
}

$ns at 100.0 "finish"
$ns run



Note:-  
In the underlined line put the bandwidth from 0.5Mb, 0.75Mb, 1.0Mb, 1.25Mb, 1.5Mb, 1.75Mb, 2.0Mb, 2.25Mb and 2.5Mb and execute the program.

Calculatin ThroughPut:

For every time you change the bandwidth execute the following code with this command in terminal:-  awk -f throughput.awk ex_05.tr

BEGIN

recvbytes = 0 starttime = $2 


if ( $1 == "r" && $4 == 3 && $6 >100) 

recvbytes += $6 endt = $2 


END

printf(" %f \n", ((recvbytes/(endt-starttime))* (8/(1024*1024)))) 
}

Calculatin Delay:

For every time you change the bandwidth execute the following code with this command in terminal:- awk -f delay.awk ex_05.tr

BEGIN

tdelay=0 count=0 pktid=-1 


if($1=="+" && $3==0 && $12>pktid) 

pktid=$12 sTime[pktid]=$2 

if($1=="r" && $4==6) 

pktid=$12 eTime[$12]=$2 count++ 

if($1=="d") 

eTime[$12]=-1 


END

for(i=0;i<pktid;i++)

delay[i]=eTime[i]-sTime[i] if(delay[i]>0) tdelay=tdelay+delay[i] 

print("%f\n",(tdelay/count)) 
}

1 comment: