A packet is a block of data that is part of a message or traffic being sent between two or more computers over the internet or a network. Packets are blocks of data which contain data making up parts or all of a message. Each packet in a message has a sequence number so the computer receiving the packets can put the message back together in the correct order. Packets that make up a single message may not always be sent over the same network path.
There are three main sections in a packet which include:
- Header - Information about where the packet is going and where it came from. In a TCP packet this includes the source and destination port along with a sequence number and other flags. In a IP packet the header includes the source and destination IP address.
- Data area - Contains the data to be included in the message.
- Trailer - Contains items for error checking like a checksum of the message.
There is no guarantee that packets will be delivered to their final destination. Some protocols that send packets provide for a guarantee of delivery by providing for acknowledgements of packet receipts. If a packet is not acknowledged to have been recieved within some period of time, the packet may be re-transmitted by the sender.
A message may be made of the contents of a series of packets. The receiving computer uses the header and trailer to determine whether the packet has been received correctly then assembles the message from a series of packets.