Skip to content
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

Python bindings #457

Closed
ghost opened this issue Aug 23, 2021 · 2 comments
Closed

Python bindings #457

ghost opened this issue Aug 23, 2021 · 2 comments

Comments

@ghost
Copy link

ghost commented Aug 23, 2021

Hi,

I'm currently writing a sniffer tool for my master thesis and stumbled over this awesome project. Due to the performance issues of pyshark and scapy on heavy load I would like to use this lib from my python code. I've read a bit into python bindings and asked myself whether there is someone in the community who has some hints what's the easiest way to build the bindings and call the lib from python code. Is it recommended to use one of the tools described here?
Has someone experiences using this?

Any help is much appreciated.

Thanks a lot in advance for this awesome project.

@mfontanini
Copy link
Owner

mfontanini commented Sep 3, 2021

I'd suggest either:

  • Using a faster python library. According to the benchmarks I ran, dpkt should be a lot faster than scapy. It definitely won't be as fast as libtins but it may give you enough of a performance boost over the sluggish scapy.
  • Write the code in C++ using libtins and export thinner bindings to whatever algorithm you have. e.g. if you were trying to build a traceroute tool, write it in C++ using libtins and then export a function such as run_traceroute so it is importable via python. I've used boost.python for this in the past and it works well, but there's probably better alternatives out there. This will let you write a smaller amount of code to glue the C++/Python worlds together as well as giving you some performance boost. If you end up having to wrap the entire library so you can use it from Python it's going to take you a very long time. I started working on pytins a very long time ago but never ended up finishing it.

Hope this helps!

@ghost
Copy link
Author

ghost commented Sep 6, 2021

Thank you very much. I will think about your suggestions.
Currently I use a TShark process directly for sniffing. Let's see how far that takes us.

@ghost ghost closed this as completed Sep 6, 2021
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant