Exercise: Understanding Network Communication

In this exercise, we will analyze the step-by-step process of network communication between different devices. We'll use three networks: A, B, and C, with specific IP address ranges. Let's break down the process using Markdown and sprinkle in a few icons and emojis along the way!

Network Setup

  • Network A: Address space 10.1.1.0/24

  • Network B: Address space 192.168.1.0/24

  • Network C: Address space 172.16.1.0/24

  • Router A:

    • Interface on Network A: IP 10.1.1.1

    • Interface on Network B: IP 192.168.1.254

  • Router B:

    • Interface on Network B: IP 192.168.1.1

    • Interface on Network C: IP 172.16.1.1

Devices on the Networks

  • Computer 1:

    • Network: A

    • IP address: 10.1.1.100

    • Role: Client (a desktop computer at a workplace)

  • Computer 2:

    • Network: C

    • IP address: 172.16.1.100

    • Role: Server (located in a data center)

Communication Flow

  1. Computer 1 user opens a web browser and enters 172.16.1.100 in the address bar.

    🌐💻🔍 Web browser request: Computer 1's web browser sends a request to retrieve a webpage from 172.16.1.100.

  2. Web browser communicates with the local networking stack.

    🖥️🌐📡 Networking stack interaction: The web browser interacts with the local networking stack, responsible for handling networking functions.

  3. Web browser specifies the desired TCP connection to 172.16.1.100 port 80.

    🌐🔌🔗 TCP connection request: The web browser informs the networking stack about the intention to establish a TCP connection to 172.16.1.100 on port 80.

  4. Networking stack checks its subnet and determines the destination is on another network.

    🖥️🔍🔀 Subnet analysis: The networking stack identifies that it belongs to the 10.1.1.0/24 network, realizing that 172.16.1.100 is on a different network.

  5. Computer 1 identifies the need to send data to its gateway for routing.

    🖥️🔀🌐 Gateway identification: Computer 1 knows it must send the data to its configured gateway, which is 10.1.1.1.

  6. Computer 1 looks up the MAC address of its gateway (10.1.1.1).

    🖥️🔍🔎 MAC address lookup: Computer 1 searches its Address Resolution Protocol (ARP) table for the MAC address of 10.1.1.1 but doesn't find a corresponding entry.

  7. Computer 1 sends an ARP request for the MAC address of 10.1.1.1 to all devices on the local network.

    🖥️🔁📨 ARP request broadcast: Computer 1 broadcasts an ARP request for the MAC address of 10.1.1.1 to all devices on the local network.

  8. Router A, assigned with the IP address 10.1.1.1, receives the ARP request.

    🌐📨📩 ARP response: Router A receives the ARP message and identifies itself as the device with the IP address 10.1.1.1. It responds to Computer 1, providing its own MAC address (00:11:22:33:44:55).

  9. Computer 1 receives the ARP response and learns the MAC address of its gateway.

    🖥️📩🔍 MAC address acquisition: Computer 1 receives the ARP response from Router A and learns its MAC address. It now knows the hardware address of its gateway.

  10. Computer 1 starts constructing the outbound packet.

    🖥️🔨📦 Packet construction: Computer 1 prepares to construct the outbound packet to send data to 172.16.1.100. It understands that the web browser requested an outbound TCP connection and needs an available TCP port.

  11. Computer 1 selects an available ephemeral port (e.g., port 50,000) and opens a socket for the web browser.

    🖥️🔌🔒 Socket creation: Computer 1 identifies an available ephemeral port (e.g., port 50,000) and establishes a socket connection between the web browser and this port.

  12. Computer 1 encapsulates the TCP segment within an IP packet.

    🖥️📦🔒 TCP segment encapsulation: Computer 1 encapsulates the TCP segment within an IP packet, with the source IP address as 10.1.1.100, the destination IP address as 172.16.1.100, and the source port as the selected ephemeral port (e.g., 50,000). The destination port is set to 80.

  13. Computer 1 checks its routing table to determine the appropriate next hop.

    🖥️🔍🗺️ Routing decision: Computer 1 consults its routing table to determine where to send the packet. It finds that the destination IP address 172.16.1.100 falls outside its local network (10.1.1.0/24), so it selects the default gateway 10.1.1.1 as the next hop.

  14. Computer 1 prepares the Ethernet frame for transmission.

    🖥️📦🔗 Ethernet frame preparation: Computer 1 constructs an Ethernet frame with the destination MAC address set to the MAC address of Router A (00:11:22:33:44:55), the source MAC address set to its own MAC address, and the payload containing the IP packet.

  15. Computer 1 sends the Ethernet frame over the local network.

    🖥️📤🌐 Frame transmission: Computer 1 sends the Ethernet frame onto the local network. The frame travels through the network medium (e.g., Ethernet cables or wireless signals) and reaches Router A.

  16. Router A receives the Ethernet frame.

    🌐📨📩 Frame reception: Router A receives the Ethernet frame and examines the destination MAC address. Since the destination MAC address matches its own MAC address, Router A processes the frame.

  17. Router A extracts the IP packet from the Ethernet frame.

    🌐📦🔓 Frame processing: Router A removes the Ethernet frame and extracts the IP packet from the payload.

  18. Router A checks its routing table to determine the next hop for the IP packet.

    🌐🔍🗺️ Routing decision: Router A consults its routing table and finds that the destination IP address 172.16.1.100 falls outside its local network (192.168.1.0/24). It identifies that the next hop for this packet should be Router B (192.168.1.1).

  19. Router A prepares a new Ethernet frame with the IP packet as the payload.

    🌐📦🔗 Ethernet frame preparation: Router A constructs a new Ethernet frame with the destination MAC address set to the MAC address of Router B, the source MAC address set to its own MAC address, and the payload containing the IP packet.

  20. Router A sends the new Ethernet frame over the local network.

    🌐📤🌐 Frame transmission: Router A sends the new Ethernet frame onto the local network. The frame travels through the network medium and reaches Router B.

  21. Router B receives the Ethernet frame.

    🌐📨📩 Frame reception: Router B receives the Ethernet frame and examines the destination MAC address. Since the destination MAC address matches its own MAC address, Router B processes the frame.

  22. Router B extracts the IP packet from the Ethernet frame.

    🌐📦🔓 Frame processing: Router B removes the Ethernet frame and extracts the IP packet from the payload.

  23. Router B checks its routing table to determine the next hop for the IP packet.

    🌐🔍🗺️ Routing decision: Router B consults its routing table and finds that the destination IP address 172.16.1.100 belongs to its local network (172.16.1.0/24). It identifies that the packet is destined for a device on its own network.

  24. Router B forwards the IP packet to Computer 2.

    🌐📨📤 Packet forwarding: Router B sends the IP packet directly to Computer 2 using the MAC address associated with the IP address 172.16.1.100.

  25. Computer 2 receives the IP packet.

    🖥️📨📩 Packet reception: Computer 2 receives the IP packet and extracts the enclosed TCP segment.

  26. Computer 2 checks if it has a listener on the destination port (port 80).

    🖥️🔍🔒 Port analysis: Computer 2 checks if any process is actively listening on port 80 to handle incoming TCP connections.

  27. Computer 2 finds that there is a process listening on port 80.

    🖥️🔍✅ Port availability:

Computer 2 checks to ensure that there's an open socket on Port 80, which there is. It's in the listen state and held open by running Apache web server. Computer 2 then sees that this packet has the SYN flag set. It examines the sequence number and stores that. Since it'll need to put this sequence number in the acknowledgment field once it crafts the response. After all of that, all we've done is get a single TCP segment containing a SYN flag from one computer to a second one. Everything would have to happen all over again for Computer 2 to send a SYN ACK response to Computer 1. Then everything would have to happen all over again for Computer 1 to send an ACK back to Computer 2, and so on and so on. Looking at all of this end-to-end hopefully helps show how all the different layers of our networking model have to work together to get the job done. I hope it also gives you some perspective in understanding how remarkable computer networking truly is.

Last updated