Bit and Byte Stuffing
- In a bit-oriented protocol, the data to send is a series of bits.
- In order to distinguish frames, most protocols use a bit pattern of 8-bit length (01111110) as the flag at the beginning and end of each frame.
- Here also cause the problem of appearance of the flag in the data part to deal with this an extra bit added.
- This method is called bit stuffing. In bit stuffing, if a 0 and five successive 1 bits encountered, an extra 0 is added.
- Moreover, The receiver node removes the extra-added zero.
- This process illustrated below,
- The second framing solves the problem of resynchronization by having each frame start and end with special bytes.
- A flag byte used to separate the frame as both the starting and ending delimiter, as shown in the figure.
- In this way, if the receiver ever loses synchronization, it can just search for the flag byte to find the end of the current frame.
- Two consecutive flag bytes indicate the end of one frame and start of the next one.
- It may easily happen that the flag byte’s bit pattern occurs in the data.
- Moreover, To solve this problem is to have the sender’s data link layer insert a special escape byte (ESC) just before each “accidental” flag byte in the data.
- The data link layer on the receiving end removes the escape byte before the data given to the network layer.
- This technique called byte stuffing or character stuffing.
- The disadvantage of using this framing method is that it closely tied to the use of 8-bit characters.
- Not all character codes use 8-bit characters.
- eg., UNICODE uses 16-bit characters