35 #define INSANE_STATISTICS GNUNET_NO 41 struct PendingRequestList;
249 #define N ((double) 128.0) 253 static double avg_delay;
281 avg_delay = (((avg_delay * (
N - 1.0)) + delay.
rel_value_us) /
N) + 0.01;
305 + 1.0) * atan (delay.
rel_value_us / avg_delay)) / M_PI_4;
311 "Considering (re)transmission number %u in %s\n",
317 "Earliest (re)transmission for `%s' in %us\n",
385 if (NULL != pp->
task)
411 "No active requests for plan %p.\n",
417 "Sleeping for %s before retrying requests on plan %p.\n",
431 #if INSANE_STATISTICS 440 "Executing query plan %p\n",
448 "Executing plan %p executed %u times, planning retransmission\n",
462 "# query messages sent to other peers"),
528 #if INSANE_STATISTICS 538 #if INSANE_STATISTICS 604 "Planning transmission of query `%s' to peer `%s'\n",
652 if (NULL != pp->
task)
663 while (NULL != (bi = rp->
pe_head))
686 while (NULL != (bi = rp->
pe_head))
732 for (bi = pr_head; NULL != bi; bi = bi->
next_PR)
734 if (bi->
rp->
pp->
cp == sender)
761 while (NULL != (bi = prd->
pr_head))
API to handle 'connected peers'.
void GSF_plan_add_(struct GSF_ConnectedPeer *cp, struct GSF_PendingRequest *pr)
Create a new query plan entry.
uint64_t rel_value_us
The actual value.
static unsigned long long total_delay
Sum of all transmission counters (equals total delay for all plan entries).
void GSF_plan_done()
Shutdown plan subsystem.
int GSF_request_plan_reference_get_last_transmission_(struct GSF_PendingRequestPlanBijection *pr_head, struct GSF_ConnectedPeer *sender, struct GNUNET_TIME_Absolute *result)
Get the last transmission attempt time for the request plan list referenced by pr_head, that was sent to sender.
struct GSF_RequestPlan * next
This is a doubly-linked list.
static GNUNET_CronTime last_transmission
struct GNUNET_CONTAINER_MultiHashMap * plan_map
Map of queries to plan entries.
struct GSF_PendingRequestPlanBijection * next_PE
This is a doubly-linked list.
struct GNUNET_CONTAINER_HeapNode * GNUNET_CONTAINER_heap_insert(struct GNUNET_CONTAINER_Heap *heap, void *element, GNUNET_CONTAINER_HeapCostType cost)
Inserts a new element into the heap.
double GSF_current_priorities
Typical priorities we're seeing from other peers right now.
struct GNUNET_TIME_Absolute ttl
Current TTL for the request.
struct GNUNET_TIME_Absolute GNUNET_TIME_relative_to_absolute(struct GNUNET_TIME_Relative rel)
Convert relative time to an absolute time in the future.
Transmission plan for a peer.
uint32_t GNUNET_CRYPTO_random_u32(enum GNUNET_CRYPTO_Quality mode, uint32_t i)
Produce a random value.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
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.
#define GNUNET_TIME_UNIT_SECONDS
One second.
struct GNUNET_MQ_Envelope * env
Current message under transmission for the plan.
static unsigned long long plan_count
Number of plan entries.
struct GSF_PendingRequestPlanBijection * pr_head
Fields for the plan module to track a DLL with the request.
static int ret
Return value of the commandline.
struct GNUNET_STATISTICS_Handle * GSF_stats
Handle for reporting statistics.
int GNUNET_CONTAINER_multipeermap_remove(struct GNUNET_CONTAINER_MultiPeerMap *map, const struct GNUNET_PeerIdentity *key, const void *value)
Remove the given key-value pair from the map.
shared data structures of gnunet-service-fs.c
struct GSF_PendingRequestPlanBijection * next_PR
This is a doubly-linked list.
static struct GNUNET_IDENTITY_Handle * id
Handle to identity service.
const char * GNUNET_h2s(const struct GNUNET_HashCode *hc)
Convert a hash value to a string (for printing debug messages).
#define GNUNET_new(type)
Allocate a struct or union of the given type.
int GSF_pending_request_is_compatible_(struct GSF_PendingRequest *pra, struct GSF_PendingRequest *prb)
Test if two pending requests are compatible (would generate the same query modulo filters and should ...
void GNUNET_STATISTICS_update(struct GNUNET_STATISTICS_Handle *handle, const char *name, int64_t delta, int make_persistent)
Set statistic value for the peer.
struct GNUNET_CONTAINER_MultiPeerMap * GNUNET_CONTAINER_multipeermap_create(unsigned int len, int do_not_copy_keys)
Create a multi peer map (hash map for public keys of peers).
static const struct GNUNET_HashCode * get_rp_key(struct GSF_RequestPlan *rp)
Return the query (key in the plan_map) for the given request plan.
uint64_t abs_value_us
The actual value.
Internal representation of the hash map.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
void GNUNET_CONTAINER_multipeermap_destroy(struct GNUNET_CONTAINER_MultiPeerMap *map)
Destroy a hash map.
struct GSF_ConnectedPeer * cp
Peer for which this is the plan.
struct GSF_RequestPlan * rp
Associated request plan (tells us one of the peers that we plan to forward the request to)...
#define GNUNET_TIME_UNIT_FOREVER_ABS
Constant used to specify "forever".
struct GNUNET_HashCode query
Primary query hash for this request.
struct GSF_PendingRequestPlanBijection * pe_head
Head of list of associated pending requests.
struct GSF_PendingRequestPlanBijection * pe_tail
Tail of list of associated pending requests.
API to handle pending requests.
struct GNUNET_CONTAINER_Heap * delay_heap
Heap with pending queries (struct GSF_RequestPlan), by transmission time, lowest first.
Public data (in the sense of not encapsulated within 'gnunet-service-fs_pr', not in the sense of netw...
int merged
Set to GNUNET_YES if we succeeded to merge.
API to manage query plan.
static void schedule_peer_transmission(void *cls)
Figure out when and how to transmit to the given peer.
#define GNUNET_CONTAINER_MDLL_insert(mdll, head, tail, element)
Insert an element at the head of a MDLL.
struct GNUNET_TIME_Absolute earliest_transmission
Earliest time we'd be happy to (re)transmit this request.
struct PeerPlan * pp
The transmission plan for a peer that this request is associated with.
void GNUNET_MQ_notify_sent(struct GNUNET_MQ_Envelope *ev, GNUNET_SCHEDULER_TaskCallback cb, void *cb_cls)
Call a callback once the envelope has been sent, that is, sending it can not be canceled anymore...
unsigned int transmission_counter
How often did we transmit this request to this peer?
int GSF_pending_request_test_active_(struct GSF_PendingRequest *pr)
Check if the given request is still active.
void GSF_plan_init()
Initialize plan subsystem.
void GNUNET_CONTAINER_multihashmap_destroy(struct GNUNET_CONTAINER_MultiHashMap *map)
Destroy a hash map.
#define GNUNET_CONTAINER_MDLL_remove(mdll, head, tail, element)
Remove an element from a MDLL.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_now(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run as soon as possible.
void * GNUNET_CONTAINER_heap_peek(const struct GNUNET_CONTAINER_Heap *heap)
Get element stored at the root of heap.
const char * GNUNET_STRINGS_relative_time_to_string(struct GNUNET_TIME_Relative delta, int do_round)
Give relative time in human-readable fancy format.
int GNUNET_CONTAINER_multihashmap_remove(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key, const void *value)
Remove the given key-value pair from the map.
static int result
Global testing status.
struct GNUNET_TIME_Relative GNUNET_TIME_relative_multiply(struct GNUNET_TIME_Relative rel, unsigned long long factor)
Multiply relative time by a given factor.
static void plan(struct PeerPlan *pp, struct GSF_RequestPlan *rp)
Insert the given request plan into the heap with the appropriate weight.
Handle to a node in a heap.
Internal representation of the hash map.
Heap with the minimum cost at the root.
void GNUNET_STATISTICS_set(struct GNUNET_STATISTICS_Handle *handle, const char *name, uint64_t value, int make_persistent)
Set statistic value for the peer.
void GNUNET_CONTAINER_heap_destroy(struct GNUNET_CONTAINER_Heap *heap)
Destroys the heap.
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get(void)
Get the current time.
void GSF_plan_notify_request_done_(struct GSF_PendingRequest *pr)
Notify the plan about a request being done; destroy all entries associated with this request...
struct GSF_PendingRequest * pr
Associated pending request (identifies request details and one of the origins of the request)...
unsigned int GNUNET_CONTAINER_heap_get_size(const struct GNUNET_CONTAINER_Heap *heap)
Get the current size of the heap.
There must only be one value per key; storing a value should fail if a value under the same key alrea...
struct GSF_PendingRequestPlanBijection * pr_tail
Fields for the plan module to track a DLL with the request.
struct GNUNET_CONTAINER_HeapNode * hn
Heap node associated with this request and this peer.
struct GNUNET_TIME_Absolute last_transmission
When was the last time we transmitted this request to this peer? 0 for never.
int GNUNET_CONTAINER_multihashmap_contains_value(const struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key, const void *value)
Check if the map contains the given value under the given key.
Information we keep per request per peer.
int GNUNET_CONTAINER_multihashmap_put(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key, void *value, enum GNUNET_CONTAINER_MultiHashMapOption opt)
Store a key-value pair in the map.
struct GNUNET_CONTAINER_Heap * GNUNET_CONTAINER_heap_create(enum GNUNET_CONTAINER_HeapOrder order)
Create a new heap.
struct GNUNET_MQ_Envelope * GSF_pending_request_get_message_(struct GSF_PendingRequest *pr)
Generate the message corresponding to the given pending request for transmission to other peers...
Allow multiple values with the same key.
int GNUNET_CONTAINER_multipeermap_put(struct GNUNET_CONTAINER_MultiPeerMap *map, const struct GNUNET_PeerIdentity *key, void *value, enum GNUNET_CONTAINER_MultiHashMapOption opt)
Store a key-value pair in the map.
The identity of the host (wraps the signing key of the peer).
struct GSF_PendingRequestData * GSF_pending_request_get_data_(struct GSF_PendingRequest *pr)
Obtain the public data associated with a pending request.
int GNUNET_CONTAINER_multihashmap_get_multiple(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key, GNUNET_CONTAINER_MulitHashMapIteratorCallback it, void *it_cls)
Iterate over all entries in the map that match a particular key.
const struct GNUNET_PeerIdentity * GSF_connected_peer_get_identity2_(const struct GSF_ConnectedPeer *cp)
Obtain the identity of a connected peer.
void * GNUNET_CONTAINER_multipeermap_get(const struct GNUNET_CONTAINER_MultiPeerMap *map, const struct GNUNET_PeerIdentity *key)
Given a key find a value in the map matching the key.
Heap with the maximum cost at the root.
#define GNUNET_log(kind,...)
Entry in list of pending tasks.
void * GNUNET_CONTAINER_heap_remove_root(struct GNUNET_CONTAINER_Heap *heap)
Remove root of the heap.
#define TTL_DECREMENT
By which amount do we decrement the TTL for simple forwarding / indirection of the query; in milli-se...
struct GSF_PendingRequest * pr
Request we are trying to merge.
struct GNUNET_CONTAINER_MultiHashMap * GNUNET_CONTAINER_multihashmap_create(unsigned int len, int do_not_copy_keys)
Create a multi hash map.
void GSF_plan_notify_peer_disconnect_(const struct GSF_ConnectedPeer *cp)
Notify the plan about a peer being no longer available; destroy all entries associated with this peer...
struct GSF_RequestPlan * prev
This is a doubly-linked list.
struct GNUNET_TIME_Relative GNUNET_TIME_absolute_get_remaining(struct GNUNET_TIME_Absolute future)
Given a timestamp in the future, how much time remains until then?
Time for absolute times used by GNUnet, in microseconds.
struct GSF_PendingRequestPlanBijection * prev_PR
This is a doubly-linked list.
struct GNUNET_SCHEDULER_Task * task
Current task for executing the plan.
static int merge_pr(void *cls, const struct GNUNET_HashCode *query, void *element)
Iterator that checks if an equivalent request is already present for this peer.
unsigned int GNUNET_CONTAINER_multipeermap_size(const struct GNUNET_CONTAINER_MultiPeerMap *map)
Get the number of key-value pairs in the map.
uint64_t priority
Current priority for this request for this target.
static struct GNUNET_CONTAINER_MultiPeerMap * plans
Hash map from peer identities to PeerPlans.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_at(struct GNUNET_TIME_Absolute at, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run at the specified time.
void * GNUNET_CONTAINER_heap_remove_node(struct GNUNET_CONTAINER_HeapNode *node)
Removes a node from the heap.
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
struct GSF_PendingRequestPlanBijection * prev_PE
This is a doubly-linked list.
No good quality of the operation is needed (i.e., random numbers can be pseudo-random).
struct GSF_PendingRequest * get_latest(const struct GSF_RequestPlan *rp)
Get the pending request with the highest TTL from the given plan.
#define GNUNET_free(ptr)
Wrapper around free.
Time for relative time used by GNUnet, in microseconds.
M:N binding of plans to pending requests.
#define gettext_noop(String)
struct GNUNET_CONTAINER_Heap * priority_heap
Heap with pending queries (struct GSF_RequestPlan), higher weights mean higher priority.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.