Commit 18c8a948 authored by Jonathon Duerig's avatar Jonathon Duerig

Added logging to try to find two bugs.

parent f1be0720
...@@ -117,7 +117,7 @@ void Connection::connect(unsigned int ip) ...@@ -117,7 +117,7 @@ void Connection::connect(unsigned int ip)
isConnected = peer->isConnected(); isConnected = peer->isConnected();
if (isConnected) if (isConnected)
{ {
logWrite(CONNECTION, "Inserting a connection with key %s", logWrite(PCAP,"Inserting key: %s",
planet.toString().c_str()); planet.toString().c_str());
global::planetMap[planet] = this; global::planetMap[planet] = this;
} }
...@@ -185,6 +185,8 @@ Time Connection::writeToConnection(Time const & previousTime) ...@@ -185,6 +185,8 @@ Time Connection::writeToConnection(Time const & previousTime)
if (!isConnected && result.isConnected) if (!isConnected && result.isConnected)
{ {
planet = result.planet; planet = result.planet;
logWrite(PCAP,"Inserting key: %s",
planet.toString().c_str());
global::planetMap[planet] = this; global::planetMap[planet] = this;
} }
else if (isConnected && result.isConnected else if (isConnected && result.isConnected
...@@ -193,8 +195,9 @@ Time Connection::writeToConnection(Time const & previousTime) ...@@ -193,8 +195,9 @@ Time Connection::writeToConnection(Time const & previousTime)
logWrite(CONNECTION, "OldKey: %s", planet.toString().c_str()); logWrite(CONNECTION, "OldKey: %s", planet.toString().c_str());
global::planetMap[planet] = NULL; global::planetMap[planet] = NULL;
planet = result.planet; planet = result.planet;
logWrite(PCAP,"Inserting key: %s",
planet.toString().c_str());
global::planetMap[planet] = this; global::planetMap[planet] = this;
logWrite(CONNECTION, "NewKey: %s", planet.toString().c_str());
} }
isConnected = result.isConnected; isConnected = result.isConnected;
bufferFull = result.bufferFull; bufferFull = result.bufferFull;
......
...@@ -65,7 +65,11 @@ void DirectInput::nextCommand(fd_set * readable) ...@@ -65,7 +65,11 @@ void DirectInput::nextCommand(fd_set * readable)
if (error == Header::PREFIX_SIZE - index) if (error == Header::PREFIX_SIZE - index)
{ {
unsigned char version = headerBuffer[Header::PREFIX_SIZE - 1]; unsigned char version = headerBuffer[Header::PREFIX_SIZE - 1];
global::CONTROL_VERSION = version; if (global::CONTROL_VERSION != version)
{
logWrite(COMMAND_INPUT, "Setting version to %d", version);
global::CONTROL_VERSION = version;
}
versionSize = Header::headerSize(); versionSize = Header::headerSize();
index += error; index += error;
state = HEADER; state = HEADER;
......
...@@ -809,8 +809,10 @@ namespace ...@@ -809,8 +809,10 @@ namespace
bool outgoing; bool outgoing;
logWrite(PCAP,"Looking up key (outgoing): t=%d,i=%s,lp=%i,rp=%i", // logWrite(PCAP,"Looking up key (outgoing): t=%d,i=%s,lp=%i,rp=%i",
transport, inet_ntoa(ipPacket->ip_dst),key.localPort,key.remotePort); // transport, inet_ntoa(ipPacket->ip_dst),key.localPort,key.remotePort);
logWrite(PCAP, "Looking up key (outgoing): %s",
key.toString().c_str());
map<PlanetOrder, Connection *>::iterator pos; map<PlanetOrder, Connection *>::iterator pos;
pos = global::planetMap.find(key); pos = global::planetMap.find(key);
...@@ -821,8 +823,10 @@ namespace ...@@ -821,8 +823,10 @@ namespace
swap(key.localPort, key.remotePort); swap(key.localPort, key.remotePort);
// key.localPort = ntohs(tcpPacket->dest); // key.localPort = ntohs(tcpPacket->dest);
// key.remotePort = ntohs(tcpPacket->source); // key.remotePort = ntohs(tcpPacket->source);
logWrite(PCAP,"Looking up key (incoming): t=%d,i=%s,lp=%i,rp=%i", logWrite(PCAP, "Looking up key (incoming): %s",
transport,inet_ntoa(ipPacket->ip_src),key.localPort,key.remotePort); key.toString().c_str());
// logWrite(PCAP,"Looking up key (incoming): t=%d,i=%s,lp=%i,rp=%i",
// transport,inet_ntoa(ipPacket->ip_src),key.localPort,key.remotePort);
pos = global::planetMap.find(key); pos = global::planetMap.find(key);
if (pos != global::planetMap.end()) { if (pos != global::planetMap.end()) {
outgoing = false; outgoing = false;
......
...@@ -492,14 +492,15 @@ def send_write(conn, key, timestamp, app_connection, size): ...@@ -492,14 +492,15 @@ def send_write(conn, key, timestamp, app_connection, size):
def receive_characteristic(conn): def receive_characteristic(conn):
global socket_map global socket_map
buf = conn.recv(36) buf = conn.recv(36)
if len(buf) != 36:
raise Exception('ERROR: Event header is the wrong size. Length: '
+ str(len(buf)))
eventType = load_char(buf[0:1]); eventType = load_char(buf[0:1]);
size = load_short(buf[1:3]); size = load_short(buf[1:3]);
version = load_char(buf[3:4]); version = load_char(buf[3:4]);
if version != magent_version: if version != magent_version:
raise Exception('ERROR: Wrong version from magent.'); raise Exception('ERROR: Wrong version from magent: version('
+ str(version) + ') buf_size(' + len(buf) + ')');
if len(buf) != 36:
raise Exception('ERROR: Event header is the wrong size. Length: '
+ str(len(buf)))
socketKey = buf[4:34]; socketKey = buf[4:34];
connectionKey = load_short(buf[34:36]); connectionKey = load_short(buf[34:36]);
...@@ -550,7 +551,8 @@ def receive_characteristic(conn): ...@@ -550,7 +551,8 @@ def receive_characteristic(conn):
else: else:
sys.stdout.write('Recieve: Ignored TENTATIVE_THROUGHPUT for ' sys.stdout.write('Recieve: Ignored TENTATIVE_THROUGHPUT for '
+ app_connection.dest.remote_ip + ' - ' + app_connection.dest.remote_ip + ' - '
+ buf + ' vs ' + app_connection.last_bandwidth + '\n') + buf + ' vs ' + str(app_connection.last_bandwidth)
+ '\n')
elif eventType == AUTHORITATIVE_BANDWIDTH and int(buf) > 0: elif eventType == AUTHORITATIVE_BANDWIDTH and int(buf) > 0:
# We know that the bandwidth has definitely changed. Reset everything. # We know that the bandwidth has definitely changed. Reset everything.
app_connection.last_bandwidth = int(buf) app_connection.last_bandwidth = int(buf)
...@@ -607,8 +609,8 @@ def set_link(source, dest, ending, event_type='MODIFY'): ...@@ -607,8 +609,8 @@ def set_link(source, dest, ending, event_type='MODIFY'):
def send_command(conn, key, command_id, command): def send_command(conn, key, command_id, command):
if is_fake: if is_fake:
sys.stdout.write('Command: ' + key + ' ' + command_to_string[command_id] sys.stdout.write('Command: ' + key + ' version(' + str(magent_version)
+ '\n') + ') ' + command_to_string[command_id] + '\n')
return return
output = (save_char(command_id) output = (save_char(command_id)
+ save_short(len(command)) + save_short(len(command))
......
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