Most active commenters
  • pandax381(7)

139 points pandax381 | 13 comments | | HN request time: 0.866s | source | bottom

Hi HN,

To truly understand how operating systems and network protocols work, I decided to combine two classic learning tools: the xv6 teaching OS and a from-scratch TCP/IP stack.

I'm excited to share the result: my own from-scratch TCP/IP networking stack running directly inside the xv6-riscv (https://github.com/pandax381/xv6-riscv-net) kernel.

The project uses a modern virtio-net driver, allowing it to run seamlessly in QEMU and communicate with the host machine.

Key features:

- From-Scratch Stack: The core is powered by microps (https://github.com/pandax381/microps), a TCP/IP stack I originally wrote to run in user-space as a personal project to learn the low-level details of networking.

- Kernel Integration: This project ports microps from user-space into the xv6-riscv kernel.

- Socket API: Implements standard system calls (socket, bind, accept, etc.) to enable network application development.

- User-level Tools: Comes with a simple ifconfig command, plus tcpecho and udpecho servers to demonstrate its capabilities.

This has been a fantastic learning experience. My goal was to demystify the magic behind network-aware operating systems by building the components myself.

I'd love to hear your feedback and answer any questions!

1. theosp ◴[] No.45023216[source]
Well done! Thank you for sharing
replies(1): >>45032911 #
2. lesser-shadow ◴[] No.45023790[source]
Are you using any RISC-V extensions? If so, which? I couldn't find this information on the xv6 project page. It would be cool if you could run this project in bare metal.
replies(1): >>45033005 #
3. Tony_Delco ◴[] No.45024013[source]
This is amazing work. Most people don’t realize how much effort and depth there is behind writing a TCP/IP stack and plugging it into xv6 with virtio-net and sockets. Huge respect for making it public. Projects like this are gold for those of us who love low-level systems.
replies(1): >>45032886 #
4. dancek ◴[] No.45024257[source]
Awesome work! Thank you for showing it to the world!

I've considered writing a network stack myself. It's much more complex than most people can imagine. We have great tooling for TCP and that makes people believe it's simple technology. It's not.

replies(1): >>45032921 #
5. AbbeFaria ◴[] No.45025677[source]
Well done. I am actually solving the labs rn. I am on mmap, trying to get fork to work :)
replies(1): >>45032904 #
6. cardiffspaceman ◴[] No.45031490[source]
The readme implies that UDP is included. Is that true?
replies(1): >>45032899 #
7. pandax381 ◴[] No.45032886[source]
Thank you so much for the kind words! It really means a lot, especially from someone who understands the effort involved. I'm thrilled that it's resonating with fellow low-level systems fans.
8. pandax381 ◴[] No.45032899[source]
Yes, that's correct! Both TCP and UDP are implemented. There's a udpecho server included as a sample application you can use to test it out.
9. pandax381 ◴[] No.45032904[source]
Thank you! And good luck with the labs, they're a great learning experience.
10. pandax381 ◴[] No.45032911[source]
Thank you for checking it out!
11. pandax381 ◴[] No.45032921[source]
Thank you! I completely agree, the complexity is definitely hidden by modern tools and abstractions. It's a challenging but rewarding project. You should give it a try, it's a fantastic way to learn!
12. pandax381 ◴[] No.45033005[source]
Thanks for asking! It's compiled with -march=rv64g, so it uses the standard general-purpose extensions (IMAFD) and doesn't rely on anything exotic. Running it on bare metal is definitely a challenge I'd like to try someday! For now, the virtio-net driver is tightly coupled with QEMU, so a different network driver would be needed for specific hardware.