DESERT 4.0.0
uwmulti-stack-controller.h
Go to the documentation of this file.
1//
2// Copyright (c) 2014 Regents of the SIGNET lab, University of Padova.
3// All rights reserved.
4//
5// Redistribution and use in source and binary forms, with or without
6// modification, are permitted provided that the following conditions
7// are met:
8// 1. Redistributions of source code must retain the above copyright
9// notice, this list of conditions and the following disclaimer.
10// 2. Redistributions in binary form must reproduce the above copyright
11// notice, this list of conditions and the following disclaimer in the
12// documentation and/or other materials provided with the distribution.
13// 3. Neither the name of the University of Padova (SIGNET lab) nor the
14// names of its contributors may be used to endorse or promote products
15// derived from this software without specific prior written permission.
16//
17// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
19// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
20// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
21// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
22// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
23// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
24// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
25// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
26// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
27// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
38#ifndef UWMULTI_STACK_CONTROLLER_H
39#define UWMULTI_STACK_CONTROLLER_H
40
41#include <map>
42#include <module.h>
43#include <packet.h>
44#include <rng.h>
45#include <tclcl.h>
46
47#include "controller-clmsg.h"
48#include <climits>
49#include <cmath>
50#include <iostream>
51#include <string.h>
52
53typedef std::map<int, double>
55typedef std::map<int, ThresMap> ThresMatrix;
60class UwMultiStackController : public Module
61{
62
63public:
64 // constant definitions
65 static int const layer_not_exist;
72
77 {
78 }
79
90 virtual int command(int, const char *const *);
91
98 virtual void addLayer(int id, int order);
99
108 virtual void addThreshold(int i, int j, double thres_ij);
109
115 virtual void recv(Packet *p);
116
124 int inline getOrder(int layer_id)
125 {
126 return id2order.find(layer_id) == id2order.end()
128 : id2order.find(layer_id)->second;
129 }
130
139 int inline getId(int layer_order)
140 {
141 return order2id.find(layer_order) == order2id.end()
143 : order2id.find(layer_order)->second;
144 }
145
146protected:
147 // Variables
153
154 int debug_;
159 std::map<int, int> id2order;
163 std::map<int, int>
174 virtual void recvFromUpperLayers(Packet *p);
175
186 virtual inline int
187 getBestLayer(Packet *p)
188 {
190 return lower_id_active_;
191 }
192
200 virtual bool isLayerAvailable(int id);
201
212 virtual double getMetricFromSelectedLowerLayer(int id, Packet *p);
213
224 virtual bool getThreshold(int i, int j, double &thres_ij);
225
234 virtual void eraseThreshold(int i, int j);
235
243 void inline setThreshold(int i, int j, double thres_ij)
244 {
245 threshold_map[i][j] = thres_ij;
246 }
247
248private:
249 // Variables
250};
251
252#endif /* UWMULTI_STACK_CONTROLLER_H */
Definition uwmulti-stack-controller.h:61
virtual void addThreshold(int i, int j, double thres_ij)
Definition uwmulti-stack-controller.cc:130
int debug_
Definition uwmulti-stack-controller.h:154
int signaling_pktSize_
Definition uwmulti-stack-controller.h:166
int getOrder(int layer_id)
Definition uwmulti-stack-controller.h:124
virtual int getBestLayer(Packet *p)
Definition uwmulti-stack-controller.h:187
virtual ~UwMultiStackController()
Definition uwmulti-stack-controller.h:76
Mode
Definition uwmulti-stack-controller.h:149
@ UW_AUTOMATIC_SWITCH
Definition uwmulti-stack-controller.h:151
@ UW_MANUAL_SWITCH
Definition uwmulti-stack-controller.h:150
std::map< int, int > order2id
Definition uwmulti-stack-controller.h:164
virtual void addLayer(int id, int order)
Definition uwmulti-stack-controller.cc:120
virtual double getMetricFromSelectedLowerLayer(int id, Packet *p)
Definition uwmulti-stack-controller.cc:169
virtual int command(int, const char *const *)
Definition uwmulti-stack-controller.cc:82
int lower_id_active_
Definition uwmulti-stack-controller.h:157
virtual void eraseThreshold(int i, int j)
Definition uwmulti-stack-controller.cc:193
virtual void recv(Packet *p)
Definition uwmulti-stack-controller.cc:138
static int const layer_not_exist
Definition uwmulti-stack-controller.h:65
virtual bool isLayerAvailable(int id)
Definition uwmulti-stack-controller.cc:163
UwMultiStackController()
Definition uwmulti-stack-controller.cc:66
virtual void recvFromUpperLayers(Packet *p)
Definition uwmulti-stack-controller.cc:150
ThresMatrix threshold_map
Definition uwmulti-stack-controller.h:161
void setThreshold(int i, int j, double thres_ij)
Definition uwmulti-stack-controller.h:243
double min_delay_
Definition uwmulti-stack-controller.h:155
virtual bool getThreshold(int i, int j, double &thres_ij)
Definition uwmulti-stack-controller.cc:177
std::map< int, int > id2order
Definition uwmulti-stack-controller.h:159
Mode switch_mode_
Definition uwmulti-stack-controller.h:156
int getId(int layer_order)
Definition uwmulti-stack-controller.h:139
std::map< int, double > ThresMap
Definition uwmulti-stack-controller.h:54
std::map< int, ThresMap > ThresMatrix
Definition uwmulti-stack-controller.h:55