Changeset 7954 in orxonox.OLD for trunk/src/lib/network/connection_monitor.h
- Timestamp:
- May 29, 2006, 3:28:41 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/network/connection_monitor.h
r6981 r7954 10 10 #include "netdefs.h" 11 11 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 12 18 class ConnectionMonitor : virtual public BaseObject 13 19 { 14 20 public: 15 ConnectionMonitor( );21 ConnectionMonitor( int userId ); 16 22 virtual ~ConnectionMonitor(); 17 23 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 27 void processZippedOutgoingPacket( byte * data, int length, int stateId ); 28 void processZippedIncomingPacket( byte * data, int length, int stateId, int ackedState ); 29 30 void calculatePing(); 31 32 bool hasTimedOut(); 33 34 void printStatis(); 35 36 private: 37 float calculateBandWidth( std::map<int,int> packetHistory, int tick ); 38 39 int userId; //!< user's id 19 40 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; 20 51 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 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; 52 67 }; 53 68
Note: See TracChangeset
for help on using the changeset viewer.