pmd-pytcp
Pure-Python, zero-dependency TCP/IP stack — Ethernet through RFC 9293 TCP — running in user space on a TAP/TUN interface, embeddable in-process or run as a daemon, with a Berkeley-sockets API.
Decision gist · record as of 2026-08-14
Yes, with conditions. Install if you need a pure-Python, controllable TCP/IP stack for testing, simulation, or custom protocol work and can accept GPL-3.0-or-later licensing. The low install friction, active maintenance, and zero external dependencies (only internal PyTCP modules) make it straightforward to add. However, it is Alpha-status software; expect API changes and verify performance and stability for your use case before relying on it in production. Requires Linux and root/CAP_NET_ADMIN for interface setup.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Requires root or CAP_NET_ADMIN to create and configure TAP/TUN interfaces.
- Python >=3.9 required.
- Linux only (POSIX::Linux classifier).
License · maintenance · safety
GPL-3.0-or-later (copyleft) — GPL-3.0-or-later (copyleft): any code that links this library must be distributed under a compatible open-source license. Proprietary or closed-source projects cannot use it without a separate commercial license.
last release 2026-08-13 (1 days) · last repo commit 2026-08-10 · 376 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 108,065 downloads/mo, #12,580 on PyPI
Alternatives
Verify before relying
# In-process stack
from pmd_pytcp import socket, stack
stack.init()
stack.start()
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.connect(("10.0.1.1", 7))
sock.send(b"hello")
data = sock.recv(5)
sock.close()
stack.stop()
# Or daemon mode (separate process):
# Terminal 1: python -m pmd_pytcp.daemon --ipc-socket /tmp/pmd_pytcp.sock
# Terminal 2:
from pmd_pytcp.client import connect
from pmd_pytcp.socket import AddressFamily, SocketType
with connect(socket_path="/tmp/pmd_pytcp.sock") as client:
sock = client.socket(AddressFamily.INET4, SocketType.STREAM)
sock.connect(("10.0.1.1", 7))- Performance characteristics (throughput, latency) compared to kernel stack or other implementations.
- Stability and production readiness beyond Alpha status; known limitations or edge cases in RFC compliance.
- Multicast and IPv6 feature completeness (MLDv2/IGMP mentioned but not fully detailed).
- Scalability limits (number of concurrent sockets, interfaces, or packet throughput).
What it is and what it does
PyTCP is a complete TCP/IP stack written entirely in Python that runs in user space on TAP/TUN interfaces instead of relying on the kernel. It implements Ethernet II, ARP, IPv4/IPv6 with extension headers, ICMPv4/ICMPv6 (including multicast group membership), DHCPv4/DHCPv6, UDP, and a full RFC 9293 TCP with congestion control (Reno, NewReno, CUBIC), selective acknowledgment, and window scaling. The stack exposes a Berkeley-sockets API that mirrors the standard library socket module, so existing socket code can often run with minimal changes.
You can embed PyTCP directly in your Python process (calling stack.init(), stack.start(), then creating sockets) or run it as a daemon in a separate process and connect to it via an AF_UNIX control socket from client processes. The daemon model lets multiple processes share a single stack instance without each one needing to own the TAP/TUN interface. The implementation is fully typed, thread-safe for multi-interface setups, and designed to match Linux kernel behavior where RFCs are ambiguous. It ships with three independently published distributions: pmd-net-addr (address types), pmd-net-proto (packet parsing), and pmd-pytcp (the running stack).
Use it for
- Embedded network simulation or testing: run a full TCP/IP stack in a test harness without kernel privileges or system configuration.
- Custom protocol development: build and test new transport or application protocols on top of a controllable, inspectable stack.
- Network emulation or sandbox environments: isolate application network behavior in user space for security or reproducibility.
- Educational or reference implementation: study RFC-compliant TCP/IP behavior with readable, auditable Python source code.
- Daemon-based multi-process networking: share a single stack instance across multiple client processes via IPC.
- TAP/TUN-based VPN or overlay networking: implement custom network overlays or tunneling without kernel module development.
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes, with conditions.
Install if you need a pure-Python, controllable TCP/IP stack for testing, simulation, or custom protocol work and can accept GPL-3.0-or-later licensing. The low install friction, active maintenance, and zero external dependencies (only internal PyTCP modules) make it straightforward to add. However, it is Alpha-status software; expect API changes and verify performance and stability for your use case before relying on it in production. Requires Linux and root/CAP_NET_ADMIN for interface setup.
Install
pmd-pytcp on PyPI
Before you install
Low friction: three runtime dependencies (pmd-net-addr, pmd-net-proto, typing_extensions), all published by the same project. Active maintenance with a commit on 2026-08-10 and 376 repository stars. Alpha status (Development Status :: 3) means the API may still shift.
Requires root or CAP_NET_ADMIN to create and configure TAP/TUN interfaces. Python >=3.9 required. Linux only (POSIX::Linux classifier).
License in practice
GPL-3.0-or-later (copyleft): any code that links this library must be distributed under a compatible open-source license. Proprietary or closed-source projects cannot use it without a separate commercial license.
Quickstart
# In-process stack
from pmd_pytcp import socket, stack
stack.init()
stack.start()
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.connect(("10.0.1.1", 7))
sock.send(b"hello")
data = sock.recv(5)
sock.close()
stack.stop()
# Or daemon mode (separate process):
# Terminal 1: python -m pmd_pytcp.daemon --ipc-socket /tmp/pmd_pytcp.sock
# Terminal 2:
from pmd_pytcp.client import connect
from pmd_pytcp.socket import AddressFamily, SocketType
with connect(socket_path="/tmp/pmd_pytcp.sock") as client:
sock = client.socket(AddressFamily.INET4, SocketType.STREAM)
sock.connect(("10.0.1.1", 7))
Verify before relying
- Performance characteristics (throughput, latency) compared to kernel stack or other implementations.
- Stability and production readiness beyond Alpha status; known limitations or edge cases in RFC compliance.
- Multicast and IPv6 feature completeness (MLDv2/IGMP mentioned but not fully detailed).
- Scalability limits (number of concurrent sockets, interfaces, or packet throughput).
Package facts
| License | GPL-3.0-or-later copyleft |
| Python support | Supports the current Python release >=3.9 |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | 3 packagespmd-net-addrpmd-net-prototyping_extensions |
| Maintenance | Actively maintained 1 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 108,065 / month, #12,580 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Development Status :: 3 - AlphaEnvironment :: ConsoleNatural Language :: EnglishOperating System :: POSIX :: LinuxProgramming Language :: Python :: 3.14Topic :: System :: NetworkingTyping :: Typed |
Evidence: pmd_pytcp-0.3.7-py3-none-any.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “TCP/IP stack Python”
- pmd-pytcpA pure-Python TCP/IP stack (Ethernet through RFC 9293 TCP) that runs…
- pydivertPyDivert is a Python binding for the WinDivert Windows driver that…
- dpktdpkt parses and creates TCP/IP protocol packets with minimal…
Give your agent the search over MCP, or paste the wish link into any chat.
More Networking packages
h11 is a pure-Python HTTP/1.1 protocol implementation that handles parsing and serializing HTTP messages without any built-in I/O, letting you integrate it with any network layer you choose.
psutil retrieves real-time information about running processes and system resources (CPU, memory, disks, network, sensors) across multiple operating systems, enabling system monitoring, process profiling, and resource management.
pyOpenSSL wraps OpenSSL's SSL/TLS functionality for Python, providing high-level connection objects and certificate handling through a Python-friendly interface around OpenSSL's cryptographic operations.
uvloop is a drop-in replacement for Python's built-in asyncio event loop, implemented in Cython and using libuv, that accelerates async I/O operations.
execnet lets you spawn and communicate with Python interpreters across local processes, remote hosts, and different platforms, using a simple API for task distribution and inter-process messaging.
However, the aging maintenance status (275 days since last release) means you should verify it meets your concurrency and performance needs before committing to a…
PyZMQ provides Python bindings for ZeroMQ (ØMQ), a lightweight messaging library that enables fast, asynchronous communication between distributed processes and applications.
See also pmd-net-proto · pytun-pmd3 · icmplib · pymemcache · dpkt · clamav-client · port-for · pydivert · snitun · aioping