Packets and Packet Switching
When you send or receive data over the internet (or other networks) you want two things to happen: You want all the data to be transported and you want it to get to its destination as fast as possible. Some of the problems you might find are some of the "connections" might not be working properly, or they might just be really busy - picture a series of roads between two places, some are busy, one has a breakdown, one is shut for road works - you get the idea.
Inside a computer
To help avoid this problem things are sent by different routes, finding the most efficient way. Also things are split up - imagine there is a large group travelling in 10 cars, some of them will use different routes. This is how it works for data too... (This spitting the data up and sending it different routes is called packet switching)
When data is sent between networks, eg on the internet, it is sent in packets (using TCP / IP). This means splitting a bundle of data (like a file) into smaller equal sized pieces. These pieces are called packets.Each packet has a header , the payload and a trailer (or footer).
The packet header contain the control information for that packet - think of the control information as the envelope of a letter - it includes:
- The destination address - an IP address
- The source (or senders) address - also an IP address
- The packet number - to show the order of the packets
- The total numbers of packets
The payload is the actual data, like the letter inside the document, it may be part of a document, webpage, video, email etc.
The Trailer is small and simply tells the receiving device it has reached the end of the packet.The packet will also contain a checksum (or several checksums) to make sure the data has been not been corrupted.
How Packet Switching works
- The sending device (say a laptop) split the data into packets and numbers each packet showing the packet order
- The (sending) router reads the packets header, gets the destination (IP address) and decides which way to send this particular packet
- This is repeated for each packets, sometimes the packets that make up one file get sent different routes
- When the data is received the receiving device uses the packet number to put them together in the right order
- If it finds one is missing (after waiting the allowed time) it sends the sending device a "time out message" basically saying I didn't get this packet, resend it..
- If all packets are there , and the checksum says nothing has corrupted, then the receiving device sends a receipt confirmation (basically "I got everything and it all works")