|
a |
|
b/src/policies/DIF/FA/NewFlowRequest/QoSCubeComparer/QoSCubeComparer.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 <QoSCubeComparer.h>
|
|
|
17 |
|
|
|
18 |
Define_Module(QoSCubeComparer);
|
|
|
19 |
|
|
|
20 |
bool QoSCubeComparer::run(Flow& flow) {
|
|
|
21 |
Enter_Method("invokeNewFlowRequestPolicy()");
|
|
|
22 |
//Is flow policy acceptable
|
|
|
23 |
std::string apname = flow.getSrcApni().getApn().getName();
|
|
|
24 |
|
|
|
25 |
//FIXME: Vesely - Simulate error and DTCP flag better
|
|
|
26 |
if ( apname.find("Err") != std::string::npos) {
|
|
|
27 |
return false;
|
|
|
28 |
}
|
|
|
29 |
|
|
|
30 |
//TODO: Compare QoS Parameters with available QoS cubes
|
|
|
31 |
QoSCubeSet cubes = ResourceAllocator->getQoSCubes();
|
|
|
32 |
//EV << ResourceAllocator->getQoSCubes();
|
|
|
33 |
|
|
|
34 |
unsigned short qosid = 0;
|
|
|
35 |
short score = 0;
|
|
|
36 |
|
|
|
37 |
for (QCubeCItem it = cubes.begin(); it != cubes.end(); ++it) {
|
|
|
38 |
short tmpscore = flow.getQosParameters().countFeasibilityScore(*it);
|
|
|
39 |
// EV << "QosID: " << it->getQosId()
|
|
|
40 |
// << " tmpscore: " << tmpscore
|
|
|
41 |
// << " score: " << score << endl
|
|
|
42 |
// << " qosid: " << qosid << endl;
|
|
|
43 |
if (score < tmpscore) {
|
|
|
44 |
score = tmpscore;
|
|
|
45 |
qosid = it->getQosId();
|
|
|
46 |
}
|
|
|
47 |
}
|
|
|
48 |
flow.getConnectionId().setQoSId(qosid);
|
|
|
49 |
return qosid ? true : false;
|
|
|
50 |
|
|
|
51 |
}
|
|
|
52 |
|