rust-pcap / pcap

Rust language pcap library
Apache License 2.0
595 stars 138 forks source link

Distinguish data received/sent by network cards #299

Closed yunfengwangluo closed 1 year ago

yunfengwangluo commented 1 year ago

I just came into contact with this very good library and I want to differentiate the data obtained. How to distinguish the data received/sent by the network card? You still need to make your own judgment based on the source MAC.

Wojtek242 commented 1 year ago

You can set direction on a capture: https://docs.rs/pcap/latest/pcap/struct.Capture.html#method.direction. By using the Direction you can choose whether you only want incoming or outgoing packets. If you still want both, but somehow to distinguish them, you probably will need two captures - one for incoming, one for outgoing.

I hope this asnwers your question! If it doesn't please feel free to re-open the issue and continue the discussion.