Skip to content
Example · AI / MARL

RL TCP congestion control (Gym)

TCP flows over a dumbbell bottleneck where a Python RL agent controls the congestion window through the ns3-ai Gym interface. Compare with the classic TCP variants.

ns3ai_rltcp_gym about 20 s on the server

Parameters (17)

Defaults are the values the browser run form starts from. Pass any of them on the command line as --name=value.

ParameterDefaultUnitDescription
RNG seed
--simSeed
0-RNG seed
Agent time step for TcpRlTimeBased
--envTimeStep
0.1sAgent time step for TcpRlTimeBased (s)
Number of leaf nodes on each side of the dumbbell
--nLeaf
1-Number of leaf nodes on each side of the dumbbell
Transport protocol to use
--transport_prot
TcpRlTimeBased-Transport protocol to use: TcpNewReno, TcpHybla, TcpHighSpeed, TcpHtcp, TcpVegas, TcpScalable, TcpVeno, TcpBic, TcpYeah, TcpIllinois, TcpWestwood, TcpWestwoodPlus, TcpLedbat, TcpLp, TcpRlTimeBased, TcpRlEventBased
Packet error rate
--error_p
0-Packet error rate (0 to 1)
Bottleneck link rate
--bottleneck_bandwidth
2Mbps-Bottleneck link rate (ns-3 DataRate, e.g. 2Mbps)
Bottleneck link delay
--bottleneck_delay
0.01ms-Bottleneck link delay (ns-3 Time, e.g. 0.01ms)
Access link rate
--access_bandwidth
10Mbps-Access link rate (ns-3 DataRate, e.g. 10Mbps)
Access link delay
--access_delay
20ms-Access link delay (ns-3 Time, e.g. 20ms)
Prefix of the output trace files
--prefix_name
TcpVariantsComparison-Prefix of the output trace files
Data to send per flow
--data
0-Data to send per flow (MB, 0 = unlimited)
IP packet size
--mtu
400bytesIP packet size (bytes)
Flow duration
--duration
60sFlow duration (s) (set for the paired Python agent; binary default 1000.0)
Enable flow monitor
--flow_monitor
false-Enable flow monitor
Allowed: true, false
Queue disc type for gateway
--queue_disc_type
ns3::PfifoFastQueueDisc-Queue disc type for gateway (e.g. ns3::CoDelQueueDisc)
Enable or disable SACK option
--sack
true-Enable or disable SACK option
Allowed: true, false
TCP recovery algorithm
--recovery
ns3::TcpClassicRecovery-TCP recovery algorithm (e.g. ns3::TcpPrrRecovery)

Reproduce it locally

With the example's built-in defaults, in the public Docker image:

shell
docker run --rm -it uzairdocker69/ns3-ntn-toolkit:latest ./ns3 run "ns3ai_rltcp_gym"

With the same parameters the browser run form starts from:

shell
docker run --rm -it uzairdocker69/ns3-ntn-toolkit:latest ./ns3 run "ns3ai_rltcp_gym --simSeed=0 --envTimeStep=0.1 --nLeaf=1 --transport_prot=TcpRlTimeBased --error_p=0 --bottleneck_bandwidth=2Mbps --bottleneck_delay=0.01ms --access_bandwidth=10Mbps --access_delay=20ms --prefix_name=TcpVariantsComparison --data=0 --mtu=400 --duration=60 --flow_monitor=false --queue_disc_type=ns3::PfifoFastQueueDisc --sack=true --recovery=ns3::TcpClassicRecovery"

List every argument with ./ns3 run "ns3ai_rltcp_gym --PrintHelp".

More AI / MARL examples

Cite this

If you use this module, please cite the article that describes the toolkit: doi:10.1109/OJCOMS.2026.3745010.

M. Uzair, B. G. Aldahlan, A. A. Albar, H. Althumali and A. Alghammas, "ns3-ntn-toolkit: An integrated ns-3 platform for 6G non-terrestrial networks," IEEE Open Journal of the Communications Society, vol. 7, pp. 13440-13467, 2026, doi: 10.1109/OJCOMS.2026.3745010.

BibTeX
@article{uzair2026ns3ntntoolkit,
  author  = {Uzair, Muhammad and Aldahlan, Bassma G. and Albar, Ali A. and
             Althumali, Huda and Alghammas, Adnan},
  title   = {ns3-ntn-toolkit: An Integrated ns-3 Platform for 6G
             Non-Terrestrial Networks},
  journal = {IEEE Open Journal of the Communications Society},
  volume  = {7},
  pages   = {13440--13467},
  year    = {2026},
  doi     = {10.1109/OJCOMS.2026.3745010}
}