0

I know how port forwarding works. but, if two devices in the same network are running the same process, for example suppose two devices are requesting for an HTTP response. Since both services will be running at the same port, how does the router identify the correct device for forwarding the packets

1

2 Answers 2

0

servers identify packets like follow:

Level 2: Mac Addr:
Level 3: IP Addr
Level 4: Port 

So, for the demonstration, lets say you have 3 hosts in your network: ClientA, ClientB and ServerC. You have a Web Service running on port 80 on ServerC.

When ClientA make a request, the session is like:

ClientA (IPa, Porta) <-> ServerC(IPc, Portc)

which can be:

ClientA (192.168.1.51,10001) <-> ServerC(192.168.1.10,80)

When ClientB make a request, the session is like:

ClientB (IPb, Portb) <-> ServerC(IPc, Portc)

which can be:

ClientB (192.168.1.52,10001) <-> ServerC(192.168.1.10,80)

So on server, it has 2 uniq sessions:

192.168.1.51,10001-192.168.1.10,80
192.168.1.52,10001-192.168.1.10,80

If ClientA make a second request to the ServerC, we have:

ClientA (IPa, Porta2) <-> ServerC(IPc, Portc)

which can be:

ClientA (192.168.1.51,10002) <-> ServerC(192.168.1.10,80)

So on server, it has 3 uniq sessions:

192.168.1.51,10001-192.168.1.10,80
192.168.1.51,10002-192.168.1.10,80
192.168.1.52,10001-192.168.1.10,80

I hope I was clear enough.

Philip.

1

Simplifying somewhat, every Internet packet has : a source IP, dest IP, source port and destination port. The source port is more-or less random and this is the key.

Your router builds a table mapping table which takes into account all the above and rewrites packets to/from itswan IP, using the source and destination - thus the source port can be used if 2 devices visit the same IP at the same time.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .