Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: optimize ib size for 3 TCP round trips #218

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

will-break-it
Copy link
Contributor

@will-break-it will-break-it commented Feb 27, 2025

During TCP's slow start phase, the congestion window (CWND) typically:

Starts with an initial congestion window (initcwnd) of 10 MSS (Maximum Segment Size)
Doubles after each round trip time (RTT)

With a standard MSS of 1460 bytes:

  • Round Trip 1: 10 MSS = 10 × 1460 = 14,600 bytes
  • Round Trip 2: 20 MSS = 20 × 1460 = 29,200 bytes
  • Round Trip 3: 40 MSS = 40 × 1460 = 58,400 bytes

Total for 3 round trips: 14,600 + 29,200 + 58,400 = 102,200 bytes

However, we need to account for TCP/IP overhead:

  • TCP header: 20 bytes
  • IP header: 20 bytes

This means each segment carries 1460 bytes of payload but requires 1500 bytes on the wire.
When accounting for this overhead and some implementation variations (like initial window sizes that might be slightly different in various TCP stacks), the practical optimal size for 3 round trips is approximately 98304 bytes (96KB).

This value represents a sweet spot that:

  1. Fully utilizes 3 complete round trips
  2. Doesn't require a partial 4th round trip
  3. Accounts for real-world TCP implementation variations

@will-break-it will-break-it requested a review from bwbush February 27, 2025 09:42
@Saizan
Copy link
Contributor

Saizan commented Feb 28, 2025

FWIW, that was the original default ib-body-size default (taken from the praos simulation body default). It got lost when moving to the shared configuration. When revamping the defaults I went for a rounder number but now the specific 96kB makes more sense.

@will-break-it
Copy link
Contributor Author

@Saizan so I'll merge it then?

@Saizan
Copy link
Contributor

Saizan commented Feb 28, 2025

@will-break-it probably warranted and limited harm I would say. I'm no authority on tcp matters though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants