aboutsummaryrefslogtreecommitdiff
path: root/src/ats
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2012-02-17 13:49:24 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2012-02-17 13:49:24 +0000
commitdde12b107415d22cf0dbe44e2a0b88a974b59ae0 (patch)
tree9dbb8b62890a8d6de25762fd737495454198bdb7 /src/ats
parent85da81fbbfebedf13ebd7524a2c7ad31605595f6 (diff)
downloadgnunet-dde12b107415d22cf0dbe44e2a0b88a974b59ae0.tar.gz
gnunet-dde12b107415d22cf0dbe44e2a0b88a974b59ae0.zip
- logging, testing and result extraction
Diffstat (limited to 'src/ats')
-rw-r--r--src/ats/gnunet-service-ats_addresses_mlp.c124
-rw-r--r--src/ats/test_ats_mlp.c48
2 files changed, 111 insertions, 61 deletions
diff --git a/src/ats/gnunet-service-ats_addresses_mlp.c b/src/ats/gnunet-service-ats_addresses_mlp.c
index 9850bc2a3..50d1e42a2 100644
--- a/src/ats/gnunet-service-ats_addresses_mlp.c
+++ b/src/ats/gnunet-service-ats_addresses_mlp.c
@@ -223,7 +223,7 @@ static int
223mlp_term_hook (void *info, const char *s) 223mlp_term_hook (void *info, const char *s)
224{ 224{
225 /* Not needed atm struct MLP_information *mlp = info; */ 225 /* Not needed atm struct MLP_information *mlp = info; */
226 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "%s", s); 226 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "%s", s);
227 return 1; 227 return 1;
228} 228}
229 229
@@ -603,14 +603,14 @@ mlp_add_constraints_all_addresses (struct GAS_MLP_Handle *mlp, struct GNUNET_CON
603 if (index != GNUNET_SYSERR) 603 if (index != GNUNET_SYSERR)
604 { 604 {
605 value = (double) addr->ats[index].value; 605 value = (double) addr->ats[index].value;
606#if DEBUG_ATS 606
607 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Quality %i with ATS property `%s' has index %i in addresses ats information has value %f\n", c, mlp_ats_to_string(mlp->q[c]), index, (double) addr->ats[index].value); 607 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Quality %i with ATS property `%s' has index %i in addresses ats information has value %f\n", c, mlp_ats_to_string(mlp->q[c]), index, (double) addr->ats[index].value);
608#endif 608
609 } 609 }
610#if DEBUG_ATS 610
611 else 611 else
612 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Quality %i with ATS property `%s' not existing\n", c, mlp_ats_to_string(mlp->q[c]), index); 612 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Quality %i with ATS property `%s' not existing\n", c, mlp_ats_to_string(mlp->q[c]), index);
613#endif 613
614 mlpi = addr->mlp_information; 614 mlpi = addr->mlp_information;
615 615
616 mlpi->r_q[c] = mlp->r_q[c]; 616 mlpi->r_q[c] = mlp->r_q[c];
@@ -819,7 +819,7 @@ lp_solv:
819 else 819 else
820 { 820 {
821 /* Problem was ill-defined, no way to handle that */ 821 /* Problem was ill-defined, no way to handle that */
822 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, 822 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG,
823 "ats-mlp", 823 "ats-mlp",
824 "Solving LP problem failed: %i %s\n", res, mlp_solve_to_string(res)); 824 "Solving LP problem failed: %i %s\n", res, mlp_solve_to_string(res));
825 return GNUNET_SYSERR; 825 return GNUNET_SYSERR;
@@ -848,7 +848,7 @@ lp_solv:
848 848
849 /* Problem was ill-defined, no way to handle that */ 849 /* Problem was ill-defined, no way to handle that */
850 default: 850 default:
851 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, 851 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG,
852 "ats-mlp", 852 "ats-mlp",
853 "Solving LP problem failed, no solution: %s\n", mlp_status_to_string(res)); 853 "Solving LP problem failed, no solution: %s\n", mlp_status_to_string(res));
854 return GNUNET_SYSERR; 854 return GNUNET_SYSERR;
@@ -896,7 +896,7 @@ mlp_solve_mlp_problem (struct GAS_MLP_Handle *mlp)
896 else 896 else
897 { 897 {
898 /* Problem was ill-defined, no way to handle that */ 898 /* Problem was ill-defined, no way to handle that */
899 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, 899 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG,
900 "ats-mlp", 900 "ats-mlp",
901 "Solving MLP problem failed: %s\n", mlp_solve_to_string(res)); 901 "Solving MLP problem failed: %s\n", mlp_solve_to_string(res));
902 return GNUNET_SYSERR; 902 return GNUNET_SYSERR;
@@ -923,7 +923,7 @@ mlp_solve_mlp_problem (struct GAS_MLP_Handle *mlp)
923 923
924 /* Problem was ill-defined, no way to handle that */ 924 /* Problem was ill-defined, no way to handle that */
925 default: 925 default:
926 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, 926 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG,
927 "ats-mlp", 927 "ats-mlp",
928 "Solving MLP problem failed, %s\n\n", mlp_status_to_string(res)); 928 "Solving MLP problem failed, %s\n\n", mlp_status_to_string(res));
929 return GNUNET_SYSERR; 929 return GNUNET_SYSERR;
@@ -945,9 +945,9 @@ mlp_scheduler (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
945 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) 945 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
946 return; 946 return;
947 947
948#if DEBUG_ATS 948
949 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Scheduled problem solving\n"); 949 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Scheduled problem solving\n");
950#endif 950
951 if (mlp->addr_in_problem != 0) 951 if (mlp->addr_in_problem != 0)
952 GAS_mlp_solve_problem(mlp); 952 GAS_mlp_solve_problem(mlp);
953} 953}
@@ -964,9 +964,9 @@ GAS_mlp_solve_problem (struct GAS_MLP_Handle *mlp)
964{ 964{
965 int res; 965 int res;
966 mlp->last_execution = GNUNET_TIME_absolute_get (); 966 mlp->last_execution = GNUNET_TIME_absolute_get ();
967#if DEBUG_ATS 967
968 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Problem solving\n"); 968 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Problem solving\n");
969#endif 969
970 970
971#if WRITE_MLP 971#if WRITE_MLP
972 char * name; 972 char * name;
@@ -987,9 +987,9 @@ GAS_mlp_solve_problem (struct GAS_MLP_Handle *mlp)
987 987
988 if (res != GNUNET_OK) 988 if (res != GNUNET_OK)
989 { 989 {
990#if DEBUG_ATS 990
991 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "LP Problem solving failed\n"); 991 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "LP Problem solving failed\n");
992#endif 992
993 return GNUNET_SYSERR; 993 return GNUNET_SYSERR;
994 } 994 }
995 995
@@ -1002,17 +1002,40 @@ GAS_mlp_solve_problem (struct GAS_MLP_Handle *mlp)
1002# endif 1002# endif
1003 if (res != GNUNET_OK) 1003 if (res != GNUNET_OK)
1004 { 1004 {
1005#if DEBUG_ATS 1005
1006 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MLP Problem solving failed\n"); 1006 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MLP Problem solving failed\n");
1007#endif 1007
1008 return GNUNET_SYSERR; 1008 return GNUNET_SYSERR;
1009 } 1009 }
1010 1010
1011#if DEBUG_ATS
1012 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Problem solved\n");
1013#endif
1014 1011
1012 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Problem solved\n");
1015 /* Process result */ 1013 /* Process result */
1014 struct ATS_Peer *p = NULL;
1015 struct ATS_Address *a = NULL;
1016 struct MLP_information *mlpi = NULL;
1017
1018 for (p = mlp->peer_head; p != NULL; p = p->next)
1019 {
1020 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer `%s'\n", GNUNET_i2s (&p->id));
1021 for (a = p->head; a != NULL; a = a->next)
1022 {
1023 double b = 0.0;
1024 double n = 0.0;
1025
1026 mlpi = a->mlp_information;
1027
1028 b = glp_mip_col_val(mlp->prob, mlpi->c_b);
1029 n = glp_mip_col_val(mlp->prob, mlpi->c_n);
1030
1031 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "\tAddress %f %f\n", n, b);
1032
1033 }
1034
1035 }
1036
1037
1038
1016 1039
1017 if (mlp->mlp_task != GNUNET_SCHEDULER_NO_TASK) 1040 if (mlp->mlp_task != GNUNET_SCHEDULER_NO_TASK)
1018 { 1041 {
@@ -1145,20 +1168,21 @@ GAS_mlp_init (const struct GNUNET_CONFIGURATION_Handle *cfg,
1145 1168
1146 /* Init LP solving parameters */ 1169 /* Init LP solving parameters */
1147 glp_init_smcp(&mlp->control_param_lp); 1170 glp_init_smcp(&mlp->control_param_lp);
1171
1172 mlp->control_param_lp.msg_lev = GLP_MSG_OFF;
1148#if VERBOSE_GLPK 1173#if VERBOSE_GLPK
1149 mlp->control_param_lp.msg_lev = GLP_MSG_ALL; 1174 mlp->control_param_lp.msg_lev = GLP_MSG_ALL;
1150#else
1151 mlp->control_param_lp.msg_lev = GLP_MSG_OFF;
1152#endif 1175#endif
1176
1153 mlp->control_param_lp.it_lim = max_iterations; 1177 mlp->control_param_lp.it_lim = max_iterations;
1154 mlp->control_param_lp.tm_lim = max_duration.rel_value; 1178 mlp->control_param_lp.tm_lim = max_duration.rel_value;
1155 1179
1156 /* Init MLP solving parameters */ 1180 /* Init MLP solving parameters */
1157 glp_init_iocp(&mlp->control_param_mlp); 1181 glp_init_iocp(&mlp->control_param_mlp);
1182
1183 mlp->control_param_mlp.msg_lev = GLP_MSG_OFF;
1158#if VERBOSE_GLPK 1184#if VERBOSE_GLPK
1159 mlp->control_param_mlp.msg_lev = GLP_MSG_ALL; 1185 mlp->control_param_mlp.msg_lev = GLP_MSG_ALL;
1160#else
1161 mlp->control_param_mlp.msg_lev = GLP_MSG_OFF;
1162#endif 1186#endif
1163 mlp->control_param_mlp.tm_lim = max_duration.rel_value; 1187 mlp->control_param_mlp.tm_lim = max_duration.rel_value;
1164 1188
@@ -1225,10 +1249,10 @@ GAS_mlp_address_update (struct GAS_MLP_Handle *mlp, struct GNUNET_CONTAINER_Mult
1225 struct ATS_Peer *peer = mlp_find_peer (mlp, &address->peer); 1249 struct ATS_Peer *peer = mlp_find_peer (mlp, &address->peer);
1226 if (peer == NULL) 1250 if (peer == NULL)
1227 { 1251 {
1228#if DEBUG_ATS 1252
1229 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Adding new peer `%s'\n", 1253 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding new peer `%s'\n",
1230 GNUNET_i2s (&address->peer)); 1254 GNUNET_i2s (&address->peer));
1231#endif 1255
1232 peer = GNUNET_malloc (sizeof (struct ATS_Peer)); 1256 peer = GNUNET_malloc (sizeof (struct ATS_Peer));
1233 peer->head = NULL; 1257 peer->head = NULL;
1234 peer->tail = NULL; 1258 peer->tail = NULL;
@@ -1249,19 +1273,19 @@ GAS_mlp_address_update (struct GAS_MLP_Handle *mlp, struct GNUNET_CONTAINER_Mult
1249 } 1273 }
1250 else 1274 else
1251 { 1275 {
1252#if DEBUG_ATS 1276
1253 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Adding address to peer `%s'\n", 1277 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding address to peer `%s'\n",
1254 GNUNET_i2s (&address->peer)); 1278 GNUNET_i2s (&address->peer));
1255#endif 1279
1256 GNUNET_CONTAINER_DLL_insert (peer->head, peer->tail, address); 1280 GNUNET_CONTAINER_DLL_insert (peer->head, peer->tail, address);
1257 } 1281 }
1258 } 1282 }
1259 else 1283 else
1260 { 1284 {
1261#if DEBUG_ATS 1285
1262 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Updating existing address to peer `%s'\n", 1286 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Updating existing address to peer `%s'\n",
1263 GNUNET_i2s (&address->peer)); 1287 GNUNET_i2s (&address->peer));
1264#endif 1288
1265 mlpi = address->mlp_information; 1289 mlpi = address->mlp_information;
1266 int c; 1290 int c;
1267 for (c = 0; c < GNUNET_ATS_QualityPropertiesCount; c++) 1291 for (c = 0; c < GNUNET_ATS_QualityPropertiesCount; c++)
@@ -1271,13 +1295,13 @@ GAS_mlp_address_update (struct GAS_MLP_Handle *mlp, struct GNUNET_CONTAINER_Mult
1271 { 1295 {
1272 if (mlpi->q[c] == (double) address->ats[index].value) 1296 if (mlpi->q[c] == (double) address->ats[index].value)
1273 break; 1297 break;
1274#if DEBUG_ATS 1298
1275 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Updating address for peer `%s' value `%s'from %f to %f\n", 1299 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Updating address for peer `%s' value `%s'from %f to %f\n",
1276 GNUNET_i2s (&address->peer), 1300 GNUNET_i2s (&address->peer),
1277 mlp_ats_to_string(mlp->q[c]), 1301 mlp_ats_to_string(mlp->q[c]),
1278 mlpi->q[c], 1302 mlpi->q[c],
1279 (double) address->ats[index].value); 1303 (double) address->ats[index].value);
1280#endif 1304
1281 switch (mlp->q[c]) 1305 switch (mlp->q[c])
1282 { 1306 {
1283 case GNUNET_ATS_QUALITY_NET_DELAY: 1307 case GNUNET_ATS_QUALITY_NET_DELAY:
@@ -1302,18 +1326,18 @@ GAS_mlp_address_update (struct GAS_MLP_Handle *mlp, struct GNUNET_CONTAINER_Mult
1302 /* Get the index if matrix row of quality */ 1326 /* Get the index if matrix row of quality */
1303 for (c2 = 1; c2 <= cols; c2++ ) 1327 for (c2 = 1; c2 <= cols; c2++ )
1304 { 1328 {
1305#if DEBUG_ATS 1329
1306 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Existing element column %i : %f\n", 1330 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Existing element column %i : %f\n",
1307 ind[c2], val[c2]); 1331 ind[c2], val[c2]);
1308#endif 1332
1309 if ((mlpi->c_b == ind[c2]) && (val[c2] != mlpi->q[c])) 1333 if ((mlpi->c_b == ind[c2]) && (val[c2] != mlpi->q[c]))
1310 { 1334 {
1311 /* Update the value */ 1335 /* Update the value */
1312 val[c2] = mlpi->q[c]; 1336 val[c2] = mlpi->q[c];
1313#if DEBUG_ATS 1337
1314 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "New element column %i : %f\n", 1338 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "New element column %i : %f\n",
1315 ind[c2], val[c2]); 1339 ind[c2], val[c2]);
1316#endif 1340
1317 } 1341 }
1318 } 1342 }
1319 1343
@@ -1364,16 +1388,16 @@ GAS_mlp_address_delete (struct GAS_MLP_Handle *mlp, struct GNUNET_CONTAINER_Mult
1364 /* Remove from peer list */ 1388 /* Remove from peer list */
1365 struct ATS_Peer *head = mlp_find_peer (mlp, &address->peer); 1389 struct ATS_Peer *head = mlp_find_peer (mlp, &address->peer);
1366 GNUNET_assert (head != NULL); 1390 GNUNET_assert (head != NULL);
1367#if DEBUG_ATS 1391
1368 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Deleting address for `%s'\n", GNUNET_i2s (&address->peer)); 1392 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Deleting address for `%s'\n", GNUNET_i2s (&address->peer));
1369#endif 1393
1370 GNUNET_CONTAINER_DLL_remove (head->head, head->tail, address); 1394 GNUNET_CONTAINER_DLL_remove (head->head, head->tail, address);
1371 if ((head->head == NULL) && (head->tail == NULL)) 1395 if ((head->head == NULL) && (head->tail == NULL))
1372 { 1396 {
1373 /* No address for peer left, remove peer */ 1397 /* No address for peer left, remove peer */
1374#if DEBUG_ATS 1398
1375 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Deleting peer `%s'\n", GNUNET_i2s (&address->peer)); 1399 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Deleting peer `%s'\n", GNUNET_i2s (&address->peer));
1376#endif 1400
1377 GNUNET_CONTAINER_DLL_remove (mlp->peer_head, mlp->peer_tail, head); 1401 GNUNET_CONTAINER_DLL_remove (mlp->peer_head, mlp->peer_tail, head);
1378 GNUNET_free (head); 1402 GNUNET_free (head);
1379 mlp->c_p --; 1403 mlp->c_p --;
diff --git a/src/ats/test_ats_mlp.c b/src/ats/test_ats_mlp.c
index ac5b08f9d..23ab71f7a 100644
--- a/src/ats/test_ats_mlp.c
+++ b/src/ats/test_ats_mlp.c
@@ -78,49 +78,75 @@ check (void *cls, char *const *args, const char *cfgfile,
78 78
79 addresses = GNUNET_CONTAINER_multihashmap_create (10); 79 addresses = GNUNET_CONTAINER_multihashmap_create (10);
80 80
81 /* Creating address 1 */ 81 mlp = GAS_mlp_init (cfg, NULL, MLP_MAX_EXEC_DURATION, MLP_MAX_ITERATIONS);
82 GNUNET_CRYPTO_hash_create_random(GNUNET_CRYPTO_QUALITY_WEAK, &addr[0].peer.hashPubKey); 82 mlp->auto_solve = GNUNET_NO;
83
84 struct GNUNET_PeerIdentity p[10];
85
86 /* Creating peer 1 */
87 GNUNET_CRYPTO_hash_create_random(GNUNET_CRYPTO_QUALITY_WEAK, &p[0].hashPubKey);
88 /* Creating peer 2 */
89 GNUNET_CRYPTO_hash_create_random(GNUNET_CRYPTO_QUALITY_WEAK, &p[1].hashPubKey);
90
91 /* Creating peer 1 address 1 */
92 addr[0].peer.hashPubKey = p[0].hashPubKey;
83 struct GNUNET_ATS_Information a1_ats[3]; 93 struct GNUNET_ATS_Information a1_ats[3];
84 set_ats (&a1_ats[0], GNUNET_ATS_QUALITY_NET_DISTANCE, 1); 94 set_ats (&a1_ats[0], GNUNET_ATS_QUALITY_NET_DISTANCE, 1);
85 set_ats (&a1_ats[1], GNUNET_ATS_QUALITY_NET_DELAY, 32); 95 set_ats (&a1_ats[1], GNUNET_ATS_QUALITY_NET_DELAY, 32);
86 set_ats (&a1_ats[2], GNUNET_ATS_ARRAY_TERMINATOR, 0); 96 set_ats (&a1_ats[2], GNUNET_ATS_ARRAY_TERMINATOR, 0);
87 create_address (&addr[0], "dummy", 3, &a1_ats[0]); 97 create_address (&addr[0], "dummy", 3, &a1_ats[0]);
88 98
89 GNUNET_CRYPTO_hash_create_random(GNUNET_CRYPTO_QUALITY_WEAK, &addr[1].peer.hashPubKey); 99
100 /* Creating peer 1 address 2 */
101 addr[1].peer.hashPubKey = p[0].hashPubKey;
90 struct GNUNET_ATS_Information a2_ats[3]; 102 struct GNUNET_ATS_Information a2_ats[3];
91 set_ats (&a2_ats[0], GNUNET_ATS_ARRAY_TERMINATOR, 0); 103 set_ats (&a2_ats[0], GNUNET_ATS_ARRAY_TERMINATOR, 0);
92 set_ats (&a2_ats[1], GNUNET_ATS_QUALITY_NET_DELAY, 32); 104 set_ats (&a2_ats[1], GNUNET_ATS_QUALITY_NET_DELAY, 32);
93 set_ats (&a2_ats[2], GNUNET_ATS_QUALITY_NET_DISTANCE, 1); 105 set_ats (&a2_ats[2], GNUNET_ATS_QUALITY_NET_DISTANCE, 1);
94
95 create_address (&addr[1], "dummy2", 3, &a2_ats[0]); 106 create_address (&addr[1], "dummy2", 3, &a2_ats[0]);
96 107
97 GNUNET_CONTAINER_multihashmap_put(addresses, &addr[0].peer.hashPubKey, &addr[0], GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); 108 /* Creating peer 2 address 1 */
109 addr[2].peer.hashPubKey = p[1].hashPubKey;
110 struct GNUNET_ATS_Information a3_ats[3];
111 set_ats (&a3_ats[0], GNUNET_ATS_ARRAY_TERMINATOR, 0);
112 set_ats (&a3_ats[1], GNUNET_ATS_QUALITY_NET_DELAY, 32);
113 set_ats (&a3_ats[2], GNUNET_ATS_QUALITY_NET_DISTANCE, 1);
114 create_address (&addr[2], "dummy3", 3, &a3_ats[0]);
98 115
99 mlp = GAS_mlp_init (cfg, NULL, MLP_MAX_EXEC_DURATION, MLP_MAX_ITERATIONS); 116 GNUNET_CONTAINER_multihashmap_put(addresses, &addr[0].peer.hashPubKey, &addr[0], GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
100 mlp->auto_solve = GNUNET_NO;
101 117
102 /* Add a new address */ 118 /* Add peer 1 address 1 */
103 GAS_mlp_address_update (mlp, addresses, &addr[0]); 119 GAS_mlp_address_update (mlp, addresses, &addr[0]);
104 120
105 GNUNET_assert (mlp != NULL); 121 GNUNET_assert (mlp != NULL);
106 GNUNET_assert (mlp->addr_in_problem == 1); 122 GNUNET_assert (mlp->addr_in_problem == 1);
107 123
108 /* Update an new address */ 124 /* Update an peer 1 address 1 */
109 set_ats (&a1_ats[1], GNUNET_ATS_QUALITY_NET_DELAY, 20); 125 set_ats (&a1_ats[1], GNUNET_ATS_QUALITY_NET_DELAY, 20);
110 GAS_mlp_address_update (mlp, addresses, &addr[0]); 126 GAS_mlp_address_update (mlp, addresses, &addr[0]);
111 GNUNET_assert (mlp->addr_in_problem == 1); 127 GNUNET_assert (mlp->addr_in_problem == 1);
112 128
113 /* Add a second address for same peer */ 129 /* Add peer 1 address 2 */
114 GNUNET_CONTAINER_multihashmap_put(addresses, &addr[1].peer.hashPubKey, &addr[1], GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); 130 GNUNET_CONTAINER_multihashmap_put(addresses, &addr[0].peer.hashPubKey, &addr[1], GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
115 GAS_mlp_address_update (mlp, addresses, &addr[1]); 131 GAS_mlp_address_update (mlp, addresses, &addr[1]);
116 GNUNET_assert (mlp->addr_in_problem == 2); 132 GNUNET_assert (mlp->addr_in_problem == 2);
117 133
134 /* Add peer 2 address 1 */
135 GNUNET_CONTAINER_multihashmap_put(addresses, &addr[2].peer.hashPubKey, &addr[2], GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
136 GAS_mlp_address_update (mlp, addresses, &addr[2]);
137 GNUNET_assert (mlp->addr_in_problem == 3);
138
118 GNUNET_assert (GNUNET_OK == GAS_mlp_solve_problem(mlp)); 139 GNUNET_assert (GNUNET_OK == GAS_mlp_solve_problem(mlp));
119 140
120 /* Delete an address */ 141 /* Delete an address */
121 GNUNET_CONTAINER_multihashmap_remove (addresses, &addr[0].peer.hashPubKey, &addr[0]); 142 GNUNET_CONTAINER_multihashmap_remove (addresses, &addr[0].peer.hashPubKey, &addr[0]);
122 GAS_mlp_address_delete (mlp, addresses, &addr[0]); 143 GAS_mlp_address_delete (mlp, addresses, &addr[0]);
144 GNUNET_CONTAINER_multihashmap_remove (addresses, &addr[1].peer.hashPubKey, &addr[1]);
123 GAS_mlp_address_delete (mlp, addresses, &addr[1]); 145 GAS_mlp_address_delete (mlp, addresses, &addr[1]);
146 GNUNET_CONTAINER_multihashmap_remove (addresses, &addr[2].peer.hashPubKey, &addr[2]);
147 GAS_mlp_address_delete (mlp, addresses, &addr[2]);
148
149 GNUNET_assert (mlp->addr_in_problem == 0);
124 150
125 GAS_mlp_done (mlp); 151 GAS_mlp_done (mlp);
126 152