Skip to main content

Simulation of TCP Variants over a High Bandwidth-Delay Product (BDP) Network | NS3 Project 8

Simulation of TCP Variants over a High Bandwidth-Delay Product (BDP) Network

1. Theory and Concept Write-up

Objective: To simulate and analyse the behaviour of different Transmission Control Protocol (TCP) variants over a Long Fat Network (LFN) characterised by a high Bandwidth-Delay Product (BDP).

Concept:

A Long Fat Network (LFN) is a network that has both a high bandwidth (capacity) and a high latency (delay). Examples of such networks include satellite links or long-distance optical fibre connections. The "thickness" of the network pipe is massive, meaning it can hold a huge amount of unacknowledged data in transit at any given time.

Standard TCP variants, such as TCP NewReno, struggle to operate efficiently on these networks. Because of the high delay, acknowledgements (ACKs) take a long time to return to the sender. As a result, standard TCP increases its Congestion Window (cwnd) too slowly, failing to utilise the massive available bandwidth. To solve this, advanced TCP variants like TCP HighSpeed were developed. These variants use modified algorithms to aggressively scale up their congestion windows, allowing them to rapidly fill the large network pipe and recover much faster from packet loss.

In this simulation, a Point-to-Point network is established with a bandwidth of 100 Mbps and a delay of 50 ms, creating an LFN environment. A tiny bit of packet loss (error rate of 0.00005) is introduced to mimic real-world long-distance conditions. We use a BulkSendApplication to flood the link with data and trace the Congestion Window (cwnd) to compare how efficiently TCP NewReno and TCP HighSpeed ramp up their transmission speeds and recover from drops.


 

2. Generative AI Details

·         LLM Used: Gemini 1.5 Pro

·         Prompt Used: I need an ns-3 C++ script to simulate a Long Fat Network (LFN) with a high bandwidth-delay product (100Mbps, 50ms delay). The script must allow switching between TCP variants (like TcpNewReno and TcpHighSpeed) via command line arguments. It needs to include a BulkSendApplication, trace the TCP Congestion Window (cwnd) to a text file for Gnuplot, and generate an XML file for NetAnim. Include a tiny error rate to trigger congestion control mechanisms.



3. Source Code (tcp.cc)

#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/netanim-module.h"

#include <fstream>


using namespace ns3;


// Callback function to record the Congestion Window (cwnd) changes

static void CwndChange(Ptr<OutputStreamWrapper> stream, uint32_t oldCwnd, uint32_t newCwnd) {

    *stream->GetStream() << Simulator::Now().GetSeconds() << "\t" << newCwnd << std::endl;

}


// Function to attach the tracer to the TCP socket

static void TraceCwnd(std::string cwnd_tr_file_name) {

    AsciiTraceHelper ascii;

    Ptr<OutputStreamWrapper> stream = ascii.CreateFileStream(cwnd_tr_file_name.c_str());

    Config::ConnectWithoutContext("/NodeList/0/$ns3::TcpL4Protocol/SocketList/0/CongestionWindow", MakeBoundCallback(&CwndChange, stream));

}


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

    // Default TCP variant

    std::string tcpVariant = "TcpHighSpeed";

   

    CommandLine cmd;

    cmd.AddValue("tcpVariant", "Transport protocol to use: TcpNewReno, TcpHighSpeed, etc.", tcpVariant);

    cmd.Parse(argc, argv);


    // Set the TCP variant globally based on user input

    Config::SetDefault("ns3::TcpL4Protocol::SocketType", StringValue("ns3::" + tcpVariant));


    NodeContainer nodes;

    nodes.Create(2);


    // Create a Long Fat Network (LFN): High Bandwidth (100Mbps) + High Delay (50ms)

    PointToPointHelper p2p;

    p2p.SetDeviceAttribute("DataRate", StringValue("100Mbps"));

    p2p.SetChannelAttribute("Delay", StringValue("50ms"));

   

    // Massive queue size required to prevent immediate packet drops in an LFN

    p2p.SetQueue("ns3::DropTailQueue", "MaxSize", StringValue("10000p"));


    NetDeviceContainer devices = p2p.Install(nodes);


    // Introduce a tiny error rate to observe congestion recovery

    Ptr<RateErrorModel> em = CreateObject<RateErrorModel>();

    em->SetAttribute("ErrorRate", DoubleValue(0.00005));

    devices.Get(1)->SetAttribute("ReceiveErrorModel", PointerValue(em));


    InternetStackHelper stack;

    stack.Install(nodes);


    Ipv4AddressHelper address;

    address.SetBase("10.1.1.0", "255.255.255.0");

    Ipv4InterfaceContainer interfaces = address.Assign(devices);


    uint16_t port = 50000;


    // Server Setup (Receiver)

    Address sinkAddress(InetSocketAddress(interfaces.GetAddress(1), port));

    PacketSinkHelper packetSinkHelper("ns3::TcpSocketFactory", InetSocketAddress(Ipv4Address::GetAny(), port));

    ApplicationContainer sinkApps = packetSinkHelper.Install(nodes.Get(1));

    sinkApps.Start(Seconds(0.0));

    sinkApps.Stop(Seconds(20.0));


    // Client Setup (Sender flooding the network)

    BulkSendHelper source("ns3::TcpSocketFactory", sinkAddress);

    source.SetAttribute("MaxBytes", UintegerValue(0)); // Send unlimited data

    ApplicationContainer sourceApps = source.Install(nodes.Get(0));

    sourceApps.Start(Seconds(1.0));

    sourceApps.Stop(Seconds(20.0));


    // Schedule the CWND tracer to attach right after the socket is created

    Simulator::Schedule(Seconds(1.00001), &TraceCwnd, "lfn_" + tcpVariant + ".cwnd");


    // Network Animation setup

    AnimationInterface anim("24bps1098_animation.xml");

    anim.SetConstantPosition(nodes.Get(0), 10.0, 50.0);

    anim.SetConstantPosition(nodes.Get(1), 90.0, 50.0);


    Simulator::Stop(Seconds(20.0));

    Simulator::Run();

    Simulator::Destroy();


    return 0;

}

 

 

4. Simulation Results

A. Network Animation (NetAnim)

Congestion Window in TCP

B. Congestion Window Comparison Graph

 

Graph Analysis:

The graph illustrates the Congestion Window (cwnd) growth of two different TCP variants operating over a high bandwidth-delay product link (100 Mbps, 50 ms delay) with a slight error rate.

·         TcpNewReno (Standard TCP): Exhibits a slow, linear increase in its congestion window. Because the network delay is high, the ACKs return slowly, preventing NewReno from aggressively scaling its window. When it encounters a packet drop, it cuts its window drastically and takes too long to recover, resulting in severe underutilization of the 100 Mbps link.

·         TcpHighSpeed: Specifically designed for Long Fat Networks (LFNs). The graph clearly shows HighSpeed utilizing a much steeper, non-linear growth curve for its congestion window. It successfully ramps up to fill the high-capacity pipe much faster than NewReno and recovers from packet drops aggressively, proving its superior efficiency in high-BDP environments.

 

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...