Commit 37158133 authored by Jonathon Duerig's avatar Jonathon Duerig

Various bugfixes on the magent. Changed the default logging to SENSOR_COMPLETE...

Various bugfixes on the magent. Changed the default logging to SENSOR_COMPLETE for while we are still in debugging mode.
parent 4c85f6bb
......@@ -55,6 +55,7 @@ void LeastSquaresThroughput::localAck(PacketInfo * packet)
int i = 0;
int limit = min(MAX_SAMPLE_COUNT, totalSamples);
int leastSquareCount = 0;
int byteTotal = 0;
uint32_t timeTotal = 0;
int x_i = 0;
......@@ -62,11 +63,9 @@ void LeastSquaresThroughput::localAck(PacketInfo * packet)
double numA = 0.0;
double numB = 0.0;
double numC = 0.0;
double numD = min(MAX_LEAST_SQUARES_SAMPLES, limit);
double denomA = 0.0;
double denomB = 0.0;
double denomC = 0.0;
double denomD = min(MAX_LEAST_SQUARES_SAMPLES, limit);
for (; i < limit && (timeTotal <= static_cast<uint32_t>(maxPeriod)
|| maxPeriod <= 0); ++i)
{
......@@ -86,6 +85,7 @@ void LeastSquaresThroughput::localAck(PacketInfo * packet)
logWrite(SENSOR_COMPLETE, "LeastSquares: Kilobit sample: %f",
samples[index].size*(8.0/1000.0));
++leastSquareCount;
x_i += samples[index].period;
y_i = samples[index].rtt;
numA += x_i * y_i;
......@@ -96,6 +96,10 @@ void LeastSquaresThroughput::localAck(PacketInfo * packet)
denomC += x_i;
}
}
double numD = leastSquareCount;
double denomD = leastSquareCount;
// Calculate throughput.
logWrite(SENSOR, "LeastSquares: timeTotal: %d, kilobitTotal: %f",
timeTotal, byteTotal*(8.0/1000.0));
......@@ -112,43 +116,60 @@ void LeastSquaresThroughput::localAck(PacketInfo * packet)
{
slope = num/denom;
}
char * bufferFullBuffer;
if (packet->bufferFull)
{
bufferFullBuffer = "Buffer is FULL";
}
else
{
bufferFullBuffer = "Buffer is EMPTY";
}
logWrite(SENSOR, "LeastSquares: %s, cwnd: %d", bufferFullBuffer,
packet->kernel->tcpi_snd_cwnd);
logWrite(SENSOR, "LeastSquares: SLOPE: %f TPA: %i LR:%i", slope,
static_cast<int>(throughputAverage),lastReport);
// We have reversed the points left to right. This means that the
// line is reflected. So decreasing slope on the reflected-line
// means that there would have been increasing slope on the
// original line and therefore increasing delays.
if (slope < 0.0)
if (leastSquareCount >= MAX_LEAST_SQUARES_SAMPLES)
{
// The closest linear approximation indicates that buffers are
// being filled up, which means that the link was saturated
// over the last MAX_SAMPLE_COUNT samples. So use the average to
// yield a result.
if (static_cast<int>(throughputAverage) != lastReport)
// We have reversed the points left to right. This means that the
// line is reflected. So decreasing slope on the reflected-line
// means that there would have been increasing slope on the
// original line and therefore increasing delays.
if (slope < 0.0)
{
// The closest linear approximation indicates that buffers are
// being filled up, which means that the link was saturated
// over the last MAX_SAMPLE_COUNT samples. So use the average to
// yield a result.
if (static_cast<int>(throughputAverage) != lastReport)
{
lastReport = static_cast<int>(throughputAverage);
ostringstream buffer;
buffer << static_cast<int>(throughputAverage);
global::output->genericMessage(AUTHORITATIVE_BANDWIDTH, buffer.str(),
packet->elab);
}
}
else
{
lastReport = static_cast<int>(throughputAverage);
ostringstream buffer;
buffer << static_cast<int>(throughputAverage);
global::output->genericMessage(AUTHORITATIVE_BANDWIDTH, buffer.str(),
packet->elab);
// The buffers are not being filled up. So we just have a
// tentative throughput measurement.
if (static_cast<int>(throughputAverage) > lastReport)
{
lastReport = static_cast<int>(throughputAverage);
ostringstream buffer;
buffer << static_cast<int>(throughputAverage);
global::output->genericMessage(TENTATIVE_THROUGHPUT, buffer.str(),
packet->elab);
}
}
ackValid = true;
}
else
{
// The buffers are not being filled up. So we just have a
// tentative throughput measurement.
if (static_cast<int>(throughputAverage) > lastReport)
{
lastReport = static_cast<int>(throughputAverage);
ostringstream buffer;
buffer << static_cast<int>(throughputAverage);
global::output->genericMessage(TENTATIVE_THROUGHPUT, buffer.str(),
packet->elab);
}
ackValid = false;
}
ackValid = true;
}
else
{
......
......@@ -82,6 +82,7 @@ void NullSensor::localSend(PacketInfo * packet)
ackValid = false;
sendValid = true;
logWrite(SENSOR, "----------------------------------------");
logWrite(SENSOR, "Stream ID: %s", packet->elab.toString().c_str());
logWrite(SENSOR, "Send received: Time: %f", packet->packetTime.toDouble());
if (packet->packetTime < lastPacketTime) {
logWrite(EXCEPTION,"Reordered packets! Old %f New %f",lastPacketTime.toDouble(),
......@@ -95,6 +96,7 @@ void NullSensor::localAck(PacketInfo * packet)
sendValid = false;
ackValid = true;
logWrite(SENSOR, "----------------------------------------");
logWrite(SENSOR, "Stream ID: %s", packet->elab.toString().c_str());
logWrite(SENSOR, "Ack received: Time: %f", packet->packetTime.toDouble());
list<Option>::iterator pos = packet->tcpOptions->begin();
list<Option>::iterator limit = packet->tcpOptions->end();
......
......@@ -48,17 +48,7 @@ void StateSensor::localSend(PacketInfo * packet)
{
ackValid = false;
sendValid = true;
if (packet->tcp->syn && state == INITIAL)
{
state = AFTER_SYN;
logWrite(SENSOR, "State change to AFTER_SYN");
}
else if (packet->tcp->syn)
{
logWrite(ERROR, "Sent a SYN packet out of order");
sendValid = false;
}
else if (! packet->tcp->syn && state == AFTER_SYN_ACK)
if (! packet->tcp->syn && state != ESTABLISHED)
{
state = ESTABLISHED;
logWrite(SENSOR, "State change to ESTABLISHED");
......@@ -70,16 +60,10 @@ void StateSensor::localAck(PacketInfo * packet)
{
sendValid = false;
ackValid = true;
if (packet->tcp->syn && packet->tcp->ack && state == AFTER_SYN)
if (! packet->tcp->syn && state != ESTABLISHED)
{
state = AFTER_SYN_ACK;
logWrite(SENSOR, "State change to AFTER_SYN_ACK");
}
else if (packet->tcp->syn && packet->tcp->ack)
{
logWrite(ERROR, "Received a SYNACK packet out of order");
//ackValid = false;
state = ESTABLISHED;
logWrite(SENSOR, "State change to ESTABLISHED");
}
calculateSaturated(packet);
}
......
......@@ -11,8 +11,6 @@ public:
enum
{
INITIAL,
AFTER_SYN,
AFTER_SYN_ACK,
ESTABLISHED
};
public:
......
......@@ -296,7 +296,7 @@ void init(void)
FD_ZERO(&global::readers);
global::maxReader = -1;
logInit(stderr, LOG_EVERYTHING & ~SENSOR_COMPLETE, true);
logInit(stderr, LOG_EVERYTHING /*& ~SENSOR_COMPLETE*/, true);
/*
* Install a signal handler so that we can catch control-C's, etc.
......
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