How do online multiplayer games which use UDP get the packets delivered between networks over the internet? From what I understand, clients would have to enable port forwarding on their routers in order for the packets to arrive at their computer. Is this what big online games (WoW, Diablo, etc) require players to do?
For example, I recently created a server that handles udp traffic. It just echos back whatever a sender has sent. I deployed this to a server on the internet. I can only get the echos back to the sender after enabling port forwarding, but this will not work if there are two senders on the same local network.
Short answer: NAT Connection tracking
One thing to remember is that the vast majority of Routers on the IPv4 internet is NAT Routers.
Most NAT implementations does smart tracking, When you send UDP from a internal client to somewhere you will have a Destination Port and a Source Port. If traffic comes in with the ports reversed, then that traffic will be routed back to your client, and allowed in most firewalls.
NAT/Firewalls with tracking detects these packets as related and forwards them back.
Example based on comments with
server
on port5000
UDPserver:5000
, sourceclient:5001
client:5001
, and destinationserver:5000
.NATip:NATport
NATip:NATport
that has the source ofserver:5000
server:5000
destinationNATip:NATport
, which matches the packet that was sent out (but has source and destination reversed)client:5001
still with sourceserver:5000
The source ip+port and destination ip+port creates a combination that can be tracked. (there is more details, but this is the basics)
Some more reading But I should dig up better documentation on this and not just refer to anecdotal evidence from what I have seen experienced.