API to handle 'connected peers'. More...
Go to the source code of this file.
Data Structures | |
struct | GSF_PeerPerformanceData |
Performance data kept for a peer. More... | |
Macros | |
#define | MAX_QUEUE_PER_PEER 24 |
Maximum number of outgoing messages we queue per peer. More... | |
#define | P2P_SUCCESS_LIST_SIZE 8 |
Length of the P2P success tracker. More... | |
#define | CS2P_SUCCESS_LIST_SIZE 8 |
Length of the CS-2-P success tracker. More... | |
Typedefs | |
typedef void(* | GSF_ConnectedPeerIterator) (void *cls, const struct GNUNET_PeerIdentity *peer, struct GSF_ConnectedPeer *cp, const struct GSF_PeerPerformanceData *ppd) |
Signature of function called on a connected peer. More... | |
typedef size_t(* | GSF_GetMessageCallback) (void *cls, size_t buf_size, void *buf) |
Function called to get a message for transmission. More... | |
typedef void(* | GSF_PeerReserveCallback) (void *cls, struct GSF_ConnectedPeer *cp, int success) |
Signature of function called on a reservation success or failure. More... | |
Functions | |
void * | GSF_peer_connect_handler (void *cls, const struct GNUNET_PeerIdentity *peer, struct GNUNET_MQ_Handle *mq) |
A peer connected to us. More... | |
struct GSF_ConnectedPeer * | GSF_peer_get_ (const struct GNUNET_PeerIdentity *peer) |
Get a handle for a connected peer. More... | |
void | GSF_update_peer_latency_ (const struct GNUNET_PeerIdentity *id, struct GNUNET_TIME_Relative latency) |
Update the latency information kept for the given peer. More... | |
void | GSF_peer_transmit_ (struct GSF_ConnectedPeer *cp, int is_query, uint32_t priority, struct GNUNET_MQ_Envelope *env) |
Transmit a message to the given peer as soon as possible. More... | |
void | GSF_peer_update_performance_ (struct GSF_ConnectedPeer *cp, struct GNUNET_TIME_Absolute request_time, uint32_t request_priority) |
Report on receiving a reply; update the performance record of the given peer. More... | |
void | GSF_peer_update_responder_client_ (struct GSF_ConnectedPeer *cp, struct GSF_LocalClient *initiator_client) |
Report on receiving a reply in response to an initiating client. More... | |
void | GSF_peer_update_responder_peer_ (struct GSF_ConnectedPeer *cp, const struct GSF_ConnectedPeer *initiator_peer) |
Report on receiving a reply in response to an initiating peer. More... | |
void | handle_p2p_migration_stop (void *cls, const struct MigrationStopMessage *message) |
Handle P2P GNUNET_MESSAGE_TYPE_FS_MIGRATION_STOP message. More... | |
void | handle_p2p_get (void *cls, const struct GetMessage *gm) |
Handle P2P "QUERY" message. More... | |
struct GSF_PeerPerformanceData * | GSF_get_peer_performance_data_ (struct GSF_ConnectedPeer *cp) |
Return the performance data record for the given peer. More... | |
void | GSF_block_peer_migration_ (struct GSF_ConnectedPeer *cp, struct GNUNET_TIME_Absolute block_time) |
Ask a peer to stop migrating data to us until the given point in time. More... | |
void | GSF_peer_disconnect_handler (void *cls, const struct GNUNET_PeerIdentity *peer, void *internal_cls) |
A peer disconnected from us. More... | |
void | GSF_handle_local_client_disconnect_ (const struct GSF_LocalClient *lc) |
Notification that a local client disconnected. More... | |
void | GSF_connected_peer_change_preference_ (struct GSF_ConnectedPeer *cp, uint64_t pref) |
Notify core about a preference we have for the given peer (to allocate more resources towards it). More... | |
void | GSF_connected_peer_get_identity_ (const struct GSF_ConnectedPeer *cp, struct GNUNET_PeerIdentity *id) |
Obtain the identity of a connected peer. More... | |
const struct GNUNET_PeerIdentity * | GSF_connected_peer_get_identity2_ (const struct GSF_ConnectedPeer *cp) |
Obtain the identity of a connected peer. More... | |
void | GSF_iterate_connected_peers_ (GSF_ConnectedPeerIterator it, void *it_cls) |
Iterate over all connected peers. More... | |
void | GSF_connected_peer_init_ (void) |
Initialize peer management subsystem. More... | |
void | GSF_connected_peer_done_ (void) |
Shutdown peer management subsystem. More... | |
API to handle 'connected peers'.
Definition in file gnunet-service-fs_cp.h.
#define MAX_QUEUE_PER_PEER 24 |
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).
Definition at line 45 of file gnunet-service-fs_cp.h.
#define P2P_SUCCESS_LIST_SIZE 8 |
Length of the P2P success tracker.
Note that having a very long list can also hurt performance.
Definition at line 51 of file gnunet-service-fs_cp.h.
#define CS2P_SUCCESS_LIST_SIZE 8 |
Length of the CS-2-P success tracker.
Note that having a very long list can also hurt performance.
Definition at line 57 of file gnunet-service-fs_cp.h.
typedef void(* GSF_ConnectedPeerIterator) (void *cls, const struct GNUNET_PeerIdentity *peer, struct GSF_ConnectedPeer *cp, const struct GSF_PeerPerformanceData *ppd) |
Signature of function called on a connected peer.
cls | closure |
peer | identity of the peer |
cp | handle to the connected peer record |
perf | peer performance data |
Definition at line 156 of file gnunet-service-fs_cp.h.
typedef size_t(* GSF_GetMessageCallback) (void *cls, size_t buf_size, void *buf) |
Function called to get a message for transmission.
cls | closure |
buf_size | number of bytes available in buf |
buf | where to copy the message, NULL on error (peer disconnect) |
Definition at line 171 of file gnunet-service-fs_cp.h.
typedef void(* GSF_PeerReserveCallback) (void *cls, struct GSF_ConnectedPeer *cp, int success) |
Signature of function called on a reservation success or failure.
cls | closure |
cp | handle to the connected peer record |
success | GNUNET_YES on success, GNUNET_NO on failure |
Definition at line 184 of file gnunet-service-fs_cp.h.
void * GSF_peer_connect_handler | ( | void * | cls, |
const struct GNUNET_PeerIdentity * | peer, | ||
struct GNUNET_MQ_Handle * | mq | ||
) |
A peer connected to us.
Setup the connected peer records.
cls | NULL |
peer | identity of peer that connected |
mq | message queue for talking to peer |
Definition at line 456 of file gnunet-service-fs_cp.c.
References consider_peer_for_forwarding(), cp_map, gettext_noop, GNUNET_break, GNUNET_CONTAINER_multihashmap_create(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY, GNUNET_CONTAINER_multipeermap_put(), GNUNET_CONTAINER_multipeermap_size(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_i2s(), GNUNET_LOAD_value_init(), GNUNET_log, GNUNET_memcmp, GNUNET_new, GNUNET_NO, GNUNET_OK, GNUNET_PEER_intern(), GNUNET_PEERSTORE_iteration_start(), GNUNET_STATISTICS_set(), GNUNET_TIME_UNIT_ZERO, GNUNET_YES, GSF_connected_peer_get_identity2_(), GSF_iterate_pending_requests_(), GSF_my_id, GSF_stats, mq, GSF_ConnectedPeer::mq, GSF_PeerPerformanceData::peer, peer_respect_cb(), peerstore, GSF_PeerPerformanceData::pid, GSF_ConnectedPeer::ppd, GSF_ConnectedPeer::request_map, GSF_ConnectedPeer::respect_iterate_req, and GSF_PeerPerformanceData::transmission_delay.
Referenced by main_init().
struct GSF_ConnectedPeer * GSF_peer_get_ | ( | const struct GNUNET_PeerIdentity * | peer | ) |
Get a handle for a connected peer.
peer | peer's identity |
Definition at line 526 of file gnunet-service-fs_cp.c.
References cp_map, and GNUNET_CONTAINER_multipeermap_get().
Referenced by GSF_update_peer_latency_(), handle_p2p_get(), and put_migration_continuation().
void GSF_update_peer_latency_ | ( | const struct GNUNET_PeerIdentity * | id, |
struct GNUNET_TIME_Relative | latency | ||
) |
Update the latency information kept for the given peer.
id | peer record to update |
latency | current latency value |
Definition at line 286 of file gnunet-service-fs_cp.c.
References GNUNET_LOAD_value_set_decline(), GSF_peer_get_(), GSF_ConnectedPeer::ppd, and GSF_PeerPerformanceData::transmission_delay.
void GSF_peer_transmit_ | ( | struct GSF_ConnectedPeer * | cp, |
int | is_query, | ||
uint32_t | priority, | ||
struct GNUNET_MQ_Envelope * | env | ||
) |
Transmit a message to the given peer as soon as possible.
If the peer disconnects before the transmission can happen, the callback is invoked with a 'NULL' buffer.
cp | target peer |
is_query | is this a query (GNUNET_YES) or content (GNUNET_NO) |
priority | how important is this request? |
env | envelope of message to send |
If the peer disconnects before the transmission can happen, the callback is invoked with a NULL
buffer.
cp | target peer |
is_query | is this a query (GNUNET_YES) or content (GNUNET_NO) or neither (GNUNET_SYSERR) |
priority | how important is this request? |
env | message to send |
Definition at line 1231 of file gnunet-service-fs_cp.c.
References GSF_PeerTransmitHandle::cp, env, GSF_PeerTransmitHandle::env, GNUNET_CONTAINER_DLL_insert_after, GNUNET_new, GNUNET_NO, GNUNET_TIME_absolute_get(), GNUNET_YES, GSF_PeerTransmitHandle::is_query, GSF_PeerTransmitHandle::next, GSF_PeerPerformanceData::pending_queries, GSF_PeerPerformanceData::pending_replies, GSF_ConnectedPeer::ppd, GSF_PeerTransmitHandle::prev, GSF_PeerTransmitHandle::priority, GSF_ConnectedPeer::pth_head, GSF_ConnectedPeer::pth_tail, schedule_transmission(), and GSF_PeerTransmitHandle::transmission_request_start_time.
Referenced by GSF_block_peer_migration_(), handle_p2p_reply(), schedule_peer_transmission(), transmit_content(), and transmit_delayed_now().
void GSF_peer_update_performance_ | ( | struct GSF_ConnectedPeer * | cp, |
struct GNUNET_TIME_Absolute | request_time, | ||
uint32_t | request_priority | ||
) |
Report on receiving a reply; update the performance record of the given peer.
cp | responding peer (will be updated) |
request_time | time at which the original query was transmitted |
request_priority | priority of the original request |
Definition at line 1274 of file gnunet-service-fs_cp.c.
References GSF_PeerPerformanceData::avg_priority, GSF_PeerPerformanceData::avg_reply_delay, GNUNET_TIME_absolute_get_duration(), GSF_ConnectedPeer::ppd, GNUNET_TIME_Relative::rel_value_us, and RUNAVG_DELAY_N.
Referenced by update_request_performance_data().
void GSF_peer_update_responder_client_ | ( | struct GSF_ConnectedPeer * | cp, |
struct GSF_LocalClient * | initiator_client | ||
) |
Report on receiving a reply in response to an initiating client.
Remember that this peer is good for this client.
cp | responding peer (will be updated) |
initiator_client | local client on responsible for query |
Definition at line 1298 of file gnunet-service-fs_cp.c.
References CS2P_SUCCESS_LIST_SIZE, GSF_PeerPerformanceData::last_client_replies, GSF_ConnectedPeer::last_client_replies_woff, and GSF_ConnectedPeer::ppd.
void GSF_peer_update_responder_peer_ | ( | struct GSF_ConnectedPeer * | cp, |
const struct GSF_ConnectedPeer * | initiator_peer | ||
) |
Report on receiving a reply in response to an initiating peer.
Remember that this peer is good for this initiating peer.
cp | responding peer (will be updated) |
initiator_peer | other peer responsible for query |
Definition at line 1314 of file gnunet-service-fs_cp.c.
References GNUNET_PEER_change_rc(), GSF_PeerPerformanceData::last_p2p_replies, GSF_ConnectedPeer::last_p2p_replies_woff, P2P_SUCCESS_LIST_SIZE, GSF_PeerPerformanceData::pid, and GSF_ConnectedPeer::ppd.
void handle_p2p_migration_stop | ( | void * | cls, |
const struct MigrationStopMessage * | msm | ||
) |
Handle P2P GNUNET_MESSAGE_TYPE_FS_MIGRATION_STOP message.
cls | closure, the struct GSF_ConnectedPeer |
msm | the actual message |
Definition at line 541 of file gnunet-service-fs_cp.c.
References _, MigrationStopMessage::duration, gettext_noop, GNUNET_ERROR_TYPE_INFO, GNUNET_i2s(), GNUNET_log, GNUNET_NO, GNUNET_SCHEDULER_add_delayed(), GNUNET_STATISTICS_update(), GNUNET_STRINGS_relative_time_to_string(), GNUNET_TIME_relative_ntoh(), GNUNET_TIME_relative_to_absolute(), GNUNET_YES, GSF_push_stop_(), GSF_stats, GSF_ConnectedPeer::mig_revive_task, GSF_PeerPerformanceData::migration_blocked_until, GSF_PeerPerformanceData::peer, GSF_ConnectedPeer::ppd, GSF_ConnectedPeer::respect_iterate_req, and revive_migration().
void handle_p2p_get | ( | void * | cls, |
const struct GetMessage * | gm | ||
) |
Handle P2P "QUERY" message.
cls | the struct GSF_ConnectedPeer of the other sender |
gm | the actual message |
Creates the pending request entry and sets up all of the data structures to that we will process replies properly. Does not initiate forwarding or local database lookups.
cls | the other peer involved (sender of the message) |
gm | the GET message |
Definition at line 1033 of file gnunet-service-fs_cp.c.
References bound_priority(), bound_ttl(), PeerRequest::cp, GSF_ConnectedPeer::delay_queue_size, TestExistClosure::finished, GET_MESSAGE_BIT_RETURN_TO, GET_MESSAGE_BIT_TRANSMIT_TO, gettext_noop, GNUNET_assert, GNUNET_break, GNUNET_CONSTANTS_MAX_CORK_DELAY, GNUNET_CONTAINER_multihashmap_get_multiple(), GNUNET_CONTAINER_multihashmap_put(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE, GNUNET_CRYPTO_QUALITY_WEAK, GNUNET_CRYPTO_random_u32(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_h2s(), GNUNET_i2s(), GNUNET_LOAD_get_average(), GNUNET_LOAD_get_load(), GNUNET_log, GNUNET_MQ_get_length(), GNUNET_new, GNUNET_NO, GNUNET_OK, GNUNET_PEER_intern(), GNUNET_STATISTICS_update(), GNUNET_YES, GSF_consider_forwarding(), GSF_cover_query_count, GSF_local_lookup_(), GSF_peer_get_(), GSF_pending_request_create_(), GSF_pending_request_get_data_(), GSF_PRO_DEFAULTS, GSF_PRO_FORWARD_ONLY, GSF_rt_entry_lifetime, GSF_stats, handle_p2p_reply(), GSF_PendingRequestData::has_started, GetMessage::hash_bitmap, GetMessage::header, MAX_QUEUE_PER_PEER, GSF_ConnectedPeer::mq, options, GSF_PeerPerformanceData::peer, GSF_PeerPerformanceData::pending_replies, GSF_ConnectedPeer::ppd, PeerRequest::pr, GetMessage::priority, TestExistClosure::priority, GetMessage::query, GSF_PendingRequestData::query, GSF_ConnectedPeer::request_map, GNUNET_MessageHeader::size, test_exist_cb(), GSF_PeerPerformanceData::transmission_delay, GetMessage::ttl, TestExistClosure::ttl, TTL_DECREMENT, GetMessage::type, and TestExistClosure::type.
struct GSF_PeerPerformanceData * GSF_get_peer_performance_data_ | ( | struct GSF_ConnectedPeer * | cp | ) |
Return the performance data record for the given peer.
cp | peer to query |
Definition at line 306 of file gnunet-service-fs_cp.c.
References GSF_ConnectedPeer::ppd.
Referenced by handle_p2p_put(), put_migration_continuation(), score_content(), and transmit_content().
void GSF_block_peer_migration_ | ( | struct GSF_ConnectedPeer * | cp, |
struct GNUNET_TIME_Absolute | block_time | ||
) |
Ask a peer to stop migrating data to us until the given point in time.
cp | peer to ask |
block_time | until when to block |
Definition at line 1522 of file gnunet-service-fs_cp.c.
References GNUNET_TIME_Absolute::abs_value_us, MigrationStopMessage::duration, env, gettext_noop, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_MESSAGE_TYPE_FS_MIGRATION_STOP, GNUNET_MQ_msg, GNUNET_NO, GNUNET_STATISTICS_update(), GNUNET_STRINGS_relative_time_to_string(), GNUNET_SYSERR, GNUNET_TIME_absolute_get_remaining(), GNUNET_TIME_relative_hton(), GNUNET_YES, GSF_peer_transmit_(), GSF_stats, GSF_ConnectedPeer::last_migration_block, and MigrationStopMessage::reserved.
Referenced by handle_p2p_put(), and put_migration_continuation().
void GSF_peer_disconnect_handler | ( | void * | cls, |
const struct GNUNET_PeerIdentity * | peer, | ||
void * | internal_cls | ||
) |
A peer disconnected from us.
Tear down the connected peer record.
cls | unused |
peer | identity of peer that disconnected |
internal_cls | the corresponding struct GSF_ConnectedPeer |
Definition at line 1358 of file gnunet-service-fs_cp.c.
References cancel_pending_request(), GSF_DelayedHandle::cp, cp_map, GSF_ConnectedPeer::delay_queue_size, GSF_DelayedHandle::delay_task, GSF_ConnectedPeer::delayed_head, GSF_ConnectedPeer::delayed_tail, GSF_DelayedHandle::env, flush_respect(), gettext_noop, GNUNET_assert, GNUNET_break, GNUNET_CONTAINER_DLL_remove, GNUNET_CONTAINER_multihashmap_destroy(), GNUNET_CONTAINER_multihashmap_iterate(), GNUNET_CONTAINER_multipeermap_remove(), GNUNET_CONTAINER_multipeermap_size(), GNUNET_free, GNUNET_LOAD_value_free, GNUNET_MQ_discard(), GNUNET_NO, GNUNET_PEER_change_rc(), GNUNET_PEER_decrement_rcs(), GNUNET_PEERSTORE_iteration_stop(), GNUNET_SCHEDULER_cancel(), GNUNET_STATISTICS_set(), GNUNET_YES, GSF_plan_notify_peer_disconnect_(), GSF_push_stop_(), GSF_stats, GSF_PeerTransmitHandle::is_query, GSF_PeerPerformanceData::last_p2p_replies, GSF_ConnectedPeer::mig_revive_task, P2P_SUCCESS_LIST_SIZE, GSF_PeerPerformanceData::pending_queries, GSF_PeerPerformanceData::pending_replies, GSF_PeerPerformanceData::pid, GSF_ConnectedPeer::ppd, GSF_ConnectedPeer::pth_head, GSF_ConnectedPeer::pth_tail, GSF_ConnectedPeer::request_map, GSF_ConnectedPeer::respect_iterate_req, and GSF_PeerPerformanceData::transmission_delay.
Referenced by main_init().
void GSF_handle_local_client_disconnect_ | ( | const struct GSF_LocalClient * | lc | ) |
Notification that a local client disconnected.
Clean up all of our references to the given handle.
lc | handle to the local client (henceforth invalid) |
Definition at line 1657 of file gnunet-service-fs_cp.c.
References clean_local_client(), cp_map, and GNUNET_CONTAINER_multipeermap_iterate().
void GSF_connected_peer_change_preference_ | ( | struct GSF_ConnectedPeer * | cp, |
uint64_t | pref | ||
) |
Notify core about a preference we have for the given peer (to allocate more resources towards it).
The change will be communicated the next time we reserve bandwidth with core (not instantly).
cp | peer to reserve bandwidth from |
pref | preference change |
Definition at line 1570 of file gnunet-service-fs_cp.c.
References GSF_ConnectedPeer::inc_preference.
Referenced by handle_p2p_put().
void GSF_connected_peer_get_identity_ | ( | const struct GSF_ConnectedPeer * | cp, |
struct GNUNET_PeerIdentity * | id | ||
) |
Obtain the identity of a connected peer.
cp | peer to get identity of |
id | identity to set (written to) |
Definition at line 1492 of file gnunet-service-fs_cp.c.
References GNUNET_assert, GNUNET_PEER_resolve(), GSF_PeerPerformanceData::pid, and GSF_ConnectedPeer::ppd.
Referenced by consider_peer_for_forwarding().
const struct GNUNET_PeerIdentity * GSF_connected_peer_get_identity2_ | ( | const struct GSF_ConnectedPeer * | cp | ) |
Obtain the identity of a connected peer.
cp | peer to get identity of |
Definition at line 1507 of file gnunet-service-fs_cp.c.
References GNUNET_assert, GNUNET_PEER_resolve2(), GSF_PeerPerformanceData::pid, and GSF_ConnectedPeer::ppd.
Referenced by GSF_peer_connect_handler(), GSF_plan_add_(), GSF_plan_notify_peer_disconnect_(), GSF_push_start_(), and process_migration_content().
void GSF_iterate_connected_peers_ | ( | GSF_ConnectedPeerIterator | it, |
void * | it_cls | ||
) |
Iterate over all connected peers.
it | function to call for each peer |
it_cls | closure for it |
Definition at line 1472 of file gnunet-service-fs_cp.c.
References call_iterator(), cp_map, GNUNET_CONTAINER_multipeermap_iterate(), IterationContext::it, and IterationContext::it_cls.
Referenced by GSF_consider_forwarding().
void GSF_connected_peer_init_ | ( | void | ) |
Initialize peer management subsystem.
Definition at line 1600 of file gnunet-service-fs_cp.c.
References cp_map, cron_flush_respect(), fr_task, GNUNET_CONTAINER_multipeermap_create(), GNUNET_PEERSTORE_connect(), GNUNET_SCHEDULER_add_with_priority(), GNUNET_SCHEDULER_PRIORITY_HIGH, GNUNET_YES, GSF_cfg, and peerstore.
Referenced by run().
void GSF_connected_peer_done_ | ( | void | ) |
Shutdown peer management subsystem.
Definition at line 1613 of file gnunet-service-fs_cp.c.
References cp_map, flush_respect(), fr_task, GNUNET_CONTAINER_multipeermap_destroy(), GNUNET_CONTAINER_multipeermap_iterate(), GNUNET_PEERSTORE_disconnect(), GNUNET_SCHEDULER_cancel(), and peerstore.
Referenced by shutdown_task().