E N D
Introduction to NS2 T S Pradeep Kumar VIT Chennai http://www.nsnam.com http://www.pradeepkumar.org pradeepkumarts@gmail.com 1
Overview ✤Linux Vs Windows ✤Network Simulation ✤Introduction to NS2 ✤NS2 Architecture ✤OTCL 2
Use Linux • Verss Because…. ✤Support has been stopped beyond NS-2.27 in windows ✤Package Configuration is tedious in windows ✤Use NS2 at your own risk in windows ✤Also now the recent architecture of windows8x family is experiencing lot of difficulties in tuning cygwin or mingw. 3
Ò Linux for NS2 ✕You may use any distributions like Ubuntu, Fedora, Linux Mint, RHEL/CentOS, etc. É Know basic commands (ls, chmod, tar, rpm, make, gedit, vi, pwd, passwd, echo, cd, etc) É Know the directory structure and shell prompt in linux and NS2 É Understand Path variables setting, Installation of packages and dependencies for corresponding distribution. 4
Basic Linux Commands ✤ ls – to list the directory contents ✤ chmod – changing the mode of the file ✤ tar – tape archive (to compress or decompress) ✤ rpm – a type of installation file for linux ✤ make – to compile or recompile in linux ✤ gedit or vi – editors (similar like notepad) ✤ pwd - present working directory ✤ passwd – to change the user passwd ✤ echo – to echo to the screen ✤ cd – change directory ✤ mkdir – to create a directory 5
Linux basics ✤ To run the install file within the directory scope ✤ $prompt] ./install ✤To run the install file in global scope is ✤$prompt] install TS PRADEEP KUMAR 6
Network Simulation ✤ Approaches ✤ Experiment ✤ Put all network Devices and measure the results/performance ✤ Pros - realistic ✤ Cons - Expensive/Sometime impossible ✤ Mathematical model ✤ Model devices using a graph model ✤ Insight ✤ Need to make assumptions ✤ Simulation ✤ Use programming to represent devices ✤ Easy and can be easily verified ✤ Not much insight, need to make assumptions TS PRADEEP KUMAR 7
Network Simulation ✤ Network Simulation ✤ Event Driven ✤ Every event provide a reference to the next event (Example: using pointer) C A B ✤ Simulation finishes ✤ When there are no more events ✤ At pre-specified time TS PRADEEP KUMAR 8
About NS2 ✤ NS is a discrete event simulator ✤ It provides support for ✤ Simulation of TCP ✤ Routing ✤ Huge number of protocols ranging from wired to wireless networks ✤ Supports the addition of new entities like agent, packet, application, queue, protocol, routing, etc. TS PRADEEP KUMAR 9
About NS2 ✤ NS2 is not a polished or a finished product ✤ Errors/Bugs are being discovered and corrected. ✤ Users of ns are requested to verify that the results are not invalidated by bugs. TS PRADEEP KUMAR 10
NS2 Architecture ✤ Network Simulator 2 is an event driven Simulator ✤ It consists of ✤ C++ (Internally) ✤ OTCL (User Interface) ✤ TclCL (Interface between C++ and OTCL) TS PRADEEP KUMAR 11
NS2 Architecture TS PRADEEP KUMAR 12
NS2 Architecture TS PRADEEP KUMAR 13
OTCL ✤ NS is a OTCL interpreter with network simulation object libraries ✤ Relation between TCL & OTCL is similar to C & C++ ✤ To run a Tcl File and animation file ✤ ns filename.tcl (or) tclsh filename.tcl ✤ nam filename.nam 15
OTCL Example # Create a class call "mom" and add a member function call "greet" Class mom mom instproc greet {} { $self instvar age_ puts "$age_ years old mom say: How are you doing?" } 16
OTCL Example # Create a child class of "mom" called "kid" and overide the member function "greet" Class kid -superclass mom kid instproc greet {} { $self instvar age_ puts "$age_ years old kid say: What's up, dude?" } 17
OTCL Example ✤ # Create a mom and a kid object set each age ✤ set a [new mom] ✤ $a set age_ 45 ✤ set b [new kid] ✤ $b set age_ 15 ✤ # Calling member function "greet" of each object ✤ $a greet ✤ $b greet 18
To run the above file ✤ Open an Editor preferably gedit or Text Editor in Linux ✤ Type the program ✤ Mom Class ✤ Kid Class ✤ creation of object of both classes ✤ Run the File using ✤ ns momkid.tcl 19