Remove classification "by-ip" from protocol stack (#1743)

Basically:
* "classification by-ip" (i.e. `flow->guessed_protocol_id_by_ip` is
NEVER returned in the protocol stack (i.e.
`flow->detected_protocol_stack[]`);
* if the application is interested into such information, it can access
`ndpi_protocol->protocol_by_ip` itself.

There are mainly 4 points in the code that set the "classification
by-ip" in the protocol stack:  the generic `ndpi_set_detected_protocol()`/
`ndpi_detection_giveup()` functions and the HTTP/STUN  dissectors.

In the unit tests output, a print about `ndpi_protocol->protocol_by_ip`
has been added for each flow: the huge diff of this commit is mainly due
to that.

Strictly speaking, this change is NOT an API/ABI breakage, but there are
important differences in the classification results. For examples:
* TLS flows without the initial handshake (or without a matching
SNI/certificate) are simply classified as `TLS`;
* similar for HTTP or QUIC flows;
* DNS flows without a matching request domain are simply classified as
`DNS`; we don't have `DNS/Google` anymore just because the server is
8.8.8.8 (that was an outrageous behaviour...);
* flows previusoly classified only "by-ip" are now classified as
`NDPI_PROTOCOL_UNKNOWN`.

See #1425 for other examples of why adding the "classification by-ip" in
the protocol stack is a bad idea.

Please, note that IPV6 is not supported :(  (long standing issue in nDPI) i.e.
`ndpi_protocol->protocol_by_ip` wil be always `NDPI_PROTOCOL_UNKNOWN` for
IPv6 flows.

Define `NDPI_CONFIDENCE_MATCH_BY_IP` has been removed.

Close #1687
This commit is contained in:
Ivan Nardi
2022-09-20 22:24:47 +02:00
committed by GitHub
parent 174cd739db
commit a7c2734b38
379 changed files with 9022 additions and 9061 deletions
+4 -4
View File
@@ -21,7 +21,7 @@ Patricia protocols: 12/8 (search/found)
i3D 60 36502 4
1 UDP 192.168.2.100:62461 <-> 213.163.87.47:50004 [proto: 301/i3D][ClearText][Confidence: DPI][cat: Game/8][14 pkts/16467 bytes <-> 1 pkts/116 bytes][Goodput ratio: 96/63][0.05 sec][bytes ratio: 0.986 (Upload)][IAT c2s/s2c min/avg/max/stddev: 1/0 4/0 36/0 10/0][Pkt Len c2s/s2c min/avg/max/stddev: 116/116 1176/116 1258/116 294/0][PLAIN TEXT (90.186.132.133)][Plen Bins: 0,0,13,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,20,66,0,0,0,0,0,0,0,0,0]
2 UDP 192.168.2.100:55205 <-> 213.163.87.47:50004 [proto: 301/i3D][ClearText][Confidence: DPI][cat: Game/8][14 pkts/11517 bytes <-> 1 pkts/116 bytes][Goodput ratio: 95/63][0.11 sec][bytes ratio: 0.980 (Upload)][IAT c2s/s2c min/avg/max/stddev: 1/0 9/0 31/0 10/0][Pkt Len c2s/s2c min/avg/max/stddev: 102/116 823/116 1209/116 456/0][PLAIN TEXT (90.186.132.133)][Plen Bins: 0,6,13,0,0,0,0,0,0,0,0,26,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,54,0,0,0,0,0,0,0,0,0,0,0]
3 UDP 192.168.2.100:62620 <-> 213.163.87.47:50004 [proto: 301/i3D][ClearText][Confidence: DPI][cat: Game/8][14 pkts/5099 bytes <-> 1 pkts/116 bytes][Goodput ratio: 88/63][0.25 sec][bytes ratio: 0.956 (Upload)][IAT c2s/s2c min/avg/max/stddev: 6/0 19/0 36/0 7/0][Pkt Len c2s/s2c min/avg/max/stddev: 102/116 364/116 1252/116 258/0][PLAIN TEXT (90.186.132.133)][Plen Bins: 0,6,13,0,0,0,0,0,47,26,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,6,0,0,0,0,0,0,0,0,0,0]
4 UDP 192.168.2.100:60476 <-> 213.163.87.47:50004 [proto: 301/i3D][ClearText][Confidence: DPI][cat: Game/8][13 pkts/2895 bytes <-> 2 pkts/176 bytes][Goodput ratio: 81/46][0.22 sec][bytes ratio: 0.885 (Upload)][IAT c2s/s2c min/avg/max/stddev: 1/107 18/107 36/107 8/0][Pkt Len c2s/s2c min/avg/max/stddev: 50/60 223/88 373/116 105/28][PLAIN TEXT (90.186.132.133)][Plen Bins: 20,0,13,0,27,0,6,6,6,6,13,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
1 UDP 192.168.2.100:62461 <-> 213.163.87.47:50004 [proto: 301/i3D][IP: 0/Unknown][ClearText][Confidence: DPI][cat: Game/8][14 pkts/16467 bytes <-> 1 pkts/116 bytes][Goodput ratio: 96/63][0.05 sec][bytes ratio: 0.986 (Upload)][IAT c2s/s2c min/avg/max/stddev: 1/0 4/0 36/0 10/0][Pkt Len c2s/s2c min/avg/max/stddev: 116/116 1176/116 1258/116 294/0][PLAIN TEXT (90.186.132.133)][Plen Bins: 0,0,13,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,20,66,0,0,0,0,0,0,0,0,0]
2 UDP 192.168.2.100:55205 <-> 213.163.87.47:50004 [proto: 301/i3D][IP: 0/Unknown][ClearText][Confidence: DPI][cat: Game/8][14 pkts/11517 bytes <-> 1 pkts/116 bytes][Goodput ratio: 95/63][0.11 sec][bytes ratio: 0.980 (Upload)][IAT c2s/s2c min/avg/max/stddev: 1/0 9/0 31/0 10/0][Pkt Len c2s/s2c min/avg/max/stddev: 102/116 823/116 1209/116 456/0][PLAIN TEXT (90.186.132.133)][Plen Bins: 0,6,13,0,0,0,0,0,0,0,0,26,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,54,0,0,0,0,0,0,0,0,0,0,0]
3 UDP 192.168.2.100:62620 <-> 213.163.87.47:50004 [proto: 301/i3D][IP: 0/Unknown][ClearText][Confidence: DPI][cat: Game/8][14 pkts/5099 bytes <-> 1 pkts/116 bytes][Goodput ratio: 88/63][0.25 sec][bytes ratio: 0.956 (Upload)][IAT c2s/s2c min/avg/max/stddev: 6/0 19/0 36/0 7/0][Pkt Len c2s/s2c min/avg/max/stddev: 102/116 364/116 1252/116 258/0][PLAIN TEXT (90.186.132.133)][Plen Bins: 0,6,13,0,0,0,0,0,47,26,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,6,0,0,0,0,0,0,0,0,0,0]
4 UDP 192.168.2.100:60476 <-> 213.163.87.47:50004 [proto: 301/i3D][IP: 0/Unknown][ClearText][Confidence: DPI][cat: Game/8][13 pkts/2895 bytes <-> 2 pkts/176 bytes][Goodput ratio: 81/46][0.22 sec][bytes ratio: 0.885 (Upload)][IAT c2s/s2c min/avg/max/stddev: 1/107 18/107 36/107 8/0][Pkt Len c2s/s2c min/avg/max/stddev: 50/60 223/88 373/116 105/28][PLAIN TEXT (90.186.132.133)][Plen Bins: 20,0,13,0,27,0,6,6,6,6,13,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]