Changeset 7952 in orxonox.OLD
- Timestamp:
- May 29, 2006, 2:26:23 PM (18 years ago)
- Location:
- branches/network/src/lib/network
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/network/src/lib/network/connection_monitor.cc
r7872 r7952 24 24 using namespace std; 25 25 26 /** 27 * constructor 28 * @param userId user's id 29 */ 26 30 ConnectionMonitor::ConnectionMonitor( int userId ) 27 31 { … … 41 45 42 46 this->lastPacketTick = 0; 43 } 44 47 this->lastPrintTick = 0; 48 } 49 50 /** 51 * deconstructor 52 */ 45 53 ConnectionMonitor::~ConnectionMonitor( ) 46 54 { 47 55 } 48 56 57 /** 58 * process unzipped outgoing packet 59 * @param data pointer to packet data 60 * @param length length of packet 61 * @param stateId packet's state id 62 */ 49 63 void ConnectionMonitor::processUnzippedOutgoingPacket( byte * data, int length, int stateId ) 50 64 { … … 60 74 outgoingUnzippedBandWidth = calculateBandWidth( outgoingUnzippedPacketHistory, tick ); 61 75 62 NETPRINTF(n)("UNZIPPED UPSTREAM: user: %d bandwidth %f\n", userId, outgoingUnzippedBandWidth );76 //NETPRINTF(n)("UNZIPPED UPSTREAM: user: %d bandwidth %f\n", userId, outgoingUnzippedBandWidth ); 63 77 64 78 // count zero bytes … … 69 83 nZeroBytes++; 70 84 71 NETPRINTF(n)( "ZEROBYTES: %d (%f%%)\n", nZeroBytes, ((float)100)*nZeroBytes/length ); 72 } 73 85 //NETPRINTF(n)( "ZEROBYTES: %d (%f%%)\n", nZeroBytes, ((float)100)*nZeroBytes/length ); 86 } 87 88 /** 89 * process unzipped incoming packet 90 * @param data pointer to packet data 91 * @param length length of packet 92 * @param stateId packet's state id 93 * @param ackedState state which was acked by this packet 94 */ 74 95 void ConnectionMonitor::processUnzippedIncomingPacket( byte * data, int length, int stateId, int ackedState ) 75 96 { … … 102 123 ping /= ackDelay.size(); 103 124 104 NETPRINTF(n)("PING: user: %d ping: %d\n", userId, ping );125 //NETPRINTF(n)("PING: user: %d ping: %d\n", userId, ping ); 105 126 106 127 // calculate bandwidth … … 108 129 incomingUnzippedBandWidth = calculateBandWidth( incomingUnzippedPacketHistory, tick ); 109 130 110 NETPRINTF(n)("UNZIPPED DOWNSTREAM: user: %d bandwidth %f\n", userId, incomingUnzippedBandWidth ); 111 112 } 113 131 //NETPRINTF(n)("UNZIPPED DOWNSTREAM: user: %d bandwidth %f\n", userId, incomingUnzippedBandWidth ); 132 133 } 134 135 /** 136 * calculate bandwidth out of packethistory 137 * @param packetHistory packet history 138 * @param tick current tick from SDL_GetTicks 139 * @return bandwidth in bytes/sec 140 */ 114 141 float ConnectionMonitor::calculateBandWidth( std::map< int, int > packetHistory, int tick ) 115 142 { … … 136 163 137 164 138 139 165 /** 166 * process zipped outgoing packet 167 * @param data pointer to packet data 168 * @param length length of packet 169 * @param stateId packet's state id 170 */ 140 171 void ConnectionMonitor::processZippedOutgoingPacket( byte * data, int length, int stateId ) 141 172 { … … 148 179 outgoingZippedBandWidth = calculateBandWidth( outgoingZippedPacketHistory, tick ); 149 180 150 NETPRINTF(n)("UPSTREAM: user: %d bandwidth %f nOutgoingPackets %d\n", userId, outgoingZippedBandWidth, nOutgoingPackets ); 151 152 } 153 154 181 //NETPRINTF(n)("UPSTREAM: user: %d bandwidth %f nOutgoingPackets %d\n", userId, outgoingZippedBandWidth, nOutgoingPackets ); 182 183 if ( lastPrintTick < tick-1000 ) 184 { 185 printStatis(); 186 lastPrintTick = tick; 187 } 188 } 189 190 191 /** 192 * process zipped incoming packet 193 * @param data pointer to packet data 194 * @param length length of packet 195 * @param stateId packet's state id 196 * @param ackedState state which was acked by this packet 197 */ 155 198 void ConnectionMonitor::processZippedIncomingPacket( byte * data, int length, int stateId, int ackedState ) 156 199 { … … 163 206 incomingZippedBandWidth = calculateBandWidth( incomingZippedPacketHistory, tick ); 164 207 165 NETPRINTF(n)("DOWNSTREAM: user: %d bandwidth %f nIncomingPackets %d\n", userId, incomingZippedBandWidth, nIncomingPackets ); 166 167 } 168 169 208 //NETPRINTF(n)("DOWNSTREAM: user: %d bandwidth %f nIncomingPackets %d\n", userId, incomingZippedBandWidth, nIncomingPackets ); 209 210 } 211 212 213 /** 214 * check if client sent no packets for SECS_TO_TIMEOUT 215 * @return true if last packet recieved \< NOW() - SECS_TO_TIMEOUT 216 */ 170 217 bool ConnectionMonitor::hasTimedOut( ) 171 218 { … … 180 227 181 228 229 230 /** 231 * prints bandwith usage, ping and other important things to telnet-console 232 */ 233 void ConnectionMonitor::printStatis( ) 234 { 235 NETPRINT(n)("=========NETWORKSTATS FOR USER %d=========\n", userId); 236 NETPRINT(n)("PING = %d\n", ping); 237 NETPRINT(n)("BANDWIDTH: UP: %f (%f) DOWN %f (%f)\n", outgoingZippedBandWidth, outgoingUnzippedBandWidth, incomingZippedBandWidth, incomingUnzippedBandWidth); 238 NETPRINT(n)("=========================================="); 239 } 240 241 -
branches/network/src/lib/network/connection_monitor.h
r7872 r7952 32 32 bool hasTimedOut(); 33 33 34 void printStatis(); 35 34 36 private: 35 37 float calculateBandWidth( std::map<int,int> packetHistory, int tick ); … … 61 63 62 64 int lastPacketTick; 65 66 int lastPrintTick; 63 67 }; 64 68 -
branches/network/src/lib/network/network_stream.cc
r7916 r7952 454 454 455 455 //check if all bytes == 0 -> remove data 456 456 //TODO not all synchronizeables like this maybe add Synchronizeable::canRemoveZeroDiff() 457 457 bool allZero = true; 458 458 for ( int i = 0; i < n; i++ ) … … 464 464 if ( allZero ) 465 465 { 466 NETPRINTF(n)("REMOVE ZERO DIFF: %s (%d)\n", sync.getClassName(), sync.getUniqueID());466 //NETPRINTF(n)("REMOVE ZERO DIFF: %s (%d)\n", sync.getClassName(), sync.getUniqueID()); 467 467 offset = oldOffset; 468 468 } … … 499 499 peer->second.connectionMonitor->processZippedOutgoingPacket( compBuf, compLength, currentState ); 500 500 501 NETPRINTF(n)("send packet: %d userId = %d\n", offset, peer->second.userId);501 //NETPRINTF(n)("send packet: %d userId = %d\n", offset, peer->second.userId); 502 502 } 503 503 } … … 544 544 assert( Converter::byteArrayToInt( buf + 2*INTSIZE, &fromState ) == INTSIZE ); 545 545 assert( Converter::byteArrayToInt( buf + 3*INTSIZE, &ackedState ) == INTSIZE ); 546 NETPRINTF(n)("ackedstate: %d\n", ackedState);546 //NETPRINTF(n)("ackedstate: %d\n", ackedState); 547 547 offset = 4*INTSIZE; 548 548 549 NETPRINTF(n)("got packet: %d, %d\n", length, packetLength);549 //NETPRINTF(n)("got packet: %d, %d\n", length, packetLength); 550 550 551 551 //if this is an old state drop it
Note: See TracChangeset
for help on using the changeset viewer.