Sendrecv overhaul: async sniffing & major cleanup#1999
Sendrecv overhaul: async sniffing & major cleanup#1999p-l- merged 13 commits intosecdev:masterfrom gpotter2:perfsndrcv
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1999 +/- ##
==========================================
+ Coverage 86.86% 87.14% +0.27%
==========================================
Files 197 197
Lines 44505 44512 +7
==========================================
+ Hits 38661 38791 +130
+ Misses 5844 5721 -123
|
|
PR is currently failing with PCAP/DNET tests. I'm not sure why yet |
|
So I've been working on asynchronous sniffing for a while now, PR isn't finished (fails on OSX), but at least it passes on Windows and Linux (I have access to debug machines) @polybassa I'm pretty sure this could be used in the I can usually restart the tests to make them pass. If you could have a look it would be amazing, but the PR is quite hard to understand, and I don't want to bother too much, so it's up to you. |
|
Hi, I’ll check that PR. Unfortunately I don’t have time for it, today. But tomorrow I’ll look into it.
… On 26. May 2019, at 16:02, Gabriel ***@***.***> wrote:
So I've been working on asynchronous sniffing for a while now, PR isn't finished (fails on OSX/pcapdnet), but at least it passes on Windows and Linux (I have access to debug machines)
@polybassa I'm pretty sure this could be used in the isotp implementation. However, I'm having troubles getting it to work with ISOTP sockets: https://travis-ci.com/secdev/scapy/jobs/203122929
If you could have a look it would be amazing, but the PR is quite hard to understand, so it's up to you.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.
|
|
Hi, I've looked into your commit and tested it manually. None of my unit tests for ISOTP fails at my local machine. AsyncSniffer works fine with ISOTPNativeSocket and ISTOPSoftSocket if the socket is provided as parameter |
|
Thanks for the feedback I've actually updated the It seems to have been fixed, sorry for wasting your time. I'll see if it remains consistent |
|
No problem. I'm happy to help you. |
|
I managed to circle the issue that happened only on the OSX builds. It's related to a timeout after sending, relative to BPF. The issue shouldn't be too hard to fix, I setup a Vagrant box running Freebsd for the occasion Last issue on the table: ISOTP failures. I've disabled the tests for now. |
|
@polybassa I finally managed to fix BSD*. The last commit fails because of The PR nearly is in its final state, the only thing left is to fix that. It works all right if I disable those. Also, note that this PR will probably allow to rewrite |
|
@gpotter2 |
|
@polybassa You were very right ! Thanks a lot, I had missed the I've updated it using the new mechanic in be21a50, and it appears to have solved the issue ! |
It is an alternative fix for #1199
guedou
left a comment
There was a problem hiding this comment.
I need to take more time to review the changes in sendrecv.py but I like the idea of refactoring the code!
This PR:
REQUIRES Fix FlagsField & dissection improvements #2035sent_timein__iter__rather than requiring extra memory space to store the timestamps. This brings a small performance boost, see below.AsyncSniff, removes tons of duplications, and allow us to useSessionseverywheresniffusesAsyncSniffsndrcvusesAsyncSniffsndrcvfloodusessndrcv.Eventusage: not required anymore if we use a class.processfrom sndrcv: no one uses it, and it's extremly messy. (My bad). We could reimplement it much easily now that we useAsyncSnifferwithinsndrcvscapy/automaton.pyAsyncSnifferNoneare ignored on all platforms (previously only Windows/BPF), instead of closing the socket (and using the very unclearTimeoutElapsed).EOFErrorwill now be the default exception to close a socket (this behavior is only used in*PcapReader)conf.use_bpfwould always enable itself even ifconf.use_pcapwas True. (Missing parenthesis)scapy.arch.bpf.supersocketsockets to use therecv_rawmechanicIt's a bit harder to implement than it looks, because it must be able to get out of a frozen
select(), on sockets that don't get any more packets.Perfs:
Using the benchmarking of #1259
Note: the following stats should only be read relatively speaking. The test is performed using a short packet (
Ether()/IP()) on loopback. It isn't intended to match a real usage by any mean.Notes:
async_select_unrequired=Falsemeans that theselectfunction is blocking, therefore a control socket (fake) should be passed. It should be set toTrueotherwise (Windows/OSX/Pcapdnet)... We could potentially rename itis_blocking_socket=Falseif it's clearer (but I only thought of that later 😄)Hopes for the future:
Thanks to the use of *sniff within the sndrcv suite, we have less code to maintain + it will allow us to enable:
Sessionsinsndrcv*: match a chunked HTTP response to its answer ?multiprocessing.dummyand try to paralellize packet dissections in pools). Edit: to anyone still reading this, note AsyncSniffer does NOT improve performances (or barely). Splitting the work load in multiple threads is useless. We could try to split it across processes, but that makes it much harder to implement. Eventually, the best option to optimize your code is to disable dissection of packets you don't use. We should make an util to make that easier somedayRelated:
fixes #1523
fixes #1505
fixes #1937