The Internet is a vast, layered network of hundreds of millions of devices spread across subnets large and small. Here we show a simplified office network consisting of three subnets connected by routers and connected to some computers and office equipment using layer 2 switches or wireless hotspots.
The Layer 2 switch in the figure works at the data link layer. It maintains a mapping between IP addresses and physical addresses learned through THE Address Resolution Protocol (ARP) to determine which port on the switch forwards data packets destined for a destination host. In this way, devices on the same network segment can communicate with each other.
A router works at the network layer. Its ports are connected to another router or switch, and each port is configured with a different subnet address. Routers use Open Shortest Path First (OSPF) to learn from each other and form a routing table to learn information such as which router can pass through, which port, and how far to reach the specified subnet.
Each host (nic) on the network has an IP address manually configured or obtained from DHCP, including the host address, subnet mask, and default gateway. When the host on subnet 3, 192.168.0.100/24, wishes to send a request to the Web server 172.16.1.10/24 on subnet 1, the packet is first sent to the default gateway – here is the address of the port on the wireless router that connects to subnet 3, 192.168.0.1; The wireless router checks the routing table, obtains the optimal path to subnet 1, and forwards the packets to the next router through the specified port. This continues to complete communication across network segments.
The purpose of this article is to consolidate what you have learned by briefly understanding the different ways in which switched and routed networks work. For more information, please read cisco CCNA certification.