How to Start Intra Domain Protocol Projects Using NS3

To start intra-domain routing protocols in NS3 that has contains to configure a network in a single autonomous system (AS) and these protocols generally utilized for internal routing such as RIP (Routing Information Protocol), OSPF (Open Shortest Path First) (which is estimated with static routing, since NS3 doesn’t directly support built-in OSPF), or OLSR (Optimized Link State Routing). To find and handle the routes within an AS using these protocols.

Given below is a series of steps to configuring an intra-domain routing protocol project in NS3.

Steps to Start Intra Domain Protocols Projects in NS3

  1. Install NS3

We can follow these commands (assuming a Linux environment) as NS3 doesn’t install on the system:

# Update system and install dependencies

sudo apt update

sudo apt install -y gcc g++ python3 python3-dev cmake libgsl-dev libsqlite3-dev

# Clone the NS-3 repository

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

cd ns-3

# Configure and build NS-3

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

./ns3 build

  1. Create a New Script for Intra-Domain Routing Protocol Simulation
  1. In the NS3’s scratch directory, we need to make a new file like intra_domain_protocol_simulation.cc.
  2. Configure an intra-domain network including routing protocols such as RIP and static routing to utilize the below example code.

Basic Structure of intra_domain_protocol_simulation.cc:

#include “ns3/core-module.h”

#include “ns3/network-module.h”

#include “ns3/internet-module.h”

#include “ns3/ipv4-static-routing-helper.h”

#include “ns3/point-to-point-module.h”

#include “ns3/applications-module.h”

#include “ns3/rip-helper.h”

Using namespace ns3;

NS_LOG_COMPONENT_DEFINE(“IntraDomainProtocolSimulation”);

int main(int argc, char *argv[]) {

// Enable logging for debugging

LogComponentEnable(“UdpEchoClientApplication”, LOG_LEVEL_INFO);

LogComponentEnable(“UdpEchoServerApplication”, LOG_LEVEL_INFO);

// Create nodes representing routers and end devices

NodeContainer routers, endDevices;

routers.Create(4);    // 4 routers within the AS

endDevices.Create(4); // 4 end devices connected to routers

// Set up point-to-point links between routers and end devices

PointToPointHelper p2p;

p2p.SetDeviceAttribute(“DataRate”, StringValue(“1Gbps”));

p2p.SetChannelAttribute(“Delay”, StringValue(“2ms”));

// Link configuration between Routers and Devices

NetDeviceContainer deviceAR = p2p.Install(endDevices.Get(0), routers.Get(0));

NetDeviceContainer deviceBR = p2p.Install(endDevices.Get(1), routers.Get(1));

NetDeviceContainer deviceCR = p2p.Install(endDevices.Get(2), routers.Get(2));

NetDeviceContainer deviceDR = p2p.Install(endDevices.Get(3), routers.Get(3));

// Link configuration between Routers

NetDeviceContainer deviceRR1 = p2p.Install(routers.Get(0), routers.Get(1));

NetDeviceContainer deviceRR2 = p2p.Install(routers.Get(1), routers.Get(2));

NetDeviceContainer deviceRR3 = p2p.Install(routers.Get(2), routers.Get(3));

// Install the Internet stack and routing protocols

InternetStackHelper internet;

internet.Install(routers);

internet.Install(endDevices);

// Assign IP addresses to links

Ipv4AddressHelper ipv4;

// Assign IP addresses to device-router links

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

ipv4.Assign(deviceAR);

ipv4.SetBase(“10.1.2.0”, “255.255.255.0”);

ipv4.Assign(deviceBR);

ipv4.SetBase(“10.1.3.0”, “255.255.255.0”);

ipv4.Assign(deviceCR);

ipv4.SetBase(“10.1.4.0”, “255.255.255.0”);

ipv4.Assign(deviceDR);

// Assign IP addresses to router-router links

ipv4.SetBase(“192.168.1.0”, “255.255.255.0”);

ipv4.Assign(deviceRR1);

ipv4.SetBase(“192.168.2.0”, “255.255.255.0”);

ipv4.Assign(deviceRR2);

ipv4.SetBase(“192.168.3.0”, “255.255.255.0”);

ipv4.Assign(deviceRR3);

// Set up RIP routing protocol within the AS

RipHelper rip;

Ipv4ListRoutingHelper list;

list.Add(rip, 0);

internet.SetRoutingHelper(list);

// Install the RIP protocol on the routers

internet.Install(routers);

// Set up a static route on router 1 for a specific path to other networks

Ipv4StaticRoutingHelper staticRoutingHelper;

Ptr<Ipv4StaticRouting> staticRouting = staticRoutingHelper.GetStaticRouting(routers.Get(1)->GetObject<Ipv4>());

staticRouting->AddNetworkRouteTo(Ipv4Address(“10.1.4.0”), Ipv4Mask(“255.255.255.0”), Ipv4Address(“192.168.2.2”), 1);

// Set up UDP Echo server on one end device to test connectivity

UdpEchoServerHelper echoServer(9);

ApplicationContainer serverApps = echoServer.Install(endDevices.Get(3)); // Set device D as server

serverApps.Start(Seconds(1.0));

serverApps.Stop(Seconds(10.0));

// Set up UDP Echo client on another end device to communicate with the server

UdpEchoClientHelper echoClient(Ipv4Address(“10.1.4.1”), 9); // Server IP

echoClient.SetAttribute(“MaxPackets”, UintegerValue(5));

echoClient.SetAttribute(“Interval”, TimeValue(Seconds(1.0)));

echoClient.SetAttribute(“PacketSize”, UintegerValue(1024));

ApplicationContainer clientApps = echoClient.Install(endDevices.Get(0)); // Set device A as client

clientApps.Start(Seconds(2.0));

clientApps.Stop(Seconds(10.0));

// Run the simulation

Simulator::Stop(Seconds(10.0));

Simulator::Run();

Simulator::Destroy();

return 0;

}

Explanation of the Code

  • Node Setup:
    • Routers: We make four routers to create an intra-domain network.
    • End Devices: Four end devices are associated to routers, in the AS to denote hosts.
  • Links:
    • Router-Device Links: These links among routers and devices to replicate the connections from each host to their corresponding router.
    • Router-Router Links: Links among the routers to mimic intra-domain routing paths in the AS.
  • IP Addressing:
    • Each link is allocated an IP subnet, to permit interaction over diverse network segments.
  • Routing Protocols:
    • RIP (Routing Information Protocol): We can set up depends on the routing protocol in the AS. RIP finds and sustains the routes dynamically in the network.
    • Static Routing: More static route is set up at one of the routers, replicating a certain path in the AS.
  • Applications:
    • UDP Echo Server: Configured on one end device (Device D), in the AS obtaining packets from other devices.
    • UDP Echo Client: We set up on another end device such as Device A, transmitting packets to the server, to experiment end-to-end connectivity.
  1. Build and Run the Simulation
  1. In the scratch directory of NS3, we want to save intra_domain_protocol_simulation.cc.
  2. Go to terminal then pass through to NS3 directory, and make the script:

./ns3 build

  1. Run the simulation:

./ns3 run scratch/intra_domain_protocol_simulation

  1. Analyze the Results

This configuration illustrates the intra-domain routing to utilise RIP that finds the routes in the AS. The UDP echo application will experiment the connectivity among devices through network.

To allow in-depth logs for routing activities of RIP, we insert the below line:

LogComponentEnable(“RipRoutingProtocol”, LOG_LEVEL_ALL);

It will be offered complete result on RIP route exchanges and updates.

Further Experimentation Ideas

To discover more advanced intra-domain protocols, we can consider following experiment:

  • Add More Routers and Devices: Maximize the network size to observe how the protocol manages a larger AS.
  • Vary Link Costs: We modify the Delay attribute using PointToPointHelper to mimic various link costs.
  • Simulate OSPF-Like Behavior: While NS3 does not have OSPF then we can be utilized static routes, replicating certain paths and routing preferences.
  • Use FlowMonitor for Performance Analysis: Monitor performance indicators such as packet delivery ratio, latency, and routing overhead for diverse network sets up.

This guide offers detailed simulation procedure with sample snippets and more ideas for experiment this projects that helps you how to configure and simulate the Intra Domain Protocol projects using NS3 tool. If you’d like more details on this project, feel free to ask!

Our expertise includes RIP (Routing Information Protocol), OSPF (Open Shortest Path First), which we estimate using static routing since NS3 doesn’t have built-in OSPF support, and OLSR (Optimized Link State Routing). At phdprojects.org, we’re here to help you discover the best project topics and simulation outcomes to get your Intra Domain Protocol Projects started using the NS3 tool. Partner with us, and you’ll see your project results. Let us take care of the project performance for you.