How to Begin Implement a DSDV Protocol in NS3

To stimulate the Destination-Sequenced Distance Vector (DSDV) protocol in ns3 has includes the replicate a network in which the DSDV, a proactive routing protocol, is used to handle the consistent and updated routing tables of all nodes. The ns3 framework has includes the built-in employment for DSDV in its routing module, so we can easily setting and process for using the DSDV.

Here’s a guide to start implementing and analyzing DSDV in ns-3:

Steps to Begin Implement a DSDV Protocol in NS3

  1. Understand DSDV Protocol
  • Key Features:
    • Proactive routing: Periodically bring up-to-date for routing tables.
    • Uses the sequence numbers for prevent the loops and enable the up-to-date routes.
    • Model for mobile ad-hoc networks (MANETs).
  • Simulation Goals:
    • Examine the performance metrics such as throughput, delay, and packet delivery ratio.
    • Validate the DSDV surrounding by node mobility or exchanging the topologies.
  1. Set up ns-3 Environment
  1. Install ns-3:

git clone https://gitlab.com/nsnam/ns-3-dev.git

cd ns-3-dev

./build.py

  1. Verify the installation:

./ns3 run hello-simulator

  1. Plan the Network Topology
  • Components:
    • Mobile nodes are communicating in the wireless medium.
    • Routing is handled by DSDV.
  • Traffic:
    • It builds UDP or TCP congestion among nodes.
  1. Write the Simulation Script
  2. Include Necessary Headers

#include “ns3/core-module.h”

#include “ns3/network-module.h”

#include “ns3/internet-module.h”

#include “ns3/mobility-module.h”

#include “ns3/dsdv-helper.h”

#include “ns3/applications-module.h”

  1. Define Nodes

ns3::NodeContainer nodes;

nodes.Create(10);  // 10 mobile nodes

  1. Set Up Mobility

cpp

Copy code

ns3::MobilityHelper mobility;

// Random waypoint mobility model

mobility.SetMobilityModel(“ns3::RandomWaypointMobilityModel”,

“Speed”, ns3::StringValue(“ns3::UniformRandomVariable[Min=5.0|Max=20.0]”),

“Pause”, ns3::StringValue(“ns3::ConstantRandomVariable[Constant=2.0]”),

“PositionAllocator”, ns3::StringValue(“ns3::RandomRectanglePositionAllocator”));

 

mobility.SetPositionAllocator(“ns3::RandomRectanglePositionAllocator”,

“X”, ns3::StringValue(“ns3::UniformRandomVariable[Min=0.0|Max=500.0]”),

“Y”, ns3::StringValue(“ns3::UniformRandomVariable[Min=0.0|Max=500.0]”));

 

mobility.Install(nodes);

  1. Set Up Wi-Fi Communication

ns3::WifiHelper wifi;

wifi.SetStandard(ns3::WIFI_PHY_STANDARD_80211g);

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);

  1. Install DSDV Routing

ns3::DsdvHelper dsdv;

dsdv.Set(“PeriodicUpdateInterval”, ns3::TimeValue(ns3::Seconds(5.0)));  // Periodic table updates

dsdv.Set(“SettlingTime”, ns3::TimeValue(ns3::Seconds(2.0)));           // Settling time for updates

ns3::InternetStackHelper internet;

internet.SetRoutingHelper(dsdv);

internet.Install(nodes);

  1. Assign IP Addresses

ns3::Ipv4AddressHelper address;

address.SetBase(“10.1.1.0”, “255.255.255.0”);

ns3::Ipv4InterfaceContainer interfaces = address.Assign(devices);

  1. Generate Traffic

UDP Traffic

// UDP Echo server on node 0

ns3::UdpEchoServerHelper echoServer(9);

ns3::ApplicationContainer serverApp = echoServer.Install(nodes.Get(0));

serverApp.Start(ns3::Seconds(1.0));

serverApp.Stop(ns3::Seconds(20.0));

// UDP Echo client on node 9

ns3::UdpEchoClientHelper echoClient(interfaces.GetAddress(0), 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(9));

clientApp.Start(ns3::Seconds(2.0));

clientApp.Stop(ns3::Seconds(20.0));

  1. Run the Simulation

ns3::Simulator::Run();

ns3::Simulator::Destroy();

  1. Analyze Results

Metrics:

  • Packet Delivery Ratio:
    • The packets are Ratio of successfully delivered to transfer the whole packets.
  • End-to-End Delay:
    • It takes the normal duration for packets to reach the destination.
  • Routing Overhead:
    • Calculate the control packets are overhead because of DSDV.

Tracing and Visualization:

  • Ensure the tracing files for specific packet analysis.pcap:

ns3::AsciiTraceHelper ascii;

phy.EnableAsciiAll(ascii.CreateFileStream(“dsdv.tr”));

phy.EnablePcapAll(“dsdv”);

  • It use the command  for envision like as NetAnim:

./waf –run “dsdv-simulation –vis”

  1. Iterate and Enhance
  • Advanced Scenarios:
    • Replicate a mobility designs such as vehicle movement.
    • Launch the network failures and follow the DSDV’s retrieval.
  • Parameter Tuning:
    • Experiment with PeriodicUpdateInterval and SettlingTime values.
  • Traffic Patterns:
    • Experiment by numerous source-destination pairs or multimedia traffic.

By means of utilizing the network simulator 3, you can simulate and measure the performance for Destination-Sequenced Distance Vector protocol projects that were simulated and visualized the results in the above following steps. If you have concerns or queries, they will be addressed in a separate manual.