14. 1.2 routing
In most situations, we want our devices to connect beyond our local network to other homes, businesses, and the internet. Devices that are beyond the local network segment are known as remote hosts. When a source device sends a packet to a remote destination device, the help of routers and routing is needed. Routing is the process of identifying the best path to a destination.
A router is a networking device that connects multiple Layer 3, IP networks. At the distribution layer of the network, routers direct traffic and perform other functions critical to efficient network operation. Routers, like switches, can decode and read the messages sent to them. Unlike switches, which make forwarding decisions based on the Layer 2 MAC address, routers make these decisions based on the Layer 3 IP address.
The packet format contains the IP addresses of the destination and source hosts, as well as the message data being sent between them. The router reads the network portion of the destination IP address and uses it to find which one of the attached networks offers the best way to forward the message to the destination.
Anytime the network portion of the IP addresses of the source and destination hosts do not match, a router must be used to forward the message. For instance, if a host located on network 1.1.1.0 needs to send a message to a host on network 5.5.5.0, the host will forward the message to the router. The router receives the message, de-encapsulates the Ethernet frame, reads the destination IP address in the IP packet, determines where to forward the message, re-encapsulates the packet back into a new frame, and forwards the frame on to its destination.