-
Notifications
You must be signed in to change notification settings - Fork 1.4k
net/tcp: add support for the CLOSE_WAIT state #17678
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
Conversation
acassis
left a comment
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.
@zhhyu7 nice work, please update the Documentation to reflect this support:
https://nuttx.apache.org/docs/latest/components/net/index.html
Hi @acassis , Currently, there is no existing documentation explaining the overall TCP process. Given the extensive content of TCP, it is not easy to compile a detailed documentation. Would it be better to submit a separate PR to supplement the explanation of TCP? |
@zhhyu7 you are completely right, the "best" Documentation we have is maybe this one that Greg wrote: https://nuttx.apache.org/docs/latest/components/net/delay_act_and_tcp_perf.html But I suggest you to just use it as starting point and write a small and basic Documentation, then over the time we will evolve it. It is better than no documentation at all. |
@acassis I've added a basic description document on how NuttX implements TCP state transitions. Please review it again. Thank you a lot. |
|
@zhhyu7 please fix: |
CLOSE-WAIT - represents waiting for a connection termination request
from the local user.
TCP A TCP B
1. ESTABLISHED ESTABLISHED
2. (Close)
FIN-WAIT-1 --> <SEQ=100><ACK=300><CTL=FIN,ACK> --> CLOSE-WAIT
3. FIN-WAIT-2 <-- <SEQ=300><ACK=101><CTL=ACK> <-- CLOSE-WAIT
4. (Close)
TIME-WAIT <-- <SEQ=300><ACK=101><CTL=FIN,ACK> <-- LAST-ACK
5. TIME-WAIT --> <SEQ=101><ACK=301><CTL=ACK> --> CLOSED
6. (2 MSL)
CLOSED
in the current state, we can continue to send data until the user
calls shutdown or close, then directly enter the TCP_LAST_ACK state
Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
acassis
left a comment
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.
@zhhyu7 amazing!!! Kudos
Done. |
Summary
CLOSE-WAIT - represents waiting for a connection termination request
from the local user.
TCP A TCP B
FIN-WAIT-1 --> <SEQ=100><ACK=300><CTL=FIN,ACK> --> CLOSE-WAIT
CLOSED
in the current state, we can continue to send data until the user calls shutdown or close, then directly enter the TCP_LAST_ACK state
Impact
TCP supports half-open state
Testing
sim:matter with test code
Linux TCP test code:
NuttX TCP test code:
test log, interaction process of packet capture: