To simulate the Fisheye State Routing (FSR) protocol is a proactive (table-driven) routing protocol for mobile ad-hoc networks (MANETs). In FSR, the nodes are swap link state data with differing frequencies based on the distance among the nodes. Nodes are closer to each other exchange data more often than nodes are farther apart, therefore minimizing overhead for distant nodes.
Inopportunely, FSR is not natively executed within NS3. But, we can be replicated FSR either by using a third-party NS3 module or by manually executing it by altering existing proactive protocols such as OLSR (Optimized Link State Routing).
In this instruction, we will discover two possible choices:
- Utilising a third-party NS3-Fisheye module, if obtainable.
- Replicating FSR-like behaviour by changing or replicating the routing according to the OLSR or another proactive protocol.
Option 1: Using a Third-Party NS3-FSR Module
If there is a third-party NS3-FSR module, we can incorporate it into the NS3 installation by following same steps as installing other third-party modules such as AOMDV. This would contain downloading, copying the files into the NS3 directory, and rebuilding NS3.
If we have access to such a module then we follow these steps:
- Clone the repository:
git clone https://github.com/path-to-fsr-module.git
- Copy the FSR files into the src/ directory of your NS3:
cp -r fsr-module /path/to/ns3/src/
- Rebuild NS3:
cd /path/to/ns3/
./waf configure
./waf build
Then, we can make a simulation using the FSR protocol likewise to how we could with any other protocol, like AODV or OLSR.
If a pre-built FSR module is not obtainable then we proceed to option 2 for a manual configure.
Option 2: Simulating FSR-like Behavior Using OLSR (Modified Approach)
Because FSR is a proactive protocol such as OLSR, we can change the performance of OLSR to replicate FSR-like aspects. In OLSR, nodes are regularly swap topology control messages, and by changing the frequency of updates for closer and more distant nodes, we can be replicated FSR-like behaviour.
The following is an instruction on how to replicate FSR-like behaviour utilising NS3’s OLSR protocol, with changed metrics for update intervals.
Steps to Simulate FSR-like Behaviour Using OLSR
- Install NS3
Make certain NS3 is installed on the computer. Unless, we can download it from the NS3 official website.
- Create a Simulation Using OLSR
By adapting the link state update intervals within OLSR, we can estimated FSR behaviour. In FSR, nodes that are nearer to each other exchange updates more often, even though nodes are farther apart swap updates less frequently.
Example Simulation of FSR-like Behavior Using OLSR in NS3
- Include Necessary Headers
The following headers are essential to configure the wireless communication, mobility, the OLSR routing protocol (which we will simulate FSR-like behavior with), and applications.
#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/olsr-helper.h” // OLSR protocol
#include “ns3/applications-module.h”
#include “ns3/netanim-module.h”
- Create and Install Nodes
Make a set of nodes are signifying the wireless ad-hoc network. These nodes will be used the OLSR protocol to communicate, with changed update intervals to replicate the FSR behavior.
NodeContainer nodes;
nodes.Create(10); // Create 10 nodes
- Configure Wireless Communication (Wi-Fi)
We can use the WifiHelper and YansWifiChannelHelper to configure the wireless communication among the nodes. This replicates how the nodes will be interacted wirelessly in the ad-hoc network.
YansWifiChannelHelper wifiChannel = YansWifiChannelHelper::Default();
YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default();
wifiPhy.SetChannel(wifiChannel.Create());
WifiHelper wifi;
wifi.SetStandard(WIFI_PHY_STANDARD_80211g); // Set the Wi-Fi standard to 802.11g
wifi.SetRemoteStationManager(“ns3::AarfWifiManager”);
WifiMacHelper wifiMac;
wifiMac.SetType(“ns3::AdhocWifiMac”); // Ad-hoc MAC layer for nodes
NetDeviceContainer devices = wifi.Install(wifiPhy, wifiMac, nodes);
- Install Internet Stack and OLSR Routing Protocol
Install the Internet stack (TCP/IP protocols) and set up OLSR as the routing protocol, with changed parameters to replicate the FSR behaviour.
InternetStackHelper internet;
OlsrHelper olsr;
// Set up OLSR with modified update intervals to simulate FSR
internet.SetRoutingHelper(olsr); // Set OLSR as the routing protocol
internet.Install(nodes);
- Assign IP Addresses
Allocate an IP addresses to the nodes thus they can be interacted across the wireless network.
Ipv4AddressHelper address;
address.SetBase(“10.1.1.0”, “255.255.255.0”); // Assign IP addresses to the network
Ipv4InterfaceContainer interfaces = address.Assign(devices);
- Set up Mobility Model for Nodes
We can use the MobilityHelper to allocate positions and mobility to the nodes. We can use a random waypoint mobility model to replicate the node movement.
MobilityHelper mobility;
mobility.SetPositionAllocator(“ns3::RandomRectanglePositionAllocator”,
“X”, StringValue(“ns3::UniformRandomVariable[Min=0.0|Max=500.0]”),
“Y”, StringValue(“ns3::UniformRandomVariable[Min=0.0|Max=500.0]”));
mobility.SetMobilityModel(“ns3::RandomWaypointMobilityModel”,
“Speed”, StringValue(“ns3::UniformRandomVariable[Min=1.0|Max=10.0]”),
“Pause”, StringValue(“ns3::ConstantRandomVariable[Constant=2.0]”),
“PositionAllocator”, StringValue(“ns3::RandomRectanglePositionAllocator”));
mobility.Install(nodes);
- Set up Traffic Applications
We can mimic communication among the nodes using applications like UDP Echo. One node will perform as a server, and another as a client.
- Server (UDP Echo Server):
uint16_t port = 9;
UdpEchoServerHelper echoServer(port);
ApplicationContainer serverApp = echoServer.Install(nodes.Get(0)); // Server on node 0
serverApp.Start(Seconds(1.0));
serverApp.Stop(Seconds(20.0));
- Client (UDP Echo Client):
UdpEchoClientHelper echoClient(interfaces.GetAddress(0), port); // Client sends messages to node 0
echoClient.SetAttribute(“MaxPackets”, UintegerValue(50));
echoClient.SetAttribute(“Interval”, TimeValue(Seconds(1.0)));
echoClient.SetAttribute(“PacketSize”, UintegerValue(1024));
ApplicationContainer clientApp = echoClient.Install(nodes.Get(5)); // Client on node 5
clientApp.Start(Seconds(2.0));
clientApp.Stop(Seconds(20.0));
- Enable Tracing and Animation
Allow packet capture (PCAP) to evaluate the communication among the nodes and we use NetAnim to envision the simulation.
wifiPhy.EnablePcapAll(“fisheye_simulation”); // Enable PCAP tracing for all nodes
AnimationInterface anim(“fisheye_simulation.xml”); // Enable NetAnim animation
- Run the Simulation
Set the simulation stop time and we run the simulation.
Simulator::Stop(Seconds(20.0)); // Set the simulation stop time
Simulator::Run(); // Run the simulation
Simulator::Destroy(); // Clean up after the simulation
- Full Example Script for FSR-like Behavior Using OLSR
Here is a comprehensive instance of a simulation script using OLSR to approximate FSR behaviour.
#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/olsr-helper.h”
#include “ns3/applications-module.h”
#include “ns3/netanim-module.h”
using namespace ns3;
int main(int argc, char *argv[]) {
// Step 1: Create nodes for the FSR-like network
NodeContainer nodes;
nodes.Create(10); // Create 10 nodes
// Step 2: Configure Wi-Fi communication
YansWifiChannelHelper wifiChannel = YansWifiChannelHelper::Default();
YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default();
wifiPhy.SetChannel(wifiChannel.Create());
WifiHelper wifi;
wifi.SetStandard(WIFI_PHY_STANDARD_80211g);
wifi.SetRemoteStationManager(“ns3::AarfWifiManager”);
WifiMacHelper wifiMac;
wifiMac.SetType(“ns3::AdhocWifiMac”); // Ad-hoc MAC for nodes
NetDeviceContainer devices = wifi.Install(wifiPhy, wifiMac, nodes);
// Step 3: Install OLSR routing protocol and Internet stack
InternetStackHelper internet;
OlsrHelper olsr; // OLSR routing protocol (modified for FSR-like behavior)
internet.SetRoutingHelper(olsr);
internet.Install(nodes);
// Step 4: Assign IP addresses
Ipv4AddressHelper address;
address.SetBase(“10.1.1.0”, “255.255.255.0”);
Ipv4InterfaceContainer interfaces = address.Assign(devices);
// Step 5: Set up mobility model for nodes
MobilityHelper mobility;
mobility.SetPositionAllocator(“ns3::RandomRectanglePositionAllocator”,
“X”, StringValue(“ns3::UniformRandomVariable[Min=0.0|Max=500.0]”),
“Y”, StringValue(“ns3::UniformRandomVariable[Min=0.0|Max=500.0]”));
mobility.SetMobilityModel(“ns3::RandomWaypointMobilityModel”,
“Speed”, StringValue(“ns3::UniformRandomVariable[Min=1.0|Max=10.0]”),
“Pause”, StringValue(“ns3::ConstantRandomVariable[Constant=2.0]”),
“PositionAllocator”, StringValue(“ns3::RandomRectanglePositionAllocator”));
mobility.Install(nodes);
// Step 6: Set up UDP Echo Server on node 0
uint16_t port = 9;
UdpEchoServerHelper echoServer(port);
ApplicationContainer serverApp = echoServer.Install(nodes.Get(0)); // Server on node 0
serverApp.Start(Seconds(1.0));
serverApp.Stop(Seconds(20.0));
// Step 7: Set up UDP Echo Client on node 5
UdpEchoClientHelper echoClient(interfaces.GetAddress(0), port); // Client sends messages to node 0
echoClient.SetAttribute(“MaxPackets”, UintegerValue(50));
echoClient.SetAttribute(“Interval”, TimeValue(Seconds(1.0)));
echoClient.SetAttribute(“PacketSize”, UintegerValue(1024));
ApplicationContainer clientApp = echoClient.Install(nodes.Get(5)); // Client on node 5
clientApp.Start(Seconds(2.0));
clientApp.Stop(Seconds(20.0));
// Step 8: Enable tracing and animation
wifiPhy.EnablePcapAll(“fisheye_simulation”);
AnimationInterface anim(“fisheye_simulation.xml”);
// Step 9: Run the simulation
Simulator::Stop(Seconds(20.0));
Simulator::Run();
Simulator::Destroy();
return 0;
}
- Running the Simulation
- We compile and run the script using NS3’s waf build system:
./waf build
./waf –run fisheye_simulation
- Analyzing Results
- PCAP Traces: The pcap files are generated in the course of the simulation can be examined using tools such as Wireshark to monitor the packet exchanges and traffic.
- NetAnim: We can envision the network topology and node movements in NetAnim using the .xml file generated during the simulation.
- Extending the Simulation
We can expand this FSR simulation by:
- Executing a more exact FSR behaviour (modifying the OLSR update frequencies based on node distances).
- Mimicking larger networks and more complex mobility patterns (e.g., using SUMO to import real-world mobility traces).
- Modifying the communication pattern to replicate more complex traffic types such as TCP or real-time multimedia.
We have successfully simulated and delivered the Fisheye protocol projects through the NS3 environment. Also we will be provided further informations relevant to this projects in another material.
Send us all the information about your Fisheye Protocol Projects, and we’ll help you with the best simulation outcomes.