DESERT 3.5.1
Loading...
Searching...
No Matches
uwmulti-stack-controller-phy-master.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
39#ifndef UWOPTICAL_ACOUSTIC_CONTROLLER_MASTER_H
40#define UWOPTICAL_ACOUSTIC_CONTROLLER_MASTER_H
41
43#include <mac.h>
44
45#include <limits>
46
48
53
54public:
55
60
65
74 virtual int command(int, const char*const*);
75
84 virtual void recv(Packet *p, int idSrc);
85
86protected:
87 // Internal classes
88 class UwMultiStackSignalingTimer : public TimerHandler {
89 public:
90
92 module = m;
93 }
94
95 protected:
96 virtual void expire(Event *e);
98 };
99
100 // Variables
105 double alpha_;
118 virtual int getBestLayer(Packet *p);
119
124 virtual void checkAndSignal();
125
130 virtual void resetCheckAndSignal();
131
136 virtual int checkBestLayer();
137
142 virtual void signalsBestPhy();
143
156 int recvSyncClMsg(ClMessage* m);
157
165 virtual void updateMasterStatistics(Packet *p, int idSrc);
166
174 inline int getShorterRangeLayer(int layer_id){ return (getId(getOrder(layer_id) + 1) == UwMultiStackController::layer_not_exist)?
175 layer_id : getId(getOrder(layer_id) + 1);
176 }
177
185 inline int getLongerRangeLayer(int layer_id){ return (getId(getOrder(layer_id) - 1) == UwMultiStackController::layer_not_exist)?
186 layer_id : getId(getOrder(layer_id) - 1);
187 }
188
189private:
190 //Variables
191};
192
193#endif /* UWOPTICAL_ACOUSTIC_CONTROLLER_H */
Class used to represents the UwMultiStackControllerPhyMaster layer of a node.
int getLongerRangeLayer(int layer_id)
Return the previous layer in order which can achieve longer range with lower bitrete.
int getShorterRangeLayer(int layer_id)
Return the next layer in order which can achieve shorter range with higer bitrete.
virtual void resetCheckAndSignal()
If signaling is active and signaling timer expires, check the average power thresholds at each packet...
double power_statistics_
ID of the last PHY layer used.
virtual int checkBestLayer()
Check the average power thresholds.
virtual int getBestLayer(Packet *p)
Return the best layer to forward the packet when the system works in AUTOMATIC_MODE.
UwMultiStackSignalingTimer signaling_timer_
Number of signaling packets sent.
double alpha_
Address of the node which the master is collecting the average power.
virtual ~UwMultiStackControllerPhyMaster()
Destructor of UwMultiPhy class.
int power_stat_node_
Average received power from the closest node according to the IIR filter.
virtual void checkAndSignal()
If signaling is active, check the average power thresholds at each packet received.
int last_layer_used_
If true master is in signaling mode, otherwise not.
virtual void signalsBestPhy()
Signals the best phy.
UwMultiStackControllerPhyMaster()
Constructor of UwMultiPhy class.
virtual int command(int, const char *const *)
TCL command interpreter.
int signaling_sent_
Period to check the best layer if no interactions occurs.
virtual void updateMasterStatistics(Packet *p, int idSrc)
It implements the slave choice rule to choose the lower layer when the system works in AUTOMATIC_MODE...
int recvSyncClMsg(ClMessage *m)
Cross-Layer messages synchronous interpreter.
virtual void recv(Packet *p, int idSrc)
It manages each packet reception, either from the upper and the lower layer.
int getOrder(int layer_id)
return the order of the id for the controller logic
static int const layer_not_exist
This constant is returned when a searched layer does not exist>
int getId(int layer_order)
return the id of the controlled layer given its order in the controller logic
Definition of UwMultiStackControllerPhy class.