-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Multithread sniff #1259
Multithread sniff #1259
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1259 +/- ##
==========================================
+ Coverage 85.34% 85.39% +0.05%
==========================================
Files 177 175 -2
Lines 40850 40583 -267
==========================================
- Hits 34862 34657 -205
+ Misses 5988 5926 -62
|
93e1358
to
23ddd4e
Compare
23ddd4e
to
a7b633e
Compare
scapy/arch/linux.py
Outdated
@@ -438,34 +438,26 @@ def close(self): | |||
for i in self.iff: | |||
set_promisc(self.ins, i, 0) | |||
SuperSocket.close(self) | |||
def recv(self, x=MTU): | |||
def recv_async(self, x=MTU): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if this name is really appropriate... The goal of this function is to receive without dissecting. Any ideas?
a7b633e
to
6fc03ed
Compare
recv_raw ?
|
4ac8e94
to
c3a5d20
Compare
14232cb
to
0f755ae
Compare
0f755ae
to
bef6e75
Compare
eb620d3
to
4be4d16
Compare
.travis/install.sh
Outdated
@@ -17,7 +17,8 @@ fi | |||
# Install wireshark data | |||
if [ "$TRAVIS_OS_NAME" = "linux" ] && [ "$TRAVIS_SUDO" = "true" ] | |||
then | |||
sudo apt-get -qy install tshark | |||
# The wireshark packets should be installed with tshark, but Travis sometimes ignores the dependencies | |||
sudo apt-get -qy install libwireshark5 wireshark-common tshark |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See https://travis-ci.org/gpotter2/scapy/jobs/390697554
$ bash .travis/install.sh
Reading package lists...
Building dependency tree...
Reading state information...
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies:
tshark : Depends: libwireshark5 (>= 1.12.0~rc3) but it is not going to be installed
Depends: wireshark-common (= 1.12.1+g01b65bf-4+deb8u11ubuntu0.14.04.1) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.
2f375de
to
fefd299
Compare
fefd299
to
1e59be7
Compare
- Allow the recv() function to accept an argument from a previously received recv_raw() - Remove duplicated code from pcapdnet.py
1e59be7
to
bfddfac
Compare
I have doubts about the real performance improvement of this PR... |
I can't get this PR to go anywhere, and am only losing performances :/ Will leave it here in the meanwhile... I do think that using multiprocessing, and keeping this PR will improve the performances, but It seems maybe too hard to implement (sharing objects with multiprocessing is a pain), so I don't think the work is worth it.. |
This PR was a failure. See #1999
What it does
Split the sniffing process into several threads:
To make this work, it was needed to separate dissecting and recieving in the arch/ hooks: introducing
recv_async
(of course name may be changed), which only recieves the packet as raw bytes. It is called by the olderrecv()
functions, which will keep the same behaviorThis allows to split scapy's processing part from API calls. It free the buffer of the APIs into scapy's one.
Benchmark
Start 2 scapy instances
In the first one:
stats()
Results
Those results already are an average
Edit: this seems wrong, as we are not using multiprocessing but threading, so the measuring methods are slowed down too, making the hole thing clunky.. Redoing the tests in a proper environment (two separate shells) makes the results very different
Conclusion
This PR improves the recieved packet / second rate by 281%
TODO & discussion