Find a file
Toni Uhlig e835d36f63
Added nDPId-test as all-in-one JSON dumper.
* fixed invalid flow event schema type
 * added run_tests.sh to generate/diff JSON dumps
 * renamed lot's of vars/fns in nDPId.c/nDPIsrvd.c, so nDPId-test.c can include "*.c"
 * improved CMake dependency checks

Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
2021-03-24 11:28:56 +01:00
cmake Switched to CMake build system. 2021-03-17 17:41:19 +01:00
dependencies Reduced code duplication. Preps for nDPId-test. 2021-03-23 14:25:56 +01:00
examples Switched to CMake build system. 2021-03-17 17:41:19 +01:00
schema Added nDPId-test as all-in-one JSON dumper. 2021-03-24 11:28:56 +01:00
test Added nDPId-test as all-in-one JSON dumper. 2021-03-24 11:28:56 +01:00
.clang-format clang-format and set BreakBeforeBraces to Allmanz 2020-07-10 20:48:23 +02:00
.gitignore Added basic collectd-exec example. 2021-03-10 18:32:09 +01:00
.travis.yml Switched to CMake build system. 2021-03-17 17:41:19 +01:00
CMakeLists.txt Added nDPId-test as all-in-one JSON dumper. 2021-03-24 11:28:56 +01:00
config.h nDPIsrvd C API overhaul and massive simplification. 2021-02-06 15:41:30 +01:00
Makefile.old Added nDPId-test as all-in-one JSON dumper. 2021-03-24 11:28:56 +01:00
nDPId-test.c Added nDPId-test as all-in-one JSON dumper. 2021-03-24 11:28:56 +01:00
nDPId.c Added nDPId-test as all-in-one JSON dumper. 2021-03-24 11:28:56 +01:00
nDPIsrvd.c Added nDPId-test as all-in-one JSON dumper. 2021-03-24 11:28:56 +01:00
README.md nDPIsrvd collectd-exec overhaul. 2021-03-15 14:39:43 +01:00
utils.c nDPId/nDPIsrvd: change_user_group does now chown/chmod collector/distributor socket paths 2020-10-07 14:38:10 +02:00
utils.h nDPId/nDPIsrvd: change_user_group does now chown/chmod collector/distributor socket paths 2020-10-07 14:38:10 +02:00

abstract

nDPId is a set of daemons and tools to capture, process and classify network flows. It's only dependencies (besides a half-way modern c library and POSIX threads) are libnDPI (>= 3.4.0, current github dev branch) and libpcap.

The core daemon nDPId uses pthread but does use mutexes for performance reasons. Instead synchronization is achieved by a packet distribution mechanism. To balance all workload to all threads (more or less) equally a hash value is calculated using the 5-tuple. This value serves as unique identifier for the processing thread. Multithreaded packet processing has to be flow-stable.

nDPId uses libnDPI's JSON serialization to produce meaningful JSON output which it then sends to the nDPIsrvd for distribution. High level applications can connect to nDPIsrvd to get the latest flow/packet events from nDPId.

Unfortunately nDPIsrvd does currently not support any encryption/authentication for TCP connections. TODO: Provide some sort of AEAD for connecting distributor clients via TCP (somehow very critical).

architecture

This project uses some kind of microservice architecture.

_______________________                                         __________________________
|     "producer"      |                                         |       "consumer"       |
|---------------------|      _____________________________      |------------------------|
|                     |      |        nDPIsrvd           |      |                        |
| nDPId --- Thread 1 >| ---> |>           |             <| <--- |< example/c-json-stdout |
| (eth0) `- Thread 2 >| ---> |> collector | distributor <| <--- |________________________|
|        `- Thread N >| ---> |>    >>> forward >>>      <| <--- |                        |
|_____________________|  ^   |____________|______________|   ^  |< example/py-flow-info  |
|                     |  |                                   |  |________________________|
| nDPId --- Thread 1 >|  `- connect to UNIX socket           |  |                        |
| (eth1) `- Thread 2 >|  `- sends serialized data            |  |< example/...           |
|        `- Thread N >|                                      |  |________________________|
|_____________________|                                      |                            
                                                             `- connect to UNIX/TCP socket
                                                             `- receives serialized data  

It doesn't use a producer/consumer design pattern, so the wording is not precise.

JSON TCP protocol

All JSON strings sent need to be in the following format:

[5-digit-number][JSON string]

Example:

0015{"key":"value"}

where 0015 describes the length of a complete JSON string.

TODO: Describe data format via JSON schema.

build

To get an overview over all build options, run:

make help

To build nDPId and nDPIsrvd, run:

make all

To build nDPId and nDPIsrvd with sanitizer, debug mode enabled and a custom/not-your-distro libnDPI, run:

make ENABLE_DEBUG=yes ENABLE_SANITIZER=yes CUSTOM_LIBNDPI=[path-to-libndpi].[a|so] all

To build nDPId and nDPIsrvd and examples, run:

make all examples

run

Daemons:

./nDPIsrvd -d
sudo ./nDPId -d

or for a usage printout:

./nDPIsrvd -h
./nDPId -h

And why not a flow-info example? Run

./examples/py-flow-info/flow-info.py

or

./examples/c-json-stdout/c-json-stdout

or anything below ./examples.