aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2013-04-03 07:37:28 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2013-04-03 07:37:28 +0000
commit0b0572d08c9d802f0555a1376c92f2858a285e78 (patch)
treefdeaf56d4d11063c8afd117ad14de13eacd0b406 /src
parent5b082ff11acb8334d669af3e2d0dbdacb1e9f5aa (diff)
downloadgnunet-0b0572d08c9d802f0555a1376c92f2858a285e78.tar.gz
gnunet-0b0572d08c9d802f0555a1376c92f2858a285e78.zip
fixed mlp
Diffstat (limited to 'src')
-rw-r--r--src/ats/gnunet-service-ats_addresses_mlp.c49
1 files changed, 36 insertions, 13 deletions
diff --git a/src/ats/gnunet-service-ats_addresses_mlp.c b/src/ats/gnunet-service-ats_addresses_mlp.c
index 4c10f5b8a..bc5ed5f32 100644
--- a/src/ats/gnunet-service-ats_addresses_mlp.c
+++ b/src/ats/gnunet-service-ats_addresses_mlp.c
@@ -359,7 +359,29 @@ mlp_solve_to_string (int retcode)
359 } 359 }
360} 360}
361 361
362/**
363 * Extract an ATS performance info from an address
364 *
365 * @param address the address
366 * @param type the type to extract in HBO
367 * @return the value in HBO or UINT32_MAX in HBO if value does not exist
368 */
369static int
370get_performance_info (struct ATS_Address *address, uint32_t type)
371{
372 int c1;
373 GNUNET_assert (NULL != address);
362 374
375 if ((NULL == address->atsi) || (0 == address->atsi_count))
376 return UINT32_MAX;
377
378 for (c1 = 0; c1 < address->atsi_count; c1++)
379 {
380 if (ntohl(address->atsi[c1].type) == type)
381 return ntohl(address->atsi[c1].value);
382 }
383 return UINT32_MAX;
384}
363 385
364 386
365struct CountContext 387struct CountContext
@@ -483,6 +505,7 @@ mlp_create_problem_add_address_information (void *cls, const struct GNUNET_HashC
483 struct ATS_Peer *peer; 505 struct ATS_Peer *peer;
484 struct MLP_information *mlpi; 506 struct MLP_information *mlpi;
485 char *name; 507 char *name;
508 uint32_t addr_net;
486 int c; 509 int c;
487 510
488 /* Check if we have to add this peer due to a pending request */ 511 /* Check if we have to add this peer due to a pending request */
@@ -582,13 +605,15 @@ mlp_create_problem_add_address_information (void *cls, const struct GNUNET_HashC
582 */ 605 */
583 for (c = 0; c < GNUNET_ATS_NetworkTypeCount; c++) 606 for (c = 0; c < GNUNET_ATS_NetworkTypeCount; c++)
584 { 607 {
585#if 0 608 addr_net = get_performance_info (address, GNUNET_ATS_NETWORK_TYPE);
586 if (mlp->pv.quota_index[c] == address->atsp_network_type) 609 if (UINT32_MAX == addr_net)
610 addr_net = GNUNET_ATS_NET_UNSPECIFIED;
611
612 if (mlp->pv.quota_index[c] == addr_net)
587 { 613 {
588 mlp_create_problem_set_value (p, p->r_quota[c], mlpi->c_b, 1, __LINE__); 614 mlp_create_problem_set_value (p, p->r_quota[c], mlpi->c_b, 1, __LINE__);
589 break; 615 break;
590 } 616 }
591#endif
592 } 617 }
593 618
594 /* c 7) Optimize quality */ 619 /* c 7) Optimize quality */
@@ -596,7 +621,6 @@ mlp_create_problem_add_address_information (void *cls, const struct GNUNET_HashC
596 for (c = 0; c < mlp->pv.m_q; c++) 621 for (c = 0; c < mlp->pv.m_q; c++)
597 mlp_create_problem_set_value (p, p->r_q[c], mlpi->c_b, mlpi->q_averaged[c], __LINE__); 622 mlp_create_problem_set_value (p, p->r_q[c], mlpi->c_b, mlpi->q_averaged[c], __LINE__);
598 623
599
600 return GNUNET_OK; 624 return GNUNET_OK;
601} 625}
602 626
@@ -1078,9 +1102,9 @@ mlp_update_quality (struct GAS_MLP_Handle *mlp,
1078 int qual_changed; 1102 int qual_changed;
1079 int type_index; 1103 int type_index;
1080 int avg_index; 1104 int avg_index;
1105 uint32_t addr_net;
1081 uint32_t type; 1106 uint32_t type;
1082 uint32_t value; 1107 uint32_t value;
1083 uint32_t old_value;
1084 double avg; 1108 double avg;
1085 double *queue; 1109 double *queue;
1086 int rows; 1110 int rows;
@@ -1110,18 +1134,17 @@ mlp_update_quality (struct GAS_MLP_Handle *mlp,
1110 /* Check for network update */ 1134 /* Check for network update */
1111 if (type == GNUNET_ATS_NETWORK_TYPE) 1135 if (type == GNUNET_ATS_NETWORK_TYPE)
1112 { 1136 {
1113#if 0 1137 addr_net = get_performance_info (address, GNUNET_ATS_NETWORK_TYPE);
1114 if (address->atsp_network_type != value) 1138 if (UINT32_MAX == addr_net)
1139 addr_net = GNUNET_ATS_NET_UNSPECIFIED;
1140 if (addr_net != value)
1115 { 1141 {
1116 LOG (GNUNET_ERROR_TYPE_DEBUG, "Updating network for peer `%s' from `%s' to `%s'\n", 1142 LOG (GNUNET_ERROR_TYPE_DEBUG, "Updating network for peer `%s' from `%s' to `%s'\n",
1117 GNUNET_i2s (&address->peer), 1143 GNUNET_i2s (&address->peer),
1118 GNUNET_ATS_print_network_type(address->atsp_network_type), 1144 GNUNET_ATS_print_network_type(addr_net),
1119 GNUNET_ATS_print_network_type(value)); 1145 GNUNET_ATS_print_network_type(value));
1120 } 1146 }
1121 1147
1122 old_value = address->atsp_network_type;
1123 address->atsp_network_type = value;
1124#endif
1125 if (mlpi->c_b == MLP_UNDEFINED) 1148 if (mlpi->c_b == MLP_UNDEFINED)
1126 continue; /* This address is not yet in the matrix*/ 1149 continue; /* This address is not yet in the matrix*/
1127 1150
@@ -1132,7 +1155,7 @@ mlp_update_quality (struct GAS_MLP_Handle *mlp,
1132 1155
1133 for (c_net = 0; c_net <= length + 1; c_net ++) 1156 for (c_net = 0; c_net <= length + 1; c_net ++)
1134 { 1157 {
1135 if (ind[c_net] == mlp->p.r_quota[old_value]) 1158 if (ind[c_net] == mlp->p.r_quota[addr_net])
1136 break; /* Found index for old network */ 1159 break; /* Found index for old network */
1137 } 1160 }
1138 val[c_net] = 0.0; 1161 val[c_net] = 0.0;
@@ -1153,7 +1176,7 @@ mlp_update_quality (struct GAS_MLP_Handle *mlp,
1153 { 1176 {
1154 if (ind[c_net] == mlp->p.r_quota[value]) 1177 if (ind[c_net] == mlp->p.r_quota[value])
1155 LOG (GNUNET_ERROR_TYPE_DEBUG, "Removing old network index [%u] == [%f]\n",ind[c_net],val[c_net]); 1178 LOG (GNUNET_ERROR_TYPE_DEBUG, "Removing old network index [%u] == [%f]\n",ind[c_net],val[c_net]);
1156 if (ind[c_net] == mlp->p.r_quota[old_value]) 1179 if (ind[c_net] == mlp->p.r_quota[addr_net])
1157 { 1180 {
1158 LOG (GNUNET_ERROR_TYPE_DEBUG, "Setting new network index [%u] == [%f]\n",ind[c_net],val[c_net]); 1181 LOG (GNUNET_ERROR_TYPE_DEBUG, "Setting new network index [%u] == [%f]\n",ind[c_net],val[c_net]);
1159 break; 1182 break;