Commit c0d736ef authored by 's avatar

Added histogram of inter-burst gaps. Gap size is measured in "bytes".


git-svn-id: file:///home/svn/mapi/trunk@1395 8d5bb341-7cf1-0310-8cf6-ba355fef3186
parent 7d223639
......@@ -23,6 +23,7 @@
// End Implementation dependencies --------------------------------------------
// Debugging {{{
// informations about received packets
//#define __BURST_DEBUG
// informations about manipulation with received packets
......@@ -33,6 +34,7 @@
//#define __BURST_DEBUG_LAG_LEAD_MAX
// print warning if timestamping is not reliable (typically at NIC card)
//#define __BURST_DEBUG_WARNINGS
// }}}
// fixed point ntp timestamp aritmetics
......@@ -206,11 +208,13 @@ struct burst_inst_struct {
unsigned long burst_bytes; /* collectors */
unsigned long burst_packets;
int cats;
// Debugging {{{
#ifdef __BURST_DEBUG_LAG_LEAD_MAX
unsigned int initialized;
unsigned long long lagmax;
unsigned long long leadmax;
#endif
// }}}
};
static int burst_instance(mapidflib_function_instance_t *instance,
......@@ -226,6 +230,7 @@ static int burst_instance(mapidflib_function_instance_t *instance,
instance->def->shm_size = ((max-min)/step+2)*sizeof(burst_category_t);
// Debugging {{{
#ifdef __BURST_DEBUG
printf("Compiled with DEBUG flag\n");
#endif
......@@ -245,6 +250,7 @@ printf("Compiled with DEBUG_WARNINGS flag\n");
#ifdef __BURST_DEBUG
printf("burst_instace(): min %d, max %d, step %d, shm_size %d\n", min, max, step, instance->def->shm_size);
#endif
// }}}
return 0;
}
......@@ -256,6 +262,7 @@ static int burst_init(mapidflib_function_instance_t *instance,
int min, max, step;
int iatime, lag, lead;
int link_speed;
//// l_fp B_frac_tmp;
fargs = instance->args;
min = getargint(&fargs);
......@@ -282,12 +289,17 @@ static int burst_init(mapidflib_function_instance_t *instance,
internal_data_ptr->lag_s = (double) lag / 1000000000;
internal_data_ptr->lead_s = (double) lead / 1000000000;
internal_data_ptr->B_s = (double) 8 / ((double) link_speed * 1000000); // 1B [s]
//// //DTOULL(internal_data_ptr->B_s, internal_data_ptr->B_frac); // 1B [frac]
//// DTOLFP(internal_data_ptr->B_s, B_frac_tmp); // 1B [frac]
//// LFPTOULL(B_frac_tmp, internal_data_ptr->B_frac); // 1B [frac]
memset(&internal_data_ptr->last_pkt_ts, 0, sizeof(l_fp));
internal_data_ptr->last_pkt_wlen = 0;
internal_data_ptr->burst_bytes = 0;
internal_data_ptr->burst_packets = 0;
internal_data_ptr->cats = (max - min) / step + 2 - 1;
// Debugging {{{
#ifdef __BURST_DEBUG_LAG_LEAD_MAX
internal_data_ptr->initialized = 0;
internal_data_ptr->lagmax = 0;
......@@ -299,6 +311,7 @@ printf("iatime %23.12f lag %23.12f lead %23.12f\n", internal_data_ptr->iatime_s,
printf("link_speed: %u (mbps)\n", link_speed);
printf("1 B: %23.12f (sec)\n\n\n", internal_data_ptr->B_s);
#endif
// }}}
return 0;
}
......@@ -312,10 +325,15 @@ static int burst_process(mapidflib_function_instance_t *instance,
int cat;
// count with l_fp
l_fp pkt_ts_min, pkt_ts_max, len_ts_min, len_ts_max;
l_fp pkt_ts_min, pkt_ts_max, pkt_ts_exa, len_ts_min, len_ts_max, len_ts_exa;
// store final values in ull
unsigned long long pkt_ts_ull_min, pkt_ts_ull_max;
unsigned long long pkt_ts_ull_min, pkt_ts_ull_max, pkt_ts_ull_exa;
// gap
unsigned long long gap_len_frac;
double gap_len_s;
unsigned long long gap_len_b;
// Debugging {{{
// just ascii art, not code
#ifdef __BURST_DEBUG
l_fp delta, pkt_ts, len_ts, assumed_ts;
......@@ -338,6 +356,7 @@ double d_i, d_f;
#endif
#endif
#endif
// }}}
internal_data_ptr = (struct burst_inst_struct *) (instance->internal_data);
......@@ -346,13 +365,17 @@ double d_i, d_f;
// start with last_pkt_ts
pkt_ts_max = internal_data_ptr->last_pkt_ts;
pkt_ts_min = internal_data_ptr->last_pkt_ts;
pkt_ts_exa = internal_data_ptr->last_pkt_ts;
// add wlen, iatime, +-
DTOLFP(internal_data_ptr->last_pkt_wlen * internal_data_ptr->B_s + internal_data_ptr->iatime_s - internal_data_ptr->lead_s, len_ts_min);
DTOLFP(internal_data_ptr->last_pkt_wlen * internal_data_ptr->B_s + internal_data_ptr->iatime_s + internal_data_ptr->lag_s, len_ts_max);
DTOLFP(internal_data_ptr->last_pkt_wlen * internal_data_ptr->B_s + internal_data_ptr->iatime_s, len_ts_exa);
L_ADD(pkt_ts_min, len_ts_min);
L_ADD(pkt_ts_max, len_ts_max);
L_ADD(pkt_ts_exa, len_ts_exa);
// Debugging {{{
#ifdef __BURST_DEBUG_WARNINGS
unsigned long long lastullts;
LFPTOULL(internal_data_ptr->last_pkt_ts, lastullts);
......@@ -430,11 +453,13 @@ printf("leadmax : %012lu.%012lu (ntp) == %010.0f + %.012f (sec)\n", laglead.l
}
}
#endif
// }}}
// resolve bursts
LFPTOULL(pkt_ts_min, pkt_ts_ull_min);
LFPTOULL(pkt_ts_max, pkt_ts_ull_max);
LFPTOULL(pkt_ts_exa, pkt_ts_ull_exa);
// not burst
if(pkt_head->ts < pkt_ts_ull_min || pkt_head->ts > pkt_ts_ull_max) {
......@@ -442,18 +467,23 @@ printf("leadmax : %012lu.%012lu (ntp) == %010.0f + %.012f (sec)\n", laglead.l
// count measurement into results
if(internal_data_ptr->burst_bytes < (unsigned long) internal_data_ptr->min) {
// Debugging {{{
#ifdef __BURST_VERBOSE
printf("process: I am sed :-( I wish I have [0.x] to save this burst into.\n");
#endif
// }}}
cat = 0;
}
else cat = (((long signed int) internal_data_ptr->burst_bytes - internal_data_ptr->min ) / internal_data_ptr->step) + 1; // +1: category 0 is reserved for <0, min>
else cat = ((internal_data_ptr->burst_bytes - internal_data_ptr->min) / internal_data_ptr->step) + 1; // +1: category 0 is reserved for <0, min>
if(cat > internal_data_ptr->cats) {
// Debugging {{{
#ifdef __BURST_VERBOSE
printf("process: I am sed :-( I wish I have [%d] to save this burst into.\n", cat);
#endif
// }}}
cat = internal_data_ptr->cats;
}
......@@ -463,19 +493,45 @@ printf("process: I am sed :-( I wish I have [%d] to save this burst into.\n", ca
if(internal_data_ptr->burst_bytes > 0) // not the very first packet
((burst_category_t *)instance->result.data)[cat].bursts++;
// Debugging {{{
#ifdef __BURST_VERBOSE
printf("process: save [%d / %d] += %lu B (= %lu B), += %lu pkts (= %lu pkts), +1 burst (= %lu bursts)\n", cat, internal_data_ptr->cats, internal_data_ptr->burst_bytes, ((burst_category_t *)instance->result.data)[cat].bytes, internal_data_ptr->burst_packets, ((burst_category_t *)instance->result.data)[cat].packets, ((burst_category_t *)instance->result.data)[cat].bursts);
#endif
// }}}
// and start new measurement
internal_data_ptr->burst_bytes = 0; // reset collectors
internal_data_ptr->burst_packets = 0;
// NEW: store inter-burst gap size too
if(pkt_head->ts > pkt_ts_ull_exa) {
gap_len_frac = pkt_head->ts - pkt_ts_ull_exa;
ULLTOD(gap_len_frac, gap_len_s);
gap_len_b = (unsigned long long) (gap_len_s / internal_data_ptr->B_s);
}
else gap_len_b = 0;
if(gap_len_b < internal_data_ptr->min) {
cat = 0;
} else cat = ((gap_len_b - internal_data_ptr->min) / internal_data_ptr->step) + 1; // +1: category 0 is reserved for <0, min>
if(cat > internal_data_ptr->cats) {
cat = internal_data_ptr->cats;
}
((burst_category_t *)instance->result.data)[cat].gap_bytes += gap_len_b;
if(internal_data_ptr->burst_bytes > 0) // not the very first packet
((burst_category_t *)instance->result.data)[cat].gaps++;
}
else { // if one bursts, show goes on
// Debugging {{{
#ifdef __BURST_VERBOSE
printf("process: collect [x] (BURST detected)\n");
#endif
// }}}
}
......@@ -536,3 +592,5 @@ mapidflib_function_def_t* burst_get_funct_info() {
}
// end of burst.c
/* vim: set foldmethod=marker foldmarker=\ {{{,\ }}} foldclose= foldcolumn=0 : */
......@@ -5,6 +5,8 @@ typedef struct burst_category {
unsigned long bytes;
unsigned long packets;
unsigned long bursts;
unsigned long gap_bytes;
unsigned long gaps;
} burst_category_t;
#endif
......@@ -116,10 +116,12 @@ int main(int argc, char *argv[]) {
res = mapi_read_results(fd, fid);
for(i = 0; i < categories; i++) {
printf("%d: burst[%d]: %lu bytes, %lu packets, %lu bursts\n", loop, i,
printf("%d: burst[%d]: %lu bytes, %lu packets, %lu bursts, %lu gap bytes, %lu gaps\n", loop, i,
((burst_category_t*)res->res)[i].bytes - ((burst_category_t*)oldres)[i].bytes,
((burst_category_t*)res->res)[i].packets - ((burst_category_t*)oldres)[i].packets,
((burst_category_t*)res->res)[i].bursts - ((burst_category_t*)oldres)[i].bursts
((burst_category_t*)res->res)[i].bursts - ((burst_category_t*)oldres)[i].bursts,
((burst_category_t*)res->res)[i].gap_bytes - ((burst_category_t*)oldres)[i].gap_bytes,
((burst_category_t*)res->res)[i].gaps - ((burst_category_t*)oldres)[i].gaps
);
((burst_category_t *)oldres)[i] = ((burst_category_t *)res->res)[i];
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment