Consider a small local area network. When each user checks the public ip-address (say using whatismyipaddress) all users are having the same public ip-address. However ipconfig shows a different private ip-address for each user. Say two users are accessing gmail. How does the gmail server identify both users when they have the same public ip-address. The data packets from both the users will have a target and source ip-address. For both users the source ip-address on their data packet to gmail would be same. Is the identification done by appending different port numbers with the ip-address of each user.


You've answered your own question :)

Each TCP session to the GMail server originates from a different source port on your end so both ends know which connection (or stream) each packet belongs to. It is the responsibility of the NAT implementation to track this information. In GMail's case, each user is likely connecting to a different server on Google's end too since they have so many.

GMail tracks which "user" each connection/stream belongs to based on the cookies etc in the HTTP traffic.

| improve this answer | |

Not the answer you're looking for? Browse other questions tagged or ask your own question.