Skip to content

net: tcp: Use correct seqnum for tcp_out and tcp_out_ext #90636

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

Merged
merged 1 commit into from
May 29, 2025

Conversation

shrek-wang
Copy link
Contributor

Based on TCP Spec., the outgoing TCP packets shoud use SND.NXT as the seqnum. In Zephyr, the conn->seq works as the SND.UNA and the conn->seq + conn->unacked_len works as the SND.NXT. Currently, it uses SND.UNA in tcp_out() as the seqnum, which might get dropped as old packets and could not deliver the message to the peer. A few exceptions use SND.NXT - 1 as the seqnum are: keepalive, zero-window-probe, FIN/SYN retransmissions.
And, for closing a connection, Zephyr won't send out FIN until all the data has been ACKed, so the conn->unacked_len is 0 and it is ok to use conn->seq as the SND.NXT.

Based on TCP Spec., the outgoing TCP packets shoud use SND.NXT as
the seqnum. In Zephyr, the conn->seq works as the SND.UNA and the
conn->seq + conn->unacked_len works as the SND.NXT. Currently, it
uses SND.UNA in tcp_out() as the seqnum, which might get dropped
as old packets and could not deliver the message to the peer.
A few exceptions use SND.NXT - 1 as the seqnum are: keepalive,
zero-window-probe, FIN/SYN retransmissions. And, for closing a
connection, Zephyr won't send out FIN until all the data has been
ACKed, so the conn->unacked_len is 0 and it is ok to use conn->seq
as the SND.NXT.

Signed-off-by: Shrek Wang <[email protected]>
Copy link

Copy link
Collaborator

@rlubos rlubos left a comment

Choose a reason for hiding this comment

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

Looks fine, thanks

@kartben kartben merged commit 744380a into zephyrproject-rtos:main May 29, 2025
28 checks passed
@shrek-wang shrek-wang deleted the tcp_polish branch May 29, 2025 08:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants