Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7974 in orxonox.OLD


Ignore:
Timestamp:
May 30, 2006, 11:44:48 AM (18 years ago)
Author:
rennerc
Message:

network traffic is measured correctly now
added PlayerStats class

Location:
branches/network/src
Files:
2 added
7 edited

Legend:

Unmodified
Added
Removed
  • branches/network/src/defs/class_id.h

    r7954 r7974  
    367367  CL_NETWORK_GAME_MANAGER       =    0x00000d07,
    368368  CL_MESSAGE_MANAGER            =    0x00000d08,
    369   CL_SIMPLE_SYNC                =    0x00000d09,
     369  CL_PLAYER_STATS               =    0x00000d09,
     370  CL_SIMPLE_SYNC                =    0x00000d0a,
    370371
    371372
  • branches/network/src/lib/network/Makefile.am

    r7954 r7974  
    2323                      network_log.cc \
    2424                      zip.cc \
     25                      player_stats.cc \
    2526                      \
    2627                      synchronizeable_var/synchronizeable_var.cc \
     
    5657                 network_log.h \
    5758                 zip.h \
     59                 player_stats.h \
    5860                 \
    5961                 synchronizeable_var/synchronizeable_var.h \
  • branches/network/src/lib/network/connection_monitor.cc

    r7954 r7974  
    6161 * @param stateId packet's state id
    6262 */
    63 void ConnectionMonitor::processUnzippedOutgoingPacket( byte * data, int length, int stateId )
    64 {
    65   int tick = SDL_GetTicks();
    66  
     63void ConnectionMonitor::processUnzippedOutgoingPacket( int tick, byte * data, int length, int stateId )
     64{
    6765  nOutgoingPackets++;
    6866 
     
    9391 * @param ackedState state which was acked by this packet
    9492 */
    95 void ConnectionMonitor::processUnzippedIncomingPacket( byte * data, int length, int stateId, int ackedState )
    96 {
    97   int tick = SDL_GetTicks();
    98  
     93void ConnectionMonitor::processUnzippedIncomingPacket( int tick, byte * data, int length, int stateId, int ackedState )
     94{
    9995  nIncomingPackets++;
    10096 
     
    169165 * @param stateId packet's state id
    170166 */
    171 void ConnectionMonitor::processZippedOutgoingPacket( byte * data, int length, int stateId )
    172 {
    173   int tick = SDL_GetTicks();
    174  
     167void ConnectionMonitor::processZippedOutgoingPacket( int tick, byte * data, int length, int stateId )
     168{
    175169  nZOutgoingPackets++;
    176170 
     
    196190 * @param ackedState state which was acked by this packet
    197191 */
    198 void ConnectionMonitor::processZippedIncomingPacket( byte * data, int length, int stateId, int ackedState )
    199 {
    200   int tick = SDL_GetTicks();
    201  
     192void ConnectionMonitor::processZippedIncomingPacket( int tick, byte * data, int length )
     193{
    202194  nZIncomingPackets++;
    203195 
     
    233225void ConnectionMonitor::printStatis( )
    234226{
    235   NETPRINT(n)("=========NETWORKSTATS FOR USER %d=========\n", userId);
    236   NETPRINT(n)("PING = %d\n", ping);
     227  NETPRINT(n)("============NETWORKSTATS FOR USER %d============\n", userId);
     228  NETPRINT(n)("PING = %d\n", ping );
    237229  NETPRINT(n)("BANDWIDTH: UP: %f (%f) DOWN %f (%f)\n", outgoingZippedBandWidth, outgoingUnzippedBandWidth, incomingZippedBandWidth, incomingUnzippedBandWidth);
    238   NETPRINT(n)("==========================================");
    239 }
    240 
    241 
     230  NETPRINT(n)("PACKETS: RECIEVED %d; SENT %d\n", nIncomingPackets, nOutgoingPackets );
     231  NETPRINT(n)("================================================\n");
     232}
     233
     234
  • branches/network/src/lib/network/connection_monitor.h

    r7954 r7974  
    2222    virtual ~ConnectionMonitor();
    2323
    24     void processUnzippedOutgoingPacket( byte * data, int length, int stateId );
    25     void processUnzippedIncomingPacket( byte * data, int length, int stateId, int ackedState );
     24    void processUnzippedOutgoingPacket( int tick, byte * data, int length, int stateId );
     25    void processUnzippedIncomingPacket( int tick, byte * data, int length, int stateId, int ackedState );
    2626   
    27     void processZippedOutgoingPacket( byte * data, int length, int stateId );
    28     void processZippedIncomingPacket( byte * data, int length, int stateId, int ackedState );
     27    void processZippedOutgoingPacket( int tick, byte * data, int length, int stateId );
     28    void processZippedIncomingPacket( int tick, byte * data, int length );
    2929   
    3030    void calculatePing();
  • branches/network/src/lib/network/network_stream.cc

    r7954 r7974  
    177177void NetworkStream::processData()
    178178{
     179  int tick = SDL_GetTicks();
     180 
    179181  currentState++;
    180182 
     
    207209  // order of up/downstream is important!!!!
    208210  // don't change it
    209   handleDownstream();
    210   handleUpstream();
     211  handleDownstream( tick );
     212  handleUpstream( tick );
    211213
    212214}
     
    391393 * handle upstream network traffic
    392394 */
    393 void NetworkStream::handleUpstream( )
     395void NetworkStream::handleUpstream( int tick )
    394396{
    395397  int offset;
    396398  int n;
    397399 
    398   for ( PeerList::iterator peer = peers.begin(); peer != peers.end(); peer++ )
     400  for ( PeerList::reverse_iterator peer = peers.rbegin(); peer != peers.rend(); peer++ )
    399401  {
    400402    offset = INTSIZE; //make already space for length
     
    496498      writeToNewDict( buf, offset );
    497499   
    498     peer->second.connectionMonitor->processUnzippedOutgoingPacket( buf, offset, currentState );
    499     peer->second.connectionMonitor->processZippedOutgoingPacket( compBuf, compLength, currentState );
     500    peer->second.connectionMonitor->processUnzippedOutgoingPacket( tick, buf, offset, currentState );
     501    peer->second.connectionMonitor->processZippedOutgoingPacket( tick, compBuf, compLength, currentState );
    500502   
    501503    //NETPRINTF(n)("send packet: %d userId = %d\n", offset, peer->second.userId);
     
    506508 * handle downstream network traffic
    507509 */
    508 void NetworkStream::handleDownstream( )
     510void NetworkStream::handleDownstream( int tick )
    509511{
    510512  int offset = 0;
     
    527529    while ( 0 < (compLength = peer->second.socket->readPacket( compBuf, UDP_PACKET_SIZE )) )
    528530    {
    529       //TODO tell monitor about zipped packet. because dropped packets dont count to bandwidth
     531      peer->second.connectionMonitor->processZippedIncomingPacket( tick, compBuf, compLength );
     532     
    530533      //PRINTF(0)("GGGGGOOOOOOOOOOTTTTTTTT: %d\n", compLength);
    531534      packetLength = Zip::getInstance()->unZip( compBuf, compLength, buf, UDP_PACKET_SIZE );
     
    547550      //NETPRINTF(n)("ackedstate: %d\n", ackedState);
    548551      offset = 4*INTSIZE;
     552     
     553      peer->second.connectionMonitor->processUnzippedIncomingPacket( tick, buf, offset, state, ackedState );
    549554
    550555      //NETPRINTF(n)("got packet: %d, %d\n", length, packetLength);
     
    672677      }
    673678     
    674       peer->second.connectionMonitor->processZippedIncomingPacket( compBuf, compLength, state, ackedState );
    675       peer->second.connectionMonitor->processUnzippedIncomingPacket( buf, offset, state, ackedState );
    676    
    677679      assert( peer->second.lastAckedState <= ackedState );
    678680      peer->second.lastAckedState = ackedState;
  • branches/network/src/lib/network/network_stream.h

    r7954 r7974  
    7979    void updateConnectionList();
    8080    void handleHandshakes();
    81     void handleUpstream();
    82     void handleDownstream();
     81    void handleUpstream( int tick );
     82    void handleDownstream(int tick );
    8383    void handleNewClient( int userId );
    8484    void cleanUpOldSyncList();
  • branches/network/src/lib/network/synchronizeable.h

    r7954 r7974  
    6161    virtual void handleSentState( int userId, int stateId, int fromStateId );
    6262    virtual void handleRecvState( int userId, int stateId, int fromStateId );
    63 
     63   
    6464    void registerVar( SynchronizeableVar * var );
    6565    int registerVarId( SynchronizeableVar * var );
Note: See TracChangeset for help on using the changeset viewer.