DESERT 4.0.0
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( \
58 p))
60#define HDR_ACK_SINK(p) \
61 (hdr_ACK_SINK::access(p))
63#define HDR_PROBE_SINK(p) \
64 (hdr_PROBE_SINK::access( \
65 p))
67extern packet_t PT_TRIGGER;
68extern packet_t PT_POLL;
69extern packet_t PT_PROBE;
70extern packet_t PT_PROBE_SINK;
71extern packet_t PT_AUV_MULE;
72extern packet_t PT_ACK_SINK;
73
74static const int MAX_POLLED_NODE = 4000;
75static const double MIN_T_POLL = 5;
76static const double MIN_T_DATA = 5;
77static const int MAX_BUFFER_SIZE =
78 100;
79static const int prop_speed =
80 1500;
83typedef struct POLL_ID {
84 int id_;
85 double t_wait_;
87
91typedef struct hdr_TRIGGER {
92 uint16_t t_in_;
94 uint16_t t_fin_;
97 static int offset_;
102 inline static int &
104 {
105 return offset_;
106 }
107
111 uint16_t &
113 {
114 return (t_in_);
115 }
116
120 uint16_t &
122 {
123 return (t_fin_);
124 }
128 uint &
130 {
131 return (TRIGGER_uid_);
132 }
133
134 inline static struct hdr_TRIGGER *
135 access(const Packet *p)
136 {
137 return (struct hdr_TRIGGER *) p->access(offset_);
138 }
140
144typedef struct hdr_POLL {
145 int id_;
147 uint16_t POLL_time_;
148 static int offset_;
153 int &
155 {
156 return (id_);
157 }
158
162 uint &
164 {
165 return (POLL_uid_);
166 }
167
168 uint16_t &
170 {
171 return (POLL_time_);
172 }
173
177 inline static int &
179 {
180 return offset_;
181 }
182
183 inline static struct hdr_POLL *
184 access(const Packet *p)
185 {
186 return (struct hdr_POLL *) p->access(offset_);
187 }
189
193typedef struct hdr_PROBE {
194 // uint16_t backoff_time_; /**< Backoff time chosen by the node */
195 uint16_t ts_;
198 uint id_node_;
200 static int offset_;
205 uint16_t &
207 {
208 return (ts_);
209 }
210
214 /* uint16_t &
215 backoff_time()
216 {
217 return (backoff_time_);
218 }*/
219
223 int &
225 {
226 return (n_pkts_);
227 }
228
232 uint &
234 {
235 return (id_node_);
236 }
237
241 uint &
243 {
244 return (PROBE_uid_);
245 }
246
250 inline static int &
252 {
253 return offset_;
254 }
255
256 inline static struct hdr_PROBE *
257 access(const Packet *p)
258 {
259 return (struct hdr_PROBE *) p->access(offset_);
260 }
262
266typedef struct hdr_PROBE_SINK {
267 uint id_sink_;
269 uint16_t id_ack_;
270 static int offset_;
275 uint &
277 {
278 return (id_sink_);
279 }
280
284 uint &
286 {
287 return (PROBE_uid_);
288 }
289
293 uint16_t &
295 {
296 return (id_ack_);
297 }
298
302 inline static int &
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
318typedef struct hdr_AUV_MULE {
319 uint16_t
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 &
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 &
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
Definition uwpolling_cmn_hdr.h:83
double t_wait_
Definition uwpolling_cmn_hdr.h:85
int id_
Definition uwpolling_cmn_hdr.h:84
Definition uwpolling_cmn_hdr.h:361
static int offset_
Definition uwpolling_cmn_hdr.h:363
static struct hdr_ACK_SINK * access(const Packet *p)
Definition uwpolling_cmn_hdr.h:384
static int & offset()
Definition uwpolling_cmn_hdr.h:378
std::vector< uint16_t > & id_ack()
Definition uwpolling_cmn_hdr.h:369
std::vector< uint16_t > id_ack_
Definition uwpolling_cmn_hdr.h:362
Definition uwpolling_cmn_hdr.h:318
uint16_t pkt_uid_
Definition uwpolling_cmn_hdr.h:320
uint16_t & last_pkt_uid()
Definition uwpolling_cmn_hdr.h:337
static int offset_
Definition uwpolling_cmn_hdr.h:322
static int & offset()
Definition uwpolling_cmn_hdr.h:346
static struct hdr_AUV_MULE * access(const Packet *p)
Definition uwpolling_cmn_hdr.h:352
uint16_t last_pkt_uid_
Definition uwpolling_cmn_hdr.h:321
uint16_t & pkt_uid()
Definition uwpolling_cmn_hdr.h:328
Definition uwpolling_cmn_hdr.h:144
int id_
Definition uwpolling_cmn_hdr.h:145
int & ID()
Definition uwpolling_cmn_hdr.h:154
uint16_t POLL_time_
Definition uwpolling_cmn_hdr.h:147
static struct hdr_POLL * access(const Packet *p)
Definition uwpolling_cmn_hdr.h:184
static int & offset()
Definition uwpolling_cmn_hdr.h:178
uint16_t & POLL_time()
Definition uwpolling_cmn_hdr.h:169
uint & POLL_uid()
Definition uwpolling_cmn_hdr.h:163
uint POLL_uid_
Definition uwpolling_cmn_hdr.h:146
static int offset_
Definition uwpolling_cmn_hdr.h:148
Definition uwpolling_cmn_hdr.h:266
uint id_sink_
Definition uwpolling_cmn_hdr.h:267
uint16_t & id_ack()
Definition uwpolling_cmn_hdr.h:294
uint & PROBE_uid()
Definition uwpolling_cmn_hdr.h:285
static struct hdr_PROBE_SINK * access(const Packet *p)
Definition uwpolling_cmn_hdr.h:309
static int offset_
Definition uwpolling_cmn_hdr.h:270
uint16_t id_ack_
Definition uwpolling_cmn_hdr.h:269
uint & id_sink()
Definition uwpolling_cmn_hdr.h:276
uint PROBE_uid_
Definition uwpolling_cmn_hdr.h:268
static int & offset()
Definition uwpolling_cmn_hdr.h:303
Definition uwpolling_cmn_hdr.h:193
uint PROBE_uid_
Definition uwpolling_cmn_hdr.h:199
static int offset_
Definition uwpolling_cmn_hdr.h:200
static int & offset()
Definition uwpolling_cmn_hdr.h:251
uint & id_node()
Definition uwpolling_cmn_hdr.h:233
uint16_t & ts()
Definition uwpolling_cmn_hdr.h:206
uint & PROBE_uid()
Definition uwpolling_cmn_hdr.h:242
uint16_t ts_
Definition uwpolling_cmn_hdr.h:195
static struct hdr_PROBE * access(const Packet *p)
Definition uwpolling_cmn_hdr.h:257
int & n_pkts()
Definition uwpolling_cmn_hdr.h:224
uint id_node_
Definition uwpolling_cmn_hdr.h:198
int n_pkts_
Definition uwpolling_cmn_hdr.h:196
Definition uwpolling_cmn_hdr.h:91
uint TRIGGER_uid_
Definition uwpolling_cmn_hdr.h:96
uint16_t t_in_
Definition uwpolling_cmn_hdr.h:92
static int & offset()
Definition uwpolling_cmn_hdr.h:103
static int offset_
Definition uwpolling_cmn_hdr.h:97
static struct hdr_TRIGGER * access(const Packet *p)
Definition uwpolling_cmn_hdr.h:135
uint16_t t_fin_
Definition uwpolling_cmn_hdr.h:94
uint & TRIGGER_uid()
Definition uwpolling_cmn_hdr.h:129
uint16_t & t_in()
Definition uwpolling_cmn_hdr.h:112
uint16_t & t_fin()
Definition uwpolling_cmn_hdr.h:121
packet_t PT_PROBE_SINK
Definition initlib.cpp:55
struct POLL_ID id_poll
packet_t PT_TRIGGER
Definition initlib.cpp:53
packet_t PT_AUV_MULE
Definition initlib.cpp:57
packet_t PT_POLL
Definition initlib.cpp:56
packet_t PT_PROBE
Definition initlib.cpp:54
packet_t PT_ACK_SINK
Definition initlib.cpp:58