Commit 10708988 authored by 's avatar
Browse files

BURST now returns not only size in bytes, but a number of packets and bursts...

BURST now returns not only size in bytes, but a number of packets and bursts in each category as well.


git-svn-id: file:///home/svn/mapi/trunk@1305 8d5bb341-7cf1-0310-8cf6-ba355fef3186
parent a0609b50
...@@ -319,7 +319,7 @@ struct stats { ...@@ -319,7 +319,7 @@ struct stats {
.fi .fi
.\"-------------------------------------------------------- .\"--------------------------------------------------------
.IP "\fBBURST\fP (int \fImin\fP, int \fImax\fP, int \fIstep\fP, int \fIiftime\fP, int \fIlate\fP, int \fIearly\fP, int \fIlink_speed\fP)" .IP "\fBBURST\fP (int \fImin\fP, int \fImax\fP, int \fIstep\fP, int \fIiftime\fP, int \fIlate\fP, int \fIearly\fP, int \fIlink_speed\fP)"
Returns the histogram of bursts. Bursts are categorized according to their total size in bytes, the result is an array of total sizes of these bursts. Catogory 0 always holds bursts of lower size than the minimum size specified (\fImin\fP [B]). The last category always holds bursts of greater size than the maximum size specified (\fImax\fP [B]). \fIstep\fP [B] specifies the precission of the histogram. Returns the histogram of bursts. Bursts are categorized according to their total size in bytes, the result is an array, where each category holds its size in bytes and number of packets and bursts collected. Catogory 0 always holds bursts of lower size than the minimum size specified (\fImin\fP [B]). The last category always holds bursts of greater size than the maximum size specified (\fImax\fP [B]). \fIstep\fP [B] specifies the precission of the histogram.
.nf .nf
Category Burst size in bytes Category Burst size in bytes
...@@ -334,7 +334,15 @@ N >= max ...@@ -334,7 +334,15 @@ N >= max
Number of categories returned: (\fImax\fP - \fImin\fP) / \fIstep\fP + 2 Number of categories returned: (\fImax\fP - \fImin\fP) / \fIstep\fP + 2
Type of results: \fBunsigned long[]\fP. Type of results: \fBstruct burst_category[]\fP.
.nf
struct burst_category {
unsigned long bytes;
unsigned long packets;
unsigned long bursts;
};
.fi
.\"-------------------------------------------------------- .\"--------------------------------------------------------
.SH "EXAMPLES" .SH "EXAMPLES"
......
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
// informations about received packets // informations about received packets
//#define __BURST_DEBUG //#define __BURST_DEBUG
// informations about manipulation with received packets // informations about manipulation with received packets
//#define __BURST_VERBOSE #define __BURST_VERBOSE
// print lag/lead for each packets (if you need some stats...) // print lag/lead for each packets (if you need some stats...)
//#define __BURST_DEBUG_LAG_LEAD //#define __BURST_DEBUG_LAG_LEAD
// print maximal/minimal lag/lead (if you need some stats...) // print maximal/minimal lag/lead (if you need some stats...)
...@@ -203,7 +203,8 @@ struct burst_inst_struct { ...@@ -203,7 +203,8 @@ struct burst_inst_struct {
double B_s; /* 1B [s] */ double B_s; /* 1B [s] */
l_fp last_pkt_ts; l_fp last_pkt_ts;
unsigned int last_pkt_wlen; unsigned int last_pkt_wlen;
unsigned long burst_length; /* collector */ unsigned long burst_bytes; /* collectors */
unsigned long burst_packets;
int cats; int cats;
#ifdef __BURST_DEBUG_LAG_LEAD_MAX #ifdef __BURST_DEBUG_LAG_LEAD_MAX
unsigned int initialized; unsigned int initialized;
...@@ -223,7 +224,7 @@ static int burst_instance(mapidflib_function_instance_t *instance, ...@@ -223,7 +224,7 @@ static int burst_instance(mapidflib_function_instance_t *instance,
max = getargint(&fargs); max = getargint(&fargs);
step = getargint(&fargs); step = getargint(&fargs);
instance->def->shm_size = ((max-min)/step+2)*sizeof(unsigned long); instance->def->shm_size = ((max-min)/step+2)*sizeof(burst_category_t);
#ifdef __BURST_DEBUG #ifdef __BURST_DEBUG
printf("Compiled with DEBUG flag\n"); printf("Compiled with DEBUG flag\n");
...@@ -283,7 +284,8 @@ static int burst_init(mapidflib_function_instance_t *instance, ...@@ -283,7 +284,8 @@ static int burst_init(mapidflib_function_instance_t *instance,
internal_data_ptr->B_s = (double) 8 / ((double) link_speed * 1000000); // 1B [s] internal_data_ptr->B_s = (double) 8 / ((double) link_speed * 1000000); // 1B [s]
internal_data_ptr->last_pkt_wlen = 0; internal_data_ptr->last_pkt_wlen = 0;
internal_data_ptr->burst_length = 0; internal_data_ptr->burst_bytes = 0;
internal_data_ptr->burst_packets = 0;
internal_data_ptr->cats = (max - min) / step + 2 - 1; internal_data_ptr->cats = (max - min) / step + 2 - 1;
#ifdef __BURST_DEBUG_LAG_LEAD_MAX #ifdef __BURST_DEBUG_LAG_LEAD_MAX
...@@ -438,14 +440,14 @@ printf("leadmax : %012lu.%012lu (ntp) == %010.0f + %.012f (sec)\n", laglead.l ...@@ -438,14 +440,14 @@ printf("leadmax : %012lu.%012lu (ntp) == %010.0f + %.012f (sec)\n", laglead.l
if(pkt_head->ts < pkt_ts_ull_min || pkt_head->ts > pkt_ts_ull_max) { if(pkt_head->ts < pkt_ts_ull_min || pkt_head->ts > pkt_ts_ull_max) {
// count measurement into results // count measurement into results
if(internal_data_ptr->burst_length < internal_data_ptr->min) { if(internal_data_ptr->burst_bytes < (unsigned long) internal_data_ptr->min) {
#ifdef __BURST_VERBOSE #ifdef __BURST_VERBOSE
printf("process: I am sed :-( I wish I have [0.x] to save this burst into.\n"); printf("process: I am sed :-( I wish I have [0.x] to save this burst into.\n");
#endif #endif
cat = 0; cat = 0;
} }
else cat = (((long signed int) internal_data_ptr->burst_length - internal_data_ptr->min ) / internal_data_ptr->step) + 1; // +1: category 0 is reserved for <0, min> 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>
if(cat > internal_data_ptr->cats) { if(cat > internal_data_ptr->cats) {
...@@ -456,14 +458,18 @@ printf("process: I am sed :-( I wish I have [%d] to save this burst into.\n", ca ...@@ -456,14 +458,18 @@ printf("process: I am sed :-( I wish I have [%d] to save this burst into.\n", ca
cat = internal_data_ptr->cats; cat = internal_data_ptr->cats;
} }
((unsigned long*)instance->result.data)[cat] += internal_data_ptr->burst_length; ((burst_category_t *)instance->result.data)[cat].bytes += internal_data_ptr->burst_bytes;
((burst_category_t *)instance->result.data)[cat].packets += internal_data_ptr->burst_packets;
if(internal_data_ptr->burst_bytes > 0) // not the very first packet
((burst_category_t *)instance->result.data)[cat].bursts++;
#ifdef __BURST_VERBOSE #ifdef __BURST_VERBOSE
printf("process: save [%d / %d] += %lu (sum %lu)\n", cat, internal_data_ptr->cats, internal_data_ptr->burst_length, ((unsigned long*)instance->result.data)[cat]); 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 #endif
// and start new measurement // and start new measurement
internal_data_ptr->burst_length = 0; // reset collector internal_data_ptr->burst_bytes = 0; // reset collectors
internal_data_ptr->burst_packets = 0;
} }
else { // if one bursts, show goes on else { // if one bursts, show goes on
...@@ -474,7 +480,8 @@ printf("process: collect [x] (BURST detected)\n"); ...@@ -474,7 +480,8 @@ printf("process: collect [x] (BURST detected)\n");
} }
// count current into collector // count current into collector
internal_data_ptr->burst_length += (unsigned long) pkt_head->wlen; internal_data_ptr->burst_bytes += (unsigned long) pkt_head->wlen;
internal_data_ptr->burst_packets++;
// save pktinfo for next generation // save pktinfo for next generation
ULLTOLFP(pkt_head->ts, internal_data_ptr->last_pkt_ts); ULLTOLFP(pkt_head->ts, internal_data_ptr->last_pkt_ts);
...@@ -488,7 +495,8 @@ static int burst_reset(mapidflib_function_instance_t* instance) { ...@@ -488,7 +495,8 @@ static int burst_reset(mapidflib_function_instance_t* instance) {
internal_data_ptr = (struct burst_inst_struct *) (instance->internal_data); internal_data_ptr = (struct burst_inst_struct *) (instance->internal_data);
L_SUB(internal_data_ptr->last_pkt_ts, internal_data_ptr->last_pkt_ts); L_SUB(internal_data_ptr->last_pkt_ts, internal_data_ptr->last_pkt_ts);
internal_data_ptr->burst_length = 0; internal_data_ptr->burst_bytes = 0;
internal_data_ptr->burst_packets = 0;
memset(instance->result.data, 0, instance->def->shm_size); memset(instance->result.data, 0, instance->def->shm_size);
return 0; return 0;
......
...@@ -5,7 +5,11 @@ ...@@ -5,7 +5,11 @@
// End interface dependencies ------------------------------------------------- // End interface dependencies -------------------------------------------------
typedef struct burst_category {
unsigned long bytes;
unsigned long packets;
unsigned long bursts;
} burst_category_t;
#endif #endif
......
...@@ -6,6 +6,12 @@ ...@@ -6,6 +6,12 @@
#include <string.h> #include <string.h>
typedef struct burst {
unsigned long bytes;
unsigned long packets;
unsigned long bursts;
} burst_category_t;
int main(int argc, char *argv[]) { int main(int argc, char *argv[]) {
int fd; int fd;
int fid; int fid;
...@@ -83,7 +89,7 @@ int main(int argc, char *argv[]) { ...@@ -83,7 +89,7 @@ int main(int argc, char *argv[]) {
// allocate memory to store results in // allocate memory to store results in
if((oldres = malloc(oldres_size = categories * sizeof(unsigned long))) == NULL) { if((oldres = malloc(oldres_size = categories * sizeof(burst_category_t))) == NULL) {
fprintf(stderr, "Could not allocate internal data.\n"); fprintf(stderr, "Could not allocate internal data.\n");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
...@@ -115,8 +121,12 @@ int main(int argc, char *argv[]) { ...@@ -115,8 +121,12 @@ int main(int argc, char *argv[]) {
res = mapi_read_results(fd, fid); res = mapi_read_results(fd, fid);
for(i = 0; i < categories; i++) { for(i = 0; i < categories; i++) {
printf("%d: burst[%d]: %lu\n", loop, i, ((unsigned long*)res->res)[i] - ((unsigned long*)oldres)[i]); printf("%d: burst[%d]: %lu bytes, %lu packets, %lu bursts\n", loop, i,
((unsigned long*)oldres)[i] = ((unsigned long*)res->res)[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 *)oldres)[i] = ((burst_category_t *)res->res)[i];
} }
printf("\n"); printf("\n");
......
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