You are on page 1of 16

t

ment-2
to transmit data
Tal script
*A To write a

nodes using
TCP & UDP protals
between

&Software : NS2/NSG2.1
Required
-

Ubuntu
OS
3) =

to script an
in
forgenerating
"are
ar
NSG2.jar
·open
terminal type" java
scenario.
new
wined
select
2) click
on Scenario, in
the empty
3 modes
Node and
place
3) click on below
as
shown
window
area of the

x2
No ·
·

x(
below
Click
a) on Link & select the
setting as

Link
· Duplex
· Drop Tail Queue
Mbps
Capacity 100

no mes
·
Delay
50
size
· Quene
-> we
>M1; m,
then Connect no

below
Agent setting
as

select the
sa)Click Agent, on

TCP Agent
bytes
·

1500
·
packet size
mode no
to source
Then Connect topo below
setting
select the Agent
5b) Click on Agent,
Sink
·TCP bytes
1500
size mode ma
· packet destination
to
sinks
Then connect
to Sink 1
5c) Connect topo
6) Click on
Application. Select the settings as below

Type as FTP
·
Application
time 8
1, stop
· start time

type to tcpo.
Connect

Click
7) on
parameters. Select the settings as below

·Simulation time 10.0

e2.th
· trace file name as

e2.nam
· nam file name as

Click or done

Click
8) on TC1. Save the file on Desktop
with filename e2otcl.
& it,
Locate the file on the Deskop open

make sure that all the lines are generated


with the code.
in e2. Ecl file, by cross checking

Final
Deskip type the Command

the coremand
ad

tcl file by using


1)
Bun the

us
e2.tc) on be in Animation
1)
The moments of packets seen

12 file, file are generated


corresponding trace man

transfer.
o the Desktop after completion of data
the generated trace file is 22.tr
13) Analyze
the command
using
wiredLawk 22.t
awk of
values are
throughput, delay, pour
in) The parameters
obtained in the terminal.

15) Take the screenshots of


rams
e2.
a)

ty
e2.
6)
calculated
2) output of paramelers
d) nodes
animation op
to script an
in

forgenerating
bare
ar
NSG2.jar
·open
terminal type" java
scenario.
new
wined
select
2) click
on Scenario, in
the empty
3 modes
Node and
place
click
3) on below
as
shown
window
area of the

x2
No ·
·

x(
below
Click
a) on Link & select the
setting as

Link
· Duplex
· Drop Tail Queue
Mbps
Capacity 100

no mes
·
Delay
50
size
· Quene
-> we
>M1; m,
then Connect no

below
Agent setting
as

select the
sa)Click Agent, on

UDP Agent
bytes
·

1500
·
packet size
node no
upo source

Then connect below
setting
select the Agent
5b) Click on Agent,
NOLL
·

1500 bytes
size mode ma
· packet destination
connect wall to
There
wall to adpo
5c) Connect
6) Click on
Application. Select the settings as below

Type as CBR
·
Application
1, stop
time 8., packet Size
· start time

Connect clue to udpo

Click
7) on
parameters. Select the settings as below

·Simulation time 10.0

e2b. to
· trace file name as

ezb.nam
· nam file name as

Click or done

Click
8) on TC1. Save the file on Desktop
with filename ezbotal
& it,
Locate the file on the Deskop open

make sure that all the lines are generated


with the code.
in ezbital file, by cross checking

Final
Deskip type the Command

the coremand
ad

tcl file by using


1)
Bun the

us
egbots) on be in Animation
1)
The moments of packets seen

12 file, file are generated


corresponding trace man

transfer.
o the Desktop after completion of data
the generated trace file is 22.tr
13) Analyze
the command
using
wiredLawk 22.t
awk of
values are
throughput, delay, pour
in) The parameters
obtained in the terminal.

15) Take the screenshots of


eebo
a
name

ty
ezb
6)
calculated
2) output of paramelers
d) nodes
animation op
a
s
·I
EEEEEE
Procedure of generating tcl script using
NSG2.1 for UDP agent :
1.Open terminal type “ java –jar NSG2.1.jar ”,click on enter.
2.Click on scenario and select new wired scenario.
3.Click the Node and Place 3 nodes in the empty area of the
window ,
4.Click the Link & select the link as duplex link, Queuetype as
Drop-Tail ,capacity of 100Mbps ,propagation delay of

i n
10ms , & Queuesize of 50 .
5.Click on Agent select a source node and give Agent type as
UDP and select destination node & give Agent type as NULL .
& packet size as 1500 bytes.Then Connect udp0 & sink1.
6.Click on Application .Then select Application type as CBR to
to source nodeB only.Give start time as 1 & stop time as 8.

7.Click on Parameters -Give simulation time as 10.0 , Trace Rle


as e2b.tr , nam Rle as e2b.nam & click on done.
8.Go to tcl script and verify the script & name it as e2b.tcl &save it
on desktop.
9.Go to terminal and change directory to desktop as: cd Desktop.
10. Run the tcl Rle by giving command: ns <Rlename>.tcl.
11. The movement of packets can be seen under NAM console.
12. Corresponding trace Rle and nam Rle are generated on the
desktop.
13. 13.Analyse the trace Rle to calculate various parameters using
14. awk -f wired1.awk e2b.tr

CODE OF TCP AGENT:


DATA TRANSMISSION USING TCP AGENT

# This script is created by NSG2 beta1


# <http://wushoupong.googlepages.com/nsg>

#===================================
# Simulation parameters setup
#===================================
set val(stop) 10.0 ;# time of simulation end
#===================================
# Initialization
#===================================
#Create a ns simulator
set ns [new Simulator]

#Open the NS trace ;le


·
set trace;le [open 2aeL101213.tr w]
$ns trace-all $trace;le

#Open the NAM trace ;le


set nam;le [open Eag
2aeL101213.nam w]
$ns namtrace-all $nam;le

#===================================
# Nodes De;nition
#===================================
#Create 3 nodes
set n0 [$ns node]
set n1 [$ns node]
set n2 [$ns node]

#===================================
# Links De;nition
#===================================
#Createlinks between nodes
$ns duplex-link $n0 $n1 100.0Mb 10ms DropTail
$ns queue-limit $n0 $n1 50
$ns duplex-link $n1 $n2 100.0Mb 10ms DropTail
$ns queue-limit $n1 $n2 50

#Give node position (for NAM)


$ns duplex-link-op $n0 $n1 orient right
$ns duplex-link-op $n1 $n2 orient right-down

#===================================
# Agents De;nition
#===================================
#Setup a TCP connection
set tcp0 [new Agent/TCP]
$ns attach-agent $n0 $tcp0
set sink1 [new Agent/TCPSink]
$ns attach-agent $n2 $sink1
$ns connect $tcp0 $sink1
$tcp0 set packetSize_ 1500

#===================================
# Applications De8nition
#===================================
#Setup a FTP Application over TCP connection
set ftp0 [new Application/FTP]
$ftp0 attach-agent $tcp0
$ns at 1.0 "$ftp0 start"
$ns at 10.0 "$ftp0 stop"

#===================================
# Termination
#===================================
#De8ne a '8nish' procedure
proc 8nish {} {
global ns trace8le nam8le
$ns Push-trace
close $trace8le
close $nam8le
exec nam b.2aeL101213.nam &
exit 0
}
$ns at $val(stop) "$ns nam-end-wireless $val(stop)"
$ns at $val(stop) "8nish"
$ns at $val(stop) "puts \"done\" ; $ns halt"$ns run

-E
EFFFFFFFFF
Observation of TCP agent:

F
I
5b)Code of UDP AGENT

# This script is created by NSG2 beta1


# <http://wushoupong.googlepages.com/nsg>

#===================================
# Simulation parameters setup
#===================================
set val(stop) 10.0 ;# time of simulation end

#===================================
# Initialization
#===================================
#Create a ns simulator
set ns [new Simulator]

#Open the NS trace Tle


set traceTle [open ERD
2beL101213.tr w]
$ns trace-all $traceTle

#Open the NAM trace Tle


set namTle [open Feb.
2beL101213.nam w]
$ns namtrace-all $namTle

#===================================
# Nodes DeTnition
#===================================
#Create 3 nodes
set n0 [$ns node]
set n1 [$ns node]
set n2 [$ns node]

#===================================
# Links De8nition
#===================================
#Createlinks between nodes
$ns duplex-link $n0 $n1 100.0Mb 10ms DropTail
$ns queue-limit $n0 $n1 50
$ns duplex-link $n1 $n2 100.0Mb 10ms DropTail
$ns queue-limit $n1 $n2 50

#Give node position (for NAM)


$ns duplex-link-op $n0 $n1 orient right
$ns duplex-link-op $n1 $n2 orient right-down

#===================================
# Agents De8nition
#===================================
#Setup a UDP connection
set udp0 [new Agent/UDP]
$ns attach-agent $n0 $udp0
set null2 [new Agent/Null]
$ns attach-agent $n2 $null2
$ns connect $udp0 $null2
$udp0 set packetSize_ 1500
#===================================
# Applications De8nition
#===================================
#Setup a CBR Application over UDP connection
set cbr0 [new Application/TraXc/CBR]
$cbr0 attach-agent $udp0
$cbr0 set packetSize_ 1000
$cbr0 set rate_ 1.0Mb
$cbr0 set random_ null
$ns at 1.0 "$cbr0 start"
$ns at 8.0 "$cbr0 stop"

#===================================
# Termination
#===================================
#De%ne a '%nish' procedure
proc %nish {} {
global ns trace%le nam%le
I

$ns ;ush-trace
close $trace%le
close $nam%le
exec nam zb.
2beL101213.nam &
exit 0
}
$ns at $val(stop) "$ns nam-end-wireless $val(stop)"
$ns at $val(stop) "%nish"
$ns at $val(stop) "puts \"done\" ; $ns halt"
$ns run

i
Observation of UDP agent :

It
servations
TCP
C

F
UDP-
=
·servations
e2.nam,
*
22b. nare

c2.tr, ezb.ty
*

Animation of ezbotcl
Animation of 22.tcl,
*

Glaulted for
values
*
parameter
Fo
ecotr, e2b.

7) Result i
-

Hence we have transmitted the data between nodes using TCP &
UDP protocols

You might also like