Child: [b323f7] (diff)

Download this file

QoSCube.cc    387 lines (303 with data), 12.0 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
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
//
// 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/.
//
/*
* @file QoSCube.cc
* @author Marcel Marek
* @date Apr 28, 2014
* @brief
* @detail
*/
#include "QoSCube.h"
const char* STR_DONOTCARE = "do-not-care";
const char* STR_YES = "yes";
const char* STR_NO = "no";
const int VAL_DEFQOS = 0;
QoSCube::QoSCube() : qoSId(VAL_DEFQOS),
avgBand(VAL_DEFQOS), avgSDUBand(VAL_DEFQOS), peakBandDuration(VAL_DEFQOS), peakSDUBandDuration(VAL_DEFQOS),
burstPeriod(VAL_DEFQOS), burstDuration(VAL_DEFQOS), undetectedBitErr(VAL_DEFQOS), maxSDUsize(VAL_DEFQOS),
partDeliv(false), incompleteDeliv(false), forceOrder(false),
maxAllowGap(VAL_DEFQOS), delay(VAL_DEFQOS), jitter(VAL_DEFQOS),
costTime(VAL_DEFQOS), costBits(VAL_DEFQOS)
{
}
int QoSCube::getAvgBand() const {
return avgBand;
}
void QoSCube::setAvgBand(int avgBand) {
this->avgBand = avgBand;
}
int QoSCube::getAvgSduBand() const {
return avgSDUBand;
}
void QoSCube::setAvgSduBand(int avgSduBand) {
avgSDUBand = avgSduBand;
}
int QoSCube::getBurstDuration() const {
return burstDuration;
}
void QoSCube::setBurstDuration(int burstDuration) {
this->burstDuration = burstDuration;
}
int QoSCube::getBurstPeriod() const {
return burstPeriod;
}
void QoSCube::setBurstPeriod(int burstPeriod) {
this->burstPeriod = burstPeriod;
}
int QoSCube::getDelay() const {
return delay;
}
void QoSCube::setDelay(int delay) {
this->delay = delay;
}
bool QoSCube::isForceOrder() const {
return forceOrder;
}
void QoSCube::setForceOrder(bool forceOrder) {
this->forceOrder = forceOrder;
}
bool QoSCube::isIncompleteDelivery() const {
return incompleteDeliv;
}
void QoSCube::setIncompleteDelivery(bool incompleteDeliv) {
this->incompleteDeliv = incompleteDeliv;
}
int QoSCube::getJitter() const {
return jitter;
}
void QoSCube::setJitter(int jitter) {
this->jitter = jitter;
}
int QoSCube::getMaxAllowGap() const {
return maxAllowGap;
}
void QoSCube::setMaxAllowGap(int maxAllowGap) {
this->maxAllowGap = maxAllowGap;
}
int QoSCube::getMaxSduSize() const {
return maxSDUsize;
}
void QoSCube::setMaxSduSize(int maxSdUsize) {
maxSDUsize = maxSdUsize;
}
bool QoSCube::isPartialDelivery() const {
return partDeliv;
}
void QoSCube::setPartialDelivery(bool partDeliv) {
this->partDeliv = partDeliv;
}
int QoSCube::getPeakBandDuration() const {
return peakBandDuration;
}
void QoSCube::setPeakBandDuration(int peakBandDuration) {
this->peakBandDuration = peakBandDuration;
}
int QoSCube::getPeakSduBandDuration() const {
return peakSDUBandDuration;
}
void QoSCube::setPeakSduBandDuration(int peakSduBandDuration) {
peakSDUBandDuration = peakSduBandDuration;
}
double QoSCube::getUndetectedBitErr() const {
return undetectedBitErr;
}
void QoSCube::setUndetectedBitErr(double undetectedBitErr) {
this->undetectedBitErr = undetectedBitErr;
}
QoSCube::~QoSCube() {
qoSId = VAL_DEFQOS;
avgBand = VAL_DEFQOS;
avgSDUBand = VAL_DEFQOS; //Average SDU bandwidth (measured in SDUs/sec)
peakBandDuration = VAL_DEFQOS; //Peak bandwidth-duration (measured in bits/sec);
peakSDUBandDuration = VAL_DEFQOS; //Peak SDU bandwidth-duration (measured in SDUs/sec);
burstPeriod = VAL_DEFQOS; //Burst period measured in useconds
burstDuration = VAL_DEFQOS; //Burst duration, measured in useconds fraction of Burst Period
undetectedBitErr = VAL_DEFQOS; //Undetected bit error rate measured as a probability
maxSDUsize = VAL_DEFQOS; //MaxSDUSize measured in bytes
partDeliv = false; //Partial Delivery - Can SDUs be delivered in pieces rather than all at once?
incompleteDeliv = false; //Incomplete Delivery - Can SDUs with missing pieces be delivered?
forceOrder = false; //Must SDUs be delivered in-order bits
maxAllowGap = VAL_DEFQOS; //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.")
delay = VAL_DEFQOS; //Delay in usecs
jitter = VAL_DEFQOS; //Jitter in usecs
costTime = VAL_DEFQOS; //measured in $/ms
costBits = VAL_DEFQOS; //measured in $/Mb
}
unsigned short QoSCube::getQosId() const {
return qoSId;
}
double QoSCube::getCostBits() const {
return costBits;
}
void QoSCube::setCostBits(double costBits) {
this->costBits = costBits;
}
double QoSCube::getCostTime() const {
return costTime;
}
void QoSCube::setCostTime(double costTime) {
this->costTime = costTime;
}
double QoSCube::getATime() const {
return aTime;
}
void QoSCube::setATime(double aTime) {
this->aTime = aTime;
}
void QoSCube::setQosId(unsigned short qoSId) {
this->qoSId = qoSId;
}
std::ostream& operator <<(std::ostream& os, const QoSCube& cube) {
return os << cube.info();
}
short QoSCube::countFeasibilityScore(const QoSCube other) const {
short score = 0;
/*
EV << "AvgBw> \t" << getAvgBand() << " / " << templ.getAvgBand() << endl;
EV << "AvgSduBw> \t" << getAvgSduBand() << " / " << templ.getAvgSduBand() << endl;
EV << "PeakAvgBw> \t" << getPeakBandDuration() << " / " << templ.getPeakBandDuration() << endl;
EV << "PeakAvgSduBw> \t" << getPeakSduBandDuration() << " / " << templ.getPeakSduBandDuration() << endl;
EV << "BurstPeriod> \t" << getBurstPeriod() << " / " << templ.getBurstPeriod() << endl;
EV << "BurstDuration> \t" << getBurstDuration() << " / " << templ.getBurstDuration() << endl;
EV << "UndetecBitErr> \t" << getUndetectedBitErr() << " / " << templ.getUndetectedBitErr() << endl;
EV << "MaxSduSize> \t" << getMaxSduSize() << " / " << templ.getMaxSduSize() << endl;
EV << "PartiDeliv> \t" << isPartialDelivery() << " / " << templ.isPartialDelivery() << endl;
EV << "IncomDeliv> \t" << isIncompleteDelivery() << " / " << templ.isIncompleteDelivery() << endl;
EV << "ForceOrder> \t" << isForceOrder() << " / " << templ.isForceOrder() << endl;
EV << "MaxAllowGap> \t" << getMaxAllowGap() << " / " << templ.getMaxAllowGap() << endl;
EV << "Delay> \t" << getDelay() << " / " << templ.getDelay() << endl;
EV << "Jitter> \t" << getJitter() << " / " << templ.getJitter() << endl;
EV << "CostTime> \t" << getCostTime() << " / " << templ.getCostTime() << endl;
EV << "CostBits> \t" << getCostBits() << " / " << templ.getCostBits() << endl;
*/
if (getAvgBand() != VAL_QOSPARDONOTCARE)
(getAvgBand() <= other.getAvgBand()) ? score++ : score--;
if (getAvgSduBand() != VAL_QOSPARDONOTCARE)
(getAvgSduBand() <= other.getAvgSduBand()) ? score++ : score--;
if (getPeakBandDuration() != VAL_QOSPARDONOTCARE)
(getPeakBandDuration() <= other.getPeakBandDuration()) ? score++ : score--;
if (getPeakSduBandDuration() != VAL_QOSPARDONOTCARE)
(getPeakSduBandDuration() <= other.getPeakSduBandDuration()) ? score++ : score--;
if (getBurstPeriod() != VAL_QOSPARDONOTCARE)
(getBurstPeriod() <= other.getBurstPeriod()) ? score++ : score--;
if (getBurstDuration() != VAL_QOSPARDONOTCARE)
(getBurstDuration() <= other.getBurstDuration()) ? score++ : score--;
if (getUndetectedBitErr() != VAL_QOSPARDONOTCARE)
(getUndetectedBitErr() <= other.getUndetectedBitErr()) ? score++ : score--;
if (getMaxSduSize() != VAL_QOSPARDONOTCARE)
(getMaxSduSize() <= other.getMaxSduSize()) ? score++ : score--;
(isPartialDelivery() == other.isPartialDelivery()) ? score++ : score--;
(isIncompleteDelivery() == other.isIncompleteDelivery()) ? score++ : score--;
(isForceOrder() == other.isForceOrder()) ? score++ : score--;
if (getMaxAllowGap() != VAL_QOSPARDONOTCARE)
(getMaxAllowGap() <= other.getMaxAllowGap()) ? score++ : score--;
if (getDelay() != VAL_QOSPARDONOTCARE)
(getDelay() <= other.getDelay()) ? score++ : score--;
if (getJitter() != VAL_QOSPARDONOTCARE)
(getJitter() <= other.getJitter()) ? score++ : score--;
if (getCostTime() != VAL_QOSPARDONOTCARE)
(getCostTime() <= other.getCostTime()) ? score++ : score--;
if (getCostBits() != VAL_QOSPARDONOTCARE)
(getCostBits() <= other.getCostBits()) ? score++ : score--;
if (getATime() != VAL_QOSPARDONOTCARE)
(getATime() <= other.getATime()) ? score++ : score--;
return score;
}
bool QoSCube::isDTCPNeeded()const {
return isPartialDelivery() || isForceOrder() || isIncompleteDelivery() || avgBand >= 0;
}
std::string QoSCube::info() const {
std::ostringstream os;
if (this->getQosId())
os << "QoSCube Id> " << this->getQosId();
else
os << "QoS Parameters List>";
os << "\n average BW = ";
if ( this->getAvgBand() < 0)
os << STR_DONOTCARE;
else
os << this->getAvgBand() << " bit/s";
os << "\n average SDU BW = ";
if (this->getAvgSduBand() < 0)
os << STR_DONOTCARE;
else
os << this->getAvgSduBand() << " SDU/s";
os << "\n peak BW duration = ";
if (this->getPeakBandDuration() < 0)
os << STR_DONOTCARE;
else
os << this->getPeakBandDuration() << " bit/s";
os << "\n peak SDU BW duration = ";
if ( this->getPeakSduBandDuration() < 0)
os << STR_DONOTCARE;
else
os << this->getPeakSduBandDuration() << " SDU/s";
os << "\n burst period = ";
if ( this->getBurstPeriod() < 0 )
os << STR_DONOTCARE;
else
os << this->getBurstPeriod() << " usecs";
os << "\n burst duration = ";
if ( this->getBurstDuration() < 0 )
os << STR_DONOTCARE;
else
os << this->getBurstDuration() << " usecs";
os << "\n undetect. bit errors = ";
if ( this->getUndetectedBitErr() < 0 )
os << STR_DONOTCARE;
else
os << this->getUndetectedBitErr() << "%";
os << "\n max SDU Size = ";
if ( this->getMaxSduSize() < 0 )
os << STR_DONOTCARE;
else
os << this->getMaxSduSize() << " B";
os << "\n partial delivery = " << (this->isPartialDelivery() ? STR_YES : STR_NO );
os << "\n incomplete delivery = " << (this->isIncompleteDelivery() ? STR_YES : STR_NO );
os << "\n force order = " << (this->isForceOrder() ? STR_YES : STR_NO );
os << "\n max allowed gap = ";
if ( this->getMaxAllowGap() < 0 )
os << STR_DONOTCARE;
else
os << this->getMaxAllowGap() << " SDUs";
os << "\n delay = ";
if ( this->getDelay() < 0 )
os << STR_DONOTCARE;
else
os << this->getDelay() << " usecs";
os << "\n jitter = ";
if ( this->getJitter() < 0 )
os << STR_DONOTCARE;
else
os << this->getJitter() << " usecs";
os << "\n cost-time = ";
if ( this->getCostTime() < 0 )
os << STR_DONOTCARE;
else
os << this->getCostTime() << " $/ms";
os << "\n cost-bits = ";
if ( this->getCostBits() < 0 )
os << STR_DONOTCARE;
else
os << this->getCostBits() << " $/Mb";
os << "\n A-Time = ";
if ( this->getATime() < 0 )
os << STR_DONOTCARE;
else
os << this->getATime() << "ms";
return os.str();
}