DESERT 4.0.0
uwal.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
38#ifndef UWAL_H
39#define UWAL_H
40
41#include "frame-set.h"
42#include "hdr-uwal.h"
43#include "packer.h"
44
45#include <mac.h>
46#include <mphy.h>
47
48#include <cmath>
49#include <cstring>
50#include <errno.h>
51#include <fcntl.h>
52#include <fstream>
53#include <iostream>
54#include <map>
55#include <queue>
56#include <rng.h>
57#include <sstream>
58#include <stdio.h>
59#include <stdlib.h>
60#include <string.h>
61#include <sys/stat.h>
62#include <sys/types.h>
63#include <time.h>
64#include <unistd.h>
65
66typedef struct PERListElement {
68 double per;
70
71class Uwal;
72
77class TxFrameTimer : public TimerHandler
78{
79public:
87 : TimerHandler()
88 {
89 pUwal_ = pUwal;
90 }
91
92protected:
98 virtual void expire(Event *e);
99
103};
104
109class Uwal : public MPhy
110{
116 friend class TxFrameTimer;
117
118public:
122 Uwal();
123
127 ~Uwal();
128
135 virtual int recvSyncClMsg(ClMessage *m);
136
144 virtual void recv(Packet *);
145
154 virtual int command(int, const char *const *);
155
156 size_t
158 {
159 return PSDU;
160 }
161
162protected:
163 int nodeID;
164 unsigned int pkt_counter;
166 size_t PSDU;
167 string dummyStr;
169 int debug_;
171 std::queue<Packet *>
173 std::queue<Packet *>
175 std::queue<Packet *> sendUpFrames;
177 std::queue<Packet *> sendUpPkts;
179 list<PERListElement> PERList;
181 std::map<RxFrameSetKey, RxFrameSet>
186 void ALqueueManager();
192 void initializeHdr(Packet *, unsigned int);
197 void fragmentPkt(Packet *);
203 void reassembleFrames(Packet *);
207 void checkRxFrameSet();
208
214 virtual void startTx(Packet *);
215
224 virtual void endTx(Packet *);
225
234 virtual void startRx(Packet *);
235
241 virtual void endRx(Packet *);
242
245 virtual double
247 {
248 return -1;
249 }
250
253 virtual int
255 {
256 return -1;
257 }
263 virtual bool isInPERList(int mac_addr);
270 virtual double getPERfromID(int mac_addr);
271
272private:
283}; /* class Uwal */
284
285#endif /* UWAL_H */
Definition uwal.h:78
virtual void expire(Event *e)
Definition uwal.cpp:741
Uwal * pUwal_
Definition uwal.h:100
TxFrameTimer(Uwal *pUwal)
Definition uwal.h:86
Definition uwal.h:110
virtual void endRx(Packet *)
Definition uwal.cpp:734
void checkRxFrameSet()
Definition uwal.cpp:615
std::queue< Packet * > sendUpPkts
Definition uwal.h:177
int debug_
Definition uwal.h:169
virtual int recvSyncClMsg(ClMessage *m)
Definition uwal.cpp:577
virtual int command(int, const char *const *)
Definition uwal.cpp:103
string dummyStr
Definition uwal.h:167
int nodeID
Definition uwal.h:163
Uwal()
Definition uwal.cpp:65
packer * pPacker
Definition uwal.h:165
std::queue< Packet * > sendDownPkts
Definition uwal.h:172
virtual void endTx(Packet *)
Definition uwal.cpp:722
double interframe_period
Definition uwal.h:274
void ALqueueManager()
Definition uwal.cpp:237
void initializeHdr(Packet *, unsigned int)
Definition uwal.cpp:275
size_t getPSDU()
Definition uwal.h:157
TxFrameTimer InterframeTmr
Definition uwal.h:273
unsigned int pkt_counter
Definition uwal.h:164
std::queue< Packet * > sendUpFrames
Definition uwal.h:175
virtual int getModulationType(Packet *)
Definition uwal.h:254
bool has_tap_clmsg
Definition uwal.h:281
int force_endTx_
Definition uwal.h:279
~Uwal()
Definition uwal.cpp:97
virtual double getPERfromID(int mac_addr)
Definition uwal.cpp:181
list< PERListElement > PERList
Definition uwal.h:179
int frame_padding
Definition uwal.h:277
virtual double getTxDuration(Packet *)
Definition uwal.h:246
std::queue< Packet * > sendDownFrames
Definition uwal.h:174
virtual void recv(Packet *)
Definition uwal.cpp:197
virtual void startRx(Packet *)
Definition uwal.cpp:728
void fragmentPkt(Packet *)
Definition uwal.cpp:293
void reassembleFrames(Packet *)
Definition uwal.cpp:457
std::map< RxFrameSetKey, RxFrameSet > sendUpFrameSet
Definition uwal.h:182
double frame_set_validity
Definition uwal.h:276
virtual bool isInPERList(int mac_addr)
Definition uwal.cpp:165
virtual void startTx(Packet *)
Definition uwal.cpp:707
size_t PSDU
Definition uwal.h:166
Definition packer.h:57
Header of the classes defining the frame elements (key and set) exploited by Uwal objects to reassebl...
Header of the class providing the Uwal header's description.
Header of the class responsible to map an NS-Miracle packet into a bit stream, and vice-versa.
Definition uwal.h:66
int node_ID
Definition uwal.h:67
double per
Definition uwal.h:68
struct PERListElement pl_element