We had seen in previous article framing, that to send packets from sender to the receiver framing is required. But the question was how the receiver will identify the starting and ending of a frame. For receiver, starting and ending of a frame is necessary to recognize the next frames transmitted by the sender.
So in this case Flag bytes with byte stuffing framing method will support.
- In this method a flag byte, is used as both the starting and ending of a frame. See in the figure below.
- Two consecutive flag bytes indicate the end of one frame and the start of the next frame.
- If the receiver ever loses synchronization it can just search for two flag bytes to find the end of the current frame and the start of the next frame.
What if accidental unwanted flag bytes occur in the data?
To prevent from wrong flag bytes, escape byte (ESC) is inserted just before each ‘‘accidental’’ flag byte in the data. As shown in the figure below.
The data link layer on the receiving end removes the ESC before giving the data to the network layer. This technique is called byte stuffing.
What if accidental unwanted ESC occur in the data?
This unwanted ESC is also stuffed with an escape byte (ESC). As shown in the figure below.