-static size_t
-comm_send_pong_ready (void *cls, size_t size, void *buf)
-{
- static char msgbuf[TEST_MESSAGE_SIZE];
- struct BenchmarkPartner *p = cls;
- struct GNUNET_MessageHeader *msg;
-
- if (GNUNET_YES == test_core)
- p->cth = NULL;
- else
- p->tth = NULL;
-
- p->messages_sent++;
- p->bytes_sent += TEST_MESSAGE_SIZE;
- p->me->total_messages_sent++;
- p->me->total_bytes_sent += TEST_MESSAGE_SIZE;
-
- msg = (struct GNUNET_MessageHeader *) &msgbuf;
- memset (&msgbuf, 'a', TEST_MESSAGE_SIZE);
- msg->type = htons (TEST_MESSAGE_TYPE_PONG);
- msg->size = htons (TEST_MESSAGE_SIZE);
- memcpy (buf, msg, TEST_MESSAGE_SIZE);
-
- return TEST_MESSAGE_SIZE;
-}
-
-static int
-comm_handle_ping (void *cls, const struct GNUNET_PeerIdentity *other,
- const struct GNUNET_MessageHeader *message)
-{
-
- struct BenchmarkPeer *me = cls;
- struct BenchmarkPartner *p = NULL;
-
- if (NULL == (p = find_partner(me, other)))
- {
- 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;
-}