Subject: Escape Error in HDLC Framing

From: [email-masked]
Date: Tue, 22 May 2001 09:45:09 -0400

I apologize if this is off-topic. Please ignore if it is.

NOTE: I am keeping track of the following counts:

   1. Total valid frames (i.e. every frame, except invalid).
   2. Total FCS errored frames
   3. Total invalid frames

Invalid HDLC Frames (which are dropped), can be sub-classified as:

   1. Short frames; or
   2. Escape errors (0x7d followed by 0x7e).

It is #2 that concerns me with regard to how to proceed AFTER the escape
error has been detected. As I see it, there are two ways to go about it.

(1)
   real frame start                                  real frame end
     0x7E .............. 0x7D 0x7E .......................... 0x7E
     |----------escape error-----|----------fcs error------------|

   escape error is detected and an invalid frame is counted. then,   count
   the '7e' in the escape error as the start of the next frame,   likely
   leading to an FCS error or possibly a short frame error.

----OR----

(2)
   real frame start                                  real frame end
     0x7E .............. 0x7D 0x7E .......................... 0x7E
     |----------escape error-----|-------ignore to next 7E-------|

   escape error is detected, but the '7e' in the escape error is NOT
   considered the start of the next frame. The next frame is not
   considered to have started until another '7E' is encountered.

These approaches provided very different results with respect to the
counters I am tracking. Unfortunately, the RFC RE: PPP over HDLC does (1662)
not address how to resolve this issue.

Thanks for your help.

---

From: James Carlson <[email-masked]>
Date: Tue, 22 May 2001 10:14:55 -0400 (EDT)

> I apologize if this is off-topic. Please ignore if it is.

Nope; this is right on-topic.

>    2. Escape errors (0x7d followed by 0x7e).

You should be counting these separately.  The latter case is actually
an aborted frame.  See RFC 1662:

   On reception, prior to FCS computation, each octet with value less
   than hexadecimal 0x20 is checked.  If it is flagged in the receiving
   ACCM, it is simply removed (it may have been inserted by intervening
   data communications equipment).  Each Control Escape octet is also
   removed, and the following octet is exclusive-or'd with hexadecimal
   0x20, unless it is the Flag Sequence (which aborts a frame).

> error has been detected. As I see it, there are two ways to go about it.

You just start with a clean slate.  You're in a new frame.

[...]
>    leading to an FCS error or possibly a short frame error.

Version (1) is the proper handling.

> not address how to resolve this issue.

Actually, it does.  7E on the line is a frame end marker.  Always.
There are no exceptions at all.

4.1.  Flag Sequence

   The Flag Sequence indicates the beginning or end of a frame.  The
   octet stream is examined on an octet-by-octet basis for the value
   01111110 (hexadecimal 0x7e).

-- 
James Carlson, Internet Engineering       <[email-masked]>
SUN Microsystems / 1 Network Drive         71.234W   Vox +1 781 442 2084
MS UBUR02-212 / Burlington MA 01803-2757   42.497N   Fax +1 781 442 1677