NG_PRED1(4)

πŸ“¦ version 15.1, in freebsd 14.5, freebsd 15.1, nixpkgs unstable

πŸ‘‘ NG_PRED1 (4) β€” the Predictor-1 PPP compression netgraph node type, bestie edition

okay so you found a 4 page, that's a kernel interfaces manual, and this one is ng_pred1 β€” aka the Predictor-1 PPP compression (RFC 1978) netgraph node type πŸ’– literally the little guy that squishes your PPP frames down and pops them back out.


✨ SYNOPSIS ✨

#include <sys/types.h>
#include <netgraph/ng_pred1.h>

that's it, that's the whole vibe check. two includes and you're in 🫢


🌸 DESCRIPTION 🌸

okay so the pred1 node type implements the Predictor-1 sub-protocols of the Compression Control Protocol (CCP). no cap, that's its whole job.

the node has two hooks, comp for compression and decomp for decompression. and here's the ✨key✨ thing: only one of them can be connected at the same time, and whichever one it is? that's literally specifying the node's operation mode. main character hook energy πŸ’…

typically those hooks would be connected to the ng_ppp(4) node type hook of the same name β€” so <mint>comp</mint> to <mint>compress</mint>, <mint>decomp</mint> to <mint>decompress</mint>, you get it, iykyk.


πŸŽ€ HOOKS πŸŽ€

this node type supports the following hooks, and yes there are exactly two, count them:

  • comp β€” connection to the ng_ppp(4) compress hook. incoming frames are compressed and sent back out the same hook. πŸ”
  • decomp β€” connection to the ng_ppp(4) decompress hook. incoming frames are decompressed and sent back out the same hook. πŸ”
only one hook can be connected at the same time, specifying node's operation mode. pick a lane bestie, you cannot have both πŸ™ˆ

πŸ’… CONTROL MESSAGES πŸ’…

this node type supports the generic control messages, plus the following cuties:

  • NGM_PRED1_CONFIG (config) β€” this command resets and configures the node for a session (i.e., for compression or decompression). it takes a struct ng_pred1_config as an argument:
struct ng_pred1_config {
        u_char          enable;                 /* node enabled */
};

the enable field enables traffic flow through the node β€” like a little on/off switch for the vibes ⭐

  • NGM_PRED1_RESETREQ (resetreq) β€” this message contains no arguments, and is bi-directional. if an error is detected during decompression, this message is sent by the node to the originator of the NGM_PRED1_CONFIG message that initiated the session. the receiver should respond by sending a PPP CCP Reset-Request to the peer. πŸ“¨

this message may also be received by this node type when a CCP Reset-Request or Reset-Ack is received by the local PPP entity. the node will respond by flushing its compression state so the sides can resynchronize. so civilised honestly 🧚

  • NGM_PRED1_GET_STATS (getstats) β€” this control message obtains statistics for a given hook. the statistics are returned in struct ng_pred1_stats:
struct ng_pred1_stats {
        uint64_t        FramesPlain;
        uint64_t        FramesComp;
        uint64_t        FramesUncomp;
        uint64_t        InOctets;
        uint64_t        OutOctets;
        uint64_t        Errors;
};

look at all those uint64_ts, the numbers are NUMBERS-ing πŸ“

  • NGM_PRED1_CLR_STATS (clrstats) β€” this control message clears statistics for a given hook. poof, gone, fresh start πŸ’€
  • NGM_PRED1_GETCLR_STATS (getclrstats) β€” this control message obtains and clears statistics for a given hook. read it and yeet it, iconic behaviour πŸ‘‘

πŸ¦‹ SHUTDOWN πŸ¦‹

this node shuts down upon receipt of a NGM_SHUTDOWN control message, or when hook have been disconnected. that's it, that's the exit strategy, bye bestie πŸ‘‹


🌈 SEE ALSO 🌈


πŸ’œ AUTHORS πŸ’œ

Alexander Motin <mav@alkar.net>


😭 BUGS 😭

ngl this one's a real one. due to nature of netgraph PPP implementation there are possible race conditions between data packet and ResetAck CCP packet in case of packet loss. as result, packet loss can produce bigger performance degradation than supposed by protocol. so like… not a vibe, but now you know 🫢


and that's the whole page bestie, no notes. this beauty is from the Debian crew, dated December 24, 2006, and it lives at NG_PRED1(4) β€” go compress something responsibly πŸ’–βœ¨πŸŽ€

πŸ“¦ where this page comes from