Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Streaming data to clients

I have a program that sniffs network data and stores it in a database using pcapy (based on this). I need to make the data available in realtime over a network connection.

Right now when i run the program it will start a second thread for the sniffer and a Twisted server on the main thread, however i have no idea how to get clients to 'tap into' the sniffer that's running in the background.

The end result should be that a client enters an url and the connection will be kept open until the client disconnects (even when there's nothing to send), whenever the server has network activity the sniffer will sniff it and send it to the clients.

I'm a beginner with Python so i'm quite overwhelmed so if anyone could point me in the right direction it would be greatly appreciated.

like image 751
Bart Avatar asked Mar 21 '26 01:03

Bart


1 Answers

Without more information (a simple code sample that doesn't work as you expect, perhaps) it's tough to give a thorough answer.

However, here are two pointers which may help you:

  • Twisted Pair, a (unfortunately very rudimentary and poorly documented) low-level/raw sockets networking library within Twisted itself, which may be able to implement the packet capture directly in a Twisted-friendly way, or
  • The recently-released Crochet, which will allow you to manage the background Twisted thread and its interactions with your pcapy-based capture code.
like image 192
Glyph Avatar answered Mar 23 '26 14:03

Glyph