Beruflich Dokumente
Kultur Dokumente
Biplab Sikdar
Associate Professor
Department of ECSE
Rensselaer Polytechnic institute
Troy, NY 12180 USA
Acknowledgements
Important input from students and
colleagues: Sampad Mishra, David Doria
Some slides based on those of Padmaparna
Haldar, Ya Xu, Aga Zhang and Polly Huang
Outline
NS fundamentals
Example walkthrough
Data Collection and Visualization
Simulating WiMAX scenarios
Conclusions
NS Background
ATG Extensions
IEEE 802.16 MAC layer
TDD operation
UGS, rtPS and BE service classes
Block ARQ
Mobility extensions
Platforms
Most UNIX and UNIX-like systems
Linux
FreeBSD
SunOS/Solaris
HP/SGI (with some tweaking)
Windows 95/98/NT/ME/2000
Scheduler Operation
Event-driven simulator
Maintain a sorted event queue
Dequeue head event
Packet arrival
Example
Event
Queue
Head_ ->
Deque
Heap: O(logN)
Calendar: hash-based,
fastest, default, O(1)
NS Architecture
Back-end C++
Protocols & Framework
Split Object
Object created in otcl has a corresponding object in C+
+
Getting started
Download the latest code (all-in-one
package strongly recommended) from
http://www.isi.edu/nsnam/ns
Download 802.16 extensions
Compile and install
Basic skills:
Tcl
C++
Pure OTcl
objects
Pure C++
objects
C++
C++/OTcl split
objects
ns
OTcl
Printing
puts $filename string (default filename is stdout)
Arithmetic Expressions
set value [expr $v1+($v2 * 5.2)]
Control Structures
if {condition} then {.}
for {set i 0} {$i < 10} {incr i 2} {}
Procedures
proc proc_name {arg1 arg2} { }
NS Communication Model
Nodes
Hosts
Routers
Base stations
Links
Queue management
Queue monitoring
Agents
Protocols
TCP
4
TCP Sink
Elements of a NS Simulation
A Simple Script
# Create a topology
set ns [new Simulator]
set n0 [$ns node]
set n1 [$ns node]
$ns duplex-link $n0 $n1 1Mb 10ms DropTail
# Add Transport agents
set tcp [new Agent/TCP]
$ns attach-agent $n0 $tcp
set tcpsink [new Agent/TCPSink]
$ns attach-agent $n1 $tcpsink
$tcp connect $tcpsink
# Add application
set ftp [new Application/FTP]
$ftp attach-agent $tcp
# Create a schedule
$ns at 0.5 "$ftp start"
$ns at 4.5 "$ftp stop"
#Run the simulation
$ns run
FTP
FTP
TCP
TCP
n0
1Mb
10ms
n1
Script (cont.)
Script (cont.)
Script (cont.)
Script (cont.)
Script (cont.)
Setting up NS Nodes
n0
n1
Port
Classifier
Port
Classifier
Addr
Classifier
entry_
0
1
Addr
Classifier
dmux_
entry_
classifier_
1
0
classifier_
dmux_
head_
enqT_
n1
queue_
drophead_
deqT_
link_
drpT_
ttl_
n1
entry_
Routing
n0
n1
Port
Classifier
Port
Classifier
Addr
Classifier
entry_
0
1
Addr
Classifier
dmux_
Link n0-n1
entry_
classifier_
1
0
classifier_
Link n1-n0
dmux_
Transport
n0
n1
Port
Classifier
Port
Classifier
Addr
Classifier
entry_
0
1
dst_=1.0
Addr
Classifier
Agent/TCP
agents_
dmux_
Link n0-n1
entry_
classifier_
classifier_
Link n1-n0
1
0
0
dmux_
dst_=0.0
Agent/TCPSink
agents_
Application
n0
n1
Port
Classifier
Addr
Classifier
entry_
0
1
Application/FTP
dst_=1.0
Port
Classifier
Addr
Classifier
Agent/TCP
agents_
dmux_
Link n0-n1
entry_
classifier_
classifier_
Link n1-n0
1
0
0
dmux_
dst_=0.0
Agent/TCPSink
agents_
Packet Flow
n0
n1
Port
Classifier
Addr
Classifier
entry_
0
1
Application/FTP
dst_=1.0
Port
Classifier
Addr
Classifier
Agent/TCP
Link n0-n1
entry_
Link n1-n0
1
0
dst_=0.0
Agent/TCPSink
0
0
3.1 0 0
Visualization Tools
Nam-1 (Network AniMator Version)
Packet-level animation
Well-supported by ns
Xgraph
Convert trace output into xgraph format
Other Utilities in NS
Nam editor
Available as part of nam-1
Tcl debugger
For source and documentation, see
http://www.isi.edu/nsnam/ns/ns-debugging.html
Topology generator
http://www.isi.edu/nsnam/ns/ns-topogen.html
Scenario generator
http://www.isi.edu/nsnam/ns/ns-scengeneration.html
Other NS Features
Other areas in wired domain
LANs
Diffserv
Multicast
Full TCP
Applications like web-caching
Wireless domain
Ad hoc routing
Mobile IP
Satellite networking
Directed diffusion (sensor networks)
Other NS Features
Emulator
Connect simulator in a real network
Can receive and send out live packets from/into
the real world
NS Related Resources
NS distribution download
http://www.isi.edu/nsnam/ns/ns-build.html
More Resources
Marc Greis tutorial
http://www.isi.edu/nsnam/ns/tutorial
Ns-users archive
Ns-manual
http://www.isi.edu/nsnam/ns/ns-documentation.html
Extra Slides
Otcl Basics
Creating a class
Class class_name
Class class_name superclass Base_class
Creating an instance
set new_inst [new class_name]
Packet Format
cmn header
header
data
ip header
tcp header
rtp header
trace header
...
ts_
ptype_
uid_
size_
iface_