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

Update IPFIXLIB to make variance calculation of pktdist/length aware of...

Update IPFIXLIB to make variance calculation of pktdist/length aware of division-by-zero, havard.mork@gmail.com

git-svn-id: file:///home/svn/mapi/branches/haavardm-mapi@60 8d5bb341-7cf1-0310-8cf6-ba355fef3186
parent b0e5a12d
......@@ -1390,56 +1390,60 @@ static void handleTemplate(np_ctxt_t *npctxt, V9TemplateId *theTemplate,
outBuffer, outBufferBegin, outBufferMax);
case FID_VAR_PKT_DIST:
{
float f;
u_int64_t n;
float f = 0.0f;
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)));
if(n>1)
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)));
if(n>1)
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;
case FID_EXPVAL_PKT_DIST:
{
float f;
if(direction==0)
float f = 0.0f;
if(direction==0 && theFlow->pktSent>0)
f = (float)(theFlow->src2dst_expval_pktdist_x/(u_int64_t)theFlow->pktSent);
else
else if(theFlow->pktRcvd>0)
f = (float)(theFlow->dst2src_expval_pktdist_x/(u_int64_t)theFlow->pktRcvd);
copyFloat(f, outBuffer,outBufferBegin,outBufferMax);
}
break;
case FID_VAR_PKT_LENGTH:
{
float f;
float f = 0.0f;
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)));
if(n>1)
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)));
if(n>1)
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:
{
float f;
if(direction==0)
float f = 0.0f;
if(direction==0 && theFlow->pktSent>0)
f = (float)(theFlow->src2dst_expval_pktlength_x/(u_int64_t)theFlow->pktSent);
else
else if(theFlow->pktRcvd>0)
f = (float)(theFlow->dst2src_expval_pktlength_x/(u_int64_t)theFlow->pktRcvd);
copyFloat(f, outBuffer,outBufferBegin,outBufferMax);
}
......
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