DESERT 3.5.1
Loading...
Searching...
No Matches
uwmulti-traffic-range-crt.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_TRAFFIC_CONTROL_H
39#define UWMULTI_TRAFFIC_CONTROL_H
40
42#include <uwip-module.h>
43#include <set>
44
45
46extern packet_t PT_MULTI_TR_PROBE;
47extern packet_t PT_MULTI_TR_PROBE_ACK;
48#define HDR_UWMTR(P) (hdr_uwm_tr::access(P))
49// DEFINE BEHAVIORS
54
55// DEFINE STATES
60
62 std::set <int> module_ids;
63 int status;
65};
66typedef std::map <int, check_status> StatusMap;
68typedef std::map <int, uint> CounterMap;
70typedef struct hdr_uwm_tr {
71 int tr_id_;
72 static int offset_;
77 inline static int& offset() {
78 return offset_;
79 }
80
81 inline static hdr_uwm_tr * access(const Packet * p) {
82 return (hdr_uwm_tr*) p->access(offset_);
83 }
84
88 int& traffic() {
89 return tr_id_;
90 }
91
93
94
99
100
101public:
102
107
112
122 virtual int command(int, const char*const*);
123
129 virtual void recv(Packet* p, int idSrc);
130
137 virtual void sendDown(Packet* p, double delay=0) { if(p != NULL ) { Module::sendDown(p, delay); } }
138
146 virtual void sendDown(int moduleId, Packet* p, double delay=0) { if(p != NULL ) { Module::sendDown(moduleId, p, delay); } }
147
148protected:
162 virtual void manageBuffer(int traffic);
163
171 virtual int getBestLowerLayer(int traffic, Packet *p = NULL);
172
178 virtual void checkRange(int traffic, int module_id, uint8_t destAdd = UWIP_BROADCAST);
179
186 virtual void manageCheckedLayer(int module_id, uint8_t destAdd, bool in_range, int idSrc = 0);
187
193 virtual void initStatus(int traffic);
194
200 virtual void timerExpired(int traffic);
201
207 void incrSignalingCounter(int traffic, CounterMap& map_cnt);
208
216 uint getSignalingCounter(int traffic, const CounterMap& map_cnt) const;
217
218private:
222 class UwCheckRangeTimer : public TimerHandler {
223 public:
224
226 TimerHandler(),
227 traffic(traff),
228 num_expires(0),
229 max_increment(10)
230 {
231 module = m;
232 }
236 int const max_increment;
238 protected:
243 virtual void expire(Event *e);
244 UwMultiTrafficRangeCtr* module;
246 };
247 //Variables
248 std::map <int, UwCheckRangeTimer*> timers;
249};
250
251#endif /* UWMULTI_TRAFFIC_CONTROL_H */
Class used to represents the UwMultiTrafficControl layer of a node.
int const max_increment
max increment of the timeout
virtual void expire(Event *e)
Timer expire procedure: handles the PROBE timeout.
UwCheckRangeTimer(UwMultiTrafficRangeCtr *m, int traff)
Class used to represents the UwMultiTrafficRangeCtr layer of a node.
virtual void manageCheckedLayer(int module_id, uint8_t destAdd, bool in_range, int idSrc=0)
procedure when a CHECKED stack is checked
virtual void manageBuffer(int traffic)
manage to tx a packet of traffic type
CounterMap rx_probe_ack_cnt
Number of probe ACK pkts recv for each traffic.
StatusMap status
Map of status per traffic types.
virtual void recv(Packet *p, int idSrc)
Handle a packet coming from upper layers.
CounterMap tx_probe_cnt
Number of probe pkts sent for each traffic.
void incrSignalingCounter(int traffic, CounterMap &map_cnt)
Incement number of signaling pkts sent for the given traffic.
virtual int command(int, const char *const *)
TCL command interpreter.
virtual void initStatus(int traffic)
default status initialization
CounterMap tx_probe_ack_cnt
Number of probe ACK pkts sent for each traffic.
int signaling_pktSize
Signaling packet size.
double check_to_period
Time-Out period.
uint getSignalingCounter(int traffic, const CounterMap &map_cnt) const
Return the number of signaling pkts sent for the given traffic.
UwMultiTrafficRangeCtr()
Constructor of UwMultiPhy class.
std::map< int, UwCheckRangeTimer * > timers
Map of timer per traffic types.
virtual void checkRange(int traffic, int module_id, uint8_t destAdd=UWIP_BROADCAST)
procedure to check if a
virtual void sendDown(Packet *p, double delay=0)
Send a packet to the module(s) of the bottom layers.
virtual void timerExpired(int traffic)
handle when a a timer expires
CounterMap rx_probe_cnt
Number of probe pkts recv for each traffic.
virtual int getBestLowerLayer(int traffic, Packet *p=NULL)
return the Best Lower Layer id where to forward the packet of traffic type
virtual void sendDown(int moduleId, Packet *p, double delay=0)
Send a packet to the requested module of the bottom layer.
virtual ~UwMultiTrafficRangeCtr()
Destructor of UwMultiPhy class.
std::set< int > module_ids
traffic, counter
int tr_id_
Id of the traffic app layer.
static int offset_
Required by the PacketHeaderManager.
int & traffic()
Reference to the traffic ID.
static int & offset()
Reference to the offset_ variable.
static hdr_uwm_tr * access(const Packet *p)
Provides the UWIP packets header description. Definition of the class that define the network layer.
static const uint8_t UWIP_BROADCAST
Variable used to represent a broadcast UWIP.
Definition uwip-module.h:62
std::map< int, uint > CounterMap
traffic, status
std::map< int, check_status > StatusMap