DESERT 3.6.0
Loading...
Searching...
No Matches
uwrov-module.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
44#ifndef UWROV_MODULE_H
45#define UWROV_MODULE_H
46
47#include "uwsmposition.h"
48#include "uwcbr-module.h"
49#include "uwrov-packet.h"
50
51#include <fstream>
52
53#define UWROV_DROP_REASON_UNKNOWN_TYPE "UKT"
54#define UWROV_DROP_REASON_OUT_OF_SEQUENCE "OOS"
55#define UWROV_DROP_REASON_DUPLICATED_PACKET "DPK"
56#define HDR_UWROV_MONITORING(p) (hdr_uwROV_monitoring::access(p))
57#define HDR_UWROV_CTR(p) (hdr_uwROV_ctr::access(p))
58
59class UwROVModule;
60
65class UwROVSendAckTimer : public TimerHandler
66{
67public:
69 : TimerHandler()
70 {
71 module = m;
72 }
73
74protected:
75 virtual void expire(Event *e);
76 UwROVModule *module;
77};
78
84{
85 friend class UwROVSendAckTimer;
86
87public:
92
96 virtual ~UwROVModule() = default;
97
108 virtual int command(int argc, const char *const *argv) override;
109
117 virtual void initPkt(Packet *p) override;
118
124 virtual void recv(Packet *) override;
125
132 virtual void recv(Packet *p, Handler *h) override;
133
139 static int
141 {
142 return sizeof(hdr_uwROV_monitoring);
143 }
144
150 static int
152 {
153 return sizeof(hdr_uwROV_ctr);
154 }
155
159 virtual void sendAck();
160
161protected:
163
165 int ack;
177
179 std::ofstream out_file_stats;
180};
181
182#endif // UWROV_MODULE_H
UwCbrModule class is used to manage UWCBR packets and to collect statistics about them.
UwROVModule class is used to manage UWROV packets and to collect statistics about them.
int drop_old_waypoints
< Number of ACK not sent in piggyback when ackPolicy = 2.
int ack
If not zero, contains the ACK to the last command packet received.
virtual void sendAck()
Sends ACK if ackTimeout expire;.
UwROVModule()
Default Constructor of UwROVModule class.
static int getROVMonHeaderSize()
Returns the size in byte of a hdr_uwROV_monitoring packet header.
virtual ~UwROVModule()=default
Destructor of UwROVModule class.
int ackTimeout
< Flag set to 1 to drop waypoints with sequence number lower or equal than last_sn_confirmed.
UWSMPosition * posit
ROV position.
UWROV_ACK_POLICY ackPolicy
Flag to set the policy for ACK transimission, ACK_PIGGYBACK: ACK is always sent in piggyback,...
std::ofstream out_file_stats
Output stream for the textual file of debug.
virtual void recv(Packet *) override
Performs the reception of packets from upper and lower layers.
UwROVSendAckTimer ackTimer_
Timer to schedule ACK transmission.
int ackPriority
Flag to give higher priority to ACK or not.
virtual void initPkt(Packet *p) override
Initializes a monitoring data packet passed as argument with the default values.
int last_sn_confirmed
Sequence number of the last command packet received.
virtual int command(int argc, const char *const *argv) override
TCL command interpreter.
int log_flag
Flag to enable log file writing.
static int getROVCTRHeaderSize()
Returns the size in byte of a hdr_uwROV_ctr packet header.
UwROVSendACKTimer class is used to handle the scheduling period of UWROV packets.
virtual void expire(Event *e)
UwROVSendAckTimer(UwROVModule *m)
hdr_uwROV_ctr describes UWROV_ctr packets for controlling the ROV.
hdr_uwROV_monitoring describes UWROV_monitoring packets sent by the ROV to the base station for monit...
Provides the UWCBR packets header description and the definition of the class UWCBR.
Provides both UWROV monitoring and control packets header description.
Provides the definition of the class UWSMPosition.