Python and `cffi` - Visualizing Network Traces

Abhijit Gadgil (~gabhijit)


0

Votes

Description:

Overview

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!)

Intended Audience

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 cffi.

Talk Sketch

This talk is not about cffi 101, but more about lessons learnt from a real world example building

  1. Problem definition (2-3 mins)
  2. Options for developing Python bindings (2-3 mins)
    • cffi
    • ctypes
    • SWIG
    • Cython
    • Classic Python API
  3. CFFI deep(ish) dive (10-15 mins)

    • Working with cffi stages -
      • Development Stage
      • Build/Packaging Stage
      • Runtime Stage
    • Some not so FAQs.
  4. Putting things together - (5 mins)

    • Really just a bunch of queues with Python processes/threads at the end :-)
    • Packet visualization

Prerequisites:

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.

Content URLs:

Speaker Info:

.*@-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.

Speaker Links:

Section: Networking and Security
Type: Talks
Target Audience: Advanced
Last Updated: