aboutsummaryrefslogtreecommitdiff
path: root/src/ats
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2013-08-05 15:02:19 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2013-08-05 15:02:19 +0000
commit9cfe49a9f6c6049245990f958d618de835f04235 (patch)
tree168e923a7ca8d1005052e10237a7cab3e287364b /src/ats
parent8668628b998f2f40e8466d4d6d92faf1617abe08 (diff)
downloadgnunet-9cfe49a9f6c6049245990f958d618de835f04235.tar.gz
gnunet-9cfe49a9f6c6049245990f958d618de835f04235.zip
intermediate commit
Diffstat (limited to 'src/ats')
-rw-r--r--src/ats/Makefile.am8
-rw-r--r--src/ats/perf_ats.c98
2 files changed, 100 insertions, 6 deletions
diff --git a/src/ats/Makefile.am b/src/ats/Makefile.am
index 63593f7c0..1ba7ca75e 100644
--- a/src/ats/Makefile.am
+++ b/src/ats/Makefile.am
@@ -252,15 +252,15 @@ perf_ats_simplistic_bandwidth_SOURCES = \
252 perf_ats.c 252 perf_ats.c
253perf_ats_simplistic_bandwidth_LDADD = \ 253perf_ats_simplistic_bandwidth_LDADD = \
254 $(top_builddir)/src/util/libgnunetutil.la \ 254 $(top_builddir)/src/util/libgnunetutil.la \
255 $(top_builddir)/src/ats/libgnunetats.la \ 255 $(top_builddir)/src/testbed/libgnunettestbed.la \
256 $(top_builddir)/src/testbed/libgnunettestbed.la 256 $(top_builddir)/src/ats/libgnunetats.la
257 257
258perf_ats_simplistic_delay_SOURCES = \ 258perf_ats_simplistic_delay_SOURCES = \
259 perf_ats.c 259 perf_ats.c
260perf_ats_simplistic_delay_LDADD = \ 260perf_ats_simplistic_delay_LDADD = \
261 $(top_builddir)/src/util/libgnunetutil.la \ 261 $(top_builddir)/src/util/libgnunetutil.la \
262 $(top_builddir)/src/ats/libgnunetats.la \ 262 $(top_builddir)/src/testbed/libgnunettestbed.la \
263 $(top_builddir)/src/testbed/libgnunettestbed.la 263 $(top_builddir)/src/ats/libgnunetats.la
264 264
265EXTRA_DIST = \ 265EXTRA_DIST = \
266 ats.h \ 266 ats.h \
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