How to Begin Implementing a Network Routing projects using ns3

To stimulate a Network Routing project in ns-3 contains the replicate on how well the data packets are routed with network using fixed or dynamic routing protocols. Below is a step-by-step guide to help you get started.

Steps to Begin Implementing a Network Routing projects using ns3

Step 1: Understand Network Routing Concepts

  1. Routing Protocols:
    • Static Routing: The static routing has Predefined routes, no adaptation for modify the topology.
    • Dynamic Routing:
      • Proactive: It handles the routing tables for sample OSPF, DSDV.
      • Reactive: It detects the routes on demand for instance AODV, DSR.
  2. Routing Scenarios:
    • Wired networks: Use the wired network protocols such as RIP, OSPF.
    • Wireless networks: Use the wireless networks protocols like AODV, DSDV.
  3. Key Metrics:
    • It offers the performance the metrices like as end-to-end delay, packet delivery ratio, throughput, routing overhead.

Step 2: Install ns-3 and Required Modules

  1. Download ns-3:
  2. Enable Required Modules:
    • Involves the components for replicate the routing network:

./waf configure –enable-modules=internet,ipv4-routing,manet-routing,mobility,wifi,point-to-point

./waf build

  1. Verify Installation:
    • Validate the sample scripts for routing protocols:

./waf –run aodv

./waf –run dsdv

Step 3: Define the Project Scope

  • Scenario:
    • The network topology consist the static or dynamic topology.
    • The routing protocol for Wired or wireless communication.
  • Goals:
    • It associates the performance of routing protocols.
    • Execute and estimate the custom routing protocol.
  • Metrics:
    • The performance metrices such as Packet delivery ratio (PDR), latency, throughput, routing overhead.

Step : Set Up Network Topology

  1. Create Nodes:
    • Express the nodes for the network:

NodeContainer nodes;

nodes.Create(5); // 5 nodes in the network

  1. Set Up Links:
    • Use the setting for Point-to-Point (wired) or WiFi (wireless) connection:

PointToPointHelper p2p;

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

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

NetDeviceContainer devices = p2p.Install(nodes.Get(0), nodes.Get(1));

  1. Configure Mobility (For Wireless):
    • Configure the mobility for dynamic topologies:

MobilityHelper mobility;

mobility.SetMobilityModel(“ns3::RandomWalk2dMobilityModel”,

“Bounds”, RectangleValue(Rectangle(-100, 100, -100, 100)));

mobility.Install(nodes);

Step 5: Install Routing Protocols

  1. Static Routing:
    • Manually describe the routes:

Ipv4StaticRoutingHelper staticRoutingHelper;

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

staticRouting->AddHostRouteTo(Ipv4Address(“10.1.1.2”), Ipv4Address(“10.1.1.1”), 1);

  1. Dynamic Routing:
    • It use the built-in dynamic routing protocols:

AodvHelper aodv;

InternetStackHelper stack;

stack.SetRoutingHelper(aodv); // Use AODV for routing

stack.Install(nodes);

  1. Routing Table Verification:
    • Design the routing tables for enable they are setting correctly:

Ipv4GlobalRoutingHelper::PopulateRoutingTables();

Step 6: Assign IP Addresses

  • Allocate the IP addresses for devices:

InternetStackHelper stack;

stack.Install(nodes);

Ipv4AddressHelper ipv4;

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

Ipv4InterfaceContainer interfaces = ipv4.Assign(devices);

Step 7: Add Traffic Applications

  1. Traffic Generators:
    • Improve the application for build and receive congestion:

uint16_t port = 9;

Address sinkAddress(InetSocketAddress(interfaces.GetAddress(1), port));

PacketSinkHelper sink(“ns3::UdpSocketFactory”, sinkAddress);

ApplicationContainer sinkApp = sink.Install(nodes.Get(1));

sinkApp.Start(Seconds(1.0));

sinkApp.Stop(Seconds(10.0));

OnOffHelper onOff(“ns3::UdpSocketFactory”, sinkAddress);

onOff.SetAttribute(“DataRate”, StringValue(“500Kbps”));

ApplicationContainer clientApp = onOff.Install(nodes.Get(0));

clientApp.Start(Seconds(2.0));

clientApp.Stop(Seconds(10.0));

  1. Custom Applications:
    • Encompass the Application for custom congestion design.

Step 8: Enable Tracing and Monitoring

  1. Enable Tracing:
    • The performance of metrices actions for analysis:

AsciiTraceHelper ascii;

p2p.EnableAsciiAll(ascii.CreateFileStream(“routing.tr”));

  1. FlowMonitor:
    • Use the FlowMonitor for performance metrics:

FlowMonitorHelper flowMonitor;

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

Step 9: Run the Simulation

  1. Schedule Simulation:
    • Describe the duration of replication:

Simulator::Stop(Seconds(10.0));

Simulator::Run();

Simulator::Destroy();

  1. Analyze Results:
    • Use the outcomes for trace files or track the results in estimate the performance.

Step 10: Example: AODV in Wireless Network

Below is a basic sample script for executing AODV in a wireless network:

#include “ns3/core-module.h”

#include “ns3/network-module.h”

#include “ns3/mobility-module.h”

#include “ns3/wifi-module.h”

#include “ns3/aodv-helper.h”

#include “ns3/internet-module.h”

#include “ns3/applications-module.h”

using namespace ns3;

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

NodeContainer nodes;

nodes.Create(5);

MobilityHelper mobility;

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

mobility.Install(nodes);

YansWifiChannelHelper wifiChannel = YansWifiChannelHelper::Default();

YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default();

wifiPhy.SetChannel(wifiChannel.Create());

WifiHelper wifi;

wifi.SetRemoteStationManager(“ns3::AarfWifiManager”);

WifiMacHelper wifiMac;

Ssid ssid = Ssid(“ns3-wifi”);

wifiMac.SetType(“ns3::AdhocWifiMac”);

NetDeviceContainer devices = wifi.Install(wifiPhy, wifiMac, nodes);

AodvHelper aodv;

InternetStackHelper stack;

stack.SetRoutingHelper(aodv);

stack.Install(nodes);

Ipv4AddressHelper ipv4;

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

Ipv4InterfaceContainer interfaces = ipv4.Assign(devices);

uint16_t port = 9;

UdpEchoServerHelper server(port);

ApplicationContainer serverApp = server.Install(nodes.Get(4));

serverApp.Start(Seconds(1.0));

serverApp.Stop(Seconds(10.0));

UdpEchoClientHelper client(interfaces.GetAddress(4), port);

client.SetAttribute(“MaxPackets”, UintegerValue(100));

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

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

ApplicationContainer clientApp = client.Install(nodes.Get(0));

clientApp.Start(Seconds(2.0));

clientApp.Stop(Seconds(10.0));

Simulator::Stop(Seconds(10.0));

Simulator::Run();

Simulator::Destroy();

return 0;

}

Step 11: Extend and Customize

  1. Custom Protocols:
    • Apply the new routing procedures through encompass the Ipv4RoutingProtocol.
  2. Performance Analysis:
    • It associates the several routing protocols below the similar network environments.
  3. Complex Topologies:
    • It replicates the large-scale networks by dynamic mobility.

We explicitly aggregated the significant information regarding the network routing that has generates a basic topology and creates traffic among nodes using the AODV routing protocol that execute in ns3 simulation. We will issue an additional document for questions related to this project.