https://github.com/teru01/toytcp
Toy TCP implementation with Rust (技術書典10「Rustで始めるTCP自作入門」ソースコード)
https://github.com/teru01/toytcp
Last synced: 3 months ago
JSON representation
Toy TCP implementation with Rust (技術書典10「Rustで始めるTCP自作入門」ソースコード)
- Host: GitHub
- URL: https://github.com/teru01/toytcp
- Owner: teru01
- License: mit
- Created: 2020-12-18T03:04:26.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2020-12-27T14:27:14.000Z (over 4 years ago)
- Last Synced: 2024-08-02T17:40:00.054Z (11 months ago)
- Language: Rust
- Homepage:
- Size: 7.03 MB
- Stars: 98
- Watchers: 4
- Forks: 7
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# toytcp
toy tcp implementation
# setup
```
$ cd toytcp
$ chmod +x setup.sh
$ ./setup.sh
```The following virtual network environment will be created. Only Linux is supported for now.

In order to avoid conflicts with the kernel's protocol stack, all packets with the RST flag are set to be discarded by iptables.
# build & run
```
$ cargo build --examples
```## echo-server & client
server
```
$ sudo ip netns exec host1 ./target/debug/examples/echoserver 10.0.0.1 30000
```client
```
$ sudo ip netns exec host2 sudo ./target/debug/examples/echoclient 10.0.0.1 30000
```## file upload
server
```
$ sudo ip netns exec host2 ./target/debug/examples/fileserver 10.0.1.1 40000
```client
```
$ sudo ip netns exec host1 ./target/debug/examples/fileclient 10.0.1.1 40000 sample.jpg
```## simulate packet loss
### Discard 0.1% of packets
```
$ sudo ip netns exec router tc qdisc add dev router-veth2 root netem loss 0.1%
```Remember to turn off the settings when you're done experimenting.
```
sudo ip netns exec host2 tc qdisc del dev host2-veth1 root
```