I think we could eliminate this by mimicing linux sk_buf: leaving 64 bytes (IP + TCP header) ahead the buf passed to udp.recv, then construct the headers in-place, with no need to touch the payload.
I have no idea how much this would impact performance though.
Upon reading the code, I noticed each fake tcp packet will cost an alloc and copy https://github.com/dndx/phantun/blob/main/fake-tcp/src/packet.rs#L50 https://github.com/dndx/phantun/blob/main/fake-tcp/src/packet.rs#L97
I think we could eliminate this by mimicing linux sk_buf: leaving 64 bytes (IP + TCP header) ahead the buf passed to udp.recv, then construct the headers in-place, with no need to touch the payload.
I have no idea how much this would impact performance though.