X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=src%2Ffs%2Fgnunet-service-fs_cp.h;h=3ca27e814dfae4f8b8164e2c7aa4d486392a4fb4;hb=cfd880578bd21f9adedba557291c903d325e93cd;hp=84165d8b769bfed98a9093df547c0cf6724cb914;hpb=6fd3e715cae09fa6e657c96f1c6f9711ee51f42f;p=oweals%2Fgnunet.git diff --git a/src/fs/gnunet-service-fs_cp.h b/src/fs/gnunet-service-fs_cp.h index 84165d8b7..3ca27e814 100644 --- a/src/fs/gnunet-service-fs_cp.h +++ b/src/fs/gnunet-service-fs_cp.h @@ -1,6 +1,6 @@ /* This file is part of GNUnet. - (C) 2011 Christian Grothoff (and other contributing authors) + Copyright (C) 2011 Christian Grothoff (and other contributing authors) GNUnet is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published @@ -30,17 +30,39 @@ #include "gnunet-service-fs.h" +/** + * Maximum number of outgoing messages we queue per peer. + * + * Performance measurements for 2 peer setup for 50 MB file + * (using perf_gnunet_service_fs_p2p): + * + * 24: 2-3 MB/s # ~ 24 MB RAM + * 256: 8 MB/s # ~256 MB RAM + * + * Conclusion: 24 should suffice (reasonable + * performance, no excessive memory use). + */ +#define MAX_QUEUE_PER_PEER 24 + +/** + * Length of the P2P success tracker. Note that having a very long + * list can also hurt performance. + */ +#define P2P_SUCCESS_LIST_SIZE 8 + +/** + * Length of the CS-2-P success tracker. Note that + * having a very long list can also hurt performance. + */ +#define CS2P_SUCCESS_LIST_SIZE 8 + + /** * Performance data kept for a peer. */ struct GSF_PeerPerformanceData { - /** - * Transport performance data. - */ - struct GNUNET_TRANSPORT_ATS_Information *atsi; - /** * List of the last clients for which this peer successfully * answered a query. @@ -62,6 +84,13 @@ struct GSF_PeerPerformanceData */ struct GNUNET_TIME_Relative avg_reply_delay; + /** + * If we get content we already have from this peer, for how + * long do we block him? Adjusted based on the fraction of + * redundant data we receive, between 1s and 1h. + */ + struct GNUNET_TIME_Relative migration_delay; + /** * Point in time until which this peer does not want us to migrate content * to it. @@ -96,9 +125,9 @@ struct GSF_PeerPerformanceData GNUNET_PEER_Id pid; /** - * Trust rating for this peer + * Respect rating for this peer */ - uint32_t trust; + uint32_t respect; /** * Number of pending queries (replies are not counted) @@ -110,10 +139,6 @@ struct GSF_PeerPerformanceData */ unsigned int pending_replies; - /** - * How many of the last blocks from migration were duplicates? - */ - unsigned int migration_duplication; }; @@ -125,23 +150,25 @@ struct GSF_PeerPerformanceData * @param cp handle to the connected peer record * @param perf peer performance data */ -typedef void (*GSF_ConnectedPeerIterator) (void *cls, - const struct GNUNET_PeerIdentity * - peer, struct GSF_ConnectedPeer * cp, - const struct GSF_PeerPerformanceData - * ppd); +typedef void +(*GSF_ConnectedPeerIterator) (void *cls, + const struct GNUNET_PeerIdentity *peer, + struct GSF_ConnectedPeer *cp, + const struct GSF_PeerPerformanceData *ppd); /** * Function called to get a message for transmission. * * @param cls closure - * @param buf_size number of bytes available in buf + * @param buf_size number of bytes available in @a buf * @param buf where to copy the message, NULL on error (peer disconnect) - * @return number of bytes copied to 'buf', can be 0 (without indicating an error) + * @return number of bytes copied to @a buf, can be 0 (without indicating an error) */ -typedef size_t (*GSF_GetMessageCallback) (void *cls, size_t buf_size, - void *buf); +typedef size_t +(*GSF_GetMessageCallback) (void *cls, + size_t buf_size, + void *buf); /** @@ -149,11 +176,23 @@ typedef size_t (*GSF_GetMessageCallback) (void *cls, size_t buf_size, * * @param cls closure * @param cp handle to the connected peer record - * @param success GNUNET_YES on success, GNUNET_NO on failure + * @param success #GNUNET_YES on success, #GNUNET_NO on failure + */ +typedef void +(*GSF_PeerReserveCallback) (void *cls, + struct GSF_ConnectedPeer *cp, + int success); + + +/** + * Function called after the creation of a connected peer record is complete. + * + * @param cls closure + * @param cp handle to the newly created connected peer record */ -typedef void (*GSF_PeerReserveCallback) (void *cls, - struct GSF_ConnectedPeer * cp, - int success); +typedef void +(*GSF_ConnectedPeerCreationCallback) (void *cls, + struct GSF_ConnectedPeer *cp); /** @@ -167,14 +206,13 @@ struct GSF_PeerTransmitHandle; * records. * * @param peer identity of peer that connected - * @param atsi performance data for the connection - * @return handle to connected peer entry + * @param creation_cb callback function when the record is created. + * @param creation_cb_cls closure for @creation_cb */ -struct GSF_ConnectedPeer *GSF_peer_connect_handler_ (const struct - GNUNET_PeerIdentity *peer, - const struct - GNUNET_TRANSPORT_ATS_Information - *atsi); +void +GSF_peer_connect_handler_ (const struct GNUNET_PeerIdentity *peer, + GSF_ConnectedPeerCreationCallback creation_cb, + void *creation_cb_cls); /** @@ -183,8 +221,19 @@ struct GSF_ConnectedPeer *GSF_peer_connect_handler_ (const struct * @param peer peer's identity * @return NULL if this peer is not currently connected */ -struct GSF_ConnectedPeer *GSF_peer_get_ (const struct GNUNET_PeerIdentity - *peer); +struct GSF_ConnectedPeer * +GSF_peer_get_ (const struct GNUNET_PeerIdentity *peer); + + +/** + * Update the latency information kept for the given peer. + * + * @param id peer record to update + * @param latency current latency value + */ +void +GSF_update_peer_latency_ (const struct GNUNET_PeerIdentity *id, + struct GNUNET_TIME_Relative latency); /** @@ -201,13 +250,13 @@ struct GSF_ConnectedPeer *GSF_peer_get_ (const struct GNUNET_PeerIdentity * @param gmc_cls closure for gmc * @return handle to cancel request */ -struct GSF_PeerTransmitHandle *GSF_peer_transmit_ (struct GSF_ConnectedPeer *cp, - int is_query, - uint32_t priority, - struct GNUNET_TIME_Relative - timeout, size_t size, - GSF_GetMessageCallback gmc, - void *gmc_cls); +struct GSF_PeerTransmitHandle * +GSF_peer_transmit_ (struct GSF_ConnectedPeer *cp, + int is_query, + uint32_t priority, + struct GNUNET_TIME_Relative timeout, + size_t size, GSF_GetMessageCallback gmc, + void *gmc_cls); /** @@ -215,7 +264,8 @@ struct GSF_PeerTransmitHandle *GSF_peer_transmit_ (struct GSF_ConnectedPeer *cp, * * @param pth request to cancel */ -void GSF_peer_transmit_cancel_ (struct GSF_PeerTransmitHandle *pth); +void +GSF_peer_transmit_cancel_ (struct GSF_PeerTransmitHandle *pth); /** @@ -225,9 +275,10 @@ void GSF_peer_transmit_cancel_ (struct GSF_PeerTransmitHandle *pth); * @param request_time time at which the original query was transmitted * @param request_priority priority of the original request */ -void GSF_peer_update_performance_ (struct GSF_ConnectedPeer *cp, - struct GNUNET_TIME_Absolute request_time, - uint32_t request_priority); +void +GSF_peer_update_performance_ (struct GSF_ConnectedPeer *cp, + struct GNUNET_TIME_Absolute request_time, + uint32_t request_priority); /** @@ -237,9 +288,9 @@ void GSF_peer_update_performance_ (struct GSF_ConnectedPeer *cp, * @param cp responding peer (will be updated) * @param initiator_client local client on responsible for query */ -void GSF_peer_update_responder_client_ (struct GSF_ConnectedPeer *cp, - struct GSF_LocalClient - *initiator_client); +void +GSF_peer_update_responder_client_ (struct GSF_ConnectedPeer *cp, + struct GSF_LocalClient *initiator_client); /** @@ -249,29 +300,10 @@ void GSF_peer_update_responder_client_ (struct GSF_ConnectedPeer *cp, * @param cp responding peer (will be updated) * @param initiator_peer other peer responsible for query */ -void GSF_peer_update_responder_peer_ (struct GSF_ConnectedPeer *cp, - const struct GSF_ConnectedPeer - *initiator_peer); - - -/** - * Method called whenever a given peer has a status change. - * - * @param cls closure - * @param peer peer identity this notification is about - * @param bandwidth_in available amount of inbound bandwidth - * @param bandwidth_out available amount of outbound bandwidth - * @param timeout absolute time when this peer will time out - * unless we see some further activity from it - * @param atsi status information - */ -void GSF_peer_status_handler_ (void *cls, - const struct GNUNET_PeerIdentity *peer, - struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in, - struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, - struct GNUNET_TIME_Absolute timeout, - const struct GNUNET_TRANSPORT_ATS_Information - *atsi); +void +GSF_peer_update_responder_peer_ (struct GSF_ConnectedPeer *cp, + const struct GSF_ConnectedPeer + *initiator_peer); /** @@ -281,15 +313,13 @@ void GSF_peer_status_handler_ (void *cls, * @param other the other peer involved (sender or receiver, NULL * for loopback messages where we are both sender and receiver) * @param message the actual message - * @param atsi performance information - * @return GNUNET_OK to keep the connection open, - * GNUNET_SYSERR to close it (signal serious error) + * @return #GNUNET_OK to keep the connection open, + * #GNUNET_SYSERR to close it (signal serious error) */ -int GSF_handle_p2p_migration_stop_ (void *cls, - const struct GNUNET_PeerIdentity *other, - const struct GNUNET_MessageHeader *message, - const struct - GNUNET_TRANSPORT_ATS_Information *atsi); +int +GSF_handle_p2p_migration_stop_ (void *cls, + const struct GNUNET_PeerIdentity *other, + const struct GNUNET_MessageHeader *message); /** @@ -303,33 +333,31 @@ int GSF_handle_p2p_migration_stop_ (void *cls, * @param message the actual message * @return pending request handle, NULL on error */ -struct GSF_PendingRequest *GSF_handle_p2p_query_ (const struct - GNUNET_PeerIdentity *other, - const struct - GNUNET_MessageHeader - *message); +struct GSF_PendingRequest * +GSF_handle_p2p_query_ (const struct GNUNET_PeerIdentity *other, + const struct GNUNET_MessageHeader *message); /** * Return the performance data record for the given peer - * + * * @param cp peer to query * @return performance data record for the peer */ -struct GSF_PeerPerformanceData *GSF_get_peer_performance_data_ (struct - GSF_ConnectedPeer - *cp); +struct GSF_PeerPerformanceData * +GSF_get_peer_performance_data_ (struct GSF_ConnectedPeer *cp); /** * Ask a peer to stop migrating data to us until the given point * in time. - * + * * @param cp peer to ask * @param block_time until when to block */ -void GSF_block_peer_migration_ (struct GSF_ConnectedPeer *cp, - struct GNUNET_TIME_Relative block_time); +void +GSF_block_peer_migration_ (struct GSF_ConnectedPeer *cp, + struct GNUNET_TIME_Absolute block_time); /** @@ -339,8 +367,9 @@ void GSF_block_peer_migration_ (struct GSF_ConnectedPeer *cp, * @param cls unused * @param peer identity of peer that connected */ -void GSF_peer_disconnect_handler_ (void *cls, - const struct GNUNET_PeerIdentity *peer); +void +GSF_peer_disconnect_handler_ (void *cls, + const struct GNUNET_PeerIdentity *peer); /** @@ -349,7 +378,8 @@ void GSF_peer_disconnect_handler_ (void *cls, * * @param lc handle to the local client (henceforth invalid) */ -void GSF_handle_local_client_disconnect_ (const struct GSF_LocalClient *lc); +void +GSF_handle_local_client_disconnect_ (const struct GSF_LocalClient *lc); /** @@ -361,18 +391,31 @@ void GSF_handle_local_client_disconnect_ (const struct GSF_LocalClient *lc); * @param cp peer to reserve bandwidth from * @param pref preference change */ -void GSF_connected_peer_change_preference_ (struct GSF_ConnectedPeer *cp, - uint64_t pref); +void +GSF_connected_peer_change_preference_ (struct GSF_ConnectedPeer *cp, + uint64_t pref); /** * Obtain the identity of a connected peer. * - * @param cp peer to reserve bandwidth from + * @param cp peer to get identity of * @param id identity to set (written to) */ -void GSF_connected_peer_get_identity_ (const struct GSF_ConnectedPeer *cp, - struct GNUNET_PeerIdentity *id); +void +GSF_connected_peer_get_identity_ (const struct GSF_ConnectedPeer *cp, + struct GNUNET_PeerIdentity *id); + + +/** + * Obtain the identity of a connected peer. + * + * @param cp peer to get identity of + * @return reference to peer identity, valid until peer disconnects (!) + */ +const struct GNUNET_PeerIdentity * +GSF_connected_peer_get_identity2_ (const struct GSF_ConnectedPeer *cp); + /** @@ -381,19 +424,22 @@ void GSF_connected_peer_get_identity_ (const struct GSF_ConnectedPeer *cp, * @param it function to call for each peer * @param it_cls closure for it */ -void GSF_iterate_connected_peers_ (GSF_ConnectedPeerIterator it, void *it_cls); +void +GSF_iterate_connected_peers_ (GSF_ConnectedPeerIterator it, void *it_cls); /** * Initialize peer management subsystem. */ -void GSF_connected_peer_init_ (void); +void +GSF_connected_peer_init_ (void); /** * Shutdown peer management subsystem. */ -void GSF_connected_peer_done_ (void); +void +GSF_connected_peer_done_ (void); #endif