diff options
author | Julius Bünger <buenger@mytum.de> | 2019-04-08 00:55:35 +0200 |
---|---|---|
committer | Julius Bünger <buenger@mytum.de> | 2019-04-08 00:56:13 +0200 |
commit | 3afe1a3435697b01fee557420a701fba1821dbe5 (patch) | |
tree | d829a665412d2d59bccc77df309bd4d75a9c9ded /src/rps/gnunet-rps-profiler.c | |
parent | b1d840b2104b9cf4a1cd6997bce39bd4b6c1b8bf (diff) | |
download | gnunet-3afe1a3435697b01fee557420a701fba1821dbe5.tar.gz gnunet-3afe1a3435697b01fee557420a701fba1821dbe5.zip |
RPS: Retrieve more info from sampler for profiling
Diffstat (limited to 'src/rps/gnunet-rps-profiler.c')
-rw-r--r-- | src/rps/gnunet-rps-profiler.c | 91 |
1 files changed, 86 insertions, 5 deletions
diff --git a/src/rps/gnunet-rps-profiler.c b/src/rps/gnunet-rps-profiler.c index a852d94b1..ffc9d6f7e 100644 --- a/src/rps/gnunet-rps-profiler.c +++ b/src/rps/gnunet-rps-profiler.c | |||
@@ -429,7 +429,7 @@ struct PendingReply | |||
429 | /** | 429 | /** |
430 | * Handle to the request we are waiting for | 430 | * Handle to the request we are waiting for |
431 | */ | 431 | */ |
432 | struct GNUNET_RPS_Request_Handle *req_handle; | 432 | struct GNUNET_RPS_Request_Handle_Single_Info *req_handle; |
433 | 433 | ||
434 | /** | 434 | /** |
435 | * The peer that requested | 435 | * The peer that requested |
@@ -1040,7 +1040,7 @@ cancel_request (struct PendingReply *pending_rep) | |||
1040 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1040 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1041 | "Cancelling rps get reply\n"); | 1041 | "Cancelling rps get reply\n"); |
1042 | GNUNET_assert (NULL != pending_rep->req_handle); | 1042 | GNUNET_assert (NULL != pending_rep->req_handle); |
1043 | GNUNET_RPS_request_cancel (pending_rep->req_handle); | 1043 | GNUNET_RPS_request_single_info_cancel (pending_rep->req_handle); |
1044 | pending_rep->req_handle = NULL; | 1044 | pending_rep->req_handle = NULL; |
1045 | GNUNET_free (pending_rep); | 1045 | GNUNET_free (pending_rep); |
1046 | pending_rep = NULL; | 1046 | pending_rep = NULL; |
@@ -1489,6 +1489,13 @@ default_reply_handle (void *cls, | |||
1489 | } | 1489 | } |
1490 | } | 1490 | } |
1491 | 1491 | ||
1492 | |||
1493 | static void | ||
1494 | profiler_reply_handle_info (void *cls, | ||
1495 | const struct GNUNET_PeerIdentity *recv_peer, | ||
1496 | double probability, | ||
1497 | uint32_t num_observed); | ||
1498 | |||
1492 | /** | 1499 | /** |
1493 | * Request random peers. | 1500 | * Request random peers. |
1494 | */ | 1501 | */ |
@@ -1510,9 +1517,12 @@ request_peers (void *cls) | |||
1510 | "Requesting one peer\n"); | 1517 | "Requesting one peer\n"); |
1511 | pending_rep = GNUNET_new (struct PendingReply); | 1518 | pending_rep = GNUNET_new (struct PendingReply); |
1512 | pending_rep->rps_peer = rps_peer; | 1519 | pending_rep->rps_peer = rps_peer; |
1513 | pending_rep->req_handle = GNUNET_RPS_request_peers (rps_peer->rps_handle, | 1520 | //pending_rep->req_handle = GNUNET_RPS_request_peers (rps_peer->rps_handle, |
1514 | 1, | 1521 | // 1, |
1515 | cur_test_run.reply_handle, | 1522 | // cur_test_run.reply_handle, |
1523 | // pending_rep); | ||
1524 | pending_rep->req_handle = GNUNET_RPS_request_peer_info (rps_peer->rps_handle, | ||
1525 | profiler_reply_handle_info, | ||
1516 | pending_rep); | 1526 | pending_rep); |
1517 | GNUNET_CONTAINER_DLL_insert_tail (rps_peer->pending_rep_head, | 1527 | GNUNET_CONTAINER_DLL_insert_tail (rps_peer->pending_rep_head, |
1518 | rps_peer->pending_rep_tail, | 1528 | rps_peer->pending_rep_tail, |
@@ -1979,6 +1989,77 @@ profiler_reply_handle (void *cls, | |||
1979 | } | 1989 | } |
1980 | 1990 | ||
1981 | 1991 | ||
1992 | /** | ||
1993 | * Callback to call on receipt of a reply | ||
1994 | * | ||
1995 | * @param cls closure | ||
1996 | * @param n number of peers | ||
1997 | * @param recv_peers the received peers | ||
1998 | */ | ||
1999 | static void | ||
2000 | profiler_reply_handle_info (void *cls, | ||
2001 | const struct GNUNET_PeerIdentity *recv_peer, | ||
2002 | double probability, | ||
2003 | uint32_t num_observed) | ||
2004 | { | ||
2005 | struct RPSPeer *rps_peer; | ||
2006 | struct RPSPeer *rcv_rps_peer; | ||
2007 | char file_name_buf[128]; | ||
2008 | char file_name_dh_buf[128]; | ||
2009 | char file_name_dhr_buf[128]; | ||
2010 | char file_name_dhru_buf[128]; | ||
2011 | char *file_name = file_name_buf; | ||
2012 | char *file_name_dh = file_name_dh_buf; | ||
2013 | char *file_name_dhr = file_name_dhr_buf; | ||
2014 | char *file_name_dhru = file_name_dhru_buf; | ||
2015 | unsigned int i; | ||
2016 | struct PendingReply *pending_rep = (struct PendingReply *) cls; | ||
2017 | |||
2018 | pending_rep->req_handle = NULL; | ||
2019 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "profiler_reply_handle()\n"); | ||
2020 | rps_peer = pending_rep->rps_peer; | ||
2021 | (void) GNUNET_asprintf (&file_name, | ||
2022 | "/tmp/rps/received_ids-%u", | ||
2023 | rps_peer->index); | ||
2024 | |||
2025 | (void) GNUNET_asprintf (&file_name_dh, | ||
2026 | "/tmp/rps/diehard_input-%u", | ||
2027 | rps_peer->index); | ||
2028 | (void) GNUNET_asprintf (&file_name_dhr, | ||
2029 | "/tmp/rps/diehard_input_raw-%u", | ||
2030 | rps_peer->index); | ||
2031 | (void) GNUNET_asprintf (&file_name_dhru, | ||
2032 | "/tmp/rps/diehard_input_raw_aligned-%u", | ||
2033 | rps_peer->index); | ||
2034 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
2035 | "[%s] got peer with info:\n", | ||
2036 | GNUNET_i2s (rps_peer->peer_id)); | ||
2037 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
2038 | " %s\n", | ||
2039 | GNUNET_i2s (recv_peer)); | ||
2040 | tofile (file_name, | ||
2041 | "%s %d %" PRIu32 " \n", | ||
2042 | GNUNET_i2s_full (recv_peer), | ||
2043 | probability, | ||
2044 | num_observed); | ||
2045 | rcv_rps_peer = GNUNET_CONTAINER_multipeermap_get (peer_map, recv_peer); | ||
2046 | GNUNET_assert (NULL != rcv_rps_peer); | ||
2047 | tofile (file_name_dh, | ||
2048 | "%" PRIu32 "\n", | ||
2049 | (uint32_t) rcv_rps_peer->index); | ||
2050 | #ifdef TO_FILE | ||
2051 | to_file_raw (file_name_dhr, | ||
2052 | (char *) &rcv_rps_peer->index, | ||
2053 | sizeof (uint32_t)); | ||
2054 | to_file_raw_unaligned (file_name_dhru, | ||
2055 | (char *) &rcv_rps_peer->index, | ||
2056 | sizeof (uint32_t), | ||
2057 | bits_needed); | ||
2058 | #endif /* TO_FILE */ | ||
2059 | default_reply_handle (cls, 1, recv_peer); | ||
2060 | } | ||
2061 | |||
2062 | |||
1982 | static void | 2063 | static void |
1983 | profiler_cb (struct RPSPeer *rps_peer) | 2064 | profiler_cb (struct RPSPeer *rps_peer) |
1984 | { | 2065 | { |