Merge branch 'dev' of https://github.com/ntop/nDPI into dev
This commit is contained in:
@@ -1,11 +0,0 @@
|
|||||||
This directory contains the Python3 bindings for nDPI
|
|
||||||
|
|
||||||
Demo example:
|
|
||||||
- python3 ndpi_example.py <interface>
|
|
||||||
- python3 ndpi_example.py <pcap_file>
|
|
||||||
|
|
||||||
Additional example (using nfstream package):
|
|
||||||
- python3 flow_printer.py <interface>
|
|
||||||
- python3 flow_printer.py <pcap_file>
|
|
||||||
|
|
||||||
Code courtesy of: Massimo Puddu, Zied Aouini
|
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
nDPI Python bindings
|
||||||
|
--------------------
|
||||||
|
|
||||||
|
This directory contains the Python3 bindings for nDPI. We provide both ctypes and cffi based bindings.
|
||||||
|
|
||||||
|
**ctypes bindings**
|
||||||
|
|
||||||
|
Files:
|
||||||
|
|
||||||
|
* ndpi_typestruct.py
|
||||||
|
* ndpi_wrap.c
|
||||||
|
* Makefile.in
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
.. code-block:: bash
|
||||||
|
|
||||||
|
pip3 install scapy
|
||||||
|
python3 ndpi_example.py <interface>
|
||||||
|
python3 ndpi_example.py <pcap_file>
|
||||||
|
|
||||||
|
Code courtesy:
|
||||||
|
|
||||||
|
* Massimo Puddu
|
||||||
|
* Zied Aouini
|
||||||
|
|
||||||
|
**cffi bindings**
|
||||||
|
|
||||||
|
Files:
|
||||||
|
|
||||||
|
* ndpi.py
|
||||||
|
|
||||||
|
|
||||||
|
Example (using NFStream package):
|
||||||
|
|
||||||
|
.. code-block:: bash
|
||||||
|
|
||||||
|
pip3 install nfstream
|
||||||
|
python3 flow_printer.py <interface>
|
||||||
|
python3 flow_printer.py <pcap_file>
|
||||||
|
|
||||||
|
Code courtesy:
|
||||||
|
|
||||||
|
* Zied Aouini
|
||||||
+18
-6
@@ -17,11 +17,23 @@ You should have received a copy of the GNU General Public License along with nfs
|
|||||||
If not, see <http://www.gnu.org/licenses/>.
|
If not, see <http://www.gnu.org/licenses/>.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from nfstream.streamer import Streamer
|
from nfstream import NFStreamer
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
flow_streamer = Streamer(source=sys.argv[1])
|
|
||||||
flows_count = 0
|
path = sys.argv[1]
|
||||||
for flow in flow_streamer:
|
flow_streamer = NFStreamer(source=path)
|
||||||
print("flow[{}]: \n{}\n".format(flows_count, flow))
|
result = {}
|
||||||
flows_count += 1
|
try:
|
||||||
|
for flow in flow_streamer:
|
||||||
|
print(flow)
|
||||||
|
try:
|
||||||
|
result[flow.application_name] += flow.total_packets
|
||||||
|
except KeyError:
|
||||||
|
result[flow.application_name] = flow.total_packets
|
||||||
|
print("Summary (Application Name: Packets):")
|
||||||
|
print(result)
|
||||||
|
except KeyboardInterrupt:
|
||||||
|
print("Summary (Application Name: Packets):")
|
||||||
|
print(result)
|
||||||
|
print("Terminated.")
|
||||||
+1274
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user