This is the 27th day of my participation in the August More Text Challenge

The book continues, and now that we have a thorough understanding of these communications elements from the previous chapters, it is time to conclude the series.

Horizontal contrast

1. Work hierarchy

  • The Router recognizes IP packets and works at layer 3 network layer.

  • The Modem changes the signal physical format and works at the first physical layer.

  • Hub amplifies, copies and forwards signals and works in the first physical layer.

  • Bridge can forward based on MAC address and works at layer 2 data link layer.

  • The Switch can recognize MAC addresses and works at layer 2 data link layer.

  • Layer-3 switches can identify IP addresses and route routes by adding routing modules, and work at the layer 3 network layer.

  • Layer 4 Switches perform advanced scheduling, such as load balancing, based on TCP/UDP packets and work at layer 4 transport layer.

2. Work scenario

  • A Router works at the edge of a network and connects to different network segments through routing and forwarding functions.
  • Modems work at the edge of the network and transfer signals on different media by transforming signal formats.
  • Hub works in the core of LAN, through signal amplification and broadcast to achieve interconnection within a network segment;
  • Bridge works in the center of two Lans and Bridges two Lans on the same network segment.
  • Switch works in the LAN core to achieve end-to-end high-speed communication within the LAN

3. Broadcast domain and conflict domain

  • A Router can split a broadcast domain. One port of a Router is a broadcast domain.
  • A Hub combines all hosts connected to it into a broadcast domain and a collision domain.
  • Bridege can segment conflict domains, and a port of a bridge is a conflict domain, but a bridge cannot segment broadcast domains, and lans connected to the bridge are all in the same broadcast domain.
  • Switch, like bridge, can further split conflict domain, but cannot split broadcast domain.
  • Switch can divide broadcast domains by VLAN. A VLAN is a broadcast domain.

4. Duplex mode

  • The Router works in full-duplex mode and can send and receive data simultaneously. It also supports half duplex mode.
  • The Modem works in full-duplex mode and can be modulated and demodulated at the same time.
  • The Hub mode is half-duplex and cannot be sent and received at the same time, which may cause conflicts.
  • Bridge is also in half-duplex mode and cannot send and receive at the same time.
  • Switch is in full-duplex mode. Ports can send and receive data at the same time. It also supports half duplex mode.

Actual end-to-end communication flow

In the secret series of HTTP, I explained the process of browser surfing the Internet, from HTTP to DNS, to TCP, and to TLS security protocol, in a deeper understanding of the communication equipment and mechanism from the physical layer to the network layer, then let’s take a look at the real end-to-end process of Internet communication as a whole:

A complete Internet communication process

  1. Access to the Network: When our mobile phone or computer is connected to the network, the access method can be cafe WIFI, mobile hotspot, the company’s network cable, or the OPERATOR’s 4G network, then we only establish physical connection with the network, that is, layer 1;

  2. Obtain IP:

    • After connecting to the network, the NIC sends a broadcast message through the port to request the Dynamic Host Configuration Protocol (DHCP) server to assign AN IP address. The request message contains the MAC address of the Host.
    • DHCP services are typically integrated in routers or in the carrier’s machine room.
    • After receiving the request, the DHCP server automatically selects an available IP address from the IP address pool and assigns it to the host. The DHCP server also informs the router of the IP address, subnet mask, DNS address, lease duration, and other information. The following is a screenshot of the DHCP message:

  1. Obtain the GATEWAY (router) MAC address and the NEIGHBOR MAC address on the LAN:
    • It is not enough to know the IP address of the router, we also need to know the MAC address to establish the connection of the data link layer.
    • The host sends an ARP broadcast message to ask the router for the MAC address corresponding to the IP address. After receiving the broadcast message, the router sends its MAC address to the host. In this way, the Layer-2 connection between the two parties can be established.
    • The host not only needs to know the MAC address of the router, but also sends ARP broadcasts to ask for the MAC addresses of neighbors on the same network segment for communication within the LAN.

  1. The host can access the Internet through the router. After entering the URL in the browser, the host sends a request to the DNS server to obtain the target IP address.

  2. First establish the TCP connection to the destination IP address, put the destination IP address into the IP packet, there is an important judgment, determine whether the destination IP address is in the LAN:

    • If they are on the same network segment, they can communicate with each other through MAC addresses.
    • If they are not on the same network segment, they must communicate with each other through routers, which is stipulated by the protocol.
    • The router is responsible for forwarding the IP packet to the destination IP address. Therefore, the host will put the MAC address of the router into the data frame, and the router will determine the MAC address of the next hop:

  1. The router sends the data packet to the Modem for modulation, and then the data packet is transmitted to the optical fiber or telephone copper wire for transmission. The data packet is transmitted to the next hop until it reaches the destination router.

  2. The destination IP responds to the host request, and the response message is also forwarded to the host through the router:

    • The source IP of the IP layer is the target IP, but the frame header of the data link layer is the MAC address of the router, because the router is responsible for forwarding in the LAN:

  1. The thing to notice hereAlthough we can see the local IP address in the IP packet, we can know from network segment 10.0.0.N that this is only a private network address, which cannot be used for public network communication. Therefore, the router unknowingly performs a NAT address translation:
    • The router parses the IP packet sent to the public network, changes the source IP address to the public IP address, and then sends the next route.
    • The IP address in the IP packet that receives the response from the target IP address is changed to the IP address of our client, and then sent to the client.
    • So this is why when we query the local IP from the public network, it is inconsistent with what we see locally;
    • In the router management software, you can view your own public network address, which is shared by all LAN hosts.

Thank you for reading, if there are inaccurate and wrong place please comment, I will immediately correct, thank you!






Summary is not easy, please do not reprint without permission, otherwise don’t blame old uncle you are welcome

Welcome technical friends to communicate with me, wechat 1296386616