diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2012-02-23 14:40:01 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2012-02-23 14:40:01 +0000 |
commit | 21ef21a25e71ded728e0de84a1762b87bdc5af7e (patch) | |
tree | ab2bdea4705cd4b333611bfc966bf07b861ecea0 /src/ats | |
parent | 297b8ea479db3fd5513e16093d517dee30a51c24 (diff) | |
download | gnunet-21ef21a25e71ded728e0de84a1762b87bdc5af7e.tar.gz gnunet-21ef21a25e71ded728e0de84a1762b87bdc5af7e.zip |
averaging fast changing quality values
Diffstat (limited to 'src/ats')
-rw-r--r-- | src/ats/Makefile.am | 12 | ||||
-rw-r--r-- | src/ats/gnunet-service-ats_addresses_mlp.c | 298 | ||||
-rw-r--r-- | src/ats/gnunet-service-ats_addresses_mlp.h | 13 | ||||
-rw-r--r-- | src/ats/test_ats_api.conf | 2 | ||||
-rw-r--r-- | src/ats/test_ats_mlp.c | 8 |
5 files changed, 216 insertions, 117 deletions
diff --git a/src/ats/Makefile.am b/src/ats/Makefile.am index 5b7e9a127..a0a54ee47 100644 --- a/src/ats/Makefile.am +++ b/src/ats/Makefile.am | |||
@@ -16,7 +16,8 @@ endif | |||
16 | if HAVE_LIBGLPK | 16 | if HAVE_LIBGLPK |
17 | GN_LIBGLPK = -lglpk | 17 | GN_LIBGLPK = -lglpk |
18 | GN_MLP_SRC = gnunet-service-ats_addresses_mlp.c gnunet-service-ats_addresses_mlp.h | 18 | GN_MLP_SRC = gnunet-service-ats_addresses_mlp.c gnunet-service-ats_addresses_mlp.h |
19 | GN_MLP_TEST = test_ats_mlp | 19 | GN_MLP_TEST = test_ats_mlp |
20 | GN_MLP_TEST_AVG = test_ats_mlp_averaging | ||
20 | GN_MLP_PERF = perf_ats_mlp | 21 | GN_MLP_PERF = perf_ats_mlp |
21 | endif | 22 | endif |
22 | 23 | ||
@@ -54,6 +55,7 @@ gnunet_service_ats_LDADD = \ | |||
54 | check_PROGRAMS = \ | 55 | check_PROGRAMS = \ |
55 | test_ats_api_scheduling \ | 56 | test_ats_api_scheduling \ |
56 | $(GN_MLP_TEST) \ | 57 | $(GN_MLP_TEST) \ |
58 | $(GN_MLP_TEST_AVG) \ | ||
57 | $(GN_MLP_PERF) | 59 | $(GN_MLP_PERF) |
58 | # test_ats_api_scheduling_get_type | 60 | # test_ats_api_scheduling_get_type |
59 | # test_ats_api_bandwidth_consumption | 61 | # test_ats_api_bandwidth_consumption |
@@ -70,6 +72,14 @@ test_ats_mlp_LDADD = \ | |||
70 | $(GN_LIBGLPK) \ | 72 | $(GN_LIBGLPK) \ |
71 | $(top_builddir)/src/util/libgnunetutil.la \ | 73 | $(top_builddir)/src/util/libgnunetutil.la \ |
72 | $(top_builddir)/src/statistics/libgnunetstatistics.la | 74 | $(top_builddir)/src/statistics/libgnunetstatistics.la |
75 | |||
76 | test_ats_mlp_averaging_SOURCES = \ | ||
77 | $(GN_MLP_SRC) \ | ||
78 | test_ats_mlp_averaging.c | ||
79 | test_ats_mlp_averaging_LDADD = \ | ||
80 | $(GN_LIBGLPK) \ | ||
81 | $(top_builddir)/src/util/libgnunetutil.la \ | ||
82 | $(top_builddir)/src/statistics/libgnunetstatistics.la | ||
73 | 83 | ||
74 | perf_ats_mlp_SOURCES = \ | 84 | perf_ats_mlp_SOURCES = \ |
75 | $(GN_MLP_SRC) \ | 85 | $(GN_MLP_SRC) \ |
diff --git a/src/ats/gnunet-service-ats_addresses_mlp.c b/src/ats/gnunet-service-ats_addresses_mlp.c index 17e3f2f2a..e0ba5cf43 100644 --- a/src/ats/gnunet-service-ats_addresses_mlp.c +++ b/src/ats/gnunet-service-ats_addresses_mlp.c | |||
@@ -392,7 +392,7 @@ static int | |||
392 | mlp_lookup_ats (struct ATS_Address *addr, int ats_index) | 392 | mlp_lookup_ats (struct ATS_Address *addr, int ats_index) |
393 | { | 393 | { |
394 | struct GNUNET_ATS_Information * ats = addr->ats; | 394 | struct GNUNET_ATS_Information * ats = addr->ats; |
395 | int c; | 395 | int c = 0; |
396 | int found = GNUNET_NO; | 396 | int found = GNUNET_NO; |
397 | for (c = 0; c < addr->ats_count; c++) | 397 | for (c = 0; c < addr->ats_count; c++) |
398 | { | 398 | { |
@@ -626,58 +626,40 @@ mlp_add_constraints_all_addresses (struct GAS_MLP_Handle *mlp, struct GNUNET_CON | |||
626 | 626 | ||
627 | /* c 7) For all quality metrics */ | 627 | /* c 7) For all quality metrics */ |
628 | 628 | ||
629 | |||
629 | for (c = 0; c < mlp->m_q; c++) | 630 | for (c = 0; c < mlp->m_q; c++) |
630 | { | 631 | { |
631 | struct ATS_Peer *p = mlp->peer_head; | 632 | struct ATS_Peer *tp; |
632 | struct ATS_Address *addr = p->head; | 633 | struct ATS_Address *ta; |
633 | struct MLP_information * mlpi; | 634 | struct MLP_information * mlpi; |
634 | double value = 1.0; | 635 | double value = 1.0; |
635 | 636 | ||
636 | while (p != NULL) | 637 | /* Adding rows for c 7) */ |
637 | { | 638 | mlp->r_q[c] = glp_add_rows (mlp->prob, 1); |
638 | /* Adding rows for c 7) */ | 639 | GNUNET_asprintf(&name, "c7_q%i_%s", c, mlp_ats_to_string(mlp->q[c])); |
639 | mlp->r_q[c] = glp_add_rows (mlp->prob, 1); | 640 | glp_set_row_name (mlp->prob, mlp->r_q[c], name); |
640 | GNUNET_asprintf(&name, "c7_q%i_atsi_%i", c, mlp->q[c]); | 641 | GNUNET_free (name); |
641 | glp_set_row_name (mlp->prob, mlp->r_q[c], name); | 642 | /* Set row bound == 0 */ |
642 | GNUNET_free (name); | 643 | glp_set_row_bnds (mlp->prob, mlp->r_q[c], GLP_LO, 0.0, 0.0); |
643 | /* Set row bound == 0 */ | ||
644 | glp_set_row_bnds (mlp->prob, mlp->r_q[c], GLP_LO, 0.0, 0.0); | ||
645 | |||
646 | ia[mlp->ci] = mlp->r_q[c]; | ||
647 | ja[mlp->ci] = mlp->c_q[c]; | ||
648 | ar[mlp->ci] = -1; | ||
649 | mlp->ci++; | ||
650 | 644 | ||
651 | while (addr != NULL) | 645 | ia[mlp->ci] = mlp->r_q[c]; |
652 | { | 646 | ja[mlp->ci] = mlp->c_q[c]; |
653 | mlpi = addr->mlp_information; | 647 | ar[mlp->ci] = -1; |
654 | /* lookup ATS information */ | 648 | mlp->ci++; |
655 | int index = mlp_lookup_ats(addr, mlp->q[c]); | ||
656 | 649 | ||
657 | if (index != GNUNET_SYSERR) | 650 | for (tp = mlp->peer_head; tp != NULL; tp = tp->next) |
651 | for (ta = tp->head; ta != NULL; ta = ta->next) | ||
658 | { | 652 | { |
659 | value = (double) addr->ats[index].value; | 653 | mlpi = ta->mlp_information; |
660 | 654 | value = mlpi->q_averaged[c]; | |
661 | 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); | ||
662 | } | ||
663 | else | ||
664 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Quality %i with ATS property `%s' not existing\n", c, mlp_ats_to_string(mlp->q[c]), index); | ||
665 | |||
666 | mlpi = addr->mlp_information; | ||
667 | |||
668 | mlpi->r_q[c] = mlp->r_q[c]; | ||
669 | mlpi->c_q[c] = mlpi->c_b; | ||
670 | mlpi->q[c] = value; | ||
671 | 655 | ||
672 | ia[mlp->ci] = mlp->r_q[c]; | 656 | mlpi->r_q[c] = mlp->r_q[c]; |
673 | ja[mlp->ci] = mlpi->c_b; | ||
674 | ar[mlp->ci] = p->f * value; | ||
675 | mlp->ci++; | ||
676 | 657 | ||
677 | addr = addr->next; | 658 | ia[mlp->ci] = mlp->r_q[c]; |
678 | } | 659 | ja[mlp->ci] = mlpi->c_b; |
679 | p = p->next; | 660 | ar[mlp->ci] = tp->f * value; |
680 | } | 661 | mlp->ci++; |
662 | } | ||
681 | } | 663 | } |
682 | } | 664 | } |
683 | 665 | ||
@@ -1332,6 +1314,159 @@ GAS_mlp_init (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
1332 | return mlp; | 1314 | return mlp; |
1333 | } | 1315 | } |
1334 | 1316 | ||
1317 | static void | ||
1318 | update_quality (struct GAS_MLP_Handle *mlp, struct ATS_Address * address) | ||
1319 | { | ||
1320 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Updating quality metrics for peer `%s'\n", | ||
1321 | GNUNET_i2s (&address->peer)); | ||
1322 | |||
1323 | struct MLP_information *mlpi = address->mlp_information; | ||
1324 | struct GNUNET_ATS_Information *ats = address->ats; | ||
1325 | GNUNET_assert (mlpi != NULL); | ||
1326 | |||
1327 | int c; | ||
1328 | |||
1329 | for (c = 0; c < GNUNET_ATS_QualityPropertiesCount; c++) | ||
1330 | { | ||
1331 | int index = mlp_lookup_ats(address, mlp->q[c]); | ||
1332 | |||
1333 | if (index == GNUNET_SYSERR) | ||
1334 | continue; | ||
1335 | |||
1336 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Updating address for peer `%s' value `%s': %f\n", | ||
1337 | GNUNET_i2s (&address->peer), | ||
1338 | mlp_ats_to_string(mlp->q[c]), | ||
1339 | (double) ats[index].value); | ||
1340 | |||
1341 | int i = mlpi->q_avg_i[c]; | ||
1342 | double * qp = mlpi->q[c]; | ||
1343 | qp[i] = (double) ats[index].value; | ||
1344 | |||
1345 | int t; | ||
1346 | for (t = 0; t < MLP_AVERAGING_QUEUE_LENGTH; t++) | ||
1347 | { | ||
1348 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer `%s': `%s' queue[%u]: %f\n", | ||
1349 | GNUNET_i2s (&address->peer), | ||
1350 | mlp_ats_to_string(mlp->q[c]), | ||
1351 | t, | ||
1352 | qp[t]); | ||
1353 | } | ||
1354 | |||
1355 | if (mlpi->q_avg_i[c] + 1 < (MLP_AVERAGING_QUEUE_LENGTH)) | ||
1356 | mlpi->q_avg_i[c] ++; | ||
1357 | else | ||
1358 | mlpi->q_avg_i[c] = 0; | ||
1359 | |||
1360 | |||
1361 | int c2; | ||
1362 | int c3; | ||
1363 | double avg = 0.0; | ||
1364 | switch (mlp->q[c]) | ||
1365 | { | ||
1366 | case GNUNET_ATS_QUALITY_NET_DELAY: | ||
1367 | c3 = 0; | ||
1368 | for (c2 = 0; c2 < MLP_AVERAGING_QUEUE_LENGTH; c2++) | ||
1369 | { | ||
1370 | if (mlpi->q[c][c2] != -1) | ||
1371 | { | ||
1372 | double * t2 = mlpi->q[c] ; | ||
1373 | avg += t2[c2]; | ||
1374 | c3 ++; | ||
1375 | } | ||
1376 | } | ||
1377 | if (c3 > 0) | ||
1378 | /* avg = 1 / ((q[0] + ... + q[l]) /c3) => c3 / avg*/ | ||
1379 | mlpi->q_averaged[c] = (double) c3 / avg; | ||
1380 | else | ||
1381 | mlpi->q_averaged[c] = 0.0; | ||
1382 | |||
1383 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer `%s': `%s' average sum: %f, average: %f, weight: %f\n", | ||
1384 | GNUNET_i2s (&address->peer), | ||
1385 | mlp_ats_to_string(mlp->q[c]), | ||
1386 | avg, | ||
1387 | avg / (double) c3, | ||
1388 | mlpi->q_averaged[c]); | ||
1389 | |||
1390 | break; | ||
1391 | case GNUNET_ATS_QUALITY_NET_DISTANCE: | ||
1392 | c3 = 0; | ||
1393 | for (c2 = 0; c2 < MLP_AVERAGING_QUEUE_LENGTH; c2++) | ||
1394 | { | ||
1395 | if (mlpi->q[c][c2] != -1) | ||
1396 | { | ||
1397 | double * t2 = mlpi->q[c] ; | ||
1398 | avg += t2[c2]; | ||
1399 | c3 ++; | ||
1400 | } | ||
1401 | } | ||
1402 | if (c3 > 0) | ||
1403 | /* avg = 1 / ((q[0] + ... + q[l]) /c3) => c3 / avg*/ | ||
1404 | mlpi->q_averaged[c] = (double) c3 / avg; | ||
1405 | else | ||
1406 | mlpi->q_averaged[c] = 0.0; | ||
1407 | |||
1408 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer `%s': `%s' average sum: %f, average: %f, weight: %f\n", | ||
1409 | GNUNET_i2s (&address->peer), | ||
1410 | mlp_ats_to_string(mlp->q[c]), | ||
1411 | avg, | ||
1412 | avg / (double) c3, | ||
1413 | mlpi->q_averaged[c]); | ||
1414 | |||
1415 | break; | ||
1416 | default: | ||
1417 | break; | ||
1418 | } | ||
1419 | |||
1420 | if ((mlpi->c_b != 0) && (mlpi->r_q[c] != 0)) | ||
1421 | { | ||
1422 | |||
1423 | /* Get current number of columns */ | ||
1424 | int found = GNUNET_NO; | ||
1425 | int cols = glp_get_num_cols(mlp->prob); | ||
1426 | int *ind = GNUNET_malloc (cols * sizeof (int) + 1); | ||
1427 | double *val = GNUNET_malloc (cols * sizeof (double) + 1); | ||
1428 | |||
1429 | /* Get the matrix row of quality */ | ||
1430 | int length = glp_get_mat_row(mlp->prob, mlp->r_q[c], ind, val); | ||
1431 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "cols %i, length %i c_b %i\n", cols, length, mlpi->c_b); | ||
1432 | int c4; | ||
1433 | /* Get the index if matrix row of quality */ | ||
1434 | for (c4 = 1; c4 <= length; c4++ ) | ||
1435 | { | ||
1436 | if (mlpi->c_b == ind[c4]) | ||
1437 | { | ||
1438 | /* Update the value */ | ||
1439 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Updating quality `%s' column `%s' row `%s' : %f -> %f\n", | ||
1440 | mlp_ats_to_string(mlp->q[c]), | ||
1441 | glp_get_col_name (mlp->prob, ind[c4]), | ||
1442 | glp_get_row_name (mlp->prob, mlp->r_q[c]), | ||
1443 | val[c4], | ||
1444 | mlpi->q_averaged[c]); | ||
1445 | val[c4] = mlpi->q_averaged[c]; | ||
1446 | found = GNUNET_YES; | ||
1447 | break; | ||
1448 | } | ||
1449 | } | ||
1450 | |||
1451 | if (found == GNUNET_NO) | ||
1452 | { | ||
1453 | |||
1454 | ind[length+1] = mlpi->c_b; | ||
1455 | val[length+1] = mlpi->q_averaged[c]; | ||
1456 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "%i ind[%i] val[%i]: %i %f\n", length+1, length+1, length+1, mlpi->c_b, mlpi->q_averaged[c]); | ||
1457 | glp_set_mat_row (mlp->prob, mlpi->r_q[c], length+1, ind, val); | ||
1458 | } | ||
1459 | else | ||
1460 | { | ||
1461 | /* Get the index if matrix row of quality */ | ||
1462 | glp_set_mat_row (mlp->prob, mlpi->r_q[c], length, ind, val); | ||
1463 | } | ||
1464 | |||
1465 | GNUNET_free (ind); | ||
1466 | GNUNET_free (val); | ||
1467 | } | ||
1468 | } | ||
1469 | } | ||
1335 | 1470 | ||
1336 | /** | 1471 | /** |
1337 | * Updates a single address in the MLP problem | 1472 | * Updates a single address in the MLP problem |
@@ -1369,9 +1504,12 @@ GAS_mlp_address_update (struct GAS_MLP_Handle *mlp, struct GNUNET_CONTAINER_Mult | |||
1369 | int c; | 1504 | int c; |
1370 | for (c = 0; c < GNUNET_ATS_QualityPropertiesCount; c++) | 1505 | for (c = 0; c < GNUNET_ATS_QualityPropertiesCount; c++) |
1371 | { | 1506 | { |
1372 | mlpi->c_q[c] = 0; | 1507 | int c2; |
1373 | mlpi->r_q[c] = 0; | 1508 | mlpi->r_q[c] = 0; |
1374 | mlpi->q[c] = 0.0; | 1509 | for (c2 = 0; c2 < MLP_AVERAGING_QUEUE_LENGTH; c2++) |
1510 | mlpi->q[c][c2] = -1.0; /* -1.0: invalid value */ | ||
1511 | mlpi->q_avg_i[c] = 0; | ||
1512 | mlpi->q_averaged[c] = 0.0; | ||
1375 | } | 1513 | } |
1376 | 1514 | ||
1377 | address->mlp_information = mlpi; | 1515 | address->mlp_information = mlpi; |
@@ -1411,80 +1549,22 @@ GAS_mlp_address_update (struct GAS_MLP_Handle *mlp, struct GNUNET_CONTAINER_Mult | |||
1411 | 1549 | ||
1412 | GNUNET_CONTAINER_DLL_insert (peer->head, peer->tail, address); | 1550 | GNUNET_CONTAINER_DLL_insert (peer->head, peer->tail, address); |
1413 | } | 1551 | } |
1552 | |||
1553 | update_quality (mlp, address); | ||
1414 | } | 1554 | } |
1415 | else | 1555 | else |
1416 | { | 1556 | { |
1417 | |||
1418 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Updating existing address to peer `%s'\n", | 1557 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Updating existing address to peer `%s'\n", |
1419 | GNUNET_i2s (&address->peer)); | 1558 | GNUNET_i2s (&address->peer)); |
1420 | 1559 | ||
1421 | mlpi = address->mlp_information; | 1560 | update_quality (mlp, address); |
1422 | int c; | ||
1423 | for (c = 0; c < GNUNET_ATS_QualityPropertiesCount; c++) | ||
1424 | { | ||
1425 | int index = mlp_lookup_ats(address, mlp->q[c]); | ||
1426 | if ((index != GNUNET_SYSERR) && (mlpi->c_q[c] != 0) && (mlpi->r_q[c] != 0)) | ||
1427 | { | ||
1428 | if (mlpi->q[c] == (double) address->ats[index].value) | ||
1429 | break; | ||
1430 | |||
1431 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Updating address for peer `%s' value `%s'from %f to %f\n", | ||
1432 | GNUNET_i2s (&address->peer), | ||
1433 | mlp_ats_to_string(mlp->q[c]), | ||
1434 | mlpi->q[c], | ||
1435 | (double) address->ats[index].value); | ||
1436 | |||
1437 | switch (mlp->q[c]) | ||
1438 | { | ||
1439 | case GNUNET_ATS_QUALITY_NET_DELAY: | ||
1440 | mlpi->q[c] = (double) address->ats[index].value; | ||
1441 | break; | ||
1442 | case GNUNET_ATS_QUALITY_NET_DISTANCE: | ||
1443 | mlpi->q[c] = (double) address->ats[index].value; | ||
1444 | break; | ||
1445 | default: | ||
1446 | break; | ||
1447 | } | ||
1448 | |||
1449 | /* Get current number of columns */ | ||
1450 | int cols = glp_get_num_cols(mlp->prob); | ||
1451 | int *ind = GNUNET_malloc (cols * sizeof (int)); | ||
1452 | double *val = GNUNET_malloc (cols * sizeof (double)); | ||
1453 | |||
1454 | /* Get the matrix row of quality */ | ||
1455 | cols = glp_get_mat_row(mlp->prob, mlp->r_q[c], ind, val); | ||
1456 | |||
1457 | int c2; | ||
1458 | /* Get the index if matrix row of quality */ | ||
1459 | for (c2 = 1; c2 <= cols; c2++ ) | ||
1460 | { | ||
1461 | |||
1462 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Existing element column %i : %f\n", | ||
1463 | ind[c2], val[c2]); | ||
1464 | |||
1465 | if ((mlpi->c_b == ind[c2]) && (val[c2] != mlpi->q[c])) | ||
1466 | { | ||
1467 | /* Update the value */ | ||
1468 | val[c2] = mlpi->q[c]; | ||
1469 | |||
1470 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "New element column %i : %f\n", | ||
1471 | ind[c2], val[c2]); | ||
1472 | |||
1473 | } | ||
1474 | } | ||
1475 | |||
1476 | /* Get the index if matrix row of quality */ | ||
1477 | glp_set_mat_row (mlp->prob, mlpi->r_q[c], cols, ind, val); | ||
1478 | |||
1479 | GNUNET_free (ind); | ||
1480 | GNUNET_free (val); | ||
1481 | } | ||
1482 | } | ||
1483 | } | 1561 | } |
1484 | 1562 | ||
1485 | /* Recalculate */ | 1563 | /* Recalculate */ |
1486 | if (new == GNUNET_YES) | 1564 | if (new == GNUNET_YES) |
1487 | { | 1565 | { |
1566 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Recreating problem: new address\n"); | ||
1567 | |||
1488 | mlp_delete_problem (mlp); | 1568 | mlp_delete_problem (mlp); |
1489 | mlp_create_problem (mlp, addresses); | 1569 | mlp_create_problem (mlp, addresses); |
1490 | mlp->presolver_required = GNUNET_YES; | 1570 | mlp->presolver_required = GNUNET_YES; |
@@ -1536,6 +1616,8 @@ GAS_mlp_address_delete (struct GAS_MLP_Handle *mlp, struct GNUNET_CONTAINER_Mult | |||
1536 | } | 1616 | } |
1537 | 1617 | ||
1538 | /* Update problem */ | 1618 | /* Update problem */ |
1619 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Recreating problem: new address\n"); | ||
1620 | |||
1539 | mlp_delete_problem (mlp); | 1621 | mlp_delete_problem (mlp); |
1540 | if ((GNUNET_CONTAINER_multihashmap_size (addresses) > 0) && (mlp->c_p > 0)) | 1622 | if ((GNUNET_CONTAINER_multihashmap_size (addresses) > 0) && (mlp->c_p > 0)) |
1541 | { | 1623 | { |
diff --git a/src/ats/gnunet-service-ats_addresses_mlp.h b/src/ats/gnunet-service-ats_addresses_mlp.h index 1efcbf0e5..bb20e39df 100644 --- a/src/ats/gnunet-service-ats_addresses_mlp.h +++ b/src/ats/gnunet-service-ats_addresses_mlp.h | |||
@@ -36,6 +36,8 @@ | |||
36 | 36 | ||
37 | #define DEBUG_MLP GNUNET_EXTRA_LOGGING | 37 | #define DEBUG_MLP GNUNET_EXTRA_LOGGING |
38 | 38 | ||
39 | #define MLP_AVERAGING_QUEUE_LENGTH 3 | ||
40 | |||
39 | #define MLP_MAX_EXEC_DURATION GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 3) | 41 | #define MLP_MAX_EXEC_DURATION GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 3) |
40 | #define MLP_MAX_ITERATIONS INT_MAX | 42 | #define MLP_MAX_ITERATIONS INT_MAX |
41 | 43 | ||
@@ -286,11 +288,14 @@ struct MLP_information | |||
286 | /* Quality information row indices */ | 288 | /* Quality information row indices */ |
287 | unsigned int r_q[GNUNET_ATS_QualityPropertiesCount]; | 289 | unsigned int r_q[GNUNET_ATS_QualityPropertiesCount]; |
288 | 290 | ||
289 | /* Quality information column indices */ | ||
290 | unsigned int c_q[GNUNET_ATS_QualityPropertiesCount]; | ||
291 | |||
292 | /* Quality information */ | 291 | /* Quality information */ |
293 | double q[GNUNET_ATS_QualityPropertiesCount]; | 292 | double q[GNUNET_ATS_QualityPropertiesCount][MLP_AVERAGING_QUEUE_LENGTH]; |
293 | |||
294 | /* Quality information averaged */ | ||
295 | double q_averaged[GNUNET_ATS_QualityPropertiesCount]; | ||
296 | |||
297 | /* Averaging index */ | ||
298 | int q_avg_i[GNUNET_ATS_QualityPropertiesCount]; | ||
294 | }; | 299 | }; |
295 | 300 | ||
296 | 301 | ||
diff --git a/src/ats/test_ats_api.conf b/src/ats/test_ats_api.conf index 4d4682c93..fa379c92e 100644 --- a/src/ats/test_ats_api.conf +++ b/src/ats/test_ats_api.conf | |||
@@ -9,6 +9,8 @@ UNIXPATH = /tmp/test-ats-scheduling-arm.sock | |||
9 | [ats] | 9 | [ats] |
10 | #DEBUG = YES | 10 | #DEBUG = YES |
11 | #PREFIX = valgrind --leak-check=full | 11 | #PREFIX = valgrind --leak-check=full |
12 | #WAN_QUOTA_OUT = 4294967295 | ||
13 | #WAN_QUOTA_IN = 4294967295 | ||
12 | AUTOSTART = YES | 14 | AUTOSTART = YES |
13 | PORT = 12002 | 15 | PORT = 12002 |
14 | HOSTNAME = localhost | 16 | HOSTNAME = localhost |
diff --git a/src/ats/test_ats_mlp.c b/src/ats/test_ats_mlp.c index ab8327dd9..bc066fec5 100644 --- a/src/ats/test_ats_mlp.c +++ b/src/ats/test_ats_mlp.c | |||
@@ -94,7 +94,7 @@ check (void *cls, char *const *args, const char *cfgfile, | |||
94 | addr[0].peer.hashPubKey = p[0].hashPubKey; | 94 | addr[0].peer.hashPubKey = p[0].hashPubKey; |
95 | struct GNUNET_ATS_Information a1_ats[3]; | 95 | struct GNUNET_ATS_Information a1_ats[3]; |
96 | set_ats (&a1_ats[0], GNUNET_ATS_QUALITY_NET_DISTANCE, 1); | 96 | set_ats (&a1_ats[0], GNUNET_ATS_QUALITY_NET_DISTANCE, 1); |
97 | set_ats (&a1_ats[1], GNUNET_ATS_QUALITY_NET_DELAY, 2); | 97 | set_ats (&a1_ats[1], GNUNET_ATS_QUALITY_NET_DELAY, 1); |
98 | set_ats (&a1_ats[2], GNUNET_ATS_ARRAY_TERMINATOR, 0); | 98 | set_ats (&a1_ats[2], GNUNET_ATS_ARRAY_TERMINATOR, 0); |
99 | create_address (&addr[0], "dummy", 3, &a1_ats[0]); | 99 | create_address (&addr[0], "dummy", 3, &a1_ats[0]); |
100 | addr[0].atsp_network_type = GNUNET_ATS_NET_WAN; | 100 | addr[0].atsp_network_type = GNUNET_ATS_NET_WAN; |
@@ -102,8 +102,8 @@ check (void *cls, char *const *args, const char *cfgfile, | |||
102 | /* Creating peer 1 address 2 */ | 102 | /* Creating peer 1 address 2 */ |
103 | addr[1].peer.hashPubKey = p[0].hashPubKey; | 103 | addr[1].peer.hashPubKey = p[0].hashPubKey; |
104 | struct GNUNET_ATS_Information a2_ats[3]; | 104 | struct GNUNET_ATS_Information a2_ats[3]; |
105 | set_ats (&a2_ats[0], GNUNET_ATS_QUALITY_NET_DELAY, 32); | ||
106 | set_ats (&a2_ats[1], GNUNET_ATS_QUALITY_NET_DISTANCE, 1); | 105 | set_ats (&a2_ats[1], GNUNET_ATS_QUALITY_NET_DISTANCE, 1); |
106 | set_ats (&a2_ats[0], GNUNET_ATS_QUALITY_NET_DELAY, 1); | ||
107 | set_ats (&a2_ats[2], GNUNET_ATS_ARRAY_TERMINATOR, 0); | 107 | set_ats (&a2_ats[2], GNUNET_ATS_ARRAY_TERMINATOR, 0); |
108 | create_address (&addr[1], "dummy2", 3, &a2_ats[0]); | 108 | create_address (&addr[1], "dummy2", 3, &a2_ats[0]); |
109 | addr[1].atsp_network_type = GNUNET_ATS_NET_LAN; | 109 | addr[1].atsp_network_type = GNUNET_ATS_NET_LAN; |
@@ -111,8 +111,8 @@ check (void *cls, char *const *args, const char *cfgfile, | |||
111 | /* Creating peer 2 address 1 */ | 111 | /* Creating peer 2 address 1 */ |
112 | addr[2].peer.hashPubKey = p[1].hashPubKey; | 112 | addr[2].peer.hashPubKey = p[1].hashPubKey; |
113 | struct GNUNET_ATS_Information a3_ats[3]; | 113 | struct GNUNET_ATS_Information a3_ats[3]; |
114 | set_ats (&a3_ats[0], GNUNET_ATS_QUALITY_NET_DELAY, 32); | ||
115 | set_ats (&a3_ats[1], GNUNET_ATS_QUALITY_NET_DISTANCE, 1); | 114 | set_ats (&a3_ats[1], GNUNET_ATS_QUALITY_NET_DISTANCE, 1); |
115 | set_ats (&a3_ats[0], GNUNET_ATS_QUALITY_NET_DELAY, 1); | ||
116 | set_ats (&a3_ats[2], GNUNET_ATS_ARRAY_TERMINATOR, 0); | 116 | set_ats (&a3_ats[2], GNUNET_ATS_ARRAY_TERMINATOR, 0); |
117 | create_address (&addr[2], "dummy3", 3, &a3_ats[0]); | 117 | create_address (&addr[2], "dummy3", 3, &a3_ats[0]); |
118 | addr[2].atsp_network_type = GNUNET_ATS_NET_LAN; | 118 | addr[2].atsp_network_type = GNUNET_ATS_NET_LAN; |
@@ -126,7 +126,7 @@ check (void *cls, char *const *args, const char *cfgfile, | |||
126 | GNUNET_assert (mlp->addr_in_problem == 1); | 126 | GNUNET_assert (mlp->addr_in_problem == 1); |
127 | 127 | ||
128 | /* Update an peer 1 address 1 */ | 128 | /* Update an peer 1 address 1 */ |
129 | set_ats (&a1_ats[1], GNUNET_ATS_QUALITY_NET_DELAY, 20); | 129 | set_ats (&a1_ats[1], GNUNET_ATS_QUALITY_NET_DELAY, 1); |
130 | GAS_mlp_address_update (mlp, addresses, &addr[0]); | 130 | GAS_mlp_address_update (mlp, addresses, &addr[0]); |
131 | GNUNET_assert (mlp->addr_in_problem == 1); | 131 | GNUNET_assert (mlp->addr_in_problem == 1); |
132 | 132 | ||