Find a file
lns db83f82d29 Fixed build if BUILD_NDPI=ON. May happen during XCompilation.
Signed-off-by: lns <matzeton@googlemail.com>
2022-04-16 22:18:19 +02:00
.github/workflows bump libnDPI to bb12837ca75efc2691ecb18fd5f56e2d097ef26b 2022-03-24 02:16:33 +01:00
cmake Switched to CMake build system. 2021-03-17 17:41:19 +01:00
dependencies Reworked nDPIsrvd.h C-API. 2022-03-21 15:56:01 +01:00
examples Executing ./tests/run_tests.sh w/o zLib should not result in diff's anymore. 2022-03-24 01:04:49 +01:00
libnDPI@bb12837ca7 bump libnDPI to bb12837ca75efc2691ecb18fd5f56e2d097ef26b 2022-03-24 02:16:33 +01:00
schema bump libnDPI to bb12837ca75efc2691ecb18fd5f56e2d097ef26b 2022-03-24 02:16:33 +01:00
scripts Fixed build if BUILD_NDPI=ON. May happen during XCompilation. 2022-04-16 22:18:19 +02:00
test bump libnDPI to bb12837ca75efc2691ecb18fd5f56e2d097ef26b 2022-03-24 02:16:33 +01:00
.clang-format clang-format and set BreakBeforeBraces to Allmanz 2020-07-10 20:48:23 +02:00
.gitignore Build system cleanup / cosmetics. 2021-06-07 16:22:49 +02:00
.gitlab-ci.yml bump libnDPI to bb12837ca75efc2691ecb18fd5f56e2d097ef26b 2022-03-24 02:16:33 +01:00
.gitmodules Git submodule libnDPI update. 2021-05-12 12:46:49 +02:00
CMakeLists.txt Fixed build if BUILD_NDPI=ON. May happen during XCompilation. 2022-04-16 22:18:19 +02:00
config.h bump libnDPI to bb12837ca75efc2691ecb18fd5f56e2d097ef26b 2022-03-24 02:16:33 +01:00
COPYING Added GPL-3 License. 2021-05-11 16:33:34 +02:00
nDPId-test.c Executing ./tests/run_tests.sh w/o zLib should not result in diff's anymore. 2022-03-24 01:04:49 +01:00
nDPId.c bump libnDPI to bb12837ca75efc2691ecb18fd5f56e2d097ef26b 2022-03-24 02:16:33 +01:00
nDPIsrvd.c Disconnect nDPIsrvd clients immediately instead waiting for a failed write(). 2022-03-13 02:28:10 +01:00
README.md Improved py-flow-info to provide more optional information about received timestamps. 2022-02-05 15:27:13 +01:00
sonar-project.properites Github Actions integration 2021-09-17 18:59:49 +02:00
TODO.md Added daemon event: DAEMON_EVENT_STATUS (periodically send's daemon statistics.) 2022-03-06 17:38:05 +01:00
utils.c Reworked nDPIsrvd.h C-API. 2022-03-21 15:56:01 +01:00
utils.h Added logging interface used by nDPId, nDPIsrvd and nDPId-test. 2022-02-03 03:48:37 +01:00

Build Gitlab-CI

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 (>= 4.2.0 or 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.

architecture

This project uses some kind of microservice architecture.

                connect to UNIX socket          connect to UNIX/TCP socket                
_______________________   |                                 |   __________________________
|     "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 >|  `- send serialized data             |  |                        |
| (eth1) `- Thread 2 >|                                      |  |< example/...           |
|        `- Thread N >|             receive 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:

00015{"key":"value"}

where 00015 describes the length (as decimal number) of the entire JSON string including the newline \n at the end.

A common sequence of received JSON strings could look alike (simplified):

00070{"flow_event_id":1,"flow_event_name":"new","packet_id":1,"flow_id":1}
00101{"flow_id":1,"flow_packet_id":1,"packet_event_id":2,"packet_event_name":"packet-flow","packet_id":1}
00075{"flow_event_id":5,"flow_event_name":"detected","packet_id":4,"flow_id":1}
00093{"flow_event_id":2,"flow_event_name":"end","packet_id":258,"flow_id":1,"flow_packet_id":258}

build (CMake)

mkdir build
cd build
cmake ..

or

mkdir build
cd build
ccmake ..

or to build with a staticially linked libnDPI:

mkdir build
cd build
cmake .. -DSTATIC_LIBNDPI_INSTALLDIR=[path/to/your/libnDPI/installdir]

If you're using the latter one, make sure that you've configured libnDPI with ./configure --prefix=[path/to/your/libnDPI/installdir] and do not forget to set the all necessary CMake variables to link against shared libraries used by your nDPI build.

e.g.:

mkdir build
cd build
cmake .. -DSTATIC_LIBNDPI_INSTALLDIR=[path/to/your/libnDPI/installdir] -DNDPI_WITH_GCRYPT=ON -DNDPI_WITH_PCRE=OFF -DNDPI_WITH_MAXMINDDB=OFF

Or if this is all too much for you, let CMake do it for you:

mkdir build
cd build
cmake .. -DBUILD_NDPI=ON

run

Generate a nDPId compatible JSON dump:

./nDPId-test [path-to-a-PCAP-file]

Daemons:

./nDPIsrvd -d
sudo ./nDPId -d

or for a usage printout:

./nDPIsrvd -h
./nDPId -h

And why not a flow-info example?

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

or

./nDPIsrvd-json-dump

or anything below ./examples.

test

The recommended way to run integration / diff tests:

mkdir build
cd build
cmake .. -DBUILD_NDPI=ON
make nDPId-test test

Alternatively you can run some integration tests manually:

./test/run_tests.sh [/path/to/libnDPI/root/directory] [/path/to/nDPId-test]

e.g.:

./test/run_tests.sh [${HOME}/git/nDPI] [${HOME}/git/nDPId/build/nDPId-test]

Remember that all test results are tied to a specific libnDPI commit hash as part of the git submodule. Using test/run_tests.sh for other commit hashes will most likely result in PCAP diff's.

Why not use examples/py-flow-dashboard/flow-dash.py to visualize nDPId's output:

dashboard