diff options
author | Schanzenbach, Martin <mschanzenbach@posteo.de> | 2020-01-01 13:35:28 +0900 |
---|---|---|
committer | Schanzenbach, Martin <mschanzenbach@posteo.de> | 2020-01-01 13:35:28 +0900 |
commit | 0c5090e7d76fd7c85b92f0c4f918cf5420bd68f8 (patch) | |
tree | 1c2d5d10f4a3d288c42198b7989cd70ac9537f05 /src/transport/test_communicator_basic.c | |
parent | 65b645e3c3910401d43d922d46096aa22c6de9e7 (diff) | |
download | gnunet-0c5090e7d76fd7c85b92f0c4f918cf5420bd68f8.tar.gz gnunet-0c5090e7d76fd7c85b92f0c4f918cf5420bd68f8.zip |
fix backchannel
Diffstat (limited to 'src/transport/test_communicator_basic.c')
-rw-r--r-- | src/transport/test_communicator_basic.c | 37 |
1 files changed, 28 insertions, 9 deletions
diff --git a/src/transport/test_communicator_basic.c b/src/transport/test_communicator_basic.c index 4699b8dd1..c469a55a1 100644 --- a/src/transport/test_communicator_basic.c +++ b/src/transport/test_communicator_basic.c | |||
@@ -76,6 +76,10 @@ static struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue *my_tc; | |||
76 | 76 | ||
77 | #define TOTAL_ITERATIONS 5 | 77 | #define TOTAL_ITERATIONS 5 |
78 | 78 | ||
79 | #define PEER_A 0 | ||
80 | |||
81 | #define PEER_B 1 | ||
82 | |||
79 | static unsigned int iterations_left = TOTAL_ITERATIONS; | 83 | static unsigned int iterations_left = TOTAL_ITERATIONS; |
80 | 84 | ||
81 | #define SHORT_BURST_WINDOW \ | 85 | #define SHORT_BURST_WINDOW \ |
@@ -136,14 +140,12 @@ add_address_cb (void *cls, | |||
136 | aid, | 140 | aid, |
137 | nt); | 141 | nt); |
138 | // addresses[1] = GNUNET_strdup (address); | 142 | // addresses[1] = GNUNET_strdup (address); |
139 | if ((0 == strcmp ((char*) cls, cfg_peers_name[NUM_PEERS - 1])) && | 143 | if ((0 == strcmp ((char*) cls, cfg_peers_name[PEER_B])) && |
140 | (GNUNET_NO == queue_est)) | 144 | (GNUNET_NO == queue_est)) |
141 | { | 145 | { |
142 | queue_est = GNUNET_YES; | 146 | queue_est = GNUNET_YES; |
143 | GNUNET_TRANSPORT_TESTING_transport_communicator_open_queue (tc_hs[0], | 147 | GNUNET_TRANSPORT_TESTING_transport_communicator_open_queue (tc_hs[PEER_A], |
144 | &peer_id[ | 148 | &peer_id[PEER_B], |
145 | NUM_PEERS | ||
146 | - 1], | ||
147 | address); | 149 | address); |
148 | } | 150 | } |
149 | } | 151 | } |
@@ -176,6 +178,20 @@ queue_create_reply_cb (void *cls, | |||
176 | } | 178 | } |
177 | 179 | ||
178 | 180 | ||
181 | static struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle * | ||
182 | handle_backchannel_cb (void *cls, | ||
183 | struct GNUNET_MessageHeader *msg, | ||
184 | struct GNUNET_PeerIdentity *pid) | ||
185 | { | ||
186 | struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h = cls; | ||
187 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Handling BC message...\n"); | ||
188 | if (0 == memcmp (&peer_id[PEER_A], pid, sizeof (*pid))) | ||
189 | return tc_hs[PEER_A]; | ||
190 | else | ||
191 | return tc_hs[PEER_B]; | ||
192 | } | ||
193 | |||
194 | |||
179 | static char* | 195 | static char* |
180 | make_payload (size_t payload_size) | 196 | make_payload (size_t payload_size) |
181 | { | 197 | { |
@@ -366,8 +382,9 @@ incoming_message_cb (void *cls, | |||
366 | GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE, | 382 | GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE, |
367 | "Short size packet test done.\n"); | 383 | "Short size packet test done.\n"); |
368 | char *goodput = GNUNET_STRINGS_byte_size_fancy ((SHORT_MESSAGE_SIZE | 384 | char *goodput = GNUNET_STRINGS_byte_size_fancy ((SHORT_MESSAGE_SIZE |
369 | * num_received * 1000 * 1000) | 385 | * num_received * 1000 |
370 | / duration.rel_value_us); | 386 | * 1000) |
387 | / duration.rel_value_us); | ||
371 | GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE, | 388 | GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE, |
372 | "%lu/%lu packets in %llu us (%s/s) -- avg latency: %llu us\n", | 389 | "%lu/%lu packets in %llu us (%s/s) -- avg latency: %llu us\n", |
373 | (unsigned long) num_received, | 390 | (unsigned long) num_received, |
@@ -402,8 +419,9 @@ incoming_message_cb (void *cls, | |||
402 | GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE, | 419 | GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE, |
403 | "Long size packet test done.\n"); | 420 | "Long size packet test done.\n"); |
404 | char *goodput = GNUNET_STRINGS_byte_size_fancy ((LONG_MESSAGE_SIZE | 421 | char *goodput = GNUNET_STRINGS_byte_size_fancy ((LONG_MESSAGE_SIZE |
405 | * num_received * 1000 * 1000) | 422 | * num_received * 1000 |
406 | / duration.rel_value_us); | 423 | * 1000) |
424 | / duration.rel_value_us); | ||
407 | 425 | ||
408 | GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE, | 426 | GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE, |
409 | "%lu/%lu packets in %llu us (%s/s) -- avg latency: %llu us\n", | 427 | "%lu/%lu packets in %llu us (%s/s) -- avg latency: %llu us\n", |
@@ -496,6 +514,7 @@ run (void *cls) | |||
496 | &queue_create_reply_cb, | 514 | &queue_create_reply_cb, |
497 | &add_queue_cb, | 515 | &add_queue_cb, |
498 | &incoming_message_cb, | 516 | &incoming_message_cb, |
517 | &handle_backchannel_cb, | ||
499 | cfg_peers_name[i]); /* cls */ | 518 | cfg_peers_name[i]); /* cls */ |
500 | } | 519 | } |
501 | GNUNET_SCHEDULER_add_shutdown (&do_shutdown, | 520 | GNUNET_SCHEDULER_add_shutdown (&do_shutdown, |