scapy icon indicating copy to clipboard operation
scapy copied to clipboard

Turnaround time longer on Linux over conf.L2socket

Open hecrabbs opened this issue 3 years ago • 9 comments

Brief description

Packets are taking ~0.1 seconds to be received over conf.L2socket on Linux.

Scapy version

2.4.5

Python version

3.6.9

Operating system

Ubuntu 18.04.6

Additional environment information

No response

How to reproduce

Running the attached echo_demo.py file (zipped) which uses the SatCat5 python API, will print the turnaround time it takes to send and receive a message. On the Linux machine (Ubuntu 18.04.6) the turnaround time is consistently ~0.1 seconds, but Wireshark shows that the packet is actually received in less than 0.001 seconds. Running it on a Windows machine (with Npcap 1.60) shows similar results to the Wireshark output.

echo_demo.zip

Actual result

Actual_Result

Expected result

Expected_Result

Related resources

No response

hecrabbs avatar Aug 10 '22 23:08 hecrabbs

Hi, do you have the same issue if you enable conf.use_pcap = True on linux?

gpotter2 avatar Aug 11 '22 02:08 gpotter2

Yes these results are with it enabled. It is enabled on line 33 of satcat5_eth.py

hecrabbs avatar Aug 11 '22 05:08 hecrabbs

How about with it disabled?

gpotter2 avatar Aug 11 '22 23:08 gpotter2

Disabling conf.use_pcap and changing the .nonblock_recv() to .recv() gave these results:

image

hecrabbs avatar Aug 12 '22 00:08 hecrabbs

So it's better, but still not nearly as fast as it should be?

hecrabbs avatar Aug 12 '22 00:08 hecrabbs

Yeah you're right. I'll have to check if I can reproduce..

Can you retry with master to be sure? rather than 2.4.5

gpotter2 avatar Aug 12 '22 02:08 gpotter2

I tried with master and it was the same result

hecrabbs avatar Aug 15 '22 18:08 hecrabbs

Could the issue be related to this? https://www.tcpdump.org/faq.html#q15

In immediate mode libpcap receives captured packets from the OS kernel one at a time, which results in a higher CPU overhead and a more likely packet loss; in buffered mode it receives multiple packets at once, but only after the buffer is full or its timeout has expired, which might take much longer than expected

hecrabbs avatar Aug 15 '22 18:08 hecrabbs

@gpotter2 any update on reproducing it?

hecrabbs avatar Aug 23 '22 20:08 hecrabbs