|
a |
|
b/src/DAF/AE/AEBase.cc |
|
|
1 |
|
|
|
2 |
// This program is free software: you can redistribute it and/or modify
|
|
|
3 |
// it under the terms of the GNU Lesser General Public License as published by
|
|
|
4 |
// the Free Software Foundation, either version 3 of the License, or
|
|
|
5 |
// (at your option) any later version.
|
|
|
6 |
//
|
|
|
7 |
// This program is distributed in the hope that it will be useful,
|
|
|
8 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
9 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
10 |
// GNU Lesser General Public License for more details.
|
|
|
11 |
//
|
|
|
12 |
// You should have received a copy of the GNU Lesser General Public License
|
|
|
13 |
// along with this program. If not, see http://www.gnu.org/licenses/.
|
|
|
14 |
//
|
|
|
15 |
|
|
|
16 |
#include "AEBase.h"
|
|
|
17 |
|
|
|
18 |
Define_Module(AEBase);
|
|
|
19 |
|
|
|
20 |
const char* PAR_AVGBW = "averageBandwidth";
|
|
|
21 |
const char* PAR_AVGSDUBW = "averageSDUBandwidth";
|
|
|
22 |
const char* PAR_PEAKBWDUR = "peakBandwidthDuration";
|
|
|
23 |
const char* PAR_PEAKSDUBWDUR = "peakSDUBandwidthDuration";
|
|
|
24 |
const char* PAR_BURSTPERIOD = "burstPeriod";
|
|
|
25 |
const char* PAR_BURSTDURATION = "burstDuration";
|
|
|
26 |
const char* PAR_UNDETECTBITERR = "undetectedBitErr";
|
|
|
27 |
const char* PAR_MAXSDUSIZE = "maxSDUsize";
|
|
|
28 |
const char* PAR_PARTIALDELIVER = "partialDelivery";
|
|
|
29 |
const char* PAR_INCOMPLETEDELIVER = "incompleteDelivery";
|
|
|
30 |
const char* PAR_FORCEORDER = "forceOrder";
|
|
|
31 |
const char* PAR_MAXALLOWGAP = "maxAllowGap";
|
|
|
32 |
const char* PAR_DELAY = "delay";
|
|
|
33 |
const char* PAR_JITTER = "jitter";
|
|
|
34 |
const char* PAR_COSTTIME = "costTime";
|
|
|
35 |
const char* PAR_COSTBITS = "costBits";
|
|
|
36 |
|
|
|
37 |
const APNamingInfo& AEBase::getApni() const {
|
|
|
38 |
return apni;
|
|
|
39 |
}
|
|
|
40 |
|
|
|
41 |
void AEBase::setApni(const APNamingInfo& apni) {
|
|
|
42 |
this->apni = apni;
|
|
|
43 |
}
|
|
|
44 |
|
|
|
45 |
const Flows& AEBase::getFlows() const {
|
|
|
46 |
return flows;
|
|
|
47 |
}
|
|
|
48 |
|
|
|
49 |
void AEBase::setFlows(const Flows& flows) {
|
|
|
50 |
this->flows = flows;
|
|
|
51 |
}
|
|
|
52 |
|
|
|
53 |
const std::string& AEBase::getSrcAeInstance() const {
|
|
|
54 |
return srcAeInstance;
|
|
|
55 |
}
|
|
|
56 |
|
|
|
57 |
void AEBase::setSrcAeInstance(const std::string& srcAeInstance) {
|
|
|
58 |
this->srcAeInstance = srcAeInstance;
|
|
|
59 |
}
|
|
|
60 |
|
|
|
61 |
const std::string& AEBase::getSrcAeName() const {
|
|
|
62 |
return srcAeName;
|
|
|
63 |
}
|
|
|
64 |
|
|
|
65 |
void AEBase::setSrcAeName(const std::string& srcAeName) {
|
|
|
66 |
this->srcAeName = srcAeName;
|
|
|
67 |
}
|
|
|
68 |
|
|
|
69 |
const std::string& AEBase::getSrcApInstance() const {
|
|
|
70 |
return srcApInstance;
|
|
|
71 |
}
|
|
|
72 |
|
|
|
73 |
void AEBase::setSrcApInstance(const std::string& srcApInstance) {
|
|
|
74 |
this->srcApInstance = srcApInstance;
|
|
|
75 |
}
|
|
|
76 |
|
|
|
77 |
const std::string& AEBase::getSrcApName() const {
|
|
|
78 |
return srcApName;
|
|
|
79 |
}
|
|
|
80 |
|
|
|
81 |
void AEBase::setSrcApName(const std::string& srcApName) {
|
|
|
82 |
this->srcApName = srcApName;
|
|
|
83 |
}
|
|
|
84 |
|
|
|
85 |
void AEBase::initNamingInfo() {
|
|
|
86 |
//Source info
|
|
|
87 |
srcApName = this->getParentModule()->par(PAR_APNAME).stdstringValue();
|
|
|
88 |
srcApInstance = this->getParentModule()->par(PAR_APINSTANCE).stdstringValue();
|
|
|
89 |
srcAeName = this->par(PAR_AENAME).stdstringValue();
|
|
|
90 |
srcAeInstance = this->par(PAR_AEINSTANCE).stdstringValue();
|
|
|
91 |
|
|
|
92 |
apni = APNamingInfo(APN(this->srcApName), this->srcApInstance,
|
|
|
93 |
this->srcAeName, this->srcAeInstance);
|
|
|
94 |
}
|
|
|
95 |
|
|
|
96 |
void AEBase::initialize()
|
|
|
97 |
{
|
|
|
98 |
initNamingInfo();
|
|
|
99 |
initQoSRequiremets();
|
|
|
100 |
}
|
|
|
101 |
|
|
|
102 |
const QosCube& AEBase::getQoSRequirements() const {
|
|
|
103 |
return QoSRequirements;
|
|
|
104 |
}
|
|
|
105 |
|
|
|
106 |
void AEBase::setQoSRequirements(const QosCube& qoSRequirements) {
|
|
|
107 |
QoSRequirements = qoSRequirements;
|
|
|
108 |
}
|
|
|
109 |
|
|
|
110 |
void AEBase::initQoSRequiremets() {
|
|
|
111 |
//Check whether module has all QoS parameters
|
|
|
112 |
if (! (hasPar(PAR_AVGBW) &&
|
|
|
113 |
hasPar(PAR_AVGSDUBW) &&
|
|
|
114 |
hasPar(PAR_PEAKBWDUR) &&
|
|
|
115 |
hasPar(PAR_PEAKSDUBWDUR) &&
|
|
|
116 |
hasPar(PAR_BURSTPERIOD) &&
|
|
|
117 |
hasPar(PAR_BURSTDURATION) &&
|
|
|
118 |
hasPar(PAR_UNDETECTBITERR) &&
|
|
|
119 |
hasPar(PAR_MAXSDUSIZE) &&
|
|
|
120 |
hasPar(PAR_PARTIALDELIVER) &&
|
|
|
121 |
hasPar(PAR_INCOMPLETEDELIVER) &&
|
|
|
122 |
hasPar(PAR_FORCEORDER) &&
|
|
|
123 |
hasPar(PAR_MAXALLOWGAP) &&
|
|
|
124 |
hasPar(PAR_DELAY) &&
|
|
|
125 |
hasPar(PAR_JITTER) &&
|
|
|
126 |
hasPar(PAR_COSTTIME) &&
|
|
|
127 |
hasPar(PAR_COSTBITS)
|
|
|
128 |
)
|
|
|
129 |
) {
|
|
|
130 |
std::stringstream ss;
|
|
|
131 |
ss << "Module " << this->getFullName() << " is not derived from AEBase. It misses some important QoS parameters!";
|
|
|
132 |
error(ss.str().c_str());
|
|
|
133 |
}
|
|
|
134 |
|
|
|
135 |
//Create QoS cube according to parameters
|
|
|
136 |
QosCube cube;
|
|
|
137 |
|
|
|
138 |
int avgBand = VAL_QOSPARAMDONOTCARE; //Average bandwidth (measured at the application in bits/sec)
|
|
|
139 |
int avgSDUBand = VAL_QOSPARAMDONOTCARE; //Average SDU bandwidth (measured in SDUs/sec)
|
|
|
140 |
int peakBandDuration = VAL_QOSPARAMDONOTCARE; //Peak bandwidth-duration (measured in bits/sec);
|
|
|
141 |
int peakSDUBandDuration = VAL_QOSPARAMDONOTCARE; //Peak SDU bandwidth-duration (measured in SDUs/sec);
|
|
|
142 |
int burstPeriod = VAL_QOSPARAMDONOTCARE; //Burst period measured in useconds
|
|
|
143 |
int burstDuration = VAL_QOSPARAMDONOTCARE; //Burst duration, measured in usecs fraction of Burst Period
|
|
|
144 |
int undetectedBitErr = VAL_QOSPARAMDONOTCARE; //Undetected bit error rate measured as a probability
|
|
|
145 |
int maxSDUsize = VAL_QOSPARAMDONOTCARE; //MaxSDUSize measured in bytes
|
|
|
146 |
bool partDeliv = VAL_QOSPARAMDEFBOOL; //Partial Delivery - Can SDUs be delivered in pieces rather than all at once?
|
|
|
147 |
bool incompleteDeliv = VAL_QOSPARAMDEFBOOL; //Incomplete Delivery - Can SDUs with missing pieces be delivered?
|
|
|
148 |
bool forceOrder = VAL_QOSPARAMDEFBOOL; //Must SDUs be delivered in order?
|
|
|
149 |
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.")
|
|
|
150 |
int delay = VAL_QOSPARAMDONOTCARE; //Delay in usecs
|
|
|
151 |
int jitter = VAL_QOSPARAMDONOTCARE; //Jitter in usecs2
|
|
|
152 |
int costtime = VAL_QOSPARAMDONOTCARE; //measured in $/ms
|
|
|
153 |
int costbits = VAL_QOSPARAMDONOTCARE; //measured in $/Mb
|
|
|
154 |
|
|
|
155 |
avgBand = par(PAR_AVGBW);
|
|
|
156 |
if (avgBand < 0)
|
|
|
157 |
avgBand = VAL_QOSPARAMDONOTCARE;
|
|
|
158 |
avgSDUBand = par(PAR_AVGSDUBW);
|
|
|
159 |
if (avgSDUBand < 0)
|
|
|
160 |
avgSDUBand = VAL_QOSPARAMDONOTCARE;
|
|
|
161 |
peakBandDuration = par(PAR_PEAKBWDUR);
|
|
|
162 |
if (peakBandDuration < 0)
|
|
|
163 |
peakBandDuration = VAL_QOSPARAMDONOTCARE;
|
|
|
164 |
peakSDUBandDuration = par(PAR_PEAKSDUBWDUR);
|
|
|
165 |
if (peakSDUBandDuration < 0)
|
|
|
166 |
peakSDUBandDuration = VAL_QOSPARAMDONOTCARE;
|
|
|
167 |
burstPeriod = par(PAR_BURSTPERIOD);
|
|
|
168 |
if (burstPeriod < 0)
|
|
|
169 |
burstPeriod = VAL_QOSPARAMDONOTCARE;
|
|
|
170 |
burstDuration = par(PAR_BURSTDURATION);
|
|
|
171 |
if (burstDuration < 0)
|
|
|
172 |
burstDuration = VAL_QOSPARAMDONOTCARE;
|
|
|
173 |
undetectedBitErr = par(PAR_UNDETECTBITERR);
|
|
|
174 |
if (undetectedBitErr < 0 || undetectedBitErr > 1 )
|
|
|
175 |
undetectedBitErr = VAL_QOSPARAMDONOTCARE;
|
|
|
176 |
maxSDUsize = par(PAR_MAXSDUSIZE);
|
|
|
177 |
if (maxSDUsize < 0)
|
|
|
178 |
maxSDUsize = VAL_QOSPARAMDONOTCARE;
|
|
|
179 |
partDeliv = par(PAR_PARTIALDELIVER);
|
|
|
180 |
incompleteDeliv = par(PAR_INCOMPLETEDELIVER);
|
|
|
181 |
forceOrder = par(PAR_FORCEORDER);
|
|
|
182 |
maxAllowGap = par(PAR_MAXALLOWGAP);
|
|
|
183 |
if (maxAllowGap < 0)
|
|
|
184 |
maxAllowGap = VAL_QOSPARAMDONOTCARE;
|
|
|
185 |
delay = par(PAR_DELAY);
|
|
|
186 |
if (delay < 0)
|
|
|
187 |
delay = VAL_QOSPARAMDONOTCARE;
|
|
|
188 |
jitter = par(PAR_JITTER);
|
|
|
189 |
if (jitter < 0)
|
|
|
190 |
jitter = VAL_QOSPARAMDONOTCARE;
|
|
|
191 |
costtime = par(PAR_COSTTIME);
|
|
|
192 |
if (costtime < 0)
|
|
|
193 |
costtime = VAL_QOSPARAMDONOTCARE;
|
|
|
194 |
costbits = par(PAR_COSTBITS);
|
|
|
195 |
if (costbits < 0)
|
|
|
196 |
costbits = VAL_QOSPARAMDONOTCARE;
|
|
|
197 |
|
|
|
198 |
cube.setQosId(0);
|
|
|
199 |
cube.setAvgBand(avgBand);
|
|
|
200 |
cube.setAvgSduBand(avgSDUBand);
|
|
|
201 |
cube.setPeakBandDuration(peakBandDuration);
|
|
|
202 |
cube.setPeakSduBandDuration(peakSDUBandDuration);
|
|
|
203 |
cube.setBurstPeriod(burstPeriod);
|
|
|
204 |
cube.setBurstDuration(burstDuration);
|
|
|
205 |
cube.setUndetectedBitErr(undetectedBitErr);
|
|
|
206 |
cube.setMaxSduSize(maxSDUsize);
|
|
|
207 |
cube.setPartialDelivery(partDeliv);
|
|
|
208 |
cube.setIncompleteDelivery(incompleteDeliv);
|
|
|
209 |
cube.setForceOrder(forceOrder);
|
|
|
210 |
cube.setMaxAllowGap(maxAllowGap);
|
|
|
211 |
cube.setDelay(delay);
|
|
|
212 |
cube.setJitter(jitter);
|
|
|
213 |
cube.setCostBits(costbits);
|
|
|
214 |
cube.setCostTime(costtime);
|
|
|
215 |
|
|
|
216 |
this->setQoSRequirements(cube);
|
|
|
217 |
|
|
|
218 |
//EV << "QQQQQQ\n" << cube << "\n\nXXXX\n" << this->getQoSRequirements();
|
|
|
219 |
|
|
|
220 |
}
|
|
|
221 |
|
|
|
222 |
void AEBase::handleMessage(cMessage *msg)
|
|
|
223 |
{
|
|
|
224 |
// TODO - Generated method body
|
|
|
225 |
}
|
|
|
226 |
|
|
|
227 |
void AEBase::insertFlow(Flow& flow) {
|
|
|
228 |
flows.push_back(flow);
|
|
|
229 |
}
|
|
|
230 |
|
|
|
231 |
bool AEBase::hasFlow(const Flow* flow) {
|
|
|
232 |
for (TFlowsIter it = flows.begin(); it != flows.end(); ++it) {
|
|
|
233 |
if (*it == *flow)
|
|
|
234 |
return true;
|
|
|
235 |
}
|
|
|
236 |
return false;
|
|
|
237 |
}
|