freebsd-src icon indicating copy to clipboard operation
freebsd-src copied to clipboard

Feature/tcp bbr initial

Open rkarahan80 opened this issue 6 months ago • 1 comments

This commit introduces the core framework for the TCP BBR congestion control algorithm within the sys/netinet/cc/ directory.

Key changes:

  1. Created sys/netinet/cc/cc_bbr.c.
  2. Defined struct bbr_state to hold BBR's per-connection state variables, including those for BtlBw, RTprop, pacing/cwnd gains, current BBR mode (Startup, Drain, ProbeBW, ProbeRTT), round trip counting, BtlBw windowed filter, and ProbeRTT/ProbeBW cycle tracking.
  3. Implemented the required struct cc_algo bbr_algo interface with function pointers to BBR-specific handlers.
  4. Implemented core BBR callback logic:
    • bbr_cb_init(): Initializes per-connection BBR state.
    • bbr_cb_destroy(): Cleans up per-connection BBR state.
    • bbr_conn_init(): Initializes BBR state for a new TCP connection, starting in BBR_STARTUP mode.
    • bbr_ack_received(): Contains the main BBR state machine logic:
      • Updates BtlBw (using a 10-sample windowed max filter) and RTprop (via bbr_rttsample).
      • Manages transitions between BBR_STARTUP, BBR_DRAIN, BBR_PROBE_BW, and BBR_PROBE_RTT modes.
      • Implements gain cycling for BBR_PROBE_BW.
      • Calculates pacing_rate and snd_cwnd based on the current BBR mode and its model of the network path.
    • bbr_cong_signal(): Handles congestion events (RTO, ECN, NDUPACK) by adjusting snd_cwnd and BBR state (e.g., RTO causes reentry into BBR_STARTUP; loss during upward probing in BBR_PROBE_BW resets pacing gain to 1.0).
    • bbr_post_recovery(): Defines behavior after TCP fast recovery.
    • bbr_after_idle(): Resets BBR to BBR_STARTUP and clears stale estimates after an idle period.
    • bbr_rttsample(): Updates the RTprop (minimum RTT) estimate.
  5. Stubbed out less critical callbacks (bbr_ecnpkt_handler, bbr_newround, bbr_ctl_output).
  6. Used CC_ALGO_DECLARE(bbr, &bbr_algo) for module registration.

I paused while working on integrating cc_bbr.c into the build system, as sys/netinet/cc/Makefile was not found. The next step would be to locate the correct Makefile governing this directory (possibly sys/conf/files or a higher-level Makefile in sys/netinet/) and add cc_bbr.c to it. Following that, a sysctl interface for selecting BBR would be added.

rkarahan80 avatar Jun 13 '25 19:06 rkarahan80

Thank you for taking the time to contribute to FreeBSD! There are a few issues that need to be fixed:

  • Missing Signed-off-by lines7a9e7383284d6734424d47006691d882f389ea0a, 236f02db896101455ea2be4b877130e529021796, 5d4b25932af0e6afc929ac04d27d9436e7a51b4e, 75f038143dc86cd45c51a34b97ad498c63a3c946
  • Real email address is needed7a9e7383284d6734424d47006691d882f389ea0a, 236f02db896101455ea2be4b877130e529021796, 5d4b25932af0e6afc929ac04d27d9436e7a51b4e, 75f038143dc86cd45c51a34b97ad498c63a3c946

github-actions[bot] avatar Jun 13 '25 19:06 github-actions[bot]

Please don't spam our repository with AI-generated slop. It serves only to waste our time and yours. After reviewing some of your PRs, I have concluded that the rest do not warrant even a cursory review. Therefore I will close them all. If you wish to contribute again in the future, you must take more care with your submissions. You must build and test them all, at least! And you need to consider what the PR does. Is it even useful? Furthermore, the copyright status of AI-generated code is currently unclear, so the project is not accepting any such submissions at this time. But AI can of course be used as an aid, such as for debugging. Finally, I encourage you to read these documents to familiarize yourself with our project and its practices.

https://docs.freebsd.org/en/books/developers-handbook/ https://docs.freebsd.org/en/articles/problem-reports/

asomers avatar Jun 29 '25 15:06 asomers