diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2011-03-24 11:05:01 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2011-03-24 11:05:01 +0000 |
commit | a27249cf6b80518b9b6f8edfb322a0820bead1b8 (patch) | |
tree | ceefefb6b3ff8255a8d64a386d63a1d8b5d9f2cf | |
parent | 1f53960ac003ddd8cf164d07de7d01371cec8286 (diff) | |
download | gnunet-a27249cf6b80518b9b6f8edfb322a0820bead1b8.tar.gz gnunet-a27249cf6b80518b9b6f8edfb322a0820bead1b8.zip |
clean up and changes
-rw-r--r-- | src/transport/gnunet-service-transport.c | 154 | ||||
-rw-r--r-- | src/transport/transport.h | 12 |
2 files changed, 118 insertions, 48 deletions
diff --git a/src/transport/gnunet-service-transport.c b/src/transport/gnunet-service-transport.c index 919192e46..bb20fb612 100644 --- a/src/transport/gnunet-service-transport.c +++ b/src/transport/gnunet-service-transport.c | |||
@@ -55,6 +55,8 @@ | |||
55 | #define DEBUG_ATS GNUNET_YES | 55 | #define DEBUG_ATS GNUNET_YES |
56 | #endif | 56 | #endif |
57 | 57 | ||
58 | #define VERBOSE_ATS GNUNET_NO | ||
59 | |||
58 | /** | 60 | /** |
59 | * Should we do some additional checks (to validate behavior | 61 | * Should we do some additional checks (to validate behavior |
60 | * of clients)? | 62 | * of clients)? |
@@ -944,20 +946,20 @@ static void try_transmission_to_peer (struct NeighbourList *n); | |||
944 | 946 | ||
945 | struct ATS_info * ats_init (); | 947 | struct ATS_info * ats_init (); |
946 | 948 | ||
947 | void ats_shutdown (struct ATS_info * ats); | 949 | void ats_shutdown ( ); |
948 | 950 | ||
949 | void ats_notify_peer_connect (struct ATS_info * ats, | 951 | void ats_notify_peer_connect ( |
950 | const struct GNUNET_PeerIdentity *peer, | 952 | const struct GNUNET_PeerIdentity *peer, |
951 | const struct GNUNET_TRANSPORT_ATS_Information *ats_data); | 953 | const struct GNUNET_TRANSPORT_ATS_Information *ats_data); |
952 | 954 | ||
953 | void ats_notify_peer_disconnect (struct ATS_info * ats, | 955 | void ats_notify_peer_disconnect ( |
954 | const struct GNUNET_PeerIdentity *peer); | 956 | const struct GNUNET_PeerIdentity *peer); |
955 | 957 | ||
956 | void ats_notify_ats_data (struct ATS_info * ats, | 958 | void ats_notify_ats_data ( |
957 | const struct GNUNET_PeerIdentity *peer, | 959 | const struct GNUNET_PeerIdentity *peer, |
958 | const struct GNUNET_TRANSPORT_ATS_Information *ats_data); | 960 | const struct GNUNET_TRANSPORT_ATS_Information *ats_data); |
959 | 961 | ||
960 | struct ForeignAddressList * ats_get_preferred_address (struct ATS_info * ats, | 962 | struct ForeignAddressList * ats_get_preferred_address ( |
961 | struct NeighbourList *n); | 963 | struct NeighbourList *n); |
962 | 964 | ||
963 | /** | 965 | /** |
@@ -1682,7 +1684,7 @@ try_transmission_to_peer (struct NeighbourList *n) | |||
1682 | if (mq->specific_address == NULL) | 1684 | if (mq->specific_address == NULL) |
1683 | { | 1685 | { |
1684 | /* TODO: ADD ATS */ | 1686 | /* TODO: ADD ATS */ |
1685 | mq->specific_address = ats_get_preferred_address(ats, n); | 1687 | mq->specific_address = ats_get_preferred_address(n); |
1686 | GNUNET_STATISTICS_update (stats, | 1688 | GNUNET_STATISTICS_update (stats, |
1687 | gettext_noop ("# transport selected peer address freely"), | 1689 | gettext_noop ("# transport selected peer address freely"), |
1688 | 1, | 1690 | 1, |
@@ -2317,7 +2319,7 @@ notify_clients_connect (const struct GNUNET_PeerIdentity *peer, | |||
2317 | memcpy (&cim->id, peer, sizeof (struct GNUNET_PeerIdentity)); | 2319 | memcpy (&cim->id, peer, sizeof (struct GNUNET_PeerIdentity)); |
2318 | 2320 | ||
2319 | /* notify ats about connecting peer */ | 2321 | /* notify ats about connecting peer */ |
2320 | ats_notify_peer_connect(ats, peer, &(cim->ats)); | 2322 | ats_notify_peer_connect (peer, &(cim->ats)); |
2321 | 2323 | ||
2322 | cpos = clients; | 2324 | cpos = clients; |
2323 | while (cpos != NULL) | 2325 | while (cpos != NULL) |
@@ -2354,7 +2356,7 @@ notify_clients_disconnect (const struct GNUNET_PeerIdentity *peer) | |||
2354 | memcpy (&dim.peer, peer, sizeof (struct GNUNET_PeerIdentity)); | 2356 | memcpy (&dim.peer, peer, sizeof (struct GNUNET_PeerIdentity)); |
2355 | 2357 | ||
2356 | /* notify ats about connecting peer */ | 2358 | /* notify ats about connecting peer */ |
2357 | ats_notify_peer_disconnect(ats, peer); | 2359 | ats_notify_peer_disconnect (peer); |
2358 | 2360 | ||
2359 | cpos = clients; | 2361 | cpos = clients; |
2360 | while (cpos != NULL) | 2362 | while (cpos != NULL) |
@@ -4829,8 +4831,7 @@ plugin_env_receive (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
4829 | } | 4831 | } |
4830 | } | 4832 | } |
4831 | /* notify ATS about incoming data */ | 4833 | /* notify ATS about incoming data */ |
4832 | ats_notify_ats_data(ats, peer, ats_data); | 4834 | ats_notify_ats_data(peer, ats_data); |
4833 | |||
4834 | 4835 | ||
4835 | if (message != NULL) | 4836 | if (message != NULL) |
4836 | { | 4837 | { |
@@ -5565,7 +5566,7 @@ struct ATS_transports | |||
5565 | 5566 | ||
5566 | #define FUNCTION ats_create_problem (int peers, int transports, double b_min, double b_max, double r, double R, const struct ATS_peer * pl, const struct ATS_transports * tl, int max_it, int max_dur) | 5567 | #define FUNCTION ats_create_problem (int peers, int transports, double b_min, double b_max, double r, double R, const struct ATS_peer * pl, const struct ATS_transports * tl, int max_it, int max_dur) |
5567 | 5568 | ||
5568 | #if HAVE_LIBGLPK | 5569 | |
5569 | glp_prob * FUNCTION | 5570 | glp_prob * FUNCTION |
5570 | { | 5571 | { |
5571 | int result = GLP_UNDEF; | 5572 | int result = GLP_UNDEF; |
@@ -5583,28 +5584,32 @@ glp_prob * FUNCTION | |||
5583 | double ar[1+(rows*cols)]; | 5584 | double ar[1+(rows*cols)]; |
5584 | double value; | 5585 | double value; |
5585 | 5586 | ||
5586 | /* Setting options */ | 5587 | /* Setting GLPK options */ |
5587 | glp_smcp * options = GNUNET_malloc( sizeof (glp_smcp)); | 5588 | glp_smcp * options = GNUNET_malloc( sizeof (glp_smcp)); |
5588 | glp_init_smcp(options); | 5589 | glp_init_smcp(options); |
5589 | 5590 | ||
5590 | // max iterations | 5591 | /* maximum iterations */ |
5591 | options->it_lim = max_it; | 5592 | options->it_lim = max_it; |
5592 | // max durations | 5593 | /* maximum durations */ |
5593 | options->tm_lim = max_dur; | 5594 | options->tm_lim = max_dur; |
5594 | options->msg_lev = GLP_MSG_ALL; | 5595 | /* output level */ |
5596 | if (VERBOSE_ATS) | ||
5597 | options->msg_lev = GLP_MSG_ALL; | ||
5598 | else | ||
5599 | options->msg_lev = GLP_MSG_OFF; | ||
5595 | 5600 | ||
5596 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Creating LP problem: %i peers, relativity r %3.2f, b_max %5.2f, b_min %5.2f, \n",peers, r, b_max, b_min); | 5601 | if (DEBUG_ATS) GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Creating LP problem: %i peers, relativity r %3.2f, b_max %5.2f, b_min %5.2f, \n",peers, r, b_max, b_min); |
5597 | lp = glp_create_prob(); | 5602 | lp = glp_create_prob(); |
5598 | glp_set_prob_name(lp, "gnunet ats bandwidth distribution"); | 5603 | glp_set_prob_name(lp, "gnunet ats bandwidth distribution"); |
5599 | glp_set_obj_dir(lp, GLP_MAX); | 5604 | glp_set_obj_dir(lp, GLP_MAX); |
5600 | 5605 | ||
5601 | /* Adding transports */ | 5606 | /* Adding transports and objective function coefficients*/ |
5602 | glp_add_cols(lp, cols); | 5607 | glp_add_cols(lp, cols); |
5603 | for (c1=1; c1<=cols; c1++) | 5608 | for (c1=1; c1<=cols; c1++) |
5604 | { | 5609 | { |
5605 | GNUNET_asprintf(&peer_n,"%s",GNUNET_i2s(&pl[c1-1].peer)); | 5610 | GNUNET_asprintf(&peer_n,"%s",GNUNET_i2s(&pl[c1-1].peer)); |
5606 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Peer[%i] , transport %i, %s: f: %f\n",c1-1 , pl[c1-1].t, peer_n, pl[c1-1].f); | 5611 | if (DEBUG_ATS) GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Peer[%i] , transport %i, %s: f: %f\n",c1-1 , pl[c1-1].t, peer_n, pl[c1-1].f); |
5607 | /* add a single transport */ | 5612 | /* add a single transport*/ |
5608 | glp_set_col_name(lp, c1, peer_n); | 5613 | glp_set_col_name(lp, c1, peer_n); |
5609 | /* add a lower bound */ | 5614 | /* add a lower bound */ |
5610 | glp_set_col_bnds(lp, c1, GLP_LO, 0.0, 0.0); | 5615 | glp_set_col_bnds(lp, c1, GLP_LO, 0.0, 0.0); |
@@ -5615,19 +5620,22 @@ glp_prob * FUNCTION | |||
5615 | GNUNET_free(peer_n); | 5620 | GNUNET_free(peer_n); |
5616 | } | 5621 | } |
5617 | 5622 | ||
5618 | |||
5619 | /* Adding constraints */ | 5623 | /* Adding constraints */ |
5620 | glp_add_rows(lp, rows); | 5624 | glp_add_rows(lp, rows); |
5621 | cur_row = 1; | 5625 | cur_row = 1; |
5622 | 5626 | ||
5623 | // GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "row: %i \n", cur_row); | 5627 | /* constraint 1: Maximum bandwidth for all peers |
5628 | * sum(b_i) <= b_max | ||
5629 | */ | ||
5624 | glp_set_row_bnds(lp, cur_row, GLP_UP, 0.0, b_max); | 5630 | glp_set_row_bnds(lp, cur_row, GLP_UP, 0.0, b_max); |
5625 | for (index=1; index<=cols; index++) | 5631 | for (index=1; index<=cols; index++) |
5626 | { | 5632 | { |
5627 | ia[index] = 1, ja[index] = index, ar[index] = 1.0; | 5633 | ia[index] = 1, ja[index] = index, ar[index] = 1.0; |
5628 | } | 5634 | } |
5629 | 5635 | ||
5630 | 5636 | /* constraint 2: Maximum bandwidth per peer | |
5637 | * V b_i in B: b_i <= b_max | ||
5638 | */ | ||
5631 | cur_row = 2; | 5639 | cur_row = 2; |
5632 | start = index+1; | 5640 | start = index+1; |
5633 | for (c1=0; c1<peers; c1++) | 5641 | for (c1=0; c1<peers; c1++) |
@@ -5637,42 +5645,41 @@ glp_prob * FUNCTION | |||
5637 | 5645 | ||
5638 | for (c2 = 1; c2 <= cols; c2++) | 5646 | for (c2 = 1; c2 <= cols; c2++) |
5639 | { | 5647 | { |
5640 | //GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "c1: %i c2 %i index: %i \n",c1 , c2, index); | ||
5641 | ia[index] = cur_row; | 5648 | ia[index] = cur_row; |
5642 | ja[index] = c2; | 5649 | ja[index] = c2; |
5643 | ar[index] = ((c1+1 == c2) ? 1.0 : 0.0); | 5650 | ar[index] = ((c1+1 == c2) ? 1.0 : 0.0); |
5644 | //GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "ia: %i ja %i ar: %f \n",cur_row , c2, ((c1+1 == c2) ? 1.0 : 0.0)); | ||
5645 | index++; | 5651 | index++; |
5646 | } | 5652 | } |
5647 | cur_row++; | 5653 | cur_row++; |
5648 | } | 5654 | } |
5649 | 5655 | ||
5656 | /* constraint 3: Minimum bandwidth | ||
5657 | * V b_i in B: b_i >= b_min | ||
5658 | */ | ||
5650 | start = index+1; | 5659 | start = index+1; |
5651 | for (c1=0; c1<peers; c1++) | 5660 | for (c1=0; c1<peers; c1++) |
5652 | { | 5661 | { |
5653 | //GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "row: %i \n", cur_row); | ||
5654 | glp_set_row_bnds(lp, cur_row , GLP_LO, b_min, 0.0); | 5662 | glp_set_row_bnds(lp, cur_row , GLP_LO, b_min, 0.0); |
5655 | 5663 | ||
5656 | for (c2 = 1; c2 <= cols; c2++) | 5664 | for (c2 = 1; c2 <= cols; c2++) |
5657 | { | 5665 | { |
5658 | //GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "c1: %i c2 %i index: %i \n",c1 , c2, index); | ||
5659 | ia[index] = cur_row; | 5666 | ia[index] = cur_row; |
5660 | ja[index] = c2; | 5667 | ja[index] = c2; |
5661 | ar[index] = ((c1+1 == c2) ? 1.0 : 0.0); | 5668 | ar[index] = ((c1+1 == c2) ? 1.0 : 0.0); |
5662 | //GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "ia: %i ja %i ar: %f \n",cur_row , c2, ((c1+1 == c2) ? 1.0 : 0.0)); | ||
5663 | index++; | 5669 | index++; |
5664 | } | 5670 | } |
5665 | cur_row++; | 5671 | cur_row++; |
5666 | } | 5672 | } |
5667 | 5673 | ||
5674 | /* constraint 4: Bandwidth assignment relativity to peer preference | ||
5675 | * V b_i in B: b_i >= b_min | ||
5676 | */ | ||
5668 | start = index+1; | 5677 | start = index+1; |
5669 | for (c1=0; c1<peers; c1++) | 5678 | for (c1=0; c1<peers; c1++) |
5670 | { | 5679 | { |
5671 | 5680 | ||
5672 | value = pl[c1].f * r; | 5681 | value = pl[c1].f * r; |
5673 | //GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "row: %i %f\n", cur_row, value); | ||
5674 | glp_set_row_bnds(lp, cur_row , GLP_LO, value, 0.0); | 5682 | glp_set_row_bnds(lp, cur_row , GLP_LO, value, 0.0); |
5675 | |||
5676 | for (c2 = 1; c2 <= cols; c2++) | 5683 | for (c2 = 1; c2 <= cols; c2++) |
5677 | { | 5684 | { |
5678 | //GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "c1: %i c2 %i index: %i \n",c1 , c2, index); | 5685 | //GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "c1: %i c2 %i index: %i \n",c1 , c2, index); |
@@ -5685,40 +5692,96 @@ glp_prob * FUNCTION | |||
5685 | cur_row++; | 5692 | cur_row++; |
5686 | } | 5693 | } |
5687 | 5694 | ||
5688 | /* transport capacity sum of b * c_i < c_max */ | 5695 | /* constraint 4: transport capacity |
5696 | * sum of b * c_i < c_max */ | ||
5689 | start = index+1; | 5697 | start = index+1; |
5690 | for (c1=0; c1<transports; c1++) | 5698 | for (c1=0; c1<transports; c1++) |
5691 | { | 5699 | { |
5692 | 5700 | ||
5693 | value = tl[c1].c_max; | 5701 | value = tl[c1].c_max; |
5694 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Transport %i: c_max %5.2f c_1 %5.2f \n", c1, value, tl[c1].c_1); | 5702 | if (DEBUG_ATS) GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Transport %i: c_max %5.2f c_1 %5.2f \n", c1, value, tl[c1].c_1); |
5695 | glp_set_row_bnds(lp, cur_row , GLP_UP, 0.0 , value); | 5703 | glp_set_row_bnds(lp, cur_row , GLP_UP, 0.0 , value); |
5696 | 5704 | ||
5697 | for (c2 = 1; c2 <= cols; c2++) | 5705 | for (c2 = 1; c2 <= cols; c2++) |
5698 | { | 5706 | { |
5699 | //GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "c1: %i c2 %i index: %i \n",c1 , c2, index); | ||
5700 | ia[index] = cur_row; | 5707 | ia[index] = cur_row; |
5701 | ja[index] = c2; | 5708 | ja[index] = c2; |
5702 | ar[index] = ((pl[c1-1].t == tl[c1].id) ? (tl[c1].c_1) : 0.0); | 5709 | ar[index] = ((pl[c1-1].t == tl[c1].id) ? (tl[c1].c_1) : 0.0); |
5703 | //GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "ia: %i ja %i ar: %f \n",cur_row , c2, ((c1+1 == c2) ? 1.0 : 0.0)); | ||
5704 | index++; | 5710 | index++; |
5705 | } | 5711 | } |
5706 | cur_row++; | 5712 | cur_row++; |
5707 | } | 5713 | } |
5708 | 5714 | ||
5709 | glp_load_matrix(lp, rows * cols, ia, ja, ar); | 5715 | glp_load_matrix(lp, rows * cols, ia, ja, ar); |
5710 | |||
5711 | result = glp_simplex(lp, options); | 5716 | result = glp_simplex(lp, options); |
5717 | if (DEBUG_ATS) | ||
5718 | { | ||
5719 | switch (result) { | ||
5720 | case GLP_EITLIM : /* iteration limit exceeded */ | ||
5721 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Iteration limit exceeded "); | ||
5722 | break; | ||
5723 | case GLP_ETMLIM : /* time limit exceeded */ | ||
5724 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Time limit exceeded "); | ||
5725 | break; | ||
5726 | case GLP_ENOPFS : /* no primal feasible solution */ | ||
5727 | case GLP_ENODFS : /* no dual feasible solution */ | ||
5728 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "No feasible solution"); | ||
5729 | break; | ||
5730 | |||
5731 | case GLP_EBADB : /* invalid basis */ | ||
5732 | |||
5733 | break; | ||
5734 | case GLP_ESING : /* singular matrix */ | ||
5735 | break; | ||
5736 | case GLP_ECOND : /* ill-conditioned matrix */ | ||
5737 | break; | ||
5738 | case GLP_EBOUND : /* invalid bounds */ | ||
5739 | break; | ||
5740 | case GLP_EFAIL : /* solver failed */ | ||
5741 | break; | ||
5742 | case GLP_EOBJLL : /* objective lower limit reached */ | ||
5743 | break; | ||
5744 | case GLP_EOBJUL : /* objective upper limit reached */ | ||
5745 | break; | ||
5746 | case GLP_EROOT : /* root LP optimum not provided */ | ||
5747 | break; | ||
5748 | case GLP_ESTOP : /* search terminated by application */ | ||
5749 | break; | ||
5750 | case GLP_EMIPGAP: /* relative mip gap tolerance reached */ | ||
5751 | break; | ||
5752 | case GLP_ENOFEAS: /* no primal/dual feasible solution */ | ||
5753 | break; | ||
5754 | case GLP_ENOCVG : /* no convergence */ | ||
5755 | break; | ||
5756 | case GLP_EINSTAB: /* numerical instability */ | ||
5757 | break; | ||
5758 | case GLP_EDATA : /* invalid data */ | ||
5759 | break; | ||
5760 | case GLP_ERANGE : /* result out of range */ | ||
5761 | break; | ||
5762 | default: | ||
5763 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Optimal solution\n"); | ||
5764 | break; | ||
5765 | } | ||
5766 | } | ||
5712 | 5767 | ||
5768 | char * debug_solution = NULL; | ||
5769 | char * old = NULL; | ||
5713 | for (c1=1; c1<= peers; c1++ ) | 5770 | for (c1=1; c1<= peers; c1++ ) |
5714 | { | 5771 | { |
5715 | printf("x%i = %g; ", c1, glp_get_col_prim(lp, c1)); | 5772 | old = debug_solution; |
5773 | GNUNET_asprintf(&debug_solution, "%s %s = %g;", (debug_solution!=NULL) ? debug_solution : "", GNUNET_i2s(&pl[c1-1].peer), glp_get_col_prim(lp, c1)); | ||
5774 | if (old!=NULL) GNUNET_free(old); | ||
5716 | } | 5775 | } |
5717 | printf("z = %g; \n", glp_get_obj_val(lp)); | 5776 | GNUNET_asprintf(&debug_solution, "%s z = %g; \n", debug_solution, glp_get_obj_val(lp)); |
5777 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "%s \n",debug_solution); | ||
5778 | GNUNET_free(debug_solution); | ||
5779 | |||
5718 | glp_delete_prob(lp); | 5780 | glp_delete_prob(lp); |
5719 | GNUNET_free(options); | 5781 | GNUNET_free(options); |
5720 | return lp; | 5782 | return lp; |
5721 | } | 5783 | } |
5784 | #if HAVE_LIBGLPK | ||
5722 | #else | 5785 | #else |
5723 | void * FUNCTION | 5786 | void * FUNCTION |
5724 | { | 5787 | { |
@@ -5727,7 +5790,7 @@ void * FUNCTION | |||
5727 | #endif | 5790 | #endif |
5728 | 5791 | ||
5729 | 5792 | ||
5730 | void ats_calculate_bandwidth_distribution (struct ATS_info * ats) | 5793 | void ats_calculate_bandwidth_distribution () |
5731 | { | 5794 | { |
5732 | struct GNUNET_TIME_Relative delta = GNUNET_TIME_absolute_get_difference(ats->last,GNUNET_TIME_absolute_get()); | 5795 | struct GNUNET_TIME_Relative delta = GNUNET_TIME_absolute_get_difference(ats->last,GNUNET_TIME_absolute_get()); |
5733 | if (delta.rel_value < ats->min_delta.rel_value) | 5796 | if (delta.rel_value < ats->min_delta.rel_value) |
@@ -5737,9 +5800,6 @@ void ats_calculate_bandwidth_distribution (struct ATS_info * ats) | |||
5737 | #endif | 5800 | #endif |
5738 | return; | 5801 | return; |
5739 | } | 5802 | } |
5740 | #if DEBUG_ATS | ||
5741 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "CALCULATE DISTRIBUTION\n"); | ||
5742 | #endif | ||
5743 | 5803 | ||
5744 | int peers = 3; | 5804 | int peers = 3; |
5745 | int transports = 3; | 5805 | int transports = 3; |
@@ -5808,7 +5868,7 @@ ats_schedule_calculation (void *cls, | |||
5808 | #endif | 5868 | #endif |
5809 | ats_calculate_bandwidth_distribution (ats); | 5869 | ats_calculate_bandwidth_distribution (ats); |
5810 | 5870 | ||
5811 | ats->ats_task = GNUNET_SCHEDULER_add_delayed (ats->reg_delta, | 5871 | ats->ats_task = GNUNET_SCHEDULER_add_delayed (ats->exec_intervall, |
5812 | &ats_schedule_calculation, ats); | 5872 | &ats_schedule_calculation, ats); |
5813 | } | 5873 | } |
5814 | 5874 | ||
@@ -5840,7 +5900,7 @@ struct ATS_info * ats_init () | |||
5840 | GNUNET_assert(ats->peers!=NULL); | 5900 | GNUNET_assert(ats->peers!=NULL); |
5841 | 5901 | ||
5842 | ats->min_delta = ATS_MIN_INTERVAL; | 5902 | ats->min_delta = ATS_MIN_INTERVAL; |
5843 | ats->reg_delta = ATS_EXEC_INTERVAL; | 5903 | ats->exec_intervall = ATS_EXEC_INTERVAL; |
5844 | 5904 | ||
5845 | ats->ats_task = GNUNET_SCHEDULER_NO_TASK; | 5905 | ats->ats_task = GNUNET_SCHEDULER_NO_TASK; |
5846 | /* | 5906 | /* |
@@ -5856,7 +5916,7 @@ struct ATS_info * ats_init () | |||
5856 | } | 5916 | } |
5857 | 5917 | ||
5858 | 5918 | ||
5859 | void ats_shutdown (struct ATS_info * ats) | 5919 | void ats_shutdown () |
5860 | { | 5920 | { |
5861 | #if DEBUG_ATS | 5921 | #if DEBUG_ATS |
5862 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "ats_destroy\n"); | 5922 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "ats_destroy\n"); |
@@ -5871,7 +5931,7 @@ void ats_shutdown (struct ATS_info * ats) | |||
5871 | } | 5931 | } |
5872 | 5932 | ||
5873 | 5933 | ||
5874 | void ats_notify_peer_connect (struct ATS_info * ats, | 5934 | void ats_notify_peer_connect ( |
5875 | const struct GNUNET_PeerIdentity *peer, | 5935 | const struct GNUNET_PeerIdentity *peer, |
5876 | const struct GNUNET_TRANSPORT_ATS_Information *ats_data) | 5936 | const struct GNUNET_TRANSPORT_ATS_Information *ats_data) |
5877 | { | 5937 | { |
@@ -5898,7 +5958,7 @@ void ats_notify_peer_connect (struct ATS_info * ats, | |||
5898 | ats_calculate_bandwidth_distribution(ats); | 5958 | ats_calculate_bandwidth_distribution(ats); |
5899 | } | 5959 | } |
5900 | 5960 | ||
5901 | void ats_notify_peer_disconnect (struct ATS_info * ats, | 5961 | void ats_notify_peer_disconnect ( |
5902 | const struct GNUNET_PeerIdentity *peer) | 5962 | const struct GNUNET_PeerIdentity *peer) |
5903 | { | 5963 | { |
5904 | #if DEBUG_ATS | 5964 | #if DEBUG_ATS |
@@ -5915,7 +5975,7 @@ void ats_notify_peer_disconnect (struct ATS_info * ats, | |||
5915 | } | 5975 | } |
5916 | 5976 | ||
5917 | 5977 | ||
5918 | void ats_notify_ats_data (struct ATS_info * ats, | 5978 | void ats_notify_ats_data ( |
5919 | const struct GNUNET_PeerIdentity *peer, | 5979 | const struct GNUNET_PeerIdentity *peer, |
5920 | const struct GNUNET_TRANSPORT_ATS_Information *ats_data) | 5980 | const struct GNUNET_TRANSPORT_ATS_Information *ats_data) |
5921 | { | 5981 | { |
@@ -5925,7 +5985,7 @@ void ats_notify_ats_data (struct ATS_info * ats, | |||
5925 | ats_calculate_bandwidth_distribution(ats); | 5985 | ats_calculate_bandwidth_distribution(ats); |
5926 | } | 5986 | } |
5927 | 5987 | ||
5928 | struct ForeignAddressList * ats_get_preferred_address (struct ATS_info * ats, | 5988 | struct ForeignAddressList * ats_get_preferred_address ( |
5929 | struct NeighbourList *n) | 5989 | struct NeighbourList *n) |
5930 | { | 5990 | { |
5931 | #if DEBUG_ATS | 5991 | #if DEBUG_ATS |
diff --git a/src/transport/transport.h b/src/transport/transport.h index bfe9bc094..314a5c2bf 100644 --- a/src/transport/transport.h +++ b/src/transport/transport.h | |||
@@ -40,8 +40,18 @@ struct ATS_info | |||
40 | { | 40 | { |
41 | struct GNUNET_CONTAINER_MultiHashMap * peers; | 41 | struct GNUNET_CONTAINER_MultiHashMap * peers; |
42 | struct GNUNET_TIME_Absolute last; | 42 | struct GNUNET_TIME_Absolute last; |
43 | /** | ||
44 | * Minimum intervall between two executions | ||
45 | */ | ||
43 | struct GNUNET_TIME_Relative min_delta; | 46 | struct GNUNET_TIME_Relative min_delta; |
44 | struct GNUNET_TIME_Relative reg_delta; | 47 | /** |
48 | * Regular intervall when execution is triggered | ||
49 | */ | ||
50 | struct GNUNET_TIME_Relative exec_intervall; | ||
51 | /** | ||
52 | * Maximum execution time per calculation | ||
53 | */ | ||
54 | struct GNUNET_TIME_Relative max_exec_duration; | ||
45 | 55 | ||
46 | GNUNET_SCHEDULER_TaskIdentifier ats_task; | 56 | GNUNET_SCHEDULER_TaskIdentifier ats_task; |
47 | }; | 57 | }; |