How to Start Static Routing Projects Using NS3

To start a Static Routing project using NS3, able to manually set up routes among the nodes to replicate and examine the network behavior. Static routing is helpful for learning the simple concepts of networking, deterministic routing paths, and the effect of certain routes on network performance.

Below is a simplified approach to get started:

Steps to Start Static Routing Projects in NS3

  1. Understand Static Routing

What is Static Routing?

  • Static routing contains configuring routing tables manually for each node within the network.
  • It offers fixed paths for packet forwarding and it doesn’t alter to network modifications.
  • Static routing is appropriate for small and stable networks.

Key Characteristics:

  • It doesn’t calculate the dynamic route like OSPF or AODV.
  • It helps to set up easily however it not scalable for large networks.
  1. Set Up NS3

Install NS3:

  1. Go to nsnam.org to download and install NS3 on the system.
  2. Confirm installation:

./waf –run scratch/test-example

Required Modules:

  • internet: It supports for IP stack and static routing.
  • point-to-point, wifi, or csma: For network topologies, these modules are used.
  1. Plan Your Static Routing Simulation

Define Objectives:

  • To execute the static routes among nodes.
  • We should examine the performance parameters such as latency, throughput, and packet delivery.

Example Topology:

A basic multi-hop network including three nodes:

Node A ↔ Node B ↔ Node C

Metrics to Evaluate:

  • End-to-End Delay: We estimate the duration for packets moving from source to destination.
  • Packet Loss: Measure the percentage of packets that are lost.
  • Throughput: We need to compute the data effectively distributed over provided time.
  1. Implement Static Routing

Step 1: Create a Static Routing Topology

Set up routes manually using Ipv4StaticRouting of NS3.

Example Code:

#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); // Create three nodes: A, B, C

// Create point-to-point links

PointToPointHelper p2p;

p2p.SetDeviceAttribute(“DataRate”, StringValue(“10Mbps”));

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

NetDeviceContainer devicesAB = p2p.Install(nodes.Get(0), nodes.Get(1)); // A ↔ B

NetDeviceContainer devicesBC = p2p.Install(nodes.Get(1), nodes.Get(2)); // B ↔ C

// Install Internet stack

InternetStackHelper stack;

stack.Install(nodes);

// Assign IP addresses

Ipv4AddressHelper ipv4;

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

Ipv4InterfaceContainer interfacesAB = ipv4.Assign(devicesAB);

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

Ipv4InterfaceContainer interfacesBC = ipv4.Assign(devicesBC);

// Configure static routing

Ipv4StaticRoutingHelper staticRoutingHelper;

// Static route for Node A

Ptr<Ipv4StaticRouting> staticRoutingA = staticRoutingHelper.GetStaticRouting(nodes.Get(0)->GetObject<Ipv4>());

staticRoutingA->AddHostRouteTo(Ipv4Address(“10.1.2.2”), Ipv4Address(“10.1.1.2”), 1); // A → C via B

// Static route for Node B

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

staticRoutingB->AddHostRouteTo(Ipv4Address(“10.1.2.2”), Ipv4Address(“10.1.2.2”), 2); // Forward to C

staticRoutingB->AddHostRouteTo(Ipv4Address(“10.1.1.1”), Ipv4Address(“10.1.1.1”), 1); // Forward to A

// Static route for Node C

Ptr<Ipv4StaticRouting> staticRoutingC = staticRoutingHelper.GetStaticRouting(nodes.Get(2)->GetObject<Ipv4>());

staticRoutingC->AddHostRouteTo(Ipv4Address(“10.1.1.1”), Ipv4Address(“10.1.2.1”), 1); // C → A via B

// Create a UDP traffic source at Node A

uint16_t port = 9;

OnOffHelper onOffHelper(“ns3::UdpSocketFactory”, Address(InetSocketAddress(interfacesBC.GetAddress(1), port)));

onOffHelper.SetAttribute(“DataRate”, StringValue(“1Mbps”));

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

ApplicationContainer app = onOffHelper.Install(nodes.Get(0));

app.Start(Seconds(1.0));

app.Stop(Seconds(10.0));

// Create a packet sink at Node C

PacketSinkHelper packetSinkHelper(“ns3::UdpSocketFactory”, Address(InetSocketAddress(Ipv4Address::GetAny(), port)));

ApplicationContainer sinkApp = packetSinkHelper.Install(nodes.Get(2));

sinkApp.Start(Seconds(0.0));

sinkApp.Stop(Seconds(10.0));

// Enable PCAP tracing

p2p.EnablePcapAll(“static-routing”);

// Run simulation

Simulator::Run();

Simulator::Destroy();

return 0;

}

Step 2: Simulate and Debug

Enable Logging:

Allow NS3 logging to debug and then we observe the behaviour of static routing:

export NS_LOG=Ipv4StaticRouting=level_all

./waf –run scratch/static-routing

Capture Packets:

Examine traffic within Wireshark utilising PCAP tracing:

p2p.EnablePcapAll(“static-routing”);

  1. Evaluate Performance

Metrics to Measure:

  1. End-to-End Delay: Assess how long it takes time for packets moving from source to destination.
  2. Throughput: Compute the percentage of data that are effectively distributed over the simulation time.
  3. Packet Loss: Determine the volume of packets that are lost (if any).

Use FlowMonitor:

Utilize FlowMonitor to accumulate and examine the performance parameters.

FlowMonitorHelper flowMonitor;

Ptr<FlowMonitor> monitor = flowMonitor.InstallAll();

monitor->SerializeToXmlFile(“static-routing-performance.xml”, true, true);

  1. Advanced Features
  • Simulate Link Failures: We need to manually inactivate links monitoring the behavior of static routing.

devicesAB.Get(1)->SetAttribute(“ReceiveErrorModel”, PointerValue(CreateObject<RateErrorModel>()));

  • Add Mobility: Although static routing doesn’t adjust to mobility then we can be replicated the moving nodes for educational intentions.

MobilityHelper mobility;

mobility.SetMobilityModel(“ns3::ConstantPositionMobilityModel”);

mobility.Install(nodes);

  • QoS Integration: We can be used traffic shaping or priority-based packet managing with static routes.
  1. Document and Visualize

Document Implementation:

  • It offers goals, technique, routing sets up and outcomes.

Visualize Results:

  • Envision the network topology and traffic to utilize NetAnim tool.
  • We need to graph the performance indicators such as delay, throughput, and packet loss utilising Matplotlib or Gnuplot tools.

We clearly implicit the basic procedure for Static Routing Projects that were configured and simulated through NS3 environment. We will also be outlined additional information related to this topic as required.

If you want more updates on your project, feel free to contact us for assistance. By partnering with phdprojects.org, you can streamline your research and writing process, as we handle these challenging tasks for you.