aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2012-05-16 16:49:44 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2012-05-16 16:49:44 +0000
commit015238ce88ad391ad693f9395ec247e0a53f8d40 (patch)
tree7b0c8c6a2b5a5a99a85e1c2f1650e0f135ac0773
parentd4c278025719fc145516e98a6619b6136b768c23 (diff)
downloadgnunet-015238ce88ad391ad693f9395ec247e0a53f8d40.tar.gz
gnunet-015238ce88ad391ad693f9395ec247e0a53f8d40.zip
- suggestion throtteling as described in 2362
-rw-r--r--src/ats/gnunet-service-ats_addresses.c27
-rw-r--r--src/ats/gnunet-service-ats_addresses.h10
2 files changed, 37 insertions, 0 deletions
diff --git a/src/ats/gnunet-service-ats_addresses.c b/src/ats/gnunet-service-ats_addresses.c
index 865460452..096a98314 100644
--- a/src/ats/gnunet-service-ats_addresses.c
+++ b/src/ats/gnunet-service-ats_addresses.c
@@ -37,6 +37,8 @@
37 37
38#define VERBOSE GNUNET_NO 38#define VERBOSE GNUNET_NO
39 39
40#define ATS_BLOCKING_DELTA GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 100)
41
40enum ATS_Mode 42enum ATS_Mode
41{ 43{
42 /* 44 /*
@@ -169,6 +171,8 @@ create_address (const struct GNUNET_PeerIdentity *peer,
169 aa->plugin = GNUNET_strdup (plugin_name); 171 aa->plugin = GNUNET_strdup (plugin_name);
170 aa->session_id = session_id; 172 aa->session_id = session_id;
171 aa->mlp_information = NULL; 173 aa->mlp_information = NULL;
174 aa->blocked_until = GNUNET_TIME_absolute_get_zero();
175 aa->block_interval = GNUNET_TIME_relative_get_zero();
172 aa->next = NULL; 176 aa->next = NULL;
173 aa->prev = NULL; 177 aa->prev = NULL;
174 return aa; 178 return aa;
@@ -546,6 +550,26 @@ find_address_it (void *cls, const GNUNET_HashCode * key, void *value)
546 struct ATS_Address **ap = cls; 550 struct ATS_Address **ap = cls;
547 struct ATS_Address *aa = (struct ATS_Address *) value; 551 struct ATS_Address *aa = (struct ATS_Address *) value;
548 struct ATS_Address *ab = *ap; 552 struct ATS_Address *ab = *ap;
553 struct GNUNET_TIME_Absolute now;
554
555 now = GNUNET_TIME_absolute_get();
556
557 if (aa->blocked_until.abs_value == GNUNET_TIME_absolute_max (now, aa->blocked_until).abs_value)
558 {
559 /* This address is blocked for suggestion */
560 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
561 "Address %p blocked for suggestion for %llu ms \n",
562 aa,
563 GNUNET_TIME_absolute_get_difference(now, aa->blocked_until).rel_value);
564 return GNUNET_OK;
565 }
566
567
568 aa->block_interval = GNUNET_TIME_relative_add (aa->block_interval, ATS_BLOCKING_DELTA);
569 aa->blocked_until = GNUNET_TIME_absolute_add (now, aa->block_interval);
570
571 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
572 "Address %p ready for suggestion, block interval now %llu \n", aa, aa->block_interval);
549 573
550 if (NULL == ab) 574 if (NULL == ab)
551 { 575 {
@@ -678,6 +702,9 @@ void request_address_simple (const struct GNUNET_PeerIdentity *peer)
678 return; 702 return;
679 } 703 }
680 704
705 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK,
706 "Suggesting address %p for peer `%s'\n", aa, GNUNET_i2s (peer));
707
681 if (aa->active == GNUNET_NO) 708 if (aa->active == GNUNET_NO)
682 { 709 {
683 aa->active = GNUNET_YES; 710 aa->active = GNUNET_YES;
diff --git a/src/ats/gnunet-service-ats_addresses.h b/src/ats/gnunet-service-ats_addresses.h
index 0ef977b5d..fbe1fc994 100644
--- a/src/ats/gnunet-service-ats_addresses.h
+++ b/src/ats/gnunet-service-ats_addresses.h
@@ -75,6 +75,16 @@ struct ATS_Address
75 struct GNUNET_BANDWIDTH_Value32NBO assigned_bw_out; 75 struct GNUNET_BANDWIDTH_Value32NBO assigned_bw_out;
76 76
77 /** 77 /**
78 * Blocking interval
79 */
80 struct GNUNET_TIME_Relative block_interval;
81
82 /**
83 * Time when address can be suggested again
84 */
85 struct GNUNET_TIME_Absolute blocked_until;
86
87 /**
78 * Is this the active address for this peer? 88 * Is this the active address for this peer?
79 */ 89 */
80 int active; 90 int active;