THE FIRST STEP TO BECOME FAMILIAR WITH NETWORK SIMULATOR (NS) Neda Mohammadizadeh Cooperative sub-group BBCR group Feb 2012
References • http://nsnam.isi.edu/nsnam/index.php/User_Information
• http://nile.wpi.edu/NS/
• http://www.isi.edu/nsnam/ns/tutorial/index.html • Introduction to NS2(PPT), Prepared by Changyong Jung
2
Outline • Introduction on Network Simulator • Installation • Architecture of NS-2 • OTcl • Simulation Examples
3
Introduction • Network Simulator (NS)
• Discrete event network simulator • Implements
• Transport layer protocols such as TCP ( reno, tahoe, vegas, sack) and UPD
• Router queue management mechanism such as Drop Tail, RED • Routing algorithms such as Dijkstra and Ad-hoc Routing (DSDV, DSR,
AODV, TORA) • MAC layer protocols (802.11, 802.3, TDMA) • Sensor Network (diffusion, gaf), Satellite protocols, and many others • Traffic source behavior such as FTP, Telnet, Web, CBR and VBR
• NS versions: • NS-1, NS-2, NS-3
4
Introduction • NS-1:
• LNBL Simulator tool • Developed by the network research group at the Lawrence
Berkeley National Laboratory (1989). • Derived from REAL simulator • Simulation description language: TCL
5
Introduction • NS-2:
• Object oriented (OTcl instead of TCL) • Built in C++ and provides a simulation interface through OTcl • Developed by UC Berkeley
• Difficult for the first time user • Few user friendly manuals • Needs scripting language, queuing theory and modeling techniques
knowledge • Complaint about inconsistent results • BUGs!!!
6
Introduction • NS-3:
• Maintaining backward compatibility with ns-2? (2005) • YANS (Yet Another Network Simulator) -> NS-3 base • NS-3.1 (2008) , NS-3.11(2011) • Built in C++ and Phyton • Make it simpler • No support for some protocols which were supported in ns-2
7
Installation • http://nsnam.isi.edu/nsnam/index.php/Downloading_and_install
ing_ns-2
• Installing on Unix-based systems
• Installing on Windows using Cygwin
• Installing on Mac
• The following “How to install” slides are brought from Introduction to NS2(PPT), Prepared by Changyong Jung
8
How to Install -Window XP- • Go to Website: http://nsnam.isi.edu/nsnam/index.php/Running_Ns_and_Nam_Under_Windows_9x/2000/XP_Using_Cygwin
• Read “Requirements and Installation Tips” Carefully. • Download cygwin.exe from http://www.cygwin.com/
• Click the “cygwin.exe”
9
How to Install • Cygwin Installation
10
How to Install
11
How to Install • Select browse for “cygwin” file( I selected as “default”)
12
How to Install • Local package directory (I recommend c:\cygwin).
13
How to Install • Select to Install all ( I recommend it) • You can select “install”, “default”, “uninstall”, “install”, and “reinstall” behind the first
line “all”. If you select “install”, then all sub items will be automatically selected. Otherwise you may lose some items.
14
How to Install • Select download site
15
How to Install • Installing
16
How to Install • Finishing Installing
17
How to Install • NS2 Installation • Download ns-allinone-2.29.2.tar.gz from Website and
Save it to the c:/cygwin /usr/local • Unpack it: tar xvfz ns-allinone-2.29.2.tar.gz • Click on desktop icon “cygwin”
18
How to Install
19
How to Install • Type “cd ..” to go to the upper folder(“cd” must be low case. And
there is one space between “d” and “.”) • Type “cd ..” again.
20
How to Install • “cd usr”, go to folder “usr” • “cd local”, go to folder “local”
21
How to Install • Find “install.exe”
22
How to Install • Start to run the installation “./install”
23
How to Install • Installing
24
How to Install • Installing
25
How to Install • Configure system variables and library paths • After finishing installing, following window appears
26
How to Install • Configure system variables • Go to “My computer” and click “view system information”
27
How to Install • Go to “advanced” Tab and Click “Environmental variables”
28
How to Install
29
How to Install • Highlight “path” which is “system variable” box and press the “Edit”
button.
30
How to Install
31
How to Install • Add the following path separated with “;” make sure to
not change the existing path. /usr/local/ns-allinone-2.29.2/bin /usr/local/ns-allinone-2.29.2/tcl8.4.11/unix /usr/local/ns-allinone-2.29.2/tk8.4.11/unix
32
How to Install • Go to cygwin and type the following content Export LD_LIBRARY_PATH=/usr/local/ns-allinone-
2.29/otcl-1.11 Export LD_LIBRARY_PATH=/usr/local/ns-allinone-2.29/lib Export TCL_LIBRARY_PATH=/usr/local/ns-allinone-
2.29/tcl8.4.11/library
33
How to Install
34
NS-2 Architecture
NS Simulator Library
Network Component
Objects Network Setup
Modules Event
Scheduler Objects
• The event scheduler and the basic network component objects in the data path are written and compiled using C++.
• To use NS, you program in OTcl script language
35
Plumbing Network Setup: • Creating possible data paths among network objects. • The power of NS comes from plumbing.
Event is a packet ID that is unique for a packet • scheduled time • the pointer to an object that handles the event. An event scheduler • keeps track of simulation time • fires all the events in the event queue
Event Scheduling
36
NS-2 Architecture OTcl and C++
http://nile.wpi.edu/NS/
37
OTcl
Executing a test file: ns ex-tcl.tcl
Results:
38
Event Scheduler
http://nile.wpi.edu/NS/
39
1. Real-time scheduler 2. Non-real-time scheduler
• List • Heap • Calendar
. . . set ns [new Simulator] $ns use-scheduler Heap $ns at 300.5 "complete_sim" . . . proc complete_sim {} { . . . }
Network Component N
ode:
• Unicast or Multicast
• Routing Protocol Link
: • Tracing • Queue monitor
Unicast - $ns rtproto type - type: Static, Session, DV, cost, multi-path Multicast - $ns multicast (right after set $ns [new Scheduler]) - $ns mrtproto type - type: CtrMcast, DM, ST, BST
create-trace {type file src dst}
40
Partial OTcl class hierarchy
41
http://nile.wpi.edu/NS/
Other important tasks
Post simulation: Trace analysis Queue Monitor Troubleshooting: Installation problems Simulation Problems
42
NS Results
Network Animator (NAM) • A graphical simulation display tool • Developed as a part of VINT project • Has a nice graphical user interface • Can graphically present information
NS Simulation
Text-based results NAM
43
Simulation Example
http://nile.wpi.edu/NS/
44
45
Where to find…
/ns-2/tcl/lib ns-lib.tcl: The simulator class and most of its member function definitions ns-default.tcl: The default values for configurable parameters ns-packet.tcl: The packet header format initialization implementation other OTcl files: implementation of compound network objects or the front end (control part) of network objects
46
Summary
Network Simulator (NS): is an object-oriented discrete-event network simulator. Implements different network protocols. is written in C++ and OTcl. (NS-2) It was the first step to be familiar with NS. Keep going…
47
Thank You
48