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 * Outside of database identifier for the trial.
76 unsigned int other_identifier;
78 /** Number of nodes in the trial */
79 unsigned int num_nodes;
81 /** Type of initial topology */
82 unsigned int topology;
84 /** Topology to blacklist peers to */
85 unsigned int blacklist_topology;
87 /** Initially connect peers in this topology */
88 unsigned int connect_topology;
90 /** Option to modify connect topology */
91 unsigned int connect_topology_option;
93 /** Modifier for the connect option */
94 float connect_topology_option_modifier;
96 /** Percentage parameter used for certain topologies */
97 float topology_percentage;
99 /** Probability parameter used for certain topologies */
100 float topology_probability;
102 /** Number of puts in the trial */
105 /** Number of gets in the trial */
108 /** Concurrent puts/gets in the trial (max allowed) */
109 unsigned int concurrent;
111 /** How long between initial connection and issuing puts/gets */
112 unsigned int settle_time;
114 /** How many times to do put/get loop */
115 unsigned int num_rounds;
117 /** Number of malicious getters */
118 unsigned int malicious_getters;
120 /** Number of malicious putters */
121 unsigned int malicious_putters;
123 /** Number of malicious droppers */
124 unsigned int malicious_droppers;
126 /** Frequency of malicious get requests */
127 unsigned int malicious_get_frequency;
129 /** Frequency of malicious put requests */
130 unsigned int malicious_put_frequency;
132 /** Stop forwarding put/find_peer requests when peer is closer than others */
133 unsigned int stop_closest;
135 /** Stop forwarding get requests when data found */
136 unsigned int stop_found;
139 * Routing behaves as it would in Kademlia (modified to work recursively,
140 * and with our other GNUnet constraints).
142 unsigned int strict_kademlia;
144 /** Number of gets that were reported successful */
145 unsigned int gets_succeeded;
147 /** Message for this trial */
151 struct GNUNET_DHTLOG_Handle
155 * Inserts the specified query into the dhttests.queries table
157 * @param sqlqueruid inserted query uid
158 * @param queryid dht query id
159 * @param type type of the query
160 * @param hops number of hops query traveled
161 * @param succeeded whether or not query was successful
162 * @param node the node the query hit
163 * @param key the key of the query
165 * @return GNUNET_OK on success, GNUNET_SYSERR on failure.
167 int (*insert_query) (unsigned long long *sqlqueryuid,
168 unsigned long long queryid, DHTLOG_MESSAGE_TYPES type,
171 const struct GNUNET_PeerIdentity * node,
172 const GNUNET_HashCode * key);
175 * Inserts the specified trial into the dhttests.trials table
177 * @param trial_info general information about this trial
179 * @return GNUNET_OK on success, GNUNET_SYSERR on failure
181 int (*insert_trial) (struct GNUNET_DHTLOG_TrialInfo *trial_info);
184 * Inserts the specified stats into the dhttests.node_statistics table
186 * @param peer the peer inserting the statistic
187 * @param route_requests route requests seen
188 * @param route_forwards route requests forwarded
189 * @param result_requests route result requests seen
190 * @param client_requests client requests initiated
191 * @param result_forwards route results forwarded
192 * @param gets get requests handled
193 * @param puts put requests handle
194 * @param data_inserts data inserted at this node
195 * @param find_peer_requests find peer requests seen
196 * @param find_peers_started find peer requests initiated at this node
197 * @param gets_started get requests initiated at this node
198 * @param puts_started put requests initiated at this node
199 * @param find_peer_responses_received find peer responses received locally
200 * @param get_responses_received get responses received locally
201 * @param find_peer_responses_sent find peer responses sent from this node
202 * @param get_responses_sent get responses sent from this node
204 * @return GNUNET_OK on success, GNUNET_SYSERR on failure
207 (const struct GNUNET_PeerIdentity *peer, unsigned int route_requests,
208 unsigned int route_forwards, unsigned int result_requests,
209 unsigned int client_requests, unsigned int result_forwards,
210 unsigned int gets, unsigned int puts,
211 unsigned int data_inserts, unsigned int find_peer_requests,
212 unsigned int find_peers_started, unsigned int gets_started,
213 unsigned int puts_started, unsigned int find_peer_responses_received,
214 unsigned int get_responses_received, unsigned int find_peer_responses_sent,
215 unsigned int get_responses_sent);
218 * Update dhttests.trials table with current server time as end time
220 * @param gets_succeeded how many gets did the trial report successful
222 * @return GNUNET_OK on success, GNUNET_SYSERR on failure.
224 int (*update_trial) (unsigned int gets_succeeded);
227 * Update dhttests.nodes table setting the identified
228 * node as a malicious dropper.
230 * @param peer the peer that was set to be malicious
232 * @return GNUNET_OK on success, GNUNET_SYSERR on failure.
234 int (*set_malicious) (struct GNUNET_PeerIdentity *peer);
237 * Records the current topology (number of connections, time, trial)
239 * @param num_connections how many connections are in the topology
241 * @return GNUNET_OK on success, GNUNET_SYSERR on failure
243 int (*insert_topology) (int num_connections);
246 * Records a connection between two peers in the current topology
248 * @param first one side of the connection
249 * @param second other side of the connection
251 * @return GNUNET_OK on success, GNUNET_SYSERR on failure
253 int (*insert_extended_topology) (const struct GNUNET_PeerIdentity *first, const struct GNUNET_PeerIdentity *second);
256 * Inserts the specified stats into the dhttests.generic_stats table
258 * @param peer the peer inserting the statistic
259 * @param name the name of the statistic
260 * @param section the section of the statistic
261 * @param value the value of the statistic
263 * @return GNUNET_OK on success, GNUNET_SYSERR on failure
266 (*add_generic_stat) (const struct GNUNET_PeerIdentity *peer,
268 const char *section, uint64_t value);
271 * Inserts the specified round into the dhttests.rounds table
273 * @param round_type the type of round that is being started
274 * @param round_count counter for the round (if applicable)
276 * @return GNUNET_OK on success, GNUNET_SYSERR on failure
278 int (*insert_round) (unsigned int round_type, unsigned int round_count);
281 * Update dhttests.trials table with total connections information
283 * @param totalConnections the number of connections
285 * @return GNUNET_OK on success, GNUNET_SYSERR on failure.
287 int (*update_connections) (unsigned int totalConnections);
290 * Update dhttests.trials table with total connections information
292 * @param connections the number of connections
294 * @return GNUNET_OK on success, GNUNET_SYSERR on failure.
296 int (*update_topology) (unsigned int connections);
299 * Inserts the specified route information into the dhttests.routes table
301 * @param sqlqueruid inserted query uid
302 * @param queryid dht query id
303 * @param type type of the query
304 * @param hops number of hops query traveled
305 * @param succeeded whether or not query was successful
306 * @param node the node the query hit
307 * @param key the key of the query
308 * @param from_node the node that sent the message to node
309 * @param to_node next node to forward message to
311 * @return GNUNET_OK on success, GNUNET_SYSERR on failure.
313 int (*insert_route) (unsigned long long *sqlqueryuid,
314 unsigned long long queryid,
318 const struct GNUNET_PeerIdentity * node,
319 const GNUNET_HashCode * key,
320 const struct GNUNET_PeerIdentity * from_node,
321 const struct GNUNET_PeerIdentity * to_node);
324 * Inserts the specified node into the dhttests.nodes table
326 * @param nodeuid the inserted node uid
327 * @param node the node to insert
329 * @return GNUNET_OK on success, GNUNET_SYSERR on failure
331 int (*insert_node) (unsigned long long *nodeuid,
332 struct GNUNET_PeerIdentity * node);
335 * Inserts the specified dhtkey into the dhttests.dhtkeys table,
336 * stores return value of dhttests.dhtkeys.dhtkeyuid into dhtkeyuid
338 * @param dhtkeyuid return value
339 * @param dhtkey hashcode of key to insert
341 * @return GNUNET_OK on success, GNUNET_SYSERR on failure
343 int (*insert_dhtkey) (unsigned long long *dhtkeyuid,
344 const GNUNET_HashCode * dhtkey);
348 struct GNUNET_DHTLOG_Plugin
350 const struct GNUNET_CONFIGURATION_Handle *cfg;
352 struct GNUNET_DHTLOG_Handle *dhtlog_api;
356 * Connect to mysql server using the DHT log plugin.
358 * @param c a configuration to use
360 struct GNUNET_DHTLOG_Handle *
361 GNUNET_DHTLOG_connect (const struct GNUNET_CONFIGURATION_Handle *c);
364 * Shutdown the module.
367 GNUNET_DHTLOG_disconnect (struct GNUNET_DHTLOG_Handle *api);
370 #if 0 /* keep Emacsens' auto-indent happy */
377 /* end of dhtlog.h */