How to Begin Implement Network Service Level Agreement in NS3

To implement a Network Service Level Agreement (SLA) using ns3, we will need to replicate the QoS (Quality of Service) strategies, which follow predefined SLA needs like bandwidth, latency, jitter, and packet loss. Here’s a detailed guide to get started with executing SLAs in ns3:

Steps to Begin Implement Network Service Level Agreement in NS3

  1. Understand SLA Requirements
  • Describe SLA metrics for simulation:
    • Bandwidth Guarantee: Least throughput for certain flows.
    • Latency: Highest acceptable delay.
    • Jitter: Acceptable variation within packet arrival times.
    • Packet Loss: Most acceptable loss rate.
  • Detect the kinds of traffic such as VoIP, video streaming, bulk data transfer.
  1. Set Up the ns3 Environment
  • We can install ns3  simulator on the computer:

git clone https://gitlab.com/nsnam/ns-3-dev.git

cd ns-3-dev

./ns3 configure –enable-examples –enable-tests

./ns3 build

  • Confirm the installation including:

./ns3 run hello-simulator

  1. Choose or Design a Network Topology
  • Create a network topology that encompasses nodes, links, and traffic generators.
  • For various kinds of networks, we need to leverage PointToPointHelper, CsmaHelper, or WifiHelper.
  • Example: Make a basic network including SLA-critical and best-effort traffic flows.
  1. Implement QoS Mechanisms

SLA execution frequently contains prioritizing traffic and guaranteeing QoS compliance. Make use of the following approaches within ns3:

(a) Traffic Differentiation

  • Allocate priorities with the support of traffic classes:
    • Best-effort traffic for non-critical applications.
    • High-priority traffic for SLA-critical flows like VoIP.

 (b) Queue Management

  • For QoS application, we can leverage QueueDisc components:
    • PriorityQueueDisc: It gives precedence to SLA-critical traffic.
    • FIFO Queue: Default queue including no variation.
    • RED (Random Early Detection): Used for preventing congestion.

Example:

TrafficControlHelper tch;

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

(c) Traffic Shaping

  • Apply bandwidth restrictions with TrafficControlHelper:

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

tch.Install(netDevices);

  1. Generate Traffic
  • Replicate traffic utilising applications:
    • OnOffApplication: It makes traffic including certain rates.
    • UdpClient/Server or TcpClient/Server: Replicate various kinds of traffic.

Example:

OnOffHelper onOff(“ns3::UdpSocketFactory”, Address(InetSocketAddress(ipAddr, port)));

onOff.SetAttribute(“DataRate”, StringValue(“5Mbps”));

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

app.Add(onOff.Install(senderNode));

  1. Monitor SLA Compliance
  • Estimate the QoS parameters to use monitoring tools:
    • FlowMonitor: Accumulate throughput, delay, and packet loss indicators.

FlowMonitorHelper flowmon;

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

  1. Analyze SLA Violations
  • Equate the monitored parameters versus SLA thresholds.
  • Record any violations for detailed analysis.
  1. Example Code for SLA Simulation

Below is a sample code that replicates basic topology including SLA enforcement with traffic prioritization:

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

using namespace ns3;

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

CommandLine cmd;

cmd.Parse(argc, argv);

NodeContainer nodes;

nodes.Create(3);

PointToPointHelper p2p;

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

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

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

NetDeviceContainer devices2 = p2p.Install(nodes.Get(1), nodes.Get(2));

TrafficControlHelper tch;

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

tch.Install(devices1);

tch.Install(devices2);

InternetStackHelper stack;

stack.Install(nodes);

Ipv4AddressHelper address;

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

Ipv4InterfaceContainer if1 = address.Assign(devices1);

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

Ipv4InterfaceContainer if2 = address.Assign(devices2);

UdpEchoServerHelper echoServer(9);

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

serverApp.Start(Seconds(1.0));

serverApp.Stop(Seconds(10.0));

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

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

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

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

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

clientApp.Start(Seconds(2.0));

clientApp.Stop(Seconds(10.0));

FlowMonitorHelper flowmon;

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

Simulator::Run();

monitor->SerializeToXmlFile(“sla-results.xml”, true, true);

Simulator::Destroy();

return 0;

}

  1. Test Different SLA Scenarios
  • Modify traffic rates, delays, and priorities.
  • Analyze how the network replies to SLA violations.

We implemented an efficient method with complete coding outline using NS3 to execute and analyze the Network Service Level Agreement and further insights will be elaborated upon in the next guide.