Child: [180d2e] (diff)

Download this file

DTCP.h    186 lines (141 with data), 5.5 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
//
// Copyright Š 2014 PRISTINE Consortium (http://ict-pristine.eu)
//
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public License
// as published by the Free Software Foundation; either version 3
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with this program; if not, see <http://www.gnu.org/licenses/>.
//
/*
* DTCP.h
*
* Created on: Apr 17, 2014
* Author: Marcel Marek
*/
#ifndef DTCP_H_
#define DTCP_H_
#include <csimplemodule.h>
//#include "RXControl.h"
#include "DTCPState.h"
#include "DTPState.h"
#include "DTP.h"
#include "EFCP_defs.h"
#include "ControlPDU_m.h"
#include "DTCPTimers_m.h"
/* Policies */
#include "DTCPECNPolicyBase.h"
#include "DTCPRcvrFCPolicyBase.h"
#include "DTCPRcvrAckPolicyBase.h"
#include "DTCPReceivingFCPolicyBase.h"
#include "DTCPSendingAckPolicyBase.h"
#include "DTCPLostControlPDUPolicyBase.h"
#include "DTCPRcvrControlAckPolicyBase.h"
#include "DTCPSenderAckPolicyBase.h"
#include "DTCPFCOverrunPolicyBase.h"
#include "DTCPNoOverridePeakPolicyBase.h"
#include "DTCPTxControlPolicyBase.h"
#include "DTCPNoRateSlowDownPolicyBase.h"
#include "DTCPReconcileFCPolicyBase.h"
#include "DTCPRateReductionPolicyBase.h"
class DTP;
class DTCP: public cSimpleModule {
friend class DTP;
private:
DTP* dtp;
DTCPState *dtcpState;
// FlowControl* flowControl;
// RXControl* rxControl;
DTCPECNPolicyBase* ecnPolicy;
DTCPRcvrFCPolicyBase* rcvrFCPolicy;
DTCPRcvrAckPolicyBase* rcvrAckPolicy;
DTCPReceivingFCPolicyBase* receivingFCPolicy;
DTCPSendingAckPolicyBase* sendingAckPolicy;
DTCPLostControlPDUPolicyBase* lostControlPDUPolicy;
DTCPRcvrControlAckPolicyBase* rcvrControlAckPolicy;
DTCPSenderAckPolicyBase* senderAckPolicy;
DTCPFCOverrunPolicyBase* fcOverrunPolicy;
DTCPNoOverridePeakPolicyBase* noOverridePeakPolicy;
DTCPTxControlPolicyBase* txControlPolicy;
DTCPNoRateSlowDownPolicyBase* noRateSlowDownPolicy;
DTCPReconcileFCPolicyBase* reconcileFCPolicy;
DTCPRateReductionPolicyBase* rateReductionPolicy;
/*Timers*/
WindowTimer* windowTimer;
DTCPSendingRateTimer sendingRateTimer;
void schedule(DTCPTimers *timer, double time = 0.0);
void resetWindowTimer();
void sendAckPDU();
void flushAllQueuesAndPrepareToDie();
void handleSendingRateTimer(DTCPSendingRateTimer* timer);
public:
DTCP();
virtual ~DTCP();
void setDTP(DTP* dtp);
DTCPState* getDTCPState() const;
void handleWindowTimer(WindowTimer* timer);
void handleDTCPRxExpiryTimer(DTCPRxExpiryTimer* timer);
void updateRcvRtWinEdge(DTPState* dtpState);
unsigned int getNextSndCtrlSeqNum();
unsigned int getLastCtrlSeqNumRcv();
void setLastCtrlSeqnumRcvd(unsigned int ctrlSeqNum);
void setSndRtWinEdge(unsigned int sndRtWinEdge);
unsigned int getSndRtWinEdge();
void setRcvRtWinEdge(unsigned int rcvRtWinEdge);
unsigned int getRcvRtWinEdge();
unsigned int getRcvCredit();
unsigned long getSendingTimeUnit();
bool isSendingRateFullfilled() const;
void setSendingRateFullfilled(bool rateFullfilled);
void incRcvRtWinEdge();
void nackPDU(unsigned int startSeqNum, unsigned int endSeqNum = 0);
void ackPDU(unsigned int startSeqNum, unsigned int endSeqNum = 0);
void pushBackToRxQ(DataTransferPDU* pdu);
void clearRxQ();
unsigned int getDataReXmitMax() const;
unsigned int getPdusSentInTimeUnit() const;
void setPdusSentInTimeUnit(unsigned int pdusSentInTimeUnit);
void incPdusSentInTimeUnit();
unsigned int getSendingRate() const;
void setSendingRate(unsigned int sendingRate);
unsigned int getRcvrRate() const;
void incDupAcks();
unsigned int getDupAcks() const;
void incDupFC();
unsigned int getDupFC() const;
unsigned int getSenderLeftWinEdge() const;
void setSenderLeftWinEdge(unsigned int senderLeftWinEdge);
void updateSenderLWE(unsigned int seqNum);
/* Run Policies */
bool runECNPolicy(DTPState* dtpState);
bool runRcvrFCPolicy(DTPState* dtpState);
bool runRcvrAckPolicy(DTPState* dtpState);
bool runReceivingFCPolicy(DTPState* dtpState);
bool runSendingAckPolicy(DTPState* dtpState, ATimer* timer);
bool runLostControlPDUPolicy(DTPState* dtpState);
bool runRcvrControlAckPolicy(DTPState* dtpState);
bool runSenderAckPolicy(DTPState* dtpState);
bool runFCOverrunPolicy(DTPState* dtpState);
bool runNoOverridePeakPolicy(DTPState* dtpState);
bool runTxControlPolicy(DTPState* dtpState, PDUQ_t* pduQ);
bool runNoRateSlowDownPolicy(DTPState* dtpState);
bool runReconcileFCPolicy(DTPState* dtpState);
bool runRateReductionPolicy(DTPState* dtpState);
//TODO policies
void runRxTimerExpiryPolicy(DTCPRxExpiryTimer* timer);
void redrawGUI();
void createPolicyModule(cModule* policy, const char* prefix, const char* name);
protected:
virtual void handleMessage(cMessage *msg);
virtual void initialize(int step);
int numInitStages() const { return 2;};
};
#endif /* DTCP_H_ */