Ns3 Projects for B.E/B.Tech M.E/M.Tech PhD Scholars.  Phone-Number:9790238391   E-mail: ns3simulation@gmail.com

How to Implement QoS aware Routing in ns3

To implement the QoS-aware routing in ns3, we need to configure the routing protocols and based on their Quality of Service (QoS) requirements we need to select certain kinds of traffic over others by using the mechanisms. This procedure will demonstrate the setup for basic network topology in ns3 and configuring it to support QoS-aware routing using the DiffServ (Differentiated Services) model.

Step-by-Step Implementation:

Step 1: Install ns3

Make sure ns3 is installed in the computer.

Step 2: Set Up the Simulation Environment

Create a new simulation script or modify an existing one. This script will define the network topology, nodes, and communication channels.

Step 3: Define Network Topology

Create nodes and define the network topology. For QoS-aware routing, we’ll use a basic network topology with a few nodes and set up traffic flows with different QoS requirements.

#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”

#include “ns3/diffserv-module.h”

using namespace ns3;

NS_LOG_COMPONENT_DEFINE (“QoSAwareRoutingExample”);

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

{

// Enable logging

LogComponentEnable (“QoSAwareRoutingExample”, LOG_LEVEL_INFO);

// Create nodes

NodeContainer nodes;

nodes.Create (4); // Create 4 nodes

// Set up point-to-point links

PointToPointHelper pointToPoint;

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

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

NetDeviceContainer devices;

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

devices = pointToPoint.Install (nodes.Get(1), nodes.Get(2));

devices = pointToPoint.Install (nodes.Get(2), nodes.Get(3));

// Install Internet stack

InternetStackHelper stack;

stack.Install (nodes);

// Assign IP addresses

Ipv4AddressHelper address;

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

Ipv4InterfaceContainer interfaces = address.Assign (devices);

// Set up DiffServ

TrafficControlHelper tch;

tch.SetRootQueueDisc (“ns3::RedQueueDisc”);

tch.Install (devices);

// Create and configure traffic classes

Ptr<DiffServ> diffServ = CreateObject<DiffServ> ();

diffServ->AddQueueDisc (devices.Get (0)->GetObject<PointToPointNetDevice> ()->GetQueue ());

Ptr<TrafficClass> voiceClass = CreateObject<TrafficClass> ();

voiceClass->SetTrafficClass (1);

voiceClass->SetTrafficClassMask (0x01);

voiceClass->SetTrafficClassQueue (0);

Ptr<TrafficClass> videoClass = CreateObject<TrafficClass> ();

videoClass->SetTrafficClass (2);

videoClass->SetTrafficClassMask (0x02);

videoClass->SetTrafficClassQueue (1);

Ptr<TrafficClass> bestEffortClass = CreateObject<TrafficClass> ();

bestEffortClass->SetTrafficClass (3);

bestEffortClass->SetTrafficClassMask (0x03);

bestEffortClass->SetTrafficClassQueue (2);

diffServ->AddTrafficClass (voiceClass);

diffServ->AddTrafficClass (videoClass);

diffServ->AddTrafficClass (bestEffortClass);

// Install and start applications on nodes

uint16_t port = 8080;

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

UdpServerHelper server (port);

ApplicationContainer serverApps = server.Install (nodes.Get (1));

serverApps.Start (Seconds (1.0));

serverApps.Stop (Seconds (10.0));

UdpClientHelper client (serverAddress);

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

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

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

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

clientApps.Start (Seconds (2.0));

clientApps.Stop (Seconds (10.0));

// Run the simulation

Simulator::Stop (Seconds (10.0));

Simulator::Run ();

Simulator::Destroy ();

return 0;

}

Step 4: Configure Traffic Classes and DiffServ

In the script above, we set up DiffServ with three traffic classes: voice, video, and best effort. Each traffic class is assigned a different priority and mapped to a different queue.

Step 5: Set Up Traffic Generation

To generate traffic we set up a UDP server on node 1 and a UDP client on node 0. The traffic is configured to emulate various kinds of traffic with various QoS requirements.

Step 6: Run the Simulation

Compile and run your simulation script to see the effect of QoS-aware routing on network performance. The output will contain statistics like the number of packets transmitted and received, throughput, and any packet loss.

Overall, we had learned and understand about QoS-aware routing that performs based on their Quality of Service (QoS) requirements and it selects the  certain types communication over the other traffic that were implemented and executed by ns3 framework and also further support and provide the valuable insights regarding the QoS-aware routing.

Project ideas and performance analysis for Network QoS aware Routing using the ns3 tool are assisted by us. If you need assistance with performance analysis, feel free to reach out to us. Let us know your Quality of Service (QoS) requirements for optimal support.