aboutsummaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2010-11-04 10:25:49 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2010-11-04 10:25:49 +0000
commit988d2e99e50253e8ae1b0a4cf06de0faf5b73567 (patch)
tree233a32afb0c596589d78dd76298f33f920695865 /src/core
parenta765528e96799978381149bd9096aceb6071be86 (diff)
downloadgnunet-988d2e99e50253e8ae1b0a4cf06de0faf5b73567.tar.gz
gnunet-988d2e99e50253e8ae1b0a4cf06de0faf5b73567.zip
added statistics to get information about discarded messages
Diffstat (limited to 'src/core')
-rw-r--r--src/core/test_core_quota_compliance.c63
1 files changed, 50 insertions, 13 deletions
diff --git a/src/core/test_core_quota_compliance.c b/src/core/test_core_quota_compliance.c
index 99d9ed4ad..d69fb0905 100644
--- a/src/core/test_core_quota_compliance.c
+++ b/src/core/test_core_quota_compliance.c
@@ -34,6 +34,7 @@
34#include "gnunet_program_lib.h" 34#include "gnunet_program_lib.h"
35#include "gnunet_scheduler_lib.h" 35#include "gnunet_scheduler_lib.h"
36#include "gnunet_transport_service.h" 36#include "gnunet_transport_service.h"
37#include "gnunet_statistics_service.h"
37 38
38#define VERBOSE GNUNET_YES 39#define VERBOSE GNUNET_YES
39 40
@@ -50,7 +51,7 @@
50#define MEASUREMENT_MSG_SIZE 10240 51#define MEASUREMENT_MSG_SIZE 10240
51#define MEASUREMENT_MAX_QUOTA 1024 * 1024 * 1024 52#define MEASUREMENT_MAX_QUOTA 1024 * 1024 * 1024
52#define MEASUREMENT_MIN_QUOTA 1024 53#define MEASUREMENT_MIN_QUOTA 1024
53#define MEASUREMENT_INTERVALL GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10) 54#define MEASUREMENT_INTERVALL GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5)
54 55
55/** 56/**
56 * How long until we give up on transmitting the message? 57 * How long until we give up on transmitting the message?
@@ -88,13 +89,15 @@ static GNUNET_SCHEDULER_TaskIdentifier measure_task;
88struct PeerContext 89struct PeerContext
89{ 90{
90 struct GNUNET_CONFIGURATION_Handle *cfg; 91 struct GNUNET_CONFIGURATION_Handle *cfg;
92 struct GNUNET_STATISTICS_Handle *stats;
91 struct GNUNET_CORE_Handle *ch; 93 struct GNUNET_CORE_Handle *ch;
92 struct GNUNET_PeerIdentity id; 94 struct GNUNET_PeerIdentity id;
93 struct GNUNET_TRANSPORT_Handle *th; 95 struct GNUNET_TRANSPORT_Handle *th;
94 struct GNUNET_MessageHeader *hello; 96 struct GNUNET_MessageHeader *hello;
97
95 int connect_status; 98 int connect_status;
96#if START_ARM 99#if START_ARM
97 pid_t arm_pid; 100 struct GNUNET_OS_Process *arm_proc;
98#endif 101#endif
99}; 102};
100 103
@@ -218,6 +221,22 @@ outbound_notify (void *cls,
218} 221}
219 222
220static void 223static void
224next_fin (void *cls, int success)
225{
226
227}
228
229
230static int
231check_2 (void *cls,
232 const char *subsystem,
233 const char *name, uint64_t value, int is_persistent)
234{
235 fprintf(stderr, "%s %s %llu\n", subsystem, name, (long long unsigned int) value);
236 return GNUNET_OK;
237}
238
239static void
221measurement_end (void *cls, 240measurement_end (void *cls,
222 const struct GNUNET_SCHEDULER_TaskContext *tc) 241 const struct GNUNET_SCHEDULER_TaskContext *tc)
223{ 242{
@@ -226,8 +245,22 @@ measurement_end (void *cls,
226 measure_task = GNUNET_SCHEDULER_NO_TASK; 245 measure_task = GNUNET_SCHEDULER_NO_TASK;
227 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) 246 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
228 return; 247 return;
229 measurement_running = GNUNET_NO;
230 248
249 if (err_task != GNUNET_SCHEDULER_NO_TASK)
250 GNUNET_SCHEDULER_cancel (sched, err_task);
251 if (send_task != GNUNET_SCHEDULER_NO_TASK)
252 GNUNET_SCHEDULER_cancel (sched,send_task);
253
254 GNUNET_STATISTICS_get(p1.stats,"core","# discarded CORE_SEND requests",GNUNET_TIME_UNIT_SECONDS, &next_fin, &check_2, &p1);
255 GNUNET_STATISTICS_get(p1.stats,"core","# discarded CORE_SEND requests",GNUNET_TIME_UNIT_SECONDS, &next_fin, &check_2, &p2);
256 GNUNET_STATISTICS_get(p1.stats,"core","# discarded lower priority CORE_SEND requests",GNUNET_TIME_UNIT_SECONDS, &next_fin, &check_2, &p1);
257 GNUNET_STATISTICS_get(p1.stats,"core","# discarded lower priority CORE_SEND requests",GNUNET_TIME_UNIT_SECONDS, &next_fin, &check_2, &p2);
258
259 GNUNET_STATISTICS_get(p1.stats,"core","# discarded CORE_SEND request bytes",GNUNET_TIME_UNIT_SECONDS, &next_fin, &check_2, &p1);
260 GNUNET_STATISTICS_get(p1.stats,"core","# discarded CORE_SEND request bytes",GNUNET_TIME_UNIT_SECONDS, &next_fin, &check_2, &p2);
261 GNUNET_STATISTICS_get(p1.stats,"core","# discarded lower priority CORE_SEND request bytes",GNUNET_TIME_UNIT_SECONDS, &next_fin, &check_2, &p1);
262 GNUNET_STATISTICS_get(p1.stats,"core","# discarded lower priority CORE_SEND request bytes",GNUNET_TIME_UNIT_SECONDS, &next_fin, &check_2, &p2);
263 measurement_running = GNUNET_NO;
231 duration = GNUNET_TIME_absolute_get_difference(start_time, GNUNET_TIME_absolute_get()); 264 duration = GNUNET_TIME_absolute_get_difference(start_time, GNUNET_TIME_absolute_get());
232 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 265 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
233 "\nQuota compliance: \n"\ 266 "\nQuota compliance: \n"\
@@ -237,10 +270,7 @@ measurement_end (void *cls,
237 (total_bytes_recv/(duration.rel_value / 1000)/1024), 270 (total_bytes_recv/(duration.rel_value / 1000)/1024),
238 (total_bytes_sent/(duration.rel_value / 1000)/1024),current_quota_p1_in/1024); 271 (total_bytes_sent/(duration.rel_value / 1000)/1024),current_quota_p1_in/1024);
239 272
240 if (err_task != GNUNET_SCHEDULER_NO_TASK) 273
241 GNUNET_SCHEDULER_cancel (sched, err_task);
242 if (send_task != GNUNET_SCHEDULER_NO_TASK)
243 GNUNET_SCHEDULER_cancel (sched,send_task);
244 GNUNET_SCHEDULER_add_now (sched, &terminate_task, NULL); 274 GNUNET_SCHEDULER_add_now (sched, &terminate_task, NULL);
245} 275}
246 276
@@ -251,6 +281,8 @@ static void
251send_tsk (void *cls, 281send_tsk (void *cls,
252 const struct GNUNET_SCHEDULER_TaskContext *tc) 282 const struct GNUNET_SCHEDULER_TaskContext *tc)
253{ 283{
284 send_task = GNUNET_SCHEDULER_NO_TASK;
285
254 ch = GNUNET_CORE_notify_transmit_ready (p1.ch, 286 ch = GNUNET_CORE_notify_transmit_ready (p1.ch,
255 0, 287 0,
256 FAST_TIMEOUT, 288 FAST_TIMEOUT,
@@ -396,7 +428,9 @@ transmit_ready (void *cls, size_t size, void *buf)
396 428
397 total_bytes += ret; 429 total_bytes += ret;
398 total_bytes_sent += ret; 430 total_bytes_sent += ret;
399 send_task = GNUNET_SCHEDULER_add_delayed (sched, GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 100), &send_tsk, NULL); 431 if (send_task != GNUNET_SCHEDULER_NO_TASK)
432 GNUNET_SCHEDULER_cancel(sched, send_task);
433 send_task = GNUNET_SCHEDULER_add_delayed (sched, GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 20), &send_tsk, NULL);
400 434
401 return ret; 435 return ret;
402} 436}
@@ -487,6 +521,8 @@ setup_peer (struct PeerContext *p, const char *cfgname)
487 "-c", cfgname, NULL); 521 "-c", cfgname, NULL);
488#endif 522#endif
489 GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname)); 523 GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname));
524 p->stats = GNUNET_STATISTICS_create (sched, "core", p->cfg);
525 GNUNET_assert (p->stats != NULL);
490 p->th = GNUNET_TRANSPORT_connect (sched, p->cfg, NULL, p, NULL, NULL, NULL); 526 p->th = GNUNET_TRANSPORT_connect (sched, p->cfg, NULL, p, NULL, NULL, NULL);
491 GNUNET_assert (p->th != NULL); 527 GNUNET_assert (p->th != NULL);
492 GNUNET_TRANSPORT_get_hello (p->th, &process_hello, p); 528 GNUNET_TRANSPORT_get_hello (p->th, &process_hello, p);
@@ -540,14 +576,15 @@ stop_arm (struct PeerContext *p)
540{ 576{
541#if START_ARM 577#if START_ARM
542 if (0 != GNUNET_OS_process_kill (p->arm_proc, SIGTERM)) 578 if (0 != GNUNET_OS_process_kill (p->arm_proc, SIGTERM))
543 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); 579 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
544 if (GNUNET_OS_process_wait(p->arm_pid) != GNUNET_OK) 580 if (GNUNET_OS_process_wait(p->arm_proc) != GNUNET_OK)
545 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid"); 581 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid");
582
583 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"ARM process stopped\n");
546 GNUNET_OS_process_close (p->arm_proc); 584 GNUNET_OS_process_close (p->arm_proc);
547 p->arm_proc = NULL; 585 p->arm_proc = NULL;
548 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
549 "ARM process %u stopped\n", p->arm_pid);
550#endif 586#endif
587 GNUNET_STATISTICS_destroy (p->stats, 0);
551 GNUNET_CONFIGURATION_destroy (p->cfg); 588 GNUNET_CONFIGURATION_destroy (p->cfg);
552} 589}
553 590