X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=lib%2Fsflow_poller.c;h=d2e4155210d90602d20290ea2213ef24b44052ee;hb=HEAD;hp=ffd09d3c2ae777c634a7d98fb29493f5ab60922d;hpb=2ad2eb042517b975d761d456cceb5c9325c4aaa7;p=sliver-openvswitch.git diff --git a/lib/sflow_poller.c b/lib/sflow_poller.c index ffd09d3c2..d2e415521 100644 --- a/lib/sflow_poller.c +++ b/lib/sflow_poller.c @@ -1,5 +1,9 @@ -/* Copyright (c) 2002-2009 InMon Corp. Licensed under the terms of the InMon sFlow licence: */ -/* http://www.inmon.com/technology/sflowlicense.txt */ +/* Copyright (c) 2002-2009 InMon Corp. Licensed under the terms of either the + * Sun Industry Standards Source License 1.1, that is available at: + * http://host-sflow.sourceforge.net/sissl.html + * or the InMon sFlow License, that is available at: + * http://www.inmon.com/technology/sflowlicense.txt + */ #include "sflow_api.h" @@ -23,10 +27,10 @@ void sfl_poller_init(SFLPoller *poller, /* clear everything */ memset(poller, 0, sizeof(*poller)); - + /* restore the linked list ptr */ poller->nxt = nxtPtr; - + /* now copy in the parameters */ poller->agent = agent; poller->dsi = dsi; /* structure copy */ @@ -68,10 +72,29 @@ u_int32_t sfl_poller_get_sFlowCpInterval(SFLPoller *poller) { void sfl_poller_set_sFlowCpInterval(SFLPoller *poller, u_int32_t sFlowCpInterval) { poller->sFlowCpInterval = sFlowCpInterval; - /* Set the countersCountdown to be a randomly selected value between 1 and - sFlowCpInterval. That way the counter polling would be desynchronised - (on a 200-port switch, polling all the counters in one second could be harmful). */ - poller->countersCountdown = 1 + (random() % sFlowCpInterval); + if(sFlowCpInterval) { + /* Set the countersCountdown to be a randomly selected value between 1 and + sFlowCpInterval. That way the counter polling will be desynchronised + (on a 200-port switch, polling all the counters in one second could be harmful). + In a large network, even this might not be ideal if time-synchroniziation + between devices is close and counters are always polled on second boundaries. If + 1000 different devices all send an sFlow datagram on the same second boundary + it could result in an antisocial burst. + However when counter-samples are packed into the export datagram they do not + always result in that datagram being sent immediately. It is more likely that + a subsequent packet-sample will be the one that triggers the datagram to be sent. + The packet-sample events are not sychronized to any clock, so that results in + excellent desynchronization (http://blog.sflow.com/2009/05/measurement-traffic.html). + Another smoothing factor is that the tick() function called here is usually + driven from a fairly "soft" polling loop rather than a hard real-time event. + */ + poller->countersCountdown = 1 + (random() % sFlowCpInterval); + } + else { + /* Setting sFlowCpInterval to 0 disables counter polling altogether. Thanks to + Andy Kitchingman for spotting this ommission. */ + poller->countersCountdown = 0; + } } /*_________________---------------------------------__________________