perf_ats.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  1. /*
  2. This file is part of GNUnet.
  3. Copyright (C) 2010-2013 GNUnet e.V.
  4. GNUnet is free software: you can redistribute it and/or modify it
  5. under the terms of the GNU Affero General Public License as published
  6. by the Free Software Foundation, either version 3 of the License,
  7. or (at your 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. Affero General Public License for more details.
  12. You should have received a copy of the GNU Affero General Public License
  13. along with this program. If not, see <http://www.gnu.org/licenses/>.
  14. SPDX-License-Identifier: AGPL3.0-or-later
  15. */
  16. /**
  17. * @file ats/perf_ats.c
  18. * @brief ats benchmark: start peers and modify preferences, monitor change over time
  19. * @author Christian Grothoff
  20. * @author Matthias Wachs
  21. */
  22. #include "platform.h"
  23. #include "gnunet_util_lib.h"
  24. #include "gnunet_testbed_service.h"
  25. #include "gnunet_ats_service.h"
  26. #include "gnunet_core_service.h"
  27. #include "ats-testing.h"
  28. #define TEST_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 120)
  29. #define BENCHMARK_DURATION GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10)
  30. #define LOGGING_FREQUENCY GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 500)
  31. #define TESTNAME_PREFIX "perf_ats_"
  32. #define DEFAULT_SLAVES_NUM 2
  33. #define DEFAULT_MASTERS_NUM 1
  34. #define TEST_ATS_PREFRENCE_FREQUENCY GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1)
  35. #define TEST_ATS_PREFRENCE_START 1.0
  36. #define TEST_ATS_PREFRENCE_DELTA 1.0
  37. #define TEST_MESSAGE_TYPE_PING 12345
  38. #define TEST_MESSAGE_TYPE_PONG 12346
  39. #define TEST_MESSAGE_SIZE 1000
  40. #define TEST_MESSAGE_FREQUENCY GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1)
  41. /**
  42. * Information about a benchmarking partner
  43. */
  44. struct BenchmarkPartner
  45. {
  46. /**
  47. * The peer itself this partner belongs to
  48. */
  49. struct BenchmarkPeer *me;
  50. /**
  51. * The partner peer
  52. */
  53. struct BenchmarkPeer *dest;
  54. /**
  55. * Core transmit handles
  56. */
  57. struct GNUNET_CORE_TransmitHandle *cth;
  58. /**
  59. * Transport transmit handles
  60. */
  61. struct GNUNET_TRANSPORT_TransmitHandle *tth;
  62. /**
  63. * Timestamp to calculate communication layer delay
  64. */
  65. struct GNUNET_TIME_Absolute last_message_sent;
  66. /**
  67. * Accumulated RTT for all messages
  68. */
  69. unsigned int total_app_rtt;
  70. /**
  71. * Number of messages sent to this partner
  72. */
  73. unsigned int messages_sent;
  74. /**
  75. * Number of bytes sent to this partner
  76. */
  77. unsigned int bytes_sent;
  78. /**
  79. * Number of messages received from this partner
  80. */
  81. unsigned int messages_received;
  82. /**
  83. * Number of bytes received from this partner
  84. */
  85. unsigned int bytes_received;
  86. /* Current ATS properties */
  87. uint32_t ats_distance;
  88. uint32_t ats_delay;
  89. uint32_t bandwidth_in;
  90. uint32_t bandwidth_out;
  91. uint32_t ats_utilization_up;
  92. uint32_t ats_utilization_down;
  93. uint32_t ats_network_type;
  94. uint32_t ats_cost_wan;
  95. uint32_t ats_cost_lan;
  96. uint32_t ats_cost_wlan;
  97. };
  98. /**
  99. * Information we track for a peer in the testbed.
  100. */
  101. struct BenchmarkPeer
  102. {
  103. /**
  104. * Handle with testbed.
  105. */
  106. struct GNUNET_TESTBED_Peer *peer;
  107. /**
  108. * Unique identifier
  109. */
  110. int no;
  111. /**
  112. * Is this peer a measter: GNUNET_YES/GNUNET_NO
  113. */
  114. int master;
  115. /**
  116. * Peer ID
  117. */
  118. struct GNUNET_PeerIdentity id;
  119. /**
  120. * Testbed operation to get peer information
  121. */
  122. struct GNUNET_TESTBED_Operation *peer_id_op;
  123. /**
  124. * Testbed operation to connect to ATS performance service
  125. */
  126. struct GNUNET_TESTBED_Operation *ats_perf_op;
  127. /**
  128. * Testbed operation to connect to core
  129. */
  130. struct GNUNET_TESTBED_Operation *comm_op;
  131. /**
  132. * ATS performance handle
  133. */
  134. struct GNUNET_ATS_PerformanceHandle *ats_perf_handle;
  135. /**
  136. * Masters only:
  137. * Testbed connect operations to connect masters to slaves
  138. */
  139. struct TestbedConnectOperation *core_connect_ops;
  140. /**
  141. * Core handle
  142. */
  143. struct GNUNET_CORE_Handle *ch;
  144. /**
  145. * Core handle
  146. */
  147. struct GNUNET_TRANSPORT_Handle *th;
  148. /**
  149. * Masters only:
  150. * Peer to set ATS preferences for
  151. */
  152. struct BenchmarkPeer *pref_partner;
  153. /**
  154. * Masters only
  155. * Progress task
  156. */
  157. struct GNUNET_SCHEDULER_Task * ats_task;
  158. /**
  159. * Masters only
  160. * Progress task
  161. */
  162. double pref_value;
  163. /**
  164. * Array of partners with num_slaves entries (if master) or
  165. * num_master entries (if slave)
  166. */
  167. struct BenchmarkPartner *partners;
  168. /**
  169. * Number of partners
  170. */
  171. int num_partners;
  172. /**
  173. * Number of core connections
  174. */
  175. int core_connections;
  176. /**
  177. * Masters only:
  178. * Number of connections to slave peers
  179. */
  180. int core_slave_connections;
  181. /**
  182. * Total number of messages this peer has sent
  183. */
  184. unsigned int total_messages_sent;
  185. /**
  186. * Total number of bytes this peer has sent
  187. */
  188. unsigned int total_bytes_sent;
  189. /**
  190. * Total number of messages this peer has received
  191. */
  192. unsigned int total_messages_received;
  193. /**
  194. * Total number of bytes this peer has received
  195. */
  196. unsigned int total_bytes_received;
  197. };
  198. /* end of file perf_ats.h */