How to Develop FSR Protocol Projects Using NS3

To develop FSR (Fisheye State Routing) Protocol Projects in NS3, we need to follow this structured procedure.

  1. Introduction to FSR (Fisheye State Routing)

The Fisheye State Routing (FSR) protocol is a proactive link-state routing protocol which is intended for Mobile Ad Hoc Networks (MANETs). FSR supports to minimize the routing overhead by:

✅ Often updating the neighbouring nodes such as high accuracy.

Bring up-to-data distant nodes used less frequently like low overhead.

✅ Sustain an updated topology with the help of a “fisheye” mechanism.

  1. Setting Up NS3 for FSR

(a) Install NS3

Initially, we should install NS3 for FSR Implemenation

sudo apt update

sudo apt install git g++ python3 python3-pip cmake

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

cd ns-3-dev

./ns3 configure –enable-examples –enable-tests

./ns3 build

  1. Implementing FSR in NS3

NS3 environment does not offer inherent support for FSR implementation, thus we will:

  1. Design a new routing protocol class that used for FSR.
  2. We can utilize fisheye mechanism to execute the routing table updates.
  3. Incorporate the FSR into an NS3 simulation.

Step 1: Create an FSR Routing Class

Now, we need to generate an FSR Routing class named as fsr-routing.h

#ifndef FSR_ROUTING_H

#define FSR_ROUTING_H

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

#include “ns3/node-container.h”

#include “ns3/ipv4-route.h”

#include “ns3/packet.h”

#include “ns3/socket.h”

#include “ns3/timer.h”

class FsrRouting : public ns3::Ipv4RoutingProtocol {

public:

static ns3::TypeId GetTypeId(void);

FsrRouting();

virtual ~FsrRouting();

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

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

const ns3::Ipv4Header &header,

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

ns3::Socket::SocketErrno &sockerr) override;

virtual bool RouteInput(

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

const ns3::Ipv4Header &header,

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

UnicastForwardCallback ucb,

MulticastForwardCallback mcb,

LocalDeliverCallback lcb,

ErrorCallback ecb) override;

void UpdateRoutingTable();

void SendPeriodicUpdates();

private:

std::map<uint32_t, ns3::Ipv4Route> m_routingTable;

ns3::Timer m_updateTimer;

};

#endif // FSR_ROUTING_H

Step 2: Implement Routing Table Updates

We will make fsr-routing.cc for executing the updates of routing table

#include “fsr-routing.h”

#include “ns3/log.h”

#include “ns3/simulator.h”

NS_LOG_COMPONENT_DEFINE(“FsrRouting”);

NS_OBJECT_ENSURE_REGISTERED(FsrRouting);

ns3::TypeId FsrRouting::GetTypeId(void) {

static ns3::TypeId tid = ns3::TypeId(“ns3::FsrRouting”)

.SetParent<ns3::Ipv4RoutingProtocol>()

.SetGroupName(“Internet”);

return tid;

}

FsrRouting::FsrRouting() {

m_updateTimer.SetFunction(&FsrRouting::SendPeriodicUpdates, this);

m_updateTimer.Schedule(ns3::Seconds(1.0));

}

FsrRouting::~FsrRouting() {}

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

ns3::Ptr<ns3::Packet> packet, const ns3::Ipv4Header &header,

ns3::Ptr<ns3::NetDevice> oif, ns3::Socket::SocketErrno &sockerr) {

NS_LOG_INFO(“FSR RouteOutput: Finding best route for packet”);

return 0;

}

bool FsrRouting::RouteInput(

ns3::Ptr<const ns3::Packet> packet, const ns3::Ipv4Header &header,

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

UnicastForwardCallback ucb, MulticastForwardCallback mcb,

LocalDeliverCallback lcb, ErrorCallback ecb) {

NS_LOG_INFO(“FSR RouteInput: Handling incoming packet”);

return true;

}

void FsrRouting::UpdateRoutingTable() {

NS_LOG_INFO(“FSR Updating Routing Table using fisheye technique”);

}

void FsrRouting::SendPeriodicUpdates() {

NS_LOG_INFO(“FSR Sending periodic updates to neighbors”);

m_updateTimer.Schedule(ns3::Seconds(1.0));

}

Step 3: Integrate FSR into an NS3 Simulation

Thereafter, we have to design an fsr-simulation.cc by incorporating the FSR into an NS3 simulation

#include “ns3/core-module.h”

#include “ns3/network-module.h”

#include “ns3/internet-module.h”

#include “ns3/mobility-module.h”

#include “fsr-routing.h”

using namespace ns3;

int main() {

NodeContainer nodes;

nodes.Create(5);

MobilityHelper mobility;

mobility.SetPositionAllocator(“ns3::GridPositionAllocator”,

“MinX”, DoubleValue(0.0),

“MinY”, DoubleValue(0.0),

“DeltaX”, DoubleValue(10.0),

“DeltaY”, DoubleValue(10.0),

“GridWidth”, UintegerValue(5),

“LayoutType”, StringValue(“RowFirst”));

mobility.Install(nodes);

InternetStackHelper stack;

stack.Install(nodes);

Ptr<FsrRouting> fsrRouting = CreateObject<FsrRouting>();

nodes.Get(0)->AggregateObject(fsrRouting);

Ipv4AddressHelper address;

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

address.Assign(NetDeviceContainer());

Simulator::Run();

Simulator::Destroy();

return 0;

}

Step 4: Compile and Run the Simulation

📌 Compile

Here, we should build the script

./waf

📌 Run

Execute the simulation using

./waf –run “scratch/fsr-simulation”

  1. Performance Evaluation for FSR

We can utilize FlowMonitor to estimate the effectiveness of routing:

Ptr<FlowMonitor> flowMonitor;

FlowMonitorHelper flowHelper;

flowMonitor = flowHelper.InstallAll();

Simulator::Stop(Seconds(10.0));

Simulator::Run();

flowMonitor->SerializeToXmlFile(“fsr_results.xml”, true, true);

📌 Run analysis

python3 analyze_results.py

  1. Example FSR Project Ideas in NS3

✅ 1. Performance Comparison of FSR vs. AODV in MANETs

  • Assess the network performance metrics such as packet delivery ratio and latency within a mobile network.

✅ 2. Energy-Aware FSR for IoT Networks

  • Give precedence to energy-efficient paths by altering FSR.

✅ 3. Secure FSR Implementation

  • Integrate the encryption for avoiding FSR from routing attacks.

✅ 4. FSR in Vehicular Ad-Hoc Networks (VANETs)

  • In VANETs, enhance the FSR for high-speed mobility.

✅ 5. QoS-Aware FSR in 5G Networks

  • Customize the FSR within 5G Networks to assist the low-latency real-time traffic.

Throughout this manual, we have delivered the implementation details for the Fisheye State Protocol (FSR) in NS3 scenarios. Start by setting up NS3, implementing FSR and defining the class and then integrating it into the simulation network. We can analyze the outcomes with sample project ideas. Further information will be shared.