Glossary
mbuf
The 4.4 BSD memory buffer type. The atomic unit of networking memory in XNU — small inline payloads or pointers to clusters, chained to form a packet.
An mbuf (memory buffer) is the atomic unit of networking memory in XNU's classic stack. Inherited verbatim from 4.4 BSD; the type and API are unchanged for thirty years.
An mbuf is a small structure (typically 256 bytes) that can hold either:
- A short inline payload (the small case — TCP headers, ACK-only packets).
- A pointer to an external cluster (the large case — frame payloads up to a few KB).
mbufs chain via a next pointer. A complete packet is typically a chain: a header mbuf + one or more cluster mbufs. Protocols prepend their own headers by prepending mbufs to the chain, no payload copy required.
apple-oss-distributions/xnubsd/sys/mbuf.hThe mbuf structure and flags.View on GitHub(line —) apple-oss-distributions/xnubsd/kern/uipc_mbuf.cAllocation, free, chaining, header manipulation.View on GitHub(line —)
When a NIC receives a packet, the driver allocates an mbuf (from a per-CPU cache), DMAs the frame into the cluster, hands the chain to the protocol input. mbufs walk up the protocol switch table (Ethernet → IP → TCP) before landing in a socket buffer.
The mbuf model is being supplemented by Apple's Skywalk for higher-throughput paths.
See also: Skywalk, the network stack article.