#define BURST_RUNS 1
#define SHORT_BURST_WINDOW \
- GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS,5)
+ GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS,2)
#define LONG_BURST_WINDOW \
GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS,2)
#define SIZE_CHECK 2
-static int num_sent = 0;
+static size_t num_sent = 0;
static uint32_t ack = 0;
static uint64_t avg_latency = 0;
+static struct GNUNET_TIME_Relative duration;
+
static void
communicator_available_cb (void *cls,
struct
ack);
GNUNET_free (payload);
ack += 5;
+ num_sent++;
if (ack < 64000)
GNUNET_SCHEDULER_add_now (&size_test, NULL);
else
- GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
+ GNUNET_SCHEDULER_add_delayed (SHORT_BURST_WINDOW,
&size_test, NULL);
return;
}
GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
"Size packet test done.\n");
GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
- "#packets: %lu -- latency: %lu microseconds\n",
+ "%lu/%lu packets -- avg latency: %lu us\n",
num_received,
+ num_sent,
avg_latency);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Finished\n");
static void
long_test (void *cls)
{
- struct GNUNET_TIME_Relative duration = GNUNET_TIME_absolute_get_duration (
- start_long);
char *payload;
if (num_sent < BURST_PACKETS)
{
&long_test, NULL);
return;
}
- duration = GNUNET_TIME_absolute_get_duration (start_long);
GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
"Long size packet test done.\n");
GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
- "goodput: %lu kb/s -- #packets: %lu -- latency: %lu microseconds\n",
- (LONG_MESSAGE_SIZE * num_received) / (duration.rel_value_us / 1000),
+ "%lu/%lu packets in %lu us (%lu kb/s) -- avg latency: %lu us\n",
num_received,
+ num_sent,
+ duration.rel_value_us,
+ (LONG_MESSAGE_SIZE * num_received) / (duration.rel_value_us / 1000),
avg_latency);
ack = 10;
num_received = 0;
static void
short_test (void *cls)
{
- struct GNUNET_TIME_Relative duration;
char *payload;
- if (num_sent < BURST_PACKETS)
+ while (num_sent < BURST_PACKETS)
{
payload = make_payload (SHORT_MESSAGE_SIZE);
GNUNET_TRANSPORT_TESTING_transport_communicator_send (my_tc,
SHORT_MESSAGE_SIZE);
num_sent++;
GNUNET_free (payload);
- if (num_sent < BURST_PACKETS)
- GNUNET_SCHEDULER_add_now (&short_test, NULL);
+ //if (num_sent < BURST_PACKETS)
+ // GNUNET_SCHEDULER_add_now (&short_test, NULL);
if (num_sent == BURST_PACKETS)
+ {
GNUNET_SCHEDULER_add_delayed (SHORT_BURST_WINDOW,
&short_test, NULL);
- return;
+ return;
+ }
}
- duration = GNUNET_TIME_absolute_get_duration (start_short);
GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
"Short size packet test done.\n");
GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
- "goodput: %lu kb/s -- #packets: %lu -- latency: %lu microseconds\n",
- (SHORT_MESSAGE_SIZE * num_received) / (duration.rel_value_us / 1000),
+ "%lu/%lu packets in %lu us (%lu kb/s) -- avg latency: %lu us\n",
num_received,
+ num_sent,
+ duration.rel_value_us,
+ (SHORT_MESSAGE_SIZE * num_received) / (duration.rel_value_us / 1000),
avg_latency);
start_long = GNUNET_TIME_absolute_get ();
phase = BURST_LONG;
size_t payload_len)
{
if (0 != strcmp ((char*) cls, cfg_peers_name[NUM_PEERS - 1]))
- return; // TODO?
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ "unexpected receiver...\n");
+ return;
+ }
if (phase == BURST_SHORT)
{
GNUNET_assert (SHORT_MESSAGE_SIZE == payload_len);
num_received++;
+ duration = GNUNET_TIME_absolute_get_duration (start_short);
update_avg_latency (payload);
}
else if (phase == BURST_LONG)
{
if (LONG_MESSAGE_SIZE != payload_len)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ "Ignoring packet with wrong length\n");
return; // Ignore
+ }
num_received++;
+ duration = GNUNET_TIME_absolute_get_duration (start_long);
update_avg_latency (payload);
}
else // if (phase == SIZE_CHECK) {
*/
struct GNUNET_OS_Process *c_proc;
+ /**
+ * NAT process
+ */
+ struct GNUNET_OS_Process *nat_proc;
+
/**
* @brief Task that will be run on shutdown to stop and clean communicator
*/
* @param cls Closure - Process of communicator
*/
static void
-shutdown_communicator (void *cls)
+shutdown_process (struct GNUNET_OS_Process *proc)
{
- struct GNUNET_OS_Process *proc = cls;
-
if (0 != GNUNET_OS_process_kill (proc, SIGTERM))
{
LOG (GNUNET_ERROR_TYPE_WARNING,
GNUNET_OS_process_destroy (proc);
}
+static void
+shutdown_communicator (void *cls)
+{
+ struct GNUNET_OS_Process *proc = cls;
+ shutdown_process(proc);
+}
+
/**
* @brief Start the communicator
GNUNET_free (binary);
}
+/**
+ * @brief Task run at shutdown to kill communicator and clean up
+ *
+ * @param cls Closure - Process of communicator
+ */
+static void
+shutdown_nat (void *cls)
+{
+ struct GNUNET_OS_Process *proc = cls;
+ shutdown_process (proc);
+}
+
+
+/**
+ * @brief Start NAT
+ *
+ */
+static void
+nat_start (
+ struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h)
+{
+ char *binary;
+
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "nat_start\n");
+ binary = GNUNET_OS_get_libexec_binary_path ("gnunet-service-nat");
+ tc_h->nat_proc = GNUNET_OS_start_process (GNUNET_YES,
+ GNUNET_OS_INHERIT_STD_OUT_AND_ERR,
+ NULL,
+ NULL,
+ NULL,
+ binary,
+ "gnunet-service-nat",
+ "-c",
+ tc_h->cfg_filename,
+ NULL);
+ if (NULL == tc_h->nat_proc)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to start NAT!");
+ return;
+ }
+ LOG (GNUNET_ERROR_TYPE_INFO, "started NAT\n");
+ GNUNET_free (binary);
+}
+
+
static void
do_shutdown (void *cls)
struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h = cls;
shutdown_communicator(tc_h->c_proc);
shutdown_service(tc_h->sh);
+ shutdown_nat(tc_h->nat_proc);
}
/* Start communicator part of service */
transport_communicator_start (tc_h);
-
+ /* Start NAT */
+ nat_start (tc_h);
/* Schedule start communicator */
communicator_start (tc_h,
binary_name);