diff options
author | Luca <deri@ntop.org> | 2019-08-29 13:40:44 +0200 |
---|---|---|
committer | Luca <deri@ntop.org> | 2019-08-29 13:40:44 +0200 |
commit | 9a6f6d9fe429e1de4316b324a459db345dccfcbb (patch) | |
tree | d1f6209314676e4e3206e435723ba11312ab9785 /src/lib/ndpi_analyze.c | |
parent | e4e40e3c70e2cd49fd537a526fa70805c8c391c5 (diff) |
Implemented IAT (Inter Arrival Time) stats
Diffstat (limited to 'src/lib/ndpi_analyze.c')
-rw-r--r-- | src/lib/ndpi_analyze.c | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/src/lib/ndpi_analyze.c b/src/lib/ndpi_analyze.c index ce3168165..8facdf371 100644 --- a/src/lib/ndpi_analyze.c +++ b/src/lib/ndpi_analyze.c @@ -154,9 +154,22 @@ void ndpi_data_print_window_values(struct ndpi_analyze_struct *s) { /* ********************************************************************************* */ +/* + Upload / download ration + + -1 Download + 0 Mixed + 1 Upload + */ float ndpi_data_ratio(u_int32_t sent, u_int32_t rcvd) { - int64_t s = (int64_t)sent + (int64_t)rcvd; - int64_t d = (int64_t)sent - (int64_t)rcvd; + float s = (float)((int64_t)sent + (int64_t)rcvd); + float d = (float)((int64_t)sent - (int64_t)rcvd); + + return((s == 0) ? 0 : (d/s)); +} - return((s == 0) ? 0 : ((float)d)/((float)s)); +const char* ndpi_data_ratio2str(float ratio) { + if(ratio < -0.2) return("Download"); + else if(ratio > 0.2) return("Upload"); + else return("Mixed"); } |