How to Begin Implement Network Overhead Routing in NS3

To start implementing the Network Overhead in Routing using NS3, we’ll need to measure the extra traffic which created by leveraging the routing protocol like control messages, periodic updates, or retransmissions. To estimate the routing overhead that is essential for computing the routing protocol effectiveness in diverse network scenarios. Here’s a sequential steps to begin Network Overhead Routing in NS3:

Steps to Implement Network Overhead in Routing in NS3

  1. Understand Routing Overhead
  • Definition: Routing overhead denotes the additional interaction costs are incurred by a routing protocol to create and sustain the paths.
  • Key Metrics:
    • Control Overhead: Control Overhead=Control Packets TransmittedTotal Packets Transmitted\text{Control Overhead} = \frac{\text{Control Packets Transmitted}}{\text{Total Packets Transmitted}}Control Overhead=Total Packets TransmittedControl Packets Transmitted​
    • Overhead in Bytes: Overhead Bytes=Bytes Used for Routing Control\text{Overhead Bytes} = \text{Bytes Used for Routing Control}Overhead Bytes=Bytes Used for Routing Control
    • Percentage Overhead: Percentage Overhead=Overhead BytesTotal Bytes Transmitted×100\text{Percentage Overhead} = \frac{\text{Overhead Bytes}}{\text{Total Bytes Transmitted}} \times 100Percentage Overhead=Total Bytes TransmittedOverhead Bytes​×100
  1. Set Up the NS3 Environment
  1. Install NS3:
    • We should install and download the new version of NS3 on the system.
  2. Choose a Network Scenario:
    • Make use of an ad-hoc network or any scenario in which dynamic routing protocols like AODV, OLSR are relevant.
  3. Enable Routing Protocols:
    • NS3 environment provides numerous routing protocols such as AODV, DSDV, and OLSR that can utilize for replicating the overhead.
  1. Monitor Routing Overhead
  1. Track Control Packets:
    • Measure control packets to utilize built-in routing statistics or trace callbacks in NS3.
  2. Measure Overhead:
    • Distinguish among the control and data packets applying FlowMonitor or packet tracing.
  1. Implement Routing Overhead Calculation

Here’s a sample NS3 script for computing the routing overhead within an ad-hoc network by AODV routing protocol.

Example Script: Routing Overhead in NS3

#include “ns3/core-module.h”

#include “ns3/network-module.h”

#include “ns3/internet-module.h”

#include “ns3/wifi-module.h”

#include “ns3/mobility-module.h”

#include “ns3/applications-module.h”

#include “ns3/aodv-module.h”

#include “ns3/flow-monitor-helper.h”

using namespace ns3;

class RoutingOverheadCalculator {

public:

RoutingOverheadCalculator() : m_controlPackets(0), m_dataPackets(0), m_controlBytes(0), m_dataBytes(0) {}

void LogPacket(Ptr<const Packet> packet, const Address &src, const Address &dst, uint8_t protocol) {

if (protocol == 17) { // Assuming 17 for UDP data

m_dataPackets++;

m_dataBytes += packet->GetSize();

} else {

m_controlPackets++;

m_controlBytes += packet->GetSize();

}

}

void CalculateOverhead() {

NS_LOG_UNCOND(“Control Packets: ” << m_controlPackets);

NS_LOG_UNCOND(“Data Packets: ” << m_dataPackets);

NS_LOG_UNCOND(“Control Bytes: ” << m_controlBytes);

NS_LOG_UNCOND(“Data Bytes: ” << m_dataBytes);

double percentageOverhead = (double)m_controlBytes / (m_controlBytes + m_dataBytes) * 100;

NS_LOG_UNCOND(“Percentage Overhead: ” << percentageOverhead << “%”);

}

private:

uint32_t m_controlPackets;

uint32_t m_dataPackets;

uint64_t m_controlBytes;

uint64_t m_dataBytes;

};

RoutingOverheadCalculator calculator;

void PacketTrace(Ptr<const Packet> packet, const Address &src, const Address &dst, uint8_t protocol) {

calculator.LogPacket(packet, src, dst, protocol);

}

int main(int argc, char *argv[]) {

CommandLine cmd;

cmd.Parse(argc, argv);

// Create nodes

NodeContainer nodes;

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

// Configure WiFi

YansWifiChannelHelper wifiChannel = YansWifiChannelHelper::Default();

YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default();

wifiPhy.SetChannel(wifiChannel.Create());

WifiHelper wifi;

wifi.SetStandard(WIFI_PHY_STANDARD_80211g);

WifiMacHelper mac;

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

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

// Configure mobility

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::RandomWalk2dMobilityModel”,

“Bounds”, RectangleValue(Rectangle(0, 100, 0, 100)));

mobility.Install(nodes);

// Install Internet stack and AODV routing

AodvHelper aodv;

InternetStackHelper internet;

internet.SetRoutingHelper(aodv);

internet.Install(nodes);

Ipv4AddressHelper address;

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

Ipv4InterfaceContainer interfaces = address.Assign(devices);

// Generate traffic

uint16_t port = 9;

UdpEchoServerHelper server(port);

ApplicationContainer serverApp = server.Install(nodes.Get(9)); // Node 9 as the server

serverApp.Start(Seconds(1.0));

serverApp.Stop(Seconds(10.0));

UdpEchoClientHelper client(interfaces.GetAddress(9), port);

client.SetAttribute(“MaxPackets”, UintegerValue(100));

client.SetAttribute(“Interval”, TimeValue(MilliSeconds(100)));

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

ApplicationContainer clientApp = client.Install(nodes.Get(0)); // Node 0 as the client

clientApp.Start(Seconds(2.0));

clientApp.Stop(Seconds(10.0));

// Install Flow Monitor

FlowMonitorHelper flowmonHelper;

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

// Trace packets

Config::Connect(“/NodeList/*/ApplicationList/*/$ns3::PacketSink/Rx”, MakeCallback(&PacketTrace));

// Calculate overhead at the end of the simulation

Simulator::Schedule(Seconds(10.0), &RoutingOverheadCalculator::CalculateOverhead, &calculator);

Simulator::Run();

Simulator::Destroy();

return 0;

}

Explanation of the Script

  1. Routing Protocol:
    • Sets up routing protocol like AODV.
  2. Packet Tracing:
    • Monitors all packets and distinguishes among the control and data packets according to the protocol type.
  3. Overhead Metrics:
    • Records control and data packets, bytes, and estimates the rate of overhead.
  4. Mobility:
    • Nodes utilise the random walk mobility for replicating a dynamic topology.
  1. Run the Simulation
  1. Build the script:

./waf –run “routing-overhead-example”

  1. Monitor the records for determining the volume of control packets, data packets, control bytes, data bytes, and percentage overhead.
  1. Analyze Results
  • Impact of Mobility:
    • In routing overhead, maximize the mobility speed and monitor the modifications.
  • Impact of Node Density:
    • Enlarge the volume of nodes density and then examine the overhead.

NS3 enabled a precise implementation process with example coding, which supports to execute and analyze the Network Overhead Routing. Any concerns regarding this topic will be cleared in upcoming manual.