How to Begin Implement FSR Protocol in NS3

To begin executing the Fisheye State Routing (FSR) protocol using NS3, we can replicate their inimitable aspects like exchange of routing data periodically and a fisheye scope for routing modernizes. FSR is proactive routing protocol and targets to minimize overhead with the support of diverse frequencies for updates according to the proximity of nodes.

Below is a sequential technique to get started with FSR in NS3:

Steps to Begin Implement FSR Protocol in NS3

Step 1: Understand FSR Protocol

  • Key Features:
    • FSR is a proactive routing protocol in NS3 for mobile ad-hoc networks.
    • Applies a “fisheye” mechanism for modernizing the routing data which is more often used for nodes that are closer.
    • Minimizes the routing table overhead by means of restricting the updates’ scope.
  • Components:
    • Routing Table: It sustains to determine the shortest route data to every node.
    • Update Mechanism: It supports periodic updates including diverse scopes such as close nodes vs. remote nodes.
    • Fisheye Scopes: Describe how frequently updates are broadcasted for nodes on diverse hop distances.

Step 2: Familiarize Yourself with NS3

  • Focus on NS3’s routing structure by means of learning the existing protocols:
    • AODV: src/aodv/
    • OLSR: src/olsr/
  • Be familiar with Ipv4RoutingProtocol class that we need to prolong it for FSR.

Step 3: Set Up NS3 for Development

  1. Create a New Protocol Directory:
    • Make a new directory for protocol in src/ like src/fsr/.
  2. Add Required Files:
    • fsr-routing-protocol.h: It is a header file for the protocol.
    • fsr-routing-protocol.cc: Execution file.
    • fsr-helper.h and fsr-helper.cc: Helper class to replicate the scripts.
  3. Update Build System:
    • Fine-tune the wscript with the new protocol.

Step 4: Design the FSR Protocol

  1. Define FSR Class

Prolong the Ipv4RoutingProtocol class for executing FSR protocol.

#include “ns3/ipv4-routing-protocol.h”

#include “ns3/ipv4-address.h”

#include “ns3/timer.h”

#include “ns3/socket.h”

class FsrRoutingProtocol : public ns3::Ipv4RoutingProtocol {

public:

static ns3::TypeId GetTypeId (void);

FsrRoutingProtocol ();

virtual ~FsrRoutingProtocol ();

// Override Ipv4RoutingProtocol methods

virtual ns3::Ptr<ns3::Ipv4Route> RouteOutput (

ns3::Ptr<const ns3::Packet> packet,

const ns3::Ipv4Header &header,

ns3::Ptr<ns3::NetDevice> oif,

ns3::Socket::SocketErrno &sockerr);

virtual bool RouteInput (

ns3::Ptr<const ns3::Packet> packet,

const ns3::Ipv4Header &header,

ns3::Ptr<const ns3::NetDevice> idev,

ns3::UnicastForwardCallback ucb,

ns3::MulticastForwardCallback mcb,

ns3::LocalDeliverCallback lcb,

ns3::ErrorCallback ecb);

// FSR-specific methods

void UpdateRoutingTable (); // Periodically update the routing table

void SendRoutingUpdates (); // Send routing updates

void ProcessRoutingUpdates (ns3::Ptr<const ns3::Packet> packet); // Process received updates

private:

ns3::Ipv4Address m_selfAddress; // Node’s own address

std::map<ns3::Ipv4Address, uint32_t> m_routingTable; // Routing table

std::map<uint32_t, ns3::Time> m_fisheyeScopes; // Fisheye scopes (hop count to update interval)

ns3::Timer m_updateTimer; // Timer for periodic updates

};

  1. Implement Key Components
  • Routing Table:
    • Sustain the shortest route data for every nearby node.
    • Make use of a routing table including destination addresses and next hops.
  • Update Mechanism:
    • Transmit updates by various frequencies for nodes in diverse scopes.
    • Apply m_fisheyeScopes for describing the hop count-based update intervals.

Example:

void FsrRoutingProtocol::UpdateRoutingTable () {

// Logic to compute the shortest paths to all nodes

}

void FsrRoutingProtocol::SendRoutingUpdates () {

// Send updates with varying scopes

for (const auto &entry : m_routingTable) {

if (WithinScope(entry.first)) {

// Send update for this destination

}

}

}

void FsrRoutingProtocol::ProcessRoutingUpdates (ns3::Ptr<const ns3::Packet> packet) {

// Update the routing table based on received information

}

  • Fisheye Scopes:
    • We can utilize a plot of hop counts for modernizing the intervals to find when to broadcast updates per node.
  1. Custom Packet Header

Create a custom header in NS3 for FSR packets update.

#include “ns3/header.h”

class FsrUpdateHeader : public ns3::Header {

public:

static ns3::TypeId GetTypeId (void);

virtual TypeId GetInstanceTypeId () const;

void AddEntry (ns3::Ipv4Address dest, uint32_t metric);

virtual void Serialize (ns3::Buffer::Iterator start) const;

virtual uint32_t Deserialize (ns3::Buffer::Iterator start);

virtual void Print (std::ostream &os) const;

private:

std::vector<std::pair<ns3::Ipv4Address, uint32_t>> m_entries; // Destination and metric pairs

};

  1. Timers

For periodic updates and scope-based transmission we need to leverage timers.

m_updateTimer.SetFunction(&FsrRoutingProtocol::SendRoutingUpdates, this);

m_updateTimer.Schedule(ns3::Seconds(5)); // Default update interval

Step 5: Write a Helper Class

Make a helper class, enabling the FSR set up in simulations.

#include “fsr-routing-protocol.h”

class FsrHelper {

public:

void Install (ns3::NodeContainer nodes) {

for (auto it = nodes.Begin(); it != nodes.End(); ++it) {

ns3::Ptr<FsrRoutingProtocol> protocol = ns3::CreateObject<FsrRoutingProtocol>();

(*it)->AggregateObject(protocol);

}

}

};

Step 6: Write Simulation Script

Make a simulation script to experiment the functionality of FSR within a network.

Example:

#include “ns3/core-module.h”

#include “ns3/network-module.h”

#include “ns3/internet-module.h”

#include “fsr-helper.h”

int main () {

ns3::NodeContainer nodes;

nodes.Create(10);

ns3::InternetStackHelper stack;

stack.Install(nodes);

FsrHelper fsrHelper;

fsrHelper.Install(nodes);

// Create and configure traffic sources, sinks, and network topology

ns3::Simulator::Run();

ns3::Simulator::Destroy();

return 0;

}

Step 7: Compile and Test

  1. Build NS3 with FSR:

./waf configure

./waf build

  1. Run Simulation:

./waf –run your-script

Step 8: Validate and Extend

  • Validate FSR:
    • Confirm the behaviour of FSR protocol to leverage NS3 tracing tools such as AsciiTraceHelper, PcapHelper.
  • Metrics:
    • Measure the performance parameters such as packet delivery ratio, routing overhead, and latency.
  • Enhance:
    • For mobility or scalability, enhance the FSR.
    • Integrate QoS-based routing parameters or security aspects.

We effectively elucidated the essential information and detailed example coding on how to implement and run the FSR Protocol and how to validate and prolong it using NS3 tool. We will also be provided any other details related to this subject, if needed.