Child: [65cd22] (diff)

Download this file

AEBase.cc    238 lines (205 with data), 8.7 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
// 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_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 APNamingInfo& AEBase::getApni() const {
return apni;
}
void AEBase::setApni(const APNamingInfo& apni) {
this->apni = apni;
}
const Flows& AEBase::getFlows() const {
return flows;
}
void AEBase::setFlows(const Flows& flows) {
this->flows = flows;
}
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::initNamingInfo() {
//Source info
srcApName = this->getParentModule()->par(PAR_APNAME).stdstringValue();
srcApInstance = this->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_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)
)
) {
std::stringstream 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_QOSPARAMDONOTCARE; //Average bandwidth (measured at the application in bits/sec)
int avgSDUBand = VAL_QOSPARAMDONOTCARE; //Average SDU bandwidth (measured in SDUs/sec)
int peakBandDuration = VAL_QOSPARAMDONOTCARE; //Peak bandwidth-duration (measured in bits/sec);
int peakSDUBandDuration = VAL_QOSPARAMDONOTCARE; //Peak SDU bandwidth-duration (measured in SDUs/sec);
int burstPeriod = VAL_QOSPARAMDONOTCARE; //Burst period measured in useconds
int burstDuration = VAL_QOSPARAMDONOTCARE; //Burst duration, measured in usecs fraction of Burst Period
int undetectedBitErr = VAL_QOSPARAMDONOTCARE; //Undetected bit error rate measured as a probability
int maxSDUsize = VAL_QOSPARAMDONOTCARE; //MaxSDUSize measured in bytes
bool partDeliv = VAL_QOSPARAMDEFBOOL; //Partial Delivery - Can SDUs be delivered in pieces rather than all at once?
bool incompleteDeliv = VAL_QOSPARAMDEFBOOL; //Incomplete Delivery - Can SDUs with missing pieces be delivered?
bool forceOrder = VAL_QOSPARAMDEFBOOL; //Must SDUs be delivered in order?
unsigned int maxAllowGap = VAL_QOSPARAMDONOTCARE; //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_QOSPARAMDONOTCARE; //Delay in usecs
int jitter = VAL_QOSPARAMDONOTCARE; //Jitter in usecs2
int costtime = VAL_QOSPARAMDONOTCARE; //measured in $/ms
int costbits = VAL_QOSPARAMDONOTCARE; //measured in $/Mb
avgBand = par(PAR_AVGBW);
if (avgBand < 0)
avgBand = VAL_QOSPARAMDONOTCARE;
avgSDUBand = par(PAR_AVGSDUBW);
if (avgSDUBand < 0)
avgSDUBand = VAL_QOSPARAMDONOTCARE;
peakBandDuration = par(PAR_PEAKBWDUR);
if (peakBandDuration < 0)
peakBandDuration = VAL_QOSPARAMDONOTCARE;
peakSDUBandDuration = par(PAR_PEAKSDUBWDUR);
if (peakSDUBandDuration < 0)
peakSDUBandDuration = VAL_QOSPARAMDONOTCARE;
burstPeriod = par(PAR_BURSTPERIOD);
if (burstPeriod < 0)
burstPeriod = VAL_QOSPARAMDONOTCARE;
burstDuration = par(PAR_BURSTDURATION);
if (burstDuration < 0)
burstDuration = VAL_QOSPARAMDONOTCARE;
undetectedBitErr = par(PAR_UNDETECTBITERR);
if (undetectedBitErr < 0 || undetectedBitErr > 1 )
undetectedBitErr = VAL_QOSPARAMDONOTCARE;
maxSDUsize = par(PAR_MAXSDUSIZE);
if (maxSDUsize < 0)
maxSDUsize = VAL_QOSPARAMDONOTCARE;
partDeliv = par(PAR_PARTIALDELIVER);
incompleteDeliv = par(PAR_INCOMPLETEDELIVER);
forceOrder = par(PAR_FORCEORDER);
maxAllowGap = par(PAR_MAXALLOWGAP);
if (maxAllowGap < 0)
maxAllowGap = VAL_QOSPARAMDONOTCARE;
delay = par(PAR_DELAY);
if (delay < 0)
delay = VAL_QOSPARAMDONOTCARE;
jitter = par(PAR_JITTER);
if (jitter < 0)
jitter = VAL_QOSPARAMDONOTCARE;
costtime = par(PAR_COSTTIME);
if (costtime < 0)
costtime = VAL_QOSPARAMDONOTCARE;
costbits = par(PAR_COSTBITS);
if (costbits < 0)
costbits = VAL_QOSPARAMDONOTCARE;
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);
this->setQoSRequirements(cube);
//EV << "QQQQQQ\n" << cube << "\n\nXXXX\n" << this->getQoSRequirements();
}
void AEBase::handleMessage(cMessage *msg)
{
// TODO - Generated method body
}
void AEBase::insertFlow(Flow& flow) {
flows.push_back(flow);
}
bool AEBase::hasFlow(const Flow* flow) {
for (TFlowsIter it = flows.begin(); it != flows.end(); ++it) {
if (*it == *flow)
return true;
}
return false;
}