DESERT 3.5.1
Loading...
Searching...
No Matches
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
71
72
73class Uwal;
74
79class TxFrameTimer : public TimerHandler
80{
81public:
89 : TimerHandler()
90 {
91 pUwal_ = pUwal;
92 }
93
94protected:
100 virtual void expire(Event *e);
101
105};
106
111class Uwal : public MPhy
112{
118 friend class TxFrameTimer;
119
120public:
124 Uwal();
125
129 ~Uwal();
130
137 virtual int recvSyncClMsg(ClMessage *m);
138
146 virtual void recv(Packet *);
147
156 virtual int command(int, const char *const *);
157
158 size_t
160 {
161 return PSDU;
162 }
163
164protected:
165 int nodeID;
166 unsigned int pkt_counter;
168 size_t PSDU;
169 string dummyStr;
171 int debug_;
173 std::queue<Packet *>
175 std::queue<Packet *>
177 std::queue<Packet *> sendUpFrames;
179 std::queue<Packet *> sendUpPkts;
181 list<PERListElement> PERList;
183 std::map<RxFrameSetKey, RxFrameSet>
188 void ALqueueManager();
194 void initializeHdr(Packet *, unsigned int);
199 void fragmentPkt(Packet *);
205 void reassembleFrames(Packet *);
209 void checkRxFrameSet();
210
216 virtual void startTx(Packet *);
217
226 virtual void endTx(Packet *);
227
236 virtual void startRx(Packet *);
237
243 virtual void endRx(Packet *);
244
247 virtual double
249 {
250 return -1;
251 }
252
255 virtual int
257 {
258 return -1;
259 }
265 virtual bool isInPERList(int mac_addr);
272 virtual double getPERfromID(int mac_addr);
273
274private:
285}; /* class Uwal */
286
287#endif /* UWAL_H */
The class used by Uwal to handle simulator's event expirations; it is exploited to schedule the sendD...
Definition uwal.h:80
virtual void expire(Event *e)
Method to handle the expiration of a given event.
Definition uwal.cpp:741
Uwal * pUwal_
Pointer to an Uwal object.
Definition uwal.h:102
TxFrameTimer(Uwal *pUwal)
Class constructor.
Definition uwal.h:88
The main class implementing the module used to implement the adaptation layer between ns2/NS-Miracle ...
Definition uwal.h:112
virtual void endRx(Packet *)
Method to end a packet reception.
Definition uwal.cpp:734
void checkRxFrameSet()
Method responsible to check for errors the received frames.
Definition uwal.cpp:615
std::queue< Packet * > sendUpPkts
queue of the packets to send up to the upper protocols
Definition uwal.h:179
int debug_
String containing dummy characters to be used as padding chars if necessary.
Definition uwal.h:171
virtual int recvSyncClMsg(ClMessage *m)
Method to handle the reception of a synchronous crosslayer message.
Definition uwal.cpp:577
virtual int command(int, const char *const *)
Method to map tcl commands into c++ methods.
Definition uwal.cpp:103
string dummyStr
Definition uwal.h:169
int nodeID
Node ID.
Definition uwal.h:165
Uwal()
Class constructor.
Definition uwal.cpp:65
packer * pPacker
Pointer to the packer of the protocol headers.
Definition uwal.h:167
std::queue< Packet * > sendDownPkts
queue of the packet to send down to the modem
Definition uwal.h:174
virtual void endTx(Packet *)
Method to end a packet transmission.
Definition uwal.cpp:722
double interframe_period
Time period [s] between two successive frame to be sent down.
Definition uwal.h:276
void ALqueueManager()
Method responsible to manage the queueing system of Adaptation Layer.
Definition uwal.cpp:237
void initializeHdr(Packet *, unsigned int)
Method responsible to initialize the headers of the packet.
Definition uwal.cpp:275
size_t getPSDU()
Definition uwal.h:159
TxFrameTimer InterframeTmr
Object of the class TxFrameTimer.
Definition uwal.h:275
unsigned int pkt_counter
Counter for the pktID to set in TX.
Definition uwal.h:166
std::queue< Packet * > sendUpFrames
queue of the frames to send up to the upper protocols
Definition uwal.h:177
virtual int getModulationType(Packet *)
Unused method at the moment.
Definition uwal.h:256
bool has_tap_clmsg
True if received a ClMessage from uwTAP.
Definition uwal.h:283
int force_endTx_
0 not force, otherwise force endTx
Definition uwal.h:281
~Uwal()
Class destructor.
Definition uwal.cpp:97
virtual double getPERfromID(int mac_addr)
Method to search for the PER associated with a particular MAC address.
Definition uwal.cpp:181
list< PERListElement > PERList
PER list (couple of ID of the node and Packet Error Rate associated )
Definition uwal.h:181
int frame_padding
Flag to determine if perfoming bit padding up to PSDU size.
Definition uwal.h:279
virtual double getTxDuration(Packet *)
Unused method at the moment.
Definition uwal.h:248
std::queue< Packet * > sendDownFrames
queue of the frames to send down
Definition uwal.h:176
virtual void recv(Packet *)
Method to handle the reception of packets arriving from the upper layers of the network simulator.
Definition uwal.cpp:197
virtual void startRx(Packet *)
Method to start a packet reception.
Definition uwal.cpp:728
void fragmentPkt(Packet *)
Method responsible to fragment the packet.
Definition uwal.cpp:293
void reassembleFrames(Packet *)
Method responsible to reassemble the various fragments in a unique packets.
Definition uwal.cpp:457
std::map< RxFrameSetKey, RxFrameSet > sendUpFrameSet
map of the frames to send up
Definition uwal.h:184
double frame_set_validity
Time of validity of a frame set.
Definition uwal.h:278
virtual bool isInPERList(int mac_addr)
Method to search a MAC address in the PER List.
Definition uwal.cpp:165
virtual void startTx(Packet *)
Method to start the packet transmission.
Definition uwal.cpp:707
size_t PSDU
size of the PSDU
Definition uwal.h:168
Class exploited by the Uwal module to map an NS-Miracle packet into a bit stream, and vice-versa.
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.
int node_ID
Definition uwal.h:67
double per
Definition uwal.h:68
struct PERListElement pl_element