Nam File in Ns2 Projects plays a significant role as without NAM, output cannot be visualized in NS2. It is GUI tool for NS2, which makes it a significant component of NS2 and our major focus too. NAM file is a separate program which is distributed with NS2 simulator to read an input file and draw the network events graphically. It is used to visualize the progression of packets through the Network. As we are working with NS2 for the past 10 years, we are well aware about each nook and corner of NS2. This is the reason; we can focus on each concept of NS2 in an elaborate way. Here, we have focused on NAM file in NS2 projects. Now, let’s learn few basics about NAM to get an idea about what is NAM actually.


NAM[Network Animator]:

  • TCL/TK based animation tool used to view real world packet traces and network simulation traces.
  • It supports:

                    -Topology layout

                    -Packet level animation

                    -Various data inspection tool

  • Support for graphical interface[provides information about the number of packet drops at each link]

NAM in NS2 highlights:

  • Provides visual interpretation of overall network
  • Executes from the TCL script directly
  • Provides controls for play, stop, pause, display speed controller, packet monitor facility etc.
  • Supports for drag and drop interface for creating topology
  • Provides information regarding the overall throughput, number of packets transmission on each link etc.
  • NAM graph shows the overall graphical representation of packet flow[i.e. when the packets are received or dropped].
  • NAM files contains the work flow of TCL script
  • To execute a NAM, use the following command:

Exec  nam  $filename

How the NAM file looks like:

   We have provided the NAM code generated for each TCL script written in NS2. This will give you an idea about what is NAM and how it looks like.


  • If we change the color of the nodes, the nam file will generate like

              n -t 0.4 -s 6 -S COLOR -c green -o gold -i green -I gold

              n -t 1.1 -s 8 -S COLOR -c brown -o gold -i brown -I gold

  • If suppose, we add Marks on the Node, the NAM fle will be generates as:

              m -t 0.40000000000000002 -s 6 -n m1 -c green -h hexagon

              m -t 0.59999999999999998 -s 7 -n m1 -c red -h square

  • If suppose, we add Labels on the Node, the NAM file will look like:

               n -t 0.40000000000000002 -s 6 -S DLABEL -l “SOURCE” -L “”

               n -t 0.59999999999999998 -s 7 -S DLABEL -l “DESTINATION” -L “”

  • If suppose, packet transmission occurs in simulation, the NAM will be generated as:

                h -t 4.356591980 -s 6 -d -1 -p tcp -e 1040 -c 2 -a 0 -i 78 -k AGT

                + -t 4.356591980 -s 6 -d 5 -p tcp -e 1040 -c 2 -a 0 -i 78 -k RTR


How to generate Executable file for NAM:

  • Using “Make” command, we can create an object file and NAM file[Executable file] in NS2
  • It needs Makefile, Install-sh and few installation file[like,, address.h,,, bbox.h, ,bin/ etc] support.

Concepts to be focused in NAM:

  • NAM Trace format
  • Nam Command line options
  • User Interface in NAM
  • Keyboards Commands in NAM
  • Network Layout for NAM
  • Animation objects in NAM
  • Generating External Animations using NAM


      We have discussed in detail about each of the above mentioned concepts in our other articles in this site, you can refer it for further information. In this article, we have provided an overview of NAM in NS2. For further guidance on NAM File in NS2 projects, approach us through our online service. We will offer you complete guidance for your project accomplishment along with basic tutoring on NAM in NS2.