Which crate can be used to build ethernet packets?

I need to compose raw ethernet packets that could contain udp, tcp packets, and then send them through pcap

I have surveied following candidate:
etherparse
It has a Builder that helps to build packets, but currently only suitable to UDP packets. In order to compose other kinds of packets, it requires more works to do.

pnet_packet
It is more useful to parse packet. It can create packet from raw &[u8], but it seems to be incapable of building packets from different packet parts e.g., source mac, dest mac, source ip, dest ip, ports, payloads.

etherparse seems to be more suitable for my purpose, but it still has some aspects to be improved.

Is there any other choices?

Thanks.

Perhaps the wire module from smoltcp: smoltcp::wire - Rust

2 Likes