The Internet is a huge hierarchical network structure, with hundreds of millions of devices distributed in its large and small subnets. Here we show a simplified office network, including 3 subnets, the subnets are connected by routers, and some computers and office equipment are connected to the subnets using Layer 2 switches or wireless hotspots.
The Layer 2 switch in the figure is working at the data link layer. It maintains a mapping from IP address to physical address learned through ARP (Address Resolution Protocol) to determine whether to send to a certain The data packet of the target host is forwarded from which port of the switch. Thereby achieving network segments communication within the device.
The router works at the network layer. Its ports are connected to another router or switch, and each port is configured with (reaching) addresses of different subnets. The OSPF (Open Shortest Path First) protocol is used between the routers to learn from each other to form a routing table, which is used to grasp the similar "Which router can be passed through, which port, to the designated subnet, how far away "And other information.
Each host (network card) in the network has been manually configured or obtained an IP address from DHCP, including host address , subnet mask and default gateway . When the host 192.168.0.100/24 in subnet 3 wants to send a request to the web server 172.16.1.10/24 in subnet 1, the data packet will first be sent to default gateway -here is the wireless router connecting to subnet 3 The address of the port is 192.168.0.1; the wireless router checks the routing table to obtain the best path to subnet 1, and forwards the data packet to the next station router through the designated port; so continue to complete across network segments Communications.
The purpose of this article is to briefly understand the different working methods of switching networks and routing networks, so as to consolidate the knowledge previously learned. Friends who are interested can read the related materials of Cisco CCNA certification for more information.