NS2 Program Help is an initiative started with a collaboration of top experts and programmers from all over the world. We have started our service 7 years before and completed 7 successful years with an inner satisfaction that we have served our students as per their needs. The main focus behind our service lies in the fact that our skills and expertise must be useful for the budding students. Our experts have an experience of 10 years in the field of NS2, which makes them to develop simple and efficient programs. In programs reflect our code efficiency and expertise, which shows our efforts and dedication for our students. You can approach us for Code support in NS2 regarding your final year projects, assignment topics, lab cycles or research work. We will provide best code, as per your need to make your work to speak about your efficiency and potential.


In the NS2 Program Help is a major service started for the students who seek for external guidance regarding code support in NS2. You may think that why we have given so much importance on programming help. Program is the soul of any simulation project you undertake as it decides the final outcome. As NS2 is one of the popular simulators used by majority of scholars today, we are focused about NS2 programming support.


You may be an expert of NS2, but sometime you may not get with the perfect output, you expect. In such a situation, you don’t have to be panic, just click one call to us; we will find best solution for your problem. For students, who seek for programming help in a particular algorithm, project, assignment topic, routing protocols or any code in NS2, can aid our online guidance support. Now, let’s focus on few basic programming aspects of Ns2, for scholars to get an idea about NS2 programs.


Before learning about NS2 program, we must learn about the overall simulation process involved in NS2. Once you are clear with this, we can proceed towards the basics of NS2.

Simulation phase in NS2

Pre-Simulation phase:
  • Uses OTCL script writing for Scenario generation using Scenario file and traffic pattern
  • OTCL is used to control the over all simulation setup and configuration.
Execution phase:
  • Based on the trace file and NAM file
  • NAM[Network Animation] files are used to record the simulation in text files and uses it back in the simulation for animation
Post Simulation phase:
  • Converts the trace file in the format suitable for XGraph
  • Utilizes “awk” and “perl” scripting languages
Learn to program in NS2:

         Programming in NS2 mainly involves two major things to learn i.e. programming language used and platform support. NS2 is based on two major languages i.e. C++ and OTCL. Next to talk about platform support, NS2 works on Windows, Unix, Linux, MAC OS X etc. Major concepts involved in NS2 are Routing, clustering, unicast and Multicast protocol, Queue management etc. We can simulate both wired and wireless networking concept in NS2. Let’ take few basic commands in NS2, to learn the basics of NS2 programming.

Code for Node Connectivity:

$ns at 0.5000 “$node_(1) setdest 150 450 0.15667896543”

$node_(1) set Z_ 0.0

$ node_(1) set Y_ 128

$node_(1) set X_ 44

To create a link between Nodes:

$ns duplex-link $node_(1) $node_(5) 2Mb 40ms RED

To activate NAM trace

$ns namtrace-all $file

This are just few sample commands used in NS2, to get a better idea about NS2 programming, we have provided a complete structure of NS2 program.

Basic program in NS2

# Setup Network Simulation

set ns [new Simulator]

#Configuring Node

$ns node-config -adhocRouting $val(adhocRouting) \

-llType $val(ll) \

-macType $val(mac) \

-ifqType $val(ifq) \

-ifqLen $val(ifqlen) \

-antType $val(ant) \

-propType $val(prop) \

-phyType $val(netif) \

-channelType $val(chan) \

-topoInstance $topo \

-agentTrace ON \

-routerTrace ON \

-macTrace OFF \

-movementTrace OFF\

-energyModel “EnergyModel” \

-initialEnergy 1000

#intializing Trace and Nam

set tracefd       [open Smart_Grid_Network_Topology.tr w]

set namtrace      [open Smart_Grid_Network_Topology.nam w]

#Activating nam Trace

$ns trace-all $tracefd

$ns namtrace-all-wireless $namtrace $val(x) $val(y)

set topo       [new Topography]

$topo load_flatgrid $val(x) $val(y)


create-god (1)

source len

set god_ [God instance]

#Positioning Nodes

$ns at 0.5000 “$node_(0) setdest 100 400 0.15667896543”

$node_(0) set Z_ 0.0

$ node_(0) set Y_ 128

$node_(0) set X_ 142

$ns at 0.5000 “$node_(1) setdest 150 450 0.15667896543”

$node_(1) set Z_ 0.0

$ node_(1) set Y_ 128

$node_(1) set X_ 44

# Formation of Link

$ns duplex-link $node_(1) $node_(0) 5Mb 50ms BLUE

#$ns at 0.0 “$ns trace-annotate \”MOBILE NODE MOVEMENTS\””

for {set i 0} {$i < $val(nn)

}{  incr i

} {

$node_($i) color blue}

for {set i 0} {$i < $val(nn) }


incr i } {

$node_($i) color blue

$ns at 0.0 “$node_($i) color black”


#setting initial position

for {set i 0} {$i < $val(nn)} { incr i } {

$ns initial_node_pos $node_($i) 20}

#$ns at $val(stop) “$ns nam-end-wireless $val(stop)”

$ ns at $val(stop) “stop”

$ns at 130.01 “puts \”end simulation\” ; $ns halt”

proc stop {} {

global ns tracefd namtrace

$ns flush-trace

close $tracefd


#Run Simulation

$ns run

Programming help in the following Networking areas of NS-2
  • Wireless Sensor Networks
  • Ad hoc Networks
  • Vehicular Ad hoc Networks
  • Underwater Acoustic Networks
  • Satellite Networks
  • Networking systems and algorithms
  • Wireless Networking
  • Energy efficient Networking
  • Cognitive Radio Network
  • Software defined Network
  • Wireless body area Network
Programming help in the following topics:
  • On the use of ns2 also for evaluate mobile ip in dsdv routing protocol performance
  • An effective mechanisms also for wireless networks of adaptive coding in scalable video
  • An efficient mechanisms also for high rate multi hop wpans for analysis in formation of scatternet
  • A study of Multipath random also forward concurrent crosslayer algorithm
  • An efficient mechanism of spin data centric wireless sensor network also for node density selection in cluster

    You may feel contented also with our above mentioned information. For further guidance and also support in NS2 programs, approach our online service. We will also there for you at 24/7.