Question

I'm trying to learn the basics of ARP/TCP/HTTP (in sort of a scatter-shot way). As an example, what happens when I go to google.com and do a search?

My understanding so far:

  • For my machine to communicate with others (the gateway in this case), it may need to do an ARP Broadcast (if it doesn't already have the MAC address in the ARP cache)

  • It then needs to resolve google.com's IP address. It does this by contacting the DNS server. (I'm not completely sure how it knows where the DNS server is? Or is it the gateway that knows?)

  • This involves communication through the TCP protocol since HTTP is built on it (TCP handshake: SYN, SYN/ACK, ACK, then requests for content, then RST, RST/ACK, ACK)

  • To actually load a webpage, the browser gets the index.html, parses it, then sends more requests based on what it needs? (images,etc)

  • And finally, to do the actual google search, I don't understand how the browser knows to communicate "I typed something in the search box and hit Enter".

Does this seem about right? / Did I get anything wrong or leave out anything crucial?

Was it helpful?

Solution

Firstly try to understand that your home router is two devices: a switch and a router. enter image description here

Focus on these facts:

  • The switch connects all the devices in your LAN together(including the router).
  • The router merely connects your switch(LAN) with the ISP(WAN).
  • Your LAN is essentially an Ethernet network which works with MAC addresses.

For my machine to communicate with others (the gateway in this case), it may need to do an ARP Broadcast (if it doesn't already have the MAC address in the ARP cache)

Correct.

When you want to send a file from your dekstop to your laptop, you do not want to go through the router. You want to go through the switch, as that is faster(lower layer). However you only know the IP of the laptop in your network. For that reason you need to get its MAC address. That's where ARP kicks in.

In this case you would broadcast the ARP request in the LAN until someone responds to you. This could be the router or any other device connected to the switch.

It then needs to resolve google.com's IP address. It does this by contacting the DNS server. (I'm not completely sure how it knows where the DNS server is? Or is it the gateway that knows?)

If you use DHCP, then that has already provided you with the IP of the DNS server. If not, then it means that you manually provided the IP of the DNS. So the IP of the DNS server is stored locally on your computer.

Making a DNS request is just about putting its IP in the packet with the request and forwarding the packet to the network.

Sidenote: DHCP also provides the IP address of the router.

This involves communication through the TCP protocol since HTTP is built on it (TCP handshake: SYN, SYN/ACK, ACK, then requests for content, then RST, RST/ACK, ACK)

Yes. To clarify things: When your computer sends the request

FRAME[IP[TCP[GET www.google.com]]]

The frame is being sent to your LAN's switch which forwards it to the MAC of the router. Your router will open the frame to check the destination IP and route it accordingly(in this case to the WAN). Finally when the frame arrives at the server, the server will open the TCP segment and read the payload, which is the HTTP message. The ACK/SYN etc. messages are being processed just by your computer and the server and not any router or switch.

To actually load a webpage, the browser gets the index.html, parses it, then sends more requests based on what it needs? (images,etc)

Yes. An HTML file is essentially a tree structure which can have embedded resources like images, javafiles, CSS etc. For each such resource a new request has to be sent.

Once your browser gets all these recourses, it will render the webpage.

And finally, to do the actual google search, I don't understand how the browser knows to communicate "I typed something in the search box and hit Enter".

When you type a single character, it is being sent to the server. The server then responds with its suggestions. Easy as that.

References(good reads):

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top