[go: up one dir, main page]

0% found this document useful (0 votes)
48 views11 pages

Session 3 - Wired and Wireless Examples

This document summarizes a wired network simulation example with 4 nodes connected by 3 links of varying bandwidth and delay. It describes creating the nodes and links in the simulator, attaching TCP, UDP and CBR/FTP applications to nodes, scheduling the applications to start and stop, and running the simulation. The simulation outputs trace files to analyze traffic over the wired links.

Uploaded by

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

Session 3 - Wired and Wireless Examples

This document summarizes a wired network simulation example with 4 nodes connected by 3 links of varying bandwidth and delay. It describes creating the nodes and links in the simulator, attaching TCP, UDP and CBR/FTP applications to nodes, scheduling the applications to start and stop, and running the simulation. The simulation outputs trace files to analyze traffic over the wired links.

Uploaded by

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

Wired and wireless

example
T S PRADEEP KUMAR
VIT University – Chennai Campus
http://www.pradeepkumar.org
tspembedded@gmail.com
www.facebook.com/tspradeep

1
Wired Example

2
Wired Example….
• This network consists of 4 nodes (n0, n1, n2, n3) as shown in
above figure.
• The duplex links between n0 and n2, and n1 and n2 have 2
Mbps of bandwidth and 10ms of delay.
• The duplex link between n2 and n3 has 1.7 Mbps of
bandwidth and 20 ms of delay.
• Each node uses a DropTail queue, of which the maximum size
is 10.

3
Wired Example….
#Create a simulator object
set ns [new Simulator]

#Open the NAM trace file


set nf [open out.nam w]
$ns namtrace-all $nf

#color for data flow


$ns color 1 red
$ns color 2 blue

#Create four nodes


set n0 [$ns node]
set n1 [$ns node]
set n2 [$ns node] 4
set n3 [$ns node]
Wired Example….
#Define a 'finish' procedure
proc finish {} {
global ns nf
$ns flush-trace
#Close the NAM trace file
close $nf
#Execute NAM on the trace file
exec nam out.nam &
exit 0
}
5
Wired Example….
#Create links between the nodes
$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

#Set Queue Size of link (n2-n3) to 10


$ns queue-limit $n2 $n3 10

#Give node position (for NAM)


$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

#Monitor the queue for link (n2-n3). (for NAM) 6


$ns duplex-link-op $n2 $n3 queuePos 0.5
Wired Example….
#Setup a TCP connection
set tcp [new Agent/TCP]
$tcp set class_ 2
$ns attach-agent $n0 $tcp
set sink [new Agent/TCPSink]
$ns attach-agent $n3 $sink
$ns connect $tcp $sink
$tcp set fid_ 1

7
Wired Example….
#Setup a FTP over TCP connection
set ftp [new Application/FTP]
$ftp attach-agent $tcp
$ftp set type_ FTP

#Setup a UDP connection


set udp [new Agent/UDP]
$ns attach-agent $n1 $udp
set null [new Agent/Null]
$ns attach-agent $n3 $null
$ns connect $udp $null
$udp set fid_ 2 8
Wired Example….
#Setup a CBR over UDP connection
set cbr [new Application/Traffic/CBR]
$cbr attach-agent $udp
$cbr set type_ CBR
$cbr set packet_size_ 1000
$cbr set rate_ 1mb
$cbr set random_ false

9
Wired Example….
#Schedule events for the CBR and FTP agents
$ns at 0.1 "$cbr start"
$ns at 1.0 "$ftp start"
$ns at 4.0 "$ftp stop"
$ns at 4.5 "$cbr stop"

#Detach tcp and sink agents (not really necessary)


$ns at 4.5 "$ns detach-agent $n0 $tcp ; $ns detach-agent $n3 $sink"

#Call the finish procedure after 5 seconds of simulation time


$ns at 5.0 "finish"

#Print CBR packet size and interval


puts "CBR packet size = [$cbr set packet_size_]"
puts "CBR interval = [$cbr set interval_]"

#Run the simulation 10


$ns run
Output

11

You might also like