Sunteți pe pagina 1din 25

Computer Networks Lab (17CSL57)

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.

gedit program1.tcl Create a Simulator object and give it a name “ns”

Opens file program1.nam in “write” mode and assigns it a


set ns [new Simulator]
pointer “nf”

Record all simulation traces in NAM input format


set nf [open program1.nam w]
$ns namtrace-all $nf
Create a data trace file “program1.tr” & assign it a pointer “tf”

set tf [open program1.tr w]


$ns trace-all $tf The traces will go to the file program1.tr pointed by “tf”

“proc” - declares a procedure “finish”


proc finish {} {
“global” - tells that we are using variables declared outside
global ns nf tf the procedure.
$ns flush-trace “flush-trace” – a simulator method to dump the traces on
close $tf the respective files.

exec nam program1.nam & “close” - closes the trace files defined before

exit 0 “exec” executes the nam program for visualization.


} “exit 0” - ends the application and return the number 0
(clean exit) as status to the system.

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

Shylaja B, Asst. Prof, Dept of CSE, DSATM 1 2019-20


Computer Networks Lab (17CSL57)

$ns duplex-link $n1 $n2 100Mb 5ms DropTail


$ns duplex-link $n2 $n3 1Mb 1000ms DropTail

$ns queue-limit $n0 $n2 10 Buffer capacity from node 0 to node 2 = 10 packets

$ns queue-limit $n1 $n2 10

set udp0 [new Agent/UDP] Create a UDP agent, assign it a name “udp0”

$ns attach-agent $n0 $udp0 Attach $udp0 to node 0 ($n0)

For actual data to flow, we need traffic generators.


They simulate some application traffic. Ex: CBR
set cbr0 [new Application/Traffic/CBR]
Creating CBR (Constant Bit Rate) agent cbr0,
$cbr0 set packetSize_ 500 set the packet size, packet interval.
$cbr0 set interval_ 0.005
$cbr0 attach-agent $udp0 Attach the CBR agent $cbr0 to UDP agent $udp0.

set udp1 [new Agent/UDP]


$ns attach-agent $n1 $udp1
set cbr1 [new Application/Traffic/CBR]
$cbr1 attach-agent $udp1

set udp2 [new Agent/UDP]


$ns attach-agent $n2 $udp2
set cbr2 [new Application/Traffic/CBR]
$cbr2 attach-agent $udp2
Create a null agent null0 which acts as traffic sink
(receiver)
set null0 [new Agent/Null]
Attach null agent $null0 to node n3
$ns attach-agent $n3 $null0

In UDP communication, data flows from UDP


$ns connect $udp0 $null0 agent to Null agent. So connect udp agent to null
$ns connect $udp1 $null0 agent.

Shylaja B, Asst. Prof, Dept of CSE, DSATM 2 2019-20


Computer Networks Lab (17CSL57)

$ns at 0.1 "$cbr0 start"


Start the event scheduler
$ns at 0.2 "$cbr1 start"
$ns at 1.0 "finish" Call the finish procedure defined
earlier
$ns run
Begin the simulation

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

Shylaja B, Asst. Prof, Dept of CSE, DSATM 3 2019-20


Computer Networks Lab (17CSL57)

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.

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

set n0 [$ns node]


set n1 [$ns node]
set n2 [$ns node]
set n3 [$ns node]
set n4 [$ns node]
set n5 [$ns node]

$n4 shape box Square shape for node 4. By default, nodes are circular shaped

$ns duplex-link $n0 $n4 1005Mb 1ms DropTail


$ns duplex-link $n1 $n4 50Mb 1ms DropTail
$ns duplex-link $n2 $n4 2000Mb 1ms DropTail
$ns duplex-link $n3 $n4 200Mb 1ms DropTail
$ns duplex-link $n4 $n5 1Mb 1ms DropTail

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.

Shylaja B, Asst. Prof, Dept of CSE, DSATM 4 2019-20


Computer Networks Lab (17CSL57)

set p2 [new Agent/Ping]


$ns attach-agent $n1 $p2

set p3 [new Agent/Ping]


$ns attach-agent $n2 $p3
$p3 set packetSize_ 30000
$p3 set interval_ 0.00001

set p4 [new Agent/Ping]


$ns attach-agent $n3 $p4
instproc – adds class methods

$self – similar to “this” in java, C++ (Holds the


set p5 [new Agent/Ping] address of the current object)
$ns attach-agent $n5 $p5 instvar – adds instance variables and brings them
to the local scope

$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

Agent/Ping instproc recv {from rtt} {


$self instvar node_
puts "node [$node_ id] received answer from $from with round trip time $rtt msec"
}

$ns connect $p1 $p5


$ns connect $p3 $p4
$ns connect $p2 $p5

proc finish { } {
global ns nf tf

Shylaja B, Asst. Prof, Dept of CSE, DSATM 5 2019-20


Computer Networks Lab (17CSL57)

$ns flush-trace
close $nf
close $tf
exec nam program2.nam &
exit 0
}

$ns at 0.1 "$p1 send"


$ns at 0.2 "$p1 send"
$ns at 0.3 "$p1 send"
$ns at 0.4 "$p1 send"
$ns at 0.5 "$p1 send"
$ns at 0.6 "$p1 send"
$ns at 0.7 "$p1 send"
$ns at 0.8 "$p1 send"
$ns at 0.9 "$p1 send"
$ns at 1.0 "$p1 send"
$ns at 1.1 "$p1 send"
$ns at 1.2 "$p1 send"
$ns at 1.3 "$p1 send"
$ns at 1.4 "$p1 send"
$ns at 1.5 "$p1 send"
$ns at 1.6 "$p1 send"
$ns at 1.7 "$p1 send"
$ns at 1.8 "$p1 send"
$ns at 1.9 "$p1 send"
$ns at 2.0 "$p1 send"
$ns at 2.1 "$p1 send"
$ns at 2.2 "$p1 send"
$ns at 2.3 "$p1 send"
Shylaja B, Asst. Prof, Dept of CSE, DSATM 6 2019-20
Computer Networks Lab (17CSL57)

$ns at 2.4 "$p1 send"


$ns at 2.5 "$p1 send"
$ns at 2.6 "$p1 send"
$ns at 2.7 "$p1 send"
$ns at 2.8 "$p1 send"
$ns at 2.9 "$p1 send"
$ns at 0.1 "$p3 send"
$ns at 0.2 "$p3 send"
$ns at 0.3 "$p3 send"
$ns at 0.4 "$p3 send"
$ns at 0.5 "$p3 send"
$ns at 0.6 "$p3 send"
$ns at 0.7 "$p3 send"
$ns at 0.8 "$p3 send"
$ns at 0.9 "$p3 send"
$ns at 1.0 "$p3 send"
$ns at 1.1 "$p3 send"
$ns at 1.2 "$p3 send"
$ns at 1.3 "$p3 send"
$ns at 1.4 "$p3 send"
$ns at 1.5 "$p3 send"
$ns at 1.6 "$p3 send"
$ns at 1.7 "$p3 send"
$ns at 1.8 "$p3 send"
$ns at 1.9 "$p3 send"
$ns at 2.0 "$p3 send"
$ns at 2.1 "$p3 send"
$ns at 2.2 "$p3 send"
$ns at 2.3 "$p3 send"
$ns at 2.4 "$p3 send"
Shylaja B, Asst. Prof, Dept of CSE, DSATM 7 2019-20
Computer Networks Lab (17CSL57)

$ns at 2.5 "$p3 send"


$ns at 2.6 "$p3 send"
$ns at 2.7 "$p3 send"
$ns at 2.8 "$p3 send"
$ns at 2.9 "$p3 send"
$ns at 3.0 "finish"
$ns run

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

Shylaja B, Asst. Prof, Dept of CSE, DSATM 8 2019-20


Computer Networks Lab (17CSL57)

3. Implement an Ethernet LAN using n nodes and set multiple traffic nodes and plot

congestion window for different source / destination.

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

set n0 [$ns node]


$n0 color "magenta"
$n0 label "src1"

set n1 [$ns node]

set n2 [$ns node]


$n2 color "magenta"
$n2 label "src2"

set n3 [$ns node]


$n3 color "blue"
$n3 label "dest2"

set n4 [$ns node]

set n5 [$ns node]


$n5 color "blue" Creates a LAN from a set of nodes given by
<node_list>, Bandwidth, Delay, Link Layer,
$n5 label "dest1"
Interface Queue, MAC Layer

$ns make-lan "$n0 $n1 $n2 $n3 $n4" 100Mb 100ms LL Queue/DropTail Mac/802_3

$ns duplex-link $n4 $n5 1Mb 1ms DropTail

Shylaja B, Asst. Prof, Dept of CSE, DSATM 9 2019-20


Computer Networks Lab (17CSL57)

Create a TCP sending module tcp0


set tcp0 [new Agent/TCP]
Attach $tcp0 to node $n0
$ns attach-agent $n0 $tcp0

Create an FTP traffic generator, ftp0


set ftp0 [new Application/FTP]
$ftp0 attach-agent $tcp0 Attach $ftp0 to $tcp0

$ftp0 set packetSize_ 500


$ftp0 set interval_ 0.0001

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

set tcp2 [new Agent/TCP]


$ns attach-agent $n2 $tcp2
set ftp2 [new Application/FTP]
$ftp2 attach-agent $tcp2
$ftp2 set packetSize_ 600
$ftp2 set interval_ 0.001

set sink3 [new Agent/TCPSink]


$ns attach-agent $n3 $sink3

$ns connect $tcp2 $sink3

set file1 [open file1.tr w]


$tcp0 attach $file1

set file2 [open file2.tr w]


$tcp2 attach $file2

Shylaja B, Asst. Prof, Dept of CSE, DSATM 10 2019-20


Computer Networks Lab (17CSL57)

$tcp0 trace cwnd_ cwnd_ Contains Congestion Window


size of the TCP module
$tcp2 trace cwnd_
(Congestion Window – is a TCP state
proc finish { } { variable that limits the amount of
data the TCP can send into the
global ns nf tf
network before receiving an ACK)
$ns flush-trace
close $tf
close $nf
exec nam program3.nam &
exit 0
}
$ns at 0.1 "$ftp0 start"
$ns at 5 "$ftp0 stop"
$ns at 7 "$ftp0 start"
$ns at 0.2 "$ftp2 start"
$ns at 8 "$ftp2 stop"
$ns at 14 "$ftp0 stop"
$ns at 10 "$ftp2 start"
$ns at 15 "$ftp2 stop"
$ns at 16 "finish"
$ns run
gedit program3.awk
BEGIN {
}
{
if($6=="cwnd_")
printf("%f \t %f\t \n",$1,$7);
}
END{
}

Shylaja B, Asst. Prof, Dept of CSE, DSATM 11 2019-20


Computer Networks Lab (17CSL57)

Execution Commands:
 ns program3.tcl
 awk -f program3.awk file1.tr > a1
 awk -f program3.awk file2.tr > a2
 xgraph a1 a2

Shylaja B, Asst. Prof, Dept of CSE, DSATM 12 2019-20


Computer Networks Lab (17CSL57)

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

set topo [new Topography] Create a flat topology in a 1000 X 1000 m


$topo load_flatgrid 1000 1000 area

set nf [open p4.nam w]


$ns namtrace-all-wireless $nf 1000 1000
$ns node-config -adhocRouting DSDV\ Using Adhoc Routing Protocol DSDV (
Destination Sequence Distance
-llType LL\ Logical Link Vector)
-macType Mac/802_11\
-ifqType Queue/DropTail\
-ifqLen 50\ Queue Length

-phyType Phy/WirelessPhy\ Physical Layer Type

-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

god (General Operations Director ) is the object to


create-god 3 store global information about the state of the
environment, network or nodes.
set n0 [$ns node] value 3 – indicates the number of mobile nodes
set n1 [$ns node]
set n2 [$ns node]
Shylaja B, Asst. Prof, Dept of CSE, DSATM 13 2019-20
Computer Networks Lab (17CSL57)

$n0 label "tcp0"


$n1 label "sink1/tcp1"
$n2 label "sink2"

$n0 set X_ 50 Set the coordinates for node 0


$n0 set Y_ 50
$n0 set Z_ 0

$n1 set X_ 100


$n1 set Y_ 100
$n1 set Z_ 0

setdest – to generate the positions of nodes &


$n2 set X_ 600
their moving speed.
$n2 set Y_ 600
setdest 50 50 15 (X Y Speed in m/s)
$n2 set Z_ 0

$ns at 0.1 "$n0 setdest 50 50 15"


$ns at 0.1 "$n1 setdest 100 100 25"
$ns at 0.1 "$n2 setdest 600 600 25"

set tcp0 [new Agent/TCP]


$ns attach-agent $n0 $tcp0

set ftp0 [new Application/FTP]


$ftp0 attach-agent $tcp0

set sink1 [new Agent/TCPSink]


$ns attach-agent $n1 $sink1

Shylaja B, Asst. Prof, Dept of CSE, DSATM 14 2019-20


Computer Networks Lab (17CSL57)

$ns connect $tcp0 $sink1

set tcp1 [new Agent/TCP]


$ns attach-agent $n1 $tcp1

set ftp1 [new Application/FTP]


$ftp1 attach-agent $tcp1

set sink2 [new Agent/TCPSink]


$ns attach-agent $n2 $sink2

$ns connect $tcp1 $sink2

$ns at 5 "$ftp0 start"


$ns at 5 "$ftp1 start"
$ns at 100 "$n1 setdest 550 550 15"
$ns at 190 "$n1 setdest 70 70 15"

proc finish { } {
global ns nf tf
$ns flush-trace
exec nam program4.nam &
close $tf
exit 0
}

$ns at 250 "finish"


$ns run

Shylaja B, Asst. Prof, Dept of CSE, DSATM 15 2019-20


Computer Networks Lab (17CSL57)

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

Shylaja B, Asst. Prof, Dept of CSE, DSATM 16 2019-20


Computer Networks Lab (17CSL57)

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

set ns [new Simulator]


set nt [open program5.tr w]
$ns trace-all $nt

set nodes(c1) [$ns node] Create nodes


set nodes(ms) [$ns node]  Two Cellular Phones (c1 , c2)
 Two Base Stations (bs1 , bs2)
set nodes(bs1) [$ns node]
 One Mobile Station (ms)
set nodes(bs2) [$ns node]
set nodes(c2) [$ns node]

Define a procedure to create topology


proc cell_topo {} {
global ns nodes

Shylaja B, Asst. Prof, Dept of CSE, DSATM 17 2019-20


Computer Networks Lab (17CSL57)

$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
}
RED (Random Early Detection) – Drops
the packets before the buffer is full.
switch gsm { Uses predictive models to decide which
packets to drop.
gsm -
gprs -
create topology
umts {cell_topo}
}

$ns bandwidth $nodes(bs1) $nodes(ms) $bwDL(gsm) simplex


$ns bandwidth $nodes(ms) $nodes(bs1) $bwUL(gsm) simplex
$ns bandwidth $nodes(bs2) $nodes(ms) $bwDL(gsm) simplex
$ns bandwidth $nodes(ms) $nodes(bs2) $bwUL(gsm) simplex

$ns delay $nodes(bs1) $nodes(ms) $propDL(gsm) simplex


$ns delay $nodes(ms) $nodes(bs1) $propDL(gsm) simplex
$ns delay $nodes(bs2) $nodes(ms) $propDL(gsm) simplex
$ns delay $nodes(ms) $nodes(bs2) $propDL(gsm) simplex

$ns queue-limit $nodes(bs1) $nodes(ms) $buf(gsm)


$ns queue-limit $nodes(ms) $nodes(bs1) $buf(gsm)
$ns queue-limit $nodes(bs2) $nodes(ms) $buf(gsm)
$ns queue-limit $nodes(ms) $nodes(bs2) $buf(gsm) Inserting delay for
Channel Allocation

$ns insert-delayer $nodes(ms) $nodes(bs1) [new Delayer]


$ns insert-delayer $nodes(bs1) $nodes(ms) [new Delayer]
$ns insert-delayer $nodes(ms) $nodes(bs2) [new Delayer]
Shylaja B, Asst. Prof, Dept of CSE, DSATM 18 2019-20
Computer Networks Lab (17CSL57)

$ns insert-delayer $nodes(bs2) $nodes(ms) [new Delayer]

Source
set tcp [new Agent/TCP]
$ns attach-agent $nodes(c1) $tcp

set ftp [new Application/FTP]


$ftp attach-agent $tcp

set sink [new Agent/TCPSink] Destination

$ns attach-agent $nodes(c2) $sink

$ns connect $tcp $sink

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

Shylaja B, Asst. Prof, Dept of CSE, DSATM 20 2019-20


Computer Networks Lab (17CSL57)

Global System for Mobile communication (GSM).


 Second Generation (2G) technology is based on the technology known as GSM.
 The GSM standard originally described as a digital, circuit-switched network
optimized for full duplex voice telephony.
 This expanded over time to include data communications, first by circuit-switched
transport, then by packet data transport via GPRS (General Packet Radio Services).
 UMTS (Universal Mobile Telecommunications Service) is a third-generation (3G)
broadband, packet-based transmission of text, digitized voice, video, and multimedia
at data rates up to 2 megabits per second (Mbps).
 UMTS is based on GSM

Shylaja B, Asst. Prof, Dept of CSE, DSATM 21 2019-20


Computer Networks Lab (17CSL57)

6. Implement and study the performance of CDMA on NS2/NS3 (Using stack called Call
net) or equivalent environment.

gedit program6.tcl

set bwDL(cdma) 384000


set bwUL(cdma) 64000
set propDL(cdma) .150
set propUL(cdma) .150
set buf(cdma) 20

set ns [new Simulator]


set nt [open program6.tr w]
$ns trace-all $nt

set nodes(c1) [$ns node]


set nodes(ms) [$ns node]
set nodes(bs1) [$ns node]
set nodes(bs2) [$ns node]
set nodes(c2) [$ns node]

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}
}

Shylaja B, Asst. Prof, Dept of CSE, DSATM 22 2019-20


Computer Networks Lab (17CSL57)

$ns bandwidth $nodes(bs1) $nodes(ms) $bwDL(cdma) simplex


$ns bandwidth $nodes(ms) $nodes(bs1) $bwUL(cdma) simplex
$ns bandwidth $nodes(bs2) $nodes(ms) $bwDL(cdma) simplex
$ns bandwidth $nodes(ms) $nodes(bs2) $bwUL(cdma) simplex

$ns delay $nodes(bs1) $nodes(ms) $propDL(cdma) simplex


$ns delay $nodes(ms) $nodes(bs1) $propDL(cdma) simplex
$ns delay $nodes(bs2) $nodes(ms) $propDL(cdma) simplex
$ns delay $nodes(ms) $nodes(bs2) $propDL(cdma) simplex

$ns queue-limit $nodes(bs1) $nodes(ms) $buf(cdma)


$ns queue-limit $nodes(ms) $nodes(bs1) $buf(cdma)
$ns queue-limit $nodes(bs2) $nodes(ms) $buf(cdma)
$ns queue-limit $nodes(ms) $nodes(bs2) $buf(cdma)

$ns insert-delayer $nodes(ms) $nodes(bs1) [new Delayer]


$ns insert-delayer $nodes(bs1) $nodes(ms) [new Delayer]
$ns insert-delayer $nodes(ms) $nodes(bs2) [new Delayer]
$ns insert-delayer $nodes(bs2) $nodes(ms) [new Delayer]

set tcp [new Agent/TCP]


$ns attach-agent $nodes(c1) $tcp

set ftp [new Application/FTP]


$ftp attach-agent $tcp

set sink [new Agent/TCPSink]


$ns attach-agent $nodes(c2) $sink

Shylaja B, Asst. Prof, Dept of CSE, DSATM 23 2019-20


Computer Networks Lab (17CSL57)

$ns connect $tcp $sink

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
}

$ns at 0.0 "$ftp start"


$ns at 10.0 "End"
$ns run

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

Shylaja B, Asst. Prof, Dept of CSE, DSATM 24 2019-20


Computer Networks Lab (17CSL57)

CDMA (Code-Division Multiple Access)


 Refers to any of several protocols used in second-generation (2G) and third-generation (3G)
wireless communications.
 CDMA is a form of multiplexing, which allows numerous signals to occupy a single
transmission channel, optimizing the use of available bandwidth.

Shylaja B, Asst. Prof, Dept of CSE, DSATM 25 2019-20

S-ar putea să vă placă și