Documente Academic
Documente Profesional
Documente Cultură
Min Chen
School of Computer Science and Engineering
Seoul National University
1
Outline
Events Queuing
Server
Generator System
… ...
3
Simulation Design
4
Queuing Simulation in ns-2
cbr
udp null
0 1
5
Review of Otcl Script
#========================================
# Beginning of the simulation
#========================================
#initiate a simulator
set ns [new Simulator]
#========================================
# nodes configuration
#========================================
set n0 [$ns node]
set n1 [$ns node]
6
Queuing Simulation in ns-2
0 1
7
Review of Otcl Script (2)
#======================================== Service
# Configure the Link and the queue length ServiceRate
Rate
#========================================
$ns duplex-link $n0 $n1 1Mb 10ms DropTail
$ns queue-limit $n0 $n1 10
Queuing
QueuingLength
Length
#========================================
# Setup UDP connection
#========================================
set udp0 [new Agent/UDP]
$ns attach-agent $n0 $udp0
8
Queuing Simulation in ns-2
udp null
0 1
9
Review of Otcl Script (3)
#========================================
# Setup Exponential Traffic
#========================================
set traffic0 [new Application/Traffic/CBR]
$traffic0 set packetSize_ 1000
$traffic0 set rate_ 1Mb
Event
EventRate
Rate
$traffic0 attach-agent $udp0
#========================================
# For the Animation
#========================================
$ns duplex-link-op $n0 $n1 orient right
$ns duplex-link-op $n0 $n1 queuePos 0.5
10
Queuing Simulation in ns-2
cbr
udp null
0 1
11
Review of Otcl Script (4)
#========================================
# End of the simulation
#========================================
proc finish { } {
global ns nf nd
$ns flush-trace
close $nf
close $nd
$ns run 12
Review of AWK : Delay Calculation
BEGIN { highest_packet_id=0; }
{ Action = $1; time = $2;
From = $3; to = $4;
type = $5; pktsize = $6;
flow_id = $8; src = $9;
dst = $10; seq_no = $11;
packet_id = $12;
➢ ns 4-cbr-queuing.tcl
➢ To run the OTcl Script
➢ awk -f delay.awk out.tr > cbr-delay-10-1.txt
➢ To calculate real-time delay
➢ Change the data rate and the queuing length
➢ Queuing Length: 10, Data Rate: 1Mb
➢ cbr-delay-10-1.txt
➢ Queuing Length: 10, Data Rate: 1.5Mb
➢ cbr-delay-10-1.5.txt
➢ Queuing Length: 10000, Data Rate: 1.5Mb
➢ cbr-delay-10000-1.5.txt
14
Animations for Simulation
Queuing
QueuingLength:
Length:10
10
Date Rate: 1Mb
Date Rate: 1Mb
Queuing
QueuingLength:
Length:10
10
Data Rate: 1.5 Mb
Data Rate: 1.5 Mb
Queuing
QueuingLength:
Length:10000
10000
Data Rate: 1.5Mb
Data Rate: 1.5Mb
15
Review of GNUplot
~$ gnuplot cbr-compare.gpl
16
To make simluation efficiency
17
Pass values of the parameters
18
More Efficiency?
20
Random Seed and Distribution
#========================================
# Beginning of the simulation
#========================================
#initiate a simulator
set ns [new Simulator]
set nf [open out.nam w]
$ns namtrace-all $nf
set nd [open out.tr w]
$ns trace-all $nd
#========================================
# nodes configuration
#========================================
set n0 [$ns node]
set n1 [$ns node] 23
Specific Traffic Flows: Exponential(2)
#========================================
# Configure the Link and the queue length
#========================================
$ns duplex-link $n0 $n1 1Mb 10ms DropTail
$ns queue-limit $n0 $n1 $QueueLength
#========================================
# Setup UDP connection
#========================================
set udp0 [new Agent/UDP]
$ns attach-agent $n0 $udp0
24
Specific Traffic Flows: Exponential(3)
#========================================
# Setup Exponential Traffic
#========================================
set traffic0 [new Application/Traffic/Exponential]
$traffic0 set packetSize_ 1000
$traffic0 set burst_time_ 0.5
$traffic0 set idle_time_ 0
$traffic0 set rate_ [expr $Rate*1.0]Mb
$traffic0 attach-agent $udp0
#========================================
# For the Animation
#========================================
$ns duplex-link-op $n0 $n1 orient right
$ns duplex-link-op $n0 $n1 queuePos 0.5
25
Burst Time and Idle Time
26
Specific Traffic Flows: Exponential(4)
#========================================
# End of the simulation
#========================================
proc finish { } {
global ns nf nd
$ns flush-trace
close $nf
close $nd
$ns run
27