DESERT 3.5.1
Loading...
Searching...
No Matches
sun-ipr-common-structures.h
Go to the documentation of this file.
1//
2// Copyright (c) 2021 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 SUN_COMMON_STRUCTURES_H
41#define SUN_COMMON_STRUCTURES_H
42
43#define STACK_TRACE 0
44#define MIN_SNR -9999.9
45// From ip-routing.h
46#define DROP_DEST_UNREACHABLE_REASON \
47 "DUR"
49#define DROP_PATH_ALREADY_PROCESSED \
50 "PAP"
51#define DROP_MAX_NUMBER_OF_HOP_IN_LIST_REACHED \
52 "MHR"
53#define DROP_WRONG_NODE_PATH_EST \
54 "WNP"
56// Drop reasons for Data packets.
57#define DROP_DATA_HOPS_LENGTH_EQUALS_ZERO \
58 "DHZ"
60// Drops reasons for Path Establishment Search packets
61#define DROP_PATH_ESTABLISHMENT_SEARCH_PACKET_HOP_LIST_FULL \
62 "PSF"
63#define DROP_PATH_ESTABLISHMENT_SEARCH_PACKET_ALREADY_PROCESSED \
64 "PSA"
65#define DROP_PATH_ESTABLISHMENT_SEARCH_PACKET_WRONG_CHECKSUM \
66 "PWC"
67#define DROP_PATH_ESTABLISHMENT_SEARCH_PACKET_NO_ROUTE_TO_DESTINATION \
68 "PNR"
70// Drops reasons for Path Establishment answer packets
71#define DROP_PATH_ESTABLISHMENT_ANSWER_PACKET_GARBAGE \
72 "PAG"
73#define DROP_PATH_ESTABLISHMENT_ANSWER_NODE_ROUTING_TABLE_FULL \
74 "PAF"
76// Drop reasons for Sink Node
77#define DROP_SINK_PACKET_TYPE_UNSOPPORTED \
78 "SPU"
80// Others
81#define DROP_PACKET_NOT_FOR_ME \
82 "PNM"
83#define DROP_PACKET_WITHOUT_DIRECTION \
84 "PWD"
85#define DROP_BROKEN_LINK_DROP \
86 "BLD"
87#define DROP_BUFFER_IS_FULL \
88 "BIF"
90#include "packet.h"
91
92#include <iostream>
93#include <sstream>
94
95static const int MAX_HOP_NUMBER =
96 5;
98static int sunuid_ = 0;
103typedef struct buffer_element {
104
105 Packet *p_;
108 double t_last_tx_;
113 unsigned int retx_;
114
116 {
117 }
118 buffer_element(Packet *_p, int _id_pkt_ = 0,
119 double _t_reception_ = Scheduler::instance().clock(),
120 double _t_last_tx_ = 0, int _num_retx_ = 0)
121 : p_(_p)
122 , id_pkt_(_id_pkt_)
123 , t_reception_(_t_reception_)
124 , t_last_tx_(_t_last_tx_)
125 , num_attempts_(_num_retx_)
126 , retx_(0)
127 {
128 }
131
132#endif // SUN_COMMON_STRUCTURES_H
buffer_element describes an entry in the buffer used by SUN.
buffer_element(Packet *_p, int _id_pkt_=0, double _t_reception_=Scheduler::instance().clock(), double _t_last_tx_=0, int _num_retx_=0)
Constructor for buffer_element.
unsigned int retx_
Real retransmission counter: incremented only if packet is sent donwlayer.
Packet * p_
Pointer to the packet buffered.
double t_last_tx_
Time instant of the last transmission attempt.
int id_pkt_
ID of the packet buffered.
double t_reception_
Time instant in which the packet was buffered.
int num_attempts_
Number of transmission attempts.
buffer_element()
Constructor for buffer_element.
static int sunuid_
Unique identifier for UWSUN packets.
static const int MAX_HOP_NUMBER
Maximum number of hops contained in a SUN Path Establishment packet.