How to Implement DYMO Protocol in NS2

To implement the DYMO (Dynamic MANET On-demand) protocol in ns2, we have to configure the routing protocol that manages route discovery and handle in mobile ad hoc networks (MANETs). These protocol is an evolution of AODV (Ad hoc On-Demand Distance Vector) routing protocol, developed to be basic and more effective.

The given below is the process on how to implement DYMO using ns2:

Step-by-Step Implementation:

Step 1: Understand DYMO Protocol

DYMO is an on-demand routing protocol where routes are accomplished only when desired. Generate routes and route error (RERR) messages to manage handle wrecked links by using route requests (RREQs) and route replies (RREPs).

Step 2: Set Up NS2

Make certain that you have installed the ns2 on your computer by following the instructions:

Step 3: Implement the DYMO Protocol

  1. Create the DYMO Agent Class (C++)

Accomplish DYMO routing logic by configuring a new C++ class that should manage the given below:

  • Route Discovery: Beginning route discovery when a packet needs to be direct to a destination for which no route occurs.
  • Route Maintenance: Managing link breaks and maintaining active routes.

Here’s a basic structure:

#include <agent.h>

#include <packet.h>

#include <trace.h>

#include <address.h>

#include <map>

class DYMOAgent : public Agent {

public:

DYMOAgent();

void recv(Packet* p, Handler* h);

void discoverRoute(int dest);

void forwardPacket(Packet* p);

void handleLinkBreak();

protected:

std::map<int, int> routingTable_; // Destination -> Next Hop

};

// Constructor

DYMOAgent::DYMOAgent() : Agent(PT_UDP) {

// Initialization code here

}

// Packet reception

void DYMOAgent::recv(Packet* p, Handler* h) {

hdr_ip* iph = hdr_ip::access(p);

int dest = iph->dst();

 

if (routingTable_.find(dest) != routingTable_.end()) {

forwardPacket(p);

} else {

discoverRoute(dest);

}

}

// Route discovery in DYMO

void DYMOAgent::discoverRoute(int dest) {

// Implement route discovery using RREQ and RREP packets

}

// Forward packet to the selected next hop

void DYMOAgent::forwardPacket(Packet* p) {

hdr_ip* iph = hdr_ip::access(p);

int nextHop = routingTable_[iph->dst()];

// Code to forward the packet to the next hop

}

// Handle link breaks and rediscover routes

void DYMOAgent::handleLinkBreak() {

// Implement logic for handling link breaks and sending RERR packets

}

  1. Integrate the DYMO Agent into NS2
  1. Modify the Makefile: Attach your new DYMOAgent class to the NS2 Makefile so that it gets compiled with the rest of the simulator.
  2. Recompile NS2:

make clean

make

Step 4: Create a Tcl Script to Simulate DYMO

Build a TCL script to recreate a network using DYMO, after the protocol is executed and compiled.

Example Tcl Script:

# Create a simulator object

set ns [new Simulator]

# Define the topology

set val(chan)   Channel/WirelessChannel

set val(prop)   Propagation/TwoRayGround

set val(netif)  Phy/WirelessPhy

set val(mac)    Mac/802_11

set val(ifq)    Queue/DropTail/PriQueue

set val(ll)     LL

set val(ant)    Antenna/OmniAntenna

set val(ifqlen) 50

set val(nn)     10

set val(x)      1000

set val(y)      1000

set val(stop)   100.0

set val(rp)     DYMO   ;# Dynamic MANET On-demand protocol

# Initialize the topology object

set topo [new Topography]

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

# Create the God object

create-god $val(nn)

# Configure the nodes

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

-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 ON \

-movementTrace ON

# Create nodes

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

set node_($i) [$ns node]

}

# Define node positions and movement model

$node_(0) set X_ 100.0; $node_(0) set Y_ 200.0

$node_(1) set X_ 200.0; $node_(1) set Y_ 300.0

$node_(2) set X_ 300.0; $node_(2) set Y_ 400.0

$node_(3) set X_ 400.0; $node_(3) set Y_ 500.0

$node_(4) set X_ 500.0; $node_(4) set Y_ 600.0

# Set up traffic sources

set udp [new Agent/UDP]

$ns attach-agent $node_(0) $udp

set null [new Agent/Null]

$ns attach-agent $node_(4) $null

$ns connect $udp $null

set cbr [new Application/Traffic/CBR]

$cbr attach-agent $udp

$cbr set packetSize_ 512

$cbr set interval_ 0.1

$cbr start

# Simulation end

$ns at $val(stop) “stop”

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

$ns at $val(stop) “exit 0”

proc stop {} {

global ns tracefile namfile

$ns flush-trace

close $tracefile

close $namfile

}

# Run the simulation

$ns run

Step 5: Run the Simulation

  1. Store the Tcl script (dymo_example.tcl).
  2. Open a terminal and route to the directory where you logged the Tcl script.
  3. Run the simulation using the below command:

ns dymo_example.tcl

Step 6: Analyze the Results

  • With the help of the trace files and the network animator (NAM), we can assess the performance of the DYMO protocol, focusing on metrics includes packet delivery ratio, end-to-end delay, and routing overhead.
  • Test how well DYMO manages route discovery and maintenance in a dynamic network environment.

Additional Considerations

  • Routing Metrics: Enhance the protocol’s performance by customizing and inspecting with the metrics used for route discovery and maintenance.
  • Performance Comparison: Compare DYMO with other routing protocols like AODV and DSR to compute its efficiency and scalability.

Through this set up, we covered the basic simulation, installation, configuring route discovery and maintenance and simulate the DYMO agents to accomplish the DYMO (Dynamic MANET On-demand) protocol in ns2. For further requirements, we will offer them over another simulation.

Receive personalized support from us as we assist you in implementing the DYMO Protocol in NS2. Feel free to visit ns2project.com, where we can provide you with innovative ideas and topics to explore.