RINASim  October 2016
Documentation of framework for OMNeT++
MinComparer.cc
Go to the documentation of this file.
1 // The MIT License (MIT)
2 //
3 // Copyright (c) 2014-2016 Brno University of Technology, PRISTINE project
4 //
5 // Permission is hereby granted, free of charge, to any person obtaining a copy
6 // of this software and associated documentation files (the "Software"), to deal
7 // in the Software without restriction, including without limitation the rights
8 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 // copies of the Software, and to permit persons to whom the Software is
10 // furnished to do so, subject to the following conditions:
11 //
12 // The above copyright notice and this permission notice shall be included in
13 // all copies or substantial portions of the Software.
14 //
15 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 // THE SOFTWARE.
22 
23 
24 #include <MinComparer.h>
25 
27 
28 bool MinComparer::isFeasibility(const QoSReq requirements, const QoSCube cube) const {
29 
30  // std::cout << requirements.getDelay() << "/" << requirements.getPduDropProbability() << " vs " << cube.getDelay() << "/" << cube.getPduDropProbability()<<endl;
31 
32  if (requirements.getAvgBand() != VAL_QOSPARDONOTCARE && requirements.getAvgBand() > cube.getAvgBand())
33  return false;
34 
35  if (requirements.getAvgSduBand() != VAL_QOSPARDONOTCARE && requirements.getAvgSduBand() > cube.getAvgSduBand())
36  return false;
37 
38  if (requirements.getPeakBandDuration() != VAL_QOSPARDONOTCARE && requirements.getPeakBandDuration() > cube.getPeakBandDuration())
39  return false;
40 
41  if (requirements.getPeakSduBandDuration() != VAL_QOSPARDONOTCARE && requirements.getPeakSduBandDuration() > cube.getPeakSduBandDuration())
42  return false;
43 
44  if (requirements.getBurstPeriod() != VAL_QOSPARDONOTCARE && requirements.getBurstPeriod() > cube.getBurstPeriod())
45  return false;
46 
47  if (requirements.getBurstDuration() != VAL_QOSPARDONOTCARE && requirements.getBurstDuration() > cube.getBurstDuration())
48  return false;
49 
50  if (requirements.getUndetectedBitErr() != VAL_QOSPARDONOTCARE && requirements.getUndetectedBitErr() < cube.getUndetectedBitErr())
51  return false;
52 
53  if (requirements.getPduDropProbability() != VAL_QOSPARDONOTCARE && requirements.getPduDropProbability() < cube.getPduDropProbability())
54  return false;
55 
56  if (requirements.getMaxSduSize() != VAL_QOSPARDONOTCARE && requirements.getMaxSduSize() > cube.getMaxSduSize())
57  return false;
58 
59  if(!cube.isPartialDelivery() && requirements.isPartialDelivery())
60  return false;
61 
62  if(!cube.isIncompleteDelivery() && requirements.isIncompleteDelivery())
63  return false;
64 
65  if(!cube.isForceOrder() && requirements.isForceOrder())
66  return false;
67 
68  if (requirements.getMaxAllowGap() != VAL_QOSPARDONOTCARE && requirements.getMaxAllowGap() > cube.getMaxAllowGap())
69  return false;
70 
71  if (requirements.getDelay() != VAL_QOSPARDONOTCARE && requirements.getDelay() < cube.getDelay())
72  return false;
73 
74  if (requirements.getJitter() != VAL_QOSPARDONOTCARE && requirements.getJitter() > cube.getJitter())
75  return false;
76 
77  if (requirements.getCostTime() != VAL_QOSPARDONOTCARE && requirements.getCostTime() < cube.getCostTime())
78  return false;
79 
80  if (requirements.getCostBits() != VAL_QOSPARDONOTCARE && requirements.getCostBits() < cube.getCostBits())
81  return false;
82  // std::cout << "OK" << endl;
83  return true;
84 
85 }
86 bool MinComparer::run(Flow& flow) {
87  Enter_Method("invokeNewFlowRequestPolicy()");
88  //Is flow policy acceptable
89  std::string apname = flow.getSrcApni().getApn().getName();
90 
91  //FIXME: Vesely - Simulate error and DTCP flag better
92  if ( apname.find("Err") != std::string::npos) {
93  return false;
94  }
95 
96  //Always translate management traffic to appropriate management QoSCube
97  if (flow.isManagementFlow()) {
100  return true;
101  }
102 
103  //TODO: Compare QoS Parameters with available QoS cubes
105  //EV << ResourceAllocator->getQoSCubes();
106 
107  std::string qosid = VAL_UNDEF_QOSID;
108  //XXX: Vesely->Gaixas: Please, check following cost variable value and overall functionality of this comparer
109  double cost = DBL_MAX;
110  QoSCube qs;
111 
112  for (QCubeCItem it = cubes.begin(); it != cubes.end(); ++it) {
113  if(it->getQosId() == VAL_MGMTQOSID) { continue; }
114 
115  if( isFeasibility(flow.getQosRequirements(), *it) ){
116  double tmpscore = it->getCostBits();
117  if (cost > tmpscore) {
118  cost = tmpscore;
119  qosid = it->getQosId();
120  qs = *it;
121  }
122  }
123  }
124  flow.getConnectionId().setQoSId(qosid);
125  flow.setQosCube(qs);
126  return qosid.compare(VAL_UNDEF_QOSID) ? true : false;
127 
128 }
129 
double getUndetectedBitErr() const
Gets Undetected Bit Error Rate parameter.
Definition: QoSReq.cc:325
static const QoSCube MANAGEMENT
Definition: QoSCube.h:201
Class representing flow object with attributes from specs.
Definition: Flow.h:45
const APNamingInfo & getSrcApni() const
Gets read-only source APNamingInfo.
Definition: Flow.cc:134
int getBurstPeriod() const
Gets Burst Period parameter.
Definition: QoSCube.cc:276
int getBurstDuration() const
Gets Burst Duration parameter.
Definition: QoSCube.cc:268
int getAvgBand() const
Gets Average Bandwidth parameter.
Definition: QoSCube.cc:252
ConnectionId & getConnectionId()
Gets Flow's ConnectionId.
Definition: Flow.cc:209
double getPduDropProbability() const
Gets PDU Dropping Probability parameter.
Definition: QoSCube.cc:400
int getPeakBandDuration() const
Gets Peak Band Duration parameter.
Definition: QoSCube.cc:340
int getJitter() const
Gets Jitter parameter.
Definition: QoSCube.cc:308
Define_Module(MinComparer)
double getCostBits() const
Gets Cost-bits parameter.
Definition: QoSCube.cc:368
const std::string VAL_MGMTQOSID
Definition: QoSCube.cc:37
bool isForceOrder() const
Gets in-order delivery flag.
Definition: QoSReq.cc:261
int getMaxSduSize() const
Gets Maximum SDU Size parameter.
Definition: QoSCube.cc:324
double getUndetectedBitErr() const
Gets Undetected Bit Error Rate parameter.
Definition: QoSCube.cc:356
double getPduDropProbability() const
Gets PDU Dropping Probability parameter.
Definition: QoSReq.cc:472
const QoSCubeSet & getQoSCubes() const
Definition: RABase.cc:35
const APN & getApn() const
Getter of APN.
Definition: APNamingInfo.h:142
const std::string VAL_UNDEF_QOSID
Definition: QoSCube.cc:36
int getMaxSduSize() const
Gets Maximum SDU Size parameter.
Definition: QoSReq.cc:293
const QoSReq & getQosRequirements() const
Gets QoS parameters wanted by flow initiator.
Definition: Flow.cc:176
bool isIncompleteDelivery() const
Gets incomplete delivery flag.
Definition: QoSCube.cc:300
bool isManagementFlow() const
Definition: Flow.cc:366
bool isFeasibility(const QoSReq requirements, const QoSCube cube) const
Definition: MinComparer.cc:28
const int VAL_QOSPARDONOTCARE
int getPeakSduBandDuration() const
Gets Peak SDU Duration parameter.
Definition: QoSReq.cc:317
QoSCubeSet::const_iterator QCubeCItem
Definition: RABase.h:34
std::list< QoSCube > QoSCubeSet
Definition: RABase.h:33
int getMaxAllowGap() const
Gets Maximum Allowable Gap in SDUs parameter.
Definition: QoSReq.cc:285
int getDelay() const
Gets Delay parameter.
Definition: QoSReq.cc:253
bool isPartialDelivery() const
Gets partial delivery flag.
Definition: QoSReq.cc:301
Class representing QoSCube with all its properties that is primarily used by FA, RMT and RA Specifica...
Definition: QoSCube.h:57
int getJitter() const
Gets Jitter parameter.
Definition: QoSReq.cc:277
double getCostTime() const
Gets Cost-time parameter.
Definition: QoSCube.cc:376
bool isPartialDelivery() const
Gets partial delivery flag.
Definition: QoSCube.cc:332
bool isForceOrder() const
Gets in-order delivery flag.
Definition: QoSCube.cc:292
void setQoSId(std::string qoSId)
Setter of selected QoS-cube identifier.
Definition: ConnectionId.cc:49
double getCostTime() const
Gets Cost-time parameter.
Definition: QoSReq.cc:341
Class representing QoSReq with all its properties that is primarily used by FA, RMT and RA Specificat...
Definition: QoSReq.h:44
int getPeakBandDuration() const
Gets Peak Band Duration parameter.
Definition: QoSReq.cc:309
double getCostBits() const
Gets Cost-bits parameter.
Definition: QoSReq.cc:333
int getAvgBand() const
Gets Average Bandwidth parameter.
Definition: QoSReq.cc:221
int getDelay() const
Gets Delay parameter.
Definition: QoSCube.cc:284
const std::string & getName() const
Gets APN string name representation.
Definition: APN.cc:40
int getBurstDuration() const
Gets Burst Duration parameter.
Definition: QoSReq.cc:237
int getPeakSduBandDuration() const
Gets Peak SDU Duration parameter.
Definition: QoSCube.cc:348
void setQosCube(const QoSCube &qosCube)
Definition: Flow.cc:167
int getAvgSduBand() const
Gets Average SDU Bandwidth parameter.
Definition: QoSCube.cc:260
int getAvgSduBand() const
Gets Average SDU Bandwidth parameter.
Definition: QoSReq.cc:229
int getBurstPeriod() const
Gets Burst Period parameter.
Definition: QoSReq.cc:245
virtual bool run(Flow &flow)
Definition: MinComparer.cc:86
int getMaxAllowGap() const
Gets Maximum Allowable Gap in SDUs parameter.
Definition: QoSCube.cc:316
bool isIncompleteDelivery() const
Gets incomplete delivery flag.
Definition: QoSReq.cc:269