OverSim
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
DHT.h
Go to the documentation of this file.
1
//
2
// Copyright (C) 2007 Institut fuer Telematik, Universitaet Karlsruhe (TH)
3
//
4
// This program is free software; you can redistribute it and/or
5
// modify it under the terms of the GNU General Public License
6
// as published by the Free Software Foundation; either version 2
7
// of the License, or (at your option) any later version.
8
//
9
// This program is distributed in the hope that it will be useful,
10
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
// GNU General Public License for more details.
13
//
14
// You should have received a copy of the GNU General Public License
15
// along with this program; if not, write to the Free Software
16
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17
//
18
24
#ifndef __DHT_H_
25
#define __DHT_H_
26
27
#include <omnetpp.h>
28
29
#include <
OverlayKey.h
>
30
#include <
SHA1.h
>
31
#include <
CommonMessages_m.h
>
32
33
#include "
DHTMessage_m.h
"
34
#include "
DHTDataStorage.h
"
35
36
#include "
BaseApp.h
"
37
#include <
RpcMacros.h
>
38
44
class
DHT
:
public
BaseApp
45
{
46
public
:
47
DHT
();
48
virtual
~DHT
();
49
50
private
:
51
enum
PendingRpcsStates
{
52
INIT
= 0,
53
LOOKUP_STARTED
= 1,
54
GET_HASH_SENT
= 2,
55
GET_VALUE_SENT
= 3,
56
PUT_SENT
= 4
57
};
58
59
class
PendingRpcsEntry
60
{
61
public
:
62
PendingRpcsEntry
()
63
{
64
getCallMsg
= NULL;
65
putCallMsg
= NULL;
66
state
=
INIT
;
67
hashVector
= NULL;
68
numSent
= 0;
69
numAvailableReplica
= 0;
70
numFailed
= 0;
71
numResponses
= 0;
72
};
73
74
DHTgetCAPICall
*
getCallMsg
;
75
DHTputCAPICall
*
putCallMsg
;
76
PendingRpcsStates
state
;
77
NodeVector
replica
;
78
NodeVector
*
hashVector
;
79
std::map<BinaryValue, NodeVector>
hashes
;
80
int
numSent
;
81
int
numAvailableReplica
;
82
int
numFailed
;
83
int
numResponses
;
84
};
85
86
friend
std::ostream&
operator<<
(std::ostream& Stream,
87
const
PendingRpcsEntry
& entry);
88
89
void
initializeApp
(
int
stage);
90
void
finishApp
();
91
void
handleTimerEvent
(cMessage* msg);
92
93
bool
handleRpcCall
(
BaseCallMessage
* msg);
94
void
handleRpcResponse
(
BaseResponseMessage
* msg, cPolymorphic *context,
95
int
rpcId, simtime_t rtt);
96
void
handleRpcTimeout
(
BaseCallMessage
* msg,
const
TransportAddress
& dest,
97
cPolymorphic* context,
int
rpcId,
98
const
OverlayKey
& destKey);
99
void
handlePutRequest
(
DHTPutCall
* dhtMsg);
100
void
handleGetRequest
(
DHTGetCall
* dhtMsg);
101
void
handlePutResponse
(
DHTPutResponse
* dhtMsg,
int
rpcId);
102
void
handleGetResponse
(
DHTGetResponse
* dhtMsg,
int
rpcId);
103
void
handlePutCAPIRequest
(
DHTputCAPICall
* capiPutMsg);
104
void
handleGetCAPIRequest
(
DHTgetCAPICall
* capiPutMsg);
105
void
handleDumpDhtRequest
(
DHTdumpCall
* call);
106
void
update
(
const
NodeHandle
& node,
bool
joined);
107
void
handleLookupResponse
(
LookupResponse
* lookupMsg,
int
rpcId);
108
void
sendMaintenancePutCall
(
const
TransportAddress
& dest,
109
const
OverlayKey
& key,
110
const
DhtDataEntry
& entry);
111
int
resultValuesBitLength
(
DHTGetResponse
* msg);
112
113
uint
numReplica
;
114
int
numGetRequests
;
115
double
ratioIdentical
;
116
double
maintenanceMessages
;
117
double
normalMessages
;
118
double
numBytesMaintenance
;
119
double
numBytesNormal
;
120
121
bool
secureMaintenance
;
122
bool
invalidDataAttack
;
123
bool
maintenanceAttack
;
125
typedef
std::map<uint32_t, PendingRpcsEntry>
PendingRpcs
;
126
PendingRpcs
pendingRpcs
;
128
// module references
129
DHTDataStorage
*
dataStorage
;
130
};
131
132
#endif
src
applications
dht
DHT.h
Generated on Fri Dec 7 2012 13:37:52 for OverSim by
1.8.1.2