Search code examples
pythonscapysniffing

Stop sniffing after X seconds (instead of X packets)


I know I can do this with scapy:

sniff(count=10)

to sniff 10 packets.

How would I go about sniffing for 10 seconds instead in python? Can scapy do this itself or do I need to wrap it some other method to handle that?


Solution

  • You can simply pass a timeout to the sniff function. For more details, refer to the official API documentation:

    timeout: stop sniffing after a given time (default: None).