0

I'm a software engineer wanting to comprehend the network layer of the OSI model.

Given that I'm sending a request to serverfault.com. The packet with the server's IP is sent from my PC to my home router which sends it further to the destination. Then the host replies and sends response to the IP address of my router. Now the router needs to redirect it to my PC, not f.e. my phone.

I don't believe the request author's mac address would be included in the request. Therefore I wander how the routers forwards the http responses to appropriate node.

Many thanks.

1
  • Within the local area network the link layer (OSI layer 2) protocols ARP or NDP are used tcpipguide.com/free/…
    – Bob
    Sep 30 '20 at 9:09
0

You router has WAN and LAN interfaces. In order to send packets from LAN to WAN route use PAT(IP + port pair.) It crates mapping table ip + port. Lets say your home PC has 192.168.1.1 and Mobile phone 192.168.1.1 when use send request to serverfault.com. reuest will 192.168.1.1:(something) to serverfault.com.:80/443(port) and router will remember that and create mapping table. https://www.ciscozine.com/nat-and-pat-a-complete-explanation/

0

If your user-agent has a unique globally routable IP address, easy. Packets making up the response go from Stack Exchange's backend, through their edge router, via a transit ISP's network, to your ISP, your router, and finally to your PC. The entire time the destination IP address is preserved, unique on the Internet as your PC. Now that IPv4 address space is exhausted, this simple end-to-end scenario is only likely on IPv6 networks.

IPv4 client networks are probably behind a NAT. A similar path, but the destination header is the NAT device. NAT's job includes converting incoming packets to a destination IP on the internal network. To do this, it has to remember connection state, based on port numbers and other layer 4 protocol hints.

Destination's layer 2 MAC addresses is not relevant to IP packets traversing the internet. It might not be Ethernet on the other side, connecting very different networks is the entire point of IP.

Once your PC's router recognizes an IP address as on link, then it will send the data via layer 2. Perhaps wrapped in an Ethernet frame to a WiFi controller.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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