smoltcp

A standalone, heap-free TCP/IP networking stack for bare-metal and embedded Rust systems.

Library
Cargo
v0.14.0
4,570stars
0BSD

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
87/100Excellent
Development Activity96
Maintenance72
Community80
Maturity60
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
84/100Excellent
Architecture93
Code Quality92
Innovation88
Learning Curve62

smoltcp is a standalone, event-driven TCP/IP stack written in Rust and designed for bare-metal, real-time systems. Its guiding goals are simplicity and robustness, and it deliberately avoids complicated compile-time tricks such as heavy macro or type machinery, even where that would trade away some performance.

Crucially, smoltcp needs no heap allocation at all, making it a natural fit for embedded targets and no_std environments, yet it still reaches roughly gigabit-per-second throughput against the Linux stack in loopback tests. It implements Ethernet, IPv4, IPv6, TCP, UDP, ARP, DHCPv4, DNS, and 6LoWPAN over IEEE 802.15.4, all behind fine-grained Cargo feature flags.

What You Get

  • A complete TCP/IP stack (Ethernet, ARP, IPv4/IPv6, TCP, UDP, ICMP) with no heap allocation
  • Socket types for TCP, UDP, raw, ICMP, DHCPv4, and DNS that you own and manage
  • Support for multiple mediums: Ethernet, bare IP, and IEEE 802.15.4 with 6LoWPAN
  • Fine-grained Cargo feature flags to compile in only the protocols you need
  • std physical layers (raw socket, TUN/TAP) plus a device trait for custom hardware

Common Use Cases

  • Adding networking to a no_std embedded device or RTOS-based firmware
  • Building a userspace network stack behind a TUN/TAP interface on Linux
  • Implementing a DHCP client or DNS resolver on constrained hardware
  • Running a low-power 6LoWPAN/802.15.4 IoT node

Under The Hood

Architecture - The crate is layered under src/: wire/ parses and emits packet formats (Ethernet, ARP, IPv4/6, TCP, UDP, ICMP, DHCP, DNS, 6LoWPAN); iface/ holds the Interface and routing/neighbor logic that ties the medium, IP, and socket layers together; socket/ implements the individual socket state machines; phy/ defines the Device trait and std-only raw-socket/TUN-TAP backends; storage/ provides the fixed-capacity ring and packet buffers that let the stack run without a heap. The whole thing is event-driven: the caller repeatedly polls the interface with the current time.

Tech Stack - Pure Rust on edition 2024, MSRV 1.91, with minimal dependencies: managed, heapless, byteorder, bitflags, and cfg-if, plus optional log/defmt for tracing and libc for the std physical layers. An extensive feature-flag matrix (medium-*, proto-*, socket-*, phy-*) controls exactly what is compiled.

Code Quality - Very high. The repo has ~2000 commits from 175 contributors, uses rstest and insta snapshot testing plus a fuzzing harness (cfg(fuzzing)), tracks coverage via codecov, and is extensively documented on docs.rs. The no-allocation, no-unsafe-tricks philosophy keeps the code auditable, which matters for a networking stack.

API Design - The public API is explicit and deterministic: you own the device, the socket set, and the poll loop, which suits real-time and embedded constraints where hidden allocation or threading is unacceptable. It is lower-level than a std socket API and thus has a steeper learning curve, but the numerous runnable examples (ping, httpclient, dhcp_client, dns, loopback benchmark) and thorough docs substantially ease onboarding.

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search