Hi All, Our website moved to a new URL. Please bookmark the new link: https://ns2bloggers.blogspot.com/

Saturday 5 April 2014

INTRODUCTION TO NETWORK SIMULATOR 2

INTRODUCTION 

Network Simulator Version 2, widely known as NS2, is an event driven simulation tool that is useful in studying the dynamic nature of communication networks. Simulation of wired as well as wireless network functions and protocols (e.g., routing algorithms, TCP, UDP) can be done using NS2. In general, NS2 provides users with a way of specifying such network protocols and simulating their corresponding behaviors. Due to its flexibility and modular nature, NS2 has gained constant popularity in the networking research community since its birth in 1989. Ever since, several revolutions and revisions have marked the growing maturity of the tool, thanks to substantial contributions from the players in the field. Among these are the University of California and Cornell University who developed the REAL network simulator,1 the foundation which NS is based on. Since 1995 the Defense Advanced Research Projects Agency (DARPA) supported development of NS through the Virtual InterNetwork Testbed (VINT) project.Currently the National Science Foundation (NSF) has joined the ride in development. Last but not the least, the group of researchers and developers in the community are constantly working to keep NS2 strong and versatile.

BASIC ARCHITECTURE OF NS2

Figure given below shows the basic architecture of NS2. NS2 provides users with an executable command ns which takes on input argument, the name of a Tcl simulation scripting file. Users are feeding the name of a Tcl simulation script (which sets up a simulation) as an input argument of an NS2 executable command ns. In most cases, a simulation trace file is created, and is used to plot graph and/or to create animation.




NS2 consists of two key languages: C++ and Object-oriented Tool Command Language (OTcl). While the C++ defines the internal mechanism (i.e.,a back end) of the simulation objects, the OTcl sets up simulation by assembling and configuring the objects as well as scheduling discrete events (i.e.,a front end). The C++ and the OTcl are linked together using TclCL. Mapped to a C++ object, variables in the OTcl domains are sometimes referred to as handles. Conceptually, a handle (e.g., n as a Node handle) is just a string (e.g.,o10) in the OTcl domain, and does not contain any functionality. Instead, the functionality(e.g., receiving a packet) is defined in the mapped C++ object (e.g., of class Connector). In the OTcl domain, a handle acts as a front end which interacts with users and other OTcl objects. It may defines its own procedures and variables to facilitate the interaction. Note that the member procedures and variables in the OTcl domain are called instance procedures(instprocs) and instance variables(instvars), respectively. Before proceeding further, the readers are encouraged to learn C++ and OTcl languages and we include it on our previous posts.

NS2 provides a large number of built in C++ objects. It is advisable to use these C++ objects to set up a simulation using a Tcl simulation script. However, advance users may find these objects insufficient. They need to develop their own C++ objects, and use a OTcl configuration interface to put together these objects. After simulation, NS2 outputs either text-based or animation-based simulation results. To interpret these results graphically and interactively, tools such as NAM (Network AniMator) and XGraph are used. To analyze a particular behavior of the network, users can extract a relevant subset of text-based data and transform it to a more conceivable presentation.

INSTALLATION

NS2 is a free simulation tool. It runs on various platforms including UNIX (or Linux), Windows, and Mac systems. Being developed in the Unix environment, with no surprise, NS2 has the smoothest ride there, and so does its installation.

NS2 source codes are distributed in two forms: all-in-one suite and the component-wise. With the all-in-one package, users get all the required components along with some optional components. This is basically a recommended choice for the beginners. This package provides an “install” script which configures the NS2 environment and creates NS2 executable file using the “make” utility. The current all-in-one suite consists of the following main components : 
  • NS release 2.30,
  • Tcl/Tk release 8.4.13,
  • OTcl release 1.12, and
  • TclCL release 1.18.
and the following are the optional components:
  • NAM release 1.12: NAM is an animation tool for viewing network simulation traces and packet traces.
  • Zlib version 1.2.3: This is the required library for NAM.
  • Xgraph version 12.1: This is a data plotter with interactive buttons for panning, zooming, printing, and selecting display options.
The idea of the component-wise approach is to obtain the above pieces and install them individually. This option save considerable amount of downloading time and memory space. However, it could be troublesome for the beginners, and is therefore recommended only for experienced users.

Click the following links to know more about installation:



14 comments :

  1. Hello, I read this article..that gave me idea about ns2..i need to implement 802.11e(EDCA) in ns2..i dont know anything about TCL scripting ..i dont know where to start..can anyone explain what should i do??.it'll be really kind of you..Thanks..

    ReplyDelete
    Replies
    1. Pls go through our page programs for you for wlan programs..

      Delete
  2. pls tell me how to start the simulation after the execution of tcl script (i need a command or function not view the results graphically because I have a lot of test)

    ReplyDelete
    Replies
    1. YOU CAN SEE THE SIMULATION OUTPUTS BY USING NAM,XGRAPH OR BY USING AWK SCRIPT. FOR GRAPHIC REPRESENTATION,USE XGRAPH.

      IF YOU MAIL YOUR PROGRAM WITH A DETAILED DESCRIPTION,WE WILL CORRECT IT FOR YOU...MAIL US IN.. www.ns2blogger@gmail.com

      Delete
    2. the problem is not how to see the simulation, but how to start the simulation, ineed a command for the button to play forward
      http://www.hostingpics.net/viewer.php?id=295267image3.png

      Delete
    3. CLICK ON PLAY BUTTON AND INCREASE SPEED OF STEP..YOU CAN SEE SIMULATION FASTLY....

      Delete
    4. Press F or f to move fast forward.

      Delete
    5. I have hundreds of tests, unreasonable to do it every time and because of this I want a command or function or script for do that(just i nedd the party of launching the simulation)

      Delete
    6. nam [ -g geometry ] [ -t graphInput ][ -i interval ] [ -P
      peerName ] [ -N appName ] [ -c cacheSize ] [ -f configfile ]
      [ -S ] tracefile


      Command Line Options

      -g Specify geometry of the window upon startup.
      -t Instruct nam to use tkgraph, and specify input file nam for tkgraph.
      -i [Information for this option may not be accurate] Specify rate (real) milliseconds as the screenupdate rate. The default rate is 50ms (i.e., 20 frames per second). Note that the X server may not be able to keep up with this rate, in which case the animation will run as fast as the X server allowsit to (at 100% cpu utilization).
      -N Specify the application name of this nam instance. This application name may later be used in peer synchronization.
      -c The maximum size of the cache used to store 'active' objects when doing animating in reverse.
      -f Name of the initialization files to be loaded during startup. In this file, user can define functions which will be called in the trace file. An example for this is the 'link-up' and 'link-down' events of dynamic links in ns. (Refer to $ns rtmodel for detail, and tcl/ex/simple-dyn.tcl in your ns direc-tory for example). Example initialization files can be found at ex/sample.nam.tcl and ex/dynamicnam.conf.
      -a Create a separate instance of nam.
      -p Print out nam trace file format.
      -S Enable synchronous X behavior so it is easier for graphics debugging. For UNIX system running X only.
      is the name of the file containing the trace data to be animated. If cannot be read, nam will try to open .nam.

      Delete
    7. Please an example,i don't know how to process this command

      Delete
  3. Please an example,i don't know how to process this command

    ReplyDelete
  4. hi
    i want to adjust transmission range of base station such that it transmit in different range on same interval

    ReplyDelete
    Replies
    1. the simplest way to change the transmission range is by varying the transmitting power

      Delete
  5. For peoples who want to install NAM (Network AniMator), just open Terminal and Type the following:

    sudo apt-get install nam

    ReplyDelete