To simulate the ABR (Associativity-Based Routing) protocol using NS3, which is a reactive routing protocol created for mobile ad hoc networks (MANETs). It chooses routes according to the stability of connections are calculated by how long two nodes have been connected with each other (associativity). Even though NS3 doesn’t have a built-in execution of the ABR, we can be replicated ABR-like behaviour by changing the reactive protocols (such as AODV) or making a custom execution in NS3. Here, we will guide you through the below simulation method on how to approach and replicate the ABR protocol projects using NS3:
Steps to Simulate ABR-like Behavior in NS3:
- Install NS3: Make sure that NS3 is installed on the system. We can download it from the NS3 website.
- Create a MANET Topology: Make a set of mobile nodes, which will form the ad hoc network. We can ne used NS3’s Wi-Fi or 802.11 modules to replicate wireless communication.
- Implement the ABR Protocol: ABR uses associativity and stability as routing metrics. Because NS3 does not have a built-in ABR, we can replicate their behaviour by expanding or tailoring current reactive routing protocols such as AODV. It could encompass tracing the stability of links according to the node movement and associativity that we can be executed in a custom application or as part of the routing table updates.
- Use or Modify AODV/DSR: Alter AODV or DSR (Dynamic Source Routing) to contain a parameter for link associativity. Instead, we can be traced the associativity within a custom application and we create a decisions on route discovery and maintenance based on that.
- Set up Traffic Generating Applications: We can be used NS3’s UDP or TCP applications to generate traffic among the nodes. It will support in analysing the route stability rely on associativity.
- Run the Simulation: After configuring the network, then we run the simulation to examine the route stability, associativity metrics, and overall performance.
Simulating ABR-Like Behaviour with a Custom Implementation
The following is an example in which we can replicate ABR-like behaviour by keeping track of link stability using a custom metric within 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-helper.h”
using namespace ns3;
NS_LOG_COMPONENT_DEFINE (“ABRSimulation”);
class AbrApplication : public Application
{
public:
AbrApplication() {}
virtual ~AbrApplication() {}
void Setup (Ptr<Node> node)
{
m_node = node;
m_stableLinks = 0;
TrackAssociativity();
}
void TrackAssociativity()
{
// Custom logic to simulate tracking link stability (associativity)
NS_LOG_INFO(“Node ” << m_node->GetId() << ” is tracking associativity.”);
// Increment stability score for each stable link
m_stableLinks++;
ScheduleNextAssociativityCheck();
}
protected:
virtual void StartApplication()
{
m_running = true;
TrackAssociativity();
}
virtual void StopApplication()
{
m_running = false;
}
private:
void ScheduleNextAssociativityCheck()
{
Simulator::Schedule (Seconds (5.0), &AbrApplication::TrackAssociativity, this); // Check associativity every 5 seconds
}
Ptr<Node> m_node;
bool m_running;
uint32_t m_stableLinks;
};
int main (int argc, char *argv[])
{
CommandLine cmd;
cmd.Parse (argc, argv);
// Step 1: Create nodes for the mobile ad hoc network (MANET)
NodeContainer nodes;
nodes.Create (5); // Create 5 nodes
// Step 2: Set up Wi-Fi network using Ad Hoc mode
WifiHelper wifi;
wifi.SetStandard (WIFI_PHY_STANDARD_80211b);
YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default ();
YansWifiChannelHelper wifiChannel = YansWifiChannelHelper::Default ();
wifiPhy.SetChannel (wifiChannel.Create ());
WifiMacHelper wifiMac;
wifiMac.SetType (“ns3::AdhocWifiMac”);
NetDeviceContainer devices = wifi.Install (wifiPhy, wifiMac, nodes);
// Step 3: Set up mobility for nodes (random waypoint model)
MobilityHelper mobility;
mobility.SetPositionAllocator (“ns3::RandomDiscPositionAllocator”,
“X”, DoubleValue (50.0),
“Y”, DoubleValue (50.0),
“Rho”, StringValue (“Uniform:0:50”));
mobility.SetMobilityModel (“ns3::RandomWaypointMobilityModel”,
“Speed”, StringValue (“ns3::UniformRandomVariable[Min=1.0|Max=5.0]”),
“Pause”, StringValue (“ns3::ConstantRandomVariable[Constant=2.0]”));
mobility.Install (nodes);
// Step 4: Install the internet stack and AODV routing protocol
AodvHelper aodv;
InternetStackHelper internet;
internet.SetRoutingHelper (aodv); // Use AODV for routing
internet.Install (nodes);
// Step 5: Assign IP addresses
Ipv4AddressHelper ipv4;
ipv4.SetBase (“10.1.1.0”, “255.255.255.0”);
ipv4.Assign (devices);
// Step 6: Set up AbrApplication on each node
for (uint32_t i = 0; i < nodes.GetN (); i++)
{
Ptr<AbrApplication> app = CreateObject<AbrApplication> ();
app->Setup (nodes.Get(i));
nodes.Get(i)->AddApplication (app);
app->SetStartTime (Seconds (1.0));
}
// Step 7: Set up traffic applications
UdpEchoServerHelper echoServer (9);
ApplicationContainer serverApps = echoServer.Install (nodes.Get (4)); // Server on node 4
serverApps.Start (Seconds (2.0));
serverApps.Stop (Seconds (20.0));
UdpEchoClientHelper echoClient (Ipv4Address (“10.1.1.5”), 9);
echoClient.SetAttribute (“MaxPackets”, UintegerValue (10));
echoClient.SetAttribute (“Interval”, TimeValue (Seconds (2.0)));
echoClient.SetAttribute (“PacketSize”, UintegerValue (512));
ApplicationContainer clientApps = echoClient.Install (nodes.Get (0)); // Client on node 0
clientApps.Start (Seconds (3.0));
clientApps.Stop (Seconds (20.0));
// Step 8: Run the simulation
Simulator::Run ();
Simulator::Destroy ();
return 0;
}
Explanation of the Code:
- Node Creation: Five nodes are made to form the MANET.
- Wi-Fi Setup: Wi-Fi is configure using the AdhocWifiMac for ad hoc networking among the nodes.
- Mobility Model: A random waypoint mobility model is utilised to replicate mobile nodes moving at random speeds with pauses.
- Custom ABR-like Application: A custom application AbrApplication is made to replicate the tracing of associativity among the nodes. Every 5 seconds, for each node verifies the stability of its links (simulated in this case by incrementing a stability score).
- Routing with AODV: AODV is utilised as the base routing protocol. We can expand or alter this to account for associativity in route selection.
- Traffic Generation: A UDP Echo server is configure on node 4, and a client is made on node 0 to send packets via the network.
Key Metrics for ABR:
- Associativity: The amount of stable links a node has with its neighbours. This parameter is used to decide the finest routes.
- Route Discovery Time: The time taken to find and ascertain a stable route based on associativity.
- Packet Delivery Ratio (PDR): The amount of effectively delivered packets against the total packets sent.
- Energy Consumption: Estimate how the ABR protocol executes such as energy efficiency because of the route stability.
Running the Simulation:
- Build and Run: Then we run the below commands in the NS3 directory to build and run the simulation:
./waf configure
./waf build
./waf –run abr-simulation
Extending the Simulation:
- Associativity Calculation: Expand the AbrApplication to estimate the associativity according to the real-time link monitoring among nodes.
- Routing Protocol Integration: Alter the AODV protocol to integrate associativity into their route selection process.
- Dynamic Mobility Models: We can use various mobility models to mimic dynamic network topologies, analysing how successfully ABR adjusts to node movement and altering links.
In this manual, we had offered the simulation process about ABR-like Behaviour and key metrics for ABR and simulation expanding for ABR protocol projects utilising NS3 tool. We will present further details on this topic, if required.
To simulate ABR protocol projects using the NS3 tool, share your research details with us. We offer tailored solutions and assist you in performance evaluation. Our focus is on reactive protocols, and by providing us with your information, we can guide you toward the best outcomes.