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: don't send data outside the remote window #387

Merged
merged 2 commits into from
Dec 19, 2020

Conversation

Dirbaio
Copy link
Member

@Dirbaio Dirbaio commented Dec 18, 2020

If we receive a packet with ack_seq=1000, win_len=10, this means the remote end is granting us permission to send bytes up to seq=1010 but no more.

The current implementation limits segment length to win, but does not limit the byte count. In the example above, it'll send many small packets: 1000-1010, 1010-1020 ... until the entire tx_buffer is sent.

This fixes the window handling so that only 1000-1010 is sent, and the rest isn't sent until the remote end sends a window update opening more space.

  • Updated 1 test that tested for the previous behavior: test_established_send_buf_gt_win
  • Updated a few tests that used the window to force sending small packets: they now use MSS.

Copy link
Contributor

@whitequark whitequark left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At a glance the change seems reasonable, but I haven't thought about it in-depth, so I primarily trust that you have tested it well.

@whitequark
Copy link
Contributor

Thanks!

@whitequark whitequark merged commit 2080152 into smoltcp-rs:master Dec 19, 2020
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