   How does the UDP Server know the difference between two players behind a router?
  How does the UDP Server know the difference between six players behind a router? Sorry for these questions. I looked all over the forums and could not find a specific answer.Lets say I have a UDP Server at IP: 69.3.1.32 Port 8301Then at my friends house he has 6 computers setup behind his router, but he only has 1 IP which is 64.3.4.21 .... I run my client app on each of his 6 computers. These client apps each send 1 udp packet to the server at 69.3.1.32 Port 8301Will the UDP server app receive them like this.1 - incoming UDP packet from: 54.3.4.2:83012 - incoming UDP packet from: 54.3.4.2:83013 - incoming UDP packet from: 54.3.4.2:83014 - incoming UDP packet from: 54.3.4.2:83015 - incoming UDP packet from: 54.3.4.2:83016 - incoming UDP packet from: 54.3.4.2:8301Thus I won't know which UDP packet came from which computer, unless I include a username or unique ID in the UDP packet?  Please help. If this is a redundant question i'm very sorry!Luzarius   
  Im not positive on my answer but this may be right. I have a router and 4 computer hooked up to it. Each computer is assigned a different router ip address. 192.168.1.100,192.168.1.101,ect. So each computer is actually acting as its own ip.   ;  The router assigns a different port on the external interface for each IP/port combination sending TO the internal interface.So your server is at 69.3.1.32:8301 (this may be a router's external IP with port forwarding set up - DON'T USE A DMZ IF YOU DON'T HAVE TO)The router at your friends house:External (WAN) 134.163.1.45 (no port open till a client punches through).Internal (LAN) 192.168.0.1 (this is the gateway for his network).Your friend's PCs:192.168.0.10192.168.0.5192.168.0.3192.168.0.10 creates a socket, port 3432 (system assigned) UDPs to 69.3.1.32:8301.The IP address is not on the local network, so the router forwards it on - NOT NECESSARILY FROM THE SAME PORT - your server recieves from 134.163.1.45:1335 for example. The router holds that port (1335) open so replies can be accepted and forwarded to 192:168.0.10:3432.Now 192.168.0.5 connects, from it's system-generated port of say, 3352. Again, the router forwards the send and assigns another port (say 1336). The router's NAT table now looks like:192.168.0.10:3432 <-> 134.163.1.45:1335 192.168.0.5:3352 <-> 134.163.1.45:1336 (same IP, different port)So in short, you'll notice different port numbers from connecting clients.   ;Quote:So in short, you'll notice different port numbers from connecting clients.Do you know if these ports will ever change? I was thinking of using the IP & port to identify a user.  But it may look as though I have to place an ID in the UDP packet which I was trying to avoid. A unique id for each user.;  The port number will not change during the lifetime of the connection. Other than that, you can make no other real guarantees about the port numbers.   ;  From previous answers here, it sounds as though one client should keep the same IP/port combination during a session. Some (older) routers can be bad though and switch them.   ;  Yes - *generally* the port number won't change.You can basically rely on the port to stay the same - it only gets changed if the router is idle (no thru transmission) for so long that it assumes the connection should be dead - the NAT entry is removed, and as soon as a new outgoing packet hits the router a new NAT entry (and external port) is created.;Quote:Original post by _winterdyne_Yes - *generally* the port number won't change.You can basically rely on the port to stay the same - it only gets changed if the router is idle (no thru transmission) for so long that it assumes the connection should be dead - the NAT entry is removed, and as soon as a new outgoing packet hits the router a new NAT entry (and external port) is created.Aye, this is why keep alive packets should be sent to ensure that you don't idle timeout, although they are only needed during idle periods. As far as the game is concerned that would probably appear to be an entirely new customer, and as such it would react accordingly (either ignoring them, or sending back an error message).   ;Quote:Original post by luzariusWill the UDP server app receive them like this.1 - incoming UDP packet from: 54.3.4.2:83012 - incoming UDP packet from: 54.3.4.2:83013 - incoming UDP packet from: 54.3.4.2:83014 - incoming UDP packet from: 54.3.4.2:83015 - incoming UDP packet from: 54.3.4.2:83016 - incoming UDP packet from: 54.3.4.2:8301Thus I won't know which UDP packet came from which computer, unless I include a username or unique ID in the UDP packet?  Please help. If this is a redundant question i'm very sorry!LuzariusOkay, so from what I understand there are six computers and each send out a packet over UDP.  So shouldn't each packet receive a different demux?  Meaning, each computer should have its own discernable IP host address (unless it's some subnetting issue, which I have no idea about...).  So this problem should never happen.What I would be more concerned about is if a packet is received out of order.  I don't think UDP keeps sequence numbers, so if you receive a packet out of order you just have to deal with it.Someone please correct me if I'm wrong... :|   ;  The OP was asking about subnetting and NAT.  Nothing to do with packet order.   