NS2 SIMULATOR TUTORIAL

      NS2 Simulator Tutorial offers you brief and compact information about NS2 to equip you with some basics of NS2. Our Simulator Tutorial service is a collaborative effort of top professionals and technocrats from all over the world. To be precise, we can say that our service is started in a motive, to share our valuable information with the budding students to make their career enlighten with our knowledge. NS2 is an open source simulator used to simulate wide range of networks and networking protocols. To work with NS2, one must be well aware of C++ and TCL. Students can approach our online tutoring service to learn the basics of NS2 along with complete NS2 programming fundamentals.

We follow an innovative approach to tutor students i.e. project based learning. Students can undertake a project in NS-2 along with that, they can experience our complete tutoring on NS-2. This is the right time to think and approach us, as time will never wait for your turn; you have to take right step at right time.

LEARN THE BASICS OF NS-2:
Languages Used:
  • C++[Used to define the mechanism of each block like scheduling events, packet forwarding, collecting statistics etc ]
  • OTCL[Object oriented Extension of TCL(Tool Command language)]

Major Components:

NAM[Network Animator]:
  • Used to view the Network simulation traces
  • Supports packet transmission, topology, data inspection etc
  • During the execution of simulation, it supports animation
Trace File:
  • Used to store the coverage information or overall network information
  • To generate a trace file, we have to first create a trace file using OTCL Script.
X-Graph:
  • Used to visualize the resulting graph
AWK Script:
  • Used to process the data from the log[i.e. trace file]
Ns2 Simulation:
  • Define the Simulation Object
  • Connect the object with each other through links
  • Start the Source applications.
  • Packets are creates and transmitted through the network
  • Exit the simulation at fixed time

Programming with NS2:

Create an Event Scheduler:

Set  ns [ new  simulator ]//create a new simulator

$ ns  at  < time >   < event >//Schedules the event

$ns   run// Start the scheduler

Tracing in NS2:

General syntax:  $ns   traceall[open   filename.tr   w]

<event>  <time>  <from>  <to>  <pkt>  <size>

………………………………………………….

<flowid>  <src>  <dst>  <seqno>  <aseqno>

Trace file format[12 fields]:
  • Event[packet dropped, added to queue , received]

+  = Add to queue

-= To remove from queue

D= drop the packet

R = received the packed

  • Time[Second field used to indicate the time at which the event occurs]
  • From and to Node[Used to specify the sender and receiver of current package]
  • Packet type[5th field-represent the packet type(FTP,CBR, HTTP)]
    • -Tcp[TCP packet]
    • -Aodv[AODV packet]
    •  -Cbr[CBR traffic packet]
  • Packet Size[sixth field used to show the packet size(bytes)]
  • Flags[seven flags are used- disabled, ECN echo(C), priority in IP header is enabled(P), TCP fast start(F), Congestion action(A), Congestion experienced(E), explicit congestion notification is on(N)]
  • Flow ID[provides IP flow id as per IPv6]
  • Source and destination address[specified as addr.port-port is also specified]
  • Sequence number[agents attach sequence number with packets]
  • Packet ID[Unique identifier for each packet]
Sample trace file

+  0.52  0  1 cbr  100——  0  0.0  5.0   0   2

–   0.52  0  1 cbr  100—– 0   0.0  5.0  0   2

r  0.524 0  1 cbr  100 ——0   0.0   5.0  0   0

To create Network topology:
  • Link creation between two nodes:
First create nodes using

set  n1 [ $ns   node ]

setn2 [ $ns   node ]

Now, create link using the command:

$ns  < link_type(Simplex/duplex)>  $n1  $n2  <bandwidth>  <delay>  <queue-type>

For ex. – $ns duplex-link $n1  $n2 5Mb 100ms Drop Tail

To create transport connection and generate traffic:

Traffic generation[FTP, telnet]

set   ftp  new  Application / FTP  ]

set    telnet    [new   Application /  Telnet ]

  • For data sending
//create UDP agent

set  udp1 [ new   Agent/ UDP  ]

$ns  attach – agent $n1  $udp1

//Create CBR traffic source

set  cbr1  [ new   Application / Traffic / CBR ]

$cbr1  set  packetSize_ 100

$ cbr1  set interval_ 0.05

$cbr1  attach – agent  $udp1

 // to create a traffic Sink

 set  null1  [ new  Agent/Null ]

$ns  attach – agent$n2  $null1

// To connect the agents

$ns  connect   $udp1   $null1

// to start and stop

$ns  at  0.1 “$cbr0 start”

$ ns  at  1.0 “$cbr0 stop”

     We have provided an overview about NS2, for students to get an insight about NS2 basics and syntax. Beginners can get comprehensive knowledge about NS2 through our NS2 Simulator Tutorial service. If you feel to have further guidance on NS2, approach us through our online tutoring service or you can also refer our other articles available in this site. You can also approach us for any kind of support regarding your NS2 based projects/research, assignments or lab cycles. We are there for you at 24/7, approach us anytime, through anyway

BEING THE BEST DOESN’T MATTER…………………

DOING THE BEST…………ALWAYS MATTERS………

LET’S JOIN TOGETHER TO BRING OUT THE BEST……………..