Commit bc10370d authored by Nigel Kukard's avatar Nigel Kukard
Browse files

* Made running totals a little softer

parent 98eef077
......@@ -17,4 +17,3 @@ TO DO
* bwm_firewall to generate automatic MARK values for flows
* fix findFlowByName & findGroupByName, these 2 functions are similar and i'm sure can be merged
* have the location of iptables-restore automatically discovered using ./configure, with override options
* Change IPC mechanism used by bwmd and bwm_monitor to use more accurate flow->curThroughput
......@@ -172,6 +172,7 @@ static unsigned char autoClassify_tos(struct ip_packet_t *ip_packet, unsigned ch
* - PRIO 10
* - high drop probability
*/
prio = 10;
}
else if (tos == IPTOS_THROUGHPUT)
{
......@@ -195,6 +196,7 @@ static unsigned char autoClassify_tos(struct ip_packet_t *ip_packet, unsigned ch
* - PRIO 90
* - high drop probability
*/
prio = 90;
}
return prio;
......
......@@ -296,16 +296,15 @@ static int processPktQueue(struct runnerData_t *runnerData, struct pktQueue_t *p
g_mutex_lock(flow->lock);
flow->running.pktCount++;
flow->running.pktSize += PKT_SIZE(packet);
flow->curCredit -= PKT_SIZE(packet);
flow->accumThroughput += PKT_SIZE(packet);
flow->accumPackets++;
// If we can burst ...
if (flow->burstRate > 0)
flow->curBurstCredit -= PKT_SIZE(packet);
// We bursted
// We bursted - this must be direct and not an average
if (bursted)
flow->running.pktBursted++;
......@@ -323,23 +322,30 @@ static int processPktQueue(struct runnerData_t *runnerData, struct pktQueue_t *p
{
float delta;
// Get the fraction of time passed since last update, divide this by 1000000 to predict
// approx values below if 1s had passed
// flow->curThroughputAge -= 2000000;
// Get the fraction of time passed since last update
delta = flow->curThroughputAge / 1000000.0;
flow->curThroughputAge = 0;
// Calculate throughput
flow->curThroughput = (flow->curThroughput + (flow->accumThroughput / delta)) / 2;
flow->running.pktSize = flow->curThroughput;
flow->accumThroughput = 0;
// Calculate average queue size
flow->avgQueueSize = (flow->avgQueueSize + (flow->curQueueSize / delta)) / 2;
#if 0
fprintf(stderr,"%s: curThroughput: %f\tavgQueueSize:%u\n",
// Calculate packet rate
flow->curPacketRate = (flow->curPacketRate + (flow->accumPackets / delta)) / 2;
flow->running.pktCount = flow->curPacketRate;
flow->accumPackets = 0;
// Calculate queue size
flow->softQueueSize = (flow->softQueueSize + flow->curQueueSize) / 2;
if (strcmp(flow->flowName,"saix_in") == 0)
fprintf(stderr,"%s: curThroughput: %f\tsoftQueueSize:%u\n",
flow->flowName,
flow->curThroughput,
flow->avgQueueSize);
#endif
flow->softQueueSize);
flow->curThroughputAge = 0;
}
// Set this as the last time we updated our throughput
......
......@@ -174,7 +174,7 @@ static int queuePacket(struct runnerData_t *runnerData, unsigned long int nfmark
// FIXME - this is based on the flow's queue size, it should be configurable to the queue's queue size
maxQueueSize = P_FLOW(foundQueue,maxQueueSize);
curQueueSize = P_FLOW(foundQueue,curQueueSize);
avgQueueSize = P_FLOW(foundQueue,avgQueueSize);
avgQueueSize = P_FLOW(foundQueue,softQueueSize);
// Check if we have limits to exceed
if (maxQueueSize && curQueueSize > 0 && avgQueueSize > 0)
......
......@@ -110,21 +110,24 @@ struct flow_t
struct pktStat_t counter; // This is the counter which is logged to file
GList *groups;
// Credit stuff... this is used in calculating current credit
double usCredit; // Credits for maxRate per microsecond
long int curCredit; // Current available credit for maxRate, if we burst we will be < 0
double usBurstCredit;
long int curBurstCredit; // Curent burstable credit available
unsigned int accumThroughput; // Accumulated throughput
float curThroughput; // Current throughput
// Throughput and internal stats
unsigned int curThroughputAge; // How many microseconds since last throughput update
unsigned int avgQueueSize; // Average queue size
struct timeval lastThroughputUpdate; // Last time the throughput was updated
unsigned int accumThroughput; // Accumulated throughput
unsigned int accumPackets; // Accumulated packets
float curThroughput; // Current throughput
unsigned int curPacketRate; // Current throughput
unsigned int softQueueSize; // Queue size
unsigned int accumMs; // Accumulated number of microseconds
struct timeval lastCreditCalc; // Last "timeval" that we calculated additional credit
struct pktStat_t running; // This is the running counter
struct pktStat_t running; // This is the running counter used for stats & logging
int lastDumpTimestamp;
int counterTimeout; // STATIC - length between file logs
......
......@@ -727,8 +727,10 @@ static struct flow_t* createFlow(
gettimeofday(&flow->lastThroughputUpdate,NULL);
flow->curThroughputAge = 0;
flow->accumThroughput = 0;
flow->accumPackets = 0;
flow->curThroughput = 0;
flow->avgQueueSize = 0;
flow->curPacketRate = 0;
flow->softQueueSize = 0;
// Set last time we calculated credit and the rest...
flow->accumMs = 0;
gettimeofday(&flow->lastCreditCalc,NULL);
......
Supports Markdown
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