How to Begin Implement Network Queue Time in NS3
To begin the network queue time is NS3, we want to necessary for follow this procedure:
Steps to Begin Implement Network Queue Time in NS3
- Understand the Requirements
- Queue Time: These suggest to their duration packets employ in a queue for network before being communicated or stopped.
- Objective: Examine or operate the queuing delay according to some performance of parameters such as queue size, connection bandwidth, congestion design, etc.
- Set up ns-3
- Download and install the latest version of ns-3.
- Setting the conditions:
./waf configure –build-profile=debug –enable-examples –enable-tests
./waf build
- Validate the configuration using sample scripts:
./waf –run hello-simulator
- Familiarize Yourself with Queue Models in ns-3
The ns3 delivers the different queue designs. They generally used the designs are included:
- DropTailQueue: It is a basic FIFO queue.
- RedQueue: For apply the Random Early Detection (RED).
- CoDelQueue: Executes the Controlled Delay (CoDel).
- Modify or Create a Simulation Script
- It begins by a sample script such as simple-point-to-point.cc in scratch or examples.
- Increase the queue for the point-to-point connection.
Example: Configuring a Queue
#include “ns3/core-module.h”
#include “ns3/network-module.h”
#include “ns3/point-to-point-module.h”
#include “ns3/applications-module.h”
#include “ns3/traffic-control-module.h”
using namespace ns3;
int main(int argc, char *argv[])
{
Time::SetResolution(Time::NS);
NodeContainer nodes;
nodes.Create(2);
PointToPointHelper pointToPoint;
pointToPoint.SetDeviceAttribute(“DataRate”, StringValue(“10Mbps”));
pointToPoint.SetChannelAttribute(“Delay”, StringValue(“2ms”));
NetDeviceContainer devices;
devices = pointToPoint.Install(nodes);
// Set up queue
TrafficControlHelper tch;
tch.SetRootQueueDisc(“ns3::RedQueueDisc”);
QueueDiscContainer qdiscs = tch.Install(devices);
InternetStackHelper stack;
stack.Install(nodes);
Ipv4AddressHelper address;
address.SetBase(“10.1.1.0”, “255.255.255.0”);
Ipv4InterfaceContainer interfaces = address.Assign(devices);
UdpEchoServerHelper echoServer(9);
ApplicationContainer serverApps = echoServer.Install(nodes.Get(1));
serverApps.Start(Seconds(1.0));
serverApps.Stop(Seconds(10.0));
UdpEchoClientHelper echoClient(interfaces.GetAddress(1), 9);
echoClient.SetAttribute(“MaxPackets”, UintegerValue(1));
echoClient.SetAttribute(“Interval”, TimeValue(Seconds(1.0)));
echoClient.SetAttribute(“PacketSize”, UintegerValue(1024));
ApplicationContainer clientApps = echoClient.Install(nodes.Get(0));
clientApps.Start(Seconds(2.0));
clientApps.Stop(Seconds(10.0));
Simulator::Run();
// Analyze queue statistics
Ptr<QueueDisc> queue = qdiscs.Get(0);
NS_LOG_UNCOND(“Packets Dropped: ” << queue->GetStats().nTotalDroppedPackets);
NS_LOG_UNCOND(“Packets Enqueued: ” << queue->GetStats().nTotalEnqueuedPackets);
Simulator::Destroy();
return 0;
}
- Measure Queue Time
- Add Hooks: It tracks the packets for entering and exiting a queue.
- Sample for observe the packet queueing delay:
void QueueTrace(Ptr<const QueueDiscItem> item)
{
NS_LOG_UNCOND(“Packet Entered Queue at Time: ” << Simulator::Now().GetSeconds());
}
// Connect the trace
Ptr<QueueDisc> queue = qdiscs.Get(0);
queue->TraceConnectWithoutContext(“Enqueue”, MakeCallback(&QueueTrace));
- Run and Analyze
- Generate the execution for a replication:
./waf –run scratch/my-queue-simulation
- Examine the logged outcomes to recognize the queue behavior.
From this page, we had learned and get the knowledge on how to measure the queue times in the network to handle the enhanced transmission using the ns3 tool. We deliver the additional information on how the network queue time will perform in other simulation time.