*/
struct BenchmarkState
{
- /* Are we connected to ATS service of all peers: GNUNET_YES/NO */
+ /**
+ * Are we connected to ATS service of all peers: GNUNET_YES/NO
+ */
int connected_ATS_service;
- /* Are we connected to CORE service of all peers: GNUNET_YES/NO */
+ /**
+ * Are we connected to CORE service of all peers: GNUNET_YES/NO
+ */
int connected_COMM_service;
- /* Are we connected to all peers: GNUNET_YES/NO */
+ /**
+ * Are we connected to all peers: GNUNET_YES/NO
+ */
int connected_PEERS;
- /* Are we connected to all slave peers on CORE level: GNUNET_YES/NO */
+ /**
+ * Are we connected to all slave peers on CORE level: GNUNET_YES/NO
+ */
int connected_CORE;
- /* Are we connected to CORE service of all peers: GNUNET_YES/NO */
+ /**
+ * Are we connected to CORE service of all peers: GNUNET_YES/NO
+ */
int benchmarking;
};
+
/**
* Shutdown task
*/
/**
* Number master peers
*/
-static int num_masters;
+static unsigned int num_masters;
/**
* Array of master peers
*/
-static struct BenchmarkPeer *mps;
+static struct BenchmarkPeer *mps;
/**
* Number slave peers
*/
-static int num_slaves;
+static unsigned int num_slaves;
+
/**
* Array of slave peers
*/
{
p = &mp->partners[c_s];
fprintf (stderr,
- "%c Master [%u] -> Slave [%u]: sent %u KiB/s (%.2f \%), received %u KiB/s (%.2f \%)\n",
+ "%c Master [%u] -> Slave [%u]: sent %u KiB/s (%.2f %%), received %u KiB/s (%.2f %%)\n",
(mp->pref_partner == p->dest) ? '*' : ' ',
mp->no, p->dest->no,
(p->bytes_sent / 1024) / duration,
"%c Master [%u] -> Slave [%u]: Average application layer RTT: %u ms\n",
(mp->pref_partner == p->dest) ? '*' : ' ',
mp->no, p->dest->no,
- p->total_app_delay / (1000 * p->messages_sent));
+ p->total_app_rtt / (1000 * p->messages_sent));
}
}
}
int c_m;
int c_s;
int c_op;
+ struct BenchmarkPeer *p;
if (GNUNET_YES == logging)
perf_logging_stop();
for (c_m = 0; c_m < num_masters; c_m++)
{
+ p = &mps[c_m];
if (NULL != mps[c_m].peer_id_op)
{
- GNUNET_TESTBED_operation_done (mps[c_m].peer_id_op);
- mps[c_m].peer_id_op = NULL;
+ GNUNET_TESTBED_operation_done (p->peer_id_op);
+ p->peer_id_op = NULL;
}
- if (GNUNET_SCHEDULER_NO_TASK != mps[c_m].ats_task)
- GNUNET_SCHEDULER_cancel (mps[c_m].ats_task);
- mps[c_m].ats_task = GNUNET_SCHEDULER_NO_TASK;
+ if (GNUNET_SCHEDULER_NO_TASK != p->ats_task)
+ GNUNET_SCHEDULER_cancel (p->ats_task);
+ p->ats_task = GNUNET_SCHEDULER_NO_TASK;
- for (c_op = 0; c_op < num_slaves; c_op++)
+ for (c_op = 0; c_op < p->num_partners; c_op++)
{
-
- if (NULL != mps[c_m].partners[c_op].cth)
+ if (NULL != p->partners[c_op].cth)
{
- GNUNET_CORE_notify_transmit_ready_cancel (mps[c_m].partners[c_op].cth);
- mps[c_m].partners[c_op].cth = NULL;
+ GNUNET_CORE_notify_transmit_ready_cancel (p->partners[c_op].cth);
+ p->partners[c_op].cth = NULL;
}
- if (NULL != mps[c_m].partners[c_op].tth)
+ if (NULL != p->partners[c_op].tth)
{
- GNUNET_TRANSPORT_notify_transmit_ready_cancel (mps[c_m].partners[c_op].tth);
- mps[c_m].partners[c_op].tth = NULL;
+ GNUNET_TRANSPORT_notify_transmit_ready_cancel (p->partners[c_op].tth);
+ p->partners[c_op].tth = NULL;
}
-
-
- if (NULL != mps[c_m].core_connect_ops[c_op].connect_op)
+ if (NULL != p->core_connect_ops[c_op].connect_op)
{
GNUNET_log(GNUNET_ERROR_TYPE_INFO,
_("Failed to connect peer 0 and %u\n"), c_op);
GNUNET_TESTBED_operation_done (
- mps[c_m].core_connect_ops[c_op].connect_op);
- mps[c_m].core_connect_ops[c_op].connect_op = NULL;
+ p->core_connect_ops[c_op].connect_op);
+ p->core_connect_ops[c_op].connect_op = NULL;
result = 1;
}
}
- if (NULL != mps[c_m].ats_perf_op)
+ if (NULL != p->ats_perf_op)
{
- GNUNET_TESTBED_operation_done (mps[c_m].ats_perf_op);
- mps[c_m].ats_perf_op = NULL;
+ GNUNET_TESTBED_operation_done (p->ats_perf_op);
+ p->ats_perf_op = NULL;
}
- if (NULL != mps[c_m].comm_op)
+ if (NULL != p->comm_op)
{
- GNUNET_TESTBED_operation_done (mps[c_m].comm_op);
- mps[c_m].comm_op = NULL;
+ GNUNET_TESTBED_operation_done (p->comm_op);
+ p->comm_op = NULL;
}
- GNUNET_free(mps[c_m].core_connect_ops);
- GNUNET_free(mps[c_m].partners);
- mps[c_m].partners = NULL;
+ GNUNET_free(p->core_connect_ops);
+ GNUNET_free(p->partners);
+ p->partners = NULL;
}
for (c_s = 0; c_s < num_slaves; c_s++)
{
- if (NULL != sps[c_s].peer_id_op)
+ p = &sps[c_s];
+ if (NULL != p->peer_id_op)
{
- GNUNET_TESTBED_operation_done (sps[c_s].peer_id_op);
- sps[c_s].peer_id_op = NULL;
+ GNUNET_TESTBED_operation_done (p->peer_id_op);
+ p->peer_id_op = NULL;
}
- for (c_op = 0; c_op < num_slaves; c_op++)
+ for (c_op = 0; c_op < p->num_partners; c_op++)
{
- if (NULL != sps[c_s].partners[c_op].cth)
+ if (NULL != p->partners[c_op].cth)
{
- GNUNET_CORE_notify_transmit_ready_cancel (sps[c_s].partners[c_op].cth);
- sps[c_s].partners[c_op].cth = NULL;
+ GNUNET_CORE_notify_transmit_ready_cancel (p->partners[c_op].cth);
+ p->partners[c_op].cth = NULL;
}
-
- if (NULL != sps[c_s].partners[c_op].tth)
+ if (NULL != p->partners[c_op].tth)
{
- GNUNET_TRANSPORT_notify_transmit_ready_cancel (sps[c_s].partners[c_op].tth);
- sps[c_s].partners[c_op].tth = NULL;
+ GNUNET_TRANSPORT_notify_transmit_ready_cancel (p->partners[c_op].tth);
+ p->partners[c_op].tth = NULL;
}
}
-
- if (NULL != sps[c_s].ats_perf_op)
+ if (NULL != p->ats_perf_op)
{
- GNUNET_TESTBED_operation_done (sps[c_s].ats_perf_op);
- sps[c_s].ats_perf_op = NULL;
+ GNUNET_TESTBED_operation_done (p->ats_perf_op);
+ p->ats_perf_op = NULL;
}
- if (NULL != sps[c_s].comm_op)
+ if (NULL != p->comm_op)
{
- GNUNET_TESTBED_operation_done (sps[c_s].comm_op);
- sps[c_s].comm_op = NULL;
+ GNUNET_TESTBED_operation_done (p->comm_op);
+ p->comm_op = NULL;
}
-
- GNUNET_free(sps[c_s].partners);
- sps[c_s].partners = NULL;
+ GNUNET_free(p->partners);
+ p->partners = NULL;
}
GNUNET_SCHEDULER_shutdown ();
GNUNET_free(id);
}
+static struct BenchmarkPartner *
+find_partner (struct BenchmarkPeer *me, const struct GNUNET_PeerIdentity * peer)
+{
+ int c_m;
+ GNUNET_assert (NULL != me);
+ GNUNET_assert (NULL != peer);
+
+ for (c_m = 0; c_m < me->num_partners; c_m++)
+ {
+ /* Find a partner with other as destination */
+ if (0 == memcmp (peer, &me->partners[c_m].dest->id,
+ sizeof(struct GNUNET_PeerIdentity)))
+ {
+ return &me->partners[c_m];
+ }
+ }
+
+ return NULL;
+}
+
static void
comm_disconnect_cb (void *cls, const struct GNUNET_PeerIdentity * peer)
{
struct BenchmarkPeer *me = cls;
- struct BenchmarkPeer *remote;
+ struct BenchmarkPartner *p;
char *id;
- remote = find_peer (peer);
- if (NULL == remote)
- {
- GNUNET_break(0);
+ if (NULL == (p = find_partner (me, peer)))
return;
- }
id = GNUNET_strdup (GNUNET_i2s (&me->id));
GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "%s disconnected from %s \n", id,
me->core_connections--;
if ((GNUNET_YES == state.benchmarking)
- && ((GNUNET_YES == me->master) || (GNUNET_YES == remote->master)))
+ && ((GNUNET_YES == me->master) || (GNUNET_YES == p->dest->master)))
{
GNUNET_log(GNUNET_ERROR_TYPE_ERROR,
"%s disconnected from %s while benchmarking \n", id, GNUNET_i2s (peer));
+ if (NULL != p->tth)
+ {
+ GNUNET_TRANSPORT_notify_transmit_ready_cancel (p->tth);
+ p->tth = NULL;
+ }
+ if (NULL != p->cth)
+ {
+ GNUNET_CORE_notify_transmit_ready_cancel (p->cth);
+ p->cth = NULL;
+ }
}
GNUNET_free(id);
}
comm_handle_ping (void *cls, const struct GNUNET_PeerIdentity *other,
const struct GNUNET_MessageHeader *message)
{
- int c_m;
+
struct BenchmarkPeer *me = cls;
struct BenchmarkPartner *p = NULL;
- for (c_m = 0; c_m < num_masters; c_m++)
- {
- /* Find a partner with other as destination */
- if (0 == memcmp (other, &me->partners[c_m].dest->id,
- sizeof(struct GNUNET_PeerIdentity)))
- {
- p = &me->partners[c_m];
- break;
- }
- }
- if (NULL == p)
+
+ if (NULL == (p = find_partner(me, other)))
{
GNUNET_break(0);
return GNUNET_SYSERR;
comm_handle_pong (void *cls, const struct GNUNET_PeerIdentity *other,
const struct GNUNET_MessageHeader *message)
{
- int c_s;
struct BenchmarkPeer *me = cls;
struct BenchmarkPartner *p = NULL;
- for (c_s = 0; c_s < num_slaves; c_s++)
- {
- if (0
- == memcmp (other, &me->partners[c_s].dest->id,
- sizeof(struct GNUNET_PeerIdentity)))
- {
- p = &me->partners[c_s];
- break;
- }
- }
- if (NULL == p)
+ if (NULL == (p = find_partner (me, other)))
{
GNUNET_break(0);
return GNUNET_SYSERR;
}
-
GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
"Master [%u]: Received PONG from [%u], next message\n", me->no,
p->dest->no);
p->bytes_received += TEST_MESSAGE_SIZE;
p->me->total_messages_received++;
p->me->total_bytes_received += TEST_MESSAGE_SIZE;
- p->total_app_delay += GNUNET_TIME_absolute_get_difference(p->last_message_sent,
+ p->total_app_rtt += GNUNET_TIME_absolute_get_difference(p->last_message_sent,
GNUNET_TIME_absolute_get()).rel_value_us;
comm_schedule_send (p);
const struct GNUNET_ATS_Information *ats, uint32_t ats_count)
{
struct BenchmarkPeer *me = cls;
+ struct BenchmarkPartner *p;
int c_a;
+ int log;
char *peer_id;
- peer_id = GNUNET_strdup (GNUNET_i2s (&me->id));
- for (c_a = 0; c_a < ats_count; c_a++)
+ p = find_partner (me, &address->peer);
+ if (NULL == p)
{
- /*GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("%c %03u: %s %s %u\n"),
- (GNUNET_YES == p->master) ? 'M' : 'S',
- p->no,
- GNUNET_i2s (&address->peer),
- GNUNET_ATS_print_property_type(ntohl(ats[c_a].type)),
- ntohl(ats[c_a].value));*/
+ /* This is not one of my partners
+ * Will happen since the peers will connect to each other due to gossiping
+ */
+ return;
}
-#if 0
- if ((GNUNET_YES == me->master)
- && (0 == memcmp (&address->peer, &me->destination->id,
- sizeof(struct GNUNET_PeerIdentity))))
+ peer_id = GNUNET_strdup (GNUNET_i2s (&me->id));
+
+ log = GNUNET_NO;
+ if ((p->bandwidth_in != ntohl (bandwidth_in.value__)) ||
+ (p->bandwidth_out != ntohl (bandwidth_out.value__)))
+ log = GNUNET_YES;
+ p->bandwidth_in = ntohl (bandwidth_in.value__);
+ p->bandwidth_out = ntohl (bandwidth_out.value__);
+
+ for (c_a = 0; c_a < ats_count; c_a++)
{
- GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Bandwidth for master %u: %lu %lu\n",
- me->no, (long unsigned int ) ntohl (bandwidth_in.value__),
- (long unsigned int ) ntohl (bandwidth_in.value__));
- }
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "%s [%u] received ATS information: %s %s %u\n",
+ (GNUNET_YES == p->me->master) ? "Master" : "Slave",
+ p->me->no,
+ GNUNET_i2s (&p->dest->id),
+ GNUNET_ATS_print_property_type(ntohl(ats[c_a].type)),
+ ntohl(ats[c_a].value));
+ switch (ntohl (ats[c_a].type ))
+ {
+ case GNUNET_ATS_ARRAY_TERMINATOR:
+ break;
+ case GNUNET_ATS_UTILIZATION_OUT:
+ if (p->ats_utilization_up != ntohl (ats[c_a].value))
+ log = GNUNET_YES;
+ p->ats_utilization_up = ntohl (ats[c_a].value);
- store_information (&bp->id, address, address_active, bandwidth_in,
- bandwidth_out, ats, ats_count);
-#endif
+ break;
+ case GNUNET_ATS_UTILIZATION_IN:
+ if (p->ats_utilization_down != ntohl (ats[c_a].value))
+ log = GNUNET_YES;
+ p->ats_utilization_down = ntohl (ats[c_a].value);
+ break;
+ case GNUNET_ATS_NETWORK_TYPE:
+ if (p->ats_network_type != ntohl (ats[c_a].value))
+ log = GNUNET_YES;
+ p->ats_network_type = ntohl (ats[c_a].value);
+ break;
+ case GNUNET_ATS_QUALITY_NET_DELAY:
+ if (p->ats_delay != ntohl (ats[c_a].value))
+ log = GNUNET_YES;
+ p->ats_delay = ntohl (ats[c_a].value);
+ break;
+ case GNUNET_ATS_QUALITY_NET_DISTANCE:
+ if (p->ats_distance != ntohl (ats[c_a].value))
+ log = GNUNET_YES;
+ p->ats_distance = ntohl (ats[c_a].value);
+ GNUNET_break (0);
+ break;
+ case GNUNET_ATS_COST_WAN:
+ if (p->ats_cost_wan != ntohl (ats[c_a].value))
+ log = GNUNET_YES;
+ p->ats_cost_wan = ntohl (ats[c_a].value);
+ break;
+ case GNUNET_ATS_COST_LAN:
+ if (p->ats_cost_lan != ntohl (ats[c_a].value))
+ log = GNUNET_YES;
+ p->ats_cost_lan = ntohl (ats[c_a].value);
+ break;
+ case GNUNET_ATS_COST_WLAN:
+ if (p->ats_cost_wlan != ntohl (ats[c_a].value))
+ log = GNUNET_YES;
+ p->ats_cost_wlan = ntohl (ats[c_a].value);
+ break;
+ default:
+ break;
+ }
+ }
+ if ((GNUNET_YES == logging) && (GNUNET_YES == log))
+ collect_log_now();
GNUNET_free(peer_id);
}
* failed
*/
static void
-main_run (void *cls, struct GNUNET_TESTBED_RunHandle *h, unsigned int num_peers,
- struct GNUNET_TESTBED_Peer **peers_, unsigned int links_succeeded,
- unsigned int links_failed)
+main_run (void *cls, struct GNUNET_TESTBED_RunHandle *h,
+ unsigned int num_peers,
+ struct GNUNET_TESTBED_Peer **peers_,
+ unsigned int links_succeeded,
+ unsigned int links_failed)
{
int c_m;
int c_s;
mps[c_m].pref_partner = &sps[c_m];
mps[c_m].pref_value = TEST_ATS_PREFRENCE_START;
mps[c_m].partners =
- GNUNET_malloc (num_slaves * sizeof (struct BenchmarkPeer));
+ GNUNET_malloc (num_slaves * sizeof (struct BenchmarkPartner));
mps[c_m].num_partners = num_slaves;
/* Initialize partners */
for (c_s = 0; c_s < num_slaves; c_s++)
sps[c_s].no = c_s + num_masters;
sps[c_s].master = GNUNET_NO;
sps[c_s].partners =
- GNUNET_malloc (num_masters * sizeof (struct BenchmarkPeer));
+ GNUNET_malloc (num_masters * sizeof (struct BenchmarkPartner));
sps[c_s].num_partners = num_masters;
/* Initialize partners */
for (c_m = 0; c_m < num_masters; c_m++)