aboutsummaryrefslogtreecommitdiff
path: root/src/ats/perf_ats.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ats/perf_ats.c')
-rw-r--r--src/ats/perf_ats.c98
1 files changed, 96 insertions, 2 deletions
diff --git a/src/ats/perf_ats.c b/src/ats/perf_ats.c
index c131025bd..2f1830381 100644
--- a/src/ats/perf_ats.c
+++ b/src/ats/perf_ats.c
@@ -26,9 +26,34 @@
26#include "platform.h" 26#include "platform.h"
27#include "gnunet_util_lib.h" 27#include "gnunet_util_lib.h"
28#include "gnunet_testbed_service.h" 28#include "gnunet_testbed_service.h"
29#include "gnunet_ats_service.h"
29 30
30#define TEST_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5) 31#define TEST_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5)
31#define TESTNAME_PREFIX "perf_ats_" 32#define TESTNAME_PREFIX "perf_ats_"
33#define NUM_PEERS 4 /* At least 2 */
34
35/**
36 * Information we track for a peer in the testbed.
37 */
38struct BenchmarkPeer
39{
40 /**
41 * Handle with testbed.
42 */
43 struct GNUNET_TESTBED_Peer *daemon;
44
45 /**
46 * Testbed operation to connect to statistics service
47 */
48 struct GNUNET_TESTBED_Operation *stat_op;
49
50 struct GNUNET_ATS_PerformanceHandle *p_handle;
51 struct GNUNET_ATS_SchedulingHandle *s_handle;
52
53};
54
55struct BenchmarkPeer ph[NUM_PEERS];
56
32 57
33 58
34/** 59/**
@@ -70,6 +95,54 @@ controller_event_cb (void *cls,
70 95
71} 96}
72 97
98static void
99ats_performance_info_cb (void *cls,
100 const struct GNUNET_HELLO_Address *address,
101 int address_active,
102 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out,
103 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in,
104 const struct GNUNET_ATS_Information *ats,
105 uint32_t ats_count)
106{
107
108}
109
110/**
111 * Called to open a connection to the peer's ATS performance
112 *
113 * @param cls peer context
114 * @param cfg configuration of the peer to connect to; will be available until
115 * GNUNET_TESTBED_operation_done() is called on the operation returned
116 * from GNUNET_TESTBED_service_connect()
117 * @return service handle to return in 'op_result', NULL on error
118 */
119static void *
120ats_perf_connect_adapter (void *cls,
121 const struct GNUNET_CONFIGURATION_Handle *cfg)
122{
123 struct BenchmarkPeer *peer = cls;
124 peer->p_handle = GNUNET_ATS_performance_init (cfg, &ats_performance_info_cb, peer);
125 if (NULL == peer->p_handle)
126 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to create ATS performance handle \n");
127 return peer->p_handle;
128}
129
130/**
131 * Called to disconnect from peer's statistics service
132 *
133 * @param cls peer context
134 * @param op_result service handle returned from the connect adapter
135 */
136static void
137ats_perf_disconnect_adapter (void *cls, void *op_result)
138{
139 struct BenchmarkPeer *peer = cls;
140
141 GNUNET_ATS_performance_done(peer->p_handle);
142 peer->p_handle = NULL;
143}
144
145
73/** 146/**
74 * Signature of a main function for a testcase. 147 * Signature of a main function for a testcase.
75 * 148 *
@@ -87,9 +160,30 @@ test_master (void *cls, unsigned int num_peers,
87 unsigned int links_succeeded, 160 unsigned int links_succeeded,
88 unsigned int links_failed) 161 unsigned int links_failed)
89{ 162{
90 GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Benchmarking solver `%s' on preference `%s'\n"), solver, preference); 163 int c_p;
164 GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Benchmarking solver `%s' on preference `%s'\n"), solver, preference);
91 165
92 shutdown_task = GNUNET_SCHEDULER_add_delayed (TEST_TIMEOUT, &do_shutdown, NULL); 166 shutdown_task = GNUNET_SCHEDULER_add_delayed (TEST_TIMEOUT, &do_shutdown, NULL);
167
168 GNUNET_assert (NULL == cls);
169 GNUNET_assert (NUM_PEERS == num_peers);
170 GNUNET_assert (NULL != peers_);
171
172 for (c_p = 0; c_p < num_peers; c_p++)
173 {
174 GNUNET_assert (NULL != peers_[c_p]);
175 /* Connect to ATS service */
176 /*
177 ph[c_p].stat_op = GNUNET_TESTBED_service_connect (NULL,
178 peers_[c_p], "ats",
179 NULL, &ph[c_p],
180 &ats_perf_connect_adapter,
181 &ats_perf_disconnect_adapter,
182 &ph[c_p]);
183 */
184 }
185
186
93} 187}
94 188
95 189
@@ -132,7 +226,7 @@ main (int argc, char *argv[])
132 event_mask |= (1LL << GNUNET_TESTBED_ET_CONNECT); 226 event_mask |= (1LL << GNUNET_TESTBED_ET_CONNECT);
133 event_mask |= (1LL << GNUNET_TESTBED_ET_OPERATION_FINISHED); 227 event_mask |= (1LL << GNUNET_TESTBED_ET_OPERATION_FINISHED);
134 (void) GNUNET_TESTBED_test_run (test_name, 228 (void) GNUNET_TESTBED_test_run (test_name,
135 conf_name, 5, 229 conf_name, NUM_PEERS,
136 event_mask, &controller_event_cb, NULL, 230 event_mask, &controller_event_cb, NULL,
137 &test_master, NULL); 231 &test_master, NULL);
138 232