NG_VJC(4)

✨ NG_VJC β€” the Van Jacobson compression netgraph node type ✨

okay bestie, sit DOWN because today we're talking about ng_vjc(4), the Kernel Interfaces Manual's own certified TCP-header-shrinking icon πŸ’…


πŸŽ€ SYNOPSIS πŸŽ€

#include <sys/types.h>
#include <netinet/in.h>
#include <netinet/in_systm.h>
#include <netinet/ip.h>
#include <net/slcompress.h>
#include <netgraph/ng_vjc.h>

🌸 DESCRIPTION 🌸

so the vjc node type does Van Jacobson compression, which is the whole girlboss move used over PPP, SLIP, and other point-to-point IP connections to squish down TCP packet headers. it's giving weight loss journey but for headers, and honestly? obsessed πŸ¦‹

here's the hook layout, no cap:

  • the ip hook is the uncompressed side of the node
  • the vjcomp, vjuncomp, and vjip hooks are the compressed side of the node

packets that show up on ip get compressed or passed through as appropriate. packets that show up on the other three hooks get uncompressed as appropriate. this node also supports "always pass through" mode in either direction β€” it's flexible like that, main character energy ✨

lowkey important: Van Jacobson compression only applies to TCP packets. periodt.

only "normal" (i.e. common case) TCP packets are actually compressed, and those go out on the vjcomp hook. other TCP packets get run through the state machine but not compressed β€” those pop out on the vjuncomp hook. and other non-TCP IP packets are forwarded unchanged to vjip. the way that it just sorts them like that… a system πŸ’œ

when you're connecting to an ng_ppp(4) node, here's the pairing, memorize it bestie:

(ok yes, the ordering looks like it's playing tricks on you β€” that's literally what the page says, so we're saying it too, fr fr πŸ™ˆ)


πŸ¦‹ HOOKS πŸ¦‹

this node type supports the following hooks, and yes we're listing all of them:

  • ip β€” upstream (uncompressed) IP packets.
  • vjcomp β€” downstream compressed TCP packets.
  • vjuncomp β€” downstream uncompressed TCP packets.
  • vjip β€” downstream uncompressed IP packets.

πŸ‘‘ CONTROL MESSAGES πŸ‘‘

this node type supports the generic control messages, plus these iconic ones:

  • NGM_VJC_SET_CONFIG (setconfig) β€” this command resets the compression state and configures it according to the supplied struct ngm_vjc_config argument. that structure contains the following fields:
struct ngm_vjc_config {
  u_char   enableComp;    /* Enable compression */
  u_char   enableDecomp;  /* Enable decompression */
  u_char   maxChannel;    /* Number of outgoing channels - 1 */
  u_char   compressCID;   /* OK to compress outgoing CID's */
};
  • when enableComp is set to zero, all packets received on the ip hook are forwarded unchanged out the vjip hook. πŸ’€
  • similarly, when enableDecomp is set to zero, all packets received on the vjip hook are forwarded unchanged out the ip hook, and packets are not accepted on the vjcomp and vjuncomp hooks.
  • when a node is first created, both compression and decompression are disabled, so the node is operating in bi-directional "pass through" mode. brand new node, no thoughts, just vibes 🌈
  • when enabling compression, maxChannel should be set to the number of outgoing compression channels minus one, and is a value between 3 and 15, inclusive. (so like, 3 through 15. do not freestyle this number bestie 😭)
  • the compressCID field says whether it's OK to compress the CID header field for outgoing compressed TCP packets. this value should be zero unless either (a) it is not possible for an outgoing frame to be lost, or (b) lost frames can be reliably detected and immediately reported to the peer's decompression engine (see NGM_VJC_RECV_ERROR below).
  • NGM_VJC_GET_STATE (getstate) β€” this command returns the node's current state, described by the struct slcompress structure, which is defined in <net/slcompress.h>. she's showing you her whole state, transparent queen πŸ’…
  • NGM_VJC_CLR_STATS (clrstats) β€” clears the node statistics counters. stats are also cleared whenever the enableComp or enableDecomp fields are changed from zero to one by a NGM_VJC_SET_CONFIG control message. fresh start, clean slate ✨
  • NGM_VJC_RECV_ERROR (recverror) β€” when the peer has CID header field compression enabled, this message must be sent to the local vjc node immediately after detecting that a received frame has been lost, due to a bad checksum or for any other reason.
⚠️ real talk: failing to do that can result in corrupted TCP stream data. this is not a drill, this is not optional, send the message 🚨

🧚 SHUTDOWN 🧚

this node shuts down when it receives a NGM_SHUTDOWN control message, or when all hooks have been disconnected. she leaves when everyone else leaves, that's just the rules 🌸


πŸ”₯ SEE ALSO πŸ”₯


⭐ HISTORY ⭐

the ng_vjc node type was implemented in FreeBSD 4.0. a legend from day one, iykyk πŸ‘‘


πŸ’– AUTHORS πŸ’–

Archie Cobbs <archie@FreeBSD.org> β€” the moment, the icon, the blueprint 🫢


πŸ’€ BUGS πŸ’€

ok so, gathering all the little gremlins:

  • as the initialization routine in the kernel implementation of Van Jacobson compression initializes both compression and decompression at once, this node does not allow compression and decompression to be enabled in separate operations. so if you want to enable one while the other is already enabled, you have to first disable both, then enable both. this, of course, resets the node state. 😭 this restriction may be lifted in a later version β€” manifesting it fr fr πŸ™
  • when built as a loadable kernel module, this module includes the file net/slcompress.c. although loading the module should fail if net/slcompress.c already exists in the kernel, currently it does not, and the duplicate copies of the file do not interfere. however, this may change in the future. so like, noted, bestie 🚩

and that's the whole page, mwah πŸ’… this little writeup came to you from the <strong>Debian</strong> crew, dated <strong>January 19, 1999</strong>, filed under <strong>NG_VJC(4)</strong> β€” yes she's been serving this documentation since the 90s and she's still that girl πŸŽ€

πŸ“¦ where this page comes from