diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2012-02-20 22:02:28 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2012-02-20 22:02:28 +0000 |
commit | c4745ca5df31efd2917ebd134ac82a0d1e1281f6 (patch) | |
tree | e2a059dbfc575dcfd994b50f4ec2a0895433176d /src/ats/gnunet-service-ats_addresses.c | |
parent | 2f40f09726422b092245154cbe30a1cf4389b9fa (diff) | |
download | gnunet-c4745ca5df31efd2917ebd134ac82a0d1e1281f6.tar.gz gnunet-c4745ca5df31efd2917ebd134ac82a0d1e1281f6.zip |
- latest changes
Diffstat (limited to 'src/ats/gnunet-service-ats_addresses.c')
-rw-r--r-- | src/ats/gnunet-service-ats_addresses.c | 91 |
1 files changed, 67 insertions, 24 deletions
diff --git a/src/ats/gnunet-service-ats_addresses.c b/src/ats/gnunet-service-ats_addresses.c index 843394a0f..8900abcb6 100644 --- a/src/ats/gnunet-service-ats_addresses.c +++ b/src/ats/gnunet-service-ats_addresses.c | |||
@@ -588,34 +588,68 @@ GAS_addresses_in_use (const struct GNUNET_PeerIdentity *peer, | |||
588 | #endif | 588 | #endif |
589 | } | 589 | } |
590 | 590 | ||
591 | void | 591 | |
592 | GAS_addresses_request_address (const struct GNUNET_PeerIdentity *peer) | 592 | void request_address_mlp (const struct GNUNET_PeerIdentity *peer) |
593 | { | 593 | { |
594 | struct ATS_Address *aa; | 594 | struct ATS_Address *aa; |
595 | |||
596 | aa = NULL; | 595 | aa = NULL; |
597 | 596 | ||
598 | if (ats_mode == SIMPLE) | 597 | #if HAVE_GLPK |
598 | /* Get preferred address from MLP */ | ||
599 | struct ATS_PreferedAddress * paddr = NULL; | ||
600 | paddr = GAS_mlp_get_preferred_address (mlp, addresses, peer); | ||
601 | aa = paddr->address; | ||
602 | aa->assigned_bw_out = GNUNET_BANDWIDTH_value_init(paddr->bandwidth_out); | ||
603 | /* FIXME use bw in value */ | ||
604 | paddr->bandwidth_in = paddr->bandwidth_out; | ||
605 | aa->assigned_bw_in = GNUNET_BANDWIDTH_value_init (paddr->bandwidth_in); | ||
606 | GNUNET_free (paddr); | ||
607 | #endif | ||
608 | |||
609 | if (aa == NULL) | ||
599 | { | 610 | { |
600 | /* Get address with: stick to current address, lower distance, lower latency */ | 611 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
601 | GNUNET_CONTAINER_multihashmap_get_multiple (addresses, &peer->hashPubKey, | 612 | "Cannot suggest address for peer `%s'\n", GNUNET_i2s (peer)); |
602 | &find_address_it, &aa); | 613 | return; |
603 | } | 614 | } |
604 | if (ats_mode == MLP) | 615 | if (aa->active == GNUNET_NO) |
605 | { | 616 | { |
606 | #if HAVE_GLPK | 617 | aa->active = GNUNET_YES; |
607 | #endif | 618 | active_addr_count++; |
608 | /* Get preferred address from MLP */ | 619 | |
609 | struct ATS_PreferedAddress * paddr = NULL; | 620 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "New bandwidth for peer %s is %u/%u\n", |
610 | paddr = GAS_mlp_get_preferred_address (mlp, addresses, peer); | 621 | GNUNET_i2s (&aa->peer), ntohl (aa->assigned_bw_in.value__), |
611 | aa = paddr->address; | 622 | ntohl (aa->assigned_bw_out.value__)); |
612 | aa->assigned_bw_out = GNUNET_BANDWIDTH_value_init(paddr->bandwidth_out); | 623 | GAS_scheduling_transmit_address_suggestion (&aa->peer, aa->plugin, aa->addr, |
613 | /* FIXME use bw in value */ | 624 | aa->addr_len, aa->session_id, |
614 | paddr->bandwidth_in = paddr->bandwidth_out; | 625 | aa->ats, aa->ats_count, |
615 | aa->assigned_bw_in = GNUNET_BANDWIDTH_value_init (paddr->bandwidth_in); | 626 | aa->assigned_bw_out, |
616 | GNUNET_free (paddr); | 627 | aa->assigned_bw_in); |
628 | GAS_reservations_set_bandwidth (&aa->peer, aa->assigned_bw_in); | ||
629 | GAS_performance_notify_clients (&aa->peer, aa->plugin, aa->addr, aa->addr_len, | ||
630 | aa->ats, aa->ats_count, aa->assigned_bw_out, | ||
631 | aa->assigned_bw_in); | ||
632 | } | ||
633 | else | ||
634 | { | ||
635 | /* just to be sure... */ | ||
636 | GAS_scheduling_transmit_address_suggestion (peer, aa->plugin, aa->addr, | ||
637 | aa->addr_len, aa->session_id, | ||
638 | aa->ats, aa->ats_count, | ||
639 | aa->assigned_bw_out, | ||
640 | aa->assigned_bw_in); | ||
617 | } | 641 | } |
618 | 642 | ||
643 | } | ||
644 | |||
645 | void request_address_simple (const struct GNUNET_PeerIdentity *peer) | ||
646 | { | ||
647 | struct ATS_Address *aa; | ||
648 | aa = NULL; | ||
649 | |||
650 | /* Get address with: stick to current address, lower distance, lower latency */ | ||
651 | GNUNET_CONTAINER_multihashmap_get_multiple (addresses, &peer->hashPubKey, | ||
652 | &find_address_it, &aa); | ||
619 | if (aa == NULL) | 653 | if (aa == NULL) |
620 | { | 654 | { |
621 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 655 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
@@ -631,10 +665,6 @@ GAS_addresses_request_address (const struct GNUNET_PeerIdentity *peer) | |||
631 | { | 665 | { |
632 | recalculate_assigned_bw (); | 666 | recalculate_assigned_bw (); |
633 | } | 667 | } |
634 | if (ats_mode == SIMPLE) | ||
635 | { | ||
636 | recalculate_assigned_bw (); | ||
637 | } | ||
638 | } | 668 | } |
639 | else | 669 | else |
640 | { | 670 | { |
@@ -648,6 +678,20 @@ GAS_addresses_request_address (const struct GNUNET_PeerIdentity *peer) | |||
648 | } | 678 | } |
649 | 679 | ||
650 | 680 | ||
681 | void | ||
682 | GAS_addresses_request_address (const struct GNUNET_PeerIdentity *peer) | ||
683 | { | ||
684 | if (ats_mode == SIMPLE) | ||
685 | { | ||
686 | request_address_simple (peer); | ||
687 | } | ||
688 | if (ats_mode == MLP) | ||
689 | { | ||
690 | request_address_mlp(peer); | ||
691 | } | ||
692 | } | ||
693 | |||
694 | |||
651 | // FIXME: this function should likely end up in the LP-subsystem and | 695 | // FIXME: this function should likely end up in the LP-subsystem and |
652 | // not with 'addresses' in the future... | 696 | // not with 'addresses' in the future... |
653 | void | 697 | void |
@@ -692,7 +736,6 @@ GAS_addresses_init (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
692 | mlp = GAS_mlp_init (cfg, stats, MLP_MAX_EXEC_DURATION, MLP_MAX_ITERATIONS); | 736 | mlp = GAS_mlp_init (cfg, stats, MLP_MAX_EXEC_DURATION, MLP_MAX_ITERATIONS); |
693 | break; | 737 | break; |
694 | #else | 738 | #else |
695 | |||
696 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "MLP mode was configured, but libglpk is not installed, switching to simple mode"); | 739 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "MLP mode was configured, but libglpk is not installed, switching to simple mode"); |
697 | ats_mode = SIMPLE; | 740 | ats_mode = SIMPLE; |
698 | break; | 741 | break; |