Alex Bikfalvi
SimStream Documentation
ConnectionReceiver.h
00001 #pragma once 00002 00003 #include "Connection.h" 00004 00005 #define MAX_LOSS_EVENTS 8 00006 00007 class CConnectionReceiver : public CConnection 00008 { 00009 private: 00010 struct SLossEvent 00011 { 00012 __time firstLossTime; 00013 __uint32 firstLossSequence; 00014 }; 00015 00016 /* 00017 * For performance reasons, the loss packets history is implemented as a FIFO queue and the receiver does not check if an out-of-order 00018 * packet has been previously added (it is not possible to have out-of-order packets). Otherwise, it is possible that a receiver might 00019 * report the same packet as both acknowledged and loss at the same time. If the implementation will support out of order packets, 00020 * such a check mush be made either at the receiver or at the sender (better). 00021 */ 00022 typedef map<__uint32, __time> THistoryRecv; 00023 typedef queue<__uint32> THistoryLoss; 00024 00025 // Delegate 00026 IDelegate2<void, CConnectionReceiver*, CPacket*>* 00027 delegateRecv; 00028 00029 // Flow 00030 double flowLossRate; 00031 __bitrate flowRateRecv; 00032 __time flowRtt; 00033 __uint32 flowSequenceLast; // last received sequence number 00034 __time flowTimeLast; // last received time 00035 00036 __time timeTxLast; // transmit time of last received data packet 00037 __time timeRxLast; // receive time of last received data packet 00038 __time timeFeedbackLast; // last expiration of the feedback timer 00039 00040 // Timers 00041 CTimer<CConnectionReceiver>* 00042 timerFeedback; 00043 00044 // Receive function 00045 void (CConnectionReceiver::*recvData)(CPacketConnectionData*); 00046 00047 // History 00048 THistoryRecv historyRecv; 00049 THistoryLoss historyLoss; 00050 00051 // Loss 00052 SLossEvent lossEvents[MAX_LOSS_EVENTS]; 00053 __byte lossEventFirst; 00054 __byte lossEventLast; 00055 __byte lossEventCount; 00056 static double lossIntervalWeigth[MAX_LOSS_EVENTS]; 00057 __uint32 lossSequenceLast; 00058 double lossPrevInterval0; 00059 double lossPrevInterval1; 00060 double lossPrevWeigth; 00061 00062 __uint32 recvSize; 00063 00064 public: 00065 CConnectionReceiver( 00066 __uint32 idEntry, 00067 __uint16 port, 00068 CSimHandler* sim, 00069 IDelegate5<void, __uint16, __uint16, CAddress, __byte, CPacket*>* delegateSend, 00070 IDelegate2<void, CConnectionReceiver*, CPacket*>* delegateRecv, 00071 IDelegate1<void, CConnection*>* delegateDispose, 00072 CAddress remoteAddress, 00073 __uint16 remotePort 00074 ); 00075 virtual ~CConnectionReceiver(); 00076 00077 char* ToString() const; 00078 private: 00079 // Receive 00080 virtual void Recv(CPacketConnection* packet); 00081 virtual void RecvData(CPacketConnectionData* packet); 00082 void RecvDataFirst(CPacketConnectionData* packet); 00083 void RecvDataNext(CPacketConnectionData* packet); 00084 virtual void RecvFeedback(CPacketConnectionFeedback* packet) { /* do nothing */ } 00085 00086 // Timers 00087 void TimerFeedback(CTimerInfo* info); 00088 };
Last updated: February 8, 2011