To develop an IPv4 (Internet Protocol version 4) in NS3 which is the internet interaction’s foundation. We will need to replicate the IPv4 in NS3, utilising:
- Static Routing (Manual configuration)
- Dynamic Routing like SPF, BGP, RIP, AODV, and so on
- Network Performance Analysis such as Latency, Packet Loss, QoS
Steps to Develop an IPv4 Protocol Project in NS3
- Install NS3
We can start by installing and compiling the NS3:
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
Also, we need to install necessary NS3 Modules such as:
- Internet Module → IPv4 address assignment.
- Point-to-Point Module → Wired network simulation.
- WiFi Module → Wireless network support.
- Routing Module → OSPF, BGP, RIP, AODV.
- Applications Module → It supports to replicate the data transfer.
- Create a Simple IPv4 Network
We want to generate the IPv4 network that includes:
- IPv4 Addressing
- Multiple Nodes (Computers, Routers)
- Point-to-Point Links
- Routing Configuration
📌 Example: Creating a Simple IPv4 Network
#include “ns3/core-module.h”
#include “ns3/network-module.h”
#include “ns3/internet-module.h”
#include “ns3/point-to-point-module.h”
#include “ns3/applications-module.h”
using namespace ns3;
int main(int argc, char *argv[]) {
NodeContainer nodes;
nodes.Create(3); // Three nodes
PointToPointHelper p2p;
p2p.SetDeviceAttribute(“DataRate”, StringValue(“100Mbps”));
p2p.SetChannelAttribute(“Delay”, StringValue(“2ms”));
NetDeviceContainer devices1 = p2p.Install(nodes.Get(0), nodes.Get(1));
NetDeviceContainer devices2 = p2p.Install(nodes.Get(1), nodes.Get(2));
InternetStackHelper internet;
internet.Install(nodes);
Ipv4AddressHelper address;
address.SetBase(“10.1.1.0”, “255.255.255.0”);
address.Assign(devices1);
address.SetBase(“10.1.2.0”, “255.255.255.0”);
address.Assign(devices2);
Simulator::Stop(Seconds(10));
Simulator::Run();
Simulator::Destroy();
return 0;
}
✅ This example sets up:
- Contains three nodes that were linked through the IPv4.
- Point-to-point interaction along with IP addressing.
- Implement Static IPv4 Routing
Static Routing needs routing tables’ manual configuration to execute the IPV4 routing.
📌 Example: Adding Static Routes
#include “ns3/ipv4-static-routing-helper.h”
Ptr<Ipv4StaticRouting> staticRouting1 = Ipv4RoutingHelper::GetRouting<Ipv4StaticRouting>(nodes.Get(0)->GetObject<Ipv4>());
staticRouting1->AddNetworkRouteTo(Ipv4Address(“10.1.2.0”), Ipv4Mask(“255.255.255.0”), 1);
✅ This code sets up routes manually per node.
- Implement Dynamic IPv4 Routing (RIP)
Routing Information Protocol (RIP) permits the automatic route discovery to execute it.
📌 Example: Using RIP for IPv4 Routing
#include “ns3/rip-helper.h”
RipHelper rip;
Ipv4ListRoutingHelper list;
list.Add(rip, 10);
InternetStackHelper internet;
internet.SetRoutingHelper(list);
internet.Install(nodes);
✅ This enables RIP-based automatic routing.
- Simulating Traffic Over IPv4
We make network traffic using the TCP or UDP applications.
📌 Example: Sending UDP Traffic Over IPv4
#include “ns3/udp-client-server-helper.h”
uint16_t port = 8080;
UdpServerHelper server(port);
ApplicationContainer serverApp = server.Install(nodes.Get(2));
serverApp.Start(Seconds(1.0));
serverApp.Stop(Seconds(10.0));
UdpClientHelper client(Ipv4Address(“10.1.2.2”), 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));
✅ This replicates:
- A UDP client transmitting the 10 packets into a server.
- Sending packets via intermediate IPv4 routers.
- Implement QoS and Bandwidth Control
We will leverage Traffic Control Helper for enhancing the performance of IPv4.
📌 Example: Enabling QoS for IPv4 Traffic
#include “ns3/traffic-control-helper.h”
TrafficControlHelper tc;
tc.SetRootQueueDisc(“ns3::FqCoDelQueueDisc”);
tc.Install(devices1);
tc.Install(devices2);
✅ It makes sure that:
- Low latency for high-priority traffic.
- Enhanced bandwidth consumption.
- Performance Analysis (Throughput, Delay, Packet Loss)
Assess the performance of IPv4 with metrics like delay, packet loss, and throughput using Flow Monitor.
📌 Example: Monitoring IPv4 Traffic
#include “ns3/flow-monitor-helper.h”
Ptr<FlowMonitor> monitor;
FlowMonitorHelper flowHelper;
monitor = flowHelper.InstallAll();
Simulator::Run();
monitor->SerializeToXmlFile(“ipv4-flow.xml”, true, true);
Simulator::Destroy();
✅ Outputs: We have to estimate the performance of packet delivery, delay, and loss through the ipv4-flow.xml.
🔍 Advanced IPv4 Protocol Research Topics
- IPv4 to IPv6 Transition → Dual-stack IPv4/IPv6 routing replication.
- AI-Based IPv4 Routing Optimization → Machine learning models used for route selection.
- IPv4 Security & Firewall Simulation → To replicate the DDoS, Intrusion Detection, Encryption.
- IPv4 QoS Enhancement → To execute bandwidth-aware routing & traffic prioritization.
- IPv4 Performance Analysis in Wireless Networks → Estimate the performance of IPv4 in the wireless networks like Wi-Fi, LTE, 5G simulations.
📝 Summary: Developing IPv4 Protocol Projects in NS3
✔ Step 1: Initially, we set up NS3 & necessary components
✔ Step 2: Generate a IPv4 network topology
✔ Step 3: Execute the Static/Dynamic IPv4 routing
✔ Step 4: Mimic TCP/UDP traffic in the IPv4
✔ Step 5: Enhance QoS & Bandwidth utilization of IPv4
✔ Step 6: Assess the performance of IPv4 using parameters
This demonstration covers the sequential method of the IPv4 Protocols project, which were effectively executed and analysed the performance in the simulation tool NS3 and we are ready to provide more specifies upon request.