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

Merged
merged 5 commits into from
Mar 2, 2025
Merged

tcp: add netsim test #1026

merged 5 commits into from
Mar 2, 2025

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.

@Dirbaio Dirbaio force-pushed the netsim branch 3 times, most recently from aff2bce to ab61335 Compare December 30, 2024 12:23
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.17%. Comparing base (cce735e) to head (512aecb).
Report is 6 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.84%   81.17%   +0.33%     
==========================================
  Files          81       81              
  Lines       28485    28954     +469     
==========================================
+ Hits        23029    23504     +475     
+ Misses       5456     5450       -6     

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

@Dirbaio Dirbaio added this pull request to the merge queue Mar 2, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Mar 2, 2025
Dirbaio added 5 commits March 2, 2025 22:56
- 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.
This test simulates a network with a given latency and packet loss, and measures the
throughput between two virtual smoltcp instances.
@Dirbaio Dirbaio added this pull request to the merge queue Mar 2, 2025
Merged via the queue into main with commit df66f34 Mar 2, 2025
13 checks passed
@Dirbaio Dirbaio deleted the netsim branch March 2, 2025 22:14
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