0% found this document useful (0 votes)
7 views10 pages

Week 10,12 1

Uploaded by

Sai Abhishek
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views10 pages

Week 10,12 1

Uploaded by

Sai Abhishek
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

EXPERIMENT-10

10) Implement TCP and UDP on different pairs of systems using NS2 Simulation
Tool.
set ns [new Simulator]
$ns color 0 blue
$ns color 1 red
set nf [open out.nam w]
$ns namtrace-all $nf

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

set n0 [$ns node]


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

$ns duplex-link $n0 $n2 2Mb 10ms DropTail


$ns duplex-link $n1 $n2 2Mb 10ms DropTail
$ns duplex-link $n2 $n3 1.7Mb 20ms DropTail
$ns duplex-link-op $n0 $n2 orient right-down
$ns duplex-link-op $n1 $n2 orient right-up
$ns duplex-link-op $n2 $n3 orient right
$ns queue-limit $n0 $n2 10
$ns queue-limit $n1 $n2 10
$ns queue-limit $n2 $n3 10

set tcp1 [new Agent/TCP]


$tcp1 set fid_ 0
$ns attach-agent $n1 $tcp1
set sinkTCP3 [new Agent/TCPSink]
$ns attach-agent $n3 $sinkTCP3
$ns connect $tcp1 $sinkTCP3

set udp0 [new Agent/UDP]


$udp0 set fid_ 1
$ns attach-agent $n0 $udp0
set null0 [new Agent/Null]
$ns attach-agent $n3 $null0
$ns connect $udp0 $null0
set ftp0 [new Application/FTP]
$ftp0 attach-agent $tcp1
set cbr0 [new Application/Traffic/CBR]
$cbr0 set packetSize_ 1000
$cbr0 set interval 0.010
$cbr0 attach-agent $udp0
$ns at 0.5 "$ftp0 start"
$ns at 4.0 "$ftp0 stop"
$ns at 0.1 "$cbr0 start"
$ns at 4.5 "$cbr0 stop"
$ns at 5.0 "finish"
$ns run
OUTPUT:
srinu@ubuntu:~/CN$ ns tcpudp.tcl
EXPERIMENT-11
11) Configuring any two application layer protocols using packet tracer.
FTP PROTOCOL:
1) Open packet tracer and place a server, a switch and two devices (Ex: PCs) from
the workspace
2) Assign IP addresses to the server and both the PCs
3) Connect all the devices with straight cable.

4) In server, click on the services and turn off all the protocols except FTP protocol.
Assign username and password and add to it.

5) Now open the command prompt of any PC and type “ftp 10.10.10.0 (server’s IP
address).
6) Then server is connected and we can use different commands.

HTTP PROTOCOL:
1) Open packet tracer and place a server, a switch and two devices (Ex: PCs) from
the workspace
2) Assign IP addresses to the server and both the PCs and connect all the devices
with straight cable.

3) In server, click on the services and turn off all the protocols except HTTP
protocol. Then edit one html in file in http window and save it.
4) Then go to any PC’s web browser and type the server URL, then you get the text
written in html file of server.
EXPERIMENT-12
12) Implementation of wireless networks using NS2 Simulation Tool.
set ns [new Simulator]
set tracefile [open wireless.tr w]
$ns trace-all $tracefile
set namfile [open wireless.nam w]
$ns namtrace-all-wireless $namfile 500 500
set topo [new Topography]
$topo load_flatgrid 500 500
create-god 6
set val(chan) Channel/WirelessChannel
$ns node-config -adhocRouting AODV \
-llType LL \
-macType Mac/802_11 \
-ifqType Queue/DropTail/PriQueue \
-ifqLen 50 -antType Antenna/OmniAntenna \
-propType Propagation/TwoRayGround \
-phyType Phy/WirelessPhy \
-channel [new $val(chan)] \
-topoInstance $topo \
-agentTrace ON -routerTrace OFF \
-macTrace ON \
-movementTrace OFF

set n0 [$ns node]


set n1 [$ns node]
set n2 [$ns node]
set n3 [$ns node]
set n4 [$ns node]
set n5 [$ns node]
$n0 random-motion 0
$n1 random-motion 0
$n2 random-motion 0
$n3 random-motion 0
$n4 random-motion 0
$n5 random-motion 0

$ns initial_node_pos $n0 20


$ns initial_node_pos $n1 20
$ns initial_node_pos $n2 20
$ns initial_node_pos $n3 20
$ns initial_node_pos $n4 20
$ns initial_node_pos $n5 50

$n0 set X_ 10.0


$n0 set Y_ 20.0
$n0 set Z_ 0.0

$n1 set X_ 210.0


$n1 set Y_ 230.0
$n1 set Z_ 0.0

$n2 set X_ 100.0


$n2 set Y_ 200.0
$n2 set Z_ 0.0

$n3 set X_ 150.0


$n3 set Y_ 230.0
$n3 set Z_ 0.0

$n4 set X_ 430.0


$n4 set Y_ 320.0
$n4 set Z_ 0.0

$n5 set X_ 270.0


$n5 set Y_ 120.0
$n5 set Z_ 0.0

$ns at 1.0 "$n1 setdest 490.0 340.0 25.0"


$ns at 1.0 "$n4 setdest 300.0 130.0 5.0"
$ns at 1.0 "$n5 setdest 190.0 440.0 15.0"
$ns at 5.0 "$n5 setdest 100.0 200.0 30.0"

set tcp [new Agent/TCP]


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

set ftp [new Application/FTP]


$ftp attach-agent $tcp
$ns at 1.0 "$ftp start"

set udp [new Agent/UDP]


set null [new Agent/Null]
$ns attach-agent $n2 $udp
$ns attach-agent $n3 $null
$ns connect $udp $null

set cbr [new Application/Traffic/CBR]


$cbr attach-agent $udp
$ns at 1.0 "$cbr start"
$ns at 10.0 "finish"
proc finish {} {
global ns tracefile namfile
$ns flush-trace
close $tracefile
close $namfile
exec nam wireless.nam &
exit 0
}

puts "Starting Simulation"


$ns run

OUTPUT:
srinu@ubuntu:~/CN$ ns wireless.tcl
num_nodes is set 6
INITIALIZE THE LIST xListHead
Starting Simulation
channel.cc:sendUp - Calc highestAntennaZ_ and distCST_
highestAntennaZ_ = 1.5, distCST_ = 550.0
SORTING LISTS ...DONE!

You might also like