Framing is a fundamental process in computer networking that divides data into logical units called frames before transmission. The primary methods for framing, implemented by the Data Link Layer, ensure reliable and efficient data transfer.
Here are the main methods of framing in a computer network:
- Character Count
- Starting & Ending Characters With Character Stuffing
- Starting & ending Flags With Bit Stuffing
- Physical Layer Coding Violation
Let's delve into each method to understand how frames are delineated.
Understanding Data Framing Methods
Data framing is crucial for identifying the start and end of a block of data, allowing the receiver to correctly interpret the transmitted information. The methods employed vary based on the network's design and requirements.
Character Count
This is one of the simplest framing methods. The header of each frame contains a field specifying the number of characters (or bytes) in the frame.
- How it works: The receiver reads the character count from the header and then simply reads that many characters to obtain the entire frame.
- Pros: Simple to implement.
- Cons: Extremely sensitive to errors. If the count field is corrupted during transmission, the receiver loses synchronization and cannot determine the end of the current frame or the start of the next one.
Starting and Ending Characters with Character Stuffing
This method uses specific characters to mark the beginning and end of a frame. To prevent the end character from appearing within the data itself and being misinterpreted as the end of the frame, a technique called character stuffing is used.
- How it works: A special escape character (ESC) is inserted before any occurrence of the start, end, or escape character within the data. The receiver removes the escape character upon reception.
- Example: If 'E' is the end character and 'X' is the escape character, transmitting "DATA E DATA" becomes "START DATA X E DATA E".
- Pros: More robust than character count.
- Cons: Overhead due to stuffing. Sensitive to errors if an escape character is corrupted.
Starting and Ending Flags with Bit Stuffing
Similar to character stuffing, this method uses a unique bit pattern (a flag byte) to mark the beginning and end of a frame. To prevent the flag pattern from appearing within the data, bit stuffing is used.
- How it works: The flag pattern is typically
01111110
. Whenever the sender encounters five consecutive '1's in the data stream, it automatically inserts a '0' bit. The receiver removes this inserted '0' bit upon encountering five consecutive '1's followed by a '0'. - Example: If the data is
0111111111111110
, after stuffing it becomes0111110111110111110
. - Pros: Works well for arbitrary binary data. Widely used (e.g., in HDLC protocol).
- Cons: Some overhead from stuffed bits.
Physical Layer Coding Violation
This method relies on the physical layer's encoding scheme to indicate frame boundaries. Some physical layer coding schemes use more bits than strictly necessary to represent data bits (e.g., 4B/5B encoding). This allows for "illegal" or "coding violation" patterns that do not correspond to any valid data sequence.
- How it works: The start and end of a frame are marked with these specific coding violation patterns which cannot appear within the valid data encoding.
- Pros: Can be efficient as it leverages the physical layer.
- Cons: Depends heavily on the specific physical layer encoding used. Less flexible than other methods.
Summary of Framing Methods
Here is a table summarizing the methods:
Method | How Frame Boundaries Are Identified | Mechanism to Prevent Boundary Pattern in Data | Sensitivity to Errors | Example/Use Case |
---|---|---|---|---|
Character Count | Count of characters in the header | None | High (Corrupt count breaks sync) | Early systems |
Starting & Ending Characters with Stuffing | Special start/end characters | Character Stuffing (insert ESC) | Medium (Corrupt ESC/boundary) | Text-oriented protocols |
Starting & ending Flags With Bit Stuffing | Special flag bit pattern | Bit Stuffing (insert 0 after five 1s) | Medium (Corrupt flag/stuffed bit) | HDLC, PPP |
Physical Layer Coding Violation | Specific "illegal" physical layer patterns | Leverages unused bit patterns | Medium | FDDI, some LANs |
These methods ensure that data transmitted across a network can be correctly assembled into frames by the receiver, forming the basis for reliable communication at the data link layer.