Commit b0e5a12d authored by Håvard Moås's avatar Håvard Moås
Browse files

Update IPFIXLIB to change standard deviation into variance, also take into...

Update IPFIXLIB to change standard deviation into variance, also take into consideration that it is a sample, hence n-1, and not n. Statistical work by Andreas and Simon.  havard.mork@gmail.com

git-svn-id: file:///home/svn/mapi/branches/haavardm-mapi@59 8d5bb341-7cf1-0310-8cf6-ba355fef3186
parent ac92889b
......@@ -162,14 +162,14 @@ typedef struct hashBucket {
u_int64_t src2dstOctetDeltaCount;
u_int64_t dst2srcOctetDeltaCount;
//u_int64_t src2dstOctetTotalCount;
//u_int64_t dst2srcOctetTotalCount;
/*u_int64_t src2dstOctetTotalCount;
u_int64_t dst2srcOctetTotalCount;*/
/* The following used to calculate E(X) and E(X2) for pkt dist and length */
u_int64_t src2dst_expval_pktdist_x;
u_int64_t src2dst_expval_pktdist_x2;
u_int64_t src2dst_expval_pktlength_x;
u_int64_t src2dst_expval_pktlength_x2;
u_int64_t dst2src_expval_pktdist_x;
u_int64_t dst2src_expval_pktdist_x2;
u_int64_t dst2src_expval_pktlength_x;
......
......@@ -46,9 +46,9 @@
#define FID_RATE_100MS_MIN 32783
#define FID_RATE_10MS_MAX 32784
#define FID_RATE_10MS_MIN 32785
#define FID_STDDEV_PKT_DIST 32790
#define FID_VAR_PKT_DIST 32790
#define FID_EXPVAL_PKT_DIST 32791
#define FID_STDDEV_PKT_LENGTH 32792
#define FID_VAR_PKT_LENGTH 32792
#define FID_EXPVAL_PKT_LENGTH 32793
......@@ -776,9 +776,9 @@ static V9TemplateId ver9_templates[] = {
{ FID_RATE_100MS_MIN, 4, "MINRATE_100MS" },
{ FID_RATE_10MS_MAX, 4, "MAXRATE_10MS" },
{ FID_RATE_10MS_MIN, 4, "MINRATE_10MS" },
{ FID_STDDEV_PKT_DIST, 4, "STDDEV_PKT_DIST" }, // returns float-32
{ FID_EXPVAL_PKT_DIST, 4, "EXPVAL_PKT_DIST" }, // returns float-32
{ FID_STDDEV_PKT_LENGTH,4, "STDDEV_PKT_LENGTH" }, // returns float-32
{ FID_VAR_PKT_DIST, 4, "VAR_PKT_DIST" }, // returns float-32
{ FID_EXPVAL_PKT_DIST, 4, "EXPVAL_PKT_DIST" }, // returns float-32
{ FID_VAR_PKT_LENGTH, 4, "VAR_PKT_LENGTH" }, // returns float-32
{ FID_EXPVAL_PKT_LENGTH,4, "EXPVAL_PKT_LENGTH" }, // returns float-32
......@@ -1388,17 +1388,21 @@ static void handleTemplate(np_ctxt_t *npctxt, V9TemplateId *theTemplate,
case FID_PAYLOAD:
exportPayload(npctxt, theFlow, direction, theTemplate,
outBuffer, outBufferBegin, outBufferMax);
case FID_STDDEV_PKT_DIST:
case FID_VAR_PKT_DIST:
{
float f;
if(direction==0)
f = (float)(theFlow->src2dst_expval_pktdist_x2/(u_int64_t)theFlow->pktSent -
theFlow->src2dst_expval_pktdist_x/(u_int64_t)theFlow->pktSent);
else
f = (float)(theFlow->dst2src_expval_pktdist_x2/(u_int64_t)theFlow->pktRcvd -
theFlow->dst2src_expval_pktdist_x/(u_int64_t)theFlow->pktRcvd);
f = __builtin_sqrtf(f);
u_int64_t n;
if(direction==0) {
n = theFlow->pktSent;
f = ((n*theFlow->src2dst_expval_pktdist_x2 -
theFlow->src2dst_expval_pktdist_x*theFlow->src2dst_expval_pktdist_x) /
(n*(n-1)));
} else {
n = theFlow->pktRcvd;
f = ((n*theFlow->dst2src_expval_pktdist_x2 -
theFlow->dst2src_expval_pktdist_x*theFlow->dst2src_expval_pktdist_x) /
(n*(n-1)));
}
copyFloat(f, outBuffer,outBufferBegin, outBufferMax);
}
break;
......@@ -1412,17 +1416,22 @@ static void handleTemplate(np_ctxt_t *npctxt, V9TemplateId *theTemplate,
copyFloat(f, outBuffer,outBufferBegin,outBufferMax);
}
break;
case FID_STDDEV_PKT_LENGTH:
case FID_VAR_PKT_LENGTH:
{
float f;
if(direction==0)
f = (float)(theFlow->src2dst_expval_pktlength_x2/(u_int64_t)theFlow->pktSent -
theFlow->src2dst_expval_pktlength_x/(u_int64_t)theFlow->pktSent);
else
f = (float)(theFlow->dst2src_expval_pktlength_x2/(u_int64_t)theFlow->pktRcvd -
theFlow->dst2src_expval_pktlength_x/(u_int64_t)theFlow->pktRcvd);
f = __builtin_sqrtf(f);
copyFloat(f, outBuffer,outBufferBegin,outBufferMax);
u_int64_t n;
if(direction==0) {
n = theFlow->pktSent;
f = ((n*theFlow->src2dst_expval_pktlength_x2 -
theFlow->src2dst_expval_pktlength_x*theFlow->src2dst_expval_pktlength_x) /
(n*(n-1)));
} else {
n = theFlow->pktRcvd;
f = ((n*theFlow->dst2src_expval_pktlength_x2 -
theFlow->dst2src_expval_pktlength_x*theFlow->dst2src_expval_pktlength_x) /
(n*(n-1)));
}
copyFloat(f, outBuffer,outBufferBegin, outBufferMax);
}
break;
case FID_EXPVAL_PKT_LENGTH:
......@@ -1490,9 +1499,9 @@ turnOnSpecialProcessing(np_ctxt_t *npctxt, u_int element) {
case FID_RATE_10MS_MIN:
npctxt->bitrateCalcEnabled |= BITRATECALC_10MS;
break;
case FID_STDDEV_PKT_DIST:
case FID_VAR_PKT_DIST:
case FID_EXPVAL_PKT_DIST:
case FID_STDDEV_PKT_LENGTH:
case FID_VAR_PKT_LENGTH:
case FID_EXPVAL_PKT_LENGTH:
npctxt->pktDistLengthStddevs = 1;
break;
......
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