How does a router directs the internet traffic to a specific host in the private network?

how does a router directs the internet traffic to a specific host in the private network?

Example:

My PC has ip 192.168.134.100
Router has ip 192.168.134.200
My company's ip 202.52.150.33

When i try to access internet, say google, it traverses from MY_PC-->Router-->My_company_IP-->Google_Server.
Google server will receive request from my company ip address (202.52.150.33)and it will reply to it.
Now the question is how does the router know that this packet from google has to be routed back to my pc 192.168.134.100 ?
What is the tracking mechanism for every request from hosts in private network to internet ?

I know this a basic question... Searching internet is giving me a long concept of subnetting only, so any clarifications is highly appreciated... Thank you

Regards,
Arun

Each end of the connection has its own port. You're connecting to port 80 on google, but your own port is going to be a random number >32768. Let's call it 40,000.

So your PC transmits a connection request to google.com on port 80, from 192.168.134.100 port 40,000. It travels through your router, which marks down "forward traffic to port 40,000 to 192.168.134.100". It will continue forwarding this connection until it's explicitly broken, or the connection lies idle a few minutes (a highly annoying fact sometimes when you don't want idle connections to break!) This process is part of Network Address Translation(NAT).

These local port numbers are randomly picked, allowing many connections to coexist alongside each other without their ports overlapping.

2 Likes