From 9bec538552489065c20899978756ece41db7d32b Mon Sep 17 00:00:00 2001 From: Kristopher Chen Date: Mon, 24 Jul 2017 01:07:10 +1000 Subject: [PATCH] Modify sample rates --- ZodiacFX/src/config/config_zodiac.h | 4 ++-- ZodiacFX/src/openflow/of_helper.c | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/ZodiacFX/src/config/config_zodiac.h b/ZodiacFX/src/config/config_zodiac.h index 06dfd4f..4184988 100644 --- a/ZodiacFX/src/config/config_zodiac.h +++ b/ZodiacFX/src/config/config_zodiac.h @@ -52,7 +52,7 @@ #define MAX_METER_13 8 // Maximum number of meter entries in meter table #define MAX_METER_BANDS_13 3 // Maximum number of meter bands per meter -#define POLICING_SAMPLES 12 // Sample for rate limiter -#define POLICING_SLICE 10 // ms time slice for each sample +#define POLICING_SAMPLES 4 // Sample for rate limiter +#define POLICING_SLICE 30 // time (ms) slice for each sample #endif /* CONFIG_ZODIAC_H_ */ diff --git a/ZodiacFX/src/openflow/of_helper.c b/ZodiacFX/src/openflow/of_helper.c index 52d028c..6e41771 100644 --- a/ZodiacFX/src/openflow/of_helper.c +++ b/ZodiacFX/src/openflow/of_helper.c @@ -1407,8 +1407,8 @@ int meter_handler(uint32_t id, uint16_t bytes) { TRACE("of_helper.c: no bands triggered - packet not dropped"); - // Check if last packet was within 1 ms of this one - if(meter_samples[meter_index].sample[sample_index].packet_time == current_time) + // Check if last packet was within 1 slice of this one + if(meter_samples[meter_index].sample[sample_index].packet_time >= (current_time-POLICING_SLICE-1)) { meter_samples[meter_index].sample[sample_index].byte_count += bytes; meter_samples[meter_index].sample[sample_index].packet_count++; @@ -1430,7 +1430,7 @@ int meter_handler(uint32_t id, uint16_t bytes) // Populate (overwrite) next element meter_samples[meter_index].sample[sample_index].packet_time = current_time; meter_samples[meter_index].sample[sample_index].byte_count = bytes; - meter_samples[meter_index].sample[sample_index].packet_count++; + meter_samples[meter_index].sample[sample_index].packet_count = 0; } return METER_NOACT;