To develop an Epidemic Routing in NS3, it is a store-carry-forward mechanism that often utilised within Delay Tolerant Networks (DTN) and Opportunistic Networks. We can utilize a probabilistic forwarding technique to function by flooding packets into entire encountered nodes.
We will execute the Epidemic Routing using NS3 by:
- Replicating the mobile nodes including a random movement model.
- Message replication among the nodes once the nodes are within interaction range.
- Buffer management helps to handle the packet replication.
Steps to Develop an Epidemic Routing Protocol Project in NS3
- Install NS3 and Required Modules
Before starting, we make sure that NS3 is installed:
sudo apt update
sudo apt install -y git build-essential python3 cmake
git clone https://gitlab.com/nsnam/ns-3-dev.git ns-3
cd ns-3
./ns3 configure –enable-examples –enable-tests
./ns3 build
The following are necessary NS3 Modules:
- Mobility Module → It helps to replicate the mobile nodes.
- Network Module → Transmitting and packet forwarding.
- Internet Module → IP-based networking.
- Applications Module → Mimic data transfer.
- Flow Monitor Module → It supports for performance estimation.
- Create a Mobile Ad-Hoc Network (MANET)
Epidemic Routing functions within DTNs and MANETs in which nodes arbitrarily transfer.
📌 Example: Creating a Mobile Network with Random Motion
#include “ns3/core-module.h”
#include “ns3/network-module.h”
#include “ns3/mobility-module.h”
#include “ns3/internet-module.h”
#include “ns3/wifi-module.h”
using namespace ns3;
int main(int argc, char *argv[]) {
NodeContainer nodes;
nodes.Create(10); // 10 Mobile Nodes
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);
InternetStackHelper internet;
internet.Install(nodes);
Simulator::Run();
Simulator::Destroy();
return 0;
}
✅ The above example:
- It has 10 Mobile Nodes including the random movement.
- A random walk model used for replicating the dynamic topology modifications.
- Implement Epidemic Routing Algorithm
We will need to execute an Epidemic Routing Protocol:
- Every single node sustains a received messages’ buffer.
- Once nodes meet then they interchange the messages.
- After a timeout, redundant messages are erased.
📌 Example: Epidemic Message Exchange Algorithm
#include “ns3/packet.h”
#include “ns3/socket.h”
#include “ns3/applications-module.h”
class EpidemicRoutingApp : public Application {
private:
Ptr<Socket> socket;
std::vector<Ptr<Packet>> messageBuffer;
public:
void StartApplication() override {
socket = Socket::CreateSocket(GetNode(), UdpSocketFactory::GetTypeId());
socket->Bind(InetSocketAddress(Ipv4Address::GetAny(), 8080));
socket->SetRecvCallback(MakeCallback(&EpidemicRoutingApp::ReceivePacket, this));
}
void ReceivePacket(Ptr<Socket> socket) {
Ptr<Packet> packet = socket->Recv();
if (std::find(messageBuffer.begin(), messageBuffer.end(), packet) == messageBuffer.end()) {
messageBuffer.push_back(packet);
BroadcastPacket(packet);
}
}
void BroadcastPacket(Ptr<Packet> packet) {
for (uint32_t i = 0; i < GetNode()->GetNDevices(); i++) {
Ptr<NetDevice> device = GetNode()->GetDevice(i);
Ptr<Socket> sendSocket = Socket::CreateSocket(GetNode(), UdpSocketFactory::GetTypeId());
sendSocket->Connect(InetSocketAddress(Ipv4Address(“255.255.255.255”), 8080));
sendSocket->Send(packet);
}
}
};
✅ Key Features:
- Nodes save the packets within a buffer.
- If a packet is new then the packet is propagated again.
- Flooding is handled for avoiding redundancy.
- Simulating Message Transmission
We want to transmit a UDP message among the nodes to experiment the Epidemic Routing.
📌 Example: Sending Messages with Epidemic Routing
uint16_t port = 8080;
UdpServerHelper server(port);
ApplicationContainer serverApp = server.Install(nodes.Get(9));
serverApp.Start(Seconds(1.0));
serverApp.Stop(Seconds(10.0));
UdpClientHelper client(Ipv4Address(“10.1.1.9”), port);
client.SetAttribute(“MaxPackets”, UintegerValue(10));
client.SetAttribute(“Interval”, TimeValue(Seconds(1.0)));
client.SetAttribute(“PacketSize”, UintegerValue(512));
ApplicationContainer clientApp = client.Install(nodes.Get(0));
clientApp.Start(Seconds(2.0));
clientApp.Stop(Seconds(10.0));
✅ It replicates:
- Node 0 to transmit the 10 messages into Node 9.
- In Epidemic Routing fashion, messages obtain simulated through the nodes.
- Performance Evaluation (Delay, Throughput, Packet Delivery)
Examine the effectiveness of Epidemic Routing using Flow Monitor.
📌 Example: Adding Performance Monitoring
#include “ns3/flow-monitor-helper.h”
Ptr<FlowMonitor> monitor;
FlowMonitorHelper flowHelper;
monitor = flowHelper.InstallAll();
Simulator::Run();
monitor->SerializeToXmlFile(“epidemic-flow.xml”, true, true);
Simulator::Destroy();
✅ Outputs: The result is in epidemic-flow.xml to examine the performance with packet delivery & delay.
🔍 Advanced Epidemic Routing Research Topics
- Energy-Aware Epidemic Routing → To enhance the node energy utilization.
- AI-Based Epidemic Routing → Forecast the message forwarding with the support of machine learning models.
- Security in Epidemic Routing → It helps to avoid the message flooding attacks.
- Multi-Channel Epidemic Routing → Adaptive routing functions according to the network scenarios.
- Delay-Tolerant Epidemic Networks → To enhance the rural or disaster-recovery networks.
📝 Summary: Developing Epidemic Routing Protocol in NS3
✔ Step 1: At first, we can install NS3 & necessary modules
✔ Step 2: Create a mobile ad-hoc network (MANET) topology
✔ Step 3: Execute the Epidemic Routing (message forwarding & buffer management)
✔ Step 4: After that, we replicate the packet transmission within a delay-tolerant network
✔ Step 5: Finally, estimate the network performance using parameters such as Packet Delivery, Latency, Throughput, and so on.
The above structured manual encompasses valuable information and stepwise mechanism regarding the Epidemic Protocol Projects and how to implement it into the network by defining the MANET topology, simulating and evaluating the performance in the NS3 tool. We can also offer advanced information on this topic as per your requirements.