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

Update IPFIXLIB for adding experimental support for suppreessing sending of...

Update IPFIXLIB for adding experimental support for suppreessing sending of packets that are 'old' in the export queue, in order to make it congestion-aware. Special IPFIX fields are updated for displaying number of packets/flows/octets that are not exported for this reason. havard.mork@gmail.com

git-svn-id: file:///home/svn/mapi/branches/haavardm-mapi@67 8d5bb341-7cf1-0310-8cf6-ba355fef3186
parent 5d2a3f04
......@@ -294,19 +294,28 @@ typedef struct {
unsigned long long initialSniffTime;
u_short scanCycle /* sec */;
u_int32_t enterpriseId; // Enterprise ID, as required with field IDs >32767. See nprobe.c
u_int32_t enterpriseId; /* Enterprise ID, as required with field IDs >32767. See nprobe.c */
u_int8_t histPktSizeEnabled;
u_int8_t histPktDistEnabled;
u_int16_t histPktSizeBucket[PKTSZ_HISTOGRAM_SLOTS];
u_int16_t histPktDistBucket[PKTDIST_HISTOGRAM_SLOTS];
u_int8_t bitrateCalcEnabled; // Bitset, see BITRATECALC_* flags for options
u_int8_t bitrateCalcEnabled; /* Bitset, see BITRATECALC_* flags for options */
uint8_t pktDistLengthStddevs;
// Exporter's addresses
uint32_t exporterIpv4Address; // in_addr
/* Exporter's addresses */
u_int32_t exporterIpv4Address; /* in_addr */
struct in6_addr exporterIpv6Address;
/* Number of flows, packets, and octets dropped by emitter */
u_int64_t notsent_flows;
u_int64_t notsent_pkts;
u_int64_t notsent_octets;
/* Number of seconds that one flow may be queued for export. Old flows aren't */
/* exported in order to avoid congestion. This is max num of seconds to keep. */
u_int32_t maxExportQueueLatency;
} np_ctxt_t;
#endif
......@@ -129,6 +129,7 @@ exportBucket(np_ctxt_t *npctxt, HashBucket *myBucket)
void queueBucketToExport(np_ctxt_t *npctxt, HashBucket *myBucket) {
pthread_mutex_lock(&exportMutex);
addToList(myBucket, &npctxt->exportQueue);
myBucket->time_exported = time();
npctxt->exportBucketsLen++;
pthread_mutex_unlock(&exportMutex);
//signalCondvar(&npctxt->exportQueueCondvar);
......@@ -142,6 +143,7 @@ void*
dequeueBucketToExport(void* ctxt)
{
np_ctxt_t *npctxt = (np_ctxt_t *)ctxt;
u_int32_t timediff;
while(1) {
if(npctxt->exportQueue == NULL) {
......@@ -161,7 +163,17 @@ dequeueBucketToExport(void* ctxt)
pthread_mutex_unlock(&exportMutex);
/* Export bucket */
exportBucket(npctxt, myBucket);
timediff = time()-myBucket->time_exported;
if(timediff <= npctxt->maxExportQueueLatency) {
exportBucket(npctxt, myBucket);
} else {
if(myBucket->pktRcvd > 0)
npctxt->notsent_flows = npctxt->notsent_flows + 2;
else
npctxt->notsent_flows = npctxt->notsent_flows + 1;
npctxt->notsent_pkts = npctxt->notsent_pkts + myBucket->pktSent + myBucket->pktRcvd;
npctxt->notsent_octets = npctxt->notsent_octets+myBucket->bytesSent+myBucket->bytesRcvd;
}
/* Recycle bucket */
pthread_mutex_lock(&purgedBucketsMutex);
......@@ -1069,6 +1081,8 @@ npInitContext(void)
npctxt->compressFlows = 0;
npctxt->textFormat = NULL;
npctxt->maxExportQueueLatency = 1; // Num of seconds to keep records. NEVER set to 0!
// PENDING: conditionally set this, based on observed parameters.
npctxt->maxPayloadLen = 0;
npctxt->bufferLen = 0;
......@@ -1137,6 +1151,10 @@ npInitContext(void)
npctxt->numObservedFlows = 0;
npctxt->notsent_flows = 0;
npctxt->notsent_pkts = 0;
npctxt->notsent_octets = 0;
// Attempt to get own IP address
if (gethostname(ac, sizeof(ac))==0) {
struct hostent *phe = gethostbyname(ac);
......
......@@ -175,6 +175,8 @@ typedef struct hashBucket {
u_int64_t dst2src_expval_pktlength_x;
u_int64_t dst2src_expval_pktlength_x2;
/* The time which the bucket was put in export queue, time() value */
u_int32_t time_exported;
} HashBucket;
......@@ -1325,14 +1325,14 @@ static void handleTemplate(np_ctxt_t *npctxt, V9TemplateId *theTemplate,
case 165: /* ignoredOctetTotalCount */
copyInt64(0,outBuffer, outBufferBegin, outBufferMax);
break;
case 166: // FIXME
copyInt64(0,outBuffer, outBufferBegin, outBufferMax);
case 166: /* NOTSENT_FLOWS */
copyInt64(npctxt->notsent_flows,outBuffer, outBufferBegin, outBufferMax);
break;
case 167: // FIXME
copyInt64(0,outBuffer, outBufferBegin, outBufferMax);
case 167: /* NOTSENT_PKTS */
copyInt64(npctxt->notsent_pkts,outBuffer, outBufferBegin, outBufferMax);
break;
case 168: // FIXME
copyInt64(0,outBuffer, outBufferBegin, outBufferMax);
case 168: /* NOTSENT_OCTETS */
copyInt64(npctxt->notsent_octets,outBuffer, outBufferBegin, outBufferMax);
break;
case 190:
copyInt16(direction==0?theFlow->src2dstPktlenIpv4:theFlow->dst2srcPktlenIpv4,
......
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