Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
M

microps

> 包管理
Open source

An implementation of a small TCP/IP protocol stack for learning.

1.3K stars0 likes2 views
WebsiteGitHub

About

An implementation of a small TCP/IP protocol stack for learning.

microps

microps is an implementation of a small TCP/IP protocol stack for learning.

  • If you love the Go language: https://github.com/pandax381/lectcp
  • Reimplementation in Rust: https://github.com/pandax381/microps-rs
  • Porting to xv6: https://github.com/pandax381/xv6-net
  • Porting to xv6-riscv: https://github.com/pandax381/xv6-riscv-net
  • Porting to MikanOS: https://github.com/pandax381/mikanos-net

Documents

  • Step by Step Development Guides (Japanese)

Books

  • ゼロからのTCP/IPプロトコルスタック自作入門/マイナビ出版 (Japanese)

Third-party implementations

  • microps-zig by @arata-nvm — Reimplementation in Zig

Features

Abstraction Layer

  • Physical device abstraction
    • Define structure for physical device abstraction (struct net_device)
    • Support multiple link protocols and physical devices
  • Logical interface abstraction
    • Define structure for logical interface abstraction (struct net_iface)
    • Support multiple address family and logical interfaces

Devices

  • Null
  • Loopback
  • Ethernet
    • TUN/TAP (Linux)
    • PF_PACKET (Linux)

Protocols

  • Ethernet
  • ARP
  • IP
  • ICMP
  • UDP
  • TCP

API

  • Socket like API

Logs

…

Tutorial

1. Build

$ git clone [email protected]:pandax381/microps.git
$ cd microps
$ make

2. Prepare Tap device

$ sudo ip tuntap add mode tap user $USER name tap0
$ sudo ip addr add 192.0.2.1/24 dev tap0
$ sudo ip link set tap0 up

It is temporary and will disappear after reboot.

3. Run sample application

$ ./app/tcps.exe 7
11:48:55.884 [I] net_protocol_register: registerd, type=ARP(0x0806) (net.c:223)
11:48:55.884 [I] net_timer_register: registerd: ARP Timer interval={1, 0} (net.c:257)
11:48:55.884 [I] net_protocol_register: registerd, type=IP(0x0800) (net.c:223)
...
11:48:55.884 [D] net_run: running... (net.c:324)
11:48:55.884 [D] tcp_bind: success: addr=0.0.0.0, port=7 (tcp.c:1156)

TCP Echo Server start on port 7. (default address is 192.0.2.2/24)

4. Test (Operate in another terminal)

  • Ping
$ ping 192.0.2.2
PING 192.0.2.2 (192.0.2.2) 56(84) bytes of data.
64 bytes from 192.0.2.2: icmp_seq=1 ttl=255 time=0.660 ms
64 bytes from 192.0.2.2: icmp_seq=2 ttl=255 time=0.688 ms
64 bytes from 192.0.2.2: icmp_seq=3 ttl=255 time=0.574 ms
...
  • TCP communication
$ nc 192.0.2.2 7
foo
foo
bar
bar

Sending text will be sent back by the Echo Server.

License

microps is under the MIT License: See LICENSE file.

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

Ctcp-iptcpip-stacktuntap

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category包管理
PricingOpen source

> Related tools

N
npm
Node.js 默认包管理器
P
pnpm
高效节省磁盘的 Node 包管理器
I
is-gif
Check if a Buffer/Uint8Array is a GIF image