-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaodvugd_ping_app.h
More file actions
188 lines (148 loc) · 7.19 KB
/
Copy pathaodvugd_ping_app.h
File metadata and controls
188 lines (148 loc) · 7.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
#ifndef __SHAWN_LEGACYAPPS_AODVUGD_PING_APP_H
#define __SHAWN_LEGACYAPPS_AODVUGD_PING_APP_H
#include "_legacyapps_enable_cmake.h"
#ifdef ENABLE_AODVUGD
#include <map>
#include <list>
#include <set>
#include <vector>
#include <limits>
#include "sys/processor.h"
#include "sys/event_scheduler.h"
#include "legacyapps/aodvugd/aodvugd_message.h"
#include "legacyapps/aodvugd/aodvugd_processor.h"
//#include "legacyapps/aodvugd/aodvugd_message.h"
//#include "sys/simulation/simulation_controller.h"
namespace aodvugd
{
class InfoPingEnviado;
// ----------------------------------------------------------------------
// clase PingProgramadoEventTag----------------------------------------------------------------------
class PingProgramadoEventTag : public shawn::EventScheduler::EventTag
{
public:
//constructor
PingProgramadoEventTag( std::string destino , unsigned int pingID);
//----------------------------------------------------------------------
//destructor
virtual ~PingProgramadoEventTag();
// get set----------------------------------------------------------------------
inline std::string getDestino (void) const throw();
inline unsigned int getPingID (void) const throw();
// metodos----------------------------------------------------------------------
private:
const std::string destino_;
const unsigned int pingID_ ;
};
// ----------------------------------------------------------------------
// ----------------------------------------------------------------------
// ----------------------------------------------------------------------
// clase PingApp----------------------------------------------------------------------
class PingApp
: public shawn::Processor,
public shawn::EventScheduler::EventHandler
{
public:
PingApp();
PingApp( shawn::EventScheduler& pEventScheduler,
AodvUgdProcessor& procesoAodv );
virtual ~PingApp();
// processor----------------------------------------------------------------------
virtual void special_boot( void ) throw();
virtual void boot( void ) throw();\
virtual bool process_message( const shawn::ConstMessageHandle& ) throw();
virtual void work( void ) throw();
// inicializar----------------------------------------------------------------------
void inicilizar( shawn::EventScheduler& pEventScheduler,
AodvUgdProcessor& procesoAodv )
throw();
// metodos----------------------------------------------------------------------
void log ( ) throw();
virtual void timeout( shawn::EventScheduler&,
shawn::EventScheduler::EventHandle,
double,
shawn::EventScheduler::EventTagHandle& ) throw();
void recibirMensajePing ( const PingMessage& unPingMessage ) throw();
void programarPrimerPing( std::string destino , unsigned int maxPings ,
bool pingInfinito , double timeoutPing ,
unsigned int ttl , int size ,
double tiempoInicioPing ) throw();
private:
//unsigned int contadorBroadcast_ = 0;
//par: destino , eventoPing
typedef std::pair<unsigned int , InfoPingEnviado*> ParPingEnviado;
typedef std::map< unsigned int , InfoPingEnviado*> TipoPingsEnviados;
TipoPingsEnviados pingsEnviados;
shawn::EventScheduler* pEventScheduler_;
AodvUgdProcessor* procesoAodv_;
unsigned int pingID_ = 0;
// metodos privados----------------------------------------------------------------------
void enviarPingRequest (std::string destino , unsigned int ttl ,
int size , unsigned int pingID ,
unsigned int seqNum) throw();
void enviarPingReply (std::string destino , unsigned int ttl ,
int size , unsigned int pingID ,
unsigned int seqNum) throw();
shawn::EventScheduler::EventHandle
generarEventoTiempoEspera ( double tiempoDeEspera , std::string destino ,
unsigned int pingID ) throw();
void handle_EventPing ( const PingProgramadoEventTag& unPingProgramadoEventTag ) throw();
void handle_pingReply ( const PingMessage& unPingMessageReply ) throw();
void handle_pingRequest ( const PingMessage& unPingMessageReply ) throw();
bool existeIdPingEnviados ( unsigned int pingID ) throw();
InfoPingEnviado* devolverInfoPingEnviado( unsigned int idPing ) throw();
void cancelarTimeoutEventPing( shawn::EventScheduler::EventHandle pEventHandle )
throw();
void intentarEnviarPing ( InfoPingEnviado *unaInfoPingEnviado ) throw();
// ----------------------------------------------------------------------
// ----------------------------------------------------------------------
// ----------------------------------------------------------------------
};
// ----------------------------------------------------------------------
// ----------------------------------------------------------------------
// class InfoPingEnviado ----------------------------------------------------------------------
class InfoPingEnviado
{
public:
InfoPingEnviado ( unsigned int max , unsigned int pingID ,
bool pingInfinito , std::string destino ,
shawn::EventScheduler::EventHandle eventoTiempoEspera ,
unsigned int ttl , int size , double timeoutPing );
//InfoPingEnviado();
virtual ~InfoPingEnviado();
// get ----------------------------------------------------------------------
const int getMax ( ) const throw();
const unsigned int getPingID ( ) const throw();
const int getSeqNum ( ) const throw();
const unsigned int getTtl ( ) const throw();
const int getSize ( ) const throw();
const double getTimeoutPing ( ) const throw();
const double getLastSendTime ( ) const throw();
const double getStartSendTime ( ) const throw();
const bool getPingInfinito ( ) const throw();
const std::string getDestino ( ) const throw();
shawn::EventScheduler::EventHandle getEventoTiempoEspera()
throw();
//set
// Metodos----------------------------------------------------------------------
void actualizarSeEnvioPing ( double lastSendTime ,
shawn::EventScheduler::EventHandle eventoTiempoEspera )
throw();
private:
int max_; //cantidad max de pings permitidos.
int seqNum_ = -1; //equivale a pings enviados enviados. -1 indica que no empezo
bool pingInfinito_; //si es TRUE no hay cantidad max de pings.
std::string destino_;
unsigned int pingID_;
unsigned int ttl_;
int size_;
double timeoutPing_ = 0; //el tiempo que ese espera para enviar un nuevo ping.
double lastSendTime_= 0; //el tiempo en que se envio el ultimo ping.
//el tiempo en que se comenzo a enviar la secuencia de ping
//puede ser util para calcular cuanto duro el ping por ej.
double startSendTime_=0;
shawn::EventScheduler::EventHandle eventoTiempoEspera_;
};
}
#endif
#endif