2 This file is part of GNUnet
3 (C) 2006 Christian Grothoff (and other contributing authors)
5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 2, or (at your
8 option) any later version.
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
22 * @file src/dht/dhtlog.h
24 * @brief dhtlog is a service that implements logging of dht operations
26 * @author Nathan Evans
29 #ifndef GNUNET_DHTLOG_SERVICE_H
30 #define GNUNET_DHTLOG_SERVICE_H
32 #include "gnunet_util_lib.h"
37 #if 0 /* keep Emacsens' auto-indent happy */
45 * Type for a DHT GET message
50 * Type for a DHT PUT message
55 * Type for a DHT FIND PEER message
60 * Type for a DHT RESULT message
65 * Generic DHT ROUTE message
69 } DHTLOG_MESSAGE_TYPES;
71 struct GNUNET_DHTLOG_TrialInfo
74 * Trialuid, possibly set by insert call.
76 unsigned long long trialuid;
79 * Outside of database identifier for the trial.
81 unsigned int other_identifier;
83 /** Number of nodes in the trial */
84 unsigned int num_nodes;
86 /** Type of initial topology */
87 unsigned int topology;
89 /** Topology to blacklist peers to */
90 unsigned int blacklist_topology;
92 /** Initially connect peers in this topology */
93 unsigned int connect_topology;
95 /** Option to modify connect topology */
96 unsigned int connect_topology_option;
98 /** Modifier for the connect option */
99 float connect_topology_option_modifier;
101 /** Percentage parameter used for certain topologies */
102 float topology_percentage;
104 /** Probability parameter used for certain topologies */
105 float topology_probability;
107 /** Number of puts in the trial */
110 /** Number of gets in the trial */
113 /** Concurrent puts/gets in the trial (max allowed) */
114 unsigned int concurrent;
116 /** How long between initial connection and issuing puts/gets */
117 unsigned int settle_time;
119 /** How many times to do put/get loop */
120 unsigned int num_rounds;
122 /** Number of malicious getters */
123 unsigned int malicious_getters;
125 /** Number of malicious putters */
126 unsigned int malicious_putters;
128 /** Number of malicious droppers */
129 unsigned int malicious_droppers;
131 /** Frequency of malicious get requests */
132 unsigned int malicious_get_frequency;
134 /** Frequency of malicious put requests */
135 unsigned int malicious_put_frequency;
137 /** Stop forwarding put/find_peer requests when peer is closer than others */
138 unsigned int stop_closest;
140 /** Stop forwarding get requests when data found */
141 unsigned int stop_found;
144 * Routing behaves as it would in Kademlia (modified to work recursively,
145 * and with our other GNUnet constraints.
147 unsigned int strict_kademlia;
149 /** Number of gets that were reported successful */
150 unsigned int gets_succeeded;
152 /** Message for this trial */
156 struct GNUNET_DHTLOG_Handle
160 * Inserts the specified query into the dhttests.queries table
162 * @param sqlqueruid inserted query uid
163 * @param queryid dht query id
164 * @param type type of the query
165 * @param hops number of hops query traveled
166 * @param succeeded whether or not query was successful
167 * @param node the node the query hit
168 * @param key the key of the query
170 * @return GNUNET_OK on success, GNUNET_SYSERR on failure.
172 int (*insert_query) (unsigned long long *sqlqueryuid,
173 unsigned long long queryid, DHTLOG_MESSAGE_TYPES type,
176 const struct GNUNET_PeerIdentity * node,
177 const GNUNET_HashCode * key);
180 * Inserts the specified trial into the dhttests.trials table
182 * @param trial_info general information about this trial
184 * @return GNUNET_OK on success, GNUNET_SYSERR on failure
186 int (*insert_trial) (struct GNUNET_DHTLOG_TrialInfo *trial_info);
189 * Inserts the specified stats into the dhttests.node_statistics table
191 * @param peer the peer inserting the statistic
192 * @param route_requests route requests seen
193 * @param route_forwards route requests forwarded
194 * @param result_requests route result requests seen
195 * @param client_requests client requests initiated
196 * @param result_forwards route results forwarded
197 * @param gets get requests handled
198 * @param puts put requests handle
199 * @param data_inserts data inserted at this node
200 * @param find_peer_requests find peer requests seen
201 * @param find_peers_started find peer requests initiated at this node
202 * @param gets_started get requests initiated at this node
203 * @param puts_started put requests initiated at this node
204 * @param find_peer_responses_received find peer responses received locally
205 * @param get_responses_received get responses received locally
206 * @param find_peer_responses_sent find peer responses sent from this node
207 * @param get_responses_sent get responses sent from this node
209 * @return GNUNET_OK on success, GNUNET_SYSERR on failure
212 (const struct GNUNET_PeerIdentity *peer, unsigned int route_requests,
213 unsigned int route_forwards, unsigned int result_requests,
214 unsigned int client_requests, unsigned int result_forwards,
215 unsigned int gets, unsigned int puts,
216 unsigned int data_inserts, unsigned int find_peer_requests,
217 unsigned int find_peers_started, unsigned int gets_started,
218 unsigned int puts_started, unsigned int find_peer_responses_received,
219 unsigned int get_responses_received, unsigned int find_peer_responses_sent,
220 unsigned int get_responses_sent);
223 * Update dhttests.trials table with current server time as end time
225 * @param trialuid trial to update
226 * @param gets_succeeded how many gets did the trial report successful
228 * @return GNUNET_OK on success, GNUNET_SYSERR on failure.
230 int (*update_trial) (unsigned long long trialuid,
231 unsigned int gets_succeeded);
234 * Update dhttests.nodes table setting the identified
235 * node as a malicious dropper.
237 * @param peer the peer that was set to be malicious
239 * @return GNUNET_OK on success, GNUNET_SYSERR on failure.
241 int (*set_malicious) (struct GNUNET_PeerIdentity *peer);
244 * Records the current topology (number of connections, time, trial)
246 * @param num_connections how many connections are in the topology
248 * @return GNUNET_OK on success, GNUNET_SYSERR on failure
250 int (*insert_topology) (int num_connections);
253 * Records a connection between two peers in the current topology
255 * @param first one side of the connection
256 * @param second other side of the connection
258 * @return GNUNET_OK on success, GNUNET_SYSERR on failure
260 int (*insert_extended_topology) (const struct GNUNET_PeerIdentity *first, const struct GNUNET_PeerIdentity *second);
263 * Inserts the specified stats into the dhttests.generic_stats table
265 * @param peer the peer inserting the statistic
266 * @param name the name of the statistic
267 * @param section the section of the statistic
268 * @param value the value of the statistic
270 * @return GNUNET_OK on success, GNUNET_SYSERR on failure
273 (*add_generic_stat) (const struct GNUNET_PeerIdentity *peer,
275 const char *section, uint64_t value);
278 * Inserts the specified round into the dhttests.rounds table
280 * @param round_type the type of round that is being started
281 * @param round_count counter for the round (if applicable)
283 * @return GNUNET_OK on success, GNUNET_SYSERR on failure
285 int (*insert_round) (unsigned int round_type, unsigned int round_count);
288 * Update dhttests.trials table with total connections information
290 * @param trialuid the trialuid to update
291 * @param totalConnections the number of connections
293 * @return GNUNET_OK on success, GNUNET_SYSERR on failure.
295 int (*update_connections) (unsigned long long trialuid,
296 unsigned int totalConnections);
299 * Update dhttests.trials table with total connections information
301 * @param connections the number of connections
303 * @return GNUNET_OK on success, GNUNET_SYSERR on failure.
305 int (*update_topology) (unsigned int connections);
308 * Inserts the specified route information into the dhttests.routes table
310 * @param sqlqueruid inserted query uid
311 * @param queryid dht query id
312 * @param type type of the query
313 * @param hops number of hops query traveled
314 * @param succeeded whether or not query was successful
315 * @param node the node the query hit
316 * @param key the key of the query
317 * @param from_node the node that sent the message to node
318 * @param to_node next node to forward message to
320 * @return GNUNET_OK on success, GNUNET_SYSERR on failure.
322 int (*insert_route) (unsigned long long *sqlqueryuid,
323 unsigned long long queryid,
327 const struct GNUNET_PeerIdentity * node,
328 const GNUNET_HashCode * key,
329 const struct GNUNET_PeerIdentity * from_node,
330 const struct GNUNET_PeerIdentity * to_node);
333 * Inserts the specified node into the dhttests.nodes table
335 * @param nodeuid the inserted node uid
336 * @param node the node to insert
338 * @return GNUNET_OK on success, GNUNET_SYSERR on failure
340 int (*insert_node) (unsigned long long *nodeuid,
341 struct GNUNET_PeerIdentity * node);
344 * Inserts the specified dhtkey into the dhttests.dhtkeys table,
345 * stores return value of dhttests.dhtkeys.dhtkeyuid into dhtkeyuid
347 * @param dhtkeyuid return value
348 * @param dhtkey hashcode of key to insert
350 * @return GNUNET_OK on success, GNUNET_SYSERR on failure
352 int (*insert_dhtkey) (unsigned long long *dhtkeyuid,
353 const GNUNET_HashCode * dhtkey);
357 struct GNUNET_DHTLOG_Plugin
359 const struct GNUNET_CONFIGURATION_Handle *cfg;
361 struct GNUNET_DHTLOG_Handle *dhtlog_api;
365 * Connect to mysql server using the DHT log plugin.
367 * @param c a configuration to use
369 struct GNUNET_DHTLOG_Handle *
370 GNUNET_DHTLOG_connect (const struct GNUNET_CONFIGURATION_Handle *c);
373 * Shutdown the module.
376 GNUNET_DHTLOG_disconnect (struct GNUNET_DHTLOG_Handle *api);
379 #if 0 /* keep Emacsens' auto-indent happy */
386 /* end of dhtlog.h */