0

My level of knowledge is really basic, but as I understand when you search up say a website you send a server a request for the information of that webpage, then the server sends back packets which contain all that information. I was told these packets know where to go by the IP address you gave to the server upon the request, but that IP only gets the packets to your router, how does the router then know which device in the network requested those packets? I understand that each device has a MAC address but since you did not send the Mac address in the original request, the packets being sent back can't contain it surely? I tried looking online but really couldn't find any explanation for this. If someone could simply explain it to me I would be very grateful :)

1 Answers1

0

IP packets work very much like the U.S. Postal Service. Consider each packet an envelope with a TO: and FROM: address. When you mail the letter, it goes to your local post office. The local post office looks at the TO: address's zip code. The local post office then routes it to the next nearest post office to that zip code, and then the next, and the next, etc, until the letter arrives at the local post office of the recipient.

When your computer sends an IP packet, say an HTTP GET request to google.com, the packet first leaves your network interface, whether its WiFi or Ethernet, and arrives at your router. Well, actually, first your computer has to resolve google.com to an IP address via DNS, but that's another discussion... Your router then consults it's ARP (address resolution protocol) table to see if it's a local device connected to WiFi or the router's switch. If not, then it's sent up-stream to the router's assigned gateway IP address (which is assigned by your ISP).

The packet arrives at your local ISP's edge router. That router consults its routing tables to determine if it's an up-stream, peer, or down-stream route. It's up-stream, so the edge router sends the packet to the next router upsteam, and again, and again, until it gets to your ISP's main router, which is likely connected to a high-capacity fiber-optic backbone.

The packet then travels to Google's nearest geographical datacenter and the whole routing process is reversed until it gets to one of many Google HTTP servers.

Each time the packet stops at a router to determine the next port to go out on, we call that a "hop". You can actually see these hops in action by using the traceroute utility built in to most operating systems.

In Windows: tracert google.com

In Linux/MacOS: traceroute google.com

BTW, you're correct that every device on any network has a unique MAC (media access control) address. These IP address to MAC address conversions are stored in ARP tables. They are cleared when a switch or router is reset. In order to discover a device's MAC address for a given IP address, your network card sends out a WHOIS packet to the network broadcast address. The switch knows to send these packets to every port and if the device that has this MAC address is connected, it will respond "right here!" :-)

Designly
  • 101