ns-tutorial
25 pages
English
Le téléchargement nécessite un accès à la bibliothèque YouScribe
Tout savoir sur nos offres
25 pages
English
Le téléchargement nécessite un accès à la bibliothèque YouScribe
Tout savoir sur nos offres

Description

ƒƒƒƒƒThe Network Simulator-ns-2Claudia Canali17/11/03Tutorial OutlinePart INS fundamentalsWired worldWalk-thru an example NS scriptPart IIVisualization tools & other utilitiesHelp and references1ƒƒƒƒƒƒWhat Is NS?Started as variant of REAL in 1989Developed at UC BerkelyDiscrete event, packet level simulatorWritten in C++ with Otcl frontendWired, wireless and emulation modesLink layer and up for most wiredAdditional lower layers for wirelessPlatformsMost UNIX and UNIX-like systemsLinuxFreeBSDSunOS/SolarisHP/SGI (with some tweaking)Windows 95/98/NT/ME/2000Tips on build availableHowever validation tests don’t work2ƒƒƒƒzzArchitecture in NSObject-oriented (C++ and Otcl)Algorithms over large data sets, per packet handling in C++ Configuration, “one-time” stuff in Otcl Fast to run, quick to re-configureFine grained object compositionC++ and OTcl SeparationC++ for “data”Per packet actionOTcl (Object Tcl Extensions) for controlConfiguration, “one-time” task+ Compromise between composibility and speed– Learning and debugging3OTcl and C++: The DualityPure OTclPure C++objectsobjectsC++/OTcl split objectsC++ OTclnsBasic Tcl(Tool Command Language)set a 43set b 27proc test { a b } {set c [expr $a + $b]set d [expr [expr $a - $b] * $c]for {set k 0} {$k < 10} {incr k} {if {$k < 5} {puts “k < 5, pow = [expr pow($d, $k)]”} else {puts “k >= 5, mod = [expr $d % $k]”}}}4Basic OTclClass Mom set mom [new ...

Informations

Publié par
Nombre de lectures 19
Langue English

Extrait

ƒ
ƒ
ƒ
ƒ
ƒ
The Network Simulator-ns-2
Claudia Canali
17/11/03
Tutorial Outline
Part I
NS fundamentals
Wired world
Walk-thru an example NS script
Part II
Visualization tools & other utilities
Help and references

ƒ
ƒ
ƒ
ƒ
ƒ
What Is NS?
Started as variant of REAL in 1989
Developed at UC Berkely
Discrete event, packet level simulator
Written in C++ with Otcl frontend
Wired, wireless and emulation modes
Link layer and up for most wired
Additional lower layers for wireless
Platforms
Most UNIX and UNIX-like systems
Linux
FreeBSD
SunOS/Solaris
HP/SGI (with some tweaking)
Windows 95/98/NT/ME/2000
Tips on build available
However validation tests don’t work

ƒ
ƒ
ƒ
z
z
Architecture in NS
Object-oriented (C++ and Otcl)
Algorithms over large data sets, per packet
handling in C++
Configuration, “one-time” stuff in Otcl
Fast to run, quick to re-configure
Fine grained object composition
C++ and OTcl Separation
C++ for “data”
Per packet action
OTcl (Object Tcl Extensions) for control
Configuration, “one-time” task
+ Compromise between composibility and
speed
– Learning and debugging
3OTcl and C++: The Duality
Pure OTclPure C++
objectsobjects
C++/OTcl split objects
C++ OTcl
ns
Basic Tcl
(Tool Command Language)
set a 43
set b 27
proc test { a b } {
set c [expr $a + $b]
set d [expr [expr $a - $b] * $c]
for {set k 0} {$k < 10} {incr k} {
if {$k < 5} {
puts “k < 5, pow = [expr pow($d, $k)]”
} else {
puts “k >= 5, mod = [expr $d % $k]”
}
}
}
4Basic OTcl
Class Mom set mom [new Mom]
Mom instproc greet {} { $mom set age_ 45
$self instvar age_ set kid [new Kid]
puts “$age_ years old $kid set age_ 15
mom: How are you
doing?”
$mom greet}
$kid greet
Class Kid -superclass
Mom
Kid instproc greet {} {
$self instvar age_
puts “$age_ years old
kid: What’s up,
dude?”
}
Hello World - Interactive Mode
swallow 71% ns
% set ns [new Simulator]
_o3
% $ns at 1 “puts \“Hello World!\””
1
% $ns at 1.5 “exit”
2
% $ns run
Hello World!
swallow 72%
5Hello World - Batch Mode
simple.tcl
set ns [new Simulator]
$ns at 1 “puts \“Hello World!\””
$ns at 1.5 “exit”
$ns run
swallow 74% ns simple.tcl
Hello World!
swallow 75%
Event Driven Simulation
Scheduler – main controller of events
Scheduler clock - simulator virtual time
[$ns_ now] returns the current simulator time
Event queue - holds events in the order of
their firing times
Events have a firing time and a handler
function
Two types of events possible – packets and
“at-events”
6„



Discrete Event Scheduler
Event
time_, uid_, next_, handler_Queue
Dispatch
DequeHead_ ->
handler_ -> handle()
Reschedule
Insert time_, uid_, next_, handler_
Four types of scheduler:
List: simple linked list, order-
preserving, O(N)
Unit of time:
Heap: O(logN) seconds
Calendar: hash-based,
fastest, default, O(1)
Real-time: subclass of list,
sync with real-time, O(N)
Elements of Ns-2
Create the event scheduler
[Turn on tracing]
Create network
Setup routing
Insert errors
Create transport connection
Create traffic
7z
z
z
z
z
z
z
z
z
Creating Event Scheduler
Create event scheduler
set ns [new Simulator]
Schedule events
$ns at <time> <event>
<event>: any legitimate ns/tcl commands
Start scheduler
$ns run
Creating Network Topology
Nodes
set n0 [$ns node]
set n1 [$ns node]
Links and queuing
$ns duplex-link $n0 $n1 <bandwidth>
<delay> <queue_type>
<queue_type>: DropTail, RED, CBQ, FQ,
SFQ, DRR
$ns duplex-link $n0 $n1 5Mb 2ms DropTail

z
z
z
Links and queuing
Duplex-link 2 simple links in both
directions
Delay object simulates the link delay
DropTail implements FIFO scheduling
Tracing
Trace packets on all links
$ns trace-all [open test.out w]
Trace file format
event time from to pkt pkt flags fid src dst seq pkt
node node type size addr addr Idnum
d 1.7312 2 3 tcp 1040 ------- 1 0.0 3.0 12 471
Trace packets on all links in nam format
$ns namtrace-all [open test.nam w]
$ns namtrace-all-wireless [open wtest.nam w]
9z
z
z
z
z
Tracing
Turn on tracing on specific links
$ns trace-queue $n0 $n1
$ns namtrace-queue $n0 $n1
Trace-all commands must appear
immediately after creating
scheduler (links created AFTER will
have trace objects inserted)
Tracing
Event tracing
$ns eventtrace-all [$file]
Add eventtrace after trace-all as trace-all
file is used as default
Example script: ~ns/tcl/ex/tcp-et.tcl
10

  • Univers Univers
  • Ebooks Ebooks
  • Livres audio Livres audio
  • Presse Presse
  • Podcasts Podcasts
  • BD BD
  • Documents Documents