NS2 SIMULATOR PROGRAM

      NS2 Simulator Program is generally written in C++ and TCL. C++ is used as a programming language where as TCL is used as Scripting language. Without the knowledge of these two languages, you cannot work with NS2. In Ns2, overall network is consist of wired/wireless nodes, links, applications, agents and TCP/UDP protocols. Major simulation tasks like node construction, node configuration, link connection and also protocol implementation is done in TCL, while major background concepts are implemented in C++. Both the languages are integrated to work in NS2, and also finally the output is displayed using NAM [Network Animator].

We also have discussed an over all implementation need of NS2 Simulator program. Next we also have to focus on the major networking concepts implemented in NS2. We can also work with clustering algorithms, security algorithms, Security attacks, handover mechanisms, also Routing protocols etc in NS2. Here, we also have focus on routing protocols and its example programs to explain you better about NS-2 programs.

Implementing Routing Protocol in NS2

        Routing in Network plays also a significant role; it is also used to select a specific path for packet transmission. Path Selection may also based on the security concern or the effectiveness of the particular path. Efficient Routing will increase the packet delivery ratio and also throughput, which will also increase the overall Quality of Service. Each Network consist of numerous Routing protocols, we also have enumerated few major Routing protocols in the following Networks.

Mobile Ad-hoc Network
  • Ad hoc On-demand distance Vector also in Routing protocol
  • Optimized Link state Routing
  • Dynamic Source also in Routing
  • Destination Sequenced Distance vector also in Routing protocol
Underwater Acoustic Sensor Network
  • Depth based Routing protocol
  • Vector based forwarding also in protocol
  • Location based Routing protocol
  • Focused beam also in Routing protocol
  • Robustness Improved Location also in protocol
  • Hop by hop dynamic Addressing based protocol
  • Adaptive Routing protocol
  • Path unaware layered also in Routing protocol
  • Low propagation delay Multi-path also in Routing protocol
  • GPS-free also in Routing protocol
  • Pressure Routing protocol
Zigbee Network
  • Self learning also in Routing protocol
  • Fuzzy logic based Tree also in Routing protocol
  • Shortcut tree also in Routing protocol
  • AODV with local Repair Trials also in Routing
  • Neighbor Tree Routing
  • AODV fuzzy logic[AODV-FL]
  • Multi-path Energy balance also in Routing algorithm
Vehicular Delay Tolerant Networks
  • Distance Aware Routing also with Copy control
  • Geographical opportunistic Routing
  • Adaptive Carry-Store-forward
  • Fastest-ferry Routing also in DTN-Enabled VANET
  • Geographical spray also in VDTN
  • Density Adaptive Routing also with Node awareness

Examples of NS2 Simulator program

DSR in NS2:

void XmitFailureCallback(Packet *pkt, void *data)

{

DSRAgent *agent = (DSRAgent *)data;

agent->xmitFailed(pkt);

}

void XmitFlowFailureCallback(Packet *pkt, void *data)

{

DSRAgent *agent = (DSRAgent *)data;

agent->xmitFlowFailed(pkt);

}

void SendBufferTimer::expire(Event *)

{

a_->sendBufferCheck();

resched(BUFFER_CHECK + BUFFER_CHECK * Random::uniform(1.0));

}

void DSRAgent::dropSendBuff(SRPacket &p)

{

trace(“Ssb %.5f _%s_ dropped %s -> %s”, Scheduler::instance().clock(),net_id.dump(), p.src.dump(), p.dest.dump());

drop(p.pkt, DROP_RTR_QTIMEOUT);

p.pkt = 0;

p.route.reset();

}

void DSRAgent::stickPacketInSendBuffer(SRPacket& p)

{

Time min = DBL_MAX;

int min_index = 0;

int c;

if (verbose)

trace(“Sdebug %.5f _%s_ stuck into send buff %s -> %s”,Scheduler::instance().clock(),net_id.dump(), p.src.dump(), p.dest.dump());

for (c = 0 ; c < SEND_BUF_SIZE ; c ++)

if (send_buf.p.pkt == NULL)

{

send_buf.t = Scheduler::instance().clock();

send_buf.p = p;

return;

}

else if (send_buf.t < min)

{

min = send_buf.t;

min_index = c;

}

dropSendBuff(send_buf[min_index].p);

send_buf[min_index].t = Scheduler::instance().clock();

send_buf[min_index].p = p;

}

static class DSRAgentClass : public TclClass {

public:

DSRAgentClass() : TclClass(“Agent/DSRAgent”) {}

TclObject* create(int, const char*const*) {

return (new DSRAgent);

}

} class_DSRAgent;

AODV Routing protocol in ns2

static int extra_route_reply = 0;

staticint limit_route_request = 0;

static int route_request = 0;

int hdr_aodv::offset_;

static class aodvHeaderClass : public PacketHeaderClass

{

public: aodvHeaderClass() : PacketHeaderClass(“PacketHeader/aodv”,sizeof(hdr_all_aodv))

{

bind_offset(&hdr_aodv::offset_);

}}

class_rtProtoaodv_hdr; static class aodvclass : public TclClass

{

public: aodvclass() : TclClass(“Agent/aodv”)

{

}

TclObject* create(int argc, const char*const* argv)

{

assert(argc == 5);

return (new aodv((nsaddr_t) Address::instance().str2addr(argv[4])));

}

}

class_rtProtoaodv;voidaodvBroadcastTimer::handle(Event*)

{

agent->id_purge();

Scheduler::instance().schedule(this, &intr, BCAST_ID_SAVE);

}

voidaodvHelloTimer::handle(Event*)

{

code – could it be removed?

if (agent->rtable.rt_has_active_route())

agent->sendHello();

double interval = MinHelloInterval + ((MaxHelloInterval – MinHelloInterval) * Random::uniform());

assert(interval >= 0);

Scheduler::instance().schedule(this, &intr, interval);

}

voidaodvNeighborTimer::handle(Event*)

{

agent->nb_purge();

Scheduler::instance().schedule(this, &intr, HELLO_INTERVAL);

}

voidaodvRouteCacheTimer::handle(Event*)

{

agent->rt_purge();

#define FREQUENCY 0.5

Scheduler::instance().schedule(this, &intr, FREQUENCY);

}

voidaodvLocalRepairTimer::handle(Event* p)

{

aodv_rt_entry *rt;

struct hdr_ip *ih = HDR_IP( (Packet *)p);

rt = agent->rtable.rt_lookup(ih->daddr());

if (rt && rt->rt_flags != RTF_UP)

{

agent->rt_down(rt);

#ifdef DEBUG

fprintf(stderr,”Node %d: Dst – %d, failed local repair\n”,index, rt->rt_dst);#endif

}

Packet::free((Packet *)p);

}

     Now, you may also have got an idea about major Routing protocols used in networking which can also implemented using NS-2. Similarly, you can also implement all the concepts of Networking in NS-2. Here, we have focus on Routing protocols only, but we also provide program support for all types of topics and concepts in Networking. If you also need any particular program in Ns-2, approach us also through our online guidance service. You can also approach us for your projects, assignment or lab cycle, we will guide you in the best way we can.

WORK WITH DESIRE…………………….

HOPE FOR SUCCESS………………………………

AS NOW WE ARE THERE………….  FOR YOU……………..