The contents of a frame is unrestricted, this can lead to problems, since an A, C, FCS or I-field byte that appears to be flag may occur. A Control Escape (CE) byte is defined as binary 01111101 (X’7D’). Prior to transmitting a frame a station examines each byte between the beginning and ending flags. For each byte it encounters with the same value as a flag or CE byte (X’C0’, X’C1’, or X’7D’) it does the following.
1. Inserts a control escape (CE) byte preceding the byte
2. Complements bit 5 of the byte (i.e. exclusive OR’s the byte with X’20’)
The sending algorithm is shown below in a programmatic form.
Sending Algorithm Calculate FCS over Payload data For each byte in payload data and FCS
{
If byte is BOF, EOF, or CE
{
Insert CE
Insert byte XOR X’20’
}
}
Prior to FCS computation, the receiving station also examines the entire frame contents between the flags.
For each CE byte encountered it does the following:
1. Discards the CE byte
2. Complements bit 5 of the byte following CE