3 ms·
This is only an advantage of TCP over raw UDP per se. Of course, the idea is that you don't use raw UDP, but you build some session layer over it. The UDP serv
by kazinator 12y ago
This is only an advantage of TCP over raw UDP per se. Of course, the idea is that you don't use raw UDP, but you build some session layer over it. The UDP server won't reply to a spoofed client because the packet doesn't validate. For instance, the session could be encrypted (with proper integrity checks) and the spoofer doesn't have the session key.
In fact, UDP servers typically handle a large number of clients with a single socket. So each `recv` system call on the UDP socket pulls a message from a different client. The source IP and port number could be used to do the basic matching of the message to the client, but then subject to more checks.
This can end up being more robust than TCP. TCP can be subject to IP spoofing, and because it doesn't have the crypto, this spoofing can interfere with the session (a form of DDoS): e.g. inject bytes into the TCP stream, which then screw up the stream so that it has to be scrapped and reconnected. A UDP based protocol can robustly drop garbage, so that the session is not affected (except for the network and CPU usage of these spoofed packets).