This commit is contained in:
Quentin 2019-09-16 15:39:16 +02:00
parent 840f95eaa3
commit 1b889a1761
2 changed files with 11 additions and 6 deletions

View file

@ -6,7 +6,7 @@
#include "timer.h" #include "timer.h"
#include "proxy.h" #include "proxy.h"
uint64_t compute_delta(struct timespec* prev_time, uint64_t max) { uint64_t compute_delta(struct timespec* prev_time, uint64_t max, uint8_t update) {
struct timespec curr; struct timespec curr;
int secs, nsecs; int secs, nsecs;
uint64_t mili_sec; uint64_t mili_sec;
@ -18,7 +18,7 @@ uint64_t compute_delta(struct timespec* prev_time, uint64_t max) {
} }
secs = curr.tv_sec - prev_time->tv_sec; secs = curr.tv_sec - prev_time->tv_sec;
nsecs = curr.tv_nsec - prev_time->tv_nsec; nsecs = curr.tv_nsec - prev_time->tv_nsec;
*prev_time = curr; if(update) *prev_time = curr;
mili_sec = secs * 1000 + nsecs / 1000000; mili_sec = secs * 1000 + nsecs / 1000000;
if (mili_sec > max) mili_sec = max; if (mili_sec > max) mili_sec = max;
@ -120,7 +120,7 @@ int schedule(struct evt_core_ctx* ctx, struct evt_core_fdinfo* fdinfo, struct bu
// 4. We compute the time difference // 4. We compute the time difference
uint64_t mili_sec = 0; uint64_t mili_sec = 0;
if (protect == thunderc->total_links) if (protect == thunderc->total_links)
mili_sec = compute_delta (&thunderc->prev_link_time, UINT16_MAX); mili_sec = compute_delta (&thunderc->prev_link_time, UINT16_MAX, 1);
//printf("send packet on link %d with delta=%ld\n", thunderc->selected_link, mili_sec); //printf("send packet on link %d with delta=%ld\n", thunderc->selected_link, mili_sec);
// 5. We create the array // 5. We create the array
@ -215,7 +215,7 @@ void classify(struct evt_core_ctx* ctx, struct evt_core_fdinfo* fdinfo, struct b
//printf("Received %ld packets on link %d\n", thunderc->received_pkts_on_link[link_id], link_id); //printf("Received %ld packets on link %d\n", thunderc->received_pkts_on_link[link_id], link_id);
struct link_info *li = &ap->fmt.content.link_monitoring_thunder.links_status; struct link_info *li = &ap->fmt.content.link_monitoring_thunder.links_status;
uint64_t mili_sec = compute_delta (&thunderc->prev_rcv_link_time, UINT16_MAX); uint64_t mili_sec = compute_delta (&thunderc->prev_rcv_link_time, UINT16_MAX, 1);
for (int i = 0; i < thunderc->total_links; i++) { for (int i = 0; i < thunderc->total_links; i++) {
if (thunderc->received_pkts_on_link[i] <= 1) continue; if (thunderc->received_pkts_on_link[i] <= 1) continue;
thunderc->rcv_delta_t_per_link[i] += mili_sec; thunderc->rcv_delta_t_per_link[i] += mili_sec;
@ -302,7 +302,8 @@ void classify(struct evt_core_ctx* ctx, struct evt_core_fdinfo* fdinfo, struct b
} }
if (ctx->verbose > 1) fprintf(stderr, " [algo_thunder] Classify done\n"); if (ctx->verbose > 1) fprintf(stderr, " [algo_thunder] Classify done\n");
printf("Blacklisted links: "); uint64_t ts = compute_delta (&thunderc->start_time, UINT64_MAX, 0);
printf("[%ld] Blacklisted links: ", ts);
for (int i = 0; i < thunderc->total_links; i++) { for (int i = 0; i < thunderc->total_links; i++) {
if (is_blacklisted (thunderc, i)) printf("_"); if (is_blacklisted (thunderc, i)) printf("_");
else printf("U"); else printf("U");
@ -446,6 +447,10 @@ void algo_thunder_init(struct evt_core_ctx* ctx, struct algo_ctx* app_ctx, struc
thunderc->received_pkts_on_link[i] = 1; thunderc->received_pkts_on_link[i] = 1;
thunderc->rcv_delta_t_per_link[i] = 0; thunderc->rcv_delta_t_per_link[i] = 0;
} }
if (clock_gettime(CLOCK_MONOTONIC, &thunderc->start_time) == -1){
perror("clock_gettime error");
exit(EXIT_FAILURE);
}
union abstract_packet links = {}; union abstract_packet links = {};
//fprintf(stderr, "Total links %d\n", thunderc->total_links); //fprintf(stderr, "Total links %d\n", thunderc->total_links);

View file

@ -113,6 +113,6 @@ struct thunder_ctx {
int64_t estimated_sent[MAX_LINKS]; int64_t estimated_sent[MAX_LINKS];
size_t monit_pkt_size; size_t monit_pkt_size;
int64_t allowed_jitter_ms; int64_t allowed_jitter_ms;
struct timespec prev_link_time, prev_rcv_link_time; struct timespec prev_link_time, prev_rcv_link_time, start_time;
}; };
void get_estimation(struct thunder_ctx* thunderc, int64_t* sorted_estimation, uint64_t* sorted_occurencies); void get_estimation(struct thunder_ctx* thunderc, int64_t* sorted_estimation, uint64_t* sorted_occurencies);