diff options
author | Bart Polot <bart@net.in.tum.de> | 2013-07-10 15:10:59 +0000 |
---|---|---|
committer | Bart Polot <bart@net.in.tum.de> | 2013-07-10 15:10:59 +0000 |
commit | 096ad74fb4bc765606db9686974d00c99723fe9c (patch) | |
tree | b6df8e926aa266c0f19d144c853c3c400d3615e6 /src/mesh/gnunet-service-mesh.c | |
parent | 2693a5792de2eb435c228b65834d6c8f87b60d5c (diff) | |
download | gnunet-096ad74fb4bc765606db9686974d00c99723fe9c.tar.gz gnunet-096ad74fb4bc765606db9686974d00c99723fe9c.zip |
- use different DATA ACK for both directions
Diffstat (limited to 'src/mesh/gnunet-service-mesh.c')
-rw-r--r-- | src/mesh/gnunet-service-mesh.c | 38 |
1 files changed, 23 insertions, 15 deletions
diff --git a/src/mesh/gnunet-service-mesh.c b/src/mesh/gnunet-service-mesh.c index 8947e7175..1d87dcf73 100644 --- a/src/mesh/gnunet-service-mesh.c +++ b/src/mesh/gnunet-service-mesh.c | |||
@@ -992,6 +992,10 @@ send_client_tunnel_create (struct MeshTunnel *t) | |||
992 | msg.header.type = htons (GNUNET_MESSAGE_TYPE_MESH_LOCAL_TUNNEL_CREATE); | 992 | msg.header.type = htons (GNUNET_MESSAGE_TYPE_MESH_LOCAL_TUNNEL_CREATE); |
993 | msg.tunnel_id = htonl (t->local_tid_dest); | 993 | msg.tunnel_id = htonl (t->local_tid_dest); |
994 | msg.port = htonl (t->port); | 994 | msg.port = htonl (t->port); |
995 | msg.options = 0; | ||
996 | msg.options |= GNUNET_YES == t->reliable ? GNUNET_MESH_OPTION_RELIABLE : 0; | ||
997 | msg.options |= GNUNET_YES == t->nobuffer ? GNUNET_MESH_OPTION_NOBUFFER : 0; | ||
998 | msg.options = htonl (msg.options); | ||
995 | GNUNET_PEER_resolve (t->id.oid, &msg.peer); | 999 | GNUNET_PEER_resolve (t->id.oid, &msg.peer); |
996 | GNUNET_SERVER_notification_context_unicast (nc, t->client->handle, | 1000 | GNUNET_SERVER_notification_context_unicast (nc, t->client->handle, |
997 | &msg.header, GNUNET_NO); | 1001 | &msg.header, GNUNET_NO); |
@@ -2017,7 +2021,7 @@ tunnel_send_fwd_data_ack (struct MeshTunnel *t) | |||
2017 | { | 2021 | { |
2018 | struct GNUNET_MESH_DataACK msg; | 2022 | struct GNUNET_MESH_DataACK msg; |
2019 | 2023 | ||
2020 | msg.header.type = htons (GNUNET_MESSAGE_TYPE_MESH_DATA_ACK); | 2024 | msg.header.type = htons (GNUNET_MESSAGE_TYPE_MESH_UNICAST_ACK); |
2021 | msg.header.size = htons (sizeof (msg)); | 2025 | msg.header.size = htons (sizeof (msg)); |
2022 | msg.tid = htonl (t->id.tid); | 2026 | msg.tid = htonl (t->id.tid); |
2023 | GNUNET_PEER_resolve (t->id.oid, &msg.oid); | 2027 | GNUNET_PEER_resolve (t->id.oid, &msg.oid); |
@@ -2038,7 +2042,7 @@ tunnel_send_bck_data_ack (struct MeshTunnel *t) | |||
2038 | { | 2042 | { |
2039 | struct GNUNET_MESH_DataACK msg; | 2043 | struct GNUNET_MESH_DataACK msg; |
2040 | 2044 | ||
2041 | msg.header.type = htons (GNUNET_MESSAGE_TYPE_MESH_DATA_ACK); | 2045 | msg.header.type = htons (GNUNET_MESSAGE_TYPE_MESH_TO_ORIG_ACK); |
2042 | msg.header.size = htons (sizeof (msg)); | 2046 | msg.header.size = htons (sizeof (msg)); |
2043 | msg.tid = htonl (t->id.tid); | 2047 | msg.tid = htonl (t->id.tid); |
2044 | GNUNET_PEER_resolve (t->id.oid, &msg.oid); | 2048 | GNUNET_PEER_resolve (t->id.oid, &msg.oid); |
@@ -2084,7 +2088,7 @@ tunnel_send_fwd_ack (struct MeshTunnel *t, uint16_t type) | |||
2084 | return; | 2088 | return; |
2085 | case GNUNET_MESSAGE_TYPE_MESH_LOCAL_ACK: | 2089 | case GNUNET_MESSAGE_TYPE_MESH_LOCAL_ACK: |
2086 | break; | 2090 | break; |
2087 | case GNUNET_MESSAGE_TYPE_MESH_DATA_ACK: | 2091 | case GNUNET_MESSAGE_TYPE_MESH_UNICAST_ACK: |
2088 | tunnel_send_fwd_data_ack (t); | 2092 | tunnel_send_fwd_data_ack (t); |
2089 | break; | 2093 | break; |
2090 | case GNUNET_MESSAGE_TYPE_MESH_POLL: | 2094 | case GNUNET_MESSAGE_TYPE_MESH_POLL: |
@@ -2169,7 +2173,7 @@ tunnel_send_bck_ack (struct MeshTunnel *t, uint16_t type) | |||
2169 | return; | 2173 | return; |
2170 | case GNUNET_MESSAGE_TYPE_MESH_LOCAL_ACK: | 2174 | case GNUNET_MESSAGE_TYPE_MESH_LOCAL_ACK: |
2171 | break; | 2175 | break; |
2172 | case GNUNET_MESSAGE_TYPE_MESH_DATA_ACK: | 2176 | case GNUNET_MESSAGE_TYPE_MESH_TO_ORIG_ACK: |
2173 | tunnel_send_bck_data_ack (t); | 2177 | tunnel_send_bck_data_ack (t); |
2174 | /* fall through */ | 2178 | /* fall through */ |
2175 | case GNUNET_MESSAGE_TYPE_MESH_PATH_ACK: | 2179 | case GNUNET_MESSAGE_TYPE_MESH_PATH_ACK: |
@@ -3034,6 +3038,8 @@ queue_send (void *cls, size_t size, void *buf) | |||
3034 | { | 3038 | { |
3035 | case 0: | 3039 | case 0: |
3036 | case GNUNET_MESSAGE_TYPE_MESH_ACK: | 3040 | case GNUNET_MESSAGE_TYPE_MESH_ACK: |
3041 | case GNUNET_MESSAGE_TYPE_MESH_UNICAST_ACK: | ||
3042 | case GNUNET_MESSAGE_TYPE_MESH_TO_ORIG_ACK: | ||
3037 | case GNUNET_MESSAGE_TYPE_MESH_POLL: | 3043 | case GNUNET_MESSAGE_TYPE_MESH_POLL: |
3038 | case GNUNET_MESSAGE_TYPE_MESH_PATH_BROKEN: | 3044 | case GNUNET_MESSAGE_TYPE_MESH_PATH_BROKEN: |
3039 | case GNUNET_MESSAGE_TYPE_MESH_PATH_DESTROY: | 3045 | case GNUNET_MESSAGE_TYPE_MESH_PATH_DESTROY: |
@@ -3658,7 +3664,6 @@ handle_mesh_unicast (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
3658 | " pid %u not seen yet, forwarding\n", pid); | 3664 | " pid %u not seen yet, forwarding\n", pid); |
3659 | t->prev_fc.last_pid_recv = pid; | 3665 | t->prev_fc.last_pid_recv = pid; |
3660 | tunnel_send_client_ucast (t, msg); | 3666 | tunnel_send_client_ucast (t, msg); |
3661 | tunnel_send_fwd_ack (t, GNUNET_MESSAGE_TYPE_MESH_UNICAST); | ||
3662 | } | 3667 | } |
3663 | else | 3668 | else |
3664 | { | 3669 | { |
@@ -3666,8 +3671,8 @@ handle_mesh_unicast (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
3666 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 3671 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
3667 | " Pid %u not expected (%u), sending FWD ACK!\n", | 3672 | " Pid %u not expected (%u), sending FWD ACK!\n", |
3668 | pid, t->prev_fc.last_pid_recv + 1); | 3673 | pid, t->prev_fc.last_pid_recv + 1); |
3669 | tunnel_send_fwd_ack (t, GNUNET_MESSAGE_TYPE_MESH_DATA_ACK); | ||
3670 | } | 3674 | } |
3675 | tunnel_send_fwd_ack (t, GNUNET_MESSAGE_TYPE_MESH_UNICAST_ACK); | ||
3671 | return GNUNET_OK; | 3676 | return GNUNET_OK; |
3672 | } | 3677 | } |
3673 | t->prev_fc.last_pid_recv = pid; | 3678 | t->prev_fc.last_pid_recv = pid; |
@@ -3763,15 +3768,14 @@ handle_mesh_to_orig (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
3763 | { | 3768 | { |
3764 | t->next_fc.last_pid_recv = pid; | 3769 | t->next_fc.last_pid_recv = pid; |
3765 | tunnel_send_client_to_orig (t, msg); | 3770 | tunnel_send_client_to_orig (t, msg); |
3766 | tunnel_send_bck_ack (t, GNUNET_MESSAGE_TYPE_MESH_TO_ORIGIN); | ||
3767 | } | 3771 | } |
3768 | else | 3772 | else |
3769 | { | 3773 | { |
3770 | // GNUNET_STATISTICS_update (stats, "# duplicate PID drops BCK", 1, GNUNET_NO); | 3774 | // GNUNET_STATISTICS_update (stats, "# duplicate PID drops BCK", 1, GNUNET_NO); |
3771 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 3775 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
3772 | " Pid %u not expected, sending FWD ACK!\n", pid); | 3776 | " Pid %u not expected, sending FWD ACK!\n", pid); |
3773 | tunnel_send_bck_ack (t, GNUNET_MESSAGE_TYPE_MESH_DATA_ACK); | ||
3774 | } | 3777 | } |
3778 | tunnel_send_bck_ack (t, GNUNET_MESSAGE_TYPE_MESH_TO_ORIG_ACK); | ||
3775 | return GNUNET_OK; | 3779 | return GNUNET_OK; |
3776 | } | 3780 | } |
3777 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 3781 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
@@ -3833,9 +3837,11 @@ handle_mesh_data_ack (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
3833 | struct MeshTunnel *t; | 3837 | struct MeshTunnel *t; |
3834 | GNUNET_PEER_Id id; | 3838 | GNUNET_PEER_Id id; |
3835 | uint32_t ack; | 3839 | uint32_t ack; |
3840 | uint16_t type; | ||
3836 | 3841 | ||
3837 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Got a DATA ACK message from %s!\n", | 3842 | type = ntohs (message->type); |
3838 | GNUNET_i2s (peer)); | 3843 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Got a %s message from %s!\n", |
3844 | GNUNET_MESH_DEBUG_M2S (type), GNUNET_i2s (peer)); | ||
3839 | msg = (struct GNUNET_MESH_DataACK *) message; | 3845 | msg = (struct GNUNET_MESH_DataACK *) message; |
3840 | 3846 | ||
3841 | t = tunnel_get (&msg->oid, ntohl (msg->tid)); | 3847 | t = tunnel_get (&msg->oid, ntohl (msg->tid)); |
@@ -3850,7 +3856,7 @@ handle_mesh_data_ack (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
3850 | 3856 | ||
3851 | /* Is this a forward or backward ACK? */ | 3857 | /* Is this a forward or backward ACK? */ |
3852 | id = GNUNET_PEER_search (peer); | 3858 | id = GNUNET_PEER_search (peer); |
3853 | if (t->next_hop == id) | 3859 | if (t->next_hop == id && GNUNET_MESSAGE_TYPE_MESH_UNICAST_ACK == type) |
3854 | { | 3860 | { |
3855 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " FWD ACK\n"); | 3861 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " FWD ACK\n"); |
3856 | if (NULL == t->owner) | 3862 | if (NULL == t->owner) |
@@ -3859,9 +3865,9 @@ handle_mesh_data_ack (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
3859 | return GNUNET_OK; | 3865 | return GNUNET_OK; |
3860 | } | 3866 | } |
3861 | hm = t->sent_messages_fwd; | 3867 | hm = t->sent_messages_fwd; |
3862 | tunnel_send_fwd_ack (t, GNUNET_MESSAGE_TYPE_MESH_DATA_ACK); | 3868 | tunnel_send_fwd_ack (t, GNUNET_MESSAGE_TYPE_MESH_UNICAST_ACK); |
3863 | } | 3869 | } |
3864 | else if (t->prev_hop == id) | 3870 | else if (t->prev_hop == id && GNUNET_MESSAGE_TYPE_MESH_TO_ORIG_ACK == type) |
3865 | { | 3871 | { |
3866 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " BCK ACK\n"); | 3872 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " BCK ACK\n"); |
3867 | if (NULL == t->client) | 3873 | if (NULL == t->client) |
@@ -3870,7 +3876,7 @@ handle_mesh_data_ack (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
3870 | return GNUNET_OK; | 3876 | return GNUNET_OK; |
3871 | } | 3877 | } |
3872 | hm = t->sent_messages_bck; | 3878 | hm = t->sent_messages_bck; |
3873 | tunnel_send_bck_ack (t, GNUNET_MESSAGE_TYPE_MESH_DATA_ACK); | 3879 | tunnel_send_bck_ack (t, GNUNET_MESSAGE_TYPE_MESH_TO_ORIG_ACK); |
3874 | } | 3880 | } |
3875 | else | 3881 | else |
3876 | GNUNET_break_op (0); | 3882 | GNUNET_break_op (0); |
@@ -4077,7 +4083,9 @@ static struct GNUNET_CORE_MessageHandler core_handlers[] = { | |||
4077 | sizeof (struct GNUNET_MESH_TunnelDestroy)}, | 4083 | sizeof (struct GNUNET_MESH_TunnelDestroy)}, |
4078 | {&handle_mesh_unicast, GNUNET_MESSAGE_TYPE_MESH_UNICAST, 0}, | 4084 | {&handle_mesh_unicast, GNUNET_MESSAGE_TYPE_MESH_UNICAST, 0}, |
4079 | {&handle_mesh_to_orig, GNUNET_MESSAGE_TYPE_MESH_TO_ORIGIN, 0}, | 4085 | {&handle_mesh_to_orig, GNUNET_MESSAGE_TYPE_MESH_TO_ORIGIN, 0}, |
4080 | {&handle_mesh_data_ack, GNUNET_MESSAGE_TYPE_MESH_DATA_ACK, | 4086 | {&handle_mesh_data_ack, GNUNET_MESSAGE_TYPE_MESH_UNICAST_ACK, |
4087 | sizeof (struct GNUNET_MESH_DataACK)}, | ||
4088 | {&handle_mesh_data_ack, GNUNET_MESSAGE_TYPE_MESH_TO_ORIG_ACK, | ||
4081 | sizeof (struct GNUNET_MESH_DataACK)}, | 4089 | sizeof (struct GNUNET_MESH_DataACK)}, |
4082 | {&handle_mesh_keepalive, GNUNET_MESSAGE_TYPE_MESH_PATH_KEEPALIVE, | 4090 | {&handle_mesh_keepalive, GNUNET_MESSAGE_TYPE_MESH_PATH_KEEPALIVE, |
4083 | sizeof (struct GNUNET_MESH_TunnelKeepAlive)}, | 4091 | sizeof (struct GNUNET_MESH_TunnelKeepAlive)}, |