-
Notifications
You must be signed in to change notification settings - Fork 6.6k
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
net: tcp: Implement TCP new Reno collision avoidance #60112
net: tcp: Implement TCP new Reno collision avoidance #60112
Conversation
A initial attempt to implement collision avoidance for TCP. I'm thinking to put the collision avoidance in a separate file, I think the Linux way using tcp_congestion_ops and registering collision avoidance algorithms is a little overkill, but I can imagine that multiple choices will be available in the future that can be selected through a configure option. Feel free to comment or take this as a starting point for further development. I'll be limited available the coming weeks, but feedback is very welcome. |
Attempts to implement: #46352 |
6b81b8d
to
647302c
Compare
3cd17ea
to
0dc74b0
Compare
0dc74b0
to
14f9fd6
Compare
Other congestion avoidance algorithms like the Linux default CUBIC will perform better on long fat pipes. As the Zephyr TCP stack supports only 64K transmit window, the difference is likely neglectable even for long latencies. |
Please have a look at the form factor. Currently I've put it all in tcp.c if we would put it in a seperate file it would be possible to switch between different algorithms compile time. The specific CA algorithm will just fill in the functions. I see I need some small changes to properly implement the rfc3782 |
bb85c11
to
5873c12
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like a very useful addition - thx! Unfortunately don't know enough for a full review. Just one minor suggestion.
subsys/net/ip/Kconfig
Outdated
@@ -456,6 +456,14 @@ config NET_TCP_FAST_RETRANSMIT | |||
In that case a retransmission is triggerd to avoid having to wait for | |||
the retransmit timer to elapse. | |||
|
|||
config NET_TCP_CONGESTION_AVOIDANCE | |||
bool "Implement a collision avoidance algorithm in TCP" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is collision avoidance
also a commonly used term in this regard? I didn't find too many references to be honest. Maybe we should stick to congestion avoidance
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was this fixed? I see the prompt still says Implement a collision avoidance algorithm
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops, fix attempt 2
subsys/net/ip/tcp.c
Outdated
|
||
if (conn->ca.state == TCP_NEW_RENO_RAMPUP) { | ||
new_win += conn_mss(conn); | ||
conn->ca.congestion_win += conn_mss(conn); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems unneeded? conn->ca.congestion_win
is overwritten just below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code has fully been reworked here
During testing I bumped into a corner case, which gave me random failing unit tests. A PR for this issue is submitted at: |
5873c12
to
4cb1c54
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM now wrt my superficial remark above, still no full review, though, as I don't understand enough of what's going on there conceptually.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, just some nits. Did you have a chance to run any performance test (like zperf
) to see what is the impact on the actual throughput? I guess it should be negligible but it would be good to see if that's really the case.
subsys/net/ip/Kconfig
Outdated
@@ -456,6 +456,14 @@ config NET_TCP_FAST_RETRANSMIT | |||
In that case a retransmission is triggerd to avoid having to wait for | |||
the retransmit timer to elapse. | |||
|
|||
config NET_TCP_CONGESTION_AVOIDANCE | |||
bool "Implement a collision avoidance algorithm in TCP" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was this fixed? I see the prompt still says Implement a collision avoidance algorithm
4cb1c54
to
0104b36
Compare
With respect to throughput, the only thing I can see is that the unit test does not get significantly slower. I do not have HW which I can run a zperf on saidly, so cannot test that. |
To avoid a TCP connection from collapsing a link, implement a collision avoidance algorithm. Initially TCP new Reno is implemented for its simplicity. Signed-off-by: Sjors Hettinga <s.a.hettinga@gmail.com>
To allow insighed into the correct functioning of the collision avoidance, log the internal values and function calls. Signed-off-by: Sjors Hettinga <s.a.hettinga@gmail.com>
0104b36
to
4f85ff3
Compare
Performed a rebase to trigger a rebuild of the CI/CD |
@jukkar: Lines 2795 to 2797 in 488fd89
When the transmit window is full, which happens much more often with congestion avoidance, the resend timer is being triggered by new transmissions. This causes a lot of spurious retransmissions. |
A PR to remove this is already available: #60972 |
@ssharks FYI, I've checked with |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
To avoid a TCP connection from collapsing a link, implement a collision avoidance algorithm. Initially TCP new Reno is implemented for its simplicity.