SmolNet - A user-mode tcp/ip stack

SmolNet is an Elixir library for running independent TCP/IP stacks within an OTP application. Built on Rust’s smoltcp, it supports IPv4 and IPv6 over an application-defined raw-IP transport and provides familiar :gen_tcp and :gen_udp interfaces alongside a lower-level socket API. Precompiled native components are available for Linux and Apple Silicon macOS.

Why a userspace network stack?

BEAM applications normally use the host kernel’s network stack, which is the right choice for ordinary clients and servers. An application-owned stack is useful when packets need to travel over something other than a host network interface, or when a program needs isolated addresses, routes, sockets, and failure domains. Examples include encrypted tunnels, network simulations, packet-level tests, and application-defined transports.

gVisor’s Netstack is a larger example of the same architectural idea: its Go userspace network stack lets a sandbox handle network protocols without giving the application direct access to the host network stack. SmolNet applies that idea at a smaller scale for Elixir. It combines smoltcp’s protocol implementation with OTP supervision, bounded native work, and standard Erlang socket interfaces.

SmolNet is transport-neutral. It does not provide an Ethernet device, TUN/TAP setup, or a VPN protocol. Your link process decides where emitted raw IP packets go and feeds packets from that transport back into the stack.

3 Likes

SmolNet 0.7.0 is now available.

This release improves how SmolNet’s TCP behaves on real networks, bringing it closer to Linux. It adds congestion control, faster recovery from packet loss, and path MTU discovery. A connection whose peer has gone away now fails with an error after about 15 minutes instead of retrying indefinitely, and an optional keepalive setting detects dead peers on idle connections. TLS connections can now run over SmolNet using Erlang’s :ssl.

1 Like