Professional Documents
Culture Documents
NS2
NS2
Agenda
Overview of NS-2 History Current Status Platforms Supported Discrete Event Simulator NS-2 Environment NS-2 Hierarchy NS-2 Architecture
Node Architecture Multicast Node Architecture Packet Structure Links Traffic Flow
Example
Varaprasad Reddy
Overview of NS-2
Varaprasad Reddy
Overview of NS-2
Maintained through VINT project NS2 :collaborative simulation environment
Freely
common reference
Varaprasad Reddy
History
1995 : Developed by LBL through support of DARPA 1996: NS was extended and distributed by VINT project 1997: Satellite models added @ UCB 1999: Wireless models added @ CMU Recent incorporation of emulation
Varaprasad Reddy 5
Current status
Releases:
Periodic
releases (currently 2.27, Jan 2004) Daily snapshots (probably compiles and works, but unstable) Available from: USC/ISI, UC Berkeley, UK mirror More than 10k users from hundreds of univs
Varaprasad Reddy
Platforms supported
Most
98/2000/2003/XP
NS-2 : Components
Preprocessing
Handwritten TCL or Topology generator
Post analysis
Trace analysis using Perl/TCL/AWK/MATLAB
Varaprasad Reddy
Users Perspective
From the users perspective, NS2 is an OTcl interpreter that takes an OTcl script as input and produces a trace file as output.
Varaprasad Reddy
1
Time: 2.0 sec
2
Time: 1.8 sec
Varaprasad Reddy
10
Varaprasad Reddy
11
Event Scheduler
Varaprasad Reddy
12
NS-2 Environment
Simulation Scenario
1 2
Tcl Script
C++ Implementation
otcl: Object-oriented support tclcl: C++ and otcl linkage Discrete event scheduler Data network (the Internet) components
Varaprasad Reddy
NS-2 Hierarchy
TclObject NSOject Classifer Addr Replicator MCast MPath Hash Connector Delay Agent Application Queue Trace
Varaprasad Reddy
15
NS-2 Hierarchy
Agent UDP TCP Reno RBP Vegas RBP Sack1 NewReno Tap Sink FullTCP SRM Adaptive DSDV AODV TORA DSR
Pareto
DRR
CBR
CBQ
Trace
Varaprasad Reddy
FTP
16
tcl code
validation test
Varaprasad Reddy
Node Architecture
Node
Classifier
Local
Classifier
Port
Addr
Link
Link
Link
Agents are either protocol endpoints or related Varaprasad Reddy objects that generate/fill-in packet fields.
18
Varaprasad Reddy
19
- packet size cmn header tcp header - timestamp - type - UID - interface label ip header trace header
Varaprasad Reddy
20
Links
Links: keeps track of from and to node objects.
blocked
Enq Trace
Queue
Deq Trace
Delay
TTL
Rcv Trace
Drop head
Drp Trace
Varaprasad Reddy
21
N1
Node Node
N2
Classifier
Classifier
Local
Local
Agent Application
Agent Application
Classifier
Addr Link
Enq Trace
Classifier
Port
Port
Addr
Queue
Link
Delay
TTL
Rcv Trace
Drop head
Varaprasad Reddy
22
Varaprasad Reddy
23
Tcl or C++?
Tcl
Simple Configuration, Setup, Scenario If its something that can be done without modifying existing Tcl module.
C++
Anything that requires processing each packet Needs to change behavior of existing module
Varaprasad Reddy 25
Shadowing
TclObject
TclObject()
Agent
Agent()
Agent/DSDV
DSDVAgent()
Object Correspondence
Agent/DSDV Constructor
Invoke parent
init complete
Agent Constructor
Invoke parent
init complete
AgentDSDV() Constructor
Invoke parent
bind and return
27
Outline
Varaprasad Reddy
28
tcl code
validation test
Varaprasad Reddy
Existing code
recompile
Addition
change Makefile and recompile
Varaprasad Reddy
30
Existing code
recompile source
Addition
source change Makefile (NS_TCL_LIB), tcl/nslib.tcl (source) and recompile
Varaprasad Reddy
31
Installation
Unix variants
Download NS-allinone-2.27 package Contains
TCL/TK 8.4.5 oTCL 1.8 Tclcl 1.15 Ns2 Nam -1
Varaprasad Reddy
32
Installation
After successful downloading and unzipping install allinone package , install NS by
After successful installation , Validate the scripts by running ./validate in ~/ns-allinone2.27/ns-2.27/ Its now all set to work with NS
Varaprasad Reddy
33
Varaprasad Reddy
34
Varaprasad Reddy
35
Varaprasad Reddy
36
Creating LINKS
$ns duplex-link $N1 $R1 2Mb 5ms DropTail set DuplexLink0 [$ns link $N1 $R1] $ns duplex-link $N2 $R1 2Mb 5ms DropTail set DuplexLink1 [$ns link $N2 $R1] $ns duplex-link $R1 $R2 1Mb 10ms DropTail set DuplexLink2 [$ns link $R1 $R2] $ns duplex-link $R2 $N3 2Mb 5ms DropTail set DuplexLink3 [$ns link $R2 $N3] $ns duplex-link $R2 $N4 2Mb 5ms DropTail set DuplexLink4 [$ns link $R2 $N4]
Varaprasad Reddy
37
Orientation of links
$ns duplex-link-op $N1 $R1 orient rightdown $ns duplex-link-op $N2 $R1 orient right-up $ns duplex-link-op $R1 $R2 orient right $ns duplex-link-op $R2 $N3 orient right-up $ns duplex-link-op $R2 $N4 orient right-down
Varaprasad Reddy
38
Varaprasad Reddy
39
Varaprasad Reddy
40
Generating Traffic
Varaprasad Reddy
41
Generating Traffic
Varaprasad Reddy
42
$ns run
Varaprasad Reddy
43
Varaprasad Reddy
44