Skip to content

A network stack for the XV6 operating system, written in Rust.

License

Notifications You must be signed in to change notification settings

progbits/xv6-net

This branch is 137 commits ahead of mit-pdos/xv6-public:master.

Folders and files

NameName
Last commit message
Last commit date

Latest commit

d90db1e · Jul 30, 2023
Jul 30, 2023
Oct 15, 2008
Sep 5, 2011
Sep 21, 2009
Dec 9, 2022
Sep 5, 2007
Aug 30, 2018
Jan 23, 2023
Sep 7, 2006
Aug 10, 2020
Jan 29, 2023
Aug 4, 2014
Oct 16, 2022
Oct 16, 2022
Aug 10, 2016
Oct 16, 2022
Oct 16, 2022
Oct 16, 2022
Dec 20, 2022
Aug 27, 2007
Jun 30, 2015
Jan 23, 2023
Sep 3, 2008
Oct 16, 2022
Oct 16, 2022
Aug 10, 2016
Aug 10, 2016
Oct 16, 2022
Oct 16, 2022
Oct 16, 2022
Oct 16, 2022
Oct 16, 2022
Oct 16, 2022
Oct 16, 2022
Nov 23, 2009
Oct 16, 2022
Oct 16, 2022
Oct 16, 2022
Aug 11, 2016
Oct 16, 2022
Oct 16, 2022
Oct 16, 2022
Oct 16, 2022
Jan 22, 2020
Oct 16, 2022
Oct 16, 2022
Oct 16, 2022
Oct 16, 2022
Oct 16, 2022
Jan 23, 2023
Oct 16, 2022
Oct 16, 2022
Oct 16, 2022
Oct 16, 2022
Oct 16, 2022
Oct 16, 2022
Oct 16, 2022
Jan 29, 2023
Oct 16, 2022
Oct 16, 2022
Oct 16, 2022
Jul 13, 2009
Oct 16, 2022
Aug 24, 2012
Oct 16, 2022
Oct 16, 2022
Oct 16, 2022
Aug 30, 2018
Aug 30, 2018
Aug 29, 2014
Feb 20, 2011
Oct 16, 2022
Aug 22, 2007
Sep 6, 2006
Oct 12, 2007
Oct 16, 2022
Oct 16, 2022
Oct 16, 2022
Oct 16, 2022
Oct 12, 2007
Oct 16, 2022
Oct 16, 2022
Oct 16, 2022
Aug 30, 2018
Jan 23, 2023
Jan 23, 2023
Oct 16, 2022
Oct 16, 2022
Sep 2, 2011
Aug 28, 2007
Dec 29, 2022
Aug 9, 2017
Nov 5, 2022
Nov 7, 2022
Oct 16, 2022
Oct 16, 2022
Oct 16, 2022
Jan 29, 2023
Oct 16, 2022
Jan 23, 2023
May 31, 2009
Oct 16, 2022
Oct 16, 2022
Oct 22, 2022
Oct 16, 2022

Repository files navigation

xv6-net

A network stack for the xv6 operating system, written in Rust.

Getting Started

Prerequisites

Building and running the xv6-net the project requries the following dependencies:

  • A C compiler (e.g. GCC)
  • Make
  • Rust (and the i586-unknown-linux-gnu toolchain)
  • QEMU

On Ubuntu-like operating systems, a C compiler (GCC) and Make can be installed as part of the build-essential package:

sudo apt-get install build-essential

Rust can be installed by following the instructions on the Rust project's homepage. The i586-unknown-linux-gnu toolchain can be installed using the rustup tool:

rustup toolchain install i586-unknown-linux-gnu

QEMU can be installed via the qemu package:

apt-get install qemu

Running the Project

In addition to the standard Make targets provided by the xv6 project, the xv6-net project adds a qemu-net Make target. This target uses QEMU's -nic flag to emulate an E1000 family network device. The -nic flag creates a new TAP device which may require root privileges.

The xv6 network stack supports a single interface which is assigned a fixed address of 10.0.0.2.

The project can be built with make:

$ make

Once built, the xv6 operating system can be started with the qemu-net target:

$ make qemu-net

After assigning an address to the TAP interface:

$ ip addr add 10.0.0.2 dev tap0

The xv6 operating system should respond to ping.

$ ping 10.0.0.2
PING 10.0.0.2 (10.0.0.2) 56(84) bytes of data.
64 bytes from 10.0.0.2: icmp_seq=1 ttl=64 time=0.026 ms
64 bytes from 10.0.0.2: icmp_seq=2 ttl=64 time=0.035 ms
64 bytes from 10.0.0.2: icmp_seq=3 ttl=64 time=0.021 ms

New System Calls

The implementation of network stack adds 7 new system calls: socket, bind, connect, listen, accept, send and recv. As only UDP is currently supported, the listen and accept system calls are currently nops.

  • socket - Creates a new socket of the specified type (currently UDP only)
  • bind - Associates a socket with a local address and port
  • connect - Associates a socket with a remote address and port
  • listen - Not implemented
  • accept - Not implemented
  • send - Send data to a remote socket
  • recv - Receive data from a remote socket

Using the Network Stack

An example netcat like userspace program, nc, is provided to exercise the network stack.

The nc program operates in two modes, client or server:

nc [-c|-s] [address] [port]

In client mode (-c), the program will send data from stdin to the specified port of the host located at address. For example, to send data to 10.0.0.1 on port 4444:

$ nc -c 10.0.0.1 4444
$ hello, world!

In server mode (-s), the program will listen for data on the specified port. To listen to data on port 5555:

$ nc -s 10.0.0.2 5555

As the network interface has a fixed local address (10.0.0.2), the address argument is currently ignored in server mode.

Notes

  • The network interface is assigned a fixed address of 10.0.0.2
  • The connect(...) system call is blocking on establishing the ARP resolution of the hardware address of the remote host.
  • The send(...) system call is blocking on the successful write of a transmit descriptor to the network device.
  • The recv(...) system call is non-blocking, returning immediately if no data is available. This is until the functionality of proc.c is ported to Rust.

About

A network stack for the XV6 operating system, written in Rust.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C 67.5%
  • Rust 21.9%
  • Assembly 3.0%
  • Makefile 2.8%
  • Shell 1.8%
  • Perl 1.6%
  • Other 1.4%