How to Begin Implement A OLSR Protocol In NS3

To create an Optimized Link State Routing (OLSR) protocol in ns3 has configure the network in which OLSR handles the routing. The tool NS3 has involves the built-in execution for OLSR in the routing module, creation of directly for setting and examine. Here’s a structured guide to implement and test OLSR in ns-3:

Steps to Begin Implement A OLSR Protocol In NS3

  1. Understand OLSR Protocol
  • Key Features:
    • The main features are as Proactive, link-state routing protocol for mobile ad hoc networks (MANETs).
    • The MultiPoint Relays (MPRs) utilized to decrease the overhead for flooding control messages.
    • Periodically replace the network topology control (TC) for hello messages.
  • Simulation Goals:
    • Validate the OLSR in dynamic network topologies.
    • Estimate the performance of metrics such as throughput, delay, and packet delivery ratio.
  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. It validate the installation:

./ns3 run hello-simulator

  1. Plan the Network Topology
  • Components:
    • Mobile nodes communicating in an ad hoc network.
    • Traffic generators like UDP or TCP applications.
  • Topology:
    • The network topology uses the arbitrary mobility design for replicate the dynamic node actions.
  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/olsr-helper.h”

#include “ns3/applications-module.h”

  1. Define Nodes

ns3::NodeContainer nodes;

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

  1. Set Up Mobility

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 OLSR Routing

ns3::OlsrHelper olsr;

ns3::InternetStackHelper internet;

internet.SetRoutingHelper(olsr);  // Use OLSR as the routing protocol

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 (PDR):
    • Evaluate the ratio of packets has successfully delivered for the total packets transmitting.
  • End-to-End Delay:
    • Estimate the normal duration taken the packets for reach their destination.
  • Routing Overhead:
    • Calculate the number of control packets is replacing for during a replication.

Tracing and Visualization:

  • Ensure the tracing for packet study like .pcap:

ns3::AsciiTraceHelper ascii;

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

phy.EnablePcapAll(“olsr”);

  • For envision the used a tool NetAnim:

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

  1. Iterate and Enhance
  • Advanced Scenarios:
    • Validate by several mobility designs for sample vehicular mobility.
    • Establish the network failures for estimate the recovery duration for OLSR’s.
  • Traffic Patterns:
    • Validate by TCP traffic or several UDP streams for congestion design.
  • Parameter Tuning:
    • The tuning are alter the OLSR parameters such as HelloInterval or TcInterval for enhance the performance of metrices.
  1. Extending OLSR

If we need for alter or encompass the OLSR:

  1. Discover the OLSR execution for the src/olsr directory.
  2. Alter the main files:
    • olsr-routing-protocol.cc: Core routing logic.
    • olsr-helper.cc: Helper for configuring OLSR in simulations.
  3. Recreate ns3:

./waf

Through operating the ns3, you can simulate and measure the performance for Optimized Link State Routing projects that were simulated and visualized the results in the above following steps. We will be suggestion further information connected this project in another manual.