3

How does the receiver determine the length of a PPP frame (not PPPoE or PPPoA)? Structure of a PPP frame shows no length field. Sure, at the end of the frame there is a 2-byte checksum followed by a magic byte, but that is hardly collision-proof.

2 Answers 2

3

The PPP header starts with a 16-bit protocol id. You need to look at that first in order to know how to interpret the rest.

If the protocol id is LCP/IPCP/IPv6CP then the header structure typically looks like this:

struct PPP {
    uint16_t protocolId;
    uint8_t code;
    uint8_t identifier;
    uint16_t length; // <= network-encoded length field
};

If the protocol id is IPv4 or IPv6 then the IP header comes immediately after the protocol id. Both IPv4 and IPv6 have a length field in their headers.

I'm not familiar with HDLC frames, but I assume you are receiving them from a socket. The socket read/receive function would provide you with the size of each incoming frame. So you can use that for validation purposes as well.

1
  • 1
    As this answer states the inner protocol is identified and that can have a self contained length field. Further to this there is a Flag Sequence which signals the end of the outer PPP header itself: tools.ietf.org/html/rfc1662#section-4
    – Baldrick
    May 17, 2017 at 11:06
4

Sure, there is a 2-byte checksum followed by a magic byte, but that is hardly collision-proof.

Occurrences of the magic byte are escaped. There are two types of escaping used, called "character stuffing" and "bit stuffing".

https://technet.microsoft.com/en-us/library/cc957975.aspx

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.