[][src]Crate smolapps

Collection of application-layer protocols built on top of smoltcp.

This crate aims to follow the same guinding principles of smoltcp: simplicity and robustness. It is a #![no_std]-first crate, designed for bare-metal, real-time systems. Heap allocations (if at all present) are reduced to a minimum, and will always be feature gated.

The following protocols are implemented at this time:

  • Simple Network Time Protocol (SNTPv4)
  • Trivial File Transfer Protocol (TFTP)

All protocols are feature-gated. This reduces both compilation time and binary size, the latter being a strong limiting factor in bare-metal applications.

For convenience, this crate re-exports smoltcp under the net name.

Examples

Examples on how to use the protocols and their implementations in this crate can be found in the source repository. All examples are provided to run on a hosted Linux environment.

Before running the examples, you need to create a TAP interface with Internet access usable by non-privileged users.

To spawn a TAP interface named tap0, run the following commands:

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

To forward IPv4 traffic to/from the interface, run:

sudo iptables -t nat -A POSTROUTING -s 192.168.69.0/24 -j MASQUERADE
sudo sysctl net.ipv4.ip_forward=1

Adjust the interface IP appropriately if you happen to already be on a 192.168.69.0/24 network. If you do, remember to adjust the example accordingly.

Features

The following features can be enabled at the crate level:

sntp

Compiles the SNTP protocol and client implementation. It has a dependency on socket-udp. Enabled by default.

tftp

Compiles the TFTP protocol and server implementation. It has a dependency on socket-udp. Enabled by default.

Re-exports

pub use smoltcp as net;

Modules

sntp

Simple Network Time Protocol client implementation.

tftp

Trivial File Transfer Protocol server implementation.