aboutsummaryrefslogtreecommitdiff
path: root/src/dht/gnunet-service-dht.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2011-09-13 12:24:09 +0000
committerChristian Grothoff <christian@grothoff.org>2011-09-13 12:24:09 +0000
commit0729448dc2ea9c4a12280d48c750de0f1d7fd8c3 (patch)
treed9dea457f85ae4b5b95175198440aee699ec1a87 /src/dht/gnunet-service-dht.c
parent0533836d3bc6d2e6404bf8397b6de71c0d156bbf (diff)
downloadgnunet-0729448dc2ea9c4a12280d48c750de0f1d7fd8c3.tar.gz
gnunet-0729448dc2ea9c4a12280d48c750de0f1d7fd8c3.zip
dce
Diffstat (limited to 'src/dht/gnunet-service-dht.c')
-rw-r--r--src/dht/gnunet-service-dht.c54
1 files changed, 11 insertions, 43 deletions
diff --git a/src/dht/gnunet-service-dht.c b/src/dht/gnunet-service-dht.c
index 53f22cf3f..e815ee200 100644
--- a/src/dht/gnunet-service-dht.c
+++ b/src/dht/gnunet-service-dht.c
@@ -270,6 +270,7 @@ struct PeerInfo
270 GNUNET_SCHEDULER_TaskIdentifier ping_task; 270 GNUNET_SCHEDULER_TaskIdentifier ping_task;
271}; 271};
272 272
273
273/** 274/**
274 * Peers are grouped into buckets. 275 * Peers are grouped into buckets.
275 */ 276 */
@@ -291,6 +292,7 @@ struct PeerBucket
291 unsigned int peers_size; 292 unsigned int peers_size;
292}; 293};
293 294
295
294/** 296/**
295 * Linked list of messages to send to clients. 297 * Linked list of messages to send to clients.
296 */ 298 */
@@ -313,6 +315,7 @@ struct PendingMessage
313 315
314}; 316};
315 317
318
316/** 319/**
317 * Struct containing information about a client, 320 * Struct containing information about a client,
318 * handle to connect to it, and any pending messages 321 * handle to connect to it, and any pending messages
@@ -458,6 +461,7 @@ struct DHT_MessageContext
458 int closest; 461 int closest;
459}; 462};
460 463
464
461/** 465/**
462 * Record used for remembering what peers are waiting for what 466 * Record used for remembering what peers are waiting for what
463 * responses (based on search key). 467 * responses (based on search key).
@@ -510,6 +514,7 @@ struct DHTRouteSource
510 514
511}; 515};
512 516
517
513/** 518/**
514 * Entry in the DHT routing table. 519 * Entry in the DHT routing table.
515 */ 520 */
@@ -530,13 +535,9 @@ struct DHTQueryRecord
530 */ 535 */
531 GNUNET_HashCode key; 536 GNUNET_HashCode key;
532 537
533 /**
534 * Bloomfilter of the peers we've replied to so far
535 */
536 //struct GNUNET_BloomFilter *bloom_results; Don't think we need this, just remove from DLL on response.
537
538}; 538};
539 539
540
540/** 541/**
541 * Context used to calculate the number of find peer messages 542 * Context used to calculate the number of find peer messages
542 * per X time units since our last scheduled find peer message 543 * per X time units since our last scheduled find peer message
@@ -552,6 +553,7 @@ struct FindPeerMessageContext
552 struct GNUNET_TIME_Absolute end; 553 struct GNUNET_TIME_Absolute end;
553}; 554};
554 555
556
555/** 557/**
556 * DHT Routing results structure 558 * DHT Routing results structure
557 */ 559 */
@@ -569,6 +571,7 @@ struct DHTResults
569 571
570}; 572};
571 573
574
572/** 575/**
573 * DHT structure for recent requests. 576 * DHT structure for recent requests.
574 */ 577 */
@@ -585,6 +588,7 @@ struct RecentRequests
585 struct GNUNET_CONTAINER_MultiHashMap *hashmap; 588 struct GNUNET_CONTAINER_MultiHashMap *hashmap;
586}; 589};
587 590
591
588struct RecentRequest 592struct RecentRequest
589{ 593{
590 /** 594 /**
@@ -751,7 +755,7 @@ static unsigned int lowest_bucket; /* Initially equal to MAX_BUCKETS - 1 */
751 * The buckets (Kademlia routing table, complete with growth). 755 * The buckets (Kademlia routing table, complete with growth).
752 * Array of size MAX_BUCKET_SIZE. 756 * Array of size MAX_BUCKET_SIZE.
753 */ 757 */
754static struct PeerBucket k_buckets[MAX_BUCKETS]; /* From 0 to MAX_BUCKETS - 1 */ 758static struct PeerBucket k_buckets[MAX_BUCKETS];
755 759
756/** 760/**
757 * Hash map of all known peers, for easy removal from k_buckets on disconnect. 761 * Hash map of all known peers, for easy removal from k_buckets on disconnect.
@@ -766,7 +770,7 @@ static struct GNUNET_CONTAINER_MultiHashMap *recent_find_peer_requests;
766/** 770/**
767 * Maximum size for each bucket. 771 * Maximum size for each bucket.
768 */ 772 */
769static unsigned int bucket_size = DEFAULT_BUCKET_SIZE; /* Initially equal to DEFAULT_BUCKET_SIZE */ 773static unsigned int bucket_size = DEFAULT_BUCKET_SIZE;
770 774
771/** 775/**
772 * List of active clients. 776 * List of active clients.
@@ -888,42 +892,6 @@ hash_from_uid (uint64_t uid, GNUNET_HashCode * hash)
888 *((uint64_t *) hash) = uid; 892 *((uint64_t *) hash) = uid;
889} 893}
890 894
891#if AVG
892/**
893 * Calculate the average send time between messages so that we can
894 * ignore certain requests if we get too busy.
895 *
896 * @return the average time between asking core to send a message
897 * and when the buffer for copying it is passed
898 */
899static struct GNUNET_TIME_Relative
900get_average_send_delay ()
901{
902 unsigned int i;
903 unsigned int divisor;
904 struct GNUNET_TIME_Relative average_time;
905
906 average_time = GNUNET_TIME_relative_get_zero ();
907 divisor = 0;
908 for (i = 0; i < MAX_REPLY_TIMES; i++)
909 {
910 average_time = GNUNET_TIME_relative_add (average_time, reply_times[i]);
911 if (reply_times[i].abs_value == (uint64_t) 0)
912 continue;
913 else
914 divisor++;
915 }
916 if (divisor == 0)
917 {
918 return average_time;
919 }
920
921 average_time = GNUNET_TIME_relative_divide (average_time, divisor);
922 fprintf (stderr, "Avg send delay: %u sends is %llu\n", divisor,
923 (unsigned long long) average_time.abs_value);
924 return average_time;
925}
926#endif
927 895
928/** 896/**
929 * Given the largest send delay, artificially decrease it 897 * Given the largest send delay, artificially decrease it