X-Git-Url: http://git.onelab.eu/?p=distributedratelimiting.git;a=blobdiff_plain;f=drl%2Festimate.c;h=bfe22c5cbb6477a0999d3ffb150f8712713266b4;hp=29704bee49307796bcb86c2458049405fe1f38f6;hb=9891ed21bcd3ff9f72a92e867ac7e8e0b9abb533;hpb=a3ef11b996352e66f4031c684c7dcda536bc3bf1 diff --git a/drl/estimate.c b/drl/estimate.c index 29704be..bfe22c5 100644 --- a/drl/estimate.c +++ b/drl/estimate.c @@ -18,7 +18,7 @@ #include "ratetypes.h" /* needs util and pthread.h */ #include "logging.h" -#define PRINT_COUNTER_RESET (7) +#define PRINT_COUNTER_RESET (0) extern uint8_t system_loglevel; static int printcounter = PRINT_COUNTER_RESET - 1; @@ -105,8 +105,8 @@ static double allocate_fps_over_limit(identity_t *ident) { if (ident->common.max_flow_rate > 0) { ideal_weight = (double) ident->locallimit / (double) ident->common.max_flow_rate; - printlog(LOG_DEBUG, "%.3f %d %d FlowCount, TotalRate, MaxRate\n", - ideal_weight, ident->common.rate, ident->common.max_flow_rate); + printlog(LOG_DEBUG, "%.3f %d %d %d FlowCount, Limit, MaxRate, TotalRate\n", + ideal_weight, ident->locallimit, ident->common.max_flow_rate, ident->common.rate); } else { ideal_weight = 1; } @@ -122,7 +122,7 @@ static uint32_t allocate_fps(identity_t *ident, double total_weight) { common_accounting_t *ftable = &ident->common; /* Common flow table info */ uint32_t local_rate = ftable->rate; uint32_t ideallocal = 0; - double peer_weights; /* sum of weights of all other limiters */ + double peer_weights; /* sum of weights of all other limiters */ double idealweight = 0; double last_portion = 0; double this_portion = 0; @@ -237,9 +237,17 @@ static uint32_t allocate_fps(identity_t *ident, double total_weight) { } if (printcounter <= 0) { - printlog(LOG_WARN, "%d %.1f %.1f %.1f %d %d %d %d %d %d ", local_rate, idealweight, - ident->localweight, total_weight, ftable->num_flows, ftable->num_flows_5k, ftable->num_flows_10k, - ftable->num_flows_20k, ftable->num_flows_50k, ftable->avg_rate); + struct timeval tv; + double time_now; + + gettimeofday(&tv, NULL); + time_now = (double) tv.tv_sec + (double) ((double) tv.tv_usec / (double) 1000000); + + printlog(LOG_WARN, "%.2f %d %.2f %.2f %.2f %d %d %d %d %d %d %d %d", time_now, ftable->inst_rate, + idealweight, ident->localweight, total_weight, ftable->num_flows, ftable->num_flows_5k, + ftable->num_flows_10k, ftable->num_flows_20k, ftable->num_flows_50k, ftable->avg_rate, + ftable->max_flow_rate, ftable->max_flow_rate_flow_hash); + printcounter = PRINT_COUNTER_RESET; } else { printcounter -= 1;