How do you write a UDP port forwarder?
As UDP is a connectionless protocol, once the forwarder gets a packet and sends it to a target ip, and the target ip respo开发者_StackOverflownds with data, how can the forwarder know what ip to send the packet to?
If you are talking about a standard gateway, it knows where to send it because the packet has a destination IP address and port.
If you are talking about NAT, then the router must remember what it has recently sent out and accept corresponding incoming packets. The router maintains a session internally, which will stay alive for some configured period.
精彩评论