aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2014-02-11 10:44:24 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2014-02-11 10:44:24 +0000
commit83fecbfc0feddabc908125bde4434907fbe1c1f6 (patch)
treeb8a6ca55df36294dda7a29de9ebf05802fef1938 /src
parentfaa12c86edbe689bf73a8dd51b4d4cb49ef0493c (diff)
downloadgnunet-83fecbfc0feddabc908125bde4434907fbe1c1f6.tar.gz
gnunet-83fecbfc0feddabc908125bde4434907fbe1c1f6.zip
address management
Diffstat (limited to 'src')
-rw-r--r--src/ats/gnunet-ats-solver-eval.c224
1 files changed, 27 insertions, 197 deletions
diff --git a/src/ats/gnunet-ats-solver-eval.c b/src/ats/gnunet-ats-solver-eval.c
index 571c2930b..64480ada1 100644
--- a/src/ats/gnunet-ats-solver-eval.c
+++ b/src/ats/gnunet-ats-solver-eval.c
@@ -1458,202 +1458,6 @@ load_episode (struct Experiment *e, struct Episode *cur,
1458 op_counter++; 1458 op_counter++;
1459 } 1459 }
1460 GNUNET_free (sec_name); 1460 GNUNET_free (sec_name);
1461
1462
1463#if 0
1464 /* Get source */
1465 GNUNET_asprintf(&op_name, "op-%u-src", op_counter);
1466 if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (cfg,
1467 sec_name, op_name, &o->src_id))
1468 {
1469 fprintf (stderr, "Missing src in operation %u `%s' in episode %u\n",
1470 op_counter, op, cur->id);
1471 GNUNET_free (op);
1472 GNUNET_free (op_name);
1473 return GNUNET_SYSERR;
1474 }
1475 if (o->src_id > (e->num_masters - 1))
1476 {
1477 fprintf (stderr, "Invalid src %llu in operation %u `%s' in episode %u\n",
1478 o->src_id, op_counter, op, cur->id);
1479 GNUNET_free (op);
1480 GNUNET_free (op_name);
1481 return GNUNET_SYSERR;
1482 }
1483 GNUNET_free (op_name);
1484
1485 /* Get destination */
1486 GNUNET_asprintf(&op_name, "op-%u-dest", op_counter);
1487 if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (cfg,
1488 sec_name, op_name, &o->dest_id))
1489 {
1490 fprintf (stderr, "Missing src in operation %u `%s' in episode %u\n",
1491 op_counter, op, cur->id);
1492 GNUNET_free (op);
1493 GNUNET_free (op_name);
1494 return GNUNET_SYSERR;
1495 }
1496 if (o->dest_id > (e->num_slaves - 1))
1497 {
1498 fprintf (stderr, "Invalid destination %llu in operation %u `%s' in episode %u\n",
1499 o->dest_id, op_counter, op, cur->id);
1500 GNUNET_free (op);
1501 GNUNET_free (op_name);
1502 return GNUNET_SYSERR;
1503 }
1504 GNUNET_free (op_name);
1505
1506 GNUNET_asprintf(&op_name, "op-%u-type", op_counter);
1507 if ( (GNUNET_SYSERR != GNUNET_CONFIGURATION_get_value_string(cfg,
1508 sec_name, op_name, &type)) &&
1509 ((STOP_SEND != o->type) || (STOP_PREFERENCE != o->type)))
1510 {
1511 /* Load arguments for set_rate, start_send, set_preference */
1512 if (0 == strcmp (type, "constant"))
1513 {
1514 o->gen_type = GNUNET_ATS_TEST_TG_CONSTANT;
1515 }
1516 else if (0 == strcmp (type, "linear"))
1517 {
1518 o->gen_type = GNUNET_ATS_TEST_TG_LINEAR;
1519 }
1520 else if (0 == strcmp (type, "sinus"))
1521 {
1522 o->gen_type = GNUNET_ATS_TEST_TG_SINUS;
1523 }
1524 else if (0 == strcmp (type, "random"))
1525 {
1526 o->gen_type = GNUNET_ATS_TEST_TG_RANDOM;
1527 }
1528 else
1529 {
1530 fprintf (stderr, "Invalid type %u `%s' in episode %u\n",
1531 op_counter, op, cur->id);
1532 GNUNET_free (type);
1533 GNUNET_free (op);
1534 GNUNET_free (op_name);
1535 return GNUNET_SYSERR;
1536 }
1537 GNUNET_free (op_name);
1538
1539 /* Get base rate */
1540 GNUNET_asprintf(&op_name, "op-%u-base-rate", op_counter);
1541 if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (cfg,
1542 sec_name, op_name, &o->base_rate))
1543 {
1544 fprintf (stderr, "Missing base rate in operation %u `%s' in episode %u\n",
1545 op_counter, op, cur->id);
1546 GNUNET_free (type);
1547 GNUNET_free (op);
1548 GNUNET_free (op_name);
1549 return GNUNET_SYSERR;
1550 }
1551 GNUNET_free (op_name);
1552
1553 /* Get max rate */
1554 GNUNET_asprintf(&op_name, "op-%u-max-rate", op_counter);
1555 if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (cfg,
1556 sec_name, op_name, &o->max_rate))
1557 {
1558 if ((GNUNET_ATS_TEST_TG_LINEAR == o->gen_type) ||
1559 (GNUNET_ATS_TEST_TG_RANDOM == o->gen_type) ||
1560 (GNUNET_ATS_TEST_TG_SINUS == o->gen_type))
1561 {
1562 fprintf (stderr, "Missing max rate in operation %u `%s' in episode %u\n",
1563 op_counter, op, cur->id);
1564 GNUNET_free (type);
1565 GNUNET_free (op_name);
1566 GNUNET_free (op);
1567 return GNUNET_SYSERR;
1568 }
1569 }
1570 GNUNET_free (op_name);
1571
1572 /* Get period */
1573 GNUNET_asprintf(&op_name, "op-%u-period", op_counter);
1574 if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_time (cfg,
1575 sec_name, op_name, &o->period))
1576 {
1577 o->period = cur->duration;
1578 }
1579 GNUNET_free (op_name);
1580
1581 if (START_PREFERENCE == o->type)
1582 {
1583 /* Get frequency */
1584 GNUNET_asprintf(&op_name, "op-%u-frequency", op_counter);
1585 if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_time (cfg,
1586 sec_name, op_name, &o->frequency))
1587 {
1588 fprintf (stderr, "Missing frequency in operation %u `%s' in episode %u\n",
1589 op_counter, op, cur->id);
1590 GNUNET_free (type);
1591 GNUNET_free (op_name);
1592 GNUNET_free (op);
1593 return GNUNET_SYSERR;
1594 }
1595 GNUNET_free (op_name);
1596
1597 /* Get preference */
1598 GNUNET_asprintf(&op_name, "op-%u-pref", op_counter);
1599 if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_string (cfg,
1600 sec_name, op_name, &pref))
1601 {
1602 fprintf (stderr, "Missing preference in operation %u `%s' in episode %u\n",
1603 op_counter, op, cur->id);
1604 GNUNET_free (type);
1605 GNUNET_free (op_name);
1606 GNUNET_free (op);
1607 GNUNET_free_non_null (pref);
1608 return GNUNET_SYSERR;
1609 }
1610
1611 if (0 == strcmp(pref, "bandwidth"))
1612 o->pref_type = GNUNET_ATS_PREFERENCE_BANDWIDTH;
1613 else if (0 == strcmp(pref, "latency"))
1614 o->pref_type = GNUNET_ATS_PREFERENCE_LATENCY;
1615 else
1616 {
1617 fprintf (stderr, "Invalid preference in operation %u `%s' in episode %u\n",
1618 op_counter, op, cur->id);
1619 GNUNET_free (type);
1620 GNUNET_free (op_name);
1621 GNUNET_free (op);
1622 GNUNET_free (pref);
1623 GNUNET_free_non_null (pref);
1624 return GNUNET_SYSERR;
1625 }
1626 GNUNET_free (pref);
1627 GNUNET_free (op_name);
1628 }
1629 }
1630
1631 /* Safety checks */
1632 if ((GNUNET_ATS_TEST_TG_LINEAR == o->gen_type) ||
1633 (GNUNET_ATS_TEST_TG_SINUS == o->gen_type))
1634 {
1635 if ((o->max_rate - o->base_rate) > o->base_rate)
1636 {
1637 /* This will cause an underflow */
1638 GNUNET_break (0);
1639 }
1640 fprintf (stderr, "Selected max rate and base rate cannot be used for desired traffic form!\n");
1641 }
1642
1643 if ((START_SEND == o->type) || (START_PREFERENCE == o->type))
1644 fprintf (stderr, "Found operation %u in episode %u: %s [%llu]->[%llu] == %s, %llu -> %llu in %s\n",
1645 op_counter, cur->id, print_op (o->type), o->src_id,
1646 o->dest_id, (NULL != type) ? type : "",
1647 o->base_rate, o->max_rate,
1648 GNUNET_STRINGS_relative_time_to_string (o->period, GNUNET_YES));
1649 else
1650 fprintf (stderr, "Found operation %u in episode %u: %s [%llu]->[%llu]\n",
1651 op_counter, cur->id, print_op (o->type), o->src_id, o->dest_id);
1652
1653 GNUNET_free_non_null (type);
1654 GNUNET_free (op);
1655#endif
1656
1657 return GNUNET_OK; 1461 return GNUNET_OK;
1658} 1462}
1659 1463
@@ -1841,6 +1645,8 @@ enforce_del_address (struct GNUNET_ATS_TEST_Operation *op)
1841 op->address_id, op->peer_id); 1645 op->address_id, op->peer_id);
1842 1646
1843 sh->env.sf.s_del (sh->solver, ctx.res, GNUNET_NO); 1647 sh->env.sf.s_del (sh->solver, ctx.res, GNUNET_NO);
1648 GNUNET_free (ctx.res);
1649
1844} 1650}
1845 1651
1846static void 1652static void
@@ -2202,7 +2008,6 @@ GNUNET_ATS_solvers_solver_stop (struct SolverHandle *sh)
2202{ 2008{
2203 GNUNET_STATISTICS_destroy ((struct GNUNET_STATISTICS_Handle *) sh->env.stats, 2009 GNUNET_STATISTICS_destroy ((struct GNUNET_STATISTICS_Handle *) sh->env.stats,
2204 GNUNET_NO); 2010 GNUNET_NO);
2205 GNUNET_CONTAINER_multipeermap_destroy(sh->env.addresses);
2206 GNUNET_PLUGIN_unload (sh->plugin, sh->solver); 2011 GNUNET_PLUGIN_unload (sh->plugin, sh->solver);
2207 GNUNET_CONTAINER_multipeermap_destroy(sh->addresses); 2012 GNUNET_CONTAINER_multipeermap_destroy(sh->addresses);
2208 GNUNET_free (sh->plugin); 2013 GNUNET_free (sh->plugin);
@@ -2518,11 +2323,26 @@ GNUNET_ATS_solvers_solver_start (enum GNUNET_ATS_Solvers type)
2518 return sh; 2323 return sh;
2519} 2324}
2520 2325
2326static int
2327free_all_it (void *cls,
2328 const struct GNUNET_PeerIdentity *key,
2329 void *value)
2330{
2331 struct ATS_Address *address = value;
2332 GNUNET_CONTAINER_multipeermap_remove (sh->env.addresses, key, value);
2333 GNUNET_free (address);
2334
2335 return GNUNET_OK;
2336}
2337
2521static void 2338static void
2522done () 2339done ()
2523{ 2340{
2341 struct TestPeer *cur;
2342 struct TestPeer *next;
2524 /* Clean up experiment */ 2343 /* Clean up experiment */
2525 GNUNET_ATS_solver_generate_preferences_stop_all (); 2344 GNUNET_ATS_solver_generate_preferences_stop_all ();
2345 GNUNET_ATS_solver_generate_property_stop_all ();
2526 2346
2527 if (NULL != e) 2347 if (NULL != e)
2528 { 2348 {
@@ -2536,6 +2356,16 @@ done ()
2536 l = NULL; 2356 l = NULL;
2537 } 2357 }
2538 2358
2359 next = peer_head;
2360 while (NULL != (cur = next))
2361 {
2362 next = cur->next;
2363 GNUNET_CONTAINER_DLL_remove (peer_head, peer_tail, cur);
2364 GNUNET_break (0);
2365 GNUNET_CONTAINER_multipeermap_iterate (sh->env.addresses, &free_all_it, NULL);
2366
2367 GNUNET_free (cur);
2368 }
2539 /* Shutdown */ 2369 /* Shutdown */
2540 end_now(); 2370 end_now();
2541 2371