A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
fack-example.cc File Reference

Example to verify TCP FACK performance based on Mathis & Mahdavi paper. More...

#include "ns3/applications-module.h"
#include "ns3/core-module.h"
#include "ns3/flow-monitor-module.h"
#include "ns3/internet-module.h"
#include "ns3/network-module.h"
#include "ns3/point-to-point-module.h"
#include "ns3/traffic-control-module.h"
Include dependency graph for fack-example.cc:

Go to the source code of this file.

Functions

static void BytesInFlightTracer (Ptr< OutputStreamWrapper > stream, uint32_t oldval, uint32_t newval)
 Trace BytesInFlight in segments.
void CheckQueueSize (Ptr< QueueDisc > qd)
 Check and trace the queue size.
static void CwndTracer (Ptr< OutputStreamWrapper > stream, uint32_t oldval, uint32_t newval)
 Trace congestion window.
static void FackAwndTracer (Ptr< OutputStreamWrapper > stream, uint32_t oldval, uint32_t newval)
 Trace FACK's inflight(AWND) in segments.
void TraceBytesInFlight (uint32_t nodeId, uint32_t socketId)
 Bind the BytesInFlight trace source.
void TraceCwnd (uint32_t nodeId, uint32_t socketId)
 Bind the Congestion Window trace source.
void TraceFackAwnd (uint32_t nodeId, uint32_t socketId)
 Bind the FackAwnd trace source.
static void TracePacketDrop (Ptr< OutputStreamWrapper > stream, Ptr< const QueueDiscItem > item)
 Trace packets dropped at Queue.
static void TraceThroughput (Ptr< FlowMonitor > monitor)
 Calculate and trace throughput.

Variables

std::string g_dir
 Output directory.
std::ofstream g_individualLostSegments
 Lost segments output stream.
uint32_t g_prev = 0
 Previous throughput byte count.
Time g_prevTime
 Previous throughput measurement time.
std::ofstream g_queueSize
 Queue size output stream.
uint32_t g_segmentSize = 1448
 Segment size.
std::ofstream g_throughput
 Throughput output stream.

Detailed Description

Example to verify TCP FACK performance based on Mathis & Mahdavi paper.

The network topology used in this example is based on the Fig. 1 described in Mathis, M., & Mahdavi, J. (1996, August). Forward acknowledgement: Refining TCP congestion control.

10 Mbps 1.5 Mbps 10 Mbps
Sender -------------- R1 -------------- R2 -------------- Receiver
2ms 5ms 33ms

This program runs by default for 100 seconds and creates a new directory called 'fack-results' in the ns-3 root directory. The program creates one sub-directory called 'pcap' in 'fack-results' directory (if pcap generation is enabled) and six .dat files.

  • 'pcap' sub-directory contains six PCAP files:
    • fack-0-0.pcap for the interface on Sender
    • fack-1-0.pcap for the interface on Receiver
    • fack-2-0.pcap for the first interface on R1
    • fack-2-1.pcap for the second interface on R1
    • fack-3-0.pcap for the first interface on R2
    • fack-3-1.pcap for the second interface on R2
  • cwnd.dat file contains congestion window trace for the sender node
  • throughput.dat file contains sender side throughput trace (throughput is in Mbit/s)
  • queueSize.dat file contains queue length trace from the bottleneck link
  • lostSegments.dat file contains packet lost trace at queue
  • bytesInFlight.dat contains trace of inflight data(SND.NXT - SND.UNA).
  • fackAwnd.dat contains trace of the FACK-specific inflight estimate.

This example allows the user to quantitatively verify two key mechanisms described in the Mathis & Mahdavi paper:

  1. The preservation of the TCP Self-Clock during recovery (Section 4.2).
  2. The "Overdamping" mechanism to drain queues after overshoot (Section 4.4).

To observe these insights, you must run the simulation twice with different configurations:

  • Step 1: Run with FACK enabled (Default)
    ./ns3 run "fack-example --fack=true"
    Every class exported by the ns3 library is enclosed in the ns3 namespace.
  • Step 2: Run with FACK disabled (Standard Reno+SACK behavior)
    ./ns3 run "fack-example --fack=false"
  • Step 3: Compare the output traces 'bytesInFlight.dat' and 'cwnd.dat' from both runs.

SPECIFIC OBSERVATIONS:

A. Preservation of Self-Clock (Compare 'bytesInFlight.dat'):

  • WITHOUT FACK: When multiple packet losses occur (approx t=0.5s), the inflight data drops significantly (often stalling near zero). This indicates a loss of the ACK clock, matching the behavior of "Reno+SACK" described in Section 4.2 and Figure 3 of the paper.
  • WITH FACK: The inflight data remains elevated even during recovery. This demonstrates that FACK successfully decouples congestion control from data recovery, using SACK blocks to inject new data and maintain the self-clock. This matches the behavior in Figure 4 of the paper.

B. Overdamping and Queue Draining (Compare 'cwnd.dat' vs 'bytesInFlight.dat'):

  • In the FACK run (between t=1.0s and t=2.0s), observe that 'cwnd' drops to a low value (~10 packets) while 'bytesInFlight' remains high (~50 packets).
  • This divergence is the "Overdamping" mechanism (Section 4.4). FACK detects that the actual data in the network (inflight) exceeds the target window (cwnd) due to the initial Slow-Start overshoot.
  • Consequently, FACK inhibits transmission (visible as a throughput dip) to allow the excess queue to drain.

Definition in file fack-example.cc.

Function Documentation

◆ BytesInFlightTracer()

void BytesInFlightTracer ( Ptr< OutputStreamWrapper > stream,
uint32_t oldval,
uint32_t newval )
static

Trace BytesInFlight in segments.

Parameters
streamThe output stream
oldvalOld value
newvalNew value

Definition at line 181 of file fack-example.cc.

References g_segmentSize, ns3::Time::GetSeconds(), and ns3::Simulator::Now().

Referenced by TraceBytesInFlight().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CheckQueueSize()

void CheckQueueSize ( Ptr< QueueDisc > qd)

Check and trace the queue size.

Parameters
qdThe queue disc

Definition at line 133 of file fack-example.cc.

References CheckQueueSize(), g_queueSize, ns3::Time::GetSeconds(), ns3::Simulator::Now(), ns3::Simulator::Schedule(), and ns3::Seconds().

Referenced by CheckQueueSize(), CheckQueueSize(), CheckQueueSize(), and experiment().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CwndTracer()

void CwndTracer ( Ptr< OutputStreamWrapper > stream,
uint32_t oldval,
uint32_t newval )
static

Trace congestion window.

Parameters
streamThe output stream
oldvalOld value
newvalNew value

Definition at line 168 of file fack-example.cc.

References g_segmentSize, ns3::Time::GetSeconds(), and ns3::Simulator::Now().

Referenced by ConnectSocketTraces(), TraceCwnd(), TraceCwnd(), TraceCwnd(), and TraceCwnd().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ FackAwndTracer()

void FackAwndTracer ( Ptr< OutputStreamWrapper > stream,
uint32_t oldval,
uint32_t newval )
static

Trace FACK's inflight(AWND) in segments.

Parameters
streamThe output stream
oldvalOld value
newvalNew value

Definition at line 194 of file fack-example.cc.

References g_segmentSize, ns3::Time::GetSeconds(), and ns3::Simulator::Now().

Referenced by TraceFackAwnd().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ TraceBytesInFlight()

void TraceBytesInFlight ( uint32_t nodeId,
uint32_t socketId )

Bind the BytesInFlight trace source.

Parameters
nodeIdThe node ID.
socketIdThe socket ID.

Definition at line 222 of file fack-example.cc.

References BytesInFlightTracer(), ns3::Config::ConnectWithoutContext(), ns3::AsciiTraceHelper::CreateFileStream(), g_dir, and ns3::MakeBoundCallback().

Here is the call graph for this function:

◆ TraceCwnd()

void TraceCwnd ( uint32_t nodeId,
uint32_t socketId )

Bind the Congestion Window trace source.

Parameters
nodeIdThe node ID.
socketIdThe socket ID.

Definition at line 206 of file fack-example.cc.

References ns3::Config::ConnectWithoutContext(), ns3::AsciiTraceHelper::CreateFileStream(), CwndTracer(), g_dir, and ns3::MakeBoundCallback().

Referenced by experiment(), and InstallBulkSend().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ TraceFackAwnd()

void TraceFackAwnd ( uint32_t nodeId,
uint32_t socketId )

Bind the FackAwnd trace source.

Parameters
nodeIdThe node ID.
socketIdThe socket ID.

Definition at line 238 of file fack-example.cc.

References ns3::Config::ConnectWithoutContext(), ns3::AsciiTraceHelper::CreateFileStream(), FackAwndTracer(), g_dir, and ns3::MakeBoundCallback().

Here is the call graph for this function:

◆ TracePacketDrop()

void TracePacketDrop ( Ptr< OutputStreamWrapper > stream,
Ptr< const QueueDiscItem > item )
static

Trace packets dropped at Queue.

Parameters
streamThe output stream
itemThe queue disc item dropped

Definition at line 146 of file fack-example.cc.

References g_segmentSize, ns3::Time::GetSeconds(), ns3::TcpHeader::GetSequenceNumber(), ns3::SequenceNumber< NUMERIC_TYPE, SIGNED_TYPE >::GetValue(), and ns3::Simulator::Now().

Here is the call graph for this function:

◆ TraceThroughput()

void TraceThroughput ( Ptr< FlowMonitor > monitor)
static

Calculate and trace throughput.

Parameters
monitorThe flow monitor

Definition at line 108 of file fack-example.cc.

References g_prev, g_prevTime, g_throughput, ns3::Time::GetSeconds(), ns3::Now(), ns3::Simulator::Schedule(), ns3::Seconds(), TraceThroughput(), and ns3::Time::US.

Referenced by TraceThroughput(), TraceThroughput(), and TraceThroughput().

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ g_dir

std::string g_dir

Output directory.

Definition at line 94 of file fack-example.cc.

Referenced by TraceBytesInFlight(), TraceCwnd(), and TraceFackAwnd().

◆ g_individualLostSegments

std::ofstream g_individualLostSegments

Lost segments output stream.

Definition at line 97 of file fack-example.cc.

◆ g_prev

uint32_t g_prev = 0

Previous throughput byte count.

Definition at line 99 of file fack-example.cc.

Referenced by TraceThroughput().

◆ g_prevTime

Time g_prevTime

Previous throughput measurement time.

Definition at line 100 of file fack-example.cc.

Referenced by TraceThroughput().

◆ g_queueSize

std::ofstream g_queueSize

Queue size output stream.

Definition at line 96 of file fack-example.cc.

Referenced by CheckQueueSize().

◆ g_segmentSize

uint32_t g_segmentSize = 1448

Segment size.

Definition at line 101 of file fack-example.cc.

Referenced by BytesInFlightTracer(), CwndTracer(), FackAwndTracer(), and TracePacketDrop().

◆ g_throughput

std::ofstream g_throughput

Throughput output stream.

Definition at line 95 of file fack-example.cc.

Referenced by TraceThroughput().