[5523] | 1 | /*! |
---|
| 2 | * @file connection_monitor.h |
---|
| 3 | \brief provides information about the quality of a connection. |
---|
[5550] | 4 | */ |
---|
[5523] | 5 | |
---|
[5550] | 6 | #ifndef _CONNECTION_MONITOR_H |
---|
| 7 | #define _CONNECTION_MONITOR_H |
---|
[5523] | 8 | |
---|
[5581] | 9 | #include "base_object.h" |
---|
[5550] | 10 | #include "netdefs.h" |
---|
[5547] | 11 | |
---|
[7954] | 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 | |
---|
[5581] | 18 | class ConnectionMonitor : virtual public BaseObject |
---|
[7954] | 19 | { |
---|
[5618] | 20 | public: |
---|
[7954] | 21 | ConnectionMonitor( int userId ); |
---|
[6981] | 22 | virtual ~ConnectionMonitor(); |
---|
[5523] | 23 | |
---|
[8068] | 24 | void processUnzippedOutgoingPacket( int tick, byte * data, int length, int stateId ); |
---|
| 25 | void processUnzippedIncomingPacket( int tick, byte * data, int length, int stateId, int ackedState ); |
---|
[7954] | 26 | |
---|
[8068] | 27 | void processZippedOutgoingPacket( int tick, byte * data, int length, int stateId ); |
---|
| 28 | void processZippedIncomingPacket( int tick, byte * data, int length ); |
---|
[7954] | 29 | |
---|
| 30 | void calculatePing(); |
---|
| 31 | |
---|
| 32 | bool hasTimedOut(); |
---|
| 33 | |
---|
| 34 | void printStatis(); |
---|
| 35 | |
---|
[5618] | 36 | private: |
---|
[7954] | 37 | float calculateBandWidth( std::map<int,int> packetHistory, int tick ); |
---|
| 38 | |
---|
| 39 | int userId; //!< user's id |
---|
[5523] | 40 | |
---|
[7954] | 41 | std::map<int,int> sentStateTicks; |
---|
| 42 | |
---|
| 43 | std::map<int,int> incomingUnzippedPacketHistory; |
---|
| 44 | std::map<int,int> outgoingUnzippedPacketHistory; |
---|
| 45 | |
---|
| 46 | std::map<int,int> incomingZippedPacketHistory; |
---|
| 47 | std::map<int,int> outgoingZippedPacketHistory; |
---|
| 48 | |
---|
| 49 | std::list<int> ackDelay; |
---|
| 50 | int ping; |
---|
[5581] | 51 | |
---|
[7954] | 52 | float incomingUnzippedBandWidth; |
---|
| 53 | float outgoingUnzippedBandWidth; |
---|
| 54 | |
---|
| 55 | float incomingZippedBandWidth; |
---|
| 56 | float outgoingZippedBandWidth; |
---|
| 57 | |
---|
| 58 | int nIncomingPackets; |
---|
| 59 | int nOutgoingPackets; |
---|
| 60 | |
---|
| 61 | int nZIncomingPackets; |
---|
| 62 | int nZOutgoingPackets; |
---|
| 63 | |
---|
| 64 | int lastPacketTick; |
---|
| 65 | |
---|
| 66 | int lastPrintTick; |
---|
[5618] | 67 | }; |
---|
[5550] | 68 | |
---|
| 69 | #endif |
---|