The hosts connect to a LAN switch and can communicate to each other on the LAN without the need for a router. The router is a layer 3 device and is required to route packets across different subnets, and hence is not required for communication with the same subnet that is the case for a LAN. However, when packets have to go to destinations that are outside the subnet/LAN that the source is a part of, the packets are routed through the router. The router acts as the default gateway for all packets that are to be sent outside the subnet.
Let's consider how traffic flows from a host to other devices using a simple network shown next. There are two subnets in the figure with a router connecting the two subnets. ...