Commit 2fdbb38b authored by Jonathon Duerig's avatar Jonathon Duerig

Old changes abstracting the timestamp extraction into a separate function.

parent fa9155a3
......@@ -5,6 +5,7 @@
#include "PacketSensor.h"
#include "StateSensor.h"
#include "Time.h"
#include "TSThroughputSensor.h"
using namespace std;
......
......@@ -19,6 +19,13 @@ protected:
virtual void localAck(PacketInfo * packet);
private:
int lastDelay;
// Time lastLocalTimestamp;
// uint32_t lastRemoteTimestamp;
// int localDeltaTotal;
// int remoteDeltaTotal;
// int lastSentDelay;
PacketSensor const * packetHistory;
StateSensor const * state;
};
......
......@@ -81,20 +81,7 @@ void TSThroughputSensor::localAck(PacketInfo * packet)
* Find the time the other end of this connection says it sent this
* ACK
*/
uint32_t currentAckTS = 0;
list<Option>::iterator opt;
for (opt = packet->tcpOptions->begin();
opt != packet->tcpOptions->end();
++opt) {
if (opt->type == TCPOPT_TIMESTAMP) {
const uint32_t *stamps = reinterpret_cast<const uint32_t*>(opt->buffer);
/*
* stamps[0] is TSval (the sending node's timestamp)
* stamps[1] is TSecr (the timestamp the sending node is echoing)
*/
currentAckTS = htonl(stamps[0]);
}
}
uint32_t currentAckTS = findTcpTimestamp(packet);
/*
* It would be nice if we could fall back to regular timing instead of
......@@ -148,3 +135,25 @@ void TSThroughputSensor::localAck(PacketInfo * packet)
ackValid = false;
}
}
uint32_t findTcpTimestamp(PacketInfo * packet)
{
uint32_t result = 0;
bool done = false;
list<Option>::iterator opt = packet->tcpOptions->begin();
list<Option>::iterator limit = packet->tcpOptions->end();
for (; opt != limit && !done; ++opt)
{
if (opt->type == TCPOPT_TIMESTAMP)
{
const uint32_t *stamps = reinterpret_cast<const uint32_t*>(opt->buffer);
/*
* stamps[0] is TSval (the sending node's timestamp)
* stamps[1] is TSecr (the timestamp the sending node is echoing)
*/
result = ntohl(stamps[0]);
done = true;
}
}
return result;
}
......@@ -39,4 +39,6 @@ private:
StateSensor const * state;
};
uint32_t findTcpTimestamp(PacketInfo * packet);
#endif
......@@ -77,7 +77,11 @@ enum
TENTATIVE_THROUGHPUT = 2,
// This is a bandwidth number to use even if it is smaller than the
// bandwidth on the monitor side
AUTHORITATIVE_BANDWIDTH = 3
AUTHORITATIVE_BANDWIDTH = 3,
// This is used to let the monitor know which connections we are
// keeping track of for synchronization purposes.
SYNC_REPLY = 4
};
// Enum of header types -- from-monitor (Commands)
......@@ -90,6 +94,12 @@ enum
CONNECT_COMMAND = 4,
TRAFFIC_WRITE_COMMAND = 5,
DELETE_CONNECTION_COMMAND = 6,
// A new monitor uses this to ensure a blank slate.
DELETE_ALL_CONNECTIONS_COMMAND = 7,
// A monitor is sending a heartbeat request to ensure that our
// connection lists are synced up and the command connection is
// still active.
SYNC_REQUEST_COMMAND = 8,
// These are pseudo-commands for replay.
PACKET_INFO_SEND_COMMAND = 255,
PACKET_INFO_ACK_COMMAND = 254
......
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