Documente Academic
Documente Profesional
Documente Cultură
Note: Multiple spaces are used in the program to improve readability. Use single spaces for
execution.
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.
exec nam program1.nam & “close” - closes the trace files defined before
set n0 [$ns node] Creates a node pointed by “n0”. To refer this node
set n1 [$ns node] in the script, we should use “$n0”
set n2 [$ns node] $n0 and $n2 are connected using bidirectional link with
set n3 [$ns node] bandwidth = 200 Mb, Propagation delay=10ms, Droptail –
the way to handle buffer overflow. If there is an overflow,
last packet to arrive is dropped.
$ns duplex-link $n0 $n2 200Mb 10ms DropTail
$ns queue-limit $n0 $n2 10 Buffer capacity from node 0 to node 2 = 10 packets
set udp0 [new Agent/UDP] Create a UDP agent, assign it a name “udp0”
gedit program1.awk
BEGIN { c=0;
}
{
if ($1=="d")
{
c++;
printf("%s\t %s\n",$5,$11);
}
}
END{
printf("The number of packets dropped =%d\n",c);
}
Execution Commands:
ns program1.tcl
awk -f program1.awk program1.tr
gedit program2.tcl
set ns [new Simulator]
set nf [open program2.nam w]
$ns namtrace-all $nf
set tf [open program2.tr w]
$ns trace-all $tf
$n4 shape box Square shape for node 4. By default, nodes are circular shaped
set p1 [new Agent/Ping] Create a ping agent ‘p1’ and attach it to node 0.
$ns attach-agent $n0 $p1 Ping is a subclass of class Agent. It ensures that a
host computer the user is trying to reach is
$p1 set packetSize_ 50000
actually operating by sending an ICMP echo
$p1 set interval_ 0.0001 request and waits for a reply.
$ns queue-limit $n0 $n4 5 node_ - To get the node ID for the node the
$ns queue-limit $n2 $n4 3 agent is attached to. It is a member variable of
the base class ‘Agent’
$ns queue-limit $n4 $n5 2
instproc recv allows the user to react to the ping
result
proc finish { } {
global ns nf tf
$ns flush-trace
close $nf
close $tf
exec nam program2.nam &
exit 0
}
gedit program2.awk
BEGIN{
drop=0;
}
{
if($1=="d")
{
drop++;
}
}END{
printf("total number of %s packets dropped due to congestion= %d \n",$5,drop);
}
Execution Commands:
ns program2.tcl
awk -f program2.awk program2.tr
3. Implement an Ethernet LAN using n nodes and set multiple traffic nodes and plot
gedit program3.tcl
set ns [new Simulator]
set tf [open program3.tr w]
$ns trace-all $tf
set nf [open program3.nam w]
$ns namtrace-all $nf
$ns make-lan "$n0 $n1 $n2 $n3 $n4" 100Mb 100ms LL Queue/DropTail Mac/802_3
set sink5 [new Agent/TCPSink] Create a TCP sink agent sink5 which act as
traffic sink (receiver)
$ns attach-agent $n5 $sink5 Attach it to node n5
$ns connect $tcp0 $sink5 Connect two agents with each other
Execution Commands:
ns program3.tcl
awk -f program3.awk file1.tr > a1
awk -f program3.awk file2.tr > a2
xgraph a1 a2
4. Implement simple ESS and with transmitting nodes in wire-less LAN by simulation and
determine the performance with respect to transmission of packets.
gedit program4.tcl
set ns [new Simulator]
set tf [open program4.tr w]
$ns trace-all $tf
-channelType Channel/WirelessChannel\
-propType Propagation/TwoRayGround\ TwoRayGround – The phenomenon of
reflection from the ground and the
-antType Antenna/OmniAntenna\ antenna heights above the ground is
-topoInstance $topo\ considered in addition to Line-of-Sight
(LOS) path between the transmitter and
-agentTrace ON\
the receiver.
-routerTrace ON
proc finish { } {
global ns nf tf
$ns flush-trace
exec nam program4.nam &
close $tf
exit 0
}
gedit program4.awk
BEGIN{
count1=0 count2=0 pack1=0 pack2=0 time1=0 time2=0
}
{
if($1=="r" && $3=="_1_" && $4=="AGT")
{
count1++
pack1=pack1+$8
time1=$2
}
if($1=="r" && $3=="_2_" && $4=="AGT")
{
count2++
pack2=pack2+$8
time2=$2
}
}
END{
printf("The throughput from n0 to n1 : %f Mbps \n " , ( (count1*pack1*8) /
(time1*1000000) ) );
printf("The throughput from n0 to n2 : %f Mbps \n " , ( (count2*pack2*8) /
(time2*1000000) ) );
}
Execution Commands:
ns program4.tcl
awk -f program4.awk program4.tr
5. Implement and study the performance of GSM on NS2/NS3 (Using MAC layer) or
equivalent environment.
gedit program5.tcl
bwDL – Down Link Bandwidth in bps- from the Base
Station to the Mobile Station (downlink)
set bwDL(gsm) 9600
bwUL – Up Link Bandwidth - from the Mobile Station
set bwUL(gsm) 9600 to the Base Station (uplink)
set propDL(gsm) .500
propDL – Downlink Propagation Delay in seconds
set propUL(gsm) .500
propUL – Uplink Propagation Delay
set buf(gsm) 10
Source
set tcp [new Agent/TCP]
$ns attach-agent $nodes(c1) $tcp
proc End {} {
global ns nt
$ns flush-trace
close $nt
exec awk -f program5.awk program5.tr &
exec xgraph -P -bar -x TIME -y DATA gsm.xg &
exit 0
Plot Bar graph,
} label for x –axis is “TIME”
label for y-axis is “DATA”
Read the data from the file “gsm.xg”
$ns at 0.0 "$ftp start"
$ns at 10.0 "End"
$ns run
gedit program5.awk
BEGIN {Total_no_of_pkts=0;
}
Shylaja B, Asst. Prof, Dept of CSE, DSATM 19 2019-20
Computer Networks Lab (17CSL57)
{
if($1 == "r")
{
Total_no_of_pkts = Total_no_of_pkts + $6;
printf(" %f %d \n",$2,Total_no_of_pkts) >> "gsm.xg"
}
}
END{
}
Execution Commands:
ns program5.tcl
6. Implement and study the performance of CDMA on NS2/NS3 (Using stack called Call
net) or equivalent environment.
gedit program6.tcl
proc cell_topo {} {
global ns nodes
$ns duplex-link $nodes(c1) $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(c2) 3Mbps 50ms DropTail
}
switch umts {
cdma -
umts {cell_topo}
}
proc End {} {
global ns nt
$ns flush-trace
close $nt
exec awk -f program6.awk program6.tr &
exec xgraph -P -bar -x TIME -y DATA cdma.xg &
exit 0
}
gedit program6.awk
BEGIN {Total_no_of_pkts=0;}
{
if($1 == "r")
{
Total_no_of_pkts = Total_no_of_pkts + $6;
printf(" %f %d \n",$2,Total_no_of_pkts) >> "cdma.xg"
}
}
END{}
Execution Commands:
ns program6.tcl