DESERT 4.0.0
uw-aloha-q-sync-node.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
39#ifndef UW_ALOHA_Q_SYNC_NODE_H
40#define UW_ALOHA_Q_SYNC_NODE_H
41
42#include <mmac.h>
43#include <deque>
44#include <iostream>
45#include <assert.h>
46#include <fstream>
47
48#include <mphy.h>
49
51
52#include <vector>
53
55
61class UwAlohaQSyncTimer : public TimerHandler
62{
63
64public:
70 : TimerHandler()
71 {
72 assert(m != NULL);
73 module = m;
74 }
75
76protected:
81 virtual void expire(Event *e);
82 UwAloha_Q_Sync_NODE *module;
83};
84
88class UwAloha_Q_Sync_NODE : public MMac
89{
90
91 friend class UwAlohaQSyncTimer;
92
93public:
98
102 virtual ~UwAloha_Q_Sync_NODE() = default;
103
104
111 virtual int recvSyncClMsg(ClMessage* m);
112
113protected:
114
120 virtual void stateRxAck(Packet *p, int addr);
124 virtual void findMySlot();
129 virtual void updateQ_table(int ack_received);
133 virtual void handleTimerExpiration();
137 virtual void txData();
142 virtual void start(double delay);
146 virtual void stop();
152 virtual void recvFromUpperLayers(Packet *p);
158 virtual void Phy2MacEndRx(Packet *p);
164 virtual void Phy2MacStartRx(Packet *p);
170 virtual void Mac2PhyStartTx(Packet *p);
176 virtual void Phy2MacEndTx(const Packet *p);
182 virtual void rxPacketNotForMe(Packet *p);
188 virtual void initPkt(Packet *p);
189
201 virtual int command(int argc, const char *const *argv);
202
210 std::vector <std::vector<double>> Q_table{};
211 double start_time;
217 std::ofstream out_file_stats;
225 bool enable;
229 int debug_;
233 std::deque<Packet *> buffer;
239 double t_prop_max;
240 double t_dp;
241 double t_guard;
242 std::vector<int> ack_data;
244 int nn;
248};
249
250#endif
Definition uw-aloha-q-sync-node.h:62
UwAlohaQSyncTimer(UwAloha_Q_Sync_NODE *m)
Definition uw-aloha-q-sync-node.h:69
virtual void expire(Event *e)
Definition uw-aloha-q-sync-node.cpp:80
Definition uw-aloha-q-sync-node.h:89
std::deque< Packet * > buffer
Definition uw-aloha-q-sync-node.h:233
virtual void updateQ_table(int ack_received)
Definition uw-aloha-q-sync-node.cpp:188
int sea_trial_
Definition uw-aloha-q-sync-node.h:232
double slot_duration_factor
Definition uw-aloha-q-sync-node.h:243
int nn
Definition uw-aloha-q-sync-node.h:244
int my_curr_slot
Definition uw-aloha-q-sync-node.h:237
SLOT_STATUS
Definition uw-aloha-q-sync-node.h:206
@ RECEIVE
Definition uw-aloha-q-sync-node.h:206
@ TRANSMIT
Definition uw-aloha-q-sync-node.h:206
virtual void handleTimerExpiration()
Definition uw-aloha-q-sync-node.cpp:398
int my_curr_subslot
Definition uw-aloha-q-sync-node.h:238
double t_dp
Definition uw-aloha-q-sync-node.h:240
virtual void Phy2MacStartRx(Packet *p)
Definition uw-aloha-q-sync-node.cpp:275
virtual void recvFromUpperLayers(Packet *p)
Definition uw-aloha-q-sync-node.cpp:207
virtual void findMySlot()
Definition uw-aloha-q-sync-node.cpp:145
int curr_slot
Definition uw-aloha-q-sync-node.h:235
std::ofstream out_file_stats
Definition uw-aloha-q-sync-node.h:217
int curr_subslot
Definition uw-aloha-q-sync-node.h:236
int drop_old_
Definition uw-aloha-q-sync-node.h:223
double t_prop_max
Definition uw-aloha-q-sync-node.h:239
std::vector< std::vector< double > > Q_table
Definition uw-aloha-q-sync-node.h:210
int debug_
Definition uw-aloha-q-sync-node.h:229
bool enable
Definition uw-aloha-q-sync-node.h:225
UWALOHAQ_STATUS
Definition uw-aloha-q-sync-node.h:203
@ IDLE
Definition uw-aloha-q-sync-node.h:203
@ RECEIVING
Definition uw-aloha-q-sync-node.h:203
@ TRANSMITTING
Definition uw-aloha-q-sync-node.h:203
UwAloha_Q_Sync_NODE()
Definition uw-aloha-q-sync-node.cpp:85
virtual void start(double delay)
Definition uw-aloha-q-sync-node.cpp:445
virtual void Phy2MacEndRx(Packet *p)
Definition uw-aloha-q-sync-node.cpp:297
virtual void stop()
Definition uw-aloha-q-sync-node.cpp:457
UwAlohaQSyncTimer alohaq_sync_timer
Definition uw-aloha-q-sync-node.h:209
int packet_sent_curr_frame
Definition uw-aloha-q-sync-node.h:220
virtual void Phy2MacEndTx(const Packet *p)
Definition uw-aloha-q-sync-node.cpp:265
int subslot_num
Definition uw-aloha-q-sync-node.h:246
virtual void stateRxAck(Packet *p, int addr)
Definition uw-aloha-q-sync-node.cpp:354
UWALOHAQ_STATUS transceiver_status
Definition uw-aloha-q-sync-node.h:213
virtual int recvSyncClMsg(ClMessage *m)
Definition uw-aloha-q-sync-node.cpp:525
int max_queue_size
Definition uw-aloha-q-sync-node.h:222
virtual void initPkt(Packet *p)
Definition uw-aloha-q-sync-node.cpp:381
double t_guard
Definition uw-aloha-q-sync-node.h:241
SLOT_STATUS slot_status
Definition uw-aloha-q-sync-node.h:215
double start_time
Definition uw-aloha-q-sync-node.h:211
int HDR_size
Definition uw-aloha-q-sync-node.h:219
virtual ~UwAloha_Q_Sync_NODE()=default
virtual int command(int argc, const char *const *argv)
Definition uw-aloha-q-sync-node.cpp:465
virtual void txData()
Definition uw-aloha-q-sync-node.cpp:221
virtual void rxPacketNotForMe(Packet *p)
Definition uw-aloha-q-sync-node.cpp:388
std::vector< int > ack_data
Definition uw-aloha-q-sync-node.h:242
int checkPriority
Definition uw-aloha-q-sync-node.h:226
virtual void Mac2PhyStartTx(Packet *p)
Definition uw-aloha-q-sync-node.cpp:247
Provides the headers of ack packets of uw-aloha-q-sync-sink module.