- if (NULL == p)
- {
- GNUNET_break(0);
- return GNUNET_SYSERR;
- }
-
- GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
- "Slave [%u]: Received PING from [%u], sending PONG\n", me->no,
- p->dest->no);
-
- p->messages_received++;
- p->bytes_received += TEST_MESSAGE_SIZE;
- p->me->total_messages_received++;
- p->me->total_bytes_received += TEST_MESSAGE_SIZE;
-
- if (GNUNET_YES == test_core)
- {
- GNUNET_assert (NULL == p->cth);
- p->cth = GNUNET_CORE_notify_transmit_ready (me->ch, GNUNET_NO, 0,
- GNUNET_TIME_UNIT_MINUTES, &p->dest->id, TEST_MESSAGE_SIZE,
- &comm_send_pong_ready, p);
- }
- else
- {
- GNUNET_assert (NULL == p->tth);
- p->tth = GNUNET_TRANSPORT_notify_transmit_ready (me->th, &p->dest->id,
- TEST_MESSAGE_SIZE, 0, GNUNET_TIME_UNIT_MINUTES, &comm_send_pong_ready,
- p);
- }
- return GNUNET_OK;
-}
-
-static int
-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)
- {
- 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->messages_received++;
- p->bytes_received += TEST_MESSAGE_SIZE;
- p->me->total_messages_received++;
- p->me->total_bytes_received += TEST_MESSAGE_SIZE;
- p->total_app_rtt += GNUNET_TIME_absolute_get_difference(p->last_message_sent,
- GNUNET_TIME_absolute_get()).rel_value_us;
-
- comm_schedule_send (p);
- return GNUNET_OK;
-}
-
-static void *
-core_connect_adapter (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg)
-{
- struct BenchmarkPeer *me = cls;
-
- static const struct GNUNET_CORE_MessageHandler handlers[] = { {
- &comm_handle_ping, TEST_MESSAGE_TYPE_PING, 0 }, { &comm_handle_pong,
- TEST_MESSAGE_TYPE_PONG, 0 }, { NULL, 0, 0 } };
-
- me->ch = GNUNET_CORE_connect (cfg, me, NULL, comm_connect_cb,
- comm_disconnect_cb, NULL, GNUNET_NO, NULL, GNUNET_NO, handlers);
- if (NULL == me->ch)
- GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Failed to create core connection \n");
- return me->ch;
-}
-
-static void
-core_disconnect_adapter (void *cls, void *op_result)
-{
- struct BenchmarkPeer *me = cls;
-
- GNUNET_CORE_disconnect (me->ch);
- me->ch = NULL;
-}
-
-static void
-comm_connect_completion_cb (void *cls, struct GNUNET_TESTBED_Operation *op,
- void *ca_result, const char *emsg)
-{
- static int comm_done = 0;
- if ((NULL != emsg) || (NULL == ca_result))
- {
- GNUNET_log(GNUNET_ERROR_TYPE_INFO, _("Initialization failed, shutdown\n"));
- GNUNET_break(0);
- if (GNUNET_SCHEDULER_NO_TASK != shutdown_task)
- GNUNET_SCHEDULER_cancel (shutdown_task);
- shutdown_task = GNUNET_SCHEDULER_add_now (do_shutdown, NULL );
- return;
- }
- comm_done++;
-
- if (comm_done == num_slaves + num_masters)
- {
- GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Connected to all %s services\n",
- (GNUNET_YES == test_core) ? "CORE" : "TRANSPORT");
- state.connected_COMM_service = GNUNET_YES;
- GNUNET_SCHEDULER_add_now (&do_connect_peers, NULL );
- }