From: Kevin Webb Date: Tue, 18 Nov 2008 21:19:54 +0000 (+0000) Subject: Added a check to see if the sending rate is within 1% of the limit rather than X-Git-Tag: DistributedRateLimiting-0.1-0~46 X-Git-Url: http://git.onelab.eu/?p=distributedratelimiting.git;a=commitdiff_plain;h=f54a05e4b5bef7c5c90663765656a9084d622e82 Added a check to see if the sending rate is within 1% of the limit rather than requiring it to be over the limit before switching FPS regimes. Print a small amount of data in LOG_WARN mode so that we can track progress. Change an assert to a log to prevent crashing. --- diff --git a/drl/estimate.c b/drl/estimate.c index e55639b..17a0fd8 100644 --- a/drl/estimate.c +++ b/drl/estimate.c @@ -18,9 +18,8 @@ #include "ratetypes.h" /* needs util and pthread.h */ #include "logging.h" -static int underlimit_flowcount_count = 0; -static int underlimit_normal_count = 0; extern uint8_t system_loglevel; +static int printcounter = 8; /** * Called for each identity each estimate interval. Uses flow table information @@ -156,7 +155,8 @@ static uint32_t allocate_fps(identity_t *ident, double total_weight) { if (local_rate <= 0) { idealweight = 0; - } else if (dampen_increase == 0 && (ident->locallimit <= 0 || local_rate < ident->locallimit || ident->flowstart)) { + } else if (dampen_increase == 0 && + (ident->locallimit <= 0 || local_rate < (ident->locallimit * CLOSE_ENOUGH) || ident->flowstart)) { /* We're under the limit - all flows are bottlenecked. */ idealweight = allocate_fps_under_limit(ident, local_rate, peer_weights); ideal_over = allocate_fps_over_limit(ident); @@ -166,11 +166,9 @@ static uint32_t allocate_fps(identity_t *ident, double total_weight) { idealweight = ideal_over; regime = 3; dampen = 2; - underlimit_flowcount_count += 1; } else { regime = 1; dampen = 0; - underlimit_normal_count += 1; } /* Apply EWMA */ @@ -234,11 +232,16 @@ static uint32_t allocate_fps(identity_t *ident, double total_weight) { local_rate, idealweight, ident->localweight, total_weight); } + if (printcounter <= 0) { + printlog(LOG_WARN, "%d %.1f %.1f %.1f\n", local_rate, idealweight, ident->localweight, total_weight); + printcounter = 8; + } else { + printcounter -= 1; + } + //printf("Dampen: %d, dampen_increase: %d, peer_weights: %.3f, regime: %d\n", // dampen, dampen_increase, peer_weights, regime); - //printf("normal_count: %d, flowcount_count: %d\n", underlimit_normal_count, underlimit_flowcount_count); - if (regime == 3) { printlog(LOG_DEBUG, "MIN: min said to use flow counting, which was %.3f when other method said %.3f.\n", ideal_over, ideal_under); @@ -354,7 +357,7 @@ static void enforce(limiter_t *limiter, identity_t *ident) { * FLOW_START_THRESHOLD. */ if (ident->locallimit < FLOW_START_THRESHOLD) { - ident->locallimit = FLOW_START_THRESHOLD * 2; + ident->locallimit = FLOW_START_THRESHOLD; } /* Do not allow the node to set a limit higher than its @@ -367,6 +370,7 @@ static void enforce(limiter_t *limiter, identity_t *ident) { printf("FPS: Setting local limit to %d\n", ident->locallimit); } printlog(LOG_DEBUG, "%d Limit ID:%d\n", ident->locallimit, ident->id); + printlog(LOG_WARN, "%d\n", ident->locallimit); snprintf(cmd, CMD_BUFFER_SIZE, "/sbin/tc class change dev eth0 parent 1:%x classid 1:%x htb rate 8bit ceil %dbps quantum 1600", diff --git a/drl/raterouter.h b/drl/raterouter.h index 28c6c7f..e6de5e9 100644 --- a/drl/raterouter.h +++ b/drl/raterouter.h @@ -56,7 +56,9 @@ enum accountings { ACT_STANDARD = 1, ACT_SAMPLEHOLD = 2, ACT_SIMPLE = 3 }; * * This is used for FPS only. See estimate.c */ -#define FLOW_START_THRESHOLD (4096) +#define FLOW_START_THRESHOLD (6000) + +#define CLOSE_ENOUGH (0.99) /** * All fields come from the ip protocol header. diff --git a/drl/standard.c b/drl/standard.c index 099e6cd..93cb663 100644 --- a/drl/standard.c +++ b/drl/standard.c @@ -169,7 +169,10 @@ void standard_table_remove(standard_flow_table table, standard_flow *flow) { } } - assert(current != NULL); + //assert(current != NULL); + if (current == NULL) { + printlog(LOG_WARN, "Flow %p disappeared?\n", current); + } } /* Remove the flow from the linked list. */ diff --git a/drl/ulogd_DRL.c b/drl/ulogd_DRL.c index 0d734a7..ef5cf20 100644 --- a/drl/ulogd_DRL.c +++ b/drl/ulogd_DRL.c @@ -1109,6 +1109,16 @@ static int create_htb_hierarchy(drl_instance_t *instance) { /* End delay testing */ #endif +//#define SFQTEST + +#ifdef SFQTEST + sprintf(cmd, "/sbin/tc qdisc del dev eth0 parent 1:1000 handle 1000 pfifo"); + execute_cmd(cmd); + + sprintf(cmd, "/sbin/tc qdisc replace dev eth0 parent 1:1000 handle 1000 sfq perturb 20"); + execute_cmd(cmd); +#endif + return 0; }