Alex Bikfalvi
SimStream Documentation
ConnectionSender.h
00001 #pragma once 00002 00003 #include "Connection.h" 00004 00005 #define RECV_RATE_SET_SIZE 4 00006 00007 class CConnectionSender : public CConnection 00008 { 00009 public: 00010 enum EResult 00011 { 00012 SEND_SUCCESS = 0, 00013 SEND_FAIL_NOT_OPEN = 1 00014 }; 00015 00016 enum EStateSender 00017 { 00018 IDLE = 0, 00019 SENDING = 1 00020 }; 00021 00022 private: 00023 typedef queue<CPacket*> TBufferQueue; 00024 typedef map<__uint32, CPacket*> 00025 TBufferMap; 00026 00027 // State 00028 EStateSender stateSender; 00029 00030 // Buffer 00031 TBufferQueue bufferTx; // transmission buffer (packets to be tranmitted) 00032 TBufferMap bufferAck; // acknowledgment buffer (packets transmitted but now acknowledged, either received or lost) 00033 TBufferQueue bufferRtx; // retransmission buffer (packets acknowledged as lost) 00034 00035 // Flow 00036 __time flowRtt; // round-trip time 00037 __time flowRto; // retransmission time-out 00038 __time flowTld; // list-time doubled 00039 00040 __uint32 flowMss; // flow maximum segment size in bits 00041 __bitrate flowRate; // flow rate (bps) 00042 __bitrate flowRateBps; // flow rate calculated with TCP throughput equation 00043 __bitrate flowInitialRate; // flow initial rate (bps) 00044 00045 double flowLossRate; // flow last reported loss rate (p) 00046 00047 __uint32 flowPacketSequence; 00048 __uint32 flowPacketId; 00049 __uint32 flowPacketSize; 00050 00051 static double flowThroughputFunction[]; // flow throughput function f(p) 00052 static __time flowMaximumBackoffInterval; 00053 00054 bool flowIdleNoFeedback; 00055 00056 // Data-limited interval 00057 __time dliNotLimited1; 00058 __time dliNotLimited2; 00059 __time dliTimeNew; 00060 __time dliTimeNext; 00061 00062 // Receiver 00063 __bitrate recvRateSet[RECV_RATE_SET_SIZE]; 00064 __byte recvRateSetFirst; 00065 __byte recvRateSetLast; 00066 00067 // Timers 00068 CTimer<CConnectionSender>* 00069 timerNoFeedback; 00070 CTimer<CConnectionSender>* 00071 timerSender; 00072 00073 // Functions 00074 void (CConnectionSender::*functionSender)(); 00075 00076 // Events 00077 Event2<void, CConnectionSender*, CPacket*>* eventSend; 00078 00079 public: 00080 CConnectionSender( 00081 __uint32 idEntry, 00082 __uint16 port, 00083 CSimHandler* sim, 00084 IDelegate5<void, __uint16, __uint16, CAddress, __byte, CPacket*>* delegateSend, 00085 IDelegate1<void, CConnection*>* delegateDispose, 00086 CAddress remoteAddress, 00087 __uint16 remotePort, 00088 __uint32 remoteId, 00089 __uint32 remoteIdEntry, 00090 __uint32 segmentSize 00091 ); 00092 virtual ~CConnectionSender(); 00093 00094 // Send 00095 EResult Send(CPacket* packet); 00096 00097 // Event send 00098 inline Event2<void, CConnectionSender*, CPacket*>* 00099 EventSend() { return this->eventSend; } 00100 00101 // Stat 00102 inline __time StatFlowRtt() { return this->flowRtt; } 00103 inline __bitrate StatFlowRate() { return this->flowRate; } 00104 inline double StatFlowLossRate() { return this->flowLossRate; } 00105 00106 char* ToString() const; 00107 private: 00108 // Receive 00109 virtual void Recv(CPacketConnection* packet); 00110 virtual void RecvData(CPacketConnectionData* packet) { /* do nothing */ } 00111 virtual void RecvFeedback(CPacketConnectionFeedback* packet); 00112 00113 // Timers 00114 void TimerNoFeedback(CTimerInfo* info); 00115 void TimerSender(CTimerInfo* info); 00116 00117 void TimerSenderIdle(); 00118 void TimerSenderSending(); 00119 00120 // Congestion control 00121 void UpdateLimits(__bitrate limit); 00122 };
Last updated: February 8, 2011