Download as pdf or txt
Download as pdf or txt
You are on page 1of 16

Marlia Curado marilia@dei.uc.

pt
Departamento de Engenharia Informtica
Universidade de Coimbra
2
Summary
! Brief review of NS-2 simulation
! Traffic Generation
Traffic generators
Simulated applications
Traces
Marlia Curado MDR
set ns [new Simulator]
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
}
Marlia Curado MDR 3
set n0 [$ns node]
set n1 [$ns node]
$ns duplex-link $n0 $n1 1Mb 10ms DropTail
set udp0 [new Agent/UDP]
$ns attach-agent $n0 $udp0
set cbr0 [new Application/Traffic/CBR]
$cbr0 set packetSize_ 500
$cbr0 set interval_ 0.005
$cbr0 attach-agent $udp0
#Create a Null agent (a traffic sink) and attach it to node n1
set null0 [new Agent/Null]
$ns attach-agent $n1 $null0
Marlia Curado MDR 4
$ns connect $udp0 $null0
$ns at 0.5 "$cbr0 start"
$ns at 4.5 "$cbr0 stop"
$ns at 5.0 "finish"
$ns run
Marlia Curado MDR 5
! CBR traffic source
Generates traffic according to a deterministic rate
Packets are constant size
Some randomizing can be enabled on the inter-packet departure
intervals
Marlia Curado MDR 6
When and why are these type of sources used?
! CBR traffic generation in NS-2
rate_
! the sending rate
interval_
! interval between packets
packetSize_
! the constant size of the packets generated
random_ flag
! indicating whether or not to introduce random noise in the
scheduled departure
maxpkts_
! the maximum number of packets to send
Marlia Curado MDR 7
How can we use rate_ and interval_?
! CBR traffic generation in NS-2
set e [new Application/Traffic/CBR]
$e set packetSize_ 48
$e set rate_ 64Kb
$e set random_ 1
Marlia Curado MDR 8
Which transport protocol to use? Why?
! Exponential On-Off traffic source
Generates traffic according to an Exponential On/Off distribution
During on periods packets are sent at a fixed rate
During off periods no packets are sent
Both on and off periods are taken from an exponential
distribution
Packets have constant size
Marlia Curado MDR 9
! Exponential traffic generation in NS-2
packetSize_
! the constant size of the packets generated
burst_time_
! the average on time for the generator
idle_time_
! the average off time for the generator
rate_
! the sending rate during on times
Marlia Curado MDR 10
! Exponential traffic generation in NS-2
set e [new Application/Traffic/Exponential]
$e set packetSize_ 210
$e set burst_time_ 500ms
$e set idle_time_ 500ms
$e set rate_ 100k
Marlia Curado MDR 11
! Probability Density Function
Marlia Curado MDR 12
!
f (x) = k
x
m
k
x
k+1
, x > x
m
k > 0, shape
x
m
> 0
Which traffic behaviour looks like this?
! Pareto On-Off traffic source
Packets are sent at a fixed rate during on periods, and no
packets are sent during off periods
On and off periods are taken from a Pareto distribution
Packets are constant size
Marlia Curado MDR 13
! Pareto On/Off traffic generator in NS-2
packetSize_
the constant size of the packets generated
burst_time_
the average "on" time for the generator
idle_time_
the average "off" time for the generator
rate_
the sending rate during "on" times
shape_
the "shape" parameter used by the pareto distribution
Marlia Curado MDR 14
! Pareto On/Off traffic generator in NS-2:
set p [new Application/Traffic/Pareto]
$p set burst_time_ 500ms
$p set idle_time_ 500ms
$p set rate_ 200k
$p set packetSize_ 210
$p set shape_ 1.5
Marlia Curado MDR 15
! http://nsnam.isi.edu/nsnam/index.php/Main_Page
Marlia Curado MDR 16

You might also like