Commit c22ef5e0 authored by Jonathon Duerig's avatar Jonathon Duerig

Added a limit of the maximum number of samples used by LeastSquaresThroughput...

Added a limit of the maximum number of samples used by LeastSquaresThroughput for slope calculation. Throughput calculation still uses the previous metrics.
parent e004ad7d
......@@ -10,6 +10,7 @@ using namespace std;
const int LeastSquaresThroughput::MAX_SAMPLE_COUNT;
const int LeastSquaresThroughput::DEFAULT_MAX_PERIOD;
const int LeastSquaresThroughput::MAX_LEAST_SQUARES_SAMPLES;
LeastSquaresThroughput::LeastSquaresThroughput(
TSThroughputSensor const * newThroughput,
......@@ -61,11 +62,11 @@ void LeastSquaresThroughput::localAck(PacketInfo * packet)
double numA = 0.0;
double numB = 0.0;
double numC = 0.0;
double numD = limit;
double numD = min(MAX_LEAST_SQUARES_SAMPLES, limit);
double denomA = 0.0;
double denomB = 0.0;
double denomC = 0.0;
double denomD = limit;
double denomD = min(MAX_LEAST_SQUARES_SAMPLES, limit);
for (; i < limit && (timeTotal <= static_cast<uint32_t>(maxPeriod)
|| maxPeriod <= 0); ++i)
{
......@@ -76,21 +77,24 @@ void LeastSquaresThroughput::localAck(PacketInfo * packet)
byteTotal += samples[index].size;
timeTotal += samples[index].period;
logWrite(SENSOR_COMPLETE, "LeastSquares: ***Delay sample #%d: %d", i,
samples[index].rtt);
logWrite(SENSOR_COMPLETE, "LeastSquares: Period sample: %d",
samples[index].period);
logWrite(SENSOR_COMPLETE, "LeastSquares: Kilobit sample: %f",
samples[index].size*(8.0/1000.0));
x_i += samples[index].period;
y_i = samples[index].rtt;
numA += x_i * y_i;
numB += x_i;
numC += y_i;
denomA += x_i * x_i;
denomB += x_i;
denomC += x_i;
if (i < MAX_LEAST_SQUARES_SAMPLES)
{
logWrite(SENSOR_COMPLETE, "LeastSquares: ***Delay sample #%d: %d", i,
samples[index].rtt);
logWrite(SENSOR_COMPLETE, "LeastSquares: Period sample: %d",
samples[index].period);
logWrite(SENSOR_COMPLETE, "LeastSquares: Kilobit sample: %f",
samples[index].size*(8.0/1000.0));
x_i += samples[index].period;
y_i = samples[index].rtt;
numA += x_i * y_i;
numB += x_i;
numC += y_i;
denomA += x_i * x_i;
denomB += x_i;
denomC += x_i;
}
}
// Calculate throughput.
logWrite(SENSOR, "LeastSquares: timeTotal: %d, kilobitTotal: %f",
......
......@@ -40,6 +40,8 @@ private:
static const int MAX_SAMPLE_COUNT = 100;
// Circular buffer of the last MAX_SAMPLE_COUNT samples.
Ack samples[MAX_SAMPLE_COUNT];
// The maximum number of samples used for least squares analysis.
static const int MAX_LEAST_SQUARES_SAMPLES = 5;
// The index of the latest stored sample.
int latest;
......
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