#define DEBUG_TRANSPORT_HELLO GNUNET_YES
-#define DEBUG_ATS GNUNET_YES
-#define VERBOSE_ATS GNUNET_YES
+#define DEBUG_ATS GNUNET_NO
+#define VERBOSE_ATS GNUNET_NO
/**
* Should we do some additional checks (to validate behavior
int rows = 1 + (3*peers) + (transports);
int cols = peers;
int index = 1;
- //int start = 0;
int cur_row = 0;
int size = 1+(rows*cols);
double value;
if (DEBUG_ATS) GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Creating LP problem: %i peers, relativity r %3.2f, b_max %5.2f, b_min %5.2f, \n",peers, r, b_max, b_min);
- if (DEBUG_ATS) GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Current memory consumption %i\n",(1+(rows*cols) * (2*sizeof(int) + sizeof(double))) / (1024*1024));
+ if (DEBUG_ATS) GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Current memory consumption %i\n",(1+(rows*cols) * (2*sizeof(int) + sizeof(double))));
lp = glp_create_prob();
glp_set_prob_name(lp, "gnunet ats bandwidth distribution");
glp_set_obj_dir(lp, GLP_MAX);
if (pl[c2-1].t == tl[c1].id)
value = tl[c1].c_1;
else value = 0;
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Transport %i peer %i: index %i size %i value %f\n", c1,c2, index, size, value);
ar[index] = value;
index++;
}
void ats_benchmark (int peers, int transports, int start_peers, int end_peers)
{
struct GNUNET_TIME_Absolute start;
+ struct GNUNET_TIME_Relative duration;
int test = 11;
int mlp = GNUNET_NO;
tl[c].id = c;
tl[c].c_max = 10000;
tl[c].c_1 = 1;
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "ats_calculate_bandwidth_distribution Peer[%i] : %i \n",c , tl[c].id);
+ //GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "ats_calculate_bandwidth_distribution Peer[%i] : %i \n",c , tl[c].id);
c++;
}
// test //
start = GNUNET_TIME_absolute_get();
ats_create_problem(peers, transports, b_min, b_max, r, R, pl, tl, it, dur, mlp);
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "benchmark result ({LP/MLP},peers,duration,mem):%s,%i,%llu,%i\n",(mlp)?"mlp":"lp", peers,
- GNUNET_TIME_absolute_get_difference(start,GNUNET_TIME_absolute_get()).rel_value, (1+(peers*transports) * (2*sizeof(int) + sizeof(double))));
+ duration = GNUNET_TIME_absolute_get_difference(start,GNUNET_TIME_absolute_get());
+
+ if (DEBUG_ATS) GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "benchmark result ({LP/MLP},peers,duration,mem):%s,%i,%llu,%i\n",
+ (mlp)?"mlp":"lp", (int )peers, duration.rel_value,
+ (1+(peers*transports) * (2*sizeof(int) + sizeof(double))));
+
+ GNUNET_STATISTICS_set (stats, "ATS execution time 100 peers", duration.rel_value, GNUNET_NO);
GNUNET_free (pl);
GNUNET_free (tl);
}
if (delta.rel_value < ats->min_delta.rel_value)
{
#if DEBUG_ATS
- //GNUNET_log (GNUNET_ERROR_TYPE_BULK, "Minimum time between cycles not reached\n");
+ GNUNET_log (GNUNET_ERROR_TYPE_BULK, "Minimum time between cycles not reached\n");
#endif
return;
}
struct ATS_peer * pl = NULL;
start = GNUNET_TIME_absolute_get();
- ats_benchmark(10,3,10,10);
+ ats_benchmark(100,3,100,100);
//ats_create_problem(peers, transports, b_min, b_max, r, R, pl, tl, it, dur, mlp);
GNUNET_free_non_null (pl);
validation_map = NULL;
return;
}
-#if HAVE_GLPK
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("HAVE\n"));
-#else
- //GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("NOT HAVE\n"));
-#endif
ats = ats_init();
max_connect_per_transport = (uint32_t) tneigh;
#include "gnunet_program_lib.h"
#include "gnunet_scheduler_lib.h"
#include "gnunet_transport_service.h"
+#include "gnunet_statistics_service.h"
#include "transport.h"
+#include "gauger.h"
#define VERBOSE GNUNET_NO
/**
* How long until we give up on transmitting the message?
*/
-#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5)
+#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30)
/**
* How long until we give up on transmitting the message?
struct GNUNET_CONFIGURATION_Handle *cfg;
struct GNUNET_TRANSPORT_Handle *th;
struct GNUNET_PeerIdentity id;
+ struct GNUNET_STATISTICS_Handle *stats;
#if START_ARM
struct GNUNET_OS_Process *arm_proc;
#endif
static struct PeerContext p1;
+/**
+ * Handle for reporting statistics.
+ */
+
+
+
static struct PeerContext p2;
static int ok;
static GNUNET_SCHEDULER_TaskIdentifier die_task;
-static char * key_file_p1;
-static char * cert_file_p1;
-
-static char * key_file_p2;
-static char * cert_file_p2;
#if VERBOSE
#define OKPP do { ok++; fprintf (stderr, "Now at stage %u at %s:%u\n", ok, __FILE__, __LINE__); } while (0)
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Disconnecting from transports!\n");
GNUNET_TRANSPORT_disconnect (p1.th);
GNUNET_TRANSPORT_disconnect (p2.th);
-
+ if (p1.stats != NULL)
+ GNUNET_STATISTICS_destroy (p1.stats, GNUNET_NO);
die_task = GNUNET_SCHEDULER_NO_TASK;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Transports disconnected, returning success!\n");
ok = 0;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Disconnecting from transports!\n");
//GNUNET_break (0);
GNUNET_TRANSPORT_disconnect (p1.th);
+ if (p1.stats != NULL)
+ GNUNET_STATISTICS_destroy (p1.stats, GNUNET_NO);
//GNUNET_TRANSPORT_disconnect (p2.th);
ok = 1;
}
{
if (cls == &p1)
{
- GNUNET_SCHEDULER_cancel (die_task);
- die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT_TRANSMIT,
- &end_badly, NULL);
GNUNET_TRANSPORT_notify_transmit_ready (p1.th,
&p2.id,
GNUNET_i2s (peer), cls);
}
+int stat_cb (void *cls,
+ const char *subsystem,
+ const char *name,
+ uint64_t value,
+ int is_persistent)
+{
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Execution time for 100 Peers: %llu\n",value);
+ return GNUNET_NO;
+}
+
static void
setup_peer (struct PeerContext *p, const char *cfgname)
"-c", cfgname, NULL);
#endif
GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname));
-
- if (is_https)
- {
- struct stat sbuf;
- if (p==&p1)
- {
- if (GNUNET_CONFIGURATION_have_value (p->cfg,
- "transport-https", "KEY_FILE"))
- GNUNET_CONFIGURATION_get_value_string (p->cfg, "transport-https", "KEY_FILE", &key_file_p1);
- if (key_file_p1==NULL)
- GNUNET_asprintf(&key_file_p1,"https.key");
- if (0 == stat (key_file_p1, &sbuf ))
- {
- if (0 == remove(key_file_p1))
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Successfully removed existing private key file `%s'\n",key_file_p1);
- else
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to remove private key file `%s'\n",key_file_p1);
- }
- if (GNUNET_CONFIGURATION_have_value (p->cfg,"transport-https", "CERT_FILE"))
- GNUNET_CONFIGURATION_get_value_string (p->cfg, "transport-https", "CERT_FILE", &cert_file_p1);
- if (cert_file_p1==NULL)
- GNUNET_asprintf(&cert_file_p1,"https.cert");
- if (0 == stat (cert_file_p1, &sbuf ))
- {
- if (0 == remove(cert_file_p1))
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Successfully removed existing certificate file `%s'\n",cert_file_p1);
- else
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to remove existing certificate file `%s'\n",cert_file_p1);
- }
- }
- else if (p==&p2)
- {
- if (GNUNET_CONFIGURATION_have_value (p->cfg,
- "transport-https", "KEY_FILE"))
- GNUNET_CONFIGURATION_get_value_string (p->cfg, "transport-https", "KEY_FILE", &key_file_p2);
- if (key_file_p2==NULL)
- GNUNET_asprintf(&key_file_p2,"https.key");
- if (0 == stat (key_file_p2, &sbuf ))
- {
- if (0 == remove(key_file_p2))
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Successfully removed existing private key file `%s'\n",key_file_p2);
- else
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to remove private key file `%s'\n",key_file_p2);
- }
- if (GNUNET_CONFIGURATION_have_value (p->cfg,"transport-https", "CERT_FILE"))
- GNUNET_CONFIGURATION_get_value_string (p->cfg, "transport-https", "CERT_FILE", &cert_file_p2);
- if (cert_file_p2==NULL)
- GNUNET_asprintf(&cert_file_p2,"https.cert");
- if (0 == stat (cert_file_p2, &sbuf ))
- {
- if (0 == remove(cert_file_p2))
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Successfully removed existing certificate file `%s'\n",cert_file_p2);
- else
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to remove existing certificate file `%s'\n",cert_file_p2);
- }
- }
- }
+ p->stats = GNUNET_STATISTICS_create ("transport", p->cfg);
+ GNUNET_assert (p->stats != NULL);
+ GNUNET_assert (GNUNET_OK == GNUNET_STATISTICS_watch (p->stats,"transport","ATS execution time 100 peers", stat_cb, NULL));
p->th = GNUNET_TRANSPORT_connect (p->cfg,
NULL, p,
¬ify_receive,
¬ify_connect, ¬ify_disconnect);
GNUNET_assert (p->th != NULL);
+
+ GNUNET_SCHEDULER_cancel (die_task);
+ die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT_TRANSMIT,
+ &end_badly, NULL);
}
stop_arm (&p1);
// stop_arm (&p2);
- if (is_https)
- {
- struct stat sbuf;
- if (0 == stat (cert_file_p1, &sbuf ))
- {
- if (0 == remove(cert_file_p1))
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Successfully removed existing certificate file `%s'\n",cert_file_p1);
- else
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to remove certfile `%s'\n",cert_file_p1);
- }
-
- if (0 == stat (key_file_p1, &sbuf ))
- {
- if (0 == remove(key_file_p1))
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Successfully removed private key file `%s'\n",key_file_p1);
- else
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to private key file `%s'\n",key_file_p1);
- }
-
- if (0 == stat (cert_file_p2, &sbuf ))
- {
- if (0 == remove(cert_file_p2))
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Successfully removed existing certificate file `%s'\n",cert_file_p2);
- else
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to remove certfile `%s'\n",cert_file_p2);
- }
-
- if (0 == stat (key_file_p2, &sbuf ))
- {
- if (0 == remove(key_file_p2))
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Successfully removed private key file `%s'\n",key_file_p2);
- else
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to private key file `%s'\n",key_file_p2);
- }
- GNUNET_free(key_file_p1);
- GNUNET_free(key_file_p2);
- GNUNET_free(cert_file_p1);
- GNUNET_free(cert_file_p2);
- }
return ok;
}