Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 23, 2006, 11:40:29 AM (18 years ago)
Author:
rennerc
Message:

hover registers sync vars. started with connection monitor

File:
1 edited

Legend:

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

    r6981 r7767  
    1010#include "netdefs.h"
    1111
     12#include <map>
     13
     14#define N_PACKETS_FOR_PING 20
     15#define MSECS_TO_CALC_BWIDTH 1000
     16#define SECS_TO_TIMEOUT 10
     17
    1218class ConnectionMonitor : virtual public BaseObject
    13   {
     19{
    1420  public:
    15     ConnectionMonitor();
     21    ConnectionMonitor( int userId );
    1622    virtual ~ConnectionMonitor();
    1723
    18     void                processPacket(byte* packet, unsigned int packetLength);
     24    void processUnzippedOutgoingPacket( byte * data, int length, int stateId );
     25    void processUnzippedIncomingPacket( byte * data, int length, int stateId, int ackedState );
     26    void processZippedPacket(  );
     27   
     28    void calculatePing();
     29   
     30    bool hasTimedOut(){ return ( lastPacketTick + SECS_TO_TIMEOUT*1000 < SDL_GetTicks() ) && nIncomingPackets > 0; }
     31   
     32  private:
     33    float calculateBandWidth( std::map<int,int> packetHistory, int tick );
     34   
     35    int userId;       //!< user's id
    1936
     37    std::map<int,int>   sentStateTicks;
     38   
     39    std::map<int,int>   incomingUnzippedPacketHistory;
     40    std::map<int,int>   outgoingUnzippedPacketHistory;
     41   
     42    std::list<int>      ackDelay;
     43    int                 ping;
    2044
    21   private:
    22 
    23 
    24     void                displayStatistic();
    25     void                computeCurrentDatarate();
    26     void                doUDPRelatedStuff();
    27 
    28     /*Data of the lifetime of the ConnectionMonitor Object*/
    29     unsigned int        packetToAverage;
    30     char*               protocollType;
    31 
    32     unsigned int        totalReceivedPackets;
    33     float               averageDatarate;
    34     unsigned int        totalLostPackets;
    35     float               totalPacketloss;
    36     unsigned int        startTime;
    37 
    38     /*Data of the current packet*/
    39     unsigned int        currentPacketID;
    40     unsigned int        currentPacketTick;
    41     unsigned int        lastPacketID;
    42     unsigned int        lastPacketTick;
    43     unsigned int        currentDelay;
    44 
    45     /*Data of the last n packets (n is specified by paxketsToAverage)*/
    46     unsigned int        sizeOfLastFewPackets;
    47     unsigned int        currentDatarate;
    48     byte**              lastFewPackets;
    49     unsigned int*       lastFewDelays;
    50     unsigned int        packetCounter;
    51 
     45    float               incomingUnzippedBandWidth;
     46    float               outgoingUnzippedBandWidth;
     47   
     48    int                 nIncomingPackets;
     49    int                 nOutgoingPackets;
     50   
     51    int                 lastPacketTick;
    5252  };
    5353
Note: See TracChangeset for help on using the changeset viewer.