Packet Switching
When you click “send” on an email, you might think that your message gets sent like a paper letter – one message, delivered from place to place until it arrives at its destination. The truth is much more complicated and interesting!
The way that information is sent from place to place on the internet, indeed on most computer networks, uses a complicated but very effective technique called packet switching. Like most techniques it has its disadvantages, but it wins out because it makes for a very low-cost and highly effective way of delivering information.
Any file or information that needs to be sent from one place to another on the internet, whether it’s an email or a video or a voice call, is first broken up into packets. These packets are small chunks of data, which contain several sections. Each packet has a packet header, which contains the IP address of the sender (which computer or device was sending the information) and the IP address of the receiver (which device it is supposed to reach). The header also has the number of the packet (out of all the packets that make up the whole file), and the size of the packet. Beside the header, the packet has the payload, which is the actual data (part of the file that’s being transmitted). Finally, the packet has a packet trailer, which includes an error check (used to make sure the packet has been delivered correctly) and an indication of the end of the packet.
Each individual packet is transmitted separately. This means that each one might follow a different route to reach the receiver. Along the way, network routers (also called “nodes”) manage the flow of data across the network. As each router receives a packet, it makes sure the packet was received correctly (using the error check method in the packet trailer) and if it wasn’t, it asks for the packet to be resent. Then it sends the packet on to another node in the network that is in the direction of the recipient device. It might be directly headed to the recipient, or (if there is heavy congestion in that direction or there is some disruption of service) it might be in a slightly different direction.
This technique (sending each packet on taking into account of congestion or disruptions) makes the network very resistant to problems. It was actually designed so that the network could still function even if portions were destroyed. (Military planners wanted a network to preserve communication during a war.) There is also a technique where a hop counter gets added to the packet header to keep track of how many transmissions between routers (“hops”) the packet has made: if it gets too much (the packet is stuck in a loop or getting lost), the sender gets asked to send the packet again.
When the receiver gets each packet, it checks the sequence numbers and makes sure all the packets are there and assembles them in the correct order. (Again, if any are missing it will send a request to have the packets resent.)
This can happen very quickly because the packets are very small (maybe containing around 1,000 bytes, or 8,000 bits) and the data is transmitted very fast (typical network transmission rates are measured in millions of bits per second or more!). It’s not instantaneous, and this means that packet switching isn’t the ideal technique for real-time streaming like in video chats. But it’s very effective and impressive, so when you get frustrated that sound or video gets laggy when you are streaming information over the internet, stop and think about the thousands or millions of packets making their hops across the internet, router by router.
For more information on packet switching, check out my online course “Conquer Computer Science: Networks and Data Transmission”
Leave a Reply