Audit the Stuffing Overhead and Marker Guarantee

Audit the Stuffing Overhead and Marker Guarantee

Ada measures byte- and bit-stuffing overhead and proves the boundary marker is unique

foundations
math-foundations
framing
protocols
intermediate
Ada ADA · CALCULATION AUDIT

Audit the Stuffing Overhead and Marker Guarantee

To find message boundaries, the chapter marks frames with the flag byte 7E and then must stop ordinary data from imitating it. Byte stuffing escapes any payload byte equal to 7E, while bit stuffing inserts an extra 0 after five consecutive 1 bits, so the data stream can never reproduce the marker. This audit measures the overhead each mechanism adds and proves the boundary guarantee holds: how many extra bits or bytes does stuffing cost, and can payload data ever look like the marker?

Companion to the chapter Packet Framing — every number here comes from that chapter.

A framing marker is a physical signal pattern as well as a parsing rule: count the bits or bytes the transmitter adds, then prove the data stream cannot imitate the boundary.

See the relationship before changing it

The figure reads from left to right. The blue card is consecutive-one run. The middle card applies this page's rule. The green card is stuffing expansion. Walk the arrows once: set the input, apply the rule, then read the result with its unit.

The retained audit below checks several chapter fixtures. This model keeps those stated values fixed and changes only consecutive-one run, so the numeric fixture does not switch without explanation.

Consecutive-one run changes stuffing expansion An input card leads through the rule run expansion = one inserted bit / run length x 100 to the stuffing expansion result. INPUT PAGE INPUT APPLY THE RULE predict calculate check units OUTPUT RESULT
Walk the arrows. Bit stuffing pays one extra bit after the forbidden run so payload cannot imitate the flag.

Derive the baseline in four named moves

  1. 1

    Name the input. The chapter baseline is 5 bits.

  2. 2

    Name the relationship. run expansion = one inserted bit / run length x 100

  3. 3

    Substitute with units. 1 / 5 x 100 = 20.0%

  4. 4

    Read the result. Keep the unit beside the value. Use it only inside the technical boundary on this page.

Predict, then change consecutive-one run

Try Predict the direction of run expansion = one inserted bit / run length x 100. Test another consecutive-one run, then compare stuffing expansion.

5 bits
Chapter baseline
Stuffing expansion

Observe Bit stuffing pays one extra bit after the forbidden run so payload cannot imitate the flag. Reset consecutive-one run to 5 and compare stuffing expansion.

Explain Bit stuffing pays one extra bit after the forbidden run so payload cannot imitate the flag.

Check yourself

What should you do before trusting a moved-control result?
Answer: Predict its direction, apply the shown relationship, keep the units, and reset to the worked baseline.
What does this small model leave out?
Answer: Only consecutive-one run moves here. Field effects named in the technical boundary stay fixed.
TryPress Calculate on a payload containing flag byte 7E and on a run of five consecutive 1 bits.
ObserveThe overhead result adds one escape byte in the first case and inserts a 0 bit after the five-one run in the second.
ExplainStuffing transforms any marker-like payload sequence, preserving the invariant that an unescaped 7E or flag bit pattern can only be a frame boundary.

Ready: use the stated baseline inputs, then compare each displayed result.

1. Byte stuffing for the chapter's flag example

The escaping figure uses flag byte 7E. When a payload byte is itself 7E, the transmitter sends an escaped pair instead of the single data byte:

1 payload byte that equals 7E → 2 transmitted bytes
extra bytes = 2 - 1 = 1 byte; expansion for that byte = 1 / 1 = 100%

The overhead is local to ambiguous bytes: ordinary payload bytes still cost one transmitted byte each, while each flag-valued payload byte pays one extra escape byte.

2. Bit stuffing blocks a false marker

The chapter states that bit stuffing inserts one 0 after five consecutive 1 bits. A run of five payload ones therefore becomes six transmitted bits:

11111 → 111110
extra bits = 6 - 5 = 1 bit; expansion for that run = 1 / 5 = 0.20 = 20%

The common flag byte 0x7E is binary 01111110, which contains six consecutive ones. Because the transmitter inserts a 0 immediately after any five data ones, payload data cannot produce that six-one run on the wire.

Mechanism Chapter value Audit result
Byte stuffing Payload byte equals 7E 1 extra byte for that ambiguous byte
Bit stuffing Insert 0 after five 1 bits 1 extra bit per five-one run, or 20% for that run
Boundary guarantee 0x7E = 01111110 Six consecutive data ones cannot appear unstuffed

What the mathematics buys you: escaping is not magic; it is a measurable overhead paid to preserve a parser invariant. The receiver can trust a delimiter only because the transmitter proves that ordinary data cannot look like the delimiter.

Technical boundaries
Noise, clock recovery, CRC detection, escape-byte corruption, resynchronization, and retransmission are outside this deterministic stuffing audit; it counts only the fixed 7E and five-one fixtures.

Every number above is taken from this chapter's own worked example and re-derived step by step.