NG_DEFLATE(4)
π ng_deflate β bestie's guide to Deflate PPP compression
okay so real talk: this page is from the Kernel Interfaces Manual, and the thing it's describing is ng_deflate(4) β the netgraph node type that does Deflate PPP compression (RFC 1979). yes it's a whole mouthful. no i will not be shortening it. π
β¨ NAME β¨
ng_deflate β the Deflate PPP compression (RFC 1979) netgraph node type. that's the whole name. slay. π
π¦ SYNOPSIS π¦
#include <sys/types.h>
#include <netgraph/ng_deflate.h>
that's it, that's the vibe check. two includes and you're in. β¨
π DESCRIPTION π
okay so the deflate node type implements the Deflate sub-protocols of the Compression Control Protocol (CCP). that's the main character energy right there.
the node has two hooks: comp for compression and decomp for decompression. only one of them can be connected at the same time β and whichever one is connected is literally what specifies the node's operation mode. π₯
typically those hooks get connected to the ng_ppp(4) node type hook of the same name β like, comp to comp, decomp to decomp, iykyk. and heads up: the corresponding ng_ppp(4) node hook must be switched to NG_PPP_DECOMPRESS_FULL mode to permit sending uncompressed frames. don't skip that step bestie, it's giving important. β
πΈ HOOKS πΈ
this node type supports the following hooks, and honestly? there are only two and they're both iconic:
compβ connection to theng_ppp(4)comphook. incoming frames are compressed (if possible) and sent right back out the same hook. cute, right? πdecompβ connection to theng_ppp(4)decomphook. incoming frames are decompressed (if they are compressed), and sent back out the same hook.
and again, for the people in the back: only one hook can be connected at the same time, and that's what specifies the node's operation mode. periodt. π
π CONTROL MESSAGES π
this node type supports the generic control messages, plus these iconic ones:
NGM_DEFLATE_CONFIG(config) β this command resets and configures the node for a session (i.e., for compression or decompression). it takes astruct ng_deflate_configas an argument:
struct ng_deflate_config {
u_char enable; /* node enabled */
u_char windowBits; /* log2(Window size) */
};
the enabled field enables traffic flow through the node β¨ and the windowBits specify compression windows size as negotiated by the Compression Control Protocol (CCP) in PPP. no cap.
NGM_DEFLATE_RESETREQ(resetreq) β this message contains no arguments, and it's bi-directional. if an error is detected during decompression, this message is sent by the node to the originator of theNGM_DEFLATE_CONFIGmessage 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. it's giving teamwork honestly. π
NGM_DEFLATE_GET_STATS(getstats) β this control message obtains statistics for a given hook. the stats come back instruct ng_deflate_stats:
struct ng_deflate_stats {
uint64_t FramesPlain;
uint64_t FramesComp;
uint64_t FramesUncomp;
uint64_t InOctets;
uint64_t OutOctets;
uint64_t Errors;
};
NGM_DEFLATE_CLR_STATS(clrstats) β this control message clears statistics for a given hook. bye bye numbers π§ΉNGM_DEFLATE_GETCLR_STATS(getclrstats) β this control message obtains and clears statistics for a given hook. multitasking queen behavior. π
β 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. π
π₯ SEE ALSO π₯
netgraph(4)ng_ppp(4)ngctl(8)- J. Woods, PPP Deflate Protocol, RFC 1979.
- W. Simpson, The Point-to-Point Protocol (PPP), RFC 1661.
go read them. i'll wait. π
π AUTHORS π
Alexander Motin <mav@alkar.net> β the legend who wrote this. show some respect. π
π BUGS π
ngl there's a real one, so listen up: 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 yeah β lose a packet and the perf hit might be bigger than the protocol was ever supposed to give you. that's not a vibe, that's just the truth.
and that's the whole page bestie!! this one's from the Debian build, dated December 23, 2006 β old enough to be a vintage, still out here compressing packets with main character energy. go forth and deflate responsibly π«Άπβ¨
π¦ where this page comes from
- freebsd 14.5: base 14.5
- freebsd 15.1: base 15.1
- nixpkgs unstable: source
- Copyright (c) 2006, Alexander Motin <mav@alkar.net>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms