DESERT 3.5.1
Loading...
Searching...
No Matches
uwpolling_cmn_hdr.h
Go to the documentation of this file.
1//
2// Copyright (c) 2017 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//
29
40#ifndef UWPOLLING_CMN_HDR_H
41#define UWPOLLING_CMN_HDR_H
42
43#include <mmac.h>
44#include <module.h>
45#include <packet.h>
46
47#include <list>
48
49#define HDR_PROBE(p) \
50 (hdr_PROBE::access(p))
51#define HDR_TRIGGER(p) \
52 (hdr_TRIGGER::access(p))
54#define HDR_POLL(p) \
55 (hdr_POLL::access(p))
56#define HDR_AUV_MULE(p) \
57 (hdr_AUV_MULE::access(p))
59#define HDR_ACK_SINK(p) \
60 (hdr_ACK_SINK::access(p))
61#define HDR_PROBE_SINK(p) \
62 (hdr_PROBE_SINK::access(p))
64extern packet_t PT_TRIGGER;
65extern packet_t PT_POLL;
66extern packet_t PT_PROBE;
67extern packet_t PT_PROBE_SINK;
68extern packet_t PT_AUV_MULE;
69extern packet_t PT_ACK_SINK;
70
71static const int MAX_POLLED_NODE = 4000;
72static const double MIN_T_POLL = 5;
73static const double MIN_T_DATA = 5;
74static const int MAX_BUFFER_SIZE =
75 100;
76static const int prop_speed =
77 1500;
80typedef struct POLL_ID {
81 int id_;
82 double t_wait_;
83} id_poll;
84
88typedef struct hdr_TRIGGER {
89 uint16_t
90 t_in_;
92 uint16_t
93 t_fin_;
95 uint TRIGGER_uid_;
96 static int offset_;
101 inline static int &
103 {
104 return offset_;
105 }
106
110 uint16_t &
111 t_in()
112 {
113 return (t_in_);
114 }
115
119 uint16_t &
120 t_fin()
121 {
122 return (t_fin_);
123 }
127 uint &
129 {
130 return (TRIGGER_uid_);
131 }
132
133 inline static struct hdr_TRIGGER *
134 access(const Packet *p)
135 {
136 return (struct hdr_TRIGGER *) p->access(offset_);
137 }
139
143typedef struct hdr_POLL {
144 int id_;
145 uint POLL_uid_;
146 uint16_t POLL_time_;
147 static int offset_;
152 int &
154 {
155 return (id_);
156 }
157
161 uint &
162 POLL_uid()
163 {
164 return (POLL_uid_);
165 }
166
167 uint16_t &
169 {
170 return (POLL_time_);
171 }
172
176 inline static int &
177 offset()
178 {
179 return offset_;
180 }
181
182 inline static struct hdr_POLL *
183 access(const Packet *p)
184 {
185 return (struct hdr_POLL *) p->access(offset_);
186 }
187} hdr_POLL;
188
192typedef struct hdr_PROBE {
193 //uint16_t backoff_time_; /**< Backoff time chosen by the node */
194 uint16_t ts_;
195 int n_pkts_;
197 uint id_node_;
199 static int offset_;
204 uint16_t &
206 {
207 return (ts_);
208 }
209
213/* uint16_t &
214 backoff_time()
215 {
216 return (backoff_time_);
217 }*/
218
222 int &
223 n_pkts()
224 {
225 return (n_pkts_);
226 }
227
231 uint &
232 id_node()
233 {
234 return (id_node_);
235 }
236
240 uint &
241 PROBE_uid()
242 {
243 return (PROBE_uid_);
244 }
245
249 inline static int &
250 offset()
251 {
252 return offset_;
253 }
254
255 inline static struct hdr_PROBE *
256 access(const Packet *p)
257 {
258 return (struct hdr_PROBE *) p->access(offset_);
259 }
260} hdr_PROBE;
261
266typedef struct hdr_PROBE_SINK {
267 uint id_sink_;
268 uint PROBE_uid_;
269 uint16_t id_ack_;
270 static int offset_;
275 uint &
277 {
278 return (id_sink_);
279 }
280
284 uint &
285 PROBE_uid()
286 {
287 return (PROBE_uid_);
288 }
289
293 uint16_t &
294 id_ack()
295 {
296 return (id_ack_);
297 }
298
302 inline static int &
303 offset()
304 {
305 return offset_;
306 }
307
308 inline static struct hdr_PROBE_SINK *
309 access(const Packet *p)
310 {
311 return (struct hdr_PROBE_SINK *) p->access(offset_);
312 }
314
319typedef struct hdr_AUV_MULE {
320 uint16_t pkt_uid_;
321 uint16_t last_pkt_uid_;
322 static int offset_;
327 uint16_t &
329 {
330 return (pkt_uid_);
331 }
332
336 uint16_t &
338 {
339 return (last_pkt_uid_);
340 }
341
345 inline static int &
346 offset()
347 {
348 return offset_;
349 }
350
351 inline static struct hdr_AUV_MULE *
352 access(const Packet *p)
353 {
354 return (struct hdr_AUV_MULE *) p->access(offset_);
355 }
357
361typedef struct hdr_ACK_SINK {
362 std::vector<uint16_t> id_ack_;
363 static int offset_;
368 std::vector<uint16_t> &
370 {
371 return (id_ack_);
372 }
373
377 inline static int &
378 offset()
379 {
380 return offset_;
381 }
382
383 inline static struct hdr_ACK_SINK *
384 access(const Packet *p)
385 {
386 return (struct hdr_ACK_SINK *) p->access(offset_);
387 }
389
390#endif
Single location of the POLL vector.
double t_wait_
Time that a node has to wait before being polled.
int id_
ID of the node.
Header of the ACK sent by the SINK.
static int offset_
Required by the PacketHeaderManager.
static struct hdr_ACK_SINK * access(const Packet *p)
static int & offset()
Reference to the offset variable.
std::vector< uint16_t > & id_ack()
Reference to the id_ack_ variable.
std::vector< uint16_t > id_ack_
ACK is the id of the wrong packets.
Header of the data sent from AUV MULE to SINK.
uint16_t pkt_uid_
unique ID of the transmitted packet by the AUV node
uint16_t & last_pkt_uid()
Reference to the last_pkt_uid_ variable.
static int offset_
ID of the last packet transmitted in the round.
static int & offset()
Reference to the offset variable.
static struct hdr_AUV_MULE * access(const Packet *p)
uint16_t & pkt_uid()
Reference to the pkt_uid_ variable.
Header of the POLL message.
int id_
ID of the POLLED node.
int & ID()
Reference to the id_ variable.
uint16_t POLL_time_
Time needed by the AUV to poll all the nodes.
static struct hdr_POLL * access(const Packet *p)
static int & offset()
Reference to the offset variable.
uint16_t & POLL_time()
uint & POLL_uid()
Reference to the POLL_uid_ variable.
uint POLL_uid_
POLL packet unique ID.
static int offset_
Required by the PacketHeaderManager.
Header of the PROBE message.
uint id_sink_
ID of the sink.
uint16_t & id_ack()
Reference to id_ack_ variable.
uint & PROBE_uid()
Reference to PROBE_uid_ variable.
static struct hdr_PROBE_SINK * access(const Packet *p)
static int offset_
Required by the PacketHeaderManager.
uint16_t id_ack_
ID used for ack purpose.
uint & id_sink()
Reference to id_sink variable.
uint PROBE_uid_
Unique ID of the PROBE packet.
static int & offset()
Reference to the offset variable.
Header of the PROBE message.
uint PROBE_uid_
Unique ID of the PROBE packet.
static int offset_
Required by the PacketHeaderManager.
static int & offset()
Reference to the offset variable.
uint & id_node()
Reference to id_node variable.
uint16_t & ts()
Reference to timestamp variable.
uint & PROBE_uid()
Reference to PROBE_uid_ variable.
uint16_t ts_
Timestamp of the most recent data packet.
static struct hdr_PROBE * access(const Packet *p)
int & n_pkts()
Reference to backoff_time variable.
uint id_node_
ID of the node.
int n_pkts_
Number of packets that the node wish to transmit to the AUV.
Header of the TRIGGER message.
uint TRIGGER_uid_
TRIGGER packet unique ID.
uint16_t t_in_
Minimum value in which the node can choose his backoff time.
static int & offset()
Reference to the offset variable.
static int offset_
Required by the PacketHeaderManager.
static struct hdr_TRIGGER * access(const Packet *p)
uint16_t t_fin_
Maximum value in which the node can choose his backoff time.
uint & TRIGGER_uid()
Reference to the TRIGGER_uid variable.
uint16_t & t_in()
Reference to the t_in variable.
uint16_t & t_fin()
Reference to the t_fin variable.
static const double MIN_T_POLL
Minimum duration of the POLL timer.
static const int prop_speed
Typical underwater sound propagation speed.
static const int MAX_POLLED_NODE
Maximum number of node to POLL.
struct POLL_ID id_poll
Single location of the POLL vector.
static const int MAX_BUFFER_SIZE
Maximum size of the queue in number of packets.
static const double MIN_T_DATA
Minimum duration of the DATA timer.