Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7952 in orxonox.OLD


Ignore:
Timestamp:
May 29, 2006, 2:26:23 PM (18 years ago)
Author:
rennerc
Message:

less output on telnet console

Location:
branches/network/src/lib/network
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/network/src/lib/network/connection_monitor.cc

    r7872 r7952  
    2424using namespace std;
    2525
     26/**
     27 * constructor
     28 * @param userId user's id
     29 */
    2630ConnectionMonitor::ConnectionMonitor( int userId )
    2731{
     
    4145 
    4246  this->lastPacketTick = 0;
    43 }
    44 
     47  this->lastPrintTick = 0;
     48}
     49
     50/**
     51 * deconstructor
     52 */
    4553ConnectionMonitor::~ConnectionMonitor( )
    4654{
    4755}
    4856
     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 */
    4963void ConnectionMonitor::processUnzippedOutgoingPacket( byte * data, int length, int stateId )
    5064{
     
    6074  outgoingUnzippedBandWidth = calculateBandWidth( outgoingUnzippedPacketHistory, tick );
    6175 
    62   NETPRINTF(n)("UNZIPPED UPSTREAM: user: %d bandwidth %f\n", userId, outgoingUnzippedBandWidth );
     76  //NETPRINTF(n)("UNZIPPED UPSTREAM: user: %d bandwidth %f\n", userId, outgoingUnzippedBandWidth );
    6377 
    6478  // count zero bytes
     
    6983      nZeroBytes++;
    7084 
    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 */
    7495void ConnectionMonitor::processUnzippedIncomingPacket( byte * data, int length, int stateId, int ackedState )
    7596{
     
    102123    ping /= ackDelay.size();
    103124     
    104   NETPRINTF(n)("PING: user: %d ping: %d\n", userId, ping );
     125  //NETPRINTF(n)("PING: user: %d ping: %d\n", userId, ping );
    105126 
    106127  // calculate bandwidth
     
    108129  incomingUnzippedBandWidth = calculateBandWidth( incomingUnzippedPacketHistory, tick );
    109130 
    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 */
    114141float ConnectionMonitor::calculateBandWidth( std::map< int, int > packetHistory, int tick )
    115142{
     
    136163
    137164
    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 */
    140171void ConnectionMonitor::processZippedOutgoingPacket( byte * data, int length, int stateId )
    141172{
     
    148179  outgoingZippedBandWidth = calculateBandWidth( outgoingZippedPacketHistory, tick );
    149180 
    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 */
    155198void ConnectionMonitor::processZippedIncomingPacket( byte * data, int length, int stateId, int ackedState )
    156199{
     
    163206  incomingZippedBandWidth = calculateBandWidth( incomingZippedPacketHistory, tick );
    164207 
    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 */
    170217bool ConnectionMonitor::hasTimedOut( )
    171218{
     
    180227
    181228
     229
     230/**
     231 * prints bandwith usage, ping and other important things to telnet-console
     232 */
     233void 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  
    3232    bool hasTimedOut();
    3333   
     34    void printStatis();
     35   
    3436  private:
    3537    float calculateBandWidth( std::map<int,int> packetHistory, int tick );
     
    6163   
    6264    int                 lastPacketTick;
     65   
     66    int                 lastPrintTick;
    6367  };
    6468
  • branches/network/src/lib/network/network_stream.cc

    r7916 r7952  
    454454     
    455455      //check if all bytes == 0 -> remove data
    456 
     456      //TODO not all synchronizeables like this maybe add Synchronizeable::canRemoveZeroDiff()
    457457      bool allZero = true;
    458458      for ( int i = 0; i < n; i++ )
     
    464464      if ( allZero )
    465465      {
    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());
    467467        offset = oldOffset;
    468468      }
     
    499499    peer->second.connectionMonitor->processZippedOutgoingPacket( compBuf, compLength, currentState );
    500500   
    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);
    502502  }
    503503}
     
    544544      assert( Converter::byteArrayToInt( buf + 2*INTSIZE, &fromState ) == INTSIZE );
    545545      assert( Converter::byteArrayToInt( buf + 3*INTSIZE, &ackedState ) == INTSIZE );
    546       NETPRINTF(n)("ackedstate: %d\n", ackedState);
     546      //NETPRINTF(n)("ackedstate: %d\n", ackedState);
    547547      offset = 4*INTSIZE;
    548548
    549       NETPRINTF(n)("got packet: %d, %d\n", length, packetLength);
     549      //NETPRINTF(n)("got packet: %d, %d\n", length, packetLength);
    550550   
    551551    //if this is an old state drop it
Note: See TracChangeset for help on using the changeset viewer.