Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/lib/network/connection_monitor.h @ 8362

Last change on this file since 8362 was 8362, checked in by bensch, 18 years ago

orxonox/trunk: removed stupid included in base_object.h
this should lead to faster compile-times

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#include <list>
14
15#define N_PACKETS_FOR_PING 20
16#define MSECS_TO_CALC_BWIDTH 1000
17#define SECS_TO_TIMEOUT 10
18
19class ConnectionMonitor : virtual public BaseObject
20{
21  public:
22    ConnectionMonitor( int userId );
23    virtual ~ConnectionMonitor();
24
25    void processUnzippedOutgoingPacket( int tick, byte * data, int length, int stateId );
26    void processUnzippedIncomingPacket( int tick, byte * data, int length, int stateId, int ackedState );
27
28    void processZippedOutgoingPacket( int tick, byte * data, int length, int stateId );
29    void processZippedIncomingPacket( int tick, byte * data, int length );
30
31    void calculatePing();
32
33    bool hasTimedOut();
34
35    void printStatis();
36
37  private:
38    float calculateBandWidth( std::map<int,int> packetHistory, int tick );
39
40    int userId;       //!< user's id
41
42    std::map<int,int>   sentStateTicks;
43
44    std::map<int,int>   incomingUnzippedPacketHistory;
45    std::map<int,int>   outgoingUnzippedPacketHistory;
46
47    std::map<int,int>   incomingZippedPacketHistory;
48    std::map<int,int>   outgoingZippedPacketHistory;
49
50    std::list<int>      ackDelay;
51    int                 ping;
52
53    float               incomingUnzippedBandWidth;
54    float               outgoingUnzippedBandWidth;
55
56    float               incomingZippedBandWidth;
57    float               outgoingZippedBandWidth;
58
59    int                 nIncomingPackets;
60    int                 nOutgoingPackets;
61
62    int                 nZIncomingPackets;
63    int                 nZOutgoingPackets;
64
65    int                 lastPacketTick;
66
67    int                 lastPrintTick;
68  };
69
70#endif
Note: See TracBrowser for help on using the repository browser.