DESERT 3.5.1
Loading...
Searching...
No Matches
packer-common.cpp
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#include "packer-common.h"
41
45static class PackerCOMMONClass : public TclClass
46{
47public:
49 : TclClass("NS2/COMMON/Packer")
50 {
51 }
52
53 TclObject *
54 create(int, const char *const *)
55 {
56 return (new packerCOMMON());
57 }
59
61 : packer(false)
62{
63
64 PTYPE_Bits = sizeof(packet_t);
65 SIZE_Bits = sizeof(int);
66 UID_Bits = sizeof(int);
67 ERROR_Bits = sizeof(int);
68 TIMESTAMP_Bits = sizeof(double);
70 PREV_HOP_Bits = sizeof(nsaddr_t);
71 NEXT_HOP_Bits = sizeof(nsaddr_t);
72 ADDR_TYPE_Bits = sizeof(int);
73 LAST_HOP_Bits = sizeof(nsaddr_t);
74 TXTIME_Bits = sizeof(double);
75
77 fecsize_Bits = 0;
78 iface_Bits = 0;
80 ts_arr_Bits = 0;
87
88 bind("PTYPE_Bits", (int *) &PTYPE_Bits);
89 bind("SIZE_Bits", (int *) &SIZE_Bits);
90 bind("UID_Bits", (int *) &UID_Bits);
91 bind("ERROR_Bits", (int *) &ERROR_Bits);
92 bind("TIMESTAMP_Bits", (int *) &TIMESTAMP_Bits);
93 bind("DIRECTION_Bits", (int *) &DIRECTION_Bits);
94 bind("PREV_HOP_Bits", (int *) &PREV_HOP_Bits);
95 bind("NEXT_HOP_Bits", (int *) &NEXT_HOP_Bits);
96 bind("ADDR_TYPE_Bits", (int *) &ADDR_TYPE_Bits);
97 bind("LAST_HOP_Bits", (int *) &LAST_HOP_Bits);
98 bind("TXTIME_Bits", (int *) &TXTIME_Bits);
99
100 bind("errbitcnt_Bits", (int *) &errbitcnt_Bits);
101 bind("fecsize_Bits", (int *) &fecsize_Bits);
102 bind("iface_Bits", (int *) &iface_Bits);
103 bind("src_rt_valid_Bits", (int *) &src_rt_valid_Bits);
104 bind("ts_arr_Bits", (int *) &ts_arr_Bits);
105 bind("aomdv_salvage_count_Bits", (int *) &aomdv_salvage_count_Bits);
106 bind("xmit_failure_Bits", (int *) &xmit_failure_Bits);
107 bind("xmit_failure_data_Bits", (int *) &xmit_failure_data_Bits);
108 bind("xmit_reason_Bits", (int *) &xmit_reason_Bits);
109 bind("num_forwards_Bits", (int *) &num_forwards_Bits);
110 bind("opt_num_forwards_Bits", (int *) &opt_num_forwards_Bits);
111
112 if (debug_)
113 cout << "Initialization (from constructor) of n_bits for the UWCOMMON "
114 "packer "
115 << endl;
116
117 n_bits.clear();
118 n_bits.assign(NUM_FIELDS, 0); // NUM_FIELDS zeroes as below
119
131
143}
144
148
149void
183
184size_t
185packerCOMMON::packMyHdr(Packet *p, unsigned char *buf, size_t offset)
186{
187
188 // Pointer to the COMMON packet header
189 hdr_cmn *ch = HDR_CMN(p);
190
191 // Common header fields useful for DESERT
192 offset += put(buf, offset, &(ch->ptype_), n_bits[PTYPE]);
193
194 offset += put(buf, offset, &(ch->size_), n_bits[SIZE]);
195
196 offset += put(buf, offset, &(ch->uid_), n_bits[UID]);
197
198 offset += put(buf, offset, &(ch->error_), n_bits[ERROR]);
199
200 offset += put(buf, offset, &(ch->ts_), n_bits[TIMESTAMP]);
201
202 offset += put(buf, offset, &(ch->direction_), n_bits[DIRECTION]);
203
204 offset += put(buf, offset, &(ch->prev_hop_), n_bits[PREV_HOP]);
205
206 offset += put(buf, offset, &(ch->next_hop_), n_bits[NEXT_HOP]);
207
208 offset += put(buf, offset, &(ch->addr_type_), n_bits[ADDR_TYPE]);
209
210 offset += put(buf, offset, &(ch->last_hop_), n_bits[LAST_HOP]);
211
212 offset += put(buf, offset, &(ch->txtime_), n_bits[TXTIME]);
213
214 // Other common header fields (maybe useful for future usage)
215 offset += put(buf, offset, &(ch->errbitcnt_), n_bits[errbitcnt_]);
216
217 offset += put(buf, offset, &(ch->fecsize_), n_bits[fecsize_]);
218
219 offset += put(buf, offset, &(ch->iface_), n_bits[iface_]);
220
221 offset += put(buf, offset, &(ch->src_rt_valid), n_bits[src_rt_valid]);
222
223 offset += put(buf, offset, &(ch->ts_arr_), n_bits[ts_arr_]);
224
225 offset += put(buf,
226 offset,
227 &(ch->aomdv_salvage_count_),
229
230 offset += put(buf, offset, &(ch->xmit_failure_), n_bits[xmit_failure_]);
231
232 offset += put(
233 buf, offset, &(ch->xmit_failure_data_), n_bits[xmit_failure_data_]);
234
235 offset += put(buf, offset, &(ch->xmit_reason_), n_bits[xmit_reason_]);
236
237 offset += put(buf, offset, &(ch->num_forwards_), n_bits[num_forwards_]);
238
239 offset += put(
240 buf, offset, &(ch->opt_num_forwards_), n_bits[opt_num_forwards_]);
241
242 if (debug_) {
243 printf("\033[0;43;30m TX COMMON packer hdr \033[0m \n");
245 }
246
247 return offset;
248}
249
250size_t
251packerCOMMON::unpackMyHdr(unsigned char *buf, size_t offset, Packet *p)
252{
253 // Pointer to the COMMON packet header
254 hdr_cmn *ch = HDR_CMN(p);
255
256 // Common header fields useful for DESERT
257 if (n_bits[PTYPE]) {
258 memset(&(ch->ptype_), 0, sizeof(ch->ptype_));
259 offset += get(buf, offset, &(ch->ptype_), n_bits[PTYPE]);
260 }
261
262 if (n_bits[SIZE]) {
263 memset(&(ch->size_), 0, sizeof(ch->size_));
264 offset += get(buf, offset, &(ch->size_), n_bits[SIZE]);
265 ch->size_ = restoreSignedValue(ch->size_, n_bits[SIZE]);
266 }
267
268 if (n_bits[UID]) {
269 memset(&(ch->uid_), 0, sizeof(ch->uid_));
270 offset += get(buf, offset, &(ch->uid_), n_bits[UID]);
271 ch->uid_ = restoreSignedValue(ch->uid_, n_bits[UID]);
272 }
273
274 if (n_bits[ERROR]) {
275 memset(&(ch->error_), 0, sizeof(ch->error_));
276 offset += get(buf, offset, &(ch->error_), n_bits[ERROR]);
277 ch->error_ = restoreSignedValue(ch->error_, n_bits[ERROR]);
278 }
279
280 if (n_bits[TIMESTAMP]) {
281 memset(&(ch->ts_), 0, sizeof(ch->ts_));
282 offset += get(buf, offset, &(ch->ts_), n_bits[TIMESTAMP]);
283 }
284
285 if (n_bits[DIRECTION]) {
286 memset(&(ch->direction_), 0, sizeof(ch->direction_));
287 offset += get(buf, offset, &(ch->direction_), n_bits[DIRECTION]);
288 ch->direction_ = restoreSignedValue(ch->direction_, n_bits[DIRECTION]);
289 }
290
291 if (n_bits[PREV_HOP]) {
292 memset(&(ch->prev_hop_), 0, sizeof(ch->prev_hop_));
293 offset += get(buf, offset, &(ch->prev_hop_), n_bits[PREV_HOP]);
294 ch->prev_hop_ = restoreSignedValue(ch->prev_hop_, n_bits[PREV_HOP]);
295 }
296
297 if (n_bits[NEXT_HOP]) {
298 memset(&(ch->next_hop_), 0, sizeof(ch->next_hop_));
299 offset += get(buf, offset, &(ch->next_hop_), n_bits[NEXT_HOP]);
300 ch->next_hop_ = restoreSignedValue(ch->next_hop_, n_bits[NEXT_HOP]);
301 }
302
303 if (n_bits[ADDR_TYPE]) {
304 memset(&(ch->addr_type_), 0, sizeof(ch->addr_type_));
305 offset += get(buf, offset, &(ch->addr_type_), n_bits[ADDR_TYPE]);
306 ch->addr_type_ = restoreSignedValue(ch->addr_type_, n_bits[ADDR_TYPE]);
307 }
308
309 if (n_bits[LAST_HOP]) {
310 memset(&(ch->last_hop_), 0, sizeof(ch->last_hop_));
311 offset += get(buf, offset, &(ch->last_hop_), n_bits[LAST_HOP]);
312 ch->last_hop_ = restoreSignedValue(ch->last_hop_, n_bits[LAST_HOP]);
313 }
314
315 if (n_bits[TXTIME]) {
316 memset(&(ch->txtime_), 0, sizeof(ch->txtime_));
317 offset += get(buf, offset, &(ch->txtime_), n_bits[TXTIME]);
318 }
319
320 // Other common header fields (maybe useful for future usage)
321 memset(&(ch->errbitcnt_), 0, sizeof(ch->errbitcnt_));
322 offset += get(buf, offset, &(ch->errbitcnt_), n_bits[errbitcnt_]);
323 ch->errbitcnt_ = restoreSignedValue(ch->errbitcnt_, n_bits[errbitcnt_]);
324
325 memset(&(ch->fecsize_), 0, sizeof(ch->fecsize_));
326 offset += get(buf, offset, &(ch->fecsize_), n_bits[fecsize_]);
327 ch->fecsize_ = restoreSignedValue(ch->fecsize_, n_bits[fecsize_]);
328
329 memset(&(ch->iface_), 0, sizeof(ch->iface_));
330 offset += get(buf, offset, &(ch->iface_), n_bits[iface_]);
331 ch->iface_ = restoreSignedValue(ch->iface_, n_bits[iface_]);
332
333 memset(&(ch->src_rt_valid), 0, sizeof(ch->src_rt_valid));
334 offset += get(buf, offset, &(ch->src_rt_valid), n_bits[src_rt_valid]);
335
336 memset(&(ch->ts_arr_), 0, sizeof(ch->ts_arr_));
337 offset += get(buf, offset, &(ch->ts_arr_), n_bits[ts_arr_]);
338
339 memset(&(ch->aomdv_salvage_count_), 0, sizeof(ch->aomdv_salvage_count_));
340 offset += get(buf,
341 offset,
342 &(ch->aomdv_salvage_count_),
344 ch->aomdv_salvage_count_ = restoreSignedValue(
345 ch->aomdv_salvage_count_, n_bits[aomdv_salvage_count_]);
346
347 memset(&(ch->xmit_failure_), 0, sizeof(ch->xmit_failure_));
348 offset += get(buf, offset, &(ch->xmit_failure_), n_bits[xmit_failure_]);
349
350 memset(&(ch->xmit_failure_data_), 0, sizeof(ch->xmit_failure_data_));
351 offset += get(
352 buf, offset, &(ch->xmit_failure_data_), n_bits[xmit_failure_data_]);
353
354 memset(&(ch->xmit_reason_), 0, sizeof(ch->xmit_reason_));
355 offset += get(buf, offset, &(ch->xmit_reason_), n_bits[xmit_reason_]);
356 ch->xmit_reason_ =
357 restoreSignedValue(ch->xmit_reason_, n_bits[xmit_reason_]);
358
359 memset(&(ch->num_forwards_), 0, sizeof(ch->num_forwards_));
360 offset += get(buf, offset, &(ch->num_forwards_), n_bits[num_forwards_]);
361
362 memset(&(ch->opt_num_forwards_), 0, sizeof(ch->opt_num_forwards_));
363 offset += get(
364 buf, offset, &(ch->opt_num_forwards_), n_bits[opt_num_forwards_]);
365
366 if (debug_) {
367 printf("\033[0;43;30m RX COMMON packer hdr \033[0m \n");
369 }
370
371 return offset;
372}
373
374void
376{
377 std::cout << "\033[0;43;30m"
378 << " Packer Name "
379 << "\033[0m"
380 << " UWCOMMON" << std::endl;
381 std::cout << "\033[0;43;30m 1st field "
382 << "\033[0m"
383 << " ptype_: " << PTYPE_Bits << " bits" << std::endl;
384 std::cout << "\033[0;43;30m 2st field "
385 << "\033[0m"
386 << " size_: " << SIZE_Bits << " bits" << std::endl;
387 std::cout << "\033[0;43;30m 3st field "
388 << "\033[0m"
389 << " uid_: " << UID_Bits << " bits" << std::endl;
390 std::cout << "\033[0;43;30m 4st field "
391 << "\033[0m"
392 << " error_: " << ERROR_Bits << " bits" << std::endl;
393 std::cout << "\033[0;43;30m 5st field "
394 << "\033[0m"
395 << " ts_: " << TIMESTAMP_Bits << " bits" << std::endl;
396 std::cout << "\033[0;43;30m 6st field "
397 << "\033[0m"
398 << " direction_: " << DIRECTION_Bits << " bits" << std::endl;
399 std::cout << "\033[0;43;30m 7st field "
400 << "\033[0m"
401 << " prev_hop_: " << PREV_HOP_Bits << " bits" << std::endl;
402 std::cout << "\033[0;43;30m 8st field "
403 << "\033[0m"
404 << " next_hop_: " << NEXT_HOP_Bits << " bits" << std::endl;
405 std::cout << "\033[0;43;30m 9st field "
406 << "\033[0m"
407 << " addr_type_: " << ADDR_TYPE_Bits << " bits" << std::endl;
408 std::cout << "\033[0;43;30m 10st field "
409 << "\033[0m"
410 << " last_hop_: " << LAST_HOP_Bits << " bits" << std::endl;
411 std::cout << "\033[0;43;30m 11st field "
412 << "\033[0m"
413 << " txtime_: " << TXTIME_Bits << " bits" << std::endl;
414 std::cout << "\033[0;43;30m 12st field "
415 << "\033[0m"
416 << " errbitcnt_: " << errbitcnt_Bits << " bits" << std::endl;
417 std::cout << "\033[0;43;30m 13st field "
418 << "\033[0m"
419 << " fecsize_: " << fecsize_Bits << " bits" << std::endl;
420 std::cout << "\033[0;43;30m 14st field "
421 << "\033[0m"
422 << " iface_: " << iface_Bits << " bits" << std::endl;
423 std::cout << "\033[0;43;30m 15st field "
424 << "\033[0m"
425 << " src_rt_valid: " << src_rt_valid_Bits << " bits" << std::endl;
426 std::cout << "\033[0;43;30m 16st field "
427 << "\033[0m"
428 << " ts_arr_: " << ts_arr_Bits << " bits" << std::endl;
429 std::cout << "\033[0;43;30m 17st field "
430 << "\033[0m"
431 << " aomdv_salvage_count_: " << aomdv_salvage_count_Bits
432 << " bits" << std::endl;
433 std::cout << "\033[0;43;30m 18st field "
434 << "\033[0m"
435 << " xmit_failure_: " << xmit_failure_Bits << " bits"
436 << std::endl;
437 std::cout << "\033[0;43;30m 19st field "
438 << "\033[0m"
439 << " xmit_failure_data: " << xmit_failure_data_Bits << " bits"
440 << std::endl;
441 std::cout << "\033[0;43;30m 20st field "
442 << "\033[0m"
443 << " xmit_reason: " << xmit_reason_Bits << " bits" << std::endl;
444 std::cout << "\033[0;43;30m 21st field "
445 << "\033[0m"
446 << " num_forwards: " << num_forwards_Bits << " bits" << std::endl;
447 std::cout << "\033[0;43;30m 22st field "
448 << "\033[0m"
449 << " opt_num_forwards: " << opt_num_forwards_Bits << " bits"
450 << std::endl;
451}
452
453void
455{
456
457 hdr_cmn *ch = HDR_CMN(p);
458
459 if (n_bits[PTYPE])
460 cout << "\033[0;43;30m ptype :\033[0m " << ch->ptype_ << " "
461 << hex_bytes((size_t) ch->ptype_, n_bits[PTYPE]) << std::endl;
462 if (n_bits[SIZE])
463 cout << "\033[0;43;30m size :\033[0m " << ch->size_ << " "
464 << hex_bytes(ch->size_, n_bits[SIZE]) << std::endl;
465 if (n_bits[UID])
466 cout << "\033[0;43;30m uid :\033[0m " << ch->uid_ << " "
467 << hex_bytes(ch->uid_, n_bits[UID]) << std::endl;
468 if (n_bits[ERROR])
469 cout << "\033[0;43;30m error :\033[0m " << ch->error_ << " "
470 << hex_bytes(ch->error_, n_bits[3]) << std::endl;
471 if (n_bits[4] != 0)
472 cout << "\033[0;43;30m ts :\033[0m " << ch->ts_ << " "
473 << hex_bytes(ch->ts_) << std::endl;
474 if (n_bits[5] != 0)
475 cout << "\033[0;43;30m direction:\033[0m " << ch->direction_ << " "
476 << hex_bytes(ch->direction_, n_bits[5]) << std::endl;
477 if (n_bits[6] != 0)
478 cout << "\033[0;43;30m prev_hop:\033[0m " << ch->prev_hop_ << " "
479 << hex_bytes(ch->prev_hop_, n_bits[6]) << std::endl;
480 if (n_bits[7] != 0)
481 cout << "\033[0;43;30m next_hop:\033[0m " << ch->next_hop_ << " "
482 << hex_bytes(ch->next_hop_, n_bits[7]) << std::endl;
483 if (n_bits[8] != 0)
484 cout << "\033[0;43;30m addr_type:\033[0m " << ch->addr_type_ << " "
485 << hex_bytes(ch->addr_type_, n_bits[8]) << std::endl;
486 if (n_bits[9] != 0)
487 cout << "\033[0;43;30m last_hop:\033[0m " << ch->last_hop_ << " "
488 << hex_bytes(ch->last_hop_, n_bits[9]) << std::endl;
489 if (n_bits[10] != 0)
490 cout << "\033[0;43;30m txtime:\033[0m " << ch->txtime_ << " "
491 << hex_bytes(ch->txtime_) << std::endl;
492 if (n_bits[11] != 0)
493 cout << "\033[0;43;30m errbitcnt:\033[0m " << ch->errbitcnt_ << " "
494 << hex_bytes(ch->errbitcnt_, n_bits[11]) << std::endl;
495 if (n_bits[12] != 0)
496 cout << "\033[0;43;30m fecsize:\033[0m " << ch->fecsize_ << " "
497 << hex_bytes(ch->fecsize_, n_bits[12]) << std::endl;
498 if (n_bits[13] != 0)
499 cout << "\033[0;43;30m iface:\033[0m " << ch->iface_ << " "
500 << hex_bytes(ch->iface_, n_bits[13]) << std::endl;
501 // if (n_bits[14] != 0) cout << "\033[0;43;30m src_rt_valid:\033[0m " <<
502 // ch->src_rt_valid_ << " " << hex_bytes(ch->src_rt_valid_, n_bits[14]) <<
503 // std::endl;
504 if (n_bits[15] != 0)
505 cout << "\033[0;43;30m ts_arr:\033[0m " << ch->ts_arr_ << " "
506 << hex_bytes(ch->ts_arr_) << std::endl;
507 if (n_bits[16] != 0)
508 cout << "\033[0;43;30m aomdv_salvage_count:\033[0m "
509 << ch->aomdv_salvage_count_ << " "
510 << hex_bytes(ch->aomdv_salvage_count_, n_bits[16]) << std::endl;
511 // if (n_bits[17] != 0) cout << "\033[0;43;30m xmit_failure_:\033[0m " <<
512 // ch->xmit_failure_ << " " << hex_bytes(ch->xmit_failure_, n_bits[17]) <<
513 // std::endl;
514 // if (n_bits[18] != 0) cout << "\033[0;43;30m xmit_failure_data_:\033[0m "
515 // << ch->xmit_failure_data_ << " " << hex_bytes(ch->xmit_failure_data_,
516 // n_bits[18]) << std::endl;
517 if (n_bits[19] != 0)
518 cout << "\033[0;43;30m xmit_reason_:\033[0m " << ch->xmit_reason_ << " "
519 << hex_bytes(ch->xmit_reason_, n_bits[19]) << std::endl;
520 if (n_bits[20] != 0)
521 cout << "\033[0;43;30m num_forwards_:\033[0m " << ch->num_forwards_
522 << " " << hex_bytes(ch->num_forwards_, n_bits[20]) << std::endl;
523 if (n_bits[21] != 0)
524 cout << "\033[0;43;30m opt_num_forwards_:\033[0m "
525 << ch->opt_num_forwards_ << " "
526 << hex_bytes(ch->opt_num_forwards_, n_bits[21]) << std::endl;
527 // cout << "\033[0;41;30m packerMAC::printMyHdrField WARNING \033[0m, Field
528 // index " << field << " does not exist or its printing is not implemented."
529 // << std::endl;
530}
Class to create the Otcl shadow object for an object of the class packer.
TclObject * create(int, const char *const *)
Class to map a ns2 mac header into a bit stream, and vice-versa.
size_t aomdv_salvage_count_Bits
Bit length of the ts_arr_ field to be put in the header stream of bits.
size_t TIMESTAMP_Bits
Bit length of the error_ field to be put in the header stream of bits.
size_t PREV_HOP_Bits
Bit length of the direction_ field to be put in the header stream of bits.
size_t TXTIME_Bits
Bit length of the last_hop_ field to be put in the header stream of bits.
size_t xmit_failure_data_Bits
Bit length of the xmit_failure_ field to be put in the header stream of bits.
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...
void printMyHdrFields(Packet *)
Method used for debug purposes.
size_t SIZE_Bits
Bit length of the ptype_ field to be put in the header stream of bits.
size_t src_rt_valid_Bits
Bit length of the iface_ field to be put in the header stream of bits.
size_t DIRECTION_Bits
Bit length of the ts_ field to be put in the header stream of bits.
size_t xmit_failure_Bits
Bit length of the aomdv_salvage_count_ field to be put in the header stream of bits.
size_t ADDR_TYPE_Bits
Bit length of the next_hop_ field to be put in the header stream of bits.
packerCOMMON()
Class constructor.
size_t num_forwards_Bits
Bit length of the xmit_reason_ field to be put in the header stream of bits.
void printMyHdrMap()
Method used for debug purposes.
size_t ERROR_Bits
Bit length of the uid_ field to be put in the header stream of bits.
~packerCOMMON()
Class destructor.
size_t xmit_reason_Bits
Bit length of the xmit_failure_data_ field to be put in the header stream of bits.
size_t fecsize_Bits
Bit length of the errbitcnt_ field to be put in the header stream of bits.
size_t packMyHdr(Packet *, unsigned char *, size_t)
Method to transform the headers into a stream of bits.
size_t NEXT_HOP_Bits
Bit length of the prev_hop_ field to be put in the header stream of bits.
size_t UID_Bits
Bit length of the size_ field to be put in the header stream of bits.
size_t ts_arr_Bits
Bit length of the src_rt_valid_ field to be put in the header stream of bits.
void init()
Init the Packer.
size_t LAST_HOP_Bits
Bit length of the addr_type_ field to be put in the header stream of bits.
size_t iface_Bits
Bit length of the fecsize_ field to be put in the header stream of bits.
size_t opt_num_forwards_Bits
Bit length of the num_forwards_ field to be put in the header stream of bits.
size_t errbitcnt_Bits
Bit length of the txtime_ field to be put in the header 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
static std::string hex_bytes(float)
Definition packer.cpp:752
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
static T restoreSignedValue(T _header_field, const uint32_t &_num_compressed_bits)
Definition packer.h:174
int debug_
Flag to enable debug messages.
Definition packer.h:227
PackerCOMMONClass class_module_packerCOMMON
Header of the class responsible to map the ns2 common header into a bit stream, and vice-versa.
#define NUM_FIELDS