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

tcp: add netsim test #1026

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

tcp: add netsim test #1026

wants to merge 5 commits into from

Conversation

Dirbaio
Copy link
Member

@Dirbaio Dirbaio commented Dec 30, 2024

This test simulates a network with a given latency and packet loss, and measures the
throughput between two virtual smoltcp instances. It seems to match what's expected. For example given a 1024b buffer the expected throughput is 1024b/100ms=10240b/s (at zero loss). and it checks out. Throughput goes down exponentially as loss increases.

Depends on #1025 for fixes to actually make tcp work and not get stuck. For example lack of zero window probes, and retransmits were broken in some edge cases.

I'm not sure how to actually use the test results. Options:

  • (what this PR implements) snapshot the throughputs into a text file, check it into git. Every time someone touches something that changes the throughput they'll have to do INSTA_UPDATE=always cargo test to update the snapshot and get the test to pass, and in the PR diff we'll be able to review the effect on the throughput.
  • Sameas above, but reinvent it ourselves instead of adding insta to save a dependency.
  • Just assert throughput is higher than a number we pick as acceptable throughput. Simpler but won't catch small variations.
  • Make some bot like rustc's perf that runs it and posts the results in a PR comment and allows diffing them. Probably too overengineered.

Future work:

  • Simulate a network max throughput. Will be useful to test the congestion controllers.
  • Test usage patterns other than one-way throughput. For example non-pipelined request+response. Will be useful to test the impact of delayed ack, nagle, etc.

- RFC 6298 says we should start the retransmit timer as soon as we send a segment
  that has data. We were starting it on the *last* segment instead.
- Simplified logic with set_for_idle, it's now uniform across all tcp states.
- Fix FIN retransmits not being sent in CLOSED state.
@Dirbaio Dirbaio force-pushed the netsim branch 2 times, most recently from f11eadc to aff2bce Compare December 30, 2024 12:16
This test simulates a network with a given latency and packet loss, and measures the
throughput between two virtual smoltcp instances.
Copy link

codecov bot commented Dec 30, 2024

Codecov Report

Attention: Patch coverage is 99.01768% with 5 lines in your changes missing coverage. Please review.

Project coverage is 81.21%. Comparing base (104898b) to head (ab61335).
Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
src/socket/tcp.rs 99.01% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1026      +/-   ##
==========================================
+ Coverage   80.88%   81.21%   +0.33%     
==========================================
  Files          81       81              
  Lines       28447    28916     +469     
==========================================
+ Hits        23010    23485     +475     
+ Misses       5437     5431       -6     

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

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.

1 participant