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
Post a Comment