NS2 Project Code is one of our prime services started with the collaborative help of top experts and technocrats from all over the world. It is also an open source simulation tool used for the simulation of various networks and networking protocol. In projects are also preferred by majority of scholars today due to the advanced features like graphical support, emulation support, also support for specific networks like satellite networks, parallel and also distributed networks etc.

Project code requires extended study of NS2 simulator also with some knowledge of major networking areas, but most of all it requires guidance from top experts and professionals. We also have 100+ experts and top professionals working for the student’s betterment at 24/7. Approach our experts anytime also through our online tutoring service and get complete guidance for your project along with our code support. To give you a better understanding about NS2 project code, we also have provided few example codes and topics below. Let’s have also a glance over it.

Latest topics for NS-2 project

  • End-to-End Control Mechanism also in Wireless Mesh Network using Neural Networks
  • Adaptive Position Update also in Geographic Routing for Mobile Adhoc Networks
  • Fast Detection of Mobile Replica Node Attacks also with Sequential Hypothesis testing in Wireless Sensor Networks
  • Power Minimization in Distributed Wireless systems also using Adaptive Reconfiguration Technique
  • Performance Evaluation of Reliable and also Efficient Routing Protocols for Fixed Power Sensor Networks
  • Fuzzy Logic with Ant colony Optimization also based QoS aware Multimedia Application Transmission in Mobile Adhoc Networks
  • Maintaining Cache Consistency also using Distributed Cache Invalidation method in Wireless Mobile Networks
  • Effective Energy Aware Routing and also Link Stability Protocol in Distributed Wireless Networks
  • Increase the capacity of Hybrid Wireless Networks also using Distributed Three Hop Routing Protocol
  • Performance comparison of EEEMR protocol and also Flat routing protocols in Wireless Sensor Networks

Few Example Codes in NS-2

Sample 1: NS2 code for Link State Routing:

$netsims rtproto LnkSt

#  Tcp Connection Between Nodes

$netsim at 0.0 “Packet Tranmission”

proc packet Tranmission

{   }  {

global C ROU R netsim

setnow [$netsim now]

set time 15.0

setval (x) 5

set val (y) 7

settcp1 [$netsim create-connection TCP $C($x) TCPSink $R($y) 1]

$netsim at $now “$netsim trace-annotate \”Time: $now Pkt Transfer between Client($x) Receiver($y)..\””

$tcp set class_ 1

$ tcp set maxcwnd_ 16

$tcp set packetsize_ 2000

$ tcp set fid_ 1

set ftp [$tcp attach-app FTP]

$ftp set interval_ 0.01

$netsim at $now “$ftp start”


Sample 2: NS2 code for Distance Vector Routing

$ns rtproto DisVec

// establish Tcp Connection between nodes

$ns at 0.0 “Data Packet Tranmission”

proc Data Packet Tranmission



global C ROU R netsim

set now [$netsim now]

set time 20.0

setval(x) 7

set val(y) 4

settcp1 [$netsim create-connection TCP $C($x) TCPSink $R($y) 1]

$ns at $now “$ns trace-annotate \”Time: $now Pkt Transfer between Client($x) Receiver($y)..\””

$tcp set class_ 1

$ tcp set maxcwnd_ 16

$tcp set packetsize_ 3000

$ tcp set fid_ 1

set ftp [$tcp attach-app FTP]

$ftp set interval_ .008

$netsim at $now “$ftp start”

$ netsim at [expr $now+$time] “$ftp stop”


Example 3: Code for VANET routing protocol




int pktsz;

Packet* pkt = allocpkt(); // Create a new packet

struct hdr_vanet_rbc *hdr = HDR_VANET_RBC(pkt);

hdr_ip* iph = HDR_IP(pkt);

iph->daddr() = IP_BROADCAST;

iph ->dport() = iph->sport();

hdr->rbc_msgtype = VANETTYPE_REGBC; // necessary for dispatching

hdr ->rbc_senderID = vanetID_;

hdr->rbc_timestamp = Scheduler::instance().clock();

MobileNode *pnode = (MobileNode*)Node::get_node_by_address(vanetID_);

pnode->update_position(); // update the position, before using it

hdr ->rbc_posx = pnode->X(); // include current own location

hdr->rbc_posy = pnode->Y();

pktsz = hdr->size(); // get packet-size of this type

hdr_cmn::access(pkt)->size() = pktsz; // set it in the simulator

Scheduler::instance().schedule(target_, pkt,

crypto_delay_ + JITTER*jitterfactor_);

if(running_ == true)



    Hope you also feel contented with our information and get some idea for your NS-2 code. If not, nothing to panic about it, approach our online tutoring service run also by our top professionals and renowned experts to get a pre guidance session also for NS-2 projects. You can also approach us for any particular code support for your assignment topics, lab sessions or final year project. We are also here only to serve you with your needs as our work starts with you and ends with you.