Skip to content

BSD-like Silly Window Syndrome Avoidance#1111

Open
JPDye wants to merge 2 commits into
smoltcp-rs:mainfrom
JPDye:silly-window-syndrome
Open

BSD-like Silly Window Syndrome Avoidance#1111
JPDye wants to merge 2 commits into
smoltcp-rs:mainfrom
JPDye:silly-window-syndrome

Conversation

@JPDye

@JPDye JPDye commented Jan 26, 2026

Copy link
Copy Markdown
Contributor

Implementing SWS avoidance using the BSD approach (also copied by Linux).

  • Receiver-side SWS avoidance
  • Fix failing receiver-side tests
  • Sender-side SWS avoidance
  • Override timer for sender-side SWS avoidance
  • Fix failing sender-side tests
  • Remove duplicate calculations from seq_to_transmit() and send_is_blocked()
  • SWSOverrideTimer based on RTT?
  • More tests

@JPDye JPDye changed the title BSD-like receiver-side silly window avoidance BSD-like Silly Window Syndrome Avoidance Jan 26, 2026
@codecov

codecov Bot commented Jan 26, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 89.47368% with 12 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.25%. Comparing base (39cd44e) to head (fd13b93).
⚠️ Report is 83 commits behind head on main.

Files with missing lines Patch % Lines
src/socket/tcp.rs 89.47% 12 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1111      +/-   ##
==========================================
+ Coverage   80.45%   81.25%   +0.79%     
==========================================
  Files          81       81              
  Lines       24461    25002     +541     
==========================================
+ Hits        19681    20315     +634     
+ Misses       4780     4687      -93     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@JPDye

JPDye commented Jan 26, 2026

Copy link
Copy Markdown
Contributor Author

Not sure about the recv_out_of_recv_win() test. Previously the final ACK was sent immediately, now it's delayed. Probably need to fix that.

@JPDye JPDye force-pushed the silly-window-syndrome branch from 6ba9559 to 55e8528 Compare January 26, 2026 14:06
@JPDye JPDye force-pushed the silly-window-syndrome branch from 2e30539 to b77c147 Compare March 4, 2026 14:52
@JPDye

JPDye commented Mar 4, 2026

Copy link
Copy Markdown
Contributor Author

Obviously need to fix the tests.

More difficult is the approach to take with the override timeout that RFC 9293 requires. It says it can be combined with the ZWP timer but it's clearer to do it as a seperate timer I guess. Issue is where to do the setting of the timer, could do it by letting seq_to_transmit() take &mut self but I don't think that's very clean/inline with existing approach.

@JPDye JPDye force-pushed the silly-window-syndrome branch 2 times, most recently from a169c14 to 42b5dd8 Compare March 10, 2026 14:09
@JPDye

JPDye commented Mar 10, 2026

Copy link
Copy Markdown
Contributor Author

Need to add additional tests for the SWS behaviour.

Should SWS avoidance be toggle-able like nagles?

Edit: Now that I've finally got the netsim test working and see the throughput numbers, it would make sense to make SWS optional.

@JPDye JPDye force-pushed the silly-window-syndrome branch 4 times, most recently from 4941f8a to 37c1e0d Compare March 10, 2026 15:30
@Dirbaio

Dirbaio commented Mar 10, 2026

Copy link
Copy Markdown
Member

Edit: Now that I've finally got the netsim test working and see the throughput numbers, it would make sense to make SWS optional.

why? it shouldn't hurt throughput much

@JPDye

JPDye commented Mar 11, 2026

Copy link
Copy Markdown
Contributor Author

why? it shouldn't hurt throughput much

╭─────┬─────────┬─────────┬─────────┬─────────┬──────────┬──────────┬──────────┬──────────┬──────────╮
│   # │   buf   │  0.000  │  0.001  │  0.010  │  0.020   │  0.050   │  0.100   │  0.200   │  0.300   │
├─────┼─────────┼─────────┼─────────┼─────────┼──────────┼──────────┼──────────┼──────────┼──────────┤
│   0 │     128 │ -9.1%   │ -8.9%   │ -7.5%   │ -6.4%    │ -3.8%    │ -1.6%    │ -0.2%    │ +0%      │
│   1 │     256 │ -9.1%   │ -8.9%   │ -7.5%   │ -6.4%    │ -3.8%    │ -1.6%    │ -0.2%    │ +0%      │
│   2 │     512 │ -9.1%   │ -8.9%   │ -7.5%   │ -6.3%    │ -3.8%    │ -1.6%    │ -0.2%    │ +-0%     │
│   3 │    1024 │ -9.1%   │ -8.9%   │ -7.5%   │ -6.4%    │ -3.6%    │ -1.6%    │ -0.2%    │ +-0%     │
│   4 │    2048 │ -4.8%   │ -4.8%   │ -2.8%   │ -3.3%    │ +1%      │ +7.3%    │ +0.8%    │ +9.4%    │
│   5 │    4096 │ +0%     │ +0%     │ -0.3%   │ +0.2%    │ +4.9%    │ -1.2%    │ +2.4%    │ +13.4%   │
│   6 │    8192 │ +0%     │ +1.6%   │ +7.5%   │ +10.7%   │ +14.5%   │ +3.3%    │ +10.6%   │ -3.8%    │
│   7 │   16384 │ +0%     │ +0.2%   │ +1.8%   │ +1.9%    │ +23.7%   │ -7.3%    │ -6.8%    │ -16.7%   │
│   8 │   32768 │ +0%     │ +0.4%   │ +1.5%   │ -7.9%    │ +20.8%   │ -24.4%   │ -5%      │ -12.4%   │
╰─────┴─────────┴─────────┴─────────┴─────────┴──────────┴──────────┴──────────┴──────────┴──────────

If you know the network you're on and the hosts you're communicating with, SWS avoidance perhaps isn't necessary. Especially in an embedded context where the window is always "silly" (i.e. tiny buffers). TBF, I know nothing about embedded use-cases so if you're telling me it's not needed then that's cool.

Probably worth playing with the thresholds in window_to_update(), I mostly took them from the BSD source and so they're probably not be optimal for an embedded stack.

Also going to test if window updates need to be blocked by delayed ACKs. SWS means we'd only ever announce an update if it was significant, so delaying it to piggyback on a delayed ACK might not be optimal for throughput.

EDIT:

╭─────┬─────────┬─────────┬─────────┬─────────┬──────────┬──────────┬──────────┬──────────┬──────────╮
│   # │   buf   │  0.000  │  0.001  │  0.010  │  0.020   │  0.050   │  0.100   │  0.200   │  0.300   │
├─────┼─────────┼─────────┼─────────┼─────────┼──────────┼──────────┼──────────┼──────────┼──────────┤
│   0 │     128 │ +0%     │ +0%     │ +0%     │ +0%      │ +0%      │ +0%      │ +0%      │ +0%      │
│   1 │     256 │ +0%     │ +0%     │ +0%     │ +0%      │ +0%      │ +0%      │ +0%      │ +0%      │
│   2 │     512 │ +0%     │ +0%     │ +0%     │ +0%      │ +0%      │ +0%      │ +0%      │ +0%      │
│   3 │    1024 │ +0%     │ +0%     │ +0%     │ +0%      │ +0%      │ +0%      │ +0%      │ +0%      │
│   4 │    2048 │ +0%     │ +0%     │ +0%     │ +0%      │ +0%      │ +0%      │ +-0%     │ +0%      │
│   5 │    4096 │ +0%     │ +0%     │ +0%     │ +0%      │ +0%      │ +-0%     │ +-0%     │ +-0%     │
│   6 │    8192 │ +0%     │ +2.9%   │ +9%     │ +10.4%   │ +11.9%   │ +12.5%   │ +5.1%    │ +3.3%    │
│   7 │   16384 │ +0%     │ +0.1%   │ +1.7%   │ +0%      │ +6.1%    │ -1.9%    │ -8.4%    │ +14.9%   │
│   8 │   32768 │ +0%     │ +0.7%   │ +3.5%   │ -8.7%    │ +15.9%   │ +23.5%   │ +91.5%   │ -19.2%   │
╰─────┴─────────┴─────────┴─────────┴─────────┴──────────┴──────────┴──────────┴──────────┴──────────╯

All green if I never delay window updates to piggyback on the delayed ACK. The BSD implementation that I'm kinda copying is very explicit about not doing this so need to see how it affects number of segments sent/average segment size/etc to decide if it's worth it.

@JPDye JPDye force-pushed the silly-window-syndrome branch 2 times, most recently from 0b61a82 to ad83bee Compare March 13, 2026 12:17
@JPDye

JPDye commented Mar 13, 2026

Copy link
Copy Markdown
Contributor Author

Pretty happy with it as it is. Sending the immediate window update (even when delayed ACK is pending) seems to give much nicer performance on the netsim and I didn't notice anything significant in terms of small segments, etc....

Need to write some SWS specific tests and refactor seq_to_transmit() and send_is_blocked() to reuse their calculated values.

@JPDye JPDye force-pushed the silly-window-syndrome branch from ad83bee to 08f30be Compare March 13, 2026 17:02
@JPDye JPDye force-pushed the silly-window-syndrome branch from 08f30be to fd13b93 Compare March 13, 2026 17:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants