Python and `cffi` - Visualizing Network Traces
Abhijit Gadgil (~gabhijit) |
This talk dives a bit deeper into
cffi which is a package that is used to create Python bindings for libraries in C. We'll walk through a real problem of 'Visualizing Network Traces' and how this is done in Python using
cffi as a tool to develop Python bindings. The core idea is - to dissect the packets and get them as
json using Python bindings for
wireshark C library . Once the network packets are in Python world, all the goodies in Python are available to us. We'll be talking more about using
cffi to generate Python bindings for wireshark.
The talk focuses more on
cffi in fact except for the motivation, is exclusively about
cffi. What people would get out of the talk is how to write Python bindings for their favorite C library in an afternoon. (well almost!)
The talk is perhaps slightly advanced, in the sense that people need to be comfortable with
C/C++ compile/build ecosystem to derive the most out of it. And as such this is not a 'tutorial' on
cffi, so perhaps even some background with
cffi could help, but is not strictly necessary. We'll cover basics of
This talk is not about
cffi 101, but more about lessons learnt from a real world example building
- Problem definition (2-3 mins)
- Options for developing Python bindings (2-3 mins)
- Classic Python API
CFFI deep(ish) dive (10-15 mins)
- Working with
- Development Stage
- Build/Packaging Stage
- Runtime Stage
- Some not so FAQs.
- Working with
Putting things together - (5 mins)
- Really just a bunch of queues with Python processes/threads at the end :-)
- Packet visualization
Should have experience programming in Python. If you've tried writing Python bindings for a C library in the past (the classic way), this talk should help a lot.
.*@-Os -- (hint: regular expressions)
I have been programming in Python for almost over a decade on and off.
Python is my Go To language to try out stuff. Off late I am trying my hands at
Rust. I am mostly interested in 'systems' - stuff that is at a sufficiently lower layers of abstraction (though not necessarily OS kernel). In the past I had given talks at Pycon India.