Rust embedded network stack
Go to file
whitequark 4421b2fe27 Implement ARP replies. 2016-12-12 07:19:53 +00:00
examples Implement ARP replies. 2016-12-12 07:19:53 +00:00
src Implement ARP replies. 2016-12-12 07:19:53 +00:00
.gitignore Implement Ethernet II frame support. 2016-12-10 09:55:45 +00:00
Cargo.toml Implement raw socket interface and tcpdump. 2016-12-10 16:58:30 +00:00
LICENSE-APACHE Implement Ethernet II frame support. 2016-12-10 09:55:45 +00:00
LICENSE-MIT Implement Ethernet II frame support. 2016-12-10 09:55:45 +00:00
README.md Implement ARP replies. 2016-12-12 07:19:53 +00:00

README.md

smoltcp

smoltcp is a standalone, event-driven TCP/IP stack that is designed for bare-metal, real-time systems. Its design goals are simplicity and robustness. Its design anti-goals include complicated compile-time computations, such as macro or type tricks, even at cost of performance degradation.

Features

smoltcp is missing many widely deployed features, whether by design or simply because no one implemented them yet. To set expectations right, both implemented and omitted features are listed.

Media layer

The only supported medium is Ethernet.

  • Regular 802.3 frames are supported.
  • 802.1Q is not supported.
  • Jumbo frames are not supported.
  • CRC calculation is not supported.
  • ARP packets are supported.
  • ARP probes or announcements are not supported.

IP layer

IP is not supported yet.

UDP layer

UDP is not supported yet.

TCP layer

TCP is not supported yet.

Installation

To use the smoltcp library in your project, add the following to Cargo.toml:

[dependencies]
smoltcp = "0.1"

Usage example

smoltcp, being a userspace networking stack, needs to be able to send and receive raw frames. This normally requires superuser privileges, but on Linux it is possible to create a persistent tap interface that can be manipulated by a specific user:

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

smoltcpdump

smoltcpdump is a tiny clone of the tcpdump utility.

Unlike the rest of the examples, it uses raw sockets, and so it can be used on regular interfaces, e.g. eth0 or wlan0, as well as the tap0 interface we've created above.

Read its source code, then run it as:

cargo build --example smoltcpdump
sudo ./target/debug/smoltcpdump eth0

smoltcpserver

smoltcpserver emulates a network host that can serve requests.

The host is assigned the hardware address 02-00-00-00-00-01 and IPv4 address 192.168.69.1.

Read its source code, then run it as:

cargo run --example smoltcpserver -- tap0

It responds to:

  • pings (ping 192.168.69.1) (actually not yet).

License

smoltcp is distributed under the terms of both the MIT license and the Apache License (Version 2.0).

See LICENSE-APACHE and LICENSE-MIT for details.