W5300 SENDOK and Reserved Status Byte
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: W5300 SENDOK and Reserved Status Byte
by abes ·
I don’t know how often re-transmits occur, but the data flows very well most of the time.
The peer system is sending ACKs back. Are you saying that the ACK is not what the W5300 expects, so there is a failure to recognize the ACK?
I have attached a Wireshark capture file that shows IP addresses 192.168.1.52 and 192.168.1.55 continually retransmitting. The peer is 192.168.1.79, and it keeps sending the same ACK. This is the state when I am waiting for the SEND_OK bit to be set. This is two separate units that froze up in this state.
I already do check for the SEND_OK flag after every send command, and I also clear it every time it gets set.
For sending a lot of data, I have large TX buffers of 27kBytes for each socket, and I fill them up whenever data is available. There may be less than 1460 bytes, and there may be more than 1460 bytes. If the W5300 already breaks up large amount of data into MTU sized packets, how will it help for me to do that manually?
Even if this is rare, we will be sending large amounts of data in bursts, and this has happened many times. Every time I found it looks like the TCP sequence number is near rollover. If you can confirm that it has something to do with the TCP sequence number rolling over, maybe we can come up with a workaround.
capture with 52_1 and 55_3 frozen.zip (44.9 KB)
RE: W5300 SENDOK and Reserved Status Byte
by abes ·
Yes, I noticed that the ACK numbers didn’t match up. There were many occasions when ACKs were sent out of order, or for multiple packets, so I assumed that is normal. But I have only seen the glitch when the sequence number is near 0xFFFFFFFF.
Unfortunately, there is too much data to collect it all. Maybe I’ll find a way to have Wireshark filter or just save header information and then I can catch the packets right before the failure.
I’ve made the recommended change to only send 1460 bytes at a time, and I’ll see how it goes.
Thank you.
RE: W5300 SENDOK and Reserved Status Byte
by abes ·
I made the change to only send 1460 bytes at a time, and it did not fix the problem. I have 4 systems that ran overnight, and each one has 4 sockets open. So far, one of the sockets on one of the systems froze up. Again, the TCP sequence number is right near the 32-bit rollover:
W5300 transmitted sequence number: FFFFFC6F
peer ack number: 00000287
Also, I closed the peer program, and the frozen socket has status SSR of 1D, SOCK_LAST_ACK for many minutes. I have not changed the default values of RTR and RCR, so I would expect it to time out and close after some short time.
RE: W5300 SENDOK and Reserved Status Byte
by abes ·
I figured out how to capture just the sequence numbers near the rollover point with Wireshark, and I was able to capture one of the failure modes.
The attached file shows the problem starting around packet number 5870.
Event 5870: The PC sends an ACK with the ack sequence number in the middle of a packet.
Event 5871: The W5300 sends another packet of data.
Event 5872: The W5300 send a FIN flag.
After that, the PC sends a FIN and tries to reconnect, but the W5300 is still trying to do something and it gets messy.
The peer is a PC running Windows 7 and Labview. I don’t know how the buffers are configured, but I notice that sometimes the window size shrinks by more than the amount of data sent on a particular socket, so I think Labview or Windows is sharing some buffer space somehow, and the window size is not really available due to other traffic. We will need to see if we can allocate separate buffers for each port. Could this be the source of the problem? Should the W5300 be able to handle an ACK that only accepted part of a packet? Is that even acceptable for TCP?
I have not seen another occurrence where the PC ack sequence is only accepting part of a message, but it may be happening. I have only seen the freezing behavior associated with the time the sequence number is rolling over, so I’m guessing there is some correlation.
w5300_fin1.zip (903 KB)
RE: W5300 SENDOK and Reserved Status Byte
by abes ·
Regarding the 3-way handshake, I think it does that fine, but my Wireshark capture had a filter on it, so it didn’t show all of the packets. I don’t think it’s related to the selective ACK. When I capture everything without a filter, I see the correct 3-way handshake.
I believe I may have found an issue that would cause the “broken ack number”.
During the initial connection, the PC sends SYN with an option of window scaling = 2 (multiply by 4)
The W5300 SYN only sends Maximum Segment Size, it does not send window scaling option.
When the error occurred, the PC reported window size of 552, but it looks like the W5300 interpreted it as 552*4=2208, and sent a full packet of 1460 bytes.
The PC then only acknowledged 552 bytes because that’s all it had room for. At this point, the W5300 seems to not be able to handle the incorrect ACK number and everything falls apart.
According to someone who wrote this article: en.wikipedia.org/wiki/Transmiss … ow_scaling
“Both sides must send the option in their SYN segments to enable window scaling in either direction”
Since the W5300 did not send the window scaling option, I’m thinking it should ignore the window scale sent by the PC. Is it possible that the W5300 is using the scaling factor sent by the PC when it shouldn’t be?
I will try to see if I can modify the client to use a scale factor of 0, and see if that might resolve the issue.
Edit…I added an attachment of a second capture of a failure. You can see at event 69, the PC acks with window size of 2112, and then the W5300 sends 2 more packets of 1460 bytes each. Shortly after that, it all falls apart.
I also added a capture of the normal startup showing the 3-way handshake where the PC sends the window scaling option of 2, and the W5300 doesn’t send the window scaling option.
Also, I’m not ignoring your request to see the code, but it is written in Verilog and it not very easy to compare to a standard C program. So for now, I’m focusing on the strange behavior that has actually been captured.
Edit 2: I’m thinking that a math error on the W5300 is more likely than an error in the window scaling, because this has only happened right where the sequence number rolls from FFFFFFFF to 00000000.
capture normal SYN startup.zip (6.24 KB)
w5300_fin2_port7893_only.zip (15 KB)
RE: W5300 SENDOK and Reserved Status Byte
by abes ·
Thank you for the detailed information about the Sn_SSR MSB.
I already added code to try to disconnect when the Sn_SSR MSB came up with the 7th bit set, and that is why we see the FIN packet in the data captures, but I still don’t seem to get a clean disconnect. It seems to be in an unusual state, and unable to recover.
I understand that the W5300 doesn’t handle the un-expected ACK number. However, the problem starts when the W500 sends more data than the window size, so I think there is an error that has something to do with the window size and the sequence number rollover that causes the W5300 to send too much data. This only happens right at the rollover and only if the receive window is very small due to a buffer getting close to full, so my best guess is some math operation that doesn’t handle the 32-bit overflow properly.
It would be nice to see some more in depth research and information about this behavior if possible. In the meantime, I will try to find a workaround that ensures that there will always be buffer space so the window will never go down below 1460. I will probably have to throttle the data somehow, or ensure the PC/Labview program has high enough priority to read all the data without much buffering.
Thanks for all your feedback on this so far.
RE: W5300 SENDOK and Reserved Status Byte
by abes ·
For the sockets that are failing:
TMSR is set to 27kBytes per socket
RMSR is set to 2kBytes per socket; I think this is what you are seeing in the capture file where Win=2046, but these sockets don’t receive data, they just send data
Yes, I check TX_FSR before sending. But this only verifies that there is buffer space in the W5300 TX Buffer (27kBytes to start). It does not indicate the peer Window size. I think there is no way for me to know the peer window size. The W5300 uses it internally but doesn’t give me access to it.
Your statement that “the next 1460 data packet can’t be sent without ack packet of 1st data packet” is not consistent with the answer in this forum topic:
After the first transmission, I wait for the SENDOK flag to be set, then I clear it, then I check TX_FSR to verify that there is space in the TX buffer, and if there is space, then I send another packet. According to that post, when the ACK is received, the TX_FSR increases by the amount of data that was acknowledged by the peer, but I should not have to wait for an ACK after every packet. If I did that, I would wait for TX_FSR to show 27kBytes before I send each packet, and my data rate will go down. I’ve tried that.