NAT UDP port switching? [closed]

I’ve read about the Quake 3 networking code that they had to deal with a situation where some older NATs would randomly switch client ports.

How common is this issue these days? Is it worth handling when implementing a game network protocol?

In other words, would a UDP network protocol implementing virtual connection need to handle the case where the NAT suddenly changes the client’s port?

Answer

You should not rely on source ports being stable between connections from the same host, and if you are using UDP (generally recommended for gaming applications as maintaining low latency trumps needing reliable delivery) which is connectionless you should not expect them to be stable between individual packets.

NAT by its nature usually needs to play with source port information so this compounds the situation, and while single-level NAT can be relatively clever and try to keep source ports for packets from a given host to another stable as soon as you have more than one layer (not uncommon in mobile networks and some free wireless access points) that goes out of the window.

Attribution
Source : Link , Question Author : Nuoji , Answer Author : David Spillett

Leave a Comment