diff options
author | t3sserakt <t3ss@posteo.de> | 2024-04-25 14:04:11 +0200 |
---|---|---|
committer | t3sserakt <t3ss@posteo.de> | 2024-04-25 14:04:11 +0200 |
commit | 8de6f974d0fe210e03e891b365613e0bc4a2ceea (patch) | |
tree | 22339ebcd42e256e465ee4e55c9d79461c15a7d8 | |
parent | 3587d4a1956d41554415046794c7647f3db4860a (diff) | |
download | gnunet-dev/t3ss/probnatt.tar.gz gnunet-dev/t3ss/probnatt.zip |
Moved sync protocol to util.dev/t3ss/probnatt
-rw-r--r-- | src/include/gnunet_protocols.h | 14 | ||||
-rw-r--r-- | src/include/gnunet_util_lib.h | 1 | ||||
-rw-r--r-- | src/lib/util/Makefile.am | 1 | ||||
-rw-r--r-- | src/service/transport/gnunet-service-transport.c | 101 |
4 files changed, 43 insertions, 74 deletions
diff --git a/src/include/gnunet_protocols.h b/src/include/gnunet_protocols.h index 6ab008d16..54656ea49 100644 --- a/src/include/gnunet_protocols.h +++ b/src/include/gnunet_protocols.h | |||
@@ -3653,6 +3653,20 @@ extern "C" { | |||
3653 | */ | 3653 | */ |
3654 | #define GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_SET_EDIT_CANCEL 1752 | 3654 | #define GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_SET_EDIT_CANCEL 1752 |
3655 | 3655 | ||
3656 | /*********************************************************************************/ | ||
3657 | |||
3658 | /*********************************************************************************/ | ||
3659 | /********************************** UTIL (cont.) **************************/ | ||
3660 | /*********************************************************************************/ | ||
3661 | /* NAMESTORE: message types 1801-1810 | ||
3662 | */ | ||
3663 | |||
3664 | /** | ||
3665 | * Message exchanged between peers for burst synchronisation. | ||
3666 | */ | ||
3667 | #define GNUNET_TYPE_BURST_SYNC 1801 | ||
3668 | |||
3669 | |||
3656 | /** | 3670 | /** |
3657 | * Type used to match 'all' message types. | 3671 | * Type used to match 'all' message types. |
3658 | */ | 3672 | */ |
diff --git a/src/include/gnunet_util_lib.h b/src/include/gnunet_util_lib.h index ee850bc3c..4bca96282 100644 --- a/src/include/gnunet_util_lib.h +++ b/src/include/gnunet_util_lib.h | |||
@@ -77,6 +77,7 @@ extern "C" | |||
77 | #include "gnunet_helper_lib.h" | 77 | #include "gnunet_helper_lib.h" |
78 | #include "gnunet_mst_lib.h" | 78 | #include "gnunet_mst_lib.h" |
79 | #include "gnunet_mq_lib.h" | 79 | #include "gnunet_mq_lib.h" |
80 | #include "gnunet_nat_lib.h" | ||
80 | #include "gnunet_nt_lib.h" | 81 | #include "gnunet_nt_lib.h" |
81 | #include "gnunet_nc_lib.h" | 82 | #include "gnunet_nc_lib.h" |
82 | #include "gnunet_op_lib.h" | 83 | #include "gnunet_op_lib.h" |
diff --git a/src/lib/util/Makefile.am b/src/lib/util/Makefile.am index 00538847b..73b2835e9 100644 --- a/src/lib/util/Makefile.am +++ b/src/lib/util/Makefile.am | |||
@@ -82,6 +82,7 @@ libgnunetutil_la_SOURCES = \ | |||
82 | load.c \ | 82 | load.c \ |
83 | mst.c \ | 83 | mst.c \ |
84 | mq.c \ | 84 | mq.c \ |
85 | nat.c \ | ||
85 | nc.c \ | 86 | nc.c \ |
86 | network.c \ | 87 | network.c \ |
87 | nt.c \ | 88 | nt.c \ |
diff --git a/src/service/transport/gnunet-service-transport.c b/src/service/transport/gnunet-service-transport.c index c89779434..aab359518 100644 --- a/src/service/transport/gnunet-service-transport.c +++ b/src/service/transport/gnunet-service-transport.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | Copyright (C) 2010-2016, 2018, 2019 GNUnet e.V. | 3 | Copyright (C) 2010-2016, 2018, 2019 GNUnet e.V. |
4 | 4 | ||
@@ -1601,22 +1601,6 @@ struct VirtualLink | |||
1601 | * Are we ready to start the burst? | 1601 | * Are we ready to start the burst? |
1602 | */ | 1602 | */ |
1603 | enum GNUNET_GenericReturnValue sync_ready; | 1603 | enum GNUNET_GenericReturnValue sync_ready; |
1604 | |||
1605 | /** | ||
1606 | * Did the target tell us it is ready to start the burst? | ||
1607 | */ | ||
1608 | enum GNUNET_GenericReturnValue other_sync_ready; | ||
1609 | |||
1610 | /** | ||
1611 | * Did we start the burst? | ||
1612 | */ | ||
1613 | enum GNUNET_GenericReturnValue burst_sync; | ||
1614 | |||
1615 | /** | ||
1616 | * Factor we multiply the avarage RTT with for calculating the the delay to start the burst. | ||
1617 | * The factor depends on which peer first got ready to sync. | ||
1618 | */ | ||
1619 | unsigned long long rtt_factor; | ||
1620 | }; | 1604 | }; |
1621 | 1605 | ||
1622 | 1606 | ||
@@ -7432,6 +7416,10 @@ learn_dv_path (const struct GNUNET_PeerIdentity *path, | |||
7432 | q_timeout = GNUNET_TIME_UNIT_ZERO_ABS; | 7416 | q_timeout = GNUNET_TIME_UNIT_ZERO_ABS; |
7433 | for (struct Queue *q = n->queue_head; NULL != q; q = q->next_neighbour) | 7417 | for (struct Queue *q = n->queue_head; NULL != q; q = q->next_neighbour) |
7434 | q_timeout = GNUNET_TIME_absolute_max (q_timeout, q->validated_until); | 7418 | q_timeout = GNUNET_TIME_absolute_max (q_timeout, q->validated_until); |
7419 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
7420 | "remainig %lu to %s\n", | ||
7421 | GNUNET_TIME_absolute_get_remaining (q_timeout).rel_value_us, | ||
7422 | GNUNET_i2s (&n->pid)); | ||
7435 | if (0 != GNUNET_TIME_absolute_get_remaining (q_timeout).rel_value_us) | 7423 | if (0 != GNUNET_TIME_absolute_get_remaining (q_timeout).rel_value_us) |
7436 | { | 7424 | { |
7437 | /* Useless path: we have a direct active connection to some hop | 7425 | /* Useless path: we have a direct active connection to some hop |
@@ -9746,8 +9734,11 @@ calculate_rtt (struct DistanceVector *dv) | |||
9746 | static void | 9734 | static void |
9747 | start_burst (void *cls) | 9735 | start_burst (void *cls) |
9748 | { | 9736 | { |
9737 | struct GNUNET_StartBurstCls *sb_cls = cls; | ||
9738 | |||
9749 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 9739 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
9750 | "Burst started \n"); | 9740 | "Burst started \n"); |
9741 | GNUNET_free (sb_cls); | ||
9751 | } | 9742 | } |
9752 | 9743 | ||
9753 | /** | 9744 | /** |
@@ -9794,76 +9785,38 @@ handle_flow_control (void *cls, const struct TransportFlowControlMessage *fc) | |||
9794 | vl, | 9785 | vl, |
9795 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); | 9786 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); |
9796 | } | 9787 | } |
9797 | if (NULL != vl->n && GNUNET_YES != vl->burst_sync) | 9788 | if (NULL != vl->n) |
9798 | { | 9789 | { |
9799 | for (struct Queue *q = vl->n->queue_head; NULL != q; q = q->next_neighbour) | 9790 | for (struct Queue *q = vl->n->queue_head; NULL != q; q = q->next_neighbour) |
9800 | q_timeout = GNUNET_TIME_absolute_max (q_timeout, q->validated_until); | 9791 | q_timeout = GNUNET_TIME_absolute_max (q_timeout, q->validated_until); |
9801 | } | 9792 | } |
9802 | 9793 | ||
9803 | if ((NULL == vl->n || | 9794 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
9795 | "remaining %lu timeout for neighbour %p\n", | ||
9796 | GNUNET_TIME_absolute_get_remaining (q_timeout).rel_value_us, | ||
9797 | vl->n); | ||
9798 | if (NULL == vl->n || | ||
9804 | 0 == GNUNET_TIME_absolute_get_remaining (q_timeout).rel_value_us) | 9799 | 0 == GNUNET_TIME_absolute_get_remaining (q_timeout).rel_value_us) |
9805 | && GNUNET_YES != vl->burst_sync) | ||
9806 | { | 9800 | { |
9807 | struct GNUNET_TIME_Relative rtt; | 9801 | struct GNUNET_TIME_Relative rtt; |
9808 | struct GNUNET_TIME_Relative rel1; | 9802 | struct GNUNET_BurstSync burst_sync; |
9809 | struct GNUNET_TIME_Relative rel2; | 9803 | struct GNUNET_StartBurstCls *cls; |
9810 | 9804 | ||
9805 | cls = GNUNET_new (struct GNUNET_StartBurstCls); | ||
9811 | if (NULL != vl->dv) | 9806 | if (NULL != vl->dv) |
9812 | rtt = calculate_rtt (vl->dv); | 9807 | rtt = calculate_rtt (vl->dv); |
9813 | else | 9808 | else |
9814 | rtt = GNUNET_TIME_UNIT_FOREVER_REL; | 9809 | rtt = GNUNET_TIME_UNIT_FOREVER_REL; |
9815 | vl->other_rtt = GNUNET_TIME_relative_ntoh (fc->rtt); | 9810 | burst_sync.rtt_avarage = fc->rtt; |
9816 | vl->other_sync_ready = fc->sync_ready; | 9811 | burst_sync.sync_ready = fc->sync_ready; |
9817 | rel1 = GNUNET_TIME_relative_subtract (vl->other_rtt, rtt); | 9812 | |
9818 | rel2 = GNUNET_TIME_relative_subtract (rtt, vl->other_rtt); | 9813 | vl->sync_ready = GNUNET_is_burst_ready (rtt, |
9819 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 9814 | &burst_sync, |
9820 | "other sync ready %u, other rtt %llu and rtt %llu rel1 %llu rel2 %llu\n", | 9815 | &start_burst, |
9821 | vl->other_sync_ready, | 9816 | cls); |
9822 | vl->other_rtt.rel_value_us, | 9817 | if (NULL != vl->burst_task && |
9823 | rtt.rel_value_us, | 9818 | GNUNET_NO == vl->sync_ready); |
9824 | rel1.rel_value_us, | 9819 | vl->burst_task = NULL; |
9825 | rel2.rel_value_us); | ||
9826 | if ((vl->other_rtt.rel_value_us != GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us && | ||
9827 | rtt.rel_value_us != GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us) && | ||
9828 | rel1.rel_value_us < RTT_DIFF.rel_value_us && | ||
9829 | rel2.rel_value_us < RTT_DIFF.rel_value_us) | ||
9830 | { | ||
9831 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
9832 | "other sync ready 1\n"); | ||
9833 | if (GNUNET_YES == vl->other_sync_ready && GNUNET_YES == vl->sync_ready) | ||
9834 | { | ||
9835 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
9836 | "other sync ready 2\n"); | ||
9837 | vl->burst_sync = GNUNET_YES; | ||
9838 | vl->burst_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (rtt, vl->rtt_factor), &start_burst, vl); | ||
9839 | } | ||
9840 | else if (GNUNET_NO == vl->other_sync_ready) | ||
9841 | { | ||
9842 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
9843 | "other sync ready 3\n"); | ||
9844 | if (NULL != vl->burst_task) | ||
9845 | { | ||
9846 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
9847 | "other sync ready 4\n"); | ||
9848 | GNUNET_SCHEDULER_cancel (vl->burst_task); | ||
9849 | vl->burst_task = NULL; | ||
9850 | } | ||
9851 | vl->rtt_factor = 4; | ||
9852 | } | ||
9853 | else | ||
9854 | { | ||
9855 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
9856 | "other sync ready 5\n"); | ||
9857 | vl->rtt_factor = 2; | ||
9858 | } | ||
9859 | vl->sync_ready = GNUNET_YES; | ||
9860 | } | ||
9861 | else | ||
9862 | { | ||
9863 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
9864 | "other sync ready 6\n"); | ||
9865 | vl->sync_ready = GNUNET_NO; | ||
9866 | } | ||
9867 | } | 9820 | } |
9868 | if (0 != ntohl (fc->number_of_addresses)) | 9821 | if (0 != ntohl (fc->number_of_addresses)) |
9869 | { | 9822 | { |