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

How to Implement Video Traffic scheduling in ns3

To implement the video traffic scheduling in ns3 has encompasses to setup a network emulation where video traffic is given to the urgency or managed in a particular way to make sure the quality of service (QoS). The given below are the complete procedure to setup the video traffic scheduling in ns3 using the DiffServ (Differentiated Services) model for QoS.

Step-by-Step Implementation:

Step 1: Install ns3

Make certain ns3 is installed in the computer.

Step 2: Set Up the Simulation Environment

Generate the novel simulation script or modify an existing one. This script will describe the network topology, nodes, mobility models, and communication protocols.

Step 3: Define Network Topology

Create nodes and define the network topology. Below are the sample setup for simple network with video traffic scheduling.

#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/traffic-control-module.h”

#include “ns3/diffserv-module.h”

#include “ns3/flow-monitor-module.h”

using namespace ns3;

NS_LOG_COMPONENT_DEFINE (“VideoTrafficSchedulingExample”);

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

{

// Enable logging

LogComponentEnable (“VideoTrafficSchedulingExample”, LOG_LEVEL_INFO);

// Create nodes

NodeContainer nodes;

nodes.Create (4); // Example with 4 nodes: 1 sender, 1 receiver, 2 routers

// Create 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(2));

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

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 interfaces1 = address.Assign (devices.Get(0));

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

Ipv4InterfaceContainer interfaces2 = address.Assign (devices.Get(1));

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

Ipv4InterfaceContainer interfaces3 = address.Assign (devices.Get(2));

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

Ipv4InterfaceContainer interfaces4 = address.Assign (devices.Get(3));

// Set up traffic control

TrafficControlHelper tch;

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

tch.Install (devices);

// Set up DiffServ

DiffServHelper diffServ;

diffServ.SetNetworkLayerQueueDisc (“ns3::RedQueueDisc”);

// Create and configure traffic classes

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

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);

ds->AddTrafficClass (voiceClass);

ds->AddTrafficClass (videoClass);

ds->AddTrafficClass (bestEffortClass);

tch.Install (nodes.Get(2)->GetObject<PointToPointNetDevice> ()->GetQueue ());

tch.Install (nodes.Get(3)->GetObject<PointToPointNetDevice> ()->GetQueue ());

// Install and start applications on nodes

uint16_t port = 8080;

// Video server application

OnOffHelper videoServer (“ns3::UdpSocketFactory”, InetSocketAddress (interfaces4.GetAddress (1), port));

videoServer.SetAttribute (“DataRate”, DataRateValue (DataRate (“500kbps”)));

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

videoServer.SetAttribute (“OnTime”, StringValue (“ns3::ConstantRandomVariable[Constant=1]”));

videoServer.SetAttribute (“OffTime”, StringValue (“ns3::ConstantRandomVariable[Constant=0]”));

ApplicationContainer serverApps = videoServer.Install (nodes.Get (0));

serverApps.Start (Seconds (1.0));

serverApps.Stop (Seconds (10.0));

// Video client application

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

ApplicationContainer clientApps = videoClient.Install (nodes.Get (1));

clientApps.Start (Seconds (1.0));

clientApps.Stop (Seconds (10.0));

// Set up FlowMonitor

FlowMonitorHelper flowmon;

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

// Run the simulation

Simulator::Stop (Seconds (10.0));

Simulator::Run ();

// Print statistics

monitor->CheckForLostPackets ();

Ptr<Ipv4FlowClassifier> classifier = DynamicCast<Ipv4FlowClassifier> (flowmon.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);

NS_LOG_UNCOND (“Flow ” << i->first << ” (” << t.sourceAddress << ” -> ” << t.destinationAddress << “)”);

NS_LOG_UNCOND (”  Tx Packets: ” << i->second.txPackets);

NS_LOG_UNCOND (”  Tx Bytes:   ” << i->second.txBytes);

NS_LOG_UNCOND (”  Rx Packets: ” << i->second.rxPackets);

NS_LOG_UNCOND (”  Rx Bytes:   ” << i->second.rxBytes);

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

}

// Clean up

Simulator::Destroy ();

return 0;

}

Step 4: Set Up Traffic Control and DiffServ

In the script above, we use the TrafficControlHelper and DiffServHelper to set up traffic control and differentiated services. Traffic classes for voice, video, and best effort are created and assigned to different queues.

Step 5: Install and Start Applications

We set up an OnOff application to simulate video traffic from a server to a client. The server sends video packets to the client over UDP.

Step 6: Run the Simulation

Compile and run your simulation script to see the effect of video traffic scheduling on network performance. The performance analyse of result will contains statistics like the number of packets transmitted and received, throughput, and any packet loss.

In the whole, we had clearly learned about video traffic scheduling that are given to the urgency messages to the network and it also manage the quality of services using ns3 implementation tool. We will give further information and implementation support on  video traffic scheduling performs in other simulation tools.