What does Sn_SR "SOCK_CLOSING" value (0x1A) mean?
Ethernet Chips
No replies yet. Be the first to reply.
Join the discussion.
Ethernet Chips
No replies yet. Be the first to reply.
Join the discussion.
Share projects and connect with makers.
Joined before the site update? first.
New to WIZnet Makers?
We sent a verification link to your address. Open it to activate your account, then log in.
Accounts from this email provider are reviewed by an administrator after verification. Approval usually takes one business day.
Already have an account?
Enter your email address. If it belongs to an account, we'll send a link to set a new password. Members who joined before the site update use this to set their password.
If an account uses that address, we sent a link to set a new password. The link works once and expires in 30 minutes.
Know your password?
Need an account?
RE: What does Sn_SR "SOCK_CLOSING" value (0x1A) mean?
by oliver28 ·
This status can occur after the close command 0x10 until the socket gets its final state 0x00 closed. (last step in your process)
In every case you should repeat the status request if you receive one of the temporary statuscodes until you receive a clear final state.
If you do new commands before (e.g. disconnect and close without waiting to the end of the disconnect process) it may work but checking the connection with whireshark will show that there are problems.
RE: RE: What does Sn_SR "SOCK_CLOSING" value (0x1A) mean?
by Eugeny ·
I do not think so. 0x1A happens after DISCON command. CLOSE will immediately reset the socket and change its status to 0x00.
RE: What does Sn_SR "SOCK_CLOSING" value (0x1A) mean?
by Mxyxixptlick ·
For the benefit of future readers, I would expect the following sequence of values in a W5x00 Sn_SR after sending a DISCON command to a socket that is in the CLOSE_WAIT state (i.e., that has been half-closed by the remote peer):
If the W5x00 is disconnecting an ESTABLISHED socket, on the other hand, I would expect this sequence of Sn_SR values:
I don’t include the “CLOSING” status in this sequence because I’m not sure where it goes. But I have a suspicion.
Most sources refer to FIN-WAIT-1 and FIN-WAIT-2 to distinguish between the time spent waiting for an ACK to the initial FIN and the time spent waiting for the (possibly later) arrival of a FIN from the other side. This looks like:
But the W5x00 doesn’t identify FIN_WAIT_1 & FIN_WAIT_2 states, only FIN_WAIT. This leads me to suspect that the “CLOSING” state is really FIN_WAIT_2, which would mean our Sn_SR would go through this sequence of values when a socket is disconnected:
I was hoping someone from Wiznet could confirm this so I didn’t have to do the experiment to find out if I’m right.
RE: RE: What does Sn_SR "SOCK_CLOSING" value (0x1A) mean?
by Eugeny ·
Practically, while answer to the question would be interesting, not sure how it is useful. Application running on W5x00 in TCP mode socket should certainly care about three major states: 0x17 (ESTABLISHED), range of 0x18-0x1D and 0x00 (CLOSED) after establishing connection:
All intermediate states of 0x18-0x1D are just “for your information” on what is going on, and for troubleshooting purposes.
DISCON and CLOSE pair may be treated differently given the connection type: for server mode it is wise to perform DISCON and then immediately CLOSE, for client programmer may choose to wait after issuing DISCON to ensure server has confirmed closure of the connection and freed its sockets.
If, for some reason, process will get out of order (e.g. application re-sends FIN when it was already sent before), then the worst case it will get RST back. The main point of the connection termination is to ensure no network device is having socket hung, and thus resources consumed for more time than really needed.
RE: What does Sn_SR "SOCK_CLOSING" value (0x1A) mean?
by Mxyxixptlick ·
All valid comments. I’m improving an existing Arduino library for W5x00 chips that does some things with sockets that I don’t think it should. As I fix these things, I want to make sure I completely understand what I’m doing. I sleep better when I understand everything (including what the CLOSING state means).
RE: What does Sn_SR "SOCK_CLOSING" value (0x1A) mean?
by Mxyxixptlick ·
I ran tests today and saw the following:
When the peer sends a FIN first, I see Sn_SR change to 0x1D (SOCK_LAST_ACK) before changing to 0x00 (SOCK_CLOSE). I see no intermediate values, though this could be a sampling rate problem.
When the W5x00 sends a FIN first, I see Sn_SR change to 0x18 (SOCK_FIN_WAIT) before changing to 0x1B (SOCK_TIME_WAIT) then 0x00 (SOCK_CLOSE). Sn_IR changes to 0x02 (DISCON) at about the same time. Despite running these tests many times, I never managed to capture Sn_SR with a value of 0x1A. Maybe if I run it from outside my LAN the delay will be long enough to capture it.
RE: What does Sn_SR "SOCK_CLOSING" value (0x1A) mean?
by bscarlet ·
These TCP-relevant states of Sn_SR look to be closely related to the general description of how TCP works, for which Wikipedia and Google are useful. The correspondence isn’t quite perfect - e.g. FIN_WAIT_1 and FIN_WAIT_2 aren’t distinguished.
According to the TCP state machine transition diagram at
[Transmission Control Protocol - Wikipedia]
the CLOSING state indicates you’ve sent your FIN and then received a FIN from the other side before your FIN is ACKed. To get into such a state both sides would have to try to active-close at the same time (modulo network delay), and most of the time one would proceed quite quickly into CLOSE_WAIT - because you’d receive the ACK of your FIN soon after. So it seems reasonable you haven’t been able to see it happen.
You might be able to see it by talking through a firewall configured to drop the w5x00’s outgoing FINs.
RE: What does Sn_SR "SOCK_CLOSING" value (0x1A) mean?
by Mxyxixptlick ·
Great information. Thanks!