testbed_api_topology.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. /*
  2. This file is part of GNUnet
  3. (C) 2008--2013 Christian Grothoff (and other contributing authors)
  4. GNUnet is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published
  6. by the Free Software Foundation; either version 3, or (at your
  7. option) any later version.
  8. GNUnet is distributed in the hope that it will be useful, but
  9. WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with GNUnet; see the file COPYING. If not, write to the
  14. Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  15. Boston, MA 02111-1307, USA.
  16. */
  17. /**
  18. * @file testbed/testbed_api_topology.h
  19. * @brief header for intra library exported functions
  20. * @author Sree Harsha Totakura <sreeharsha@totakura.in>
  21. */
  22. #ifndef TESTBED_API_TOPOLOGY_H
  23. #define TESTBED_API_TOPOLOGY_H
  24. /**
  25. * Returns the number of links that are required to generate a 2d torus for the
  26. * given number of peers. Also returns the arrangment (number of rows and the
  27. * length of each row)
  28. *
  29. * @param num_peers number of peers
  30. * @param rows number of rows in the 2d torus. Can be NULL.
  31. * @param rows_len the length of each row. This array will be allocated
  32. * fresh. The caller should free it. Can be NULL.
  33. */
  34. unsigned int
  35. GNUNET_TESTBED_2dtorus_calc_links (unsigned int num_peers, unsigned int *rows,
  36. unsigned int **rows_len);
  37. /**
  38. * Get a topology from a string input.
  39. *
  40. * @param topology where to write the retrieved topology
  41. * @param topology_string The string to attempt to
  42. * get a configuration value from
  43. * @return GNUNET_YES if topology string matched a
  44. * known topology, GNUNET_NO if not
  45. */
  46. int
  47. GNUNET_TESTBED_topology_get_ (enum GNUNET_TESTBED_TopologyOption *topology,
  48. const char *topology_string);
  49. /**
  50. * Returns the string corresponding to the given topology
  51. *
  52. * @param topology the topology
  53. * @return the string (freshly allocated) of given topology; NULL if topology cannot be
  54. * expressed as a string
  55. */
  56. char *
  57. GNUNET_TESTBED_topology_to_str_ (enum GNUNET_TESTBED_TopologyOption topology);
  58. /**
  59. * Functions of this type are called to process underlay link
  60. *
  61. * @param cls closure
  62. * @param A offset of first peer
  63. * @param B offset of second peer
  64. * @param bandwidth the bandwidth of the link in bytes per second
  65. * @param latency the latency of link in milliseconds
  66. * @param loss the percentage of messages dropped on the link
  67. * @return GNUNET_OK to continue processing; GNUNET_SYSERR to abort
  68. */
  69. typedef int (*underlay_link_processor) (void *cls,
  70. unsigned int A,
  71. unsigned int B,
  72. unsigned int bandwidth,
  73. unsigned int latency,
  74. unsigned int loss);
  75. /**
  76. * Function to construct an underlay topology
  77. *
  78. * @param num_peers the number of peers for which the topology should be
  79. * generated
  80. * @param proc the underlay link processor callback. Will be called for each
  81. * underlay link generated unless a previous call to this callback
  82. * returned GNUNET_SYSERR. Cannot be NULL.
  83. * @param cls closure for proc
  84. * @param ... variable arguments denoting the topology and its parameters. They
  85. * should start with the type of topology to generate followed by their
  86. * options. These arguments should *always* end with
  87. * GNUNET_TESTBED_TOPOLOGY_OPTION_END option
  88. * @return GNUNET_OK if underlay link generation is successful; GNUNET_SYSERR
  89. * upon error in generating the underlay or if any calls to the
  90. * underlay link processor returned GNUNET_SYSERR
  91. */
  92. int
  93. GNUNET_TESTBED_underlay_construct_ (int num_peers,
  94. underlay_link_processor proc,
  95. void *cls,
  96. ...);
  97. #endif
  98. /* end of testbed_api_topology.h */