Reputation: 283
I have a project that transmits a stream of small data packets, <32 bytes, every 10-12 ms. When I send the data from the client on the computer to the host on the same computer using the IP address, not localhost mind you, I get no problems and the response is fast. However, when I connect to any source outside the machine I get the data only 3 times a second. This is weird as I have 100MB/s transfer when transporting files and the network works. I tried using a direct connection using both an USB connection and an Ethernet connection. I tried WiFi as well. They all gave me updates only 3 times per second. I isolated the network in each case.
I also tried different programs, one written in C++ and the other in python, to see if my implementation was wrong, but nothing changed. Since it works when I connect locally I cant see how the programming and network code is to blame.
I tried updating drivers, but that did not fix it. I tried building a new desktop with exactly the same components and software. It works on that PC.
I am honestly at a loss as I can not find a single pattern or explanation, not to mention a solution, for this annoying problem.
What can cause such a behaviour? It cant be the buffer as it works locally? I tried changing it and making the client send data only 10 times per sec. It shouldn't be packet loss as I am using TCP on a local network without wireless. Two PCs and one Ethernet cord.
Everything else works fine and snappy with web pages loading fast and YouTube videos loading fast. Downloads and uploads are also fast.
This problem is driving me insane. Please save my sanity.
Thank you in advance for your help.
Upvotes: 2
Views: 464
Reputation: 171206
You have nagling turned on. This is the default. It batches up data and sends it out every 200ms. So it really is 5 Hz, not 3 Hz as you estimated.
Disable nagling. Be careful because now each and every end will result in a network packet.
Upvotes: 1