How to Begin Implement a Proactive Protocols in NS3

To create proactive routing protocols in ns3 has includes configure a network where the routing information is handled and updated regularly, regardless of whether the routes are now required. In general proactive protocols are contains the OLSR (Optimized Link State Routing) and DSDV (Destination Sequenced Distance Vector). Together are helped in natively for ns3.

Here’s a step-by-step guide:

Steps to Begin Implement a Proactive Protocol in NS3

  1. Set up ns-3 Environment
  1. Install ns-3:
    • Download and install ns-3 from the official site.
    • Validate the installation through process for a simple replication: ./waf –run hello-simulator.
  2. Include Required Modules:
    • Enable the components olsr, dsdv, internet, point-to-point, wifi, and mobility components are ensured the ns3 build.
  1. Define Objectives for Proactive Protocol Implementation
  • Routing Protocol:
    • Select a protocol: it choose the protocol for OLSR or DSDV.
  • Network Topology:
    • It replicates the fixed or mobile nodes.
  • Metrics:
    • Calculate the performance of parameter metrics such as latency, packet delivery ratio, and overhead.
  1. Set Up Network Topology
  1. Create Nodes:
    • Describe the network nodes for the replication.

NodeContainer nodes;

nodes.Create(10); // 10 nodes in the network

  1. Configure Wireless Links:
    • Use WifiHelper for replicate the an ad hoc wireless network.

WifiHelper wifi;

wifi.SetStandard(WIFI_PHY_STANDARD_80211b);

YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default();

YansWifiChannelHelper wifiChannel = YansWifiChannelHelper::Default();

wifiPhy.SetChannel(wifiChannel.Create());

WifiMacHelper wifiMac;

wifiMac.SetType(“ns3::AdhocWifiMac”);

 

NetDeviceContainer devices = wifi.Install(wifiPhy, wifiMac, nodes);

  1. Set Mobility:
    • Improve the mobility models for replicate the node movement.

MobilityHelper mobility;

mobility.SetPositionAllocator(“ns3::RandomRectanglePositionAllocator”,

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

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

mobility.SetMobilityModel(“ns3::RandomWaypointMobilityModel”,

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

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

mobility.Install(nodes);

  1. Install Network Stack:
    • Enhance the IP stack for nodes.

InternetStackHelper internet;

internet.Install(nodes);

  1. Enable Proactive Routing Protocol
  1. For OLSR:
    • Use OlsrHelper for assure the OLSR all nodes.

OlsrHelper olsr;

Ipv4ListRoutingHelper list;

list.Add(olsr, 10); // Priority 10 for OLSR

internet.SetRoutingHelper(list);

  1. For DSDV:
    • Use DsdvHelper for ensure the DSDV in all nodes.

DsdvHelper dsdv;

Ipv4ListRoutingHelper list;

list.Add(dsdv, 10); // Priority 10 for DSDV

internet.SetRoutingHelper(list);

  1. Assign IP Addresses:
    • Use Ipv4AddressHelper for allocate the IP addresses.

Ipv4AddressHelper ipv4;

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

Ipv4InterfaceContainer interfaces = ipv4.Assign(devices);

  1. Install Applications
  1. Simulate Traffic:
    • Use a UDP echo application for build a congestion.

UdpEchoServerHelper echoServer(9);

ApplicationContainer serverApps = echoServer.Install(nodes.Get(9)); // Server at node 9

serverApps.Start(Seconds(1.0));

serverApps.Stop(Seconds(10.0));

UdpEchoClientHelper echoClient(Ipv4Address(“10.1.1.10”), 9); // Target server

echoClient.SetAttribute(“MaxPackets”, UintegerValue(20));

echoClient.SetAttribute(“Interval”, TimeValue(Seconds(1.0))); // Send every second

echoClient.SetAttribute(“PacketSize”, UintegerValue(1024));

ApplicationContainer clientApps = echoClient.Install(nodes.Get(0)); // Client at node 0

clientApps.Start(Seconds(2.0));

clientApps.Stop(Seconds(10.0));

  1. Monitor Traffic:
    • Use a PacketSink application for track the received packets.

PacketSinkHelper sinkHelper(“ns3::UdpSocketFactory”,

InetSocketAddress(Ipv4Address::GetAny(), 9));

ApplicationContainer sinkApps = sinkHelper.Install(nodes.Get(9)); // Monitor at server

sinkApps.Start(Seconds(1.0));

sinkApps.Stop(Seconds(10.0));

  1. Enable Tracing
  1. Enable Ascii Tracing:
    • Store the routing and packet specific trace file.

AsciiTraceHelper ascii;

wifiPhy.EnableAsciiAll(ascii.CreateFileStream(“proactive-protocols.tr”));

  1. Enable PCAP:
    • Seizure the packets for specific analysis using Wireshark.

wifiPhy.EnablePcapAll(“proactive-protocols”);

  1. Enable FlowMonitor:
    • Track and analyze the congestion metrics.

FlowMonitorHelper flowmon;

Ptr<FlowMonitor> monitor = flowmon.InstallAll();

  1. Run the Simulation
  1. Start the Simulator:
    • Compile and process for the replication.

Simulator::Run();

Simulator::Destroy();

  1. Export Results:
    • Store the FlowMonitor outcomes for offline analysis.

monitor->SerializeToXmlFile(“proactive-protocols-results.xml”, true, true);

  1. Analyze and Visualize Results
  1. Analyze Metrics:
    • It calculates the metrices for throughput, packet delivery ratio, and latency using FlowMonitor.
  2. Visualize with NetAnim:
    • Distribute the replication to NetAnim the demonstration for envision.

AnimationInterface anim(“proactive-protocols.xml”);

  1. Extend and Optimize
  1. Scalability:
    • Improve the number of nodes and validate the performance of protocol in larger networks.
  2. Topology Changes:
    • It replicates the node failures or dynamic topology variations for implement the robustness.
  3. Energy Models:
    • Incorporate the energy models for examine the protocol efficiency in resource-constrained networks.
  4. Comparison with Reactive Protocols:
    • Estimate the OLSR/DSDV against reactive protocols such as AODV or DSR below same environments.

Example Use Cases

  • Ad Hoc Networks:
    • Validate the proactive protocols in mobile ad hoc networks such as MANETs.
  • IoT Networks:
    • It replicates the routing in dense, low-power IoT deployments.
  • Disaster Recovery:
    • Calculate the disaster recovery for proactive routing in dynamic, lossy environments.

From the entire page, we had collected the most essential information that will very helpful to simulate the proactive routing protocols in ns3 tool that is used to maintain the routing tables. Additional information will be shared according to your needs.