Async TUN/TAP
Asynchronous allocation of TUN/TAP devices in Rust using async-std
and tokio
.
Getting Started
- Create a tun device using
TunBuilder
and read from it in a loop:
use AsRawFd;
use *;
use task;
use Result;
use TunBuilder;
use Ipv4Addr;
async
- Run the code using
sudo
:
- Set the address of device (address and netmask could also be set using
TunBuilder
):
- Ping to read packets:
- Display devices and analyze the network traffic:
➜ ip tuntap
➜ sudo tshark -i <tun-name>
Supported Platforms
- Linux
- FreeBSD
- Android
- OSX
- iOS
- Windows
Examples
read
: reading from tun usingasync-std
.read-mq
: reading from multi-queue tun usingasync-std
.read-tokio
: reading from tun usingtokio
. It should be run withuse-tokio
feature.