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

Support TCP simultaneous open #1001

Merged
merged 1 commit into from
Oct 20, 2024
Merged

Support TCP simultaneous open #1001

merged 1 commit into from
Oct 20, 2024

Conversation

lrh2000
Copy link
Contributor

@lrh2000 lrh2000 commented Oct 19, 2024

RFC 9293 states:

A TCP implementation MUST support simultaneous open attempts (MUST-10).

It also details the related state machine (Figure 7: Simultaneous Connection Synchronization):

TCP Peer A                                       TCP Peer B

1.  CLOSED                                           CLOSED

2.  SYN-SENT     --> <SEQ=100><CTL=SYN>              ...

3.  SYN-RECEIVED <-- <SEQ=300><CTL=SYN>              <-- SYN-SENT

4.               ... <SEQ=100><CTL=SYN>              --> SYN-RECEIVED

5.  SYN-RECEIVED --> <SEQ=100><ACK=301><CTL=SYN,ACK> ...

6.  ESTABLISHED  <-- <SEQ=300><ACK=101><CTL=SYN,ACK> <-- SYN-RECEIVED

7.               ... <SEQ=100><ACK=301><CTL=SYN,ACK> --> ESTABLISHED

In short:

  1. If a TCP socket is in SYN-SENT state and receives a SYN packet (not a SYN|ACK packet), it should change its state to SYN-RECEIVED. This is not previously implemented, and such packets are silently dropped. This PR implements the above behavior.
  2. If it then receives an ACK packet acknowledging the SYN packet, it should change its state to ESTABLISHED. This is already implemented.

@whitequark
Copy link
Contributor

I remember reading about simultaneous open in the original TCP RFC and thinking that it's a pretty silly thing that I've never seen used.

@lrh2000
Copy link
Contributor Author

lrh2000 commented Oct 20, 2024

I remember reading about simultaneous open in the original TCP RFC and thinking that it's a pretty silly thing that I've never seen used.

Yeah, agree. It could be useful for TCP hole-punching, but it is still a very limited scenario. However, per the RFC, this is required to be supported...

By the way, thanks for your review!

@whitequark whitequark added this pull request to the merge queue Oct 20, 2024
Merged via the queue into smoltcp-rs:main with commit 032094e Oct 20, 2024
13 checks passed
@lrh2000 lrh2000 deleted the sim-open branch November 8, 2024 02:56
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