Framing
Framing is one of the important functions of the Data Link Control (DLC) sublayer. The physical layer transmits a continuous stream of bits, but the data-link layer needs to divide these bits into manageable units called frames so that each frame can be identified separately.
Why is framing needed?
A message is divided into frames because:
- It separates one data unit from another.
- It identifies the beginning and end of each frame.
- A frame can contain source and destination addresses.
- Smaller frames make error control and flow control more efficient.
- If an error occurs, only the affected frame needs to be retransmitted rather than the entire message.
Frame Size
There are two types:
| Type | Description |
|---|---|
| Fixed-size framing | All frames have the same size, so the size itself identifies the frame boundary. |
| Variable-size framing | Frames can have different sizes, so special techniques are needed to identify their boundaries. |
An example of fixed size framing is the ATM WAN, which uses frames of fixed size called cells.
Variable-size framing, using two approaches:
- Character-oriented framing
- Bit-oriented framing
1. Character-Oriented Framing
In this method, the data is treated as a sequence of 8-bit characters (bytes) from a coding system such as ASCII.
Problem
The same flag pattern may occur inside the actual data.
For example:
Flag | Data ... FLAG ... | Trailer | Flag ↑ actual data
The receiver might incorrectly interpret the flag inside the data as the end of the frame.
Solution: Byte Stuffing
An ESC (escape) byte is inserted before a flag-like character occurring in the data.
Original data: A FLAG B After byte stuffing: A ESC FLAG B
The receiver removes the ESC and treats the following byte as data, not as a frame delimiter.
If the ESC character itself occurs in the data, another ESC is inserted before it.
Data: ESC Stuffed: ESC ESC
This process is called byte stuffing (character stuffing).
Character-oriented protocols present another problem in data communications. The universal coding systems in use today, such as Unicode, have 16-bit and 32-bit characters that conflict with 8-bit characters. We can say that, in general, the tendency is moving toward the bit-oriented protocols that we discuss next.
2. Bit-Oriented Framing
In bit-oriented framing, the data is considered simply as a sequence of bits, regardless of whether it represents text, audio, video, etc.
A commonly used 8-bit flag is:
01111110
The frame looks like:
Problem
The flag pattern could accidentally occur inside the data.
Solution: Bit Stuffing
To prevent the data from being mistaken for a flag:
Whenever the sender encounters five consecutive 1s after a 0, it inserts an additional 0.
The receiver removes this extra 0.
For example:
Original: 01111110 After bit stuffing: 011111010
The inserted 0 prevents the data from being interpreted as the flag 01111110.
Important point
The stuffed 0 is inserted after five consecutive 1s, regardless of the value of the next bit. The receiver removes this stuffed bit during bit unstuffing.
Character Stuffing vs Bit Stuffing
| Feature | Character-oriented | Bit-oriented |
|---|---|---|
| Unit | Byte/character | Bit |
| Delimiter | Special flag byte | 01111110 |
| Protection technique | Byte stuffing | Bit stuffing |
| Extra information | ESC byte | Extra 0 bit |
| Receiver action | Removes ESC | Removes stuffed 0 |
Summary
FRAMING | +---------+---------+ | | Character-oriented Bit-oriented | | Byte stuffing Bit stuffing | | ESC byte Insert 0 after five consecutive 1s
In short: Framing converts a continuous stream of bits into identifiable frames. In variable-size framing, byte stuffing is used with character-oriented protocols, while bit stuffing is used with bit-oriented protocols.
Comments
Post a Comment