Python sockets: TCP errors in linux, while same program works fine on Windows10

Solution 1:

I figured the problem was related to tcp timestamps. In linux, by default tcp_timestamp is enabled, in windows it's disabled.

Disabling tcp timestamps on linux, solves the problem:

sysctl -w net.ipv4.tcp_timestamps=0

Conversely, enabling timestamps on windows reproduces the same problem I observed on linux.

netsh int tcp set global timestamps=enabled

Digging a bit further, I saw that the tcp errors such as Dup Ack started occurring when device sends a packet, with a timestamp lower then of the previous packet. Probably there is a bug in the hardware/firmware of device and it creates faulty timestamps.