I am trying to debug issue with an application that intermittently has problems. The applications communicates with one another via web sockets.
The client normally sends control code 000000174.A.EXAMP to the server end.
I can see both the client and server both have the same control code when performing an strace. Here is the strace snippet which shows the correct code being sent correctly.
3651 23:13:51 sendto(117, "0", 1, 0, NULL, 0) = 1
3651 23:13:51 sendto(117, "0", 1, 0, NULL, 0) = 1
3651 23:13:51 sendto(117, "0", 1, 0, NULL, 0) = 1
3651 23:13:51 sendto(117, "0", 1, 0, NULL, 0) = 1
3651 23:13:51 sendto(117, "0", 1, 0, NULL, 0) = 1
3651 23:13:51 sendto(117, "0", 1, 0, NULL, 0) = 1
3651 23:13:51 sendto(117, "1", 1, 0, NULL, 0) = 1
3651 23:13:51 sendto(117, "7", 1, 0, NULL, 0) = 1
3651 23:13:51 sendto(117, "4", 1, 0, NULL, 0) = 1
Here's the code on the server end
00:16:36 recvfrom(11, "00000017", 8, 0, NULL, NULL) = 8
When the problem occurs, the server receives the code 00000174.A.EXAMP which is one zero short. At the moment, there is only a script on the server that logs the strace output to file and it creates three 5-minute logs and rotates logs keeping a maximum of three logs. Script stops on error detection on the server (when server has made no requests for some duration).
My question is with the packet trace I am getting from tcpdump. Nearly all the packets captured has the data as 00000174.A.EXAMP which is one zero short.
Why is this different from the strace output which has six zeroes and the packet capture shows mostly five zeroes?
Out of the several thousands of packets exchanged, several packets have missing characters when performing string search. Here's the different contents in the data packets captured through ```tcpdump``
00000174.A
00000174.A.
00000174.A.E
00000174.A.EX
00000174.A.EXA
00000174.A.EXAM
00000174.A.EXAMP (Most are coming out as with one zero missing)
0000174.A.EXAMP
000174.A.EXAMP
00174.EXAMP
IP packets are 1500 bytes in size so I wouldn't expect the packet to be split in into multiple packets since the control data is very small. Why are data packets missing characters?
The java code that sends data is d3sOut.writeBytes(slen + outBuffer). At the other end is a C web socket.
Because the client seems to use one
sendto()call for each byte of000000174.A.EXAMP, it is typical that 1st byte will be transferred in own IP packet. And rest of the bytes will be transferred after that.It is result of "Nagle's algorithm" of TCP:
When the 1st sendto() call is done, TCP can send the 1st byte immediately, because there is not unacknowledged data in the fly.
When rest of sendto() calls are called, there is unacknowledged data in fly (the 1st byte), so the TCP stack will enqueue data in the buffer for while, before sending several buffered bytes by using a single IP packet.
Please, Double check that you didn't miss/ignore the IP packet with the 1st byte.
For avoiding ineffective small IP packets, try to use one
sendto()call instead ofsendto()per a byte.