DESERT 3.5.1
Loading...
Searching...
No Matches
packer_uwUFetch.cc
Go to the documentation of this file.
1//
2// Copyright (c) 2013 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
36#include "packer_uwUFetch.h"
37
38static class PackerUwUFetchClass : public TclClass {
39public:
40
41 PackerUwUFetchClass() : TclClass("NS2/MAC/uwUFetch/Packer") {
42 }
43
44 TclObject* create(int, const char*const*) {
45 return (new packer_uwUFetch());
46 }
48
50t_bck_max_probe_Bits(0),
51t_bck_min_probe_Bits(0),
52n_cbeacon_tx_Bits(0),
53t_bck_choice_sensor_Bits(0),
54n_pck_sensor_want_tx_Bits(0),
55mac_addr_sensor_polled_Bits(0),
56n_pck_hn_want_tx_Bits(0),
57max_cbeacon_tx_hn_Bits(0),
58t_bck_max_rts_Bits(0),
59t_bck_min_rts_Bits(0),
60max_pck_want_rx_Bits(0),
61num_DATA_pcks_Bits(0),
62backoff_time_RTS_Bits(0),
63num_DATA_pcks_MAX_rx_Bits(0),
64mac_addr_HN_ctsed_Bits(0) {
65 //Header of the BEACON packet
66 bind("T_BCK_MAX_PROBE_", (int*) &t_bck_max_probe_Bits);
67 bind("T_BCK_MIN_PROBE_", (int*) &t_bck_min_probe_Bits);
68 bind("N_CBEACON_TX_", (int*) &n_cbeacon_tx_Bits);
69
70 //Header of the PROBE packet
71 bind("T_BCK_CHOICE_SENSOR_", (int*) &t_bck_choice_sensor_Bits);
72 bind("N_PCK_SENSOR_WANT_TX_", (int*) &n_pck_sensor_want_tx_Bits);
73
74 //Header of the POLL packet
75 bind("MAC_ADDR_SENSOR_POLLED_", (int*) &mac_addr_sensor_polled_Bits);
76 bind("N_PCK_HN_WANT_RX_", (int*) &n_pck_hn_want_tx_Bits);
77
78 //Header of the CBEACON packet
79 bind("MAX_CBEACON_TX_HN_", (int*) &max_cbeacon_tx_hn_Bits);
80
81 //Header of the TRIGGER packet
82 bind("T_BCK_MAX_RTS_", (int*) &t_bck_max_rts_Bits);
83 bind("T_BCK_MIN_RTS_", (int*) &t_bck_min_rts_Bits);
84 bind("N_PCK_AUV_WANT_RX_", (int*) &max_pck_want_rx_Bits);
85
86 //Header of the RTS packet
87 bind("NUM_DATA_PCKS_", (int*) &num_DATA_pcks_Bits);
88 bind("BACKOFF_TIME_RTS_", (int*) &backoff_time_RTS_Bits);
89
90 //Header of the CTS packet
91 bind("NUM_DATA_PCKS_MAX_RX_", (int*) &num_DATA_pcks_MAX_rx_Bits);
92 bind("MAC_ADRR_HN_CTSED_", (int*) &mac_addr_HN_ctsed_Bits);
93
94 this->init();
95} //end constructor of packer_uwUFetch class
96
98
99} //destructor of packer_uwUFetch class
100
102 if (debug_)
103 std::cout << "Re-initialization of n_bits for the uwUFETCH packer " << std::endl;
104
105 n_bits.clear();
106 n_bits.assign(15, 0);
107 //Header of the BEACON packet
111 //Header of the PROBE packet
114 //Header of the POLL packet
117 //Header of the CBEACON packet
119 //Header of the TRIGGER packet
123 //Header of RTS packet
126 //Header of the CTS packet
129
130} //end init()
131
132size_t packer_uwUFetch::packMyHdr(Packet* p, unsigned char* buf, size_t offset) {
133
134 hdr_cmn* hcmn = HDR_CMN(p);
135
136 if (hcmn->ptype() == PT_BEACON_UFETCH) {
137 //Packet to be serialized is a BEACON
139
140 offset += put(buf, offset, &(beaconh->t_max_bc_), n_bits[T_BCK_MAX_PROBE]);
141 offset += put(buf, offset, &(beaconh->t_min_bc_), n_bits[T_BCK_MIN_PROBE]);
142 offset += put(buf, offset, &(beaconh->num_Max_CBEACON_tx_by_HN_), n_bits[N_CBEACON_TX]);
143
144 if (debug_) {
145 std::cout << "\033[1;37;45m (TX) UWUFETCH::BEACON packer hdr \033[0m" << std::endl;
147 }
148
149 } else if (hcmn->ptype() == PT_PROBE_UFETCH) {
150 //Packet to be serialized is a PROBE
152
153 offset += put(buf, offset, &(probeh->backoff_time_PROBE_), n_bits[T_BCK_CHOICE_SENSOR]);
154 offset += put(buf, offset, &(probeh->n_DATA_pcks_Node_tx_), n_bits[N_PCK_SENSOR_WANT_TX]);
155
156 if (debug_) {
157 std::cout << "\033[1;37;45m (TX) UWUFETCH::PROBE packer hdr \033[0m" << std::endl;
159 }
160
161 } else if (hcmn->ptype() == PT_POLL_UFETCH) {
162 //Packet to be serialized is a POLL
164
165 offset += put(buf, offset, &(pollh->mac_addr_Node_polled_), n_bits[MAC_ADDR_SENSOR_POLLED]);
166 offset += put(buf, offset, &(pollh->num_DATA_pcks_MAX_rx_), n_bits[N_PCK_HN_WANT_RX]);
167
168 if (debug_) {
169 std::cout << "\033[1;37;45m (TX) UWUFETCH::POLL packer hdr \033[0m" << std::endl;
171 }
172
173 } else if (hcmn->ptype() == PT_CBEACON_UFETCH) {
174 //Packet to be serialized is a CBEACON
176
177 offset += put(buf, offset, &(cbeaconh->num_Max_CBEACON_tx_by_HN_), n_bits[MAX_CBEACON_TX_HN]);
178 offset += put(buf, offset, &(cbeaconh->t_max_bc_), n_bits[T_BCK_MAX_PROBE]);
179 offset += put(buf, offset, &(cbeaconh->t_min_bc_), n_bits[T_BCK_MIN_PROBE]);
180
181 if (debug_) {
182 std::cout << "\033[1;37;45m (TX) UWUFETCH::CBEACON packer hdr \033[0m" << std::endl;
184 }
185
186 } else if (hcmn->ptype() == PT_TRIGGER_UFETCH) {
187 //Packet to be serialized is a TRIGGER
189
190 offset += put(buf, offset, &(triggerh->t_max_), n_bits[T_BCK_MAX_RTS]);
191 offset += put(buf, offset, &(triggerh->t_min_), n_bits[T_BCK_MIN_RTS]);
192 offset += put(buf, offset, &(triggerh->max_pck_want_rx_), n_bits[N_PCK_AUV_WANT_RX]);
193 if (debug_) {
194 std::cout << "\033[1;37;45m (TX) UWUFETCH::TRIGGER packer hdr \033[0m" << std::endl;
196 }
197 } else if (hcmn->ptype() == PT_RTS_UFETCH) {
198 //Packet to be serialized is a RTS
200
201 offset += put(buf, offset, &(rtsh->backoff_time_RTS_), n_bits[BACKOFF_TIME_RTS]);
202 offset += put(buf, offset, &(rtsh->num_DATA_pcks_), n_bits[NUM_DATA_PCKS]);
203
204 if (debug_) {
205 std::cout << "\033[1;37;45m (TX) UWUFETCH::RTS packer hdr \033[0m" << std::endl;
207 }
208 } else if (hcmn->ptype() == PT_CTS_UFETCH) {
209 //Packet to be serialized is a CTS
211
212 offset += put(buf, offset, &(ctsh->mac_addr_HN_ctsed_), n_bits[MAC_ADDR_HN_CTSED]);
213 offset += put(buf, offset, &(ctsh->num_DATA_pcks_MAX_rx_), n_bits[NUM_DATA_PCKS_MAX_RX]);
214
215 if (debug_) {
216 std::cout << "\033[1;37;45m (TX) UWUFETCH::CTS packer hdr \033[0m" << std::endl;
218 }
219 }
220
221 return offset;
222} //end packMyHeader()
223
224size_t packer_uwUFetch::unpackMyHdr(unsigned char* buf, size_t offset, Packet* p) {
225
226 hdr_cmn* hcmn = HDR_CMN(p);
227
228 if (hcmn->ptype() == PT_BEACON_UFETCH) {
229 //Packet to be serialized is a BEACON
231
232 memset(&(beaconh->t_max_bc_), 0, sizeof (beaconh->t_max_bc_));
233 offset += get(buf, offset, &(beaconh->t_max_bc_), n_bits[T_BCK_MAX_PROBE]);
234
235 memset(&(beaconh->t_min_bc_), 0, sizeof (beaconh->t_min_bc_));
236 offset += get(buf, offset, &(beaconh->t_min_bc_), n_bits[T_BCK_MIN_PROBE]);
237
238 memset(&(beaconh->num_Max_CBEACON_tx_by_HN_), 0, sizeof (beaconh->num_Max_CBEACON_tx_by_HN_));
239 offset += get(buf, offset, &(beaconh->num_Max_CBEACON_tx_by_HN_), n_bits[N_CBEACON_TX]);
240
241 if (debug_) {
242 std::cout << "\033[1;32;40m (RX) UWUFETCH::BEACON packer hdr \033[0m" << std::endl;
244 }
245
246 } else if (hcmn->ptype() == PT_PROBE_UFETCH) {
247 //Packet to be serialized is a PROBE
249
250 memset(&(probeh->backoff_time_PROBE_), 0, sizeof (probeh->backoff_time_PROBE_));
251 offset += get(buf, offset, &(probeh->backoff_time_PROBE_), n_bits[T_BCK_CHOICE_SENSOR]);
252
253 memset(&(probeh->n_DATA_pcks_Node_tx_), 0, sizeof (probeh->n_DATA_pcks_Node_tx_));
254 offset += get(buf, offset, &(probeh->n_DATA_pcks_Node_tx_), n_bits[N_PCK_SENSOR_WANT_TX]);
255
256 if (debug_) {
257 std::cout << "\033[1;32;40m (RX) UWUFETCH::PROBE packer hdr \033[0m" << std::endl;
259 }
260
261 } else if (hcmn->ptype() == PT_POLL_UFETCH) {
262 //Packet to be serialized is a POLL
264
265 memset(&(pollh->mac_addr_Node_polled_), 0, sizeof (pollh->mac_addr_Node_polled_));
266 offset += get(buf, offset, &(pollh->mac_addr_Node_polled_), n_bits[MAC_ADDR_SENSOR_POLLED]);
267
268 memset(&(pollh->num_DATA_pcks_MAX_rx_), 0, sizeof (pollh->num_DATA_pcks_MAX_rx_));
269 offset += get(buf, offset, &(pollh->num_DATA_pcks_MAX_rx_), n_bits[N_PCK_HN_WANT_RX]);
270
271 if (debug_) {
272 std::cout << "\033[1;32;40m (RX) UWUFETCH::POLL packer hdr \033[0m" << std::endl;
274 }
275
276 } else if (hcmn->ptype() == PT_CBEACON_UFETCH) {
277 //Packet to be serialized is a CBEACON
279
280 memset(&(cbeaconh->num_Max_CBEACON_tx_by_HN_), 0, sizeof (cbeaconh->num_Max_CBEACON_tx_by_HN_));
281 offset += get(buf, offset, &(cbeaconh->num_Max_CBEACON_tx_by_HN_), n_bits[MAX_CBEACON_TX_HN]);
282
283 memset(&(cbeaconh->t_max_bc_), 0, sizeof (cbeaconh->t_max_bc_));
284 offset += get(buf, offset, &(cbeaconh->t_max_bc_), n_bits[T_BCK_MAX_PROBE]);
285
286 memset(&(cbeaconh->t_min_bc_), 0, sizeof (cbeaconh->t_min_bc_));
287 offset += get(buf, offset, &(cbeaconh->t_min_bc_), n_bits[T_BCK_MIN_PROBE]);
288
289 if (debug_) {
290 std::cout << "\033[1;32;40m (RX) UWUFETCH::CBEACON packer hdr \033[0m" << std::endl;
292 }
293 } else if (hcmn->ptype() == PT_TRIGGER_UFETCH) {
294 //Packet to be serialized is a TRIGGER
296
297 memset(&(triggerh->t_max_), 0, sizeof (triggerh->t_max_));
298 offset += get(buf, offset, &(triggerh->t_max_), n_bits[T_BCK_MAX_RTS]);
299
300 memset(&(triggerh->t_min_), 0, sizeof (triggerh->t_min_));
301 offset += get(buf, offset, &(triggerh->t_min_), n_bits[T_BCK_MIN_RTS]);
302
303 memset(&(triggerh->max_pck_want_rx_), 0, sizeof (triggerh->max_pck_want_rx_));
304 offset += get(buf, offset, &(triggerh->max_pck_want_rx_), n_bits[N_PCK_AUV_WANT_RX]);
305
306 if (debug_) {
307 std::cout << "\033[1;32;40m (RX) UWUFETCH::TRIGGER packer hdr \033[0m" << std::endl;
309 }
310 } else if (hcmn->ptype() == PT_RTS_UFETCH) {
311 //Packet to be serialized is a RTS
313
314 memset(&(rtsh->backoff_time_RTS_), 0, sizeof (rtsh->backoff_time_RTS_));
315 offset += get(buf, offset, &(rtsh->backoff_time_RTS_), n_bits[BACKOFF_TIME_RTS]);
316
317 memset(&(rtsh->num_DATA_pcks_), 0, sizeof (rtsh->num_DATA_pcks_));
318 offset += get(buf, offset, &(rtsh->num_DATA_pcks_), n_bits[NUM_DATA_PCKS]);
319
320 if (debug_) {
321 std::cout << "\033[1;32;40m (RX) UWUFETCH::RTS packer hdr \033[0m" << std::endl;
323 }
324 } else if (hcmn->ptype() == PT_CTS_UFETCH) {
325 //Packet to be serialized is a CTS
327
328 memset(&(ctsh->mac_addr_HN_ctsed_), 0, sizeof (ctsh->mac_addr_HN_ctsed_));
329 offset += get(buf, offset, &(ctsh->mac_addr_HN_ctsed_), n_bits[MAC_ADDR_HN_CTSED]);
330
331 memset(&(ctsh->num_DATA_pcks_MAX_rx_), 0, sizeof (ctsh->num_DATA_pcks_MAX_rx_));
332 offset += get(buf, offset, &(ctsh->num_DATA_pcks_MAX_rx_), n_bits[NUM_DATA_PCKS_MAX_RX]);
333
334 if (debug_) {
335 std::cout << "\033[1;32;40m (RX) UWUFETCH::CTS packer hdr \033[0m" << std::endl;
337 }
338 }
339 return offset;
340} //end unpackMyHdr()
341
343 std::cout << "\033[1;37;45m Packer Name \033[0m: UWUFETCH \n";
344 std::cout << "** BEACON fields:\n";
345 std::cout << "\033[1;37;45m Field: T_BCK_MAX_PROBE: \033[0m:" << n_bits[T_BCK_MAX_PROBE] << " bits\n";
346 std::cout << "\033[1;37;45m Field: T_BCK_MIN_PROBE: \033[0m:" << n_bits[T_BCK_MIN_PROBE] << " bits\n";
347 std::cout << "\033[1;37;45m Field: N_CBEACON_TX: \033[0m:" << n_bits[N_CBEACON_TX] << " bits\n";
348
349 std::cout << "** PROBE fields:\n";
350 std::cout << "\033[1;37;45m Field: T_BCK_CHOICE_SENSOR: \033[0m:" << n_bits[T_BCK_CHOICE_SENSOR] << " bits\n";
351 std::cout << "\033[1;37;45m Field: N_PCK_SENSOR_WANT_TX: \033[0m:" << n_bits[N_PCK_SENSOR_WANT_TX] << " bits\n";
352
353 std::cout << "** POLL fields:\n";
354 std::cout << "\033[1;37;45m Field: MAC_ADDR_SENSOR_POLLED: \033[0m:" << n_bits[MAC_ADDR_SENSOR_POLLED] << " bits\n";
355 std::cout << "\033[1;37;45m Field: N_PCK_HN_WANT_RX: \033[0m:" << n_bits[N_PCK_HN_WANT_RX] << " bits\n";
356
357 std::cout << "** CBEACON fields:\n";
358 std::cout << "\033[1;37;45m Field: MAX_CBEACON_TX_HN: \033[0m:" << n_bits[MAX_CBEACON_TX_HN] << " bits\n";
359 std::cout << "\033[1;37;45m Field: T_BCK_MAX_PROBE: \033[0m:" << n_bits[T_BCK_MAX_PROBE] << " bits\n";
360 std::cout << "\033[1;37;45m Field: T_BCK_MIN_PROBE: \033[0m:" << n_bits[T_BCK_MIN_PROBE] << " bits\n";
361
362 std::cout << "** TRIGGER fields:\n";
363 std::cout << "\033[1;37;45m Field: T_BCK_MAX_RTS: \033[0m:" << n_bits[T_BCK_MAX_RTS] << " bits\n";
364 std::cout << "\033[1;37;45m Field: T_BCK_MIN_RTS: \033[0m:" << n_bits[T_BCK_MIN_RTS] << " bits\n";
365 std::cout << "\033[1;37;45m Field: N_PCK_AUV_WANT_RX: \033[0m:" << n_bits[N_PCK_AUV_WANT_RX] << " bits\n";
366
367 std::cout << "** RTS fields:\n";
368 std::cout << "\033[1;37;45m Field: BACKOFF_TIME_RTS: \033[0m:" << n_bits[BACKOFF_TIME_RTS] << " bits\n";
369 std::cout << "\033[1;37;45m Field: NUM_DATA_PCKS: \033[0m:" << n_bits[NUM_DATA_PCKS] << " bits\n";
370
371 std::cout << "** CTS fields:\n";
372 std::cout << "\033[1;37;45m Field: MAC_ADDR_HN_CTSED: \033[0m:" << n_bits[MAC_ADDR_HN_CTSED] << " bits\n";
373 std::cout << "\033[1;37;45m Field: NUM_DATA_PCKS_MAX_RX: \033[0m:" << n_bits[NUM_DATA_PCKS_MAX_RX] << " bits\n";
374
375 cout << std::endl; // Only at the end do we actually flush the buffer and print
376} //end printMyHdrMap()
377
379 //Print information packet serialized by the method packMyHdr
380 hdr_cmn* hcmn = HDR_CMN(p);
381
382 if (hcmn->ptype() == PT_BEACON_UFETCH) {
383 //Packet to be serialized is a BEACON
385 std::cout << "\033[1;37;45m 1st field \033[0m, T_BCK_MAX_PROBE: " << beaconh->t_max_bc_ << std::endl;
386 std::cout << "\033[1;37;45m 2nd field \033[0m, T_BCK_MIN_PROBE: " << beaconh->t_min_bc_ << std::endl;
387 std::cout << "\033[1;37;45m 3nd field \033[0m, N_CBEACON_TX: " << beaconh->num_Max_CBEACON_tx_by_HN_ << std::endl;
388
389 } else if (hcmn->ptype() == PT_PROBE_UFETCH) {
390 //Packet to be serialized is a PROBE
392 std::cout << "\033[1;37;45m 1st field \033[0m, T_BCK_CHOICE_SENSOR: " << probeh->backoff_time_PROBE_ << std::endl;
393 std::cout << "\033[1;37;45m 2nd field \033[0m, N_PCK_SENSOR_WANT_TX: " << probeh->n_DATA_pcks_Node_tx_ << std::endl;
394
395 } else if (hcmn->ptype() == PT_POLL_UFETCH) {
396 //Packet to be serialized is a POLL
398 std::cout << "\033[1;37;45m 1st field \033[0m, MAC_ADDR_SENSOR_POLLED: " << pollh->mac_addr_Node_polled_ << std::endl;
399 std::cout << "\033[1;37;45m 2nd field \033[0m, N_PCK_HN_WANT_RX: " << pollh->num_DATA_pcks_MAX_rx_ << std::endl;
400
401 } else if (hcmn->ptype() == PT_CBEACON_UFETCH) {
402 //Packet to be serialized is a CBEACON
404 std::cout << "\033[1;37;45m 1st field \033[0m, MAX_CBEACON_TX_HN: " << cbeaconh->num_Max_CBEACON_tx_by_HN_ << std::endl;
405 std::cout << "\033[1;37;45m 2st field \033[0m, T_BCK_MAX_PROBE: " << cbeaconh->t_max_bc_ << std::endl;
406 std::cout << "\033[1;37;45m 3st field \033[0m, T_BCK_MIN_PROBE: " << cbeaconh->t_min_bc_ << std::endl;
407
408 } else if (hcmn->ptype() == PT_TRIGGER_UFETCH) {
409 //Packet to be serialized is a TRIGGER
411 std::cout << "\033[1;37;45m 1st field \033[0m, T_BCK_MAX_RTS: " << triggerh->t_max_ << std::endl;
412 std::cout << "\033[1;37;45m 2nd field \033[0m, T_BCK_MIN_RTS: " << triggerh->t_min_ << std::endl;
413 std::cout << "\033[1;37;45m 3nd field \033[0m, N_PCK_AUV_WANT_RX: " << triggerh->max_pck_want_rx_ << std::endl;
414
415 } else if (hcmn->ptype() == PT_RTS_UFETCH) {
416 //Packet to be serialized is a RTS
418 std::cout << "\033[1;37;45m 1st field \033[0m, BACKOFF_TIME_RTS: " << rtsh->backoff_time_RTS_ << std::endl;
419 std::cout << "\033[1;37;45m 2nd field \033[0m, NUM_DATA_PCKS: " << rtsh->num_DATA_pcks_ << std::endl;
420
421 } else if (hcmn->ptype() == PT_CTS_UFETCH) {
422 //Packet to be serialized is a CTS
424 std::cout << "\033[1;37;45m 1st field \033[0m, MAC_ADDR_HN_CTSED: " << ctsh->mac_addr_HN_ctsed_ << std::endl;
425 std::cout << "\033[1;37;45m 2nd field \033[0m, NUM_DATA_PCKS_MAX_RX: " << ctsh->num_DATA_pcks_MAX_rx_ << std::endl;
426 }
427} // end printMyHdrFields
TclObject * create(int, const char *const *)
Class to map a ns2 mac header into a bit stream, and vice-versa.
size_t n_cbeacon_tx_Bits
number of bits used for n_cbeacon_tx_ field on BEACON header
@ N_PCK_AUV_WANT_RX
Maximum number of packets that AUV want receive from the HN.
@ T_BCK_MAX_RTS
Upper bound of the time interval from which the sensor node choice the backoff time before to transmi...
@ N_PCK_HN_WANT_RX
Maximum number of data packet that the head node want to receive from the sensor node polled.
@ NUM_DATA_PCKS_MAX_RX
Exact number of DATA packets that AUV want to receive from the HN.
@ T_BCK_MIN_PROBE
Lower bound of the time interval from which the sensor node choice the backoff time before to transmi...
@ BACKOFF_TIME_RTS
Backoff time choice by the HN before to transmit a RTS packet.
@ N_PCK_SENSOR_WANT_TX
Number of the packets that the sensor node would like to transmit to the head node.
@ T_BCK_MIN_RTS
Lower bound of the time interval from which the sensor node choice the backoff time before to transmi...
@ N_CBEACON_TX
Maximum number of CBEACON that the head node can transmit.
@ T_BCK_CHOICE_SENSOR
Backoff time choose by the sensor node before to transmit the probe packet.
@ MAC_ADDR_SENSOR_POLLED
Mac address of the sensor node from which the head node want to receive the data packet.
@ MAC_ADDR_HN_CTSED
MAC address of the HN from which AUV want to receive DATA packet.
@ NUM_DATA_PCKS
Number of DATA packets that HN would like to transmit to the AUV.
@ MAX_CBEACON_TX_HN
Maximum number of CBEACON that the head node can transmit.
@ T_BCK_MAX_PROBE
Upper bound of the time interval from which the sensor node choice the backoff time before to transmi...
size_t num_DATA_pcks_Bits
number of bits used for num_DATA_pcks_ field on TRIGGER header
size_t mac_addr_sensor_polled_Bits
number of bits used for mac_addr_sensor_polled_ field on POLL header
size_t t_bck_min_rts_Bits
number of bits used for t_bck_min_rts_ field on CBEACON header
size_t t_bck_min_probe_Bits
number of bits used for t_bck_min_probe_ field on BEACON header
size_t mac_addr_HN_ctsed_Bits
number of bits used for mac_addr_HN_ctsed_ field on CTS header
void init()
Init the packer for uwUFetch prototocol.
size_t t_bck_max_probe_Bits
number of bits used for t_bck_max_probe_ field on BEACON header
size_t backoff_time_RTS_Bits
number of bits used for backoff_time_RTS_ field on TRIGGER header
size_t t_bck_choice_sensor_Bits
number of bits used for t_bck_choice_sensor_ field on PROBE header
size_t n_pck_sensor_want_tx_Bits
number of bits used for n_pck_sensor_want_tx_ field on PROBE header
size_t max_pck_want_rx_Bits
number of bits used for max_pck_want_rx_ field on TRIGGER header
size_t num_DATA_pcks_MAX_rx_Bits
number of bits used for num_DATA_pcks_MAX_rx_ field on RTSheader
packer_uwUFetch()
Constructor packer_uwUFetch class.
void printMyHdrFields(Packet *)
Method used for debug purposes.
size_t unpackMyHdr(unsigned char *, size_t, Packet *)
Method responsible to take the informations from the received buffer and store it into the headers of...
size_t max_cbeacon_tx_hn_Bits
number of bits used for max_cbeacon_tx_hn_ field on CBEACON header
size_t t_bck_max_rts_Bits
number of bits used for t_bck_max_rts_ field on CBEACON header
~packer_uwUFetch()
Destructor packer_uwUFetch class.
size_t n_pck_hn_want_tx_Bits
number of bits used for n_pck_hn_want_tx_ field on POLL header
void printMyHdrMap()
Method used for debug purposes.
size_t packMyHdr(Packet *, unsigned char *, size_t)
Method to transform the headers of UFetch protocol into a stream of bits.
Class exploited by the Uwal module to map an NS-Miracle packet into a bit stream, and vice-versa.
Definition packer.h:57
std::vector< size_t > n_bits
Vector of elements containing the indication of the number of bits to consider for each header field.
Definition packer.h:224
size_t put(unsigned char *buffer, size_t offset, void *val, size_t h)
Method used to map in a certain number of bits, contained in a buffer of chars, a given variable.
Definition packer.cpp:685
size_t get(unsigned char *buffer, size_t offset, void *val, size_t h)
Method used to retrieve a given variable from a certain number of bits contained in a buffer of chars...
Definition packer.cpp:673
int debug_
Flag to enable debug messages.
Definition packer.h:227
PackerUwUFetchClass class_module_packerUwUFetch
Content header of BEACON packet.
int t_max_bc_
maximum value in which the Node can choose his backoff time
int num_Max_CBEACON_tx_by_HN_
Maximum number of CBEACON that the HN can transmit after the BEACON packet.
int t_min_bc_
minimum value in which the Node can choose his backoff time
Content header of CBEACON packet.
int t_max_bc_
maximum value in which the Node can choose his backoff time
int num_Max_CBEACON_tx_by_HN_
Maximum number of CBEACON that the HN can transmit after the BEACON packet.
int t_min_bc_
minimum value in which the Node can choose his backoff time
Content header of CTS packet.
int mac_addr_HN_ctsed_
Mac address of the HN from which the AUV want to receive the DATA packets
int num_DATA_pcks_MAX_rx_
maximum number of packets that AUV want receive from HN
Content header of POLL packet.
int num_DATA_pcks_MAX_rx_
Maximum number of DATA packet that HN want to receive from the specific node that is being to poll.
int mac_addr_Node_polled_
Mac address of the NODE that the HN has polled and from which it want to receive a data packet.
Content header of PROBE packet.
int backoff_time_PROBE_
Backoff time chosen by the NODE for collision free.
int n_DATA_pcks_Node_tx_
number of packets that Node have to transmit at HN
Content header of RTS packet.
int num_DATA_pcks_
Number of packets that the HN want to transmit to the AUV.
int backoff_time_RTS_
Backoff time chosen by the HN for collision free.
Content header of TRIGGER packet.
int t_max_
maximum value in which the HN can choose his backoff time
int t_min_
minimum value in which the HN can choose his backoff time
int max_pck_want_rx_
Maximum number of pck that AUV want receive from sink.
#define HDR_BEACON_UFETCH(p)
alias defined to access the BEACON HEADER
#define HDR_POLL_UFETCH(p)
alias defined to access the POLL \ HEADER
#define HDR_CTS_UFETCH(p)
alias defined to access the CTS HEADER
#define HDR_CBEACON_UFETCH(p)
alias defined to access the CBEACON HEADER
#define HDR_TRIGGER_UFETCH(p)
alias defined to access the TRIGGER HEADER
#define HDR_PROBE_UFETCH(p)
alias defined to access the PROBE HEADER
#define HDR_RTS_UFETCH(p)
alias defined to access the RTS HEADER