diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2011-04-06 17:30:21 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2011-04-06 17:30:21 +0000 |
commit | a1706dd71f047c5261145a01fa4544be92a0bef9 (patch) | |
tree | 5a1a7dc2f018c5f6335e362ae798d551d4f18418 /src | |
parent | 78821fe96de53ff40851c11cf2134654a0b63640 (diff) | |
download | gnunet-a1706dd71f047c5261145a01fa4544be92a0bef9.tar.gz gnunet-a1706dd71f047c5261145a01fa4544be92a0bef9.zip |
now with history
Diffstat (limited to 'src')
-rw-r--r-- | src/transport/gnunet-service-transport.c | 98 |
1 files changed, 78 insertions, 20 deletions
diff --git a/src/transport/gnunet-service-transport.c b/src/transport/gnunet-service-transport.c index 94308eadd..fb08ee816 100644 --- a/src/transport/gnunet-service-transport.c +++ b/src/transport/gnunet-service-transport.c | |||
@@ -190,6 +190,8 @@ struct ForeignAddressList | |||
190 | 190 | ||
191 | struct ATS_ressource_entry * ressources; | 191 | struct ATS_ressource_entry * ressources; |
192 | 192 | ||
193 | struct ATS_quality_entry * quality; | ||
194 | |||
193 | /** | 195 | /** |
194 | * What was the last latency observed for this address, plugin and peer? | 196 | * What was the last latency observed for this address, plugin and peer? |
195 | */ | 197 | */ |
@@ -1034,14 +1036,21 @@ static struct GNUNET_STATISTICS_Handle *stats; | |||
1034 | */ | 1036 | */ |
1035 | static struct ATS_info *ats; | 1037 | static struct ATS_info *ats; |
1036 | 1038 | ||
1037 | #if HAVE_LIBGLPK | 1039 | struct ATS_quality_entry |
1040 | { | ||
1041 | int index; | ||
1042 | int atsi_index; | ||
1043 | uint32_t values[3]; | ||
1044 | int current; | ||
1045 | }; | ||
1046 | |||
1038 | static struct ATS_quality_metric qm[] = | 1047 | static struct ATS_quality_metric qm[] = |
1039 | { | 1048 | { |
1040 | {1, 1028, "QUALITY_NET_DISTANCE"}, | 1049 | {1, 1028, "QUALITY_NET_DISTANCE"}, |
1041 | {2, 1034, "QUALITY_NET_DELAY"}, | 1050 | {2, 1034, "QUALITY_NET_DELAY"}, |
1042 | }; | 1051 | }; |
1043 | static int available_quality_metrics = 2; | 1052 | static int available_quality_metrics = 2; |
1044 | #endif | 1053 | |
1045 | 1054 | ||
1046 | /** | 1055 | /** |
1047 | * The peer specified by the given neighbour has timed-out or a plugin | 1056 | * The peer specified by the given neighbour has timed-out or a plugin |
@@ -1101,6 +1110,36 @@ find_neighbour (const struct GNUNET_PeerIdentity *key) | |||
1101 | return head; | 1110 | return head; |
1102 | } | 1111 | } |
1103 | 1112 | ||
1113 | static void update_addr_ats (struct ForeignAddressList *fal, const struct GNUNET_TRANSPORT_ATS_Information *ats_data, int ats_count) | ||
1114 | { | ||
1115 | int c1, c2; | ||
1116 | for (c1=0; c1<ats_count; c1++) | ||
1117 | { | ||
1118 | for (c2=0; c2<available_quality_metrics; c2++) | ||
1119 | { | ||
1120 | if (ntohl(ats_data[c1].type) == qm[c2].atis_index) | ||
1121 | { | ||
1122 | fal->quality[c2].values[0] = fal->quality[c2].values[1]; | ||
1123 | fal->quality[c2].values[1] = fal->quality[c2].values[2]; | ||
1124 | fal->quality[c2].values[2] = ntohl(ats_data[c1].value); | ||
1125 | } | ||
1126 | } | ||
1127 | } | ||
1128 | } | ||
1129 | |||
1130 | static void update_addr_value (struct ForeignAddressList *fal, uint32_t value , int ats_index) | ||
1131 | { | ||
1132 | int c; | ||
1133 | for (c=0; c<available_quality_metrics; c++) | ||
1134 | { | ||
1135 | if (ats_index == qm[c].atis_index) | ||
1136 | { | ||
1137 | fal->quality[c].values[0] = fal->quality[c].values[1]; | ||
1138 | fal->quality[c].values[1] = fal->quality[c].values[2]; | ||
1139 | fal->quality[c].values[2] = value; | ||
1140 | } | ||
1141 | } | ||
1142 | } | ||
1104 | 1143 | ||
1105 | /** | 1144 | /** |
1106 | * Find an entry in the transport list for a particular transport. | 1145 | * Find an entry in the transport list for a particular transport. |
@@ -1797,7 +1836,7 @@ try_transmission_to_peer (struct NeighbourList *n) | |||
1797 | #if DEBUG_TRANSPORT | 1836 | #if DEBUG_TRANSPORT |
1798 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1837 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1799 | "Transmission queue for `%4s' is empty\n", | 1838 | "Transmission queue for `%4s' is empty\n", |
1800 | GNUNET_i2s (&neighbour->id)); | 1839 | GNUNET_i2s (&n->id)); |
1801 | #endif | 1840 | #endif |
1802 | return; /* nothing to do */ | 1841 | return; /* nothing to do */ |
1803 | } | 1842 | } |
@@ -1878,7 +1917,7 @@ try_transmission_to_peer (struct NeighbourList *n) | |||
1878 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1917 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1879 | "Sending message of size %u for `%4s' to `%s' via plugin `%s'\n", | 1918 | "Sending message of size %u for `%4s' to `%s' via plugin `%s'\n", |
1880 | mq->message_buf_size, | 1919 | mq->message_buf_size, |
1881 | GNUNET_i2s (&neighbour->id), | 1920 | GNUNET_i2s (&n->id), |
1882 | (mq->specific_address->addr != NULL) | 1921 | (mq->specific_address->addr != NULL) |
1883 | ? a2s (mq->plugin->short_name, | 1922 | ? a2s (mq->plugin->short_name, |
1884 | mq->specific_address->addr, | 1923 | mq->specific_address->addr, |
@@ -2631,6 +2670,7 @@ add_peer_address (struct NeighbourList *neighbour, | |||
2631 | } | 2670 | } |
2632 | } | 2671 | } |
2633 | 2672 | ||
2673 | ret->quality = GNUNET_malloc (available_quality_metrics * sizeof (struct ATS_quality_entry)); | ||
2634 | ret->addrlen = addrlen; | 2674 | ret->addrlen = addrlen; |
2635 | ret->expires = GNUNET_TIME_relative_to_absolute | 2675 | ret->expires = GNUNET_TIME_relative_to_absolute |
2636 | (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT); | 2676 | (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT); |
@@ -3947,6 +3987,8 @@ check_pending_validation (void *cls, | |||
3947 | 1, | 3987 | 1, |
3948 | GNUNET_NO); | 3988 | GNUNET_NO); |
3949 | fal->latency = GNUNET_TIME_absolute_get_duration (ve->send_time); | 3989 | fal->latency = GNUNET_TIME_absolute_get_duration (ve->send_time); |
3990 | update_addr_value (fal, GNUNET_TIME_absolute_get_duration (ve->send_time).rel_value, GNUNET_TRANSPORT_ATS_QUALITY_NET_DELAY); | ||
3991 | |||
3950 | schedule_next_ping (fal); | 3992 | schedule_next_ping (fal); |
3951 | if (n->latency.rel_value == GNUNET_TIME_UNIT_FOREVER_REL.rel_value) | 3993 | if (n->latency.rel_value == GNUNET_TIME_UNIT_FOREVER_REL.rel_value) |
3952 | n->latency = fal->latency; | 3994 | n->latency = fal->latency; |
@@ -4638,6 +4680,7 @@ disconnect_neighbour (struct NeighbourList *n, int check) | |||
4638 | peer_pos->revalidate_task = GNUNET_SCHEDULER_NO_TASK; | 4680 | peer_pos->revalidate_task = GNUNET_SCHEDULER_NO_TASK; |
4639 | } | 4681 | } |
4640 | GNUNET_free(peer_pos->ressources); | 4682 | GNUNET_free(peer_pos->ressources); |
4683 | GNUNET_free(peer_pos->quality); | ||
4641 | GNUNET_free(peer_pos); | 4684 | GNUNET_free(peer_pos); |
4642 | } | 4685 | } |
4643 | GNUNET_free (rpos); | 4686 | GNUNET_free (rpos); |
@@ -4948,6 +4991,9 @@ handle_ping(void *cls, const struct GNUNET_MessageHeader *message, | |||
4948 | } | 4991 | } |
4949 | 4992 | ||
4950 | 4993 | ||
4994 | |||
4995 | |||
4996 | |||
4951 | /** | 4997 | /** |
4952 | * Function called by the plugin for each received message. | 4998 | * Function called by the plugin for each received message. |
4953 | * Update data volumes, possibly notify plugins about | 4999 | * Update data volumes, possibly notify plugins about |
@@ -4995,6 +5041,7 @@ plugin_env_receive (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
4995 | GNUNET_assert ((plugin->api->send == NULL) || (service_context != NULL)); | 5041 | GNUNET_assert ((plugin->api->send == NULL) || (service_context != NULL)); |
4996 | peer_address = NULL; | 5042 | peer_address = NULL; |
4997 | distance = 1; | 5043 | distance = 1; |
5044 | |||
4998 | for (c=0; c<ats_count; c++) | 5045 | for (c=0; c<ats_count; c++) |
4999 | { | 5046 | { |
5000 | if (ntohl(ats_data[c].type) == GNUNET_TRANSPORT_ATS_QUALITY_NET_DISTANCE) | 5047 | if (ntohl(ats_data[c].type) == GNUNET_TRANSPORT_ATS_QUALITY_NET_DISTANCE) |
@@ -5003,7 +5050,7 @@ plugin_env_receive (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
5003 | } | 5050 | } |
5004 | } | 5051 | } |
5005 | /* notify ATS about incoming data */ | 5052 | /* notify ATS about incoming data */ |
5006 | ats_notify_ats_data(peer, ats_data); | 5053 | //ats_notify_ats_data(peer, ats_data); |
5007 | 5054 | ||
5008 | if (message != NULL) | 5055 | if (message != NULL) |
5009 | { | 5056 | { |
@@ -5016,7 +5063,11 @@ plugin_env_receive (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
5016 | sender_address_len); | 5063 | sender_address_len); |
5017 | if (peer_address != NULL) | 5064 | if (peer_address != NULL) |
5018 | { | 5065 | { |
5019 | peer_address->distance = distance; | 5066 | |
5067 | update_addr_ats(peer_address, ats_data, ats_count); | ||
5068 | update_addr_value(peer_address, distance, GNUNET_TRANSPORT_ATS_QUALITY_NET_DISTANCE); | ||
5069 | |||
5070 | peer_address->distance = distance; | ||
5020 | if (GNUNET_YES == peer_address->validated) | 5071 | if (GNUNET_YES == peer_address->validated) |
5021 | mark_address_connected (peer_address); | 5072 | mark_address_connected (peer_address); |
5022 | peer_address->timeout | 5073 | peer_address->timeout |
@@ -6059,23 +6110,30 @@ static int ats_solve_problem (int max_it, int max_dur , double D, double U, doub | |||
6059 | ja[array_index] = c2; | 6110 | ja[array_index] = c2; |
6060 | if (qm[c-1].atis_index == GNUNET_TRANSPORT_ATS_QUALITY_NET_DELAY) | 6111 | if (qm[c-1].atis_index == GNUNET_TRANSPORT_ATS_QUALITY_NET_DELAY) |
6061 | { | 6112 | { |
6062 | if (mechanisms[c2].addr->latency.rel_value == -1) | 6113 | double v0, v1, v2; |
6063 | value = 0; | 6114 | v0 = mechanisms[c2].addr->quality[c-1].values[0]; |
6064 | if (mechanisms[c2].addr->latency.rel_value == 0) | 6115 | if (v1 < 1) v0 = 0.1; |
6065 | value = 0 ; | 6116 | v1 = mechanisms[c2].addr->quality[c-1].values[1]; |
6066 | else | 6117 | if (v1 < 1) v0 = 0.1; |
6067 | value = 100 / (double) mechanisms[c2].addr->latency.rel_value; | 6118 | v2 = mechanisms[c2].addr->quality[c-1].values[2]; |
6068 | 6119 | if (v1 < 1) v0 = 0.1; | |
6069 | //if (VERBOSE_ATS) GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "DELAY VALUE %f %llu\n",value, mechanisms[c2].addr->latency.rel_value); | 6120 | value = 100.0 / ((v0 + 2 * v1 + 3 * v2) / 6.0); |
6070 | } | 6121 | } |
6071 | if (qm[c-1].atis_index == GNUNET_TRANSPORT_ATS_QUALITY_NET_DISTANCE) | 6122 | if (qm[c-1].atis_index == GNUNET_TRANSPORT_ATS_QUALITY_NET_DISTANCE) |
6072 | { | 6123 | { |
6073 | if (mechanisms[c2].addr->distance == -1) | 6124 | double v0, v1, v2; |
6074 | value = 0; | 6125 | v0 = mechanisms[c2].addr->quality[c-1].values[0]; |
6075 | else if (mechanisms[c2].addr->distance == 0) | 6126 | if (v0 < 1) v0 = 1; |
6076 | value = 0; | 6127 | v1 = mechanisms[c2].addr->quality[c-1].values[1]; |
6077 | else value = (double) 10 / mechanisms[c2].addr->distance; | 6128 | if (v1 < 1) v1 = 1; |
6078 | //if (VERBOSE_ATS) GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "DISTANCE VALUE %f %lli\n",value, mechanisms[c2].addr->distance); | 6129 | v2 = mechanisms[c2].addr->quality[c-1].values[2]; |
6130 | if (v2 < 1) v2 = 1; | ||
6131 | value = (v0 + 2 * v1 + 3 * v2) / 6.0; | ||
6132 | if (value >= 1) | ||
6133 | value = (double) 10 / value; | ||
6134 | else | ||
6135 | value = 10; | ||
6136 | if (VERBOSE_ATS) GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "DISTANCE VALUE %f\n",value); | ||
6079 | } | 6137 | } |
6080 | ar[array_index] = (mechanisms[c2].peer->f) * value ; | 6138 | ar[array_index] = (mechanisms[c2].peer->f) * value ; |
6081 | //if (VERBOSE_ATS) GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "[index]=[%i]: %s [%i,%i]=%f \n",array_index, qm[c-1].name, ia[array_index], ja[array_index], ar[array_index]); | 6139 | //if (VERBOSE_ATS) GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "[index]=[%i]: %s [%i,%i]=%f \n",array_index, qm[c-1].name, ia[array_index], ja[array_index], ar[array_index]); |