Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/network/src/lib/network/connection_monitor.h @ 7767

Last change on this file since 7767 was 7767, checked in by rennerc, 18 years ago

hover registers sync vars. started with connection monitor

File size: 1.4 KB
Line 
1/*!
2 * @file connection_monitor.h
3    \brief provides information about the quality of a connection.
4 */
5
6#ifndef _CONNECTION_MONITOR_H
7#define _CONNECTION_MONITOR_H
8
9#include "base_object.h"
10#include "netdefs.h"
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
18class ConnectionMonitor : virtual public BaseObject
19{
20  public:
21    ConnectionMonitor( int userId );
22    virtual ~ConnectionMonitor();
23
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
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;
44
45    float               incomingUnzippedBandWidth;
46    float               outgoingUnzippedBandWidth;
47   
48    int                 nIncomingPackets;
49    int                 nOutgoingPackets;
50   
51    int                 lastPacketTick;
52  };
53
54#endif
Note: See TracBrowser for help on using the repository browser.