Parent: [180d2e] (diff)

Child: [569601] (diff)

Download this file

AEBase.cc    268 lines (229 with data), 9.6 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
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
// 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/.
//
#include "AEBase.h"
Define_Module(AEBase);
const char* PAR_AVGBW = "averageBandwidth";
const char* PAR_AVGSDUBW = "averageSDUBandwidth";
const char* PAR_PEAKBWDUR = "peakBandwidthDuration";
const char* PAR_PEAKSDUBWDUR = "peakSDUBandwidthDuration";
const char* PAR_BURSTPERIOD = "burstPeriod";
const char* PAR_BURSTDURATION = "burstDuration";
const char* PAR_UNDETECTBITERR = "undetectedBitErr";
const char* PAR_PDUDROPPROBAB = "pduDroppingProbability";
const char* PAR_MAXSDUSIZE = "maxSDUsize";
const char* PAR_PARTIALDELIVER = "partialDelivery";
const char* PAR_INCOMPLETEDELIVER = "incompleteDelivery";
const char* PAR_FORCEORDER = "forceOrder";
const char* PAR_MAXALLOWGAP = "maxAllowGap";
const char* PAR_DELAY = "delay";
const char* PAR_JITTER = "jitter";
const char* PAR_COSTTIME = "costTime";
const char* PAR_COSTBITS = "costBits";
const char* PAR_ATIME = "aTime";
const APNamingInfo& AEBase::getApni() const {
return apni;
}
void AEBase::setApni(const APNamingInfo& apni) {
this->apni = apni;
}
const int AEBase::getAuthType(){
return authType;
}
const std::string& AEBase::getAuthName() const {
return authName;
}
const std::string& AEBase::getAuthPassword() const {
return authPassword;
}
const std::string& AEBase::getAuthOther() const {
return authOther;
}
const std::string& AEBase::getSrcAeInstance() const {
return srcAeInstance;
}
void AEBase::setSrcAeInstance(const std::string& srcAeInstance) {
this->srcAeInstance = srcAeInstance;
}
const std::string& AEBase::getSrcAeName() const {
return srcAeName;
}
void AEBase::setSrcAeName(const std::string& srcAeName) {
this->srcAeName = srcAeName;
}
const std::string& AEBase::getSrcApInstance() const {
return srcApInstance;
}
void AEBase::setSrcApInstance(const std::string& srcApInstance) {
this->srcApInstance = srcApInstance;
}
const std::string& AEBase::getSrcApName() const {
return srcApName;
}
void AEBase::setSrcApName(const std::string& srcApName) {
this->srcApName = srcApName;
}
void AEBase::changeConStatus(CDAPConnectionState conState){
this->connectionState = conState;
}
CDAPConnectionState AEBase::getConStatus(){
return this->connectionState;
}
void AEBase::initNamingInfo() {
//Source info
srcApName = this->getParentModule()->getParentModule()->par(PAR_APNAME).stdstringValue();
srcApInstance = this->getParentModule()->getParentModule()->par(PAR_APINSTANCE).stdstringValue();
srcAeName = this->par(PAR_AENAME).stdstringValue();
srcAeInstance = this->par(PAR_AEINSTANCE).stdstringValue();
apni = APNamingInfo(APN(this->srcApName), this->srcApInstance,
this->srcAeName, this->srcAeInstance);
}
void AEBase::initialize()
{
initNamingInfo();
initQoSRequiremets();
}
const QoSCube& AEBase::getQoSRequirements() const {
return QoSRequirements;
}
void AEBase::setQoSRequirements(const QoSCube& qoSRequirements) {
QoSRequirements = qoSRequirements;
}
void AEBase::initQoSRequiremets() {
//Check whether module has all QoS parameters
if (! (hasPar(PAR_AVGBW) &&
hasPar(PAR_AVGSDUBW) &&
hasPar(PAR_PEAKBWDUR) &&
hasPar(PAR_PEAKSDUBWDUR) &&
hasPar(PAR_BURSTPERIOD) &&
hasPar(PAR_BURSTDURATION) &&
hasPar(PAR_UNDETECTBITERR) &&
hasPar(PAR_PDUDROPPROBAB) &&
hasPar(PAR_MAXSDUSIZE) &&
hasPar(PAR_PARTIALDELIVER) &&
hasPar(PAR_INCOMPLETEDELIVER) &&
hasPar(PAR_FORCEORDER) &&
hasPar(PAR_MAXALLOWGAP) &&
hasPar(PAR_DELAY) &&
hasPar(PAR_JITTER) &&
hasPar(PAR_COSTTIME) &&
hasPar(PAR_COSTBITS) &&
hasPar(PAR_ATIME)
)
) {
std::ostringstream ss;
ss << "Module " << this->getFullName() << " is not derived from AEBase. It misses some important QoS parameters!";
error(ss.str().c_str());
}
//Create QoS cube according to parameters
QoSCube cube;
int avgBand = VAL_QOSPARDONOTCARE; //Average bandwidth (measured at the application in bits/sec)
int avgSDUBand = VAL_QOSPARDONOTCARE; //Average SDU bandwidth (measured in SDUs/sec)
int peakBandDuration = VAL_QOSPARDONOTCARE; //Peak bandwidth-duration (measured in bits/sec);
int peakSDUBandDuration = VAL_QOSPARDONOTCARE; //Peak SDU bandwidth-duration (measured in SDUs/sec);
int burstPeriod = VAL_QOSPARDONOTCARE; //Burst period measured in useconds
int burstDuration = VAL_QOSPARDONOTCARE; //Burst duration, measured in usecs fraction of Burst Period
double undetectedBitErr = VAL_QOSPARDONOTCARE; //Undetected bit error rate measured as a probability
double pduDropProbab = VAL_QOSPARDONOTCARE;
int maxSDUsize = VAL_QOSPARDONOTCARE; //MaxSDUSize measured in bytes
bool partDeliv = VAL_QOSPARDEFBOOL; //Partial Delivery - Can SDUs be delivered in pieces rather than all at once?
bool incompleteDeliv = VAL_QOSPARDEFBOOL; //Incomplete Delivery - Can SDUs with missing pieces be delivered?
bool forceOrder = VAL_QOSPARDEFBOOL; //Must SDUs be delivered in order?
unsigned int maxAllowGap = VAL_QOSPARDONOTCARE; //Max allowable gap in SDUs, (a gap of N SDUs is considered the same as all SDUs delivered, i.e. a gap of N is a "don't care.")
int delay = VAL_QOSPARDONOTCARE; //Delay in usecs
int jitter = VAL_QOSPARDONOTCARE; //Jitter in usecs2
int costtime = VAL_QOSPARDONOTCARE; //measured in $/ms
int costbits = VAL_QOSPARDONOTCARE; //measured in $/Mb
double aTime = VAL_QOSPARDONOTCARE; //measured in ms
avgBand = par(PAR_AVGBW);
if (avgBand < 0)
avgBand = VAL_QOSPARDONOTCARE;
avgSDUBand = par(PAR_AVGSDUBW);
if (avgSDUBand < 0)
avgSDUBand = VAL_QOSPARDONOTCARE;
peakBandDuration = par(PAR_PEAKBWDUR);
if (peakBandDuration < 0)
peakBandDuration = VAL_QOSPARDONOTCARE;
peakSDUBandDuration = par(PAR_PEAKSDUBWDUR);
if (peakSDUBandDuration < 0)
peakSDUBandDuration = VAL_QOSPARDONOTCARE;
burstPeriod = par(PAR_BURSTPERIOD);
if (burstPeriod < 0)
burstPeriod = VAL_QOSPARDONOTCARE;
burstDuration = par(PAR_BURSTDURATION);
if (burstDuration < 0)
burstDuration = VAL_QOSPARDONOTCARE;
undetectedBitErr = par(PAR_UNDETECTBITERR).doubleValue();
if (undetectedBitErr < 0 || undetectedBitErr > 1 )
undetectedBitErr = VAL_QOSPARDONOTCARE;
pduDropProbab = par(PAR_PDUDROPPROBAB).doubleValue();
if (pduDropProbab < 0 || pduDropProbab > 1 )
pduDropProbab = VAL_QOSPARDONOTCARE;
maxSDUsize = par(PAR_MAXSDUSIZE);
if (maxSDUsize < 0)
maxSDUsize = VAL_QOSPARDONOTCARE;
partDeliv = par(PAR_PARTIALDELIVER);
incompleteDeliv = par(PAR_INCOMPLETEDELIVER);
forceOrder = par(PAR_FORCEORDER);
maxAllowGap = par(PAR_MAXALLOWGAP);
if (maxAllowGap < 0)
maxAllowGap = VAL_QOSPARDONOTCARE;
delay = par(PAR_DELAY);
if (delay < 0)
delay = VAL_QOSPARDONOTCARE;
jitter = par(PAR_JITTER);
if (jitter < 0)
jitter = VAL_QOSPARDONOTCARE;
costtime = par(PAR_COSTTIME);
if (costtime < 0)
costtime = VAL_QOSPARDONOTCARE;
costbits = par(PAR_COSTBITS);
if (costbits < 0)
costbits = VAL_QOSPARDONOTCARE;
aTime = par(PAR_ATIME).doubleValue();
if (aTime < 0)
aTime = VAL_QOSPARDONOTCARE;
cube.setQosId(0);
cube.setAvgBand(avgBand);
cube.setAvgSduBand(avgSDUBand);
cube.setPeakBandDuration(peakBandDuration);
cube.setPeakSduBandDuration(peakSDUBandDuration);
cube.setBurstPeriod(burstPeriod);
cube.setBurstDuration(burstDuration);
cube.setUndetectedBitErr(undetectedBitErr);
cube.setMaxSduSize(maxSDUsize);
cube.setPartialDelivery(partDeliv);
cube.setIncompleteDelivery(incompleteDeliv);
cube.setForceOrder(forceOrder);
cube.setMaxAllowGap(maxAllowGap);
cube.setDelay(delay);
cube.setJitter(jitter);
cube.setCostBits(costbits);
cube.setCostTime(costtime);
cube.setATime(aTime);
this->setQoSRequirements(cube);
//EV << "QQQQQQ\n" << cube << "\n\nXXXX\n" << this->getQoSRequirements();
}
void AEBase::handleMessage(cMessage *msg)
{
// TODO - Generated method body
}
Flow* AEBase::getFlowObject() const {
return FlowObject;
}
void AEBase::setFlowObject(Flow* flowObject) {
FlowObject = flowObject;
}
bool AEBase::hasFlow(const Flow* flow) {
return FlowObject ? *FlowObject == *flow : false;
}