diff options
author | Christian Grothoff <christian@grothoff.org> | 2011-11-07 22:06:02 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2011-11-07 22:06:02 +0000 |
commit | f8c0f7d5c566bbddc2909eceeb63e6ecee591d70 (patch) | |
tree | cb03a293b5a5372f18bb114b01d02fd48d76865d /src/transport/gnunet-service-transport_validation.c | |
parent | 174ab5aba2bdfde8a4614bf0069a33a7bbe57ce7 (diff) | |
download | gnunet-f8c0f7d5c566bbddc2909eceeb63e6ecee591d70.tar.gz gnunet-f8c0f7d5c566bbddc2909eceeb63e6ecee591d70.zip |
more code to get latency in ATSI working; not complete, also now generating a warning -- for a real problem that still needs to be fixed
Diffstat (limited to 'src/transport/gnunet-service-transport_validation.c')
-rw-r--r-- | src/transport/gnunet-service-transport_validation.c | 66 |
1 files changed, 46 insertions, 20 deletions
diff --git a/src/transport/gnunet-service-transport_validation.c b/src/transport/gnunet-service-transport_validation.c index ce2ef76a7..afc35a3a6 100644 --- a/src/transport/gnunet-service-transport_validation.c +++ b/src/transport/gnunet-service-transport_validation.c | |||
@@ -529,13 +529,6 @@ revalidate_address (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
529 | 529 | ||
530 | ve->revalidation_task = GNUNET_SCHEDULER_NO_TASK; | 530 | ve->revalidation_task = GNUNET_SCHEDULER_NO_TASK; |
531 | delay = GNUNET_TIME_absolute_get_remaining (ve->revalidation_block); | 531 | delay = GNUNET_TIME_absolute_get_remaining (ve->revalidation_block); |
532 | if (delay.rel_value > 0) | ||
533 | { | ||
534 | /* should wait a bit longer */ | ||
535 | ve->revalidation_task = | ||
536 | GNUNET_SCHEDULER_add_delayed (delay, &revalidate_address, ve); | ||
537 | return; | ||
538 | } | ||
539 | /* How long until we can possibly permit the next PING? */ | 532 | /* How long until we can possibly permit the next PING? */ |
540 | canonical_delay = | 533 | canonical_delay = |
541 | (ve->in_use == GNUNET_YES) | 534 | (ve->in_use == GNUNET_YES) |
@@ -543,6 +536,19 @@ revalidate_address (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
543 | : ( (GNUNET_TIME_absolute_get_remaining (ve->valid_until).rel_value > 0) | 536 | : ( (GNUNET_TIME_absolute_get_remaining (ve->valid_until).rel_value > 0) |
544 | ? VALIDATED_PING_FREQUENCY | 537 | ? VALIDATED_PING_FREQUENCY |
545 | : UNVALIDATED_PING_KEEPALIVE); | 538 | : UNVALIDATED_PING_KEEPALIVE); |
539 | if (delay.rel_value > canonical_delay.rel_value * 2) | ||
540 | { | ||
541 | /* situation changed, recalculate delay */ | ||
542 | delay = canonical_delay; | ||
543 | ve->revalidation_block = GNUNET_TIME_relative_to_absolute (delay); | ||
544 | } | ||
545 | if (delay.rel_value > 0) | ||
546 | { | ||
547 | /* should wait a bit longer */ | ||
548 | ve->revalidation_task = | ||
549 | GNUNET_SCHEDULER_add_delayed (delay, &revalidate_address, ve); | ||
550 | return; | ||
551 | } | ||
546 | ve->revalidation_block = | 552 | ve->revalidation_block = |
547 | GNUNET_TIME_relative_to_absolute (canonical_delay); | 553 | GNUNET_TIME_relative_to_absolute (canonical_delay); |
548 | 554 | ||
@@ -1180,10 +1186,9 @@ GST_validation_get_addresses (const struct GNUNET_PeerIdentity *target, | |||
1180 | * Based on this, the validation module will measure latency for the | 1186 | * Based on this, the validation module will measure latency for the |
1181 | * address more or less often. | 1187 | * address more or less often. |
1182 | * | 1188 | * |
1183 | * @param sender peer sending the PING | 1189 | * @param sender peer |
1184 | * @param hdr the PING | 1190 | * @param plugin_name name of plugin |
1185 | * @param plugin_name name of plugin that received the PING | 1191 | * @param session session |
1186 | * @param session session we got the PING from | ||
1187 | * @param sender_address address of the sender as known to the plugin, NULL | 1192 | * @param sender_address address of the sender as known to the plugin, NULL |
1188 | * if we did not initiate the connection | 1193 | * if we did not initiate the connection |
1189 | * @param sender_address_len number of bytes in sender_address | 1194 | * @param sender_address_len number of bytes in sender_address |
@@ -1192,13 +1197,32 @@ GST_validation_get_addresses (const struct GNUNET_PeerIdentity *target, | |||
1192 | */ | 1197 | */ |
1193 | void | 1198 | void |
1194 | GST_validation_set_address_use (const struct GNUNET_PeerIdentity *sender, | 1199 | GST_validation_set_address_use (const struct GNUNET_PeerIdentity *sender, |
1195 | const struct GNUNET_MessageHeader *hdr, | ||
1196 | const char *plugin_name, struct Session *session, | 1200 | const char *plugin_name, struct Session *session, |
1197 | const void *sender_address, | 1201 | const void *sender_address, |
1198 | size_t sender_address_len, | 1202 | size_t sender_address_len, |
1199 | int in_use) | 1203 | int in_use) |
1200 | { | 1204 | { |
1201 | // FIXME: lookup address, update flag, re-schedule validation task | 1205 | struct ValidationEntry *ve; |
1206 | |||
1207 | ve = find_validation_entry (NULL, sender, plugin_name, sender_address, sender_address_len); | ||
1208 | if (NULL == ve) | ||
1209 | { | ||
1210 | /* FIXME: this can happen for inbound connections (sender_address_len == 0); | ||
1211 | in that case, we should hack up some more code here to measure | ||
1212 | latency for inbound connections! Also, in this case we'll need the session... | ||
1213 | */ | ||
1214 | GNUNET_break (0); | ||
1215 | return; | ||
1216 | } | ||
1217 | GNUNET_break (ve->in_use != in_use); /* should be different... */ | ||
1218 | ve->in_use = in_use; | ||
1219 | if (in_use == GNUNET_YES) | ||
1220 | { | ||
1221 | /* from now on, higher frequeny, so reschedule now */ | ||
1222 | GNUNET_SCHEDULER_cancel (ve->revalidation_task); | ||
1223 | ve->revalidation_task = | ||
1224 | GNUNET_SCHEDULER_add_now (&revalidate_address, ve); | ||
1225 | } | ||
1202 | } | 1226 | } |
1203 | 1227 | ||
1204 | 1228 | ||
@@ -1206,10 +1230,9 @@ GST_validation_set_address_use (const struct GNUNET_PeerIdentity *sender, | |||
1206 | * Query validation about the latest observed latency on a given | 1230 | * Query validation about the latest observed latency on a given |
1207 | * address. | 1231 | * address. |
1208 | * | 1232 | * |
1209 | * @param sender peer sending the PING | 1233 | * @param sender peer |
1210 | * @param hdr the PING | 1234 | * @param plugin_name name of plugin |
1211 | * @param plugin_name name of plugin that received the PING | 1235 | * @param session session |
1212 | * @param session session we got the PING from | ||
1213 | * @param sender_address address of the sender as known to the plugin, NULL | 1236 | * @param sender_address address of the sender as known to the plugin, NULL |
1214 | * if we did not initiate the connection | 1237 | * if we did not initiate the connection |
1215 | * @param sender_address_len number of bytes in sender_address | 1238 | * @param sender_address_len number of bytes in sender_address |
@@ -1218,13 +1241,16 @@ GST_validation_set_address_use (const struct GNUNET_PeerIdentity *sender, | |||
1218 | */ | 1241 | */ |
1219 | struct GNUNET_TIME_Relative | 1242 | struct GNUNET_TIME_Relative |
1220 | GST_validation_get_address_latency (const struct GNUNET_PeerIdentity *sender, | 1243 | GST_validation_get_address_latency (const struct GNUNET_PeerIdentity *sender, |
1221 | const struct GNUNET_MessageHeader *hdr, | ||
1222 | const char *plugin_name, struct Session *session, | 1244 | const char *plugin_name, struct Session *session, |
1223 | const void *sender_address, | 1245 | const void *sender_address, |
1224 | size_t sender_address_len) | 1246 | size_t sender_address_len) |
1225 | { | 1247 | { |
1226 | // FIXME: lookup address, return latency field... | 1248 | struct ValidationEntry *ve; |
1227 | return GNUNET_TIME_UNIT_ZERO; | 1249 | |
1250 | ve = find_validation_entry (NULL, sender, plugin_name, sender_address, sender_address_len); | ||
1251 | if (NULL == ve) | ||
1252 | return GNUNET_TIME_UNIT_FOREVER_REL; | ||
1253 | return ve->latency; | ||
1228 | } | 1254 | } |
1229 | 1255 | ||
1230 | 1256 | ||