DESERT 4.0.0
uwtdma.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
40#ifndef UWTDMA_H
41#define UWTDMA_H
42
43#include <assert.h>
44#include <deque>
45#include <fstream>
46#include <iostream>
47#include <mmac.h>
48#include <queue>
49#include <sstream>
50#include <sys/time.h>
51
52#define UW_TDMA_STATUS_MY_SLOT 1
53#define UW_TDMA_STATUS_NOT_MY_SLOT 2
55class UwTDMA;
56
62class UwTDMATimer : public TimerHandler
63{
64
65public:
71 : TimerHandler()
72 {
73 assert(m != NULL);
74 module = m;
75 }
76
77protected:
82 virtual void expire(Event *e);
83 UwTDMA *module;
84};
85
89class UwTDMA : public MMac
90{
91
92 friend class UwTDMATimer;
93
94public:
98 UwTDMA();
99
103 virtual ~UwTDMA();
104
112 virtual int recvSyncClMsg(ClMessage *m);
113
114protected:
118 virtual void txData();
123 virtual void stateTxData();
127 virtual void changeStatus();
132 virtual void start(double delay);
136 virtual void stop();
142 virtual void recvFromUpperLayers(Packet *p);
148 virtual void Phy2MacEndRx(Packet *p);
154 virtual void Phy2MacStartRx(const Packet *p);
160 virtual void Mac2PhyStartTx(Packet *p);
166 virtual void Phy2MacEndTx(const Packet *p);
172 virtual void rxPacketNotForMe(Packet *p);
178 virtual void initPkt(Packet *p);
183 inline unsigned long int
185 {
186 return time(NULL);
187 }
188
200 virtual int command(int argc, const char *const *argv);
205
209 int debug_;
221 double guard_time;
223 double start_time;
225 std::deque<Packet *> buffer;
226 std::ofstream out_file_stats;
227 bool enable;
228
236 std::string name_label_;
241};
242
243#endif
Definition uwtdma.h:63
UwTDMATimer(UwTDMA *m)
Definition uwtdma.h:70
virtual void expire(Event *e)
Definition uwtdma.cpp:74
Definition uwtdma.h:90
std::string name_label_
Definition uwtdma.h:236
UwTDMA()
Definition uwtdma.cpp:79
virtual void recvFromUpperLayers(Packet *p)
Definition uwtdma.cpp:153
virtual void initPkt(Packet *p)
Definition uwtdma.cpp:356
virtual void txData()
Definition uwtdma.cpp:214
int checkPriority
Definition uwtdma.h:238
UWTDMA_STATUS transceiver_status
Definition uwtdma.h:207
virtual void start(double delay)
Definition uwtdma.cpp:404
int tot_slots
Definition uwtdma.h:215
double guard_time
Definition uwtdma.h:221
int sea_trial_
Definition uwtdma.h:211
int max_packet_per_slot
Definition uwtdma.h:230
int drop_old_
Definition uwtdma.h:233
virtual void stateTxData()
Definition uwtdma.cpp:206
virtual void Phy2MacStartRx(const Packet *p)
Definition uwtdma.cpp:286
virtual void rxPacketNotForMe(Packet *p)
Definition uwtdma.cpp:367
int debug_
Definition uwtdma.h:209
int max_queue_size
Definition uwtdma.h:229
int HDR_size
Definition uwtdma.h:219
int fair_mode
Definition uwtdma.h:212
virtual int command(int argc, const char *const *argv)
Definition uwtdma.cpp:438
UwTDMATimer tdma_timer
Definition uwtdma.h:224
std::ofstream out_file_stats
Definition uwtdma.h:226
virtual ~UwTDMA()
Definition uwtdma.cpp:148
virtual int recvSyncClMsg(ClMessage *m)
Definition uwtdma.cpp:521
virtual void Mac2PhyStartTx(Packet *p)
Definition uwtdma.cpp:249
virtual void Phy2MacEndTx(const Packet *p)
Definition uwtdma.cpp:273
virtual void stop()
Definition uwtdma.cpp:427
unsigned long int getEpoch()
Definition uwtdma.h:184
bool enable
Definition uwtdma.h:227
virtual void Phy2MacEndRx(Packet *p)
Definition uwtdma.cpp:296
int packet_sent_curr_slot_
Definition uwtdma.h:231
double frame_duration
Definition uwtdma.h:220
double start_time
Definition uwtdma.h:223
int slot_status
Definition uwtdma.h:208
virtual void changeStatus()
Definition uwtdma.cpp:374
UWTDMA_STATUS
Definition uwtdma.h:204
@ RECEIVING
Definition uwtdma.h:204
@ TRANSMITTING
Definition uwtdma.h:204
@ IDLE
Definition uwtdma.h:204
double slot_duration
Definition uwtdma.h:222
std::deque< Packet * > buffer
Definition uwtdma.h:225
int slot_number
Definition uwtdma.h:216