Skip to main content

Appendix B. Congestion Control Pseudocode

This appendix describes an example implementation of the congestion controller described in Section 7.


B.1. Constants of Interest

  • kInitialWindow: Default initial congestion window
  • kMinimumWindow: Minimum congestion window
  • kLossReductionFactor: Congestion window reduction factor (recommended: 0.5)
  • kPersistentCongestionThreshold: Persistent congestion duration (recommended: 3)

B.2. Variables of Interest

  • max_datagram_size: Current maximum payload size
  • ecn_ce_counters[kPacketNumberSpace]: ECN-CE counter values
  • bytes_in_flight: Total bytes of in-flight packets
  • congestion_window: Maximum bytes allowed in flight
  • congestion_recovery_start_time: Recovery period start time
  • ssthresh: Slow start threshold

B.3-B.9. Algorithm Functions

Functions implementing the congestion control algorithm:

  • B.3. Initialization: Initialize congestion control variables
  • B.4. On Packet Sent: Update bytes in flight
  • B.5. On Packet Acknowledgment: Process acknowledged packets
  • B.6. On New Congestion Event: Handle congestion detection
  • B.7. Process ECN Information: Process ECN feedback
  • B.8. On Packets Lost: Handle packet loss
  • B.9. Removing Discarded Packets: Update bytes in flight for discarded packets

Note: For complete pseudocode implementations, please refer to the official RFC 9002 document Appendix B.