diff options
author | Bart Polot <bart@net.in.tum.de> | 2013-07-13 01:13:07 +0000 |
---|---|---|
committer | Bart Polot <bart@net.in.tum.de> | 2013-07-13 01:13:07 +0000 |
commit | 1d53ec8da14a39e436cbddebba9cd92537870b6a (patch) | |
tree | f368bdbd160198e7776345106362778cb0803100 /src/mesh/gnunet-service-mesh.c | |
parent | 581fa8973a09190bc59f62e5da7eb69983f39228 (diff) | |
download | gnunet-1d53ec8da14a39e436cbddebba9cd92537870b6a.tar.gz gnunet-1d53ec8da14a39e436cbddebba9cd92537870b6a.zip |
- use message ID for end-to-end ACKs
Diffstat (limited to 'src/mesh/gnunet-service-mesh.c')
-rw-r--r-- | src/mesh/gnunet-service-mesh.c | 150 |
1 files changed, 64 insertions, 86 deletions
diff --git a/src/mesh/gnunet-service-mesh.c b/src/mesh/gnunet-service-mesh.c index 169b30087..7504fa223 100644 --- a/src/mesh/gnunet-service-mesh.c +++ b/src/mesh/gnunet-service-mesh.c | |||
@@ -51,9 +51,7 @@ | |||
51 | #define MESH_MAX_POLL_TIME GNUNET_TIME_relative_multiply (\ | 51 | #define MESH_MAX_POLL_TIME GNUNET_TIME_relative_multiply (\ |
52 | GNUNET_TIME_UNIT_MINUTES,\ | 52 | GNUNET_TIME_UNIT_MINUTES,\ |
53 | 10) | 53 | 10) |
54 | #define MESH_RETRANSMIT_TIME GNUNET_TIME_relative_multiply (\ | 54 | #define MESH_RETRANSMIT_TIME GNUNET_TIME_UNIT_SECONDS |
55 | GNUNET_TIME_UNIT_SECONDS,\ | ||
56 | 5) | ||
57 | #define MESH_RETRANSMIT_MARGIN 4 | 55 | #define MESH_RETRANSMIT_MARGIN 4 |
58 | 56 | ||
59 | #if MESH_DEBUG_CONNECTION | 57 | #if MESH_DEBUG_CONNECTION |
@@ -286,6 +284,12 @@ struct MESH_TunnelID | |||
286 | 284 | ||
287 | 285 | ||
288 | /** | 286 | /** |
287 | * Data needed for reliable tunnel endpoint retransmission management. | ||
288 | */ | ||
289 | struct MeshTunnelReliability; | ||
290 | |||
291 | |||
292 | /** | ||
289 | * Info needed to retry a message in case it gets lost. | 293 | * Info needed to retry a message in case it gets lost. |
290 | */ | 294 | */ |
291 | struct MeshReliableMessage | 295 | struct MeshReliableMessage |
@@ -304,7 +308,7 @@ struct MeshReliableMessage | |||
304 | /** | 308 | /** |
305 | * ID of the message (ACK needed to free) | 309 | * ID of the message (ACK needed to free) |
306 | */ | 310 | */ |
307 | uint32_t id; | 311 | uint64_t mid; |
308 | 312 | ||
309 | /** | 313 | /** |
310 | * When was this message issued (to calculate ACK delay) FIXME update with traffic | 314 | * When was this message issued (to calculate ACK delay) FIXME update with traffic |
@@ -315,9 +319,6 @@ struct MeshReliableMessage | |||
315 | }; | 319 | }; |
316 | 320 | ||
317 | 321 | ||
318 | /** | ||
319 | * Data needed for reliable tunnel endpoint retransmission management. | ||
320 | */ | ||
321 | struct MeshTunnelReliability | 322 | struct MeshTunnelReliability |
322 | { | 323 | { |
323 | /** | 324 | /** |
@@ -337,11 +338,18 @@ struct MeshTunnelReliability | |||
337 | unsigned int n_sent; | 338 | unsigned int n_sent; |
338 | 339 | ||
339 | /** | 340 | /** |
341 | * Next MID to use | ||
342 | */ | ||
343 | uint64_t mid_sent; | ||
344 | |||
345 | /** | ||
340 | * DLL of messages received out of order. | 346 | * DLL of messages received out of order. |
341 | */ | 347 | */ |
342 | struct MeshReliableMessage *head_recv; | 348 | struct MeshReliableMessage *head_recv; |
343 | struct MeshReliableMessage *tail_recv; | 349 | struct MeshReliableMessage *tail_recv; |
344 | 350 | ||
351 | uint64_t mid_recv; | ||
352 | |||
345 | /** | 353 | /** |
346 | * Task to resend/poll in case no ACK is received. | 354 | * Task to resend/poll in case no ACK is received. |
347 | */ | 355 | */ |
@@ -2057,7 +2065,7 @@ tunnel_send_fwd_data_ack (struct MeshTunnel *t) | |||
2057 | msg.header.size = htons (sizeof (msg)); | 2065 | msg.header.size = htons (sizeof (msg)); |
2058 | msg.tid = htonl (t->id.tid); | 2066 | msg.tid = htonl (t->id.tid); |
2059 | GNUNET_PEER_resolve (t->id.oid, &msg.oid); | 2067 | GNUNET_PEER_resolve (t->id.oid, &msg.oid); |
2060 | msg.pid = htonl (t->prev_fc.last_pid_recv); | 2068 | msg.mid = GNUNET_htonll (t->bck_rel->mid_recv); |
2061 | msg.futures = 0; // FIXME set bits of other newer messages received | 2069 | msg.futures = 0; // FIXME set bits of other newer messages received |
2062 | 2070 | ||
2063 | send_prebuilt_message (&msg.header, t->prev_hop, t); | 2071 | send_prebuilt_message (&msg.header, t->prev_hop, t); |
@@ -2078,7 +2086,7 @@ tunnel_send_bck_data_ack (struct MeshTunnel *t) | |||
2078 | msg.header.size = htons (sizeof (msg)); | 2086 | msg.header.size = htons (sizeof (msg)); |
2079 | msg.tid = htonl (t->id.tid); | 2087 | msg.tid = htonl (t->id.tid); |
2080 | GNUNET_PEER_resolve (t->id.oid, &msg.oid); | 2088 | GNUNET_PEER_resolve (t->id.oid, &msg.oid); |
2081 | msg.pid = htonl (t->next_fc.last_pid_recv); | 2089 | msg.mid = GNUNET_htonll (t->fwd_rel->mid_recv); |
2082 | msg.futures = 0; // FIXME set bits of other newer messages received | 2090 | msg.futures = 0; // FIXME set bits of other newer messages received |
2083 | 2091 | ||
2084 | send_prebuilt_message (&msg.header, t->next_hop, t); | 2092 | send_prebuilt_message (&msg.header, t->next_hop, t); |
@@ -2100,6 +2108,7 @@ static void | |||
2100 | tunnel_send_fwd_ack (struct MeshTunnel *t, uint16_t type) | 2108 | tunnel_send_fwd_ack (struct MeshTunnel *t, uint16_t type) |
2101 | { | 2109 | { |
2102 | uint32_t ack; | 2110 | uint32_t ack; |
2111 | int delta; | ||
2103 | 2112 | ||
2104 | /* Is it after unicast retransmission? */ | 2113 | /* Is it after unicast retransmission? */ |
2105 | switch (type) | 2114 | switch (type) |
@@ -2114,18 +2123,10 @@ tunnel_send_fwd_ack (struct MeshTunnel *t, uint16_t type) | |||
2114 | } | 2123 | } |
2115 | if (GNUNET_YES == t->reliable && NULL != t->client) | 2124 | if (GNUNET_YES == t->reliable && NULL != t->client) |
2116 | tunnel_send_fwd_data_ack (t); | 2125 | tunnel_send_fwd_data_ack (t); |
2117 | if (GNUNET_YES == t->reliable && NULL != t->owner) | ||
2118 | if (t->fwd_rel->n_sent > 10) | ||
2119 | return; | ||
2120 | break; | 2126 | break; |
2121 | case GNUNET_MESSAGE_TYPE_MESH_ACK: | 2127 | case GNUNET_MESSAGE_TYPE_MESH_ACK: |
2122 | if (NULL != t->owner && GNUNET_YES == t->reliable) | ||
2123 | return; | ||
2124 | case GNUNET_MESSAGE_TYPE_MESH_LOCAL_ACK: | 2128 | case GNUNET_MESSAGE_TYPE_MESH_LOCAL_ACK: |
2125 | break; | 2129 | break; |
2126 | case GNUNET_MESSAGE_TYPE_MESH_UNICAST_ACK: | ||
2127 | tunnel_send_fwd_data_ack (t); | ||
2128 | break; | ||
2129 | case GNUNET_MESSAGE_TYPE_MESH_POLL: | 2130 | case GNUNET_MESSAGE_TYPE_MESH_POLL: |
2130 | case GNUNET_MESSAGE_TYPE_MESH_PATH_ACK: | 2131 | case GNUNET_MESSAGE_TYPE_MESH_PATH_ACK: |
2131 | t->force_ack = GNUNET_YES; | 2132 | t->force_ack = GNUNET_YES; |
@@ -2151,7 +2152,10 @@ tunnel_send_fwd_ack (struct MeshTunnel *t, uint16_t type) | |||
2151 | } | 2152 | } |
2152 | 2153 | ||
2153 | /* Ok, ACK might be necessary, what PID to ACK? */ | 2154 | /* Ok, ACK might be necessary, what PID to ACK? */ |
2154 | ack = t->prev_fc.last_pid_recv + t->queue_max - t->next_fc.queue_n; | 2155 | delta = t->queue_max - t->next_fc.queue_n; |
2156 | if (0 > delta) | ||
2157 | delta = 0; | ||
2158 | ack = t->prev_fc.last_pid_recv + delta; | ||
2155 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " FWD ACK %u\n", ack); | 2159 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " FWD ACK %u\n", ack); |
2156 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2160 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2157 | " last %u, qmax %u, q %u\n", | 2161 | " last %u, qmax %u, q %u\n", |
@@ -2202,18 +2206,12 @@ tunnel_send_bck_ack (struct MeshTunnel *t, uint16_t type) | |||
2202 | " Not sending ACK, nobuffer + traffic\n"); | 2206 | " Not sending ACK, nobuffer + traffic\n"); |
2203 | return; | 2207 | return; |
2204 | } | 2208 | } |
2209 | if (GNUNET_YES == t->reliable && NULL != t->owner) | ||
2210 | tunnel_send_bck_data_ack (t); | ||
2205 | break; | 2211 | break; |
2206 | case GNUNET_MESSAGE_TYPE_MESH_ACK: | 2212 | case GNUNET_MESSAGE_TYPE_MESH_ACK: |
2207 | /* Why was this here?! | ||
2208 | * This prevents the destination from starting traffic to the origin | ||
2209 | */ | ||
2210 | // if (NULL != t->client && GNUNET_YES == t->reliable) | ||
2211 | // return; | ||
2212 | case GNUNET_MESSAGE_TYPE_MESH_LOCAL_ACK: | 2213 | case GNUNET_MESSAGE_TYPE_MESH_LOCAL_ACK: |
2213 | break; | 2214 | break; |
2214 | case GNUNET_MESSAGE_TYPE_MESH_TO_ORIG_ACK: | ||
2215 | tunnel_send_bck_data_ack (t); | ||
2216 | /* fall through */ | ||
2217 | case GNUNET_MESSAGE_TYPE_MESH_PATH_ACK: | 2215 | case GNUNET_MESSAGE_TYPE_MESH_PATH_ACK: |
2218 | case GNUNET_MESSAGE_TYPE_MESH_POLL: | 2216 | case GNUNET_MESSAGE_TYPE_MESH_POLL: |
2219 | t->force_ack = GNUNET_YES; | 2217 | t->force_ack = GNUNET_YES; |
@@ -2324,6 +2322,7 @@ tunnel_retransmit_message (void *cls, | |||
2324 | { | 2322 | { |
2325 | struct MeshTunnelReliability *rel = cls; | 2323 | struct MeshTunnelReliability *rel = cls; |
2326 | struct MeshReliableMessage *copy; | 2324 | struct MeshReliableMessage *copy; |
2325 | struct MeshFlowControl *fc; | ||
2327 | struct MeshPeerQueue *q; | 2326 | struct MeshPeerQueue *q; |
2328 | struct MeshPeerInfo *pi; | 2327 | struct MeshPeerInfo *pi; |
2329 | struct MeshTunnel *t; | 2328 | struct MeshTunnel *t; |
@@ -2345,6 +2344,7 @@ tunnel_retransmit_message (void *cls, | |||
2345 | /* Search the message to be retransmitted in the outgoing queue */ | 2344 | /* Search the message to be retransmitted in the outgoing queue */ |
2346 | payload = (struct GNUNET_MESH_Data *) ©[1]; | 2345 | payload = (struct GNUNET_MESH_Data *) ©[1]; |
2347 | hop = rel == t->fwd_rel ? t->next_hop : t->prev_hop; | 2346 | hop = rel == t->fwd_rel ? t->next_hop : t->prev_hop; |
2347 | fc = rel == t->fwd_rel ? &t->next_fc : &t->prev_fc; | ||
2348 | pi = peer_get_short (hop); | 2348 | pi = peer_get_short (hop); |
2349 | for (q = pi->queue_head; NULL != q; q = q->next) | 2349 | for (q = pi->queue_head; NULL != q; q = q->next) |
2350 | { | 2350 | { |
@@ -2352,7 +2352,7 @@ tunnel_retransmit_message (void *cls, | |||
2352 | { | 2352 | { |
2353 | struct GNUNET_MESH_Data *queued_data = q->cls; | 2353 | struct GNUNET_MESH_Data *queued_data = q->cls; |
2354 | 2354 | ||
2355 | if (queued_data->pid == payload->pid) | 2355 | if (queued_data->mid == payload->mid) |
2356 | break; | 2356 | break; |
2357 | } | 2357 | } |
2358 | } | 2358 | } |
@@ -2360,14 +2360,18 @@ tunnel_retransmit_message (void *cls, | |||
2360 | /* Message not found in the queue */ | 2360 | /* Message not found in the queue */ |
2361 | if (NULL == q) | 2361 | if (NULL == q) |
2362 | { | 2362 | { |
2363 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "!!! RETRANSMIT %u\n", copy->id); | 2363 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "!!! RETRANSMIT %llu\n", copy->mid); |
2364 | copy->timestamp = GNUNET_TIME_absolute_get (); | 2364 | copy->timestamp = GNUNET_TIME_absolute_get (); |
2365 | |||
2366 | fc->last_ack_sent++; | ||
2367 | payload->pid = htonl (fc->last_pid_recv + 1); | ||
2368 | fc->last_pid_recv++; | ||
2365 | send_prebuilt_message (&payload->header, hop, t); | 2369 | send_prebuilt_message (&payload->header, hop, t); |
2366 | GNUNET_STATISTICS_update (stats, "# data retransmitted", 1, GNUNET_NO); | 2370 | GNUNET_STATISTICS_update (stats, "# data retransmitted", 1, GNUNET_NO); |
2367 | } | 2371 | } |
2368 | else | 2372 | else |
2369 | { | 2373 | { |
2370 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "!!! QUEUED %u\n", copy->id); | 2374 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "!!! STILL IN QUEUE %llu\n", copy->mid); |
2371 | } | 2375 | } |
2372 | 2376 | ||
2373 | rel->retry_timer = GNUNET_TIME_STD_BACKOFF (rel->retry_timer); | 2377 | rel->retry_timer = GNUNET_TIME_STD_BACKOFF (rel->retry_timer); |
@@ -3161,13 +3165,11 @@ queue_send (void *cls, size_t size, void *buf) | |||
3161 | switch (type) | 3165 | switch (type) |
3162 | { | 3166 | { |
3163 | case GNUNET_MESSAGE_TYPE_MESH_UNICAST: | 3167 | case GNUNET_MESSAGE_TYPE_MESH_UNICAST: |
3164 | if (GMC_is_pid_bigger(pid, t->next_fc.last_pid_sent)) | 3168 | t->next_fc.last_pid_sent = pid; |
3165 | t->next_fc.last_pid_sent = pid; | ||
3166 | tunnel_send_fwd_ack (t, GNUNET_MESSAGE_TYPE_MESH_UNICAST); | 3169 | tunnel_send_fwd_ack (t, GNUNET_MESSAGE_TYPE_MESH_UNICAST); |
3167 | break; | 3170 | break; |
3168 | case GNUNET_MESSAGE_TYPE_MESH_TO_ORIGIN: | 3171 | case GNUNET_MESSAGE_TYPE_MESH_TO_ORIGIN: |
3169 | if (GMC_is_pid_bigger(pid, t->prev_fc.last_pid_sent)) | 3172 | t->prev_fc.last_pid_sent = pid; |
3170 | t->prev_fc.last_pid_sent = pid; | ||
3171 | tunnel_send_bck_ack (t, GNUNET_MESSAGE_TYPE_MESH_TO_ORIGIN); | 3173 | tunnel_send_bck_ack (t, GNUNET_MESSAGE_TYPE_MESH_TO_ORIGIN); |
3172 | break; | 3174 | break; |
3173 | default: | 3175 | default: |
@@ -3248,8 +3250,6 @@ queue_add (void *cls, uint16_t type, size_t size, | |||
3248 | struct MeshPeerQueue *queue; | 3250 | struct MeshPeerQueue *queue; |
3249 | struct GNUNET_PeerIdentity id; | 3251 | struct GNUNET_PeerIdentity id; |
3250 | struct MeshFlowControl *fc; | 3252 | struct MeshFlowControl *fc; |
3251 | uint32_t pid; | ||
3252 | uint32_t pid_q; | ||
3253 | int priority; | 3253 | int priority; |
3254 | 3254 | ||
3255 | fc = NULL; | 3255 | fc = NULL; |
@@ -3257,56 +3257,30 @@ queue_add (void *cls, uint16_t type, size_t size, | |||
3257 | if (GNUNET_MESSAGE_TYPE_MESH_UNICAST == type) | 3257 | if (GNUNET_MESSAGE_TYPE_MESH_UNICAST == type) |
3258 | { | 3258 | { |
3259 | fc = &t->next_fc; | 3259 | fc = &t->next_fc; |
3260 | pid = ntohl (((struct GNUNET_MESH_Data *)cls)->pid); | ||
3261 | } | 3260 | } |
3262 | else if (GNUNET_MESSAGE_TYPE_MESH_TO_ORIGIN == type) | 3261 | else if (GNUNET_MESSAGE_TYPE_MESH_TO_ORIGIN == type) |
3263 | { | 3262 | { |
3264 | fc = &t->prev_fc; | 3263 | fc = &t->prev_fc; |
3265 | pid = ntohl (((struct GNUNET_MESH_Data *)cls)->pid); | ||
3266 | } | 3264 | } |
3267 | if (NULL != fc) | 3265 | if (NULL != fc) |
3268 | { | 3266 | { |
3269 | if (fc->queue_n >= t->queue_max) | 3267 | if (fc->queue_n >= t->queue_max) |
3270 | { | 3268 | { |
3271 | GNUNET_break (0); | 3269 | GNUNET_break (0); |
3272 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 3270 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
3273 | "queue full: %u/%u\n", | 3271 | "queue full: %u/%u\n", |
3274 | fc->queue_n, t->queue_max); | 3272 | fc->queue_n, t->queue_max); |
3275 | GNUNET_STATISTICS_update (stats, | 3273 | |
3276 | "# messages dropped (buffer full)", | 3274 | /* If this isn't a retransmission, drop the message */ |
3277 | 1, GNUNET_NO); | 3275 | if (GNUNET_NO == t->reliable || |
3278 | /* Get the PID of the oldest message in the queue */ | 3276 | (NULL == t->owner && GNUNET_MESSAGE_TYPE_MESH_UNICAST == type) || |
3279 | for (queue = dst->queue_head; queue != NULL; queue = queue->next) | 3277 | (NULL == t->client && GNUNET_MESSAGE_TYPE_MESH_TO_ORIGIN == type)) |
3280 | if (queue->type == type && queue->tunnel == t) | ||
3281 | { | ||
3282 | pid_q = ntohl (((struct GNUNET_MESH_Data *)(queue->cls))->pid); | ||
3283 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
3284 | "pid: %u, pid_q: %u\n", pid, pid_q); | ||
3285 | break; | ||
3286 | } | ||
3287 | GNUNET_assert (NULL != queue); | ||
3288 | |||
3289 | /* If this is an earlier message that that, give it priority: | ||
3290 | * - drop the newest message in the queue | ||
3291 | * - instert current one at the end of the queue (first to get out) | ||
3292 | */ | ||
3293 | if (GNUNET_YES == t->reliable && GMC_is_pid_bigger(pid_q, pid)) | ||
3294 | { | 3278 | { |
3295 | for (queue = dst->queue_tail; queue != NULL; queue = queue->prev) | 3279 | GNUNET_STATISTICS_update (stats, "# messages dropped (buffer full)", |
3296 | if (queue->type == type && queue->tunnel == t) | 3280 | 1, GNUNET_NO); |
3297 | { | ||
3298 | /* Drop message from queue */ | ||
3299 | pid_q = ntohl (((struct GNUNET_MESH_Data *)(queue->cls))->pid); | ||
3300 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
3301 | "dropping pid: %u\n", pid_q); | ||
3302 | queue_destroy (queue, GNUNET_YES); | ||
3303 | t->pending_messages--; | ||
3304 | priority = GNUNET_YES; | ||
3305 | break; | ||
3306 | } | ||
3307 | } | ||
3308 | else | ||
3309 | return; /* Drop this message */ | 3281 | return; /* Drop this message */ |
3282 | } | ||
3283 | priority = GNUNET_YES; | ||
3310 | } | 3284 | } |
3311 | fc->queue_n++; | 3285 | fc->queue_n++; |
3312 | } | 3286 | } |
@@ -3773,15 +3747,15 @@ handle_mesh_unicast (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
3773 | " it's for us! sending to clients...\n"); | 3747 | " it's for us! sending to clients...\n"); |
3774 | GNUNET_STATISTICS_update (stats, "# unicast received", 1, GNUNET_NO); | 3748 | GNUNET_STATISTICS_update (stats, "# unicast received", 1, GNUNET_NO); |
3775 | // if (GMC_is_pid_bigger(pid, t->prev_fc.last_pid_recv)) FIXME use | 3749 | // if (GMC_is_pid_bigger(pid, t->prev_fc.last_pid_recv)) FIXME use |
3776 | if ( (GNUNET_NO == t->reliable && | 3750 | if (GMC_is_pid_bigger (pid, t->prev_fc.last_pid_recv) |
3777 | GMC_is_pid_bigger(pid, t->prev_fc.last_pid_recv)) | 3751 | && |
3778 | || | 3752 | (GNUNET_NO == t->reliable || |
3779 | (GNUNET_YES == t->reliable && | 3753 | GNUNET_ntohll (msg->mid) == (t->bck_rel->mid_recv + 1)) ) |
3780 | pid == t->prev_fc.last_pid_recv + 1) ) | ||
3781 | { | 3754 | { |
3782 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 3755 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
3783 | " pid %u not seen yet, forwarding\n", pid); | 3756 | " pid %u not seen yet, forwarding\n", pid); |
3784 | t->prev_fc.last_pid_recv = pid; | 3757 | t->prev_fc.last_pid_recv = pid; |
3758 | t->bck_rel->mid_recv++; | ||
3785 | tunnel_send_client_ucast (t, msg); | 3759 | tunnel_send_client_ucast (t, msg); |
3786 | } | 3760 | } |
3787 | else | 3761 | else |
@@ -3958,7 +3932,7 @@ handle_mesh_data_ack (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
3958 | struct MeshReliableMessage *next; | 3932 | struct MeshReliableMessage *next; |
3959 | struct MeshTunnel *t; | 3933 | struct MeshTunnel *t; |
3960 | GNUNET_PEER_Id id; | 3934 | GNUNET_PEER_Id id; |
3961 | uint32_t ack; | 3935 | uint64_t ack; |
3962 | uint16_t type; | 3936 | uint16_t type; |
3963 | int work; | 3937 | int work; |
3964 | 3938 | ||
@@ -3974,8 +3948,8 @@ handle_mesh_data_ack (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
3974 | GNUNET_STATISTICS_update (stats, "# ack on unknown tunnel", 1, GNUNET_NO); | 3948 | GNUNET_STATISTICS_update (stats, "# ack on unknown tunnel", 1, GNUNET_NO); |
3975 | return GNUNET_OK; | 3949 | return GNUNET_OK; |
3976 | } | 3950 | } |
3977 | ack = ntohl (msg->pid); | 3951 | ack = GNUNET_ntohll (msg->mid); |
3978 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " ACK %u\n", ack); | 3952 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " ACK %llu\n", ack); |
3979 | 3953 | ||
3980 | /* Is this a forward or backward ACK? */ | 3954 | /* Is this a forward or backward ACK? */ |
3981 | id = GNUNET_PEER_search (peer); | 3955 | id = GNUNET_PEER_search (peer); |
@@ -4007,18 +3981,18 @@ handle_mesh_data_ack (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
4007 | return GNUNET_OK; | 3981 | return GNUNET_OK; |
4008 | } | 3982 | } |
4009 | 3983 | ||
4010 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "!!! ACK %u\n", ack); | 3984 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "!!! ACK %llu\n", ack); |
4011 | for (work = GNUNET_NO, copy = rel->head_sent; copy != NULL; copy = next) | 3985 | for (work = GNUNET_NO, copy = rel->head_sent; copy != NULL; copy = next) |
4012 | { | 3986 | { |
4013 | struct GNUNET_TIME_Relative time; | 3987 | struct GNUNET_TIME_Relative time; |
4014 | 3988 | ||
4015 | if (copy->id > ack) | 3989 | if (copy->mid > ack) |
4016 | { | 3990 | { |
4017 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "!!! head %u, out!\n", copy->id); | 3991 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "!!! head %llu, out!\n", copy->mid); |
4018 | break; | 3992 | break; |
4019 | } | 3993 | } |
4020 | work = GNUNET_YES; | 3994 | work = GNUNET_YES; |
4021 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "!!! id %u\n", copy->id); | 3995 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "!!! id %llu\n", copy->mid); |
4022 | next = copy->next; | 3996 | next = copy->next; |
4023 | time = GNUNET_TIME_absolute_get_duration (copy->timestamp); | 3997 | time = GNUNET_TIME_absolute_get_duration (copy->timestamp); |
4024 | rel->expected_delay.rel_value += time.rel_value; | 3998 | rel->expected_delay.rel_value += time.rel_value; |
@@ -4783,13 +4757,13 @@ handle_local_data (void *cls, struct GNUNET_SERVER_Client *client, | |||
4783 | struct MeshTunnelReliability *rel; | 4757 | struct MeshTunnelReliability *rel; |
4784 | struct MeshReliableMessage *copy; | 4758 | struct MeshReliableMessage *copy; |
4785 | 4759 | ||
4760 | rel = (tid < GNUNET_MESH_LOCAL_TUNNEL_ID_SERV) ? t->fwd_rel : t->bck_rel; | ||
4786 | copy = GNUNET_malloc (sizeof (struct MeshReliableMessage) | 4761 | copy = GNUNET_malloc (sizeof (struct MeshReliableMessage) |
4787 | + sizeof(struct GNUNET_MESH_Data) | 4762 | + sizeof(struct GNUNET_MESH_Data) |
4788 | + size); | 4763 | + size); |
4789 | copy->id = fc->last_pid_recv + 1; | 4764 | copy->mid = rel->mid_sent++; |
4790 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "!!! DATA %u\n", copy->id); | 4765 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "!!! DATA %llu\n", copy->mid); |
4791 | copy->timestamp = GNUNET_TIME_absolute_get (); | 4766 | copy->timestamp = GNUNET_TIME_absolute_get (); |
4792 | rel = (tid < GNUNET_MESH_LOCAL_TUNNEL_ID_SERV) ? t->fwd_rel : t->bck_rel; | ||
4793 | copy->rel = rel; | 4767 | copy->rel = rel; |
4794 | rel->n_sent++; | 4768 | rel->n_sent++; |
4795 | GNUNET_CONTAINER_DLL_insert_tail (rel->head_sent, rel->tail_sent, copy); | 4769 | GNUNET_CONTAINER_DLL_insert_tail (rel->head_sent, rel->tail_sent, copy); |
@@ -4804,10 +4778,14 @@ handle_local_data (void *cls, struct GNUNET_SERVER_Client *client, | |||
4804 | rel); | 4778 | rel); |
4805 | } | 4779 | } |
4806 | payload = (struct GNUNET_MESH_Data *) ©[1]; | 4780 | payload = (struct GNUNET_MESH_Data *) ©[1]; |
4781 | payload->mid = GNUNET_htonll (copy->mid); | ||
4807 | } | 4782 | } |
4808 | else | 4783 | else |
4809 | { | 4784 | { |
4810 | payload = (struct GNUNET_MESH_Data *) cbuf; | 4785 | payload = (struct GNUNET_MESH_Data *) cbuf; |
4786 | payload->mid = 0; | ||
4787 | // FIXME FIXME FIXME FIXME FIXME FIXME FIXME FIXME FIXME FIXME | ||
4788 | // use different struct for unreliable traffic, save 8 bytes | ||
4811 | } | 4789 | } |
4812 | memcpy (&payload[1], &data_msg[1], size); | 4790 | memcpy (&payload[1], &data_msg[1], size); |
4813 | payload->header.size = htons (sizeof (struct GNUNET_MESH_Data) + size); | 4791 | payload->header.size = htons (sizeof (struct GNUNET_MESH_Data) + size); |