diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2013-03-20 12:37:31 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2013-03-20 12:37:31 +0000 |
commit | a73cfc7583145f6733b196763f9bfe8a24985185 (patch) | |
tree | 8b04c78b8a1463ad124946b4a91997a74b9a327f /src/ats | |
parent | 22c8a602e7ac8591652231b829cb324a13035f7c (diff) | |
download | gnunet-a73cfc7583145f6733b196763f9bfe8a24985185.tar.gz gnunet-a73cfc7583145f6733b196763f9bfe8a24985185.zip |
test
Diffstat (limited to 'src/ats')
-rw-r--r-- | src/ats/ats_api_performance.c | 11 | ||||
-rw-r--r-- | src/ats/gnunet-service-ats_performance.c | 6 | ||||
-rw-r--r-- | src/ats/test_ats_api_performance_monitor.c | 110 |
3 files changed, 113 insertions, 14 deletions
diff --git a/src/ats/ats_api_performance.c b/src/ats/ats_api_performance.c index 34f3a232e..038a349aa 100644 --- a/src/ats/ats_api_performance.c +++ b/src/ats/ats_api_performance.c | |||
@@ -607,12 +607,13 @@ process_mr_message (struct GNUNET_ATS_PerformanceHandle *ph, | |||
607 | if (id == cur->id) | 607 | if (id == cur->id) |
608 | break; | 608 | break; |
609 | } | 609 | } |
610 | 610 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | |
611 | _("Received %s message for id %u\n"), "ATS_MONITOR_RESPONSE", id); | ||
611 | if (NULL == cur) | 612 | if (NULL == cur) |
612 | { | 613 | { |
613 | GNUNET_break (0); | 614 | GNUNET_break (0); |
614 | return GNUNET_SYSERR; | 615 | return GNUNET_SYSERR; |
615 | } | 616 | } |
616 | 617 | ||
617 | ats = (struct GNUNET_ATS_Information *) &mrm[1]; | 618 | ats = (struct GNUNET_ATS_Information *) &mrm[1]; |
618 | cur->moncb (cur->moncb_cls, &mrm->peer, ats, ats_count); | 619 | cur->moncb (cur->moncb_cls, &mrm->peer, ats, ats_count); |
diff --git a/src/ats/gnunet-service-ats_performance.c b/src/ats/gnunet-service-ats_performance.c index cbbed1967..3be0bf0bf 100644 --- a/src/ats/gnunet-service-ats_performance.c +++ b/src/ats/gnunet-service-ats_performance.c | |||
@@ -542,13 +542,13 @@ GAS_handle_performance_update (struct GNUNET_PeerIdentity *peer, | |||
542 | mrm->header.size = htons (msglen); | 542 | mrm->header.size = htons (msglen); |
543 | mrm->ats_count = htonl (ats_count); | 543 | mrm->ats_count = htonl (ats_count); |
544 | mrm->peer = *peer; | 544 | mrm->peer = *peer; |
545 | memcpy (&mrm[1], ats, sizeof (struct GNUNET_ATS_Information)); | 545 | memcpy (&mrm[1], ats, ats_count * sizeof (struct GNUNET_ATS_Information)); |
546 | 546 | ||
547 | for (cur = pc_head; NULL != cur; cur = cur->next) | 547 | for (cur = pc_head; NULL != cur; cur = cur->next) |
548 | for (curm = cur->pm_head; NULL != curm; curm = curm->next) | 548 | for (curm = cur->pm_head; NULL != curm; curm = curm->next) |
549 | { | 549 | { |
550 | /* Notify client about update */ | 550 | /* Notify client about update */ |
551 | mrm->id = curm->id; | 551 | mrm->id = htonl (curm->id); |
552 | GNUNET_SERVER_notification_context_unicast (nc, | 552 | GNUNET_SERVER_notification_context_unicast (nc, |
553 | cur->client, | 553 | cur->client, |
554 | (struct GNUNET_MessageHeader *) mrm, | 554 | (struct GNUNET_MessageHeader *) mrm, |
@@ -586,7 +586,7 @@ mon_peerinfo_it (void *cls, | |||
586 | mrm->id = htonl(pmc->id); | 586 | mrm->id = htonl(pmc->id); |
587 | mrm->ats_count = htonl (atsi_count); | 587 | mrm->ats_count = htonl (atsi_count); |
588 | mrm->peer = *id; | 588 | mrm->peer = *id; |
589 | memcpy (&mrm[1], atsi, sizeof (struct GNUNET_ATS_Information)); | 589 | memcpy (&mrm[1], atsi, atsi_count * sizeof (struct GNUNET_ATS_Information)); |
590 | 590 | ||
591 | /* Send initial information about peers to client */ | 591 | /* Send initial information about peers to client */ |
592 | 592 | ||
diff --git a/src/ats/test_ats_api_performance_monitor.c b/src/ats/test_ats_api_performance_monitor.c index 32ec27db8..bfb2a1161 100644 --- a/src/ats/test_ats_api_performance_monitor.c +++ b/src/ats/test_ats_api_performance_monitor.c | |||
@@ -31,6 +31,8 @@ | |||
31 | #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 20) | 31 | #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 20) |
32 | #define SHUTDOWN_CORRECT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5) | 32 | #define SHUTDOWN_CORRECT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5) |
33 | 33 | ||
34 | #define ATS_COUNT 3 | ||
35 | |||
34 | static GNUNET_SCHEDULER_TaskIdentifier die_task; | 36 | static GNUNET_SCHEDULER_TaskIdentifier die_task; |
35 | static GNUNET_SCHEDULER_TaskIdentifier stage_task; | 37 | static GNUNET_SCHEDULER_TaskIdentifier stage_task; |
36 | 38 | ||
@@ -44,7 +46,7 @@ static struct GNUNET_ATS_PerformanceMonitorHandle *phm; | |||
44 | 46 | ||
45 | static struct GNUNET_HELLO_Address addr; | 47 | static struct GNUNET_HELLO_Address addr; |
46 | 48 | ||
47 | static struct GNUNET_ATS_Information atsi[3]; | 49 | static struct GNUNET_ATS_Information atsi[ATS_COUNT]; |
48 | 50 | ||
49 | static int ret; | 51 | static int ret; |
50 | 52 | ||
@@ -68,7 +70,7 @@ static void setup_addresses () | |||
68 | atsi[2].type = htonl(GNUNET_ATS_QUALITY_NET_DISTANCE); | 70 | atsi[2].type = htonl(GNUNET_ATS_QUALITY_NET_DISTANCE); |
69 | atsi[2].value = htonl(5); | 71 | atsi[2].value = htonl(5); |
70 | 72 | ||
71 | GNUNET_ATS_address_add (sh, &addr, NULL, atsi, 3); | 73 | GNUNET_ATS_address_add (sh, &addr, NULL, atsi, ATS_COUNT); |
72 | } | 74 | } |
73 | 75 | ||
74 | 76 | ||
@@ -125,7 +127,7 @@ next_stage (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
125 | stage_task = GNUNET_SCHEDULER_NO_TASK; | 127 | stage_task = GNUNET_SCHEDULER_NO_TASK; |
126 | if (0 == stage_counter) | 128 | if (0 == stage_counter) |
127 | { | 129 | { |
128 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Stop performance monitoring\n"); | 130 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stop performance monitoring\n"); |
129 | 131 | ||
130 | GNUNET_ATS_performance_monitor_stop (phm); | 132 | GNUNET_ATS_performance_monitor_stop (phm); |
131 | phm = NULL; | 133 | phm = NULL; |
@@ -140,7 +142,11 @@ next_stage (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
140 | } | 142 | } |
141 | } | 143 | } |
142 | 144 | ||
143 | 145 | static void end (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |
146 | { | ||
147 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Success\n"); | ||
148 | end_now (1); | ||
149 | } | ||
144 | 150 | ||
145 | 151 | ||
146 | static void | 152 | static void |
@@ -150,14 +156,106 @@ perf_mon_cb (void *cls, | |||
150 | uint32_t ats_count) | 156 | uint32_t ats_count) |
151 | { | 157 | { |
152 | static int stage_counter = 0; | 158 | static int stage_counter = 0; |
159 | int c1; | ||
160 | int c2; | ||
161 | int c3; | ||
162 | |||
153 | if (0 == stage_counter) | 163 | if (0 == stage_counter) |
154 | { | 164 | { |
155 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Received initial callback\n"); | 165 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received initial callback for peer `%s' with %u information\n", |
166 | GNUNET_i2s (&addr.peer), ats_count); | ||
167 | if ((0 != memcmp (peer, &addr.peer, sizeof (addr.peer))) || | ||
168 | (ats_count < ATS_COUNT)) | ||
169 | { | ||
170 | GNUNET_break (0); | ||
171 | GNUNET_SCHEDULER_add_now (&end_badly, NULL); | ||
172 | return; | ||
173 | } | ||
174 | c3 = 0; | ||
175 | for (c1 = 0; c1 < ats_count; c1++) | ||
176 | { | ||
177 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "ATS information [%u] %u : %u \n", c1, ntohl (ats[c1].type), ntohl (ats[c1].value)); | ||
178 | for (c2 = 0; c2 < ATS_COUNT; c2++) | ||
179 | { | ||
180 | if (ats[c1].type == atsi[c2].type) | ||
181 | { | ||
182 | if (ats[c1].value == atsi[c2].value) | ||
183 | { | ||
184 | c3++; | ||
185 | } | ||
186 | else | ||
187 | { | ||
188 | GNUNET_break (0); | ||
189 | } | ||
190 | } | ||
191 | } | ||
192 | } | ||
193 | |||
194 | if (ATS_COUNT != c3) | ||
195 | { | ||
196 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received only %u correct ATS information \n", c3); | ||
197 | GNUNET_break (0); | ||
198 | GNUNET_SCHEDULER_add_now (&end_badly, NULL); | ||
199 | return; | ||
200 | } | ||
156 | stage_counter ++; | 201 | stage_counter ++; |
157 | } | 202 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received %u correct ATS information \n", c3); |
203 | |||
204 | atsi[0].type = htonl(GNUNET_ATS_NETWORK_TYPE); | ||
205 | atsi[0].value = htonl(GNUNET_ATS_NET_WAN); | ||
158 | 206 | ||
207 | atsi[1].type = htonl(GNUNET_ATS_QUALITY_NET_DELAY); | ||
208 | atsi[1].value = htonl(1000); | ||
159 | 209 | ||
210 | atsi[2].type = htonl(GNUNET_ATS_QUALITY_NET_DISTANCE); | ||
211 | atsi[2].value = htonl(50); | ||
160 | 212 | ||
213 | GNUNET_ATS_address_update (sh, &addr, NULL, atsi, ATS_COUNT); | ||
214 | } | ||
215 | else if (1 == stage_counter) | ||
216 | { | ||
217 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received updated callback for peer `%s' with %u information\n", | ||
218 | GNUNET_i2s (&addr.peer), ats_count); | ||
219 | |||
220 | if ((0 != memcmp (peer, &addr.peer, sizeof (addr.peer))) || | ||
221 | (ats_count < ATS_COUNT)) | ||
222 | { | ||
223 | GNUNET_break (0); | ||
224 | GNUNET_SCHEDULER_add_now (&end_badly, NULL); | ||
225 | return; | ||
226 | } | ||
227 | c3 = 0; | ||
228 | for (c1 = 0; c1 < ats_count; c1++) | ||
229 | { | ||
230 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "ATS information [%u] %u : %u \n", c1, ntohl (ats[c1].type), ntohl (ats[c1].value)); | ||
231 | for (c2 = 0; c2 < ATS_COUNT; c2++) | ||
232 | { | ||
233 | if (ats[c1].type == atsi[c2].type) | ||
234 | { | ||
235 | if (ats[c1].value == atsi[c2].value) | ||
236 | { | ||
237 | c3++; | ||
238 | } | ||
239 | else | ||
240 | { | ||
241 | GNUNET_break (0); | ||
242 | } | ||
243 | } | ||
244 | } | ||
245 | } | ||
246 | |||
247 | if (ATS_COUNT != c3) | ||
248 | { | ||
249 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received only %u correct ATS information \n", c3); | ||
250 | GNUNET_break (0); | ||
251 | GNUNET_SCHEDULER_add_now (&end_badly, NULL); | ||
252 | return; | ||
253 | } | ||
254 | stage_counter ++; | ||
255 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received %u correct ATS information, shutdown... \n", c3); | ||
256 | GNUNET_SCHEDULER_add_now (&end, NULL); | ||
257 | return; | ||
258 | } | ||
161 | } | 259 | } |
162 | 260 | ||
163 | 261 | ||