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

How to Implement Network QoS Attainment in ns3

To implement the network Quality of services (QoS) in ns3 has numerous steps that include setup the network topology, configuring the QoS parameters and using the proper traffic types and policies to make certain the QoS is met.

The given below is the procedure on how to implement the network QoS in ns3 framework:

Step-by-step Implementation:

Step 1: Set Up the Simulation Environment

  • Make certain ns3 is installed in the computer.

Step 2: Create the Network Topology

  • Generate the simple network topology using ns3. The given below is the sample script to setup a basic network with three nodes connected by point-to-point links.

Step 3: Write the Script

  • Here, we provide the sample on how to generate and configure the network topology in ns3 with QoS settings:

#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/flow-monitor-helper.h”

#include “ns3/traffic-control-module.h”

using namespace ns3;

NS_LOG_COMPONENT_DEFINE (“QoSExample”);

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

{

CommandLine cmd;

cmd.Parse (argc, argv);

// Create nodes

NodeContainer nodes;

nodes.Create (3);

// Create point-to-point links and set attributes

PointToPointHelper pointToPoint;

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

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

// Install devices and links

NetDeviceContainer devices01;

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

NetDeviceContainer devices12;

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

// Install the Internet stack on the nodes

InternetStackHelper stack;

stack.Install (nodes);

// Assign IP addresses to the devices

Ipv4AddressHelper address;

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

Ipv4InterfaceContainer interfaces01 = address.Assign (devices01);

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

Ipv4InterfaceContainer interfaces12 = address.Assign (devices12);

// Set up traffic control for QoS

TrafficControlHelper tch;

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

QueueDiscContainer qdiscs;

qdiscs = tch.Install (devices01);

qdiscs = tch.Install (devices12);

// Create a UDP server application on node 2

UdpEchoServerHelper echoServer (9);

ApplicationContainer serverApps = echoServer.Install (nodes.Get (2));

serverApps.Start (Seconds (1.0));

serverApps.Stop (Seconds (10.0));

// Create a UDP client application on node 0

UdpEchoClientHelper echoClient (interfaces12.GetAddress (1), 9);

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

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

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

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

clientApps.Start (Seconds (2.0));

clientApps.Stop (Seconds (10.0));

// Enable routing

Ipv4GlobalRoutingHelper::PopulateRoutingTables ();

// Enable Flow Monitor to collect performance metrics

FlowMonitorHelper flowmonHelper;

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

// Run the simulation

Simulator::Run ();

// Output Flow Monitor statistics

monitor->CheckForLostPackets ();

Ptr<Ipv4FlowClassifier> classifier = DynamicCast<Ipv4FlowClassifier> (flowmonHelper.GetClassifier ());

std::map<FlowId, FlowMonitor::FlowStats> stats = monitor->GetFlowStats ();

for (std::map<FlowId, FlowMonitor::FlowStats>::const_iterator i = stats.begin (); i != stats.end (); ++i)

{

Ipv4FlowClassifier::FiveTuple t = classifier->FindFlow (i->first);

std::cout << “Flow ID: ” << i->first << ” Source Address: ” << t.sourceAddress << ” Destination Address: ” << t.destinationAddress << std::endl;

std::cout << “Tx Packets = ” << i->second.txPackets << std::endl;

std::cout << “Rx Packets = ” << i->second.rxPackets << std::endl;

std::cout << “Throughput: ” << i->second.rxBytes * 8.0 / (i->second.timeLastRxPacket.GetSeconds () – i->second.timeFirstTxPacket.GetSeconds ()) / 1024 / 1024 << ” Mbps” << std::endl;

}

// Clean up the simulation

Simulator::Destroy ();

return 0;

}

Explanation:

  1. Create Nodes and Links:
    • Create three nodes and connect them using point-to-point links.
  1. Install the Internet Stack:
    • Install the Internet stack on the nodes.
  1. Assign IP Addresses:
    • Assign IP addresses to the devices.
  1. Set Up Traffic Control for QoS:
    • Use TrafficControlHelper to set up a queue discipline (e.g., FQ-CoDel) to manage traffic and ensure QoS.
  1. Create Applications:
    • Create a UDP server application on node 2 and a UDP client application on node 0 to generate traffic.
  1. Enable Routing:
    • Populate routing tables to enable communication between nodes.
  1. Enable Flow Monitor:
    • Use Flow Monitor to collect performance metrics such as throughput, packet loss, and delay.
  1. Run the Simulation:
    • Run the simulation and output Flow Monitor statistics.

Step 4: Compile and Run the Script

  1. Save the script as qos-example.cc in the scratch directory of your ns-3 installation.
  2. Compile the script using the following commands:

./waf configure

./waf build

./waf –run qos-example

Step 5: Analyze the Results

  • After running the simulation, the script will output performance metrics such as the number of transmitted and received packets, and throughput. You can further analyse this data or modify the script to collect additional metrics.

As we discussed earlier about how the Network QoS Attainment will perform in ns3 simulation tool and we help to provide further information about how the Network QoS Attainment will adapt in different environments.

Our exerts utilizes ns3tool to incorporate the simulation needed for your project, specifically for supporting Network QoS Attainment. Drop us all you details to help you out.