Implemented IAT (Inter Arrival Time) stats
This commit is contained in:
@@ -903,7 +903,8 @@ extern "C" {
|
||||
float ndpi_data_variance(struct ndpi_analyze_struct *s);
|
||||
float ndpi_data_stddev(struct ndpi_analyze_struct *s);
|
||||
float ndpi_data_ratio(u_int32_t sent, u_int32_t rcvd);
|
||||
|
||||
const char* ndpi_data_ratio2str(float ratio);
|
||||
|
||||
void ndpi_data_print_window_values(struct ndpi_analyze_struct *s); /* debug */
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
+17
-4
@@ -154,9 +154,22 @@ void ndpi_data_print_window_values(struct ndpi_analyze_struct *s) {
|
||||
|
||||
/* ********************************************************************************* */
|
||||
|
||||
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;
|
||||
/*
|
||||
Upload / download ration
|
||||
|
||||
return((s == 0) ? 0 : ((float)d)/((float)s));
|
||||
-1 Download
|
||||
0 Mixed
|
||||
1 Upload
|
||||
*/
|
||||
float ndpi_data_ratio(u_int32_t sent, u_int32_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));
|
||||
}
|
||||
|
||||
const char* ndpi_data_ratio2str(float ratio) {
|
||||
if(ratio < -0.2) return("Download");
|
||||
else if(ratio > 0.2) return("Upload");
|
||||
else return("Mixed");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user