Changeset 7767 in orxonox.OLD for branches/network/src/lib/network/connection_monitor.h
- Timestamp:
- May 23, 2006, 11:40:29 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/network/src/lib/network/connection_monitor.h
r6981 r7767 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 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 19 36 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; 20 44 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; 52 52 }; 53 53
Note: See TracChangeset
for help on using the changeset viewer.