Commit 00e6ed4b authored by Nigel Kukard's avatar Nigel Kukard
Browse files

* Improved the way avergare throughput is calculated over time

* Improved packet processing efficiency
parent edcd553a
......@@ -321,8 +321,26 @@ static int processPktQueue(struct runnerData_t *runnerData, struct pktQueue_t *p
// 2 seconds
if (flow->curThroughputAge >= 2000000)
{
flow->curThroughputAge -= 2000000;
flow->curThroughput = flow->curThroughputAge / 1000000.0 * flow->curThroughput;
float delta;
// flow->curThroughputAge -= 2000000;
// Get the fraction of time passed since last update
delta = flow->curThroughputAge / 1000000.0;
// Calculate throughput
flow->curThroughput /= delta;
// Calculate average queue size
flow->avgQueueSize = (flow->avgQueueSize + flow->curQueueSize) / delta;
/*
fprintf(stderr,"%s: curThroughput: %f, avgQueueSize: %li, delta: %f\n",
flow->flowName,
flow->curThroughput,
flow->avgQueueSize,
delta);
*/
flow->curThroughputAge = 0;
}
// Set this as the last time we updated our throughput
......@@ -446,9 +464,6 @@ static int processPktQueue(struct runnerData_t *runnerData, struct pktQueue_t *p
void *flowRunner(void *data)
{
struct runnerData_t *runnerData = (struct runnerData_t*) data;
GList *queueChangeList[NUM_PRIO_BANDS];
int i, pktsProcessed = 0;
GTimeVal mytime;
// Our processing function
......@@ -459,19 +474,21 @@ void *flowRunner(void *data)
// Check if we found a flow with a queue
pktsProcessed += processPktQueue(aRunnerData,pktQueue);
// NOTE: The function below returns the number of packets processed
processPktQueue(aRunnerData,pktQueue);
}
// Allocate queue change list
for (i = 0; i < NUM_PRIO_BANDS; i++)
queueChangeList[i] = NULL;
logMessage(LOG_DEBUG, "Flow runner started...\n");
// Loop when we get a signal
while (1)
{
GTimeVal mytime;
unsigned char i;
GList *queueChangeList = NULL;
g_mutex_lock(runnerData->bandSignalLock);
// If the queue has changed proceed
......@@ -486,15 +503,14 @@ void *flowRunner(void *data)
// Hijack the queue change list items
for (i = 0; i < NUM_PRIO_BANDS; i++)
{
// Copy list item over
queueChangeList[i] = runnerData->queueChangeList[i];
// Zero runner data if it is non-NULL
if (runnerData->queueChangeList[i])
{
runnerData->queueChangeList[i] = NULL;
// Copy list item over
queueChangeList = g_list_concat(queueChangeList,runnerData->queueChangeList[i]);
// Blank used list... copy uses directly
runnerData->queueChangeList[i] = NULL;
}
else
queueChangeList[i] = NULL;
}
runnerData->queueChanged = 0;
......@@ -502,15 +518,11 @@ void *flowRunner(void *data)
g_mutex_unlock(runnerData->bandSignalLock);
// Process all list
for (i = 0; i < NUM_PRIO_BANDS; i++)
// Process list if it is non-NULL
if (queueChangeList)
{
// Process list if it is non-NULL
if (queueChangeList[i])
{
g_list_foreach(queueChangeList[i],processQueue,runnerData);
g_list_free(queueChangeList[i]);
}
g_list_foreach(queueChangeList,processQueue,runnerData);
g_list_free(queueChangeList);
}
}
......
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