Search code examples
httptcp

HTTP Client not initiate TCP FIN/ACK when Server sends PSH,FIN,ACK


I am implementing my own TCP protocol stack and an extremely simple HTTP server on UBoot, and I run into problem that client does not send FIN/ACK after I send FIN/ACK/PSH. Both HTTP and TCP content seems to be right regarding TCP sequence and Ack, and content length, but client only respond with FIN in its first attempt on any URL. Any subsequent attempt on the visited URL does not respond with FIN. Can someone tell me what I am missing in my TCP or HTTP content, that cause the client to not close the connection?

I provided a capture in case anyone is interested in this problem Link to packet capture

The expected result should be client display the content of the HTTP 404 Not found. However, all I see if browser keeps loading non-stop until the client send a TCP RST, and the browser display Page cannot be found.


Solution

  • In the streams which issues (like tcp.stream eq 1 in the pcap) the 404 from the server does not get acknowledged by the client, which likely means that it is dropped somewhere. In the stream without issues (tcp.stream eq 0) the 404 gets acknowledged. Looking closer at both 404 reveals that the good one has a valid TCP checksum while the dropped one does not. Thus, most likely your TCP checksum calculation is wrong and the client system is dropping these wrong packets so that they never reach the client application.