Skip to main content

Simulating DropTail vs. RED Queue Disciplines in NS-3 | NS3 Project 2

to Network Congestion and Buffer Overflow

Simulating DropTail vs. RED Queue Disciplines in NS3 

1. Introduction

Network congestion occurs when the incoming traffic load exceeds the processing or transmission capacity of network resources such as routers or links. In packet-switched networks, routers temporarily store packets in buffers (queues) before forwarding them. When the arrival rate of packets is higher than the departure rate, the queue length increases progressively.

Once the buffer reaches its maximum capacity, any additional incoming packets are dropped, resulting in buffer overflow. This leads to packet loss, increased queuing delay, reduced throughput, and overall degradation in network performance. Efficient queue management techniques are therefore essential to control congestion and maintain network stability.

2. Queue Management Techniques: DropTail vs. RED

Queue disciplines define how packets are stored and discarded in a router buffer. The design and operational goals behind passive and active queue management are fundamentally divergent:

DropTail Queue (Passive Queue Management)

DropTail follows a simple First-In-First-Out (FIFO) approach. Packets are accepted until the buffer is completely full. Once full, all incoming packets are dropped until space becomes available. This results in sudden packet loss bursts and poor congestion signaling to the end systems.

Random Early Detection (RED) (Active Queue Management)

RED is an advanced queue management technique that monitors the average queue size and begins dropping packets probabilistically before the buffer becomes full. This early detection mechanism helps signal congestion to the sender (forcing TCP windows to shrink or flagging packet distribution changes), preventing abrupt overflow and improving overall network performance.

3. Performance Metrics

To evaluate and compare the effectiveness of DropTail and RED, the following key performance indicators are utilized during validation:

  • Throughput: The rate at which data is successfully received at the destination over time. Higher throughput indicates better utilisation of network resources.
  • Packet Loss Ratio (PLR): The percentage of packets dropped due to congestion and buffer overflow. Lower PLR indicates better congestion handling.
  • Queue Length Behaviour: The variation in buffer occupancy over time. Stable queue behaviour indicates efficient congestion control.
  • End-to-End Delay: The total time taken for a packet to travel from source to destination. Increased congestion leads to higher delays.

4. Simulation Scenario and Network Topology

The experiment is conducted using a multi-node network topology designed to intentionally create congestion at a bottleneck link. The topology consists of multiple sender nodes transmitting high-rate UDP traffic towards a single receiver node through two intermediate routers. The access links connecting the senders to the first router operate at high bandwidth, while the link between the two routers is configured as a low-bandwidth bottleneck.

Due to the mismatch between the incoming traffic rate and the bottleneck capacity, packets accumulate at the router queue, leading to buffer overflow. The exact same topology is simulated twice—once using DropTail and once using RED—to observe differences in baseline behaviour.

5. Simulation Parameters

The experiment is modelled using the NS-3 discrete-event network simulator, with network traffic data captured and analysed via the FlowMonitor module. Environmental constraints and protocol configurations include:

ParameterAssigned Value
Simulator EnvironmentNS-3
Traffic TypeUDP
Number of Senders2 Senders
Access Link Bandwidth10 Mbps
Access Link Delay2 ms
Bottleneck Link Bandwidth1 Mbps
Bottleneck Link Delay10 ms
Queue DisciplineDropTail / RED (Toggled via flag)
Simulation Time15 seconds (Data tracked for 10s window)
Traffic Rate5 Mbps per sender (10 Mbps cumulative load)

6. Implementation Source Code

The simulation script is written in C++ using the structural modules of NS-3. Copy or reference this source code inside your local scratch/ directory:

#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/netanim-module.h" #include "ns3/flow-monitor-module.h" using namespace ns3; NS_LOG_COMPONENT_DEFINE("BufferOverflowSimulation"); static std::ofstream throughputFile; static uint64_t lastTotalRx = 0; // Function to calculate throughput void CalculateThroughput(Ptr<FlowMonitor> flowMonitor) { flowMonitor->CheckForLostPackets(); std::map<FlowId, FlowMonitor::FlowStats> stats = flowMonitor->GetFlowStats(); uint64_t totalRx = 0; for (auto &flow : stats) { totalRx += flow.second.rxBytes; } double timeNow = Simulator::Now().GetSeconds(); double throughput = (totalRx - lastTotalRx) * 8.0 / 1000000; // Mbps throughputFile << timeNow << " " << throughput << std::endl; lastTotalRx = totalRx; Simulator::Schedule(Seconds(1.0), &CalculateThroughput, flowMonitor); } int main(int argc, char *argv[]) { bool useRed = false; CommandLine cmd; cmd.AddValue("useRed", "Use RED queue discipline", useRed); cmd.Parse(argc, argv); // Nodes NodeContainer senders, routers, receiver; senders.Create(2); routers.Create(2); receiver.Create(1); // Internet InternetStackHelper stack; stack.InstallAll(); // Links PointToPointHelper fast, slow; fast.SetDeviceAttribute("DataRate", StringValue("10Mbps")); fast.SetChannelAttribute("Delay", StringValue("2ms")); slow.SetDeviceAttribute("DataRate", StringValue("1Mbps")); slow.SetChannelAttribute("Delay", StringValue("10ms")); NetDeviceContainer d1 = fast.Install(senders.Get(0), routers.Get(0)); NetDeviceContainer d2 = fast.Install(senders.Get(1), routers.Get(0)); NetDeviceContainer d3 = slow.Install(routers.Get(0), routers.Get(1)); // bottleneck NetDeviceContainer d4 = fast.Install(routers.Get(1), receiver.Get(0)); // Queue Discipline TrafficControlHelper tch; if (useRed) { tch.SetRootQueueDisc("ns3::RedQueueDisc"); } else { tch.SetRootQueueDisc("ns3::PfifoFastQueueDisc"); } tch.Install(d3); // IP Addressing Ipv4AddressHelper addr; addr.SetBase("10.1.1.0", "255.255.255.0"); addr.Assign(d1); addr.SetBase("10.1.2.0", "255.255.255.0"); addr.Assign(d2); addr.SetBase("10.1.3.0", "255.255.255.0"); addr.Assign(d3); addr.SetBase("10.1.4.0", "255.255.255.0"); addr.Assign(d4); Ipv4GlobalRoutingHelper::PopulateRoutingTables(); // Applications uint16_t port = 9; OnOffHelper onoff("ns3::UdpSocketFactory", Address(InetSocketAddress("10.1.4.2", port))); onoff.SetConstantRate(DataRate("5Mbps")); ApplicationContainer apps = onoff.Install(senders); apps.Start(Seconds(1.0)); apps.Stop(Seconds(15.0)); PacketSinkHelper sink("ns3::UdpSocketFactory", Address(InetSocketAddress(Ipv4Address::GetAny(), port))); ApplicationContainer sinkApp = sink.Install(receiver.Get(0)); sinkApp.Start(Seconds(0.0)); sinkApp.Stop(Seconds(15.0)); // Flow Monitor FlowMonitorHelper flowHelper; Ptr<FlowMonitor> flowMonitor = flowHelper.InstallAll(); // Throughput file throughputFile.open("throughput.dat"); Simulator::Schedule(Seconds(1.0), &CalculateThroughput, flowMonitor); // NetAnim AnimationInterface anim("anim.xml"); anim.SetConstantPosition(senders.Get(0), 0, 50); anim.SetConstantPosition(senders.Get(1), 0, 10); anim.SetConstantPosition(routers.Get(0), 20, 30); anim.SetConstantPosition(routers.Get(1), 50, 30); anim.SetConstantPosition(receiver.Get(0), 80, 30); Simulator::Stop(Seconds(15.0)); Simulator::Run(); flowMonitor->SerializeToXmlFile("flowmon.xml", true, true); Simulator::Destroy(); throughputFile.close(); return 0; }
Execution Command
To run the baseline DropTail evaluation:
./ns3 run scratch/fifo.cc

To run the active RED alternative, pass the dynamic parameter:
./ns3 run "scratch/fifo.cc --useRed=true"

7. Outputs and Multi-Tool Analysis

Animation (NetAnim / Python Visualization)

Using NetAnim, the spatial configuration shows packet streams converging smoothly from the high-speed links onto Router 0, while the queue status indicators visually emphasize backlog buildup preceding the bottleneck link to Router 1.

Graph (Throughput vs. Time)

Plotting the output files generated during the execution runtime maps a stark operational difference. DropTail charts clear performance cliffs, whereas RED presents a flatter, uniform data line.

Wireshark Analysis

Wireshark was utilised to inspect packet-level transmission intervals using standard PCAP files generated natively by NS-3. Deep-dive captures show precise sequences of continuous drop periods in DropTail versus randomised drops in RED.

8. Key Results and Inference

In the DropTail scenario, the queue fills completely before any packets are dropped. This results in sudden bursts of packet loss, increased delay, and unstable throughput. Since packet drops only happen after the buffer is entirely full, there is no early indication of congestion, leading to inefficient network utilisation and traffic synchronisation issues.

In contrast, RED begins dropping packets before the buffer reaches full capacity. This probabilistic early dropping helps regulate the incoming traffic rate and prevents abrupt congestion bottlenecks. As a result, the queue length remains more stable, packet loss is distributed evenly, and throughput remains relatively consistent throughout the execution duration.


NetAnim for Queue


Core Inference
The simulation clearly demonstrates that RED significantly outperforms DropTail in handling intense network congestion. While DropTail is simple to implement, it suffers from late congestion detection and burst packet losses. RED, through early congestion detection and controlled packet dropping, improves overall network stability, minimises processing delay variations, and maintains smoother throughput. Active queue management techniques like RED are fundamentally more suitable for modern high-traffic topologies where robust congestion control is critical.
#NetworkSimulation #NS3 #NetworkCongestion #BufferOverflow #QueueManagement #DropTail #REDQueue #WiresharkAnalysis #TechDeepDive

Comments

Popular posts from this blog

How to Create Ubuntu 24.04 Bootable USB Using Rufus [Step-by-Step Guide]

How to Create Ubuntu 24.04 Bootable USB Using Rufus [Step-by-Step Guide] Are you planning to install or try Ubuntu 24.04 LTS ? The easiest and most reliable method is to create a bootable USB drive using Rufus on a Windows system. This detailed guide will help you create a Ubuntu 24.04 USB bootloader using Rufus with easy-to-follow steps and screenshots (optional). Here is the complete video of the bootloader creation and OS installation in Windows 11. 🧰 Requirements A USB flash drive (minimum 8GB recommended) A Windows PC Ubuntu 24.04 LTS ISO file Rufus USB creation tool 🧾 Steps to Create a Ubuntu 24.04 Bootable USB Using Rufus ✅ Step 1: Download Ubuntu 24.04 ISO Visit the official Ubuntu website and download the Ubuntu 24.04 LTS ISO file . ✅ Step 2: Download and Run Rufus Head to Rufus official site and download the latest version. Open the executable file (no installation required). ✅ Step 3: Insert USB Drive Plug in your USB drive. Rufus ...

Installing ns3 in Ubuntu 22.04 | Complete Instructions

In this post, we are going to see how to install ns-3.36.1 in Ubuntu 22.04. You can follow the video for complete details Tools used in this simulation: NS3 version ns-3.36.1  OS Used: Ubuntu 22.04 LTS Installation of NS3 (ns-3.36.1) There are some changes in the ns3 installation procedure and the dependencies. So open a terminal and issue the following commands Step 1:  Prerequisites $ sudo apt update In the following packages, all the required dependencies are taken care and you can install all these packages for the complete use of ns3. $ sudo apt install g++ python3 python3-dev pkg-config sqlite3 cmake python3-setuptools git qtbase5-dev qtchooser qt5-qmake qtbase5-dev-tools gir1.2-goocanvas-2.0 python3-gi python3-gi-cairo python3-pygraphviz gir1.2-gtk-3.0 ipython3 openmpi-bin openmpi-common openmpi-doc libopenmpi-dev autoconf cvs bzr unrar gsl-bin libgsl-dev libgslcblas0 wireshark tcpdump sqlite sqlite3 libsqlite3-dev  libxml2 libxml2-dev libc6-dev libc6-dev-i386 libc...

Installation of NS2 in Ubuntu 22.04 | NS2 Tutorial 2

NS-2.35 installation in Ubuntu 22.04 This post shows how to install ns-2.35 in Ubuntu 22.04 Operating System Since ns-2.35 is too old, it needs the following packages gcc-4.8 g++-4.8 gawk and some more libraries Follow the video for more instructions So, here are the steps to install this software: To download and extract the ns2 software Download the software from the following link http://sourceforge.net/projects/nsnam/files/allinone/ns-allinone-2.35/ns-allinone-2.35.tar.gz/download Extract it to home folder and in my case its /home/pradeepkumar (I recommend to install it under your home folder) $ tar zxvf ns-allinone-2.35.tar.gz or Right click over the file and click extract here and select the home folder. $ sudo apt update $ sudo apt install build-essential autoconf automake libxmu-dev gawk To install gcc-4.8 and g++-4.8 $ sudo gedit /etc/apt/sources.list make an entry in the above file deb http://in.archive.ubuntu.com/ubuntu/ bionic main universe $ sudo apt update Since, it...