Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

92 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

usrnet

usrnet is a user space TCP/IP stack I'm writing to learn about networking. It is heavily inspired by smoltcp, an awesome well documented network stack which I used as a guide when building usrnet.

Building

An Ubuntu dev VM is provided via Vagrant to build usrnet and run the provided examples. Just...

  1. vagrant up && vagrant ssh
  2. cd /usrnet && cargo build && cargo test

... and that's it!

Examples

The examples directory contains simplified versions of some common networking programs. You can run them via cargo run --example <name> -- <args..>. As a basic sanity check you can run the dev_up example and issue a ping to 10.0.0.102 (default IP for example devices) and see if you get a response.

These examples use a Linux TAP interface to transmit raw ethernet frames. This means the examples will only run on a Linux system!

tap.sh provides a clear explanation of the network topology in use so you can debug any issues you may run into. You can update env.rs if you wish to change the network topology (e.g. IP address of your device) for running the examples.

Check out the documentation for more info.

Tests

In addition to unit tests, the tests directory contains smoke tests for some sample programs. These tests will only run successfully on a Linux system for the same reason as the examples. When developing on a different system, you can use cargo test --lib to avoid running these tests.

Features

I'm writing usrnet for learning purposes so it supports only the most basic features, many of which are not complete but are listed under Upcoming. Feel free to open an issue if you find a bug in an existing feature!

Ethernet

  • Uses Ethernet II frames for link layer
  • Supports unicast and broadcast Ethernet frames
  • Supports using and responding to ARP for IP/Ethernet address mapping
  • Supports Raw Ethernet sockets for writing programs like arping

IPv4

  • Uses default options for IPv4 headers found here
  • Supports a default gateway for routing to the internet
  • Supports ping with ICMP echo request/reply messages
  • Supports Raw IPv4 sockets for writing programs like ping

UDP

  • Supports UDP sockets for writing programs like UDP echo servers
  • Supports traceroute with ICMP destination unreachable responses to UDP packets with an unbound port

Upcoming

  • DNS lookup
  • DHCP address assignment
  • TCP sockets

Resources

About

user space TCP/IP stack written in Rust

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages