Commit da655189 authored by Jonathon Duerig's avatar Jonathon Duerig

Revert odd CVS artifacts in PacketSensor.cc. Add namespace to new code in main.c

c. Add some logging and remove a complication from CircularTraffic.cc while it i
s under study for a bug.
parent 99b9f939
...@@ -37,12 +37,12 @@ Time CircularTraffic::addWrite(TrafficWriteCommand const & newWrite, ...@@ -37,12 +37,12 @@ Time CircularTraffic::addWrite(TrafficWriteCommand const & newWrite,
Time const & deadline) Time const & deadline)
{ {
Time now = getCurrentTime(); Time now = getCurrentTime();
if (! writes.empty() && newWrite.delta == 0) // if (! writes.empty() && newWrite.delta == 0)
{ // {
writes.back().size += newWrite.size; // writes.back().size += newWrite.size;
} // }
else // else
{ // {
writes.push_back(newWrite); writes.push_back(newWrite);
writes.back().localTime = now; writes.back().localTime = now;
// XXX: end() is not necessarily a constant value. Though this // XXX: end() is not necessarily a constant value. Though this
...@@ -52,7 +52,7 @@ Time CircularTraffic::addWrite(TrafficWriteCommand const & newWrite, ...@@ -52,7 +52,7 @@ Time CircularTraffic::addWrite(TrafficWriteCommand const & newWrite,
{ {
current = writes.begin(); current = writes.begin();
} }
} // }
if (deadline == Time()) if (deadline == Time())
{ {
// If there is no current deadline, return the next one. // If there is no current deadline, return the next one.
......
...@@ -221,9 +221,10 @@ int KernelTcp::writeMessage(int size, WriteResult & result) ...@@ -221,9 +221,10 @@ int KernelTcp::writeMessage(int size, WriteResult & result)
for (bytesToWrite = size; bytesToWrite > 0; bytesToWrite -= MAX_WRITESIZE) { for (bytesToWrite = size; bytesToWrite > 0; bytesToWrite -= MAX_WRITESIZE) {
int writeSize = min(MAX_WRITESIZE,bytesToWrite); int writeSize = min(MAX_WRITESIZE,bytesToWrite);
// Actually write the darn thing. // Actually write the darn thing.
logWrite(CONNECTION_MODEL, "About to write %d bytes", writeSize);
int error = send(peersock, &buffer[0], writeSize, 0); int error = send(peersock, &buffer[0], writeSize, 0);
logWrite(CONNECTION_MODEL,"Tried to write %d bytes, actually wrote %d", logWrite(CONNECTION_MODEL,
writeSize, error); "Tried to write %d bytes, actually wrote %d", writeSize, error);
if (error == 0) if (error == 0)
{ {
...@@ -299,10 +300,10 @@ void KernelTcp::init(void) ...@@ -299,10 +300,10 @@ void KernelTcp::init(void)
// Set up the peerAccept socket // Set up the peerAccept socket
if (global::peerServerPort != 0) { if (global::peerServerPort != 0) {
global::peerAccept = createServer(global::peerServerPort, global::peerAccept = createServer(global::peerServerPort,
"Peer accept socket (No incoming peer " "Peer accept socket (No incoming peer "
"connections will be accepted)"); "connections will be accepted)");
logWrite(PEER_CYCLE, "Created peer server on port %d", logWrite(PEER_CYCLE, "Created peer server on port %d",
global::peerServerPort); global::peerServerPort);
} }
// Set up the connectionModelExemplar // Set up the connectionModelExemplar
......
...@@ -173,40 +173,6 @@ void PacketSensor::localSend(PacketInfo * packet) ...@@ -173,40 +173,6 @@ void PacketSensor::localSend(PacketInfo * packet)
SentPacket record; SentPacket record;
record.seqStart = startSequence; record.seqStart = startSequence;
<<<<<<< PacketSensor.cc
/*
* Calculate the packet payload size - we have to make sure to
* take into account IP and TCP option headers
*/
unsigned int sequenceLength =
// Total length of the IP part of the packet
(ntohs(packet->ip->ip_len))
// Total length of all IP headers (including options)
- (packet->ip->ip_hl*4)
// Total length of all TCP headers (including options)
<<<<<<< PacketSensor.cc
- (packet->tcp->doff*4);
record.seqEnd = record.seqStart + sequenceLength;
record.totalLength = packet->packetLength;
record.timestamp = packet->packetTime;
logWrite(SENSOR,
<<<<<<< PacketSensor.cc
"PacketSensor::localSend() new record: ss=%i,sl=%i,se=%i,tl=%i",
record.seqStart,record.sequenceLength,record.seqEnd,
record.totalLength);
=======
"PacketSensor::localSend() new record: ss=%u,sl=%u,se=%u,tl=%u",
record.seqStart, sequenceLength, record.seqEnd,
record.totalLength);
>>>>>>> 1.5
globalSequence.seqEnd = record.seqEnd;
if (unacked.empty())
{
globalSequence.seqStart = record.seqStart;
=======
- (packet->tcp->doff*4);
=======
>>>>>>> 1.27
// We want to get the sequence number of the last data byte, not the // We want to get the sequence number of the last data byte, not the
// sequence number of the first byte of the next segment // sequence number of the first byte of the next segment
record.seqEnd = record.seqStart + sequenceLength - 1; record.seqEnd = record.seqStart + sequenceLength - 1;
...@@ -216,11 +182,6 @@ void PacketSensor::localSend(PacketInfo * packet) ...@@ -216,11 +182,6 @@ void PacketSensor::localSend(PacketInfo * packet)
"PacketSensor::localSend() new record: ss=%u,sl=%u,se=%u,tl=%u", "PacketSensor::localSend() new record: ss=%u,sl=%u,se=%u,tl=%u",
record.seqStart, sequenceLength, record.seqEnd, record.seqStart, sequenceLength, record.seqEnd,
record.totalLength); record.totalLength);
<<<<<<< PacketSensor.cc
>>>>>>> 1.11
globalSequence.seqEnd = record.seqEnd;
=======
>>>>>>> 1.16
if (unacked.empty()) if (unacked.empty())
{ {
globalSequence.seqStart = record.seqStart; globalSequence.seqStart = record.seqStart;
......
...@@ -294,7 +294,7 @@ void processArgs(int argc, char * argv[]) ...@@ -294,7 +294,7 @@ void processArgs(int argc, char * argv[])
} }
break; break;
case 'L': case 'L':
logFlags = ERROR & EXCEPTION; global::logFlags = ERROR & EXCEPTION;
break; break;
case '?': case '?':
default: default:
...@@ -309,7 +309,7 @@ void init(void) ...@@ -309,7 +309,7 @@ void init(void)
FD_ZERO(&global::readers); FD_ZERO(&global::readers);
global::maxReader = -1; global::maxReader = -1;
logInit(stderr, logFlags, true); logInit(stderr, global::logFlags, true);
/* /*
* Install a signal handler so that we can catch control-C's, etc. * Install a signal handler so that we can catch control-C's, etc.
...@@ -379,16 +379,26 @@ void mainLoop(void) ...@@ -379,16 +379,26 @@ void mainLoop(void)
{ {
timeUntilWrite = nextWrite->first - now; timeUntilWrite = nextWrite->first - now;
waitPeriod = timeUntilWrite.getTimeval(); waitPeriod = timeUntilWrite.getTimeval();
logWrite(MAIN_LOOP, "Before select, waitTime=%f",
timeUntilWrite.toDouble());
} }
else else if (nextWrite == schedule.end())
{ {
// otherwise we want to wait forever. // otherwise we want to wait forever.
timeUntilWrite = Time(); timeUntilWrite = Time();
waitPeriod = NULL; waitPeriod = NULL;
logWrite(MAIN_LOOP, "Before select, waitTime=forever");
}
else
{
timeUntilWrite = Time();
waitPeriod = timeUntilWrite.getTimeval();
logWrite(MAIN_LOOP, "Before select, waitTime=zero");
} }
int error = select(global::maxReader + 1, &readable, NULL, NULL, int error = select(global::maxReader + 1, &readable, NULL, NULL,
// &debugTimeout); // &debugTimeout);
waitPeriod); waitPeriod);
logWrite(MAIN_LOOP, "After select");
if (error == -1) if (error == -1)
{ {
switch (errno) switch (errno)
......
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