Need for framing
Since the physical layer merely accepts and transmits a stream of bits without any regard to meaning or structure, it is upto the data link layer to create and recognize frame boundaries. This can be accomplished by attaching special bit patterns to the beginning and end of the frame. If these bit patterns can accidentally occur in data, special care must be taken to make sure these patterns are not incorrectly interpreted as frame delimiters.
This is how the bits will be transmitted for frame A B ESC FLAG:
a. Character count
b. Flag bytes with byte stuffing
c. Starting and Ending flag bytes, with bit stuffing