Commit 83d9b6c8 authored by Robert Ricci's avatar Robert Ricci

Fix the way that MaxDelay calculates queueing delay. It needs to factor

out the time (likely) spent on the return path. We figure this out
from the minimum delay, so the MaxDelay sensor now depends on the
MinDelay sensor.
parent 73102ef8
...@@ -8,10 +8,12 @@ ...@@ -8,10 +8,12 @@
using namespace std; using namespace std;
MaxDelaySensor::MaxDelaySensor(DelaySensor * newDelay, StateSensor * newState) MaxDelaySensor::MaxDelaySensor(DelaySensor * newDelay, StateSensor * newState,
MinDelaySensor *newminDelay)
: maximum(0, 0.01) : maximum(0, 0.01)
, delay(newDelay) , delay(newDelay)
, state(newState) , state(newState)
, mindelay(newminDelay)
{ {
} }
...@@ -22,12 +24,26 @@ void MaxDelaySensor::localSend(PacketInfo *) ...@@ -22,12 +24,26 @@ void MaxDelaySensor::localSend(PacketInfo *)
void MaxDelaySensor::localAck(PacketInfo * packet) void MaxDelaySensor::localAck(PacketInfo * packet)
{ {
int current = delay->getLastDelay(); int current = delay->getLastDelay();
logWrite(SENSOR, "current=%d,saturated=%d", current, state->isSaturated()); /*
if (current > maximum && current != 0 && state->isSaturated()) * We assume that the minimum delay is transmission delay plus the
* propagation delay. Thus, any additional time is from queueing.
* Thus, queueingDelay = maxDelay - minDelay
* BUT - the latency we feed to dummynet is the whole time spend in the
* dummynet queue, so we have to include the 'forward' part of the min delay
* in our calculation.
*/
int minimumDelay = mindelay->getMinDelay();
int queueingDelay = current - (minimumDelay/2);
logWrite(SENSOR, "current=%d,min=%d,queueing=%d,saturated=%d", current,
minimumDelay, queueingDelay, state->isSaturated());
if (queueingDelay < 0) {
logWrite(ERROR,"Queueing delay is less than zero!");
}
if (queueingDelay > maximum && current != 0) && state->isSaturated())
{ {
ostringstream buffer; ostringstream buffer;
buffer << "MAXINQ=" << current; buffer << "MAXINQ=" << queueingDelay;
maximum.reset(current); maximum.reset(queueingDelay);
global::output->eventMessage(buffer.str(), packet->elab); global::output->eventMessage(buffer.str(), packet->elab);
} }
else else
......
...@@ -4,6 +4,8 @@ ...@@ -4,6 +4,8 @@
#define MAX_DELAY_SENSOR_H_STUB_2 #define MAX_DELAY_SENSOR_H_STUB_2
#include "Sensor.h" #include "Sensor.h"
#include "StateSensor.h"
#include "MinDelaySensor.h"
#include "Decayer.h" #include "Decayer.h"
class DelaySensor; class DelaySensor;
...@@ -12,7 +14,8 @@ class StateSensor; ...@@ -12,7 +14,8 @@ class StateSensor;
class MaxDelaySensor : public Sensor class MaxDelaySensor : public Sensor
{ {
public: public:
MaxDelaySensor(DelaySensor * newDelay, StateSensor * newState); MaxDelaySensor(DelaySensor * newDelay, StateSensor * newState,
MinDelaySensor * newminDelay);
protected: protected:
virtual void localSend(PacketInfo * packet); virtual void localSend(PacketInfo * packet);
virtual void localAck(PacketInfo * packet); virtual void localAck(PacketInfo * packet);
...@@ -20,6 +23,7 @@ private: ...@@ -20,6 +23,7 @@ private:
Decayer maximum; Decayer maximum;
DelaySensor * delay; DelaySensor * delay;
StateSensor * state; StateSensor * state;
MinDelaySensor * mindelay;
}; };
#endif #endif
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
using namespace std; using namespace std;
MinDelaySensor::MinDelaySensor(DelaySensor * newDelay) MinDelaySensor::MinDelaySensor(DelaySensor * newDelay)
: minimum(1000000, -0.01) : minimum(1000000, -0.01), minDelay(1000000)
{ {
delay = newDelay; delay = newDelay;
} }
...@@ -22,8 +22,9 @@ void MinDelaySensor::localAck(PacketInfo * packet) ...@@ -22,8 +22,9 @@ void MinDelaySensor::localAck(PacketInfo * packet)
int current = delay->getLastDelay(); int current = delay->getLastDelay();
if (current < minimum && current != 0) if (current < minimum && current != 0)
{ {
minDelay = current;
ostringstream buffer; ostringstream buffer;
buffer << "delay=" << current/2; buffer << "delay=" << minDelay/2;
minimum.reset(current); minimum.reset(current);
global::output->eventMessage(buffer.str(), packet->elab, global::output->eventMessage(buffer.str(), packet->elab,
CommandOutput::FORWARD_PATH); CommandOutput::FORWARD_PATH);
......
...@@ -15,12 +15,15 @@ class MinDelaySensor : public Sensor ...@@ -15,12 +15,15 @@ class MinDelaySensor : public Sensor
{ {
public: public:
MinDelaySensor(DelaySensor * newDelay); MinDelaySensor(DelaySensor * newDelay);
// Note: This is the minimum RTT, not one-way delay
int getMinDelay() { return minDelay; }
protected: protected:
virtual void localSend(PacketInfo * packet); virtual void localSend(PacketInfo * packet);
virtual void localAck(PacketInfo * packet); virtual void localAck(PacketInfo * packet);
private: private:
Decayer minimum; Decayer minimum;
DelaySensor * delay; DelaySensor * delay;
int minDelay;
}; };
#endif #endif
......
...@@ -99,6 +99,7 @@ void SensorList::reset(void) ...@@ -99,6 +99,7 @@ void SensorList::reset(void)
depPacketSensor = NULL; depPacketSensor = NULL;
depDelaySensor = NULL; depDelaySensor = NULL;
depThroughputSensor = NULL; depThroughputSensor = NULL;
depMinDelaySensor = NULL;
} }
void SensorList::pushSensor(std::auto_ptr<Sensor> newSensor) void SensorList::pushSensor(std::auto_ptr<Sensor> newSensor)
...@@ -194,20 +195,29 @@ void SensorList::pushMinDelaySensor(void) ...@@ -194,20 +195,29 @@ void SensorList::pushMinDelaySensor(void)
// Dependency list // Dependency list
pushDelaySensor(); pushDelaySensor();
logWrite(SENSOR, "Adding MinDelaySensor"); if (depMinDelaySensor == NULL) {
std::auto_ptr<Sensor> current(new MinDelaySensor(depDelaySensor)); logWrite(SENSOR, "Adding MinDelaySensor");
pushSensor(current); MinDelaySensor * newSensor = new MinDelaySensor(depDelaySensor);
std::auto_ptr<Sensor> current(newSensor);
pushSensor(current);
// Dependency set
depMinDelaySensor = newSensor;
}
} }
void SensorList::pushMaxDelaySensor(void) void SensorList::pushMaxDelaySensor(void)
{ {
// Dependency list // Dependency list
pushMinDelaySensor();
pushDelaySensor(); pushDelaySensor();
pushStateSensor(); pushStateSensor();
logWrite(SENSOR, "Adding MaxDelaySensor"); logWrite(SENSOR, "Adding MaxDelaySensor");
std::auto_ptr<Sensor> current(new MaxDelaySensor(depDelaySensor, std::auto_ptr<Sensor> current(new MaxDelaySensor(depDelaySensor,
depStateSensor)); depStateSensor,
depMinDelaySensor));
pushSensor(current); pushSensor(current);
} }
......
...@@ -56,6 +56,7 @@ private: ...@@ -56,6 +56,7 @@ private:
StateSensor * depStateSensor; StateSensor * depStateSensor;
PacketSensor * depPacketSensor; PacketSensor * depPacketSensor;
DelaySensor * depDelaySensor; DelaySensor * depDelaySensor;
MinDelaySensor * depMinDelaySensor;
ThroughputSensor * depThroughputSensor; ThroughputSensor * depThroughputSensor;
}; };
......
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