A final(?) effort to reduce memory usage per flow (#1389)
Remove some unused fields and re-organize other ones. In particular: * Update the parameters of `ndpi_ssl_version2str()` function * Zattoo, Thunder: these timestamps aren't really used. * Ftp/mail: these protocols are dissected only over TCP. * Attention must be paid to TLS.Bittorrent flows to avoid invalid read/write to `flow->protos.bittorrent.hash` field. This is the last(?) commit of a long series (see22241a1d,227e586e,730c2360,a8ffcd8b) aiming to reduce library memory consumption. Before, at nDPI 4.0 (more precisly, ata6b10cf7, because memory stats were wrong until that commit): ``` nDPI Memory statistics: nDPI Memory (once): 221.15 KB Flow Memory (per flow): 2.94 KB ``` Now: ``` nDPI Memory statistics: nDPI Memory (once): 231.71 KB Flow Memory (per flow): 1008 B <--------- ``` i.e. memory usage per flow has been reduced by 66%, dropping below the psychological threshold of 1 KB. To further reduce this value, we probably need to look into #1279: let's fight this battle another day.
This commit is contained in:
@@ -2030,6 +2030,7 @@ int processClientServerHello(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
u_int16_t s_offset = offset+extension_offset;
|
||||
u_int8_t version_len = packet->payload[s_offset];
|
||||
char version_str[256];
|
||||
char buf_ver_tmp[16];
|
||||
size_t version_str_len = 0;
|
||||
version_str[0] = 0;
|
||||
#ifdef DEBUG_TLS
|
||||
@@ -2049,14 +2050,14 @@ int processClientServerHello(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
|
||||
#ifdef DEBUG_TLS
|
||||
printf("Client TLS [TLS version: %s/0x%04X]\n",
|
||||
ndpi_ssl_version2str(flow, tls_version, &unknown_tls_version), tls_version);
|
||||
ndpi_ssl_version2str(buf_ver_tmp, sizeof(buf_ver_tmp), tls_version, &unknown_tls_version), tls_version);
|
||||
#endif
|
||||
|
||||
if((version_str_len+8) < sizeof(version_str)) {
|
||||
int rc = snprintf(&version_str[version_str_len],
|
||||
sizeof(version_str) - version_str_len, "%s%s",
|
||||
(version_str_len > 0) ? "," : "",
|
||||
ndpi_ssl_version2str(flow, tls_version, &unknown_tls_version));
|
||||
ndpi_ssl_version2str(buf_ver_tmp, sizeof(buf_ver_tmp), tls_version, &unknown_tls_version));
|
||||
if(rc <= 0)
|
||||
break;
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user