Now that you have developed a surface level understanding of LAN, we can get into the details of how computers actually communicate across this network. From individual frames of a YouTube video to long emails, computers have vast amounts of information that they need to transfer from point a to point b. To do so, computers simply break up this information into smaller chunks called packets.
Packets
Definition Packets
A finite string of information (1s and 0s) transmitted across a network.
Image from https://web.stanford.edu/class/cs101/network-1-introduction.html
But how does a packet know where to go? How do we know it got there? And how do we know a packet isn’t malicious?
How Packets Travel
Every packet contains not only the original data but also a header indicating its origin, destination, type (called protocol) and more. Routers then inspect the destination address contained within each packet and use this information to decide the packet’s path through the network.
Packet Header
Definition Packet Header
A packet header is the portion of an IP (Internet protocol) packet that precedes its body and contains addressing and other data that is required for it to reach its intended destination (Source: Linux Information Project).
Image from https://en.wikipedia.org/wiki/IPv4
This image outlines the structure of an IP packet. As you can see the first 20 bytes contain the IP Header containing the source, destination, protocol and other information. Without getting into the weeds of what each of these sections actually mean for routing, you can simply visualize how each packet is split up into its header and data components.
Protocols
Protocols are rules that define how a packet is transmitted across a network. They ensure that devices with different hardware and software configurations can still communicate the same way. In this lesson we will look at the two main protocols: UDP and TCP.
The fundamental difference between TCP and UDP
- TCP is connection-oriented and UDP is connectionless. This means that TCP ensures packets reach their destination whereas UDP doesn’t care.
TCP (Transmission Control Protocol)
TCP is a connection-oriented protocol. It establishes a connection before any data can be sent, maintains it during the session, and closes it once the communication is complete.
TCP guarantees that data packets are delivered
- in order
- without duplicates
- verifies that no packets are lost by using acknowledgments and retransmissions
- if a packet is lost it is resent.
This makes it ideal for applications where accuracy is critical, such as web browsing and email. The connection process also provides a layer of security to help ensure malicious packets are not accepted since each packet has specific identification.
UDP (User Datagram Protocol)
UDP is a connectionless protocol that does not establish a connection before sending data, making it faster but less reliable than TCP. It sends packets called datagrams to the receiver without waiting for acknowledgments, which means it does not guarantee the order of delivery or even delivery itself. UDP is suitable for applications where speed is more crucial than reliability, such as live video or audio streams, where occasional loss of packets is preferable to a delay in transmission.
Encapsulation
Protocols have their own headers within the IP packet data that indicate their protocol and other information. The process of embedding packets with different protocols inside of each other is called encapsulation.
Image from https://www.researchgate.net/figure/Encapsulation-format-of-TCP-IP-packet_fig3_357302515
QUIZ
Q1
Based on your understanding of connection vs connectionless protocols do you think a video game would be better suited to UDP or TCP?
Answer: UDP
Q2
Which of these statements accurately describes a packet:
- Only the first set of packets need a destination address
- All packets have a header
- Packets can only have up to one header
- Packets always reach their destination
Q3
What is a data packet?(This is a written response)
Citations
Linux Information Project