Why should you care about network virtualization? That question has more than a single answer. In fact, in this chapter, I describe several themes that point to a single overarching need: It’s time...
This Helps students who are researching on Network Simulator 2 in Multimedia field to get started!Full description
Network simulator-2 wired scenarios for reference to NS-2 beginners.Full description
Network simulator-2 wired scenarios for reference to NS-2 beginners.Full description
Presentation Agenda • Introduction to Linux • Importance of Open Source software • Network Simulators • • Ns2 Installation • TCL scripting language • Introduction to NAM and Xgraph • Discussion about trace file format
l
udhayprakash.blogspot.in
Outcomes • To get ease with Linux platform
tary • Open Source vs Free ware vs proprietar insigh ghtt abou aboutt a Netw Networ ork k Sim Simulat ulator or • To insi • • Scri Script ptin ing g lang langua uage ge vs prog progra ramm mmin ing g lang langua uage ge • Ability to install ns2, nam and xgraph • Ease in workin king with ith TCL scriptin ting • Insight to NAM and Trace files
l
udhayprakash.blogspot.in
l
udhayprakash.blogspot.in
Linux • Developed under GNU project. • Open Source software, except RedHat • Major Linux Families » Debian, Ubuntu, Mint, …. » Fedora » OpenSUSE » ArchLinux » Cent CentOS OS & RedH RedHat at
l
udhayprakash.blogspot.in
Working in Linux • Are you new to Linux Operating System?
Windows or • Are you more habituated to Windows Macintosh Operating Systems ? en, care u y o ow me… (switch on your PCs)
•
– Creating a file – Reading/writing/editing a file – Operating System specific file types
l
udhayprakash.blogspot.in
Why Simulators? • Advantages ☺Com ☺Compl plex ex sce scenari narios os can can be eas easily ily tes tested ted ☺Che ☺Cheap ap-d -doe oess no nott requ requir iree cost costly ly equi equipm pmen entt ☺Results can be quickly obtained-more ideas can be tested in a smalle sm allerr timefr timeframe ame ☺Contr ☺Controlle olled d experim experiment ental al conditi conditions ons ☺Rep ☺Repea eata tabi bili lity ty help helpss aid aid debu debugg ggin ing g
• Disadvantages ☻Not real real ☻Real systems too complex to model ☻Con ☻Consi side dera rati tion on of pract practic ical al cond condit ition ionss l
udhayprakash.blogspot.in
NS2 Network Simulator Open-s -sou ourc rcee event event-d -dri rive ven n simu simula lato tor r • Open • Designed specifically for research in computer commun communica icatio tion n networ networks. ks. •
onta ns mo u es or numerous networ components such as routing, transport layer protocol, and application.
l
udhayprakash.blogspot.in
Ns2 sources •
http://www.isi.edu/nsnam/ns/ – The source code and documentation is currently maintained by VINT project at ISI
•
http://nsnam.isi.edu/nsnam/index.php/Main_Page –
ep
,
: ns- .
re ease .
–
Mar 10, 2007: ns-2.31 released.
–
July 2, 2006: ns-3 project announced.
•
NS2 is a discrete event simulator targeted targeted at networking research
•
NS2 is an object oriented simulator, written in C++, with an OTcl OTcl interpreter as a frontend
l
udhayprakash.blogspot.in
NS2 related Documentation arcc Gr Grei eis' s'ss tu tuto tori rial al • introductory: Mar reference: Ns Manual (formerly called "ns Notes • reference: Ns and and Docu Docume ment ntat atio ion" n")) • ns y xamp e • Practical Programming in Tcl (http://www.beedub.com/book/ http://www.beedub.com/book/))
and
Tk
• http://hpds.ee.ncku.edu.tw/~smallko/ns2/ns2.htm
l
udhayprakash.blogspot.in
NS2 S2-- Feat atu ure ress • Collection of various protocols various protocols at multiple layers – – – – –
Uniform orm,, Bust Busty y, … • Error Models: Unif • Misc: Radi Radio o Prop Propag agat atio ion, n, Mo Mobi bili lity ty mod odel els, s, En Ener ergy gy Mo Mode dels ls,, … •
Topo opolog logyy Gen Genera eratio tion n too tools ls (nsg2. (nsg2.1, 1, ..) ..)
• •
Visual isualizat ization ion tools (NAM), (NAM), Tracing racing Codes are contributed from multiple research communities – Good: Large set of simulation modules – Bad: Level of support and documentation varies l
udhayprakash.blogspot.in
NS2 Chronicle • 1989: REAL by Keshav • 1995: ns by Floyd, McCanne at LBL • 1997: ns-2 by the VINT project (Virtual InterNetwork Testbed at LBL, Xerox PARC, UCB, USC/ISI • Now: ns-2.35 maintained at USC/ISI • Also there there is NS-3, but it has no backward backward compatibility with NS-2. l
dh
k h bl
NS2 Chronicle • REAL Simulator →NS (or NS1)→NS2→NS3. • NS-1 – – Developed by the network research group at the Lawrence – Berkeley National Laboratory (1989) – Derived from REAL Simulator – Simulation description language: TCL l
udhayprakash.blogspot.in
NS2 Chronicle • NS-2 – Object Object Oriented Oriented (OTcl (OTcl instead instead of TCL) – Built in C++ and provides a simulation interface through OTcl – Developed by UC Berkeley – Difficult for the first time users • Very few user friendly manuals. Ex: ns manual • Needs scripting language, queuing theory and modelling modelling techniques knowledge • Complaint about inconsistent results • And BUGS!!!!
• But, large community support l
udhayprakash.blogspot.in
NS3 • • • • • •
No backward compatibility with NS2 YANS (Yet (Yet Another Network Ne twork Simulator)→NS-3 Simulat or)→NS-3 base NS-3.1 (2008), (2008), NS-3.11(201 NS-3.11(2011), 1), … Built in C++ and python Good support su pport for LTE LTE and Wimax Simple to work with…..and suitable for dumping into and getting data from real-time devices. • No support for some protocols protocols which were supported supported in ns-2. • But, lesser community support l
udhayprakash.blogspot.in
NS-2 Directory Structure ns-allinone Tcl8.0
TK8.0
OTcl
tclcl
tcl ex examples
test
ns-2
...
lib
C++ code
mcast
validation tests OTcl code
simple.tcl l
udhayprakash.blogspot.in
nam-1
...
NS-2 Environment Simulation Scenario
1
2
set ns_ [new Simulator]
c
_
cr p
_
set node_(1) [$ns_ node]
C++ Implementation
l
clas class s Mobil MobileN eNod ode e : publi public c Node Node { friend class PositionHandler; public: MobileNode(); • • } udhayprakash.blogspot.in
NS2 Architecture
l
udhayprakash.blogspot.in
Why two languages? (Tcl & C+ C++) • C++: Detailed protocol simulations require systems programming
language – byte manipulation, packet processing, algorithm implementation – Run time s eed is im ortant – Turn around time (run simulation, find bug, fix bug, recompile, re-run) is
slower
• Tcl cl:: Si Simu mula lati tion on of sl slig ight htly ly va vary ryin ing g pa para rame mete ters rs or co conf nfig igur urat atio ions ns quic ickl kly y exp xplo lori ring ng a nu num mber ber of scen scenar ario ioss – qu iterat atio ion n tim time (cha (chang ngee the the mod odel el and re-r re-run un)) is more ore impo import rtan antt – iter
l
udhayprakash.blogspot.in
What is Tcl/Tk ? •It is a Scripting language to describe a high-level programming language with relati relativel vely y transp transpare arent nt syn syntax tax •Tools Command Lanuage (TCL) simple le stri string ng base based d scri scripti pting ng langu languag agee for for cont contro rolli lling ng and and exten extendi ding ng appl applica icatio tions ns.. –simp
– provides generic programming facilities such as variables, loops, and rocedures. –Tcl sy synt ntaax is very very much uch sim similar ilar to UNIX UNIX sh shel elll prog progra ram mming ng.. •Tool k it it (TK) – based on X-window system.
– provides facilities (widgets) for building user interfaces.
•Tcl/Tk Rapid pr proto ototyp typing ing.. Exce cell llen entt tool toolss for for Rapid –Ex –Tcl/T Thee inte interp rpre rete terr is in !/opt/bin/wish ) cl/Tk k is inte interp rpre rete ted d rath rather er than than com compile piled. d. ( Th –weak weakly ly type typed d langu languag agee (str (strin ings gs and and inte intege gerr vari variab able less are are inte interc rcha hange ngeab able le). ). l
udhayprakash.blogspot.in
Basic Tcl variables: set x 10 puts “x is $x”
procedures: proc pow {x n} { if {$n == 1} { return $x } set set part part [pow [pow x [expr [expr $n $n-1 -1]] ]] re urn expr x par }
functions and expressions: set set y [po [pow w x 2] set y [expr [expr x*x x*x]] control flow: if {$x > 0} { return $x } else { return return [expr [expr -$x] } while { $x > 0 } { puts $x incr incr x –1 } l
Also lists, associative arrays, etc. => can use a real programming language to build network topologies, traffic models, etc.
udhayprakash.blogspot.in
Basic oTcl Class Person # constructor: Person instproc init {age} { self inst instvar var age_ $self set age_ $age } # method: Person instproc greet {} { self inst instvar var age_ $self puts “$age_ years old: How are you doing?” } Person a 45 Kid b 15 a greet b greet l
# subclass: Class Kid -superclass Person Kid instproc greet {} { self inst instva varr age_ $self puts “$age_ years old kid: What’s What’s up , u e } set a [new Person 45] set b [new Kid 15] $a greet $b greet # “new” in ns2 only
=> can easily make variations of existing things (TCP, (TCP, TCP/Reno) udhayprakash.blogspot.in
Control (OTcl) vs. Data (C++) OTcl OTcl into C++: command(), tcl.result() tcl.result() C++ into OTcl: OTcl: tcl.eval()
Not all classes are mirrored mirrored exactly
OTcl
OTcl script OTcl s cript describing simulation
C++
L C l c T
C+++ an C+ and d OT OTcl cl Li Link nkag agee • Class Tcl: Tcl: instance instance of OTcl OTcl interpreter interpreter Tcl& tcl = Tcl::in Tcl::instanc stance(); e(); tcl.evalc( tcl.evalc(“puts “puts stdout hello world”) world”);; tcl.result() and tcl.error()
• Class TclOb TclObject ject and TclCl TclClass ass ariabl e bindings bind ings – Variable bind(“rtt_”, &t_rtt_) – Invoking command method in shadow class
$tcp $tcp adva advanc nceb eby y 10
l
udhayprakash.blogspot.in
Callin Cal lingg Otcl Otcl fun functi ctions ons fro from m C++ C++ • OTcl Agent/TCP instproc advance {num} { set set wind window_ ow_ [expr [expr $windo $window_ w_ + $num $num] ] return $window_ }
C++ and OT OTcl cl Se Sepa para rati tion on • “data” / control separation – C++ for “data”: core of ns • per packet processing, core • fast to run, detailed, complete control
OTcl for cont control: rol: – OTcl • • • •
Simulation scenario configurations Periodic or triggered action Manipulating existing C++ objects fast to write and change
+ runni running ng vs vs.. wri writi ting ng sp spee eed d – Learning and debugging (two languages) l
a a ma manage agemen Complex/large data structure str ucture C++ – Complex/large – One-time configuration variables
l
udhayprakash.blogspot.in
OTcl
Ns2 Installation Procedure • Linux Installation (preferred): – Go to udhayprakash.blogspot.in – Search for ns2 installation procedure –
…..
• Windows Installation – Go to http://nsnam.isi.edu/nsnam/index.php/Running_Ns _and_Nam_Under_Windows_9x/2000/XP_Using_ _and_Nam_Under_W indows_9x/2000/XP_Using_ Cygwin l
udhayprakash.blogspot.in
Where to find…/ns-2/tcl/lib find…/ns-2/tcl/lib • ns-lib.tcl: – The simulator class and most of its member function definitions
• ns-default.tcl: –
• ns-packet.tcl: – Th Thee pack packet et head header er form format at init initia iali liza zati tion on impl implem emen enta tati tion on
othe herr OT OTcl cl fi file les: s: • ot – implementation of compound network objects or the front end (con (conttrol rol part part)) of netw networ ork k ob obje ject ctss
l
udhayprakash.blogspot.in
l
udhayprakash.blogspot.in
A Simple Topology Application
n0
n1
Agent
Agent
0
0 1
0
head_
enqT_ queue_ deqT_ link_
drophead_
drpT_
Link n1 – n0
l
udhayprakash.blogspot.in
ttl_
rcvT_
N1
N2 Node
Node
C l a s s i i e r
Local
C l a s s i f i e r
C l a s s i i e r
Agent
Port
Local
C l a s s i f i e r
Agent
Port
Addr
Addr Link Enq Trace
Queue
Link
Drop head
l
Deq Trace
Delay
Drp Tr Trace ace
udhayprakash.blogspot.in
TTL
Rcv Trace
Using ns Problem
Result analysis
Simulation model Setup/run simulation with ns
l
udhayprakash.blogspot.in
Modify ns
NS-2 Generic Script Structure set ns [new Simulator] # [Turn on tracing] # [Turn on visualizer visualizer] ] # Create topology # Setup packet loss, link dynamics # Create: # - m multicast ulti ultica cas st groups grou roups # - protocol protocol agents ag agents # - applic app application licati ation on and/or and/ and/or or setup setu setup p traffic traff traffic ic sources sour sources ces # PostPost-processing -processing procs # Start simulation
l
udhayprakash.blogspot.in
Event Scheduler Creation •
Event is a packet ID that is unique for a packet, which constitutes: – 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
• Create event scheduler: set ns [new simulator] • Schedule an event: $ns at