GithubHelp home page GithubHelp logo

chaoyangnz / rust-user-net Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ykskb/rust-user-net

0.0 1.0 0.0 5.62 MB

User-space network protocol stack written in Rust

License: Apache License 2.0

Shell 0.93% Rust 98.65% Dockerfile 0.42%

rust-user-net's Introduction

rust-user-net

User-space network protocol stack written in Rust for study / experiment purpose

Talks Ethernet / ARP / IP / ICMP / UDP / TCP through TAP device on Linux.

This project is by and large a Rust port of microps project written in C. Many thanks to the owner for awesome codes and shared decks (Japanese).

High-level View

Setup and Usage

  • Built and tested on Ubuntu 22.04
cd rust-user-net

# Build
cargo build

# TAP device setup (will be reset on reboot)
./set_tap.sh

# If you want rust-user-net to connect to Internet:
# Output interface name is assumed to be `wlp0s20f3`.
# Please update it if it's different in your machine.
./set_forward.sh

# Show help
./rust-user-net -h
./rust-user-net tcp -h
./rust-user-net tcp send -h

Example

HTTP (TCP: 80) request to http://www.google.com:

# Send command sends a request and gets into receive loop
rust-user-net tcp send 142.250.4.138 80 'GET / HTTP/1.1\r\nHost: www.google.com\r\n\r\n'

Local Tests with netcat

# TCP

# Test send command:
# nc listens for TCP active open (3-way handshake) from rust-user-net
nc -nv -l 10007
rust-user-net tcp send 192.0.2.1 10007 "TCP TEST DATA"

# Test receive command:
# nc connects and sends data to rust-user-net (192.0.2.2:7) 
rust-user-net tcp receive 0.0.0.0 7
nc -nv 192.0.2.2 7 # -n: no name resolution

# UDP

# Test send command:
# nc listens for UDP data from rust-user-net
nc -u -l 10007
rust-user-net udp send 192.0.2.1 10007 "UDP TEST DATA"

# Test receive command:
# nc sends UDP data to rust-user-net (192.0.2.2:7)
rust-user-net udp receive 0.0.0.0 7
nc -u 192.0.2.2 7 # -u: UDP mode

rust-user-net's People

Contributors

ykskb avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.