How to Begin Implement a DYMO Protocol in NS3
The Dynamic MANET On-Demand (DYMO) protocol, also known as AODVv2, is a reactive routing protocol model for mobile ad hoc networks (MANETs). DYMO explore the routes on-demand and handle the required, creation of effective for dynamic and mobile networks.
In ns3, DYMO is not involved as a native protocol, so we required apply the either by encompassing the existing routing framework or through incorporate an external execution. Below is a step-by-step guide to implementing and simulating DYMO in ns-3.
Steps to Begin Implement a DYMO Protocol in NS3
- Understand DYMO Protocol
- Key Features:
- Reactive routing protocol such as routes is discovered on-demand.
- It communicates the Uses Route Request (RREQ) and Route Reply (RREP).
- It handles the route entries only if required, decrease the overhead.
- Maintain the connection breaks by Route Error (RERR) messages.
- Components:
- Route discovery: It starts after a source wants a route for the destination.
- Route maintenance: Findings and repairs for broken connection.
- Set Up ns-3 Environment
- Install ns-3:
git clone https://gitlab.com/nsnam/ns-3-dev.git
cd ns-3-dev
./build.py
- Verify the installation:
./ns3 run hello-simulator
- Plan the Network Topology
- Components:
- Mobile nodes by wireless connections.
- The network topology has includes the traffic sources and destinations.
- Topology:
- Dynamic topology by random mobility for validates the route discovery and maintenance.
- Implement DYMO in ns-3
- Define the Protocol Class
- Build a new class inheriting Ipv4RoutingProtocol:
#include “ns3/ipv4-routing-protocol.h”
#include “ns3/ipv4-route.h”
#include “ns3/socket.h”
#include “ns3/simulator.h”
#include <map>
class DymoRouting : public ns3::Ipv4RoutingProtocol {
public:
DymoRouting();
virtual ~DymoRouting();
Ptr<Ipv4Route> RouteOutput(Ptr<Packet> packet, const Ipv4Header &header,
Ptr<NetDevice> oif, Socket::SocketErrno &sockerr) override;
bool RouteInput(Ptr<const Packet> packet, const Ipv4Header &header,
Ptr<const NetDevice> idev, UnicastForwardCallback ucb,
MulticastForwardCallback mcb, LocalDeliverCallback lcb,
ErrorCallback ecb) override;
void SendRREQ(ns3::Ipv4Address dest);
void HandleRREP(Ptr<Packet> packet);
void HandleRERR(Ptr<Packet> packet);
private:
std::map<ns3::Ipv4Address, ns3::Ipv4Route> m_routeTable; // Routing table
void MaintainRoutes();
};
- Route Discovery:
- Execute the explore SendRREQ to broadcast Route Request messages.
- Maintain the received RREQs to reply by RREPs are known as the route discovery.
- Route Maintenance:
- Use Route Error (RERR) messages to identify the neighbours for broken connections.
- Continue the route table entries by finishing timers.
- Create a Helper Class
- Define the Helper:
class DymoHelper : public ns3::Ipv4RoutingHelper {
public:
DymoHelper() {}
Ptr<Ipv4RoutingProtocol> Create(Ptr<Node> node) const override {
return CreateObject<DymoRouting>();
}
};
- Integrate into Simulation Script:
DymoHelper dymoHelper;
ns3::InternetStackHelper stack;
stack.SetRoutingHelper(dymoHelper);
stack.Install(nodes);
- Set Up the Simulation
- Define Nodes
ns3::NodeContainer nodes;
nodes.Create(10); // Create 10 nodes
- Set Up Mobility
- Random Waypoint Mobility:
ns3::MobilityHelper mobility;
mobility.SetMobilityModel(“ns3::RandomWaypointMobilityModel”,
“Speed”, ns3::StringValue(“ns3::UniformRandomVariable[Min=1.0|Max=20.0]”),
“Pause”, ns3::StringValue(“ns3::ConstantRandomVariable[Constant=2.0]”),
“PositionAllocator”, ns3::StringValue(“ns3::RandomRectanglePositionAllocator”));
mobility.Install(nodes);
- Set Up Wireless Communication
ns3::WifiHelper wifi;
wifi.SetStandard(ns3::WIFI_PHY_STANDARD_80211);
ns3::WifiMacHelper mac;
mac.SetType(“ns3::AdhocWifiMac”);
ns3::WifiPhyHelper phy = ns3::WifiPhyHelper::Default();
phy.SetChannel(ns3::YansWifiChannelHelper::Default().Create());
ns3::NetDeviceContainer devices = wifi.Install(phy, mac, nodes);
- Assign IP Addresses
ns3::Ipv4AddressHelper address;
address.SetBase(“10.1.1.0”, “255.255.255.0”);
ns3::Ipv4InterfaceContainer interfaces = address.Assign(devices);
- Generate Traffic
UDP Traffic
// UDP Echo server on Node 9
ns3::UdpEchoServerHelper echoServer(9);
ns3::ApplicationContainer serverApp = echoServer.Install(nodes.Get(9));
serverApp.Start(ns3::Seconds(1.0));
serverApp.Stop(ns3::Seconds(20.0));
// UDP Echo client on Node 0
ns3::UdpEchoClientHelper echoClient(interfaces.GetAddress(9), 9);
echoClient.SetAttribute(“MaxPackets”, ns3::UintegerValue(10));
echoClient.SetAttribute(“Interval”, ns3::TimeValue(ns3::Seconds(1.0)));
echoClient.SetAttribute(“PacketSize”, ns3::UintegerValue(512));
ns3::ApplicationContainer clientApp = echoClient.Install(nodes.Get(0));
clientApp.Start(ns3::Seconds(2.0));
clientApp.Stop(ns3::Seconds(20.0));
- Run the Simulation
ns3::Simulator::Run();
ns3::Simulator::Destroy();
- Analyze Results
Metrics:
- Packet Delivery Ratio (PDR):
- It calculates the ratio of packets has successfully delivered.
- Latency:
- It estimates the normal delay for packet delivery.
- Routing Overhead:
- Amount the number of control messages such as RREQ, RREP, RERR.
Tracing and Visualization:
- .pcap assure the tracing files for packet inspection:
ns3::AsciiTraceHelper ascii;
phy.EnableAsciiAll(ascii.CreateFileStream(“dymo.tr”));
phy.EnablePcapAll(“dymo”);
- NetAnim tool utilized for envision:
./waf –run “dymo-simulation –vis”
- Iterate and Enhance
- Advanced Features:
- Enhance the help for performance of metrics such as energy usage or link quality in route collection.
- Execute and validate the connection failure recovery devices.
- Protocol Comparison:
- Associate the DYMO by other MANET protocols such as AODV or OLSR.
- Optimization:
- Enhance the routing logic for decrease the overhead in dense networks.
These project examples permit you to discover numerous aspects of DYMO in different network environments using NS3 simulations. You can learn its performance, scalability, energy efficiency and security, and propose improvements to address the certain challenges in dynamic mobile ad-hoc networks, and recovery scenarios. Additional information will be collective concerning these projects in another manual.