CN Final Part A
CN Final Part A
CN Final Part A
proc finish { } {
global ns nf tf
$ns flush-trace
close $nf
close $tf
exec nam PA1.nam &
exit 0
}
AWK FILE
BEGIN{
c=0;}
{
if($1=="d")
{ c++;
printf("%s\t%s\n",$5,$11);
}
}
END{
printf("The number of packets dropped =%d\n",c);
}
OUTPUT
2. Implement transmission of ping messages/trace route over a network
topology consisting of 6 nodes and find the number of packets dropped
due to congestion.
puts "node [$node_ id]received answer from $from with round trip
time $rtt msec"
proc finish { } {
global ns nf tf
$ns flush-trace
close $nf
close $tf
exit 0
BEGIN{
drop=0;
if($1=="d" )
drop++;
END{
Cnlab@sksjti:~$ ns lab2.tcl
AWK FILE
BEGIN {}
{
if($6=="cwnd_")
printf("%f\t%f\t\n",$1,$7);
}
END {
}
OUTPUT
4. Implement simple ESS and with transmitting nodes in wire-less LAN by
simulation and determine the performance with respect to transmission
of packets.
AWK FILE
BEGIN{
PktsSent=0;
PktsRcvd=0;
PktsAtRTR=0;
}
{
if(($1=="s")&&($4=="RTR")&&($7=="tcp"))
{
PktsAtRTR++;
}
if(($1=="s")&&($4=="AGT")&&($7=="tcp"))
{
PktsSent++;
}
if(($1=="r")&&($4=="AGT")&&($7=="tcp"))
{
PktsRcvd++;
}
}
END{
Cnlab@sksjti:~ ns lab4.tcl
Cnlab@sksjti:~ awk -f count.awk lab42.tr
Cnlab@sksjti:~ cat lab42.tr
OUTPUT
trace file
5. Implement and study the performance of GSM on NS2/NS3 (Using MAC layer)
or equivalent environment.
#General parameters
set stop 100
set type gsm
#AQM parameters
set minth 30
set maxth 0
set adaptive 1
#traffic generation
set flows 0
set window 30
#plotting statistics
set opt(wrap) 100
set opt(srcTrace) is
set opt(dstTrace) bs2
#default downlink bandwidth in bps
set bwDL(gsm) 9600
#default propogation delay in sec
set propDL(gsm) .500
set ns [new Simulator]
set tf [open Mlab5.tr w]
$ns trace-all $tf
set nodes(is) [$ns node]
set nodes(ms) [$ns node]
set nodes(bs1) [$ns node]
set nodes(bs2) [$ns node]
set nodes(lp) [$ns node]
proc cell_topo {} {
global ns nodes
$ns duplex-link $nodes(lp) $nodes(bs1) 3Mbps 10ms DropTail
$ns duplex-link $nodes(bs1) $nodes(ms) 1 1 RED
$ns duplex-link $nodes(ms) $nodes(bs2) 1 1 RED
$ns duplex-link $nodes(bs2) $nodes(is) 3Mbps 50ms DropTail
puts "GSM Cell Topology"
}
proc set_link_params {t} {
global ns nodes bwDL propDL
$ns bandwidth $nodes(bs1) $nodes(ms) $bwDL($t) duplex
$ns bandwidth $nodes(bs2) $nodes(ms) $bwDL($t) duplex
$ns delay $nodes(bs1) $nodes(ms) $propDL($t) duplex
$ns delay $nodes(bs2) $nodes(ms) $propDL($t) duplex
$ns queue-limit $nodes(bs1) $nodes(ms) 10
$ns queue-limit $nodes(bs2) $nodes(ms) 10
}
#RED and TCP parameters
Queue/RED set adaptive_ $adaptive
Queue/RED set thresh_ $minth
Queue/RED set maxthresh_ $maxth
Agent/TCP set window_ $window
#create topology
switch $type {
gsm -
umts {cell_topo}
}
set_link_params $type
$ns insert-delayer $nodes(ms) $nodes(bs1) [new Delayer]
$ns insert-delayer $nodes(ms) $nodes(bs2) [new Delayer]
# set up TCP connection
if {$flows == 0} {
set tcp1 [$ns create-connection TCP/Sack1 $nodes(is) TCPSink/Sack1 $nodes(lp) 0]
set ftp1 [[set tcp1] attach-app FTP]
$ns at 0.8 "[set ftp1] start"
}
proc stop {} {
global nodes opt tf
set wrap $opt(wrap)
set sid [$nodes($opt(srcTrace)) id]
set did [$nodes($opt(dstTrace)) id]
set a "Mlab5.tr"
set GETRC "../../../bin/getrc"
set RAW2XG "../../../bin/raw2xg"
exec $GETRC -s $sid -d $did -f 0 Mlab5.tr | \
$RAW2XG -s 0.01 -m $wrap -r > plot.xgr
exec $GETRC -s $did -d $sid -f 0 Mlab5.tr | \
$RAW2XG -a -s 0.01 -m $wrap >> plot.xgr
exec xgraph -x time -y packets plot.xgr &
exit 0
}
$ns at $stop "stop"
$ns run
OUTPUT
To see the trace file use command: cat Mlab5.tr
Trace File-
6. Implement and study the performance of CDMA on NS2/NS3 (Using stack
called Call net) or equivalent environment.
#General parameters
set stop 100
set type umts
#AQM parameters
set minth 30
set maxth 0
set adaptive 1
#traffic generation
set flows 0
set window 30
#plotting statistics
set opt(wrap) 100
set opt(srcTrace) is
set opt(dstTrace) bs2
#default downlink bandwidth in bps
set bwDL(umts) 38400
#default propogation delay in sec
set propDL(umts) .150
set ns [new Simulator]
set tf [open Mlab6.tr w]
$ns trace-all $tf
set nodes(is) [$ns node]
set nodes(ms) [$ns node]
set nodes(bs1) [$ns node]
set nodes(bs2) [$ns node]
set nodes(lp) [$ns node]
proc cell_topo {} {
global ns nodes
$ns duplex-link $nodes(lp) $nodes(bs1) 3Mbps 10ms DropTail
$ns duplex-link $nodes(bs1) $nodes(ms) 1 1 RED
$ns duplex-link $nodes(ms) $nodes(bs2) 1 1 RED
$ns duplex-link $nodes(bs2) $nodes(is) 3Mbps 50ms DropTail
puts "umts Cell Topology"
}
proc set_link_param {t} {
global ns nodes bwDL propDL
$ns bandwidth $nodes(bs1) $nodes(ms) $bwDL($t) duplex
$ns bandwidth $nodes(bs2) $nodes(ms) $bwDL($t) duplex
$ns delay $nodes(bs1) $nodes(ms) $propDL($t) duplex
$ns delay $nodes(bs2) $nodes(ms) $propDL($t) duplex
$ns queue-limit $nodes(bs1) $nodes(ms) 20
$ns queue-limit $nodes(bs2) $nodes(ms) 20
}
#set RED and TCP parameters
Queue/RED set adaptive_ $adaptive
Queue/RED set thresh_ $minth
Queue/RED set maxthresh_ $maxth
Agent/TCP set window_ $window
#create topology
switch $type {
umts {cell_topo}
}
set_link_param $type
$ns insert-delayer $nodes(ms) $nodes(bs1) [new Delayer]
$ns insert-delayer $nodes(ms) $nodes(bs2) [new Delayer]
#set up TCP connection
if {$flows == 0 } {
set tcp1 [$ns create-connection TCP/Sack1 $nodes(is) TCPSink/Sack1 $nodes(lp) 0]
set ftp1 [[set tcp1] attach-app FTP]
$ns at 0.8 "[set ftp1] start"
}
proc stop {} {
global nodes opt tf
set wrap $opt(wrap)
set sid [$nodes($opt(srcTrace)) id]
set did [$nodes($opt(dstTrace)) id]
set a "Mlab6.tr"
OUTPUT
Trace File-
..............................THE END................................