smoltcp is a standalone, event-driven TCP/IP stack for bare-metal and real-time Rust systems. It avoids heap allocation and documents protocols from Ethernet through TCP and UDP.
Overview
smoltcp implements networking for embedded and freestanding environments where a full operating-system stack is unavailable or undesirable. Design emphasis is on simplicity and robustness rather than compile-time cleverness.
Supported media include Ethernet II, IPv4 and IPv6, and IEEE 802.15.4 with 6LoWPAN compression. Socket types cover raw, UDP, TCP, ICMP, DHCPv4, and DNS when enabled via Cargo features. TCP includes window scaling, reassembly, keep-alive, Nagle's algorithm, and optional CUBIC or Reno congestion control.
The crate compiles on stable Rust without requiring a global allocator by default, though optional std or alloc integrations exist. Feature flags control logging, physical interfaces such as raw sockets or TUN/TAP on hosted Linux tests, and compile-time buffer sizing through Cargo features or SMOLTCP_* environment variables.
Hosted examples on Linux use TUN/TAP or raw sockets to exercise the stack in userspace, including fault injection and pcap tracing utilities.
Key features
- Ethernet, IPv4, IPv6, and 6LoWPAN
- TCP, UDP, ICMP, DHCPv4, DNS sockets
- Configurable reassembly and routing
- IGMP and IPv4 multicast support
- Optional CUBIC and Reno TCP congestion control
- Cargo feature-tuned buffer sizes
- Linux TUN/TAP and raw socket PHY helpers
Use cases
- Embedded firmware networking
- Bare-metal Rust IoT devices
- Testing stacks in Linux userspace
- Lightweight TCP/UDP on microcontrollers