The Network Simulator NS-2

 

 

Ns is a discrete event simulator targeted at networking research. Ns provides substantial support for simulation of TCP, routing, and multicast protocols over wired and wireless (local and satellite) networks. All the documentation is accessible at  www.isi.edu/nsnam/ns.

 

 

 

Running NS

 

 

NS is Object-oriented Tcl (OTcl) script interpreter that has a simulation event scheduler, network component object libraries, and network setup module libraries. In other words, to use NS, you program in Tcl/OTcl script language. To setup and run a simulation network, a user should write an Tcl/OTcl script that initiates an event scheduler, sets up the network topology using the network objects and the plumbing functions in the library, and tells traffic sources when to start and stop transmitting packets through the event scheduler.

 

When a simulation is finished, NS produces one or more text-based output files that contain detailed simulation data, if specified to do so in the input Tcl (or more specifically, OTcl) script. The data can be used for simulation analysis or as an input to a graphical simulation display tool called Network Animator (NAM).

 

NAM has a nice graphical user interface similar to that of a CD player (play, fast forward, rewind, pause and so on), and also has a display speed controller. Furthermore, it can graphically present information such as throughput and number of packet drops at each link, although the graphical information cannot be used for accurate simulation analysis.

 

Apart from NAM, a plotting program XGRAPH can be used to create graphic representations of simulation results. XGRAPH is a general purpose x-y data plotter that can plot data from any number of files on the same graph.

 

NS-2 software package contains following mandatory components:

-         Tcl – tool command language

-         Tk - graphical user interface toolkit

-         OTcl – an extension to Tcl/Tk for object-oriented programming

-         TclCL -  Tcl with classes is a Tcl/C++ interface used by ns, and nam.   It provides a layer of C++ glue over OTcl.

-         ns – network simulator

Also it contains some optional components such as:

-         nam -  graphical simulation display tool

-         xgraph – plotting program

 

All of those components are installed on your Unix systems. To run network simulator application you need to:

 

-Log into a Unix system (most of the 9th floor labs) using your ECE account. You can check whether you are logged into a Linux system by using the command 'uname -a'. This will give you the system information.

- If you're logged into a Linux system, please go to a Unix lab or
use one of the following commands to log into a Unix system:

 

ssh   your_username@cavendish.ece.concordia.ca

or

ssh your_username@dea.ece.concordia.ca

 

 

Executables ns, nam, xgraph can be found in /usr/local/bin directory.

For example if you type at the command line:

          which ns

the output should be:

          /usr/local/bin/ns

 

If this is not the case you need to update your .cshrc file and make sure it does not contain any path settings that point to any other ns package.

 

 

You start ns by typing:

-         ns tclscript

at the command line (assuming that you are in the directory with the ns executable, or that your path points to that directory), where tclscript is the name of a Tcl script file which defines the simulation scenario (i.e. the topology and the events) that you will be creating (tcl script files have .tcl extension). If your tcl script is not in the directory from which you are executing the ns command you need to specify the full path name of  your tcl script. You could also just start ns without any arguments and enter the Tcl commands in the Tcl shell.

 

In your tcl script you can specify if you want to invoke the nam or xgraph application in which case the ns will automatically do it after it completes the simulation, and you will be able to see it’s results in a graphical format. All of this will be much clearer once you complete the tutorials.

 

 

 

NS-2 Tutorials

 

 

All the documentation on NS-2 is available at www.isi.edu/nsnam/ns . You are advised to first start with “ns by Example” and read Purpose, Overview, and OTcl: The User Language chapters, then switch to Marc Greis’s tutorial and after completing chapters I-VIII go back to “ns by Example” and read the remaining chapters. The NS Manual contains detailed information but it is more useful once you have some experience with NS-2, that is why you should first go through the tutorials. To complete the tutorials knowledge of Tcl, Otcl  and C++ would be an asset but it is not a requirement. Reference to the documentation on Tcl, Otcl  and C++ is available as a part of Marc Greis’s tutorial.