Fastest way to send packets between two connected computers?

java, linux, udp, windows

Solution

Well, there's not much between TCP/UDP if you ignore the connect/disconnect latency. If your protocol can keep a TCP conection up and disable inappropriate, latency-inducing optimizations like the Nagle algorithm, I don't see why TCP should be struck off as a solution, though there is the slight complication of requiring a protocol on-top to exchange any message larger than one byte.

Most network rate and latency performance are usually limited by phy and route constraints anyway. Looking at one packet between two peers, it doesn't matter too much what IP protocol you use since the dodgy routers, c-limited satellite links, congested fibers, noisy and retransmit-ridden microwave/wifi/3G links, and rubbish last-mile copper will stuff you up anyway.

Problem

(I did search prior to asking, but I could only find fastest Java IPC techniques) What is the fastest way in Java to send a packet between two computers in Java (connected by one ethernet cable), on Windows and Linux (if the answer varies per OS)? I have guessed UDP would be faster than TCP (due to TCP's three-way handshake scheme), but are there any other considerations which need to be made? Are we limited to sockets (Unix-specifc answer?) or are there alternatives? What technologies can be used to send/receive the UDP as fast as possible? Likewise, are there particular high-performing ways to receive and read the data sent from another computer?

Original source