diff options
author | Christian Grothoff <christian@grothoff.org> | 2019-06-18 10:30:08 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2019-06-18 10:30:08 +0200 |
commit | 9ae7f13f17e3d04d3ba88862299c8e42541eab47 (patch) | |
tree | 167259c402cd199bcbce49f14d6aae20f41425d8 /src/transport | |
parent | 93c332be89c4c65f10b7c4c49b6ed15d91b91884 (diff) | |
download | gnunet-9ae7f13f17e3d04d3ba88862299c8e42541eab47.tar.gz gnunet-9ae7f13f17e3d04d3ba88862299c8e42541eab47.zip |
Introducing GNUNET_Uuid and matching hash map for 128 bit values.
TNG: reducing size of AcknowledgementUUIDPs from 256 bits to 128 bits.
Diffstat (limited to 'src/transport')
-rw-r--r-- | src/transport/gnunet-service-tng.c | 42 |
1 files changed, 19 insertions, 23 deletions
diff --git a/src/transport/gnunet-service-tng.c b/src/transport/gnunet-service-tng.c index 18a80b3c5..eb3cc2de9 100644 --- a/src/transport/gnunet-service-tng.c +++ b/src/transport/gnunet-service-tng.c | |||
@@ -33,8 +33,6 @@ | |||
33 | * do NOT forward it to peers _other_ than the origin, as | 33 | * do NOT forward it to peers _other_ than the origin, as |
34 | * there is clearly a better path directly from the origin to | 34 | * there is clearly a better path directly from the origin to |
35 | * whatever else we could reach. | 35 | * whatever else we could reach. |
36 | * - AcknowledgementUUIDPs are overkill with 256 bits (128 would do) | ||
37 | * => Need 128 bit hash map though! [BANDWIDTH, MEMORY] | ||
38 | * - queue_send_msg by API design has to make a copy | 36 | * - queue_send_msg by API design has to make a copy |
39 | * of the payload, and route_message on top of that requires a malloc/free. | 37 | * of the payload, and route_message on top of that requires a malloc/free. |
40 | * Change design to approximate "zero" copy better... [CPU] | 38 | * Change design to approximate "zero" copy better... [CPU] |
@@ -345,9 +343,9 @@ struct MessageUUIDP | |||
345 | struct AcknowledgementUUIDP | 343 | struct AcknowledgementUUIDP |
346 | { | 344 | { |
347 | /** | 345 | /** |
348 | * The UUID value. Not actually a hash, but a random value. | 346 | * The UUID value. |
349 | */ | 347 | */ |
350 | struct GNUNET_ShortHashCode value; | 348 | struct GNUNET_Uuid value; |
351 | }; | 349 | }; |
352 | 350 | ||
353 | 351 | ||
@@ -2736,7 +2734,7 @@ static struct GNUNET_CONTAINER_MultiPeerMap *ack_cummulators; | |||
2736 | * Map of pending acknowledgements, mapping `struct AcknowledgementUUID` to | 2734 | * Map of pending acknowledgements, mapping `struct AcknowledgementUUID` to |
2737 | * a `struct PendingAcknowledgement`. | 2735 | * a `struct PendingAcknowledgement`. |
2738 | */ | 2736 | */ |
2739 | static struct GNUNET_CONTAINER_MultiShortmap *pending_acks; | 2737 | static struct GNUNET_CONTAINER_MultiUuidmap *pending_acks; |
2740 | 2738 | ||
2741 | /** | 2739 | /** |
2742 | * Map from PIDs to `struct DistanceVector` entries describing | 2740 | * Map from PIDs to `struct DistanceVector` entries describing |
@@ -2910,9 +2908,9 @@ free_pending_acknowledgement (struct PendingAcknowledgement *pa) | |||
2910 | pa->queue = NULL; | 2908 | pa->queue = NULL; |
2911 | } | 2909 | } |
2912 | GNUNET_assert (GNUNET_YES == | 2910 | GNUNET_assert (GNUNET_YES == |
2913 | GNUNET_CONTAINER_multishortmap_remove (pending_acks, | 2911 | GNUNET_CONTAINER_multiuuidmap_remove (pending_acks, |
2914 | &pa->ack_uuid.value, | 2912 | &pa->ack_uuid.value, |
2915 | pa)); | 2913 | pa)); |
2916 | GNUNET_free (pa); | 2914 | GNUNET_free (pa); |
2917 | } | 2915 | } |
2918 | 2916 | ||
@@ -5468,7 +5466,7 @@ cummulative_ack (const struct GNUNET_PeerIdentity *pid, | |||
5468 | 5466 | ||
5469 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 5467 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
5470 | "Scheduling ACK %s for transmission to %s\n", | 5468 | "Scheduling ACK %s for transmission to %s\n", |
5471 | GNUNET_sh2s (&ack_uuid->value), | 5469 | GNUNET_uuid2s (&ack_uuid->value), |
5472 | GNUNET_i2s (pid)); | 5470 | GNUNET_i2s (pid)); |
5473 | ac = GNUNET_CONTAINER_multipeermap_get (ack_cummulators, pid); | 5471 | ac = GNUNET_CONTAINER_multipeermap_get (ack_cummulators, pid); |
5474 | if (NULL == ac) | 5472 | if (NULL == ac) |
@@ -5743,7 +5741,7 @@ handle_reliability_box (void *cls, | |||
5743 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 5741 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
5744 | "Received reliability box from %s with UUID %s of type %u\n", | 5742 | "Received reliability box from %s with UUID %s of type %u\n", |
5745 | GNUNET_i2s (&cmc->im.sender), | 5743 | GNUNET_i2s (&cmc->im.sender), |
5746 | GNUNET_sh2s (&rb->ack_uuid.value), | 5744 | GNUNET_uuid2s (&rb->ack_uuid.value), |
5747 | (unsigned int) ntohs (inbox->type)); | 5745 | (unsigned int) ntohs (inbox->type)); |
5748 | rtt = GNUNET_TIME_UNIT_SECONDS; /* FIXME: should base this on "RTT", but we | 5746 | rtt = GNUNET_TIME_UNIT_SECONDS; /* FIXME: should base this on "RTT", but we |
5749 | do not really have an RTT for the | 5747 | do not really have an RTT for the |
@@ -5981,13 +5979,13 @@ handle_reliability_ack (void *cls, | |||
5981 | for (unsigned int i = 0; i < n_acks; i++) | 5979 | for (unsigned int i = 0; i < n_acks; i++) |
5982 | { | 5980 | { |
5983 | pa = | 5981 | pa = |
5984 | GNUNET_CONTAINER_multishortmap_get (pending_acks, &ack[i].ack_uuid.value); | 5982 | GNUNET_CONTAINER_multiuuidmap_get (pending_acks, &ack[i].ack_uuid.value); |
5985 | if (NULL == pa) | 5983 | if (NULL == pa) |
5986 | { | 5984 | { |
5987 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 5985 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
5988 | "Received ACK from %s with UUID %s which is unknown to us!\n", | 5986 | "Received ACK from %s with UUID %s which is unknown to us!\n", |
5989 | GNUNET_i2s (&cmc->im.sender), | 5987 | GNUNET_i2s (&cmc->im.sender), |
5990 | GNUNET_sh2s (&ack[i].ack_uuid.value)); | 5988 | GNUNET_uuid2s (&ack[i].ack_uuid.value)); |
5991 | GNUNET_STATISTICS_update ( | 5989 | GNUNET_STATISTICS_update ( |
5992 | GST_stats, | 5990 | GST_stats, |
5993 | "# FRAGMENT_ACKS dropped, no matching pending message", | 5991 | "# FRAGMENT_ACKS dropped, no matching pending message", |
@@ -5998,7 +5996,7 @@ handle_reliability_ack (void *cls, | |||
5998 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 5996 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
5999 | "Received ACK from %s with UUID %s\n", | 5997 | "Received ACK from %s with UUID %s\n", |
6000 | GNUNET_i2s (&cmc->im.sender), | 5998 | GNUNET_i2s (&cmc->im.sender), |
6001 | GNUNET_sh2s (&ack[i].ack_uuid.value)); | 5999 | GNUNET_uuid2s (&ack[i].ack_uuid.value)); |
6002 | handle_acknowledged (pa, GNUNET_TIME_relative_ntoh (ack[i].ack_delay)); | 6000 | handle_acknowledged (pa, GNUNET_TIME_relative_ntoh (ack[i].ack_delay)); |
6003 | } | 6001 | } |
6004 | 6002 | ||
@@ -8412,7 +8410,7 @@ prepare_pending_acknowledgement (struct Queue *queue, | |||
8412 | GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_NONCE, | 8410 | GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_NONCE, |
8413 | &pa->ack_uuid, | 8411 | &pa->ack_uuid, |
8414 | sizeof (pa->ack_uuid)); | 8412 | sizeof (pa->ack_uuid)); |
8415 | } while (GNUNET_YES != GNUNET_CONTAINER_multishortmap_put ( | 8413 | } while (GNUNET_YES != GNUNET_CONTAINER_multiuuidmap_put ( |
8416 | pending_acks, | 8414 | pending_acks, |
8417 | &pa->ack_uuid.value, | 8415 | &pa->ack_uuid.value, |
8418 | pa, | 8416 | pa, |
@@ -8425,7 +8423,7 @@ prepare_pending_acknowledgement (struct Queue *queue, | |||
8425 | pa->message_size = pm->bytes_msg; | 8423 | pa->message_size = pm->bytes_msg; |
8426 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 8424 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
8427 | "Waiting for ACKnowledgment `%s' for <%llu>\n", | 8425 | "Waiting for ACKnowledgment `%s' for <%llu>\n", |
8428 | GNUNET_sh2s (&pa->ack_uuid.value), | 8426 | GNUNET_uuid2s (&pa->ack_uuid.value), |
8429 | pm->logging_uuid); | 8427 | pm->logging_uuid); |
8430 | return pa; | 8428 | return pa; |
8431 | } | 8429 | } |
@@ -10017,9 +10015,7 @@ free_validation_state_cb (void *cls, | |||
10017 | * @return #GNUNET_OK (always) | 10015 | * @return #GNUNET_OK (always) |
10018 | */ | 10016 | */ |
10019 | static int | 10017 | static int |
10020 | free_pending_ack_cb (void *cls, | 10018 | free_pending_ack_cb (void *cls, const struct GNUNET_Uuid *key, void *value) |
10021 | const struct GNUNET_ShortHashCode *key, | ||
10022 | void *value) | ||
10023 | { | 10019 | { |
10024 | struct PendingAcknowledgement *pa = value; | 10020 | struct PendingAcknowledgement *pa = value; |
10025 | 10021 | ||
@@ -10085,10 +10081,10 @@ do_shutdown (void *cls) | |||
10085 | NULL); | 10081 | NULL); |
10086 | GNUNET_CONTAINER_multipeermap_destroy (ack_cummulators); | 10082 | GNUNET_CONTAINER_multipeermap_destroy (ack_cummulators); |
10087 | ack_cummulators = NULL; | 10083 | ack_cummulators = NULL; |
10088 | GNUNET_CONTAINER_multishortmap_iterate (pending_acks, | 10084 | GNUNET_CONTAINER_multiuuidmap_iterate (pending_acks, |
10089 | &free_pending_ack_cb, | 10085 | &free_pending_ack_cb, |
10090 | NULL); | 10086 | NULL); |
10091 | GNUNET_CONTAINER_multishortmap_destroy (pending_acks); | 10087 | GNUNET_CONTAINER_multiuuidmap_destroy (pending_acks); |
10092 | pending_acks = NULL; | 10088 | pending_acks = NULL; |
10093 | GNUNET_break (0 == GNUNET_CONTAINER_multipeermap_size (neighbours)); | 10089 | GNUNET_break (0 == GNUNET_CONTAINER_multipeermap_size (neighbours)); |
10094 | GNUNET_CONTAINER_multipeermap_destroy (neighbours); | 10090 | GNUNET_CONTAINER_multipeermap_destroy (neighbours); |
@@ -10142,7 +10138,7 @@ run (void *cls, | |||
10142 | hello_mono_time = GNUNET_TIME_absolute_get_monotonic (c); | 10138 | hello_mono_time = GNUNET_TIME_absolute_get_monotonic (c); |
10143 | GST_cfg = c; | 10139 | GST_cfg = c; |
10144 | backtalkers = GNUNET_CONTAINER_multipeermap_create (16, GNUNET_YES); | 10140 | backtalkers = GNUNET_CONTAINER_multipeermap_create (16, GNUNET_YES); |
10145 | pending_acks = GNUNET_CONTAINER_multishortmap_create (32768, GNUNET_YES); | 10141 | pending_acks = GNUNET_CONTAINER_multiuuidmap_create (32768, GNUNET_YES); |
10146 | ack_cummulators = GNUNET_CONTAINER_multipeermap_create (256, GNUNET_YES); | 10142 | ack_cummulators = GNUNET_CONTAINER_multipeermap_create (256, GNUNET_YES); |
10147 | neighbours = GNUNET_CONTAINER_multipeermap_create (1024, GNUNET_YES); | 10143 | neighbours = GNUNET_CONTAINER_multipeermap_create (1024, GNUNET_YES); |
10148 | links = GNUNET_CONTAINER_multipeermap_create (512, GNUNET_YES); | 10144 | links = GNUNET_CONTAINER_multipeermap_create (512, GNUNET_YES); |