Log time
This commit is contained in:
parent
840f95eaa3
commit
1b889a1761
2 changed files with 11 additions and 6 deletions
|
@ -6,7 +6,7 @@
|
|||
#include "timer.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;
|
||||
int secs, nsecs;
|
||||
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;
|
||||
nsecs = curr.tv_nsec - prev_time->tv_nsec;
|
||||
*prev_time = curr;
|
||||
if(update) *prev_time = curr;
|
||||
mili_sec = secs * 1000 + nsecs / 1000000;
|
||||
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
|
||||
uint64_t mili_sec = 0;
|
||||
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);
|
||||
// 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);
|
||||
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++) {
|
||||
if (thunderc->received_pkts_on_link[i] <= 1) continue;
|
||||
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");
|
||||
|
||||
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++) {
|
||||
if (is_blacklisted (thunderc, i)) printf("_");
|
||||
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->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 = {};
|
||||
//fprintf(stderr, "Total links %d\n", thunderc->total_links);
|
||||
|
|
|
@ -113,6 +113,6 @@ struct thunder_ctx {
|
|||
int64_t estimated_sent[MAX_LINKS];
|
||||
size_t monit_pkt_size;
|
||||
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);
|
||||
|
|
Loading…
Reference in a new issue