Quote:
I thought that packet-switching took place while the data was en route.
It does.
The OSI model principles not only apply to the two end devices (the sender and the receiver), it is implemented by all the intermediate devices between the sender and receiver.
So when the data frame leaves the source device as Layer 1 electrical signals and before those signals are received at the destination they will encounter at least one of the following intermediate devices:
(1) Repeaters - these are not intelligent, operate only at Layer 1 and repeat/regenerate the signals and pass them on - typically used on long distance links these days if required.
(2) Hubs - do the same as repeaters, operate only at Layer 1, but also connect a number of devices together at a central point (hub) - hardly ever used these days.
(3) Switches (or more precisely Layer 2 switches) - have replaced hubs - these receive the data signals (at Layer 1) but then examine the frame of bits at Layer 2 and can make forwarding decisions based on the Layer 2 destination address (MAC address) so the frame doesn't have to be sent (as data bits on Layer 1) to all devices connected to the switch just to the destination; though there are circumstances when the frame is flooded to all devices. Also a swtich only makes forwarding decisions in the context of the local network segment, if the frame is to go to another network, then a router is required.
(3) Routers - receive the data signals at Layer 1, takes the frame of bits (at Layer 2) and then extracts the Layer 3 packet. It then examines the Layer 3 destination network IP address. Then using its routing table it determines where to send the packet. The packet is re-encapsulated into a new frame and then forwarded as Layer 1 signals onto the link that it has selected. This is
packet switching - each packet is independently forwarded by the router in accordance with the routing information that it has at that moment - hence packets in the same data stream could take different pathways to the destitnation. This makes for flexible, resilient data communications.
So the key thing is - the OSI model, to varying degrees, applies to all devices on the data network, not just the end devices.
Aubrey