Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 8420 was 8068, checked in by patrick, 18 years ago

trunk: merged the network branche back to trunk

File size: 1.8 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( int tick, byte * data, int length, int stateId );
25    void processUnzippedIncomingPacket( int tick, byte * data, int length, int stateId, int ackedState );
26   
27    void processZippedOutgoingPacket( int tick, byte * data, int length, int stateId );
28    void processZippedIncomingPacket( int tick, byte * data, int length );
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
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;
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;
67  };
68
69#endif
Note: See TracBrowser for help on using the repository browser.