Hi Lawrence,
Thank you for your reply. Can I show you two packet captures from Wireshark please? The first is the known problem: the window size reaches 0 at packet 251 and the server then pauses for 5 seconds. This what we would expect with the known w5300 problem.
No. Time Source Destination Protocol Length Info
188 *REF* 192.168.1.66 192.168.1.64 FTP 60 Request: PASV
189 0.000808000 192.168.1.64 192.168.1.66 FTP 104 Response: 227 Entering Passive Mode (192,168,1,64,239,171)
190 0.000891000 192.168.1.66 192.168.1.64 TCP 60 22→21 [ACK] Seq=44 Ack=246 Win=8138 Len=0
193 0.006190000 192.168.1.66 192.168.1.64 TCP 60 16962→61355 [SYN] Seq=0 Win=8190 Len=0 MSS=1460
194 0.006428000 192.168.1.64 192.168.1.66 TCP 58 61355→16962 [SYN, ACK] Seq=0 Ack=1 Win=8192 Len=0 MSS=1460
195 0.006492000 192.168.1.66 192.168.1.64 TCP 60 16962→61355 [ACK] Seq=1 Ack=1 Win=8190 Len=0
196 0.007544000 192.168.1.66 192.168.1.64 FTP 65 Request: RETR TEST
197 0.009260000 192.168.1.64 192.168.1.66 FTP 121 Response: 150 Opening data channel for file download from server of "/TEST"
198 0.009369000 192.168.1.66 192.168.1.64 TCP 60 22→21 [ACK] Seq=55 Ack=313 Win=8120 Len=0
199 0.010023000 192.168.1.64 192.168.1.66 FTP-DATA 2974 FTP Data: 2920 bytes
200 0.010332000 192.168.1.66 192.168.1.64 TCP 60 16962→61355 [ACK] Seq=1 Ack=1461 Win=6728 Len=0
201 0.010365000 192.168.1.64 192.168.1.66 FTP-DATA 2974 FTP Data: 2920 bytes
202 0.010487000 192.168.1.66 192.168.1.64 TCP 60 16962→61355 [ACK] Seq=1 Ack=2921 Win=5266 Len=0
203 0.010523000 192.168.1.64 192.168.1.66 FTP-DATA 1514 FTP Data: 1460 bytes
204 0.010698000 192.168.1.66 192.168.1.64 TCP 60 16962→61355 [ACK] Seq=1 Ack=4381 Win=3804 Len=0
205 0.010893000 192.168.1.66 192.168.1.64 TCP 60 16962→61355 [ACK] Seq=1 Ack=5841 Win=2342 Len=0
206 0.011005000 192.168.1.64 192.168.1.66 FTP 92 Response: 226 Successfully transferred "/TEST"
207 0.011038000 192.168.1.66 192.168.1.64 TCP 60 16962→61355 [ACK] Seq=1 Ack=7301 Win=880 Len=0
208 0.011100000 192.168.1.66 192.168.1.64 TCP 60 22→21 [ACK] Seq=55 Ack=351 Win=8150 Len=0
251 5.005901000 192.168.1.64 192.168.1.66 FTP-DATA 934 [TCP Window Full] FTP Data: 880 bytes
252 5.006148000 192.168.1.66 192.168.1.64 TCP 60 16962→61355 [ACK] Seq=1 Ack=8181 Win=7308 Len=0
253 5.006215000 192.168.1.64 192.168.1.66 FTP-DATA 7354 FTP Data: 7300 bytes
254 5.006559000 192.168.1.66 192.168.1.64 TCP 60 16962→61355 [ACK] Seq=1 Ack=9641 Win=5846 Len=0
255 5.006764000 192.168.1.66 192.168.1.64 TCP 60 16962→61355 [ACK] Seq=1 Ack=11101 Win=4384 Len=0
256 5.006973000 192.168.1.66 192.168.1.64 TCP 60 16962→61355 [ACK] Seq=1 Ack=12561 Win=2922 Len=0
257 5.006975000 192.168.1.66 192.168.1.64 TCP 60 16962→61355 [ACK] Seq=1 Ack=14021 Win=1460 Len=0
258 5.007174000 192.168.1.66 192.168.1.64 TCP 60 [TCP ZeroWindow] 16962→61355 [ACK] Seq=1 Ack=15481 Win=0 Len=0
259 5.305846000 192.168.1.64 192.168.1.66 FTP-DATA 55 [TCP ZeroWindowProbe] FTP Data: 1 bytes
260 5.305910000 192.168.1.66 192.168.1.64 TCP 60 [TCP ACKed unseen segment] 16962→61355 [ACK] Seq=1 Ack=15482 Win=8186 Len=0
261 5.305929000 192.168.1.64 192.168.1.66 FTP-DATA 1698 [TCP Previous segment not captured] FTP Data: 1644 bytes
262 5.306239000 192.168.1.66 192.168.1.64 TCP 60 [TCP ACKed unseen segment] 16962→61355 [ACK] Seq=1 Ack=16942 Win=6724 Len=0
263 5.306441000 192.168.1.66 192.168.1.64 TCP 60 16962→61355 [ACK] Seq=1 Ack=17127 Win=6538 Len=0
The second capture is with a zero-length send at packet 73, sent when the receiver has no packets to read, and which Wireshark helpfully decodes as “TCP window update”! (And again at 82). This fixes the problem: there is no server pause.
No. Time Source Destination Protocol Length Info
50 *REF* 192.168.1.66 192.168.1.64 FTP 60 Request: PASV
51 0.000848000 192.168.1.64 192.168.1.66 FTP 104 Response: 227 Entering Passive Mode (192,168,1,64,198,254)
52 0.000931000 192.168.1.66 192.168.1.64 TCP 60 22→21 [ACK] Seq=44 Ack=246 Win=8138 Len=0
55 0.011771000 192.168.1.66 192.168.1.64 TCP 60 16962→50942 [SYN] Seq=0 Win=8190 Len=0 MSS=1460
56 0.011891000 192.168.1.64 192.168.1.66 TCP 58 50942→16962 [SYN, ACK] Seq=0 Ack=1 Win=8192 Len=0 MSS=1460
57 0.011969000 192.168.1.66 192.168.1.64 TCP 60 16962→50942 [ACK] Seq=1 Ack=1 Win=8190 Len=0
58 0.013054000 192.168.1.66 192.168.1.64 FTP 65 Request: RETR TEST
59 0.013650000 192.168.1.64 192.168.1.66 FTP 121 Response: 150 Opening data channel for file download from server of "/TEST"
60 0.013717000 192.168.1.66 192.168.1.64 TCP 60 22→21 [ACK] Seq=55 Ack=313 Win=8120 Len=0
61 0.013967000 192.168.1.64 192.168.1.66 FTP-DATA 2974 FTP Data: 2920 bytes
62 0.014271000 192.168.1.66 192.168.1.64 TCP 60 16962→50942 [ACK] Seq=1 Ack=1461 Win=6728 Len=0
63 0.014304000 192.168.1.64 192.168.1.66 FTP-DATA 2974 FTP Data: 2920 bytes
64 0.014436000 192.168.1.64 192.168.1.66 FTP 92 Response: 226 Successfully transferred "/TEST"
65 0.014467000 192.168.1.66 192.168.1.64 TCP 60 16962→50942 [ACK] Seq=1 Ack=2921 Win=5266 Len=0
66 0.014479000 192.168.1.64 192.168.1.66 FTP-DATA 1514 FTP Data: 1460 bytes
67 0.014674000 192.168.1.66 192.168.1.64 TCP 60 16962→50942 [ACK] Seq=1 Ack=4381 Win=3804 Len=0
68 0.014884000 192.168.1.66 192.168.1.64 TCP 60 16962→50942 [ACK] Seq=1 Ack=5841 Win=2342 Len=0
69 0.014885000 192.168.1.66 192.168.1.64 TCP 60 22→21 [ACK] Seq=55 Ack=351 Win=8150 Len=0
70 0.014886000 192.168.1.66 192.168.1.64 TCP 60 16962→50942 [ACK] Seq=1 Ack=7301 Win=880 Len=0
73 0.295139000 192.168.1.66 192.168.1.64 TCP 60 [TCP Window Update] 16962→50942 [PSH, ACK] Seq=1 Ack=7301 Win=8190 Len=0
74 0.295176000 192.168.1.64 192.168.1.66 FTP-DATA 7354 FTP Data: 7300 bytes
75 0.295500000 192.168.1.66 192.168.1.64 TCP 60 16962→50942 [ACK] Seq=1 Ack=8761 Win=6728 Len=0
76 0.295699000 192.168.1.66 192.168.1.64 TCP 60 16962→50942 [ACK] Seq=1 Ack=10221 Win=5266 Len=0
77 0.295910000 192.168.1.66 192.168.1.64 TCP 60 16962→50942 [ACK] Seq=1 Ack=11681 Win=3804 Len=0
78 0.295911000 192.168.1.66 192.168.1.64 TCP 60 16962→50942 [ACK] Seq=1 Ack=13141 Win=2342 Len=0
79 0.296109000 192.168.1.66 192.168.1.64 TCP 60 16962→50942 [ACK] Seq=1 Ack=14601 Win=880 Len=0
82 0.519700000 192.168.1.66 192.168.1.64 TCP 60 [TCP Window Update] 16962→50942 [PSH, ACK] Seq=1 Ack=14601 Win=8190 Len=0
83 0.519755000 192.168.1.64 192.168.1.66 FTP-DATA 2579 FTP Data: 2525 bytes
84 0.520099000 192.168.1.66 192.168.1.64 TCP 60 16962→50942 [ACK] Seq=1 Ack=16061 Win=6728 Len=0
85 0.520288000 192.168.1.66 192.168.1.64 TCP 60 16962→50942 [ACK] Seq=1 Ack=17127 Win=5660 Len=0
(Please note there are two sockets active here: the data and the control. So ignore anything between ports 20 and 21 - these are the control socket packets),
So a zero length send fixes the problem in this situation. Looking at WIZnet’s socket.c, it looks like that was WIZnet’s first fix too, but then it was changed to a fix involving Keep Alives, and then changed again to actually sending one byte.
So my question is: what were the circumstances where WIZnet’s original zero-length-send fix did not work? It would be useful to know the details so that I know when my own zero-length send fix might not work.