Refactor network stack
Remove dependency on libpnet and re-implement linux and macOS code myself. This will prepare me to choose the most optimal transmission method for the two platforms and for instance use XDP/eBPF to reduce kernel signals.
I suspect the following library has a lot of the code that I could reuse for more flexibility to dig into the way we're sending packets:
https://github.com/pkts-rs/tappers
This will probably also avoid me from receiving packets not destined for me as we'll be having a dedicated interface.
I have to look at this part, it uses writev to send a packet. It states that only ip and ipv6 are supported so I think it means there's no ethernet support. At the moment, the only reason for having ethernet support is to be able to spoof my ip address. Since we're going to have a dedicated virtual interface, we can just set the ip address of the interface to the one we want to spoof and we should be good to go.
Had a quick look at the race condition attack and that uses ip and tcp, so we should be able to build that already.
It's also really nice as it already splits the interface into tun(send) and tap(receive) devices. This will make it easier to split it between threads.
Before doing this, I should carefully read this blog post, as it might be that the tun/tap device actually has MORE syscalls than the current implementation.
If a TUN/TAP device is not the way to go, look at libpnet and re-implement the relevant parts myself.