Chapter 3: Understanding Network Data Units

Before understanding how data travels through a network, we need to understand a few basic concepts.
Packet
Packet: A packet is a unit of data sent across a network. It contains an IP header and a payload, which carries data from another protocol, usually TCP or UDP.
Packet Header
Packet Header: Contains metadata (information about the packet) that helps network devices deliver and handle it correctly.
Some important fields include:
Source IP: The IP address of the sender.
Destination IP: The IP address of the receiver.
Protocol: Indicates which protocol is carried inside the packet (e.g., TCP or UDP).
TTL (Time To Live): An IPv4 header field that limits how many router hops a packet can travel before being discarded. Its IPv6 equivalent is called Hop Limit.
We will talk about IPv4 and IPv6 in future chapters.
Example: A packet starts with TTL = 5. After passing through 2 routers, its TTL becomes 3. If it reaches 0, it is discarded.
Segment
Segment: A segment is a unit of data created by TCP. It contains a TCP header and application data, and is used to transfer data between applications.
The TCP header includes information such as:
Source Port: Identifies the sending application's port.
Destination Port: Identifies the destination application's port.
Sequence Number: Helps the receiver put received data back in the correct order.
Acknowledgment Number: Indicates which data the receiver has successfully received and what it expects next.
Etc.
Note: TCP uses segments, while UDP uses datagrams.
Packet Switching
Packet Switching: A method of transmitting data by dividing it into smaller units called packets.
Each packet is forwarded through network devices using the destination IP address. Packets can travel through different paths to reach their destination.
Network devices can use a technique called Store-and-Forward: they receive a complete frame or packet, process it, and then forward it to the next device.
Unlike circuit switching, packet switching doesn't require a dedicated communication path or reserved resources between the sender and receiver.
At the destination, TCP uses sequence numbers to reassemble received data into the correct order.
Types of Packet Switching
1. Connectionless Packet Switching (Datagram):
Packets are sent independently without establishing a connection first. Each packet can take a different route to reach its destination.
Example: IP (Internet Protocol).
2. Connection-Oriented Packet Switching (Virtual Circuit):
A logical path is established before data transmission. Packets generally follow the same predetermined path.
Example: Virtual circuit networks.
Main difference: Connectionless packet switching doesn't establish a path beforehand, while connection-oriented packet switching does.
Main Types of Network Delays
Transmission Delay: Time needed to put all packet bits onto the link.
Propagation Delay: Time needed for the signal to travel across the link.
Queueing Delay: Time a packet waits in a network device's queue.
Processing Delay: Time a network device takes to examine and process a packet.
End-to-End Delay: The total time a packet takes to travel from source to destination, including processing, queueing, transmission, and propagation delays along the route.
Frame
Frame: A frame is a unit of data used to transfer information across a local network link. It carries a packet as its payload and contains a header and usually a trailer.
Frame Header
The frame header contains information needed to deliver the frame across the current network link.
Destination MAC Address: Identifies the next device receiving the frame.
Source MAC Address: Identifies the device sending the frame.
Type/Length: Identifies the payload protocol or specifies its length, depending on the Ethernet format.
Frame Payload
Frame Payload: The data carried inside a frame. It commonly contains an IP packet.
Trailer and Footer in Frames
Trailer: The final part of a frame, often containing error-detection information.
Footer: A general term for information placed at the end of data. It's not the standard term used for Ethernet frames.
Example: Ethernet uses FCS (Frame Check Sequence) in its trailer to detect corrupted frames.
Types of Framing
There are two common approaches to framing:
1. Fixed-Size Framing:
Every frame has a predefined length. The receiver knows where each frame ends because all frames have the same size. Separate start and end delimiters are not required.
Simple to implement.
Padding can be added if the data doesn't completely fill a frame.
Example: ATM cells use a fixed size of 53 bytes.
2. Variable-Size Framing:
Each frame can have a different length. The receiver needs a way to determine where each frame starts and ends.
Two common methods are:
a. Length Field:
A length field in the frame header specifies the frame's length. The receiver uses this value to determine where the frame ends.
What's the difference between Fixed-Size and Length-Field framing?
In Fixed-Size framing, all frames have the same predefined length.
In Length-Field framing, frames can have different lengths, and the length field tells the receiver how long each frame is.
b. End Delimiter:
A special pattern or character is used to mark the end of each frame.
Character/Byte Stuffing: Extra bytes are inserted into the data when necessary to prevent special delimiter characters from being mistaken for actual frame boundaries.
Bit Stuffing: Extra bits are inserted into the data to prevent the delimiter pattern from appearing accidentally. For example, a 0 can be inserted after five consecutive 1s.
Example: How Data Travels Across Networks
Imagine we have three LANs. Our PC (Computer A-1) is in LAN 1, and we want to send a 10 GB file to Computer C-1 in LAN 3.
Here's how it works:
1. Splitting data into segments:
TCP divides application data into smaller pieces. For simplicity, imagine splitting our 10 GB file into 10 parts of 1 GB each.
Each part is wrapped with a TCP header containing information such as sequence numbers, which help the receiver put the data back in the correct order.
The whole unit is called a Segment, the information is the TCP Header, and the actual data is the Payload.
Note: The 1 GB segment size is just a simplified example. In real-world TCP communication, segments are usually much smaller, depending on the network's Maximum Segment Size (MSS).
Also, the #1, #2, #3 labels are just examples to explain ordering. Real TCP sequence numbers identify positions in the byte stream, rather than simply numbering segments.
2. Wrapping each segment into a packet:
Now we need to identify where the data is coming from and where it needs to go.
IP adds a header containing information such as source and destination IP addresses.
The whole unit is called a Packet, the information is the IP Header, and the carried segment is the Payload.
3. Wrapping each packet into a frame:
Computer A-1 puts each packet inside a frame and sends it to Router 1 (the router of LAN 1).
The frame header contains information such as the source MAC address (Computer A-1) and destination MAC address (Router 1).
The whole unit is called a Frame, the information is the Frame Header, and the packet is the Payload.
Note: Payloads are different depending on the data unit.
Segment payload = Application data.
Packet payload = TCP segment (or UDP datagram).
Frame payload = IP packet.
4. Removing and replacing frames:
When Router 1 receives the frame, it removes the frame header and trailer and examines the IP packet.
It then creates a new frame with new information, such as the source and destination MAC addresses for the next network link, and sends it to Router 2.
5. Repeating the process:
This process repeats as the packet travels through the network. Each router removes the incoming frame and creates a new one for the next link.
6. Reaching the destination:
When the packet reaches Router 3, the router forwards it inside a new frame addressed to Computer C-1.
Computer C-1 removes the frame and IP headers, processes the TCP segments, and reassembles their data into the original byte stream.
References
原文:https://www.a8q9.cn/en/article/chapter-3-understanding-network-data-units-8b65bb.html

