diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2013-07-03 15:09:47 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2013-07-03 15:09:47 +0000 |
commit | 1da7ad0c7bbf692c89991c3d110fa8786ffe15a1 (patch) | |
tree | ccb1f916eebe8984f95538f4f92049c605abfa79 /src/ats | |
parent | 2ad3006f965ffc074cc9f5f163a416fda66fcb2a (diff) | |
download | gnunet-1da7ad0c7bbf692c89991c3d110fa8786ffe15a1.tar.gz gnunet-1da7ad0c7bbf692c89991c3d110fa8786ffe15a1.zip |
proportional solver uses normalized properties
Diffstat (limited to 'src/ats')
-rw-r--r-- | src/ats/gnunet-service-ats-solver_proportional.c | 37 | ||||
-rw-r--r-- | src/ats/gnunet-service-ats_normalization.c | 1 |
2 files changed, 32 insertions, 6 deletions
diff --git a/src/ats/gnunet-service-ats-solver_proportional.c b/src/ats/gnunet-service-ats-solver_proportional.c index 331896f15..95d27e654 100644 --- a/src/ats/gnunet-service-ats-solver_proportional.c +++ b/src/ats/gnunet-service-ats-solver_proportional.c | |||
@@ -575,6 +575,17 @@ struct FindBestAddressCtx | |||
575 | }; | 575 | }; |
576 | 576 | ||
577 | 577 | ||
578 | static int | ||
579 | find_property_index (uint32_t type) | ||
580 | { | ||
581 | int existing_types[] = GNUNET_ATS_QualityProperties; | ||
582 | int c; | ||
583 | for (c = 0; c < GNUNET_ATS_QualityPropertiesCount; c++) | ||
584 | if (existing_types[c] == type) | ||
585 | return c; | ||
586 | return GNUNET_SYSERR; | ||
587 | } | ||
588 | |||
578 | /** | 589 | /** |
579 | * Find a "good" address to use for a peer by iterating over the addresses for this peer. | 590 | * Find a "good" address to use for a peer by iterating over the addresses for this peer. |
580 | * If we already have an existing address, we stick to it. | 591 | * If we already have an existing address, we stick to it. |
@@ -594,6 +605,7 @@ find_best_address_it (void *cls, const struct GNUNET_HashCode * key, void *value | |||
594 | struct Network *net = (struct Network *) current->solver_information; | 605 | struct Network *net = (struct Network *) current->solver_information; |
595 | const double *norm_prop_cur; | 606 | const double *norm_prop_cur; |
596 | const double *norm_prop_prev; | 607 | const double *norm_prop_prev; |
608 | int index; | ||
597 | 609 | ||
598 | now = GNUNET_TIME_absolute_get(); | 610 | now = GNUNET_TIME_absolute_get(); |
599 | 611 | ||
@@ -647,15 +659,30 @@ find_best_address_it (void *cls, const struct GNUNET_HashCode * key, void *value | |||
647 | norm_prop_prev = fba_ctx->s->get_properties (fba_ctx->s->get_properties_cls, | 659 | norm_prop_prev = fba_ctx->s->get_properties (fba_ctx->s->get_properties_cls, |
648 | (const struct ATS_Address *) fba_ctx->best); | 660 | (const struct ATS_Address *) fba_ctx->best); |
649 | 661 | ||
650 | if (norm_prop_cur[1] < norm_prop_prev[1]) | 662 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "%s previous %u current %u\n", "DISTANCE", norm_prop_cur[1], norm_prop_cur[1]); |
663 | index = find_property_index (GNUNET_ATS_QUALITY_NET_DISTANCE); | ||
664 | if (GNUNET_SYSERR == index) | ||
665 | { | ||
666 | GNUNET_break (0); | ||
667 | return GNUNET_OK; | ||
668 | } | ||
669 | if (norm_prop_cur[index] < norm_prop_prev[index]) | ||
651 | { | 670 | { |
652 | /* user shorter distance */ | 671 | /* user shorter distance */ |
653 | fba_ctx->best = current; | 672 | fba_ctx->best = current; |
654 | return GNUNET_OK; | 673 | return GNUNET_OK; |
655 | } | 674 | } |
656 | if (norm_prop_cur[0] < norm_prop_prev[0]) | 675 | |
676 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "%s previous %u current %u\n", "DELAY", norm_prop_cur[1], norm_prop_cur[1]); | ||
677 | index = find_property_index (GNUNET_ATS_QUALITY_NET_DELAY); | ||
678 | if (GNUNET_SYSERR == index) | ||
657 | { | 679 | { |
658 | /* user shorter distance */ | 680 | GNUNET_break (0); |
681 | return GNUNET_OK; | ||
682 | } | ||
683 | if (norm_prop_cur[index] < norm_prop_prev[index]) | ||
684 | { | ||
685 | /* user shorter delay */ | ||
659 | fba_ctx->best = current; | 686 | fba_ctx->best = current; |
660 | return GNUNET_OK; | 687 | return GNUNET_OK; |
661 | } | 688 | } |
@@ -712,7 +739,7 @@ get_network (struct GAS_PROPORTIONAL_Handle *s, uint32_t type) | |||
712 | * @param cls last active address | 739 | * @param cls last active address |
713 | * @param key peer's key | 740 | * @param key peer's key |
714 | * @param value address to check | 741 | * @param value address to check |
715 | * @return GNUNET_NO on double active address else GNUNET_YES | 742 | * @return GNUNET_NO on double active address else GNUNET_YES; |
716 | */ | 743 | */ |
717 | static int | 744 | static int |
718 | get_active_address_it (void *cls, const struct GNUNET_HashCode * key, void *value) | 745 | get_active_address_it (void *cls, const struct GNUNET_HashCode * key, void *value) |
@@ -915,7 +942,7 @@ GAS_proportional_get_preferred_address (void *solver, | |||
915 | /* Get address with: stick to current address, lower distance, lower latency */ | 942 | /* Get address with: stick to current address, lower distance, lower latency */ |
916 | fba_ctx.s = s; | 943 | fba_ctx.s = s; |
917 | fba_ctx.best = NULL; | 944 | fba_ctx.best = NULL; |
918 | GNUNET_break (0); | 945 | |
919 | GNUNET_CONTAINER_multihashmap_get_multiple (s->addresses, &peer->hashPubKey, | 946 | GNUNET_CONTAINER_multihashmap_get_multiple (s->addresses, &peer->hashPubKey, |
920 | &find_best_address_it, &fba_ctx); | 947 | &find_best_address_it, &fba_ctx); |
921 | if (NULL == fba_ctx.best) | 948 | if (NULL == fba_ctx.best) |
diff --git a/src/ats/gnunet-service-ats_normalization.c b/src/ats/gnunet-service-ats_normalization.c index 982668d57..6ced1b49e 100644 --- a/src/ats/gnunet-service-ats_normalization.c +++ b/src/ats/gnunet-service-ats_normalization.c | |||
@@ -534,7 +534,6 @@ GAS_normalization_get_properties (struct ATS_Address *address) | |||
534 | else | 534 | else |
535 | norm_values[i] = DEFAULT_REL_QUALITY; | 535 | norm_values[i] = DEFAULT_REL_QUALITY; |
536 | } | 536 | } |
537 | GNUNET_break (0); | ||
538 | return norm_values; | 537 | return norm_values; |
539 | } | 538 | } |
540 | 539 | ||