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

* Modified formula for getting average values, this one should be alot more precise

parent 0c6fe385
......@@ -299,7 +299,7 @@ static int processPktQueue(struct runnerData_t *runnerData, struct pktQueue_t *p
flow->running.pktCount++;
flow->running.pktSize += PKT_SIZE(packet);
flow->curCredit -= PKT_SIZE(packet);
flow->curThroughput += PKT_SIZE(packet);
flow->accumThroughput += PKT_SIZE(packet);
// If we can burst ...
if (flow->burstRate > 0)
......@@ -319,28 +319,27 @@ static int processPktQueue(struct runnerData_t *runnerData, struct pktQueue_t *p
flow->curThroughputAge += curTime.tv_usec - flow->lastThroughputUpdate.tv_usec;
// 2 seconds
if (flow->curThroughputAge >= 2000000)
if (flow->curThroughputAge >= 250000)
{
float delta;
// flow->curThroughputAge -= 2000000;
// Get the fraction of time passed since last update
// Get the fraction of time passed since last update, divide this by 1000000 to predict
// approx values below if 1s had passed
delta = flow->curThroughputAge / 1000000.0;
flow->curThroughputAge = 0;
// Calculate throughput
flow->curThroughput /= delta;
flow->curThroughput = (flow->curThroughput + (flow->accumThroughput / delta)) / 2;
flow->accumThroughput = 0;
// Calculate average queue size
flow->avgQueueSize = (flow->avgQueueSize + flow->curQueueSize) / delta;
/*
fprintf(stderr,"%s: curThroughput: %f, avgQueueSize: %li, delta: %f\n",
flow->avgQueueSize = (flow->avgQueueSize + (flow->curQueueSize / delta)) / 2;
#if 0
fprintf(stderr,"%s: curThroughput: %f\tavgQueueSize:%u\n",
flow->flowName,
flow->curThroughput,
flow->avgQueueSize,
delta);
*/
flow->curThroughputAge = 0;
flow->avgQueueSize);
#endif
}
// Set this as the last time we updated our throughput
......@@ -445,7 +444,8 @@ static int processPktQueue(struct runnerData_t *runnerData, struct pktQueue_t *p
// Check if we havn't already gotten the queue listed
// FIXME: check if we can't just add, high flow queue
if (!g_list_find(runnerData->queueChangeList[pktQueue->prio],pktQueue))
runnerData->queueChangeList[pktQueue->prio] = g_list_append(runnerData->queueChangeList[pktQueue->prio],pktQueue);
runnerData->queueChangeList[pktQueue->prio] = g_list_append(
runnerData->queueChangeList[pktQueue->prio],pktQueue);
g_cond_signal(runnerData->bandSignalCond);
g_mutex_unlock(runnerData->bandSignalLock);
}
......
......@@ -116,6 +116,7 @@ struct flow_t
double usBurstCredit;
long int curBurstCredit; // Curent burstable credit available
unsigned int accumThroughput; // Accumulated throughput
float curThroughput; // Current throughput
unsigned int curThroughputAge; // How many microseconds since last throughput update
unsigned int avgQueueSize; // Average queue size
......
......@@ -726,6 +726,7 @@ static struct flow_t* createFlow(
// Setup throughput stuff...
gettimeofday(&flow->lastThroughputUpdate,NULL);
flow->curThroughputAge = 0;
flow->accumThroughput = 0;
flow->curThroughput = 0;
flow->avgQueueSize = 0;
// Set last time we calculated credit and the rest...
......
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