![Latest Version] ![Documentation] ![rscap: rustc 1.65+]
Rscap is a multi-purpose library for network packet capture/transmission and packet building. Its aims are twofold:
libpcap
, but written from the ground up in Rust)scapy
, but with strong typing and significantly improved performance)AF_PACKET
/PACKET_MMAP
sockets in Linux) to support cases where fine-grained control or platform-specific features are desired.no-std
Compatible: every packet type in the pkts
crate can be used without the standard library, and special LayerRef
and LayerMut
types can be used to access/modify raw packet bytes without requiring alloc
.scapy
may find the API surprisingly familiar, especially for layer composition and indexing operations:```rust use layers::{ip::Ipv4, tcp::Tcp};
let pkt = Ip::new() / Tcp::new(); pkt[Tcp].setsport(80); pkt[Tcp].setdport(12345); ```
Sequence
types that transparently handle defragmentation and reordering. Sequence
types can even be stacked so that application-layer data can easily be reassembled from captured packets. They even work in no-std
environments with or without alloc
.Session
types that handle these kinds of packets--Sessions ensure that packets are validated based on the current expected state of the protocol. Just like Sequence
, Session
types are compatible with no-std
environments and do not require alloc
.The source code of this project is licensed under either the MIT License or the Apache 2.0 License, at your option.