aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBart Polot <bart@net.in.tum.de>2013-07-15 17:35:13 +0000
committerBart Polot <bart@net.in.tum.de>2013-07-15 17:35:13 +0000
commit3a373a240a1f38d064428223d8cbd453fe652288 (patch)
tree0f5c040c5356575c19e1a1ccb33c665b7d6e106b /src
parent53ad2e450d066cf0f00e1f0f6e2a83b09698f2ea (diff)
downloadgnunet-3a373a240a1f38d064428223d8cbd453fe652288.tar.gz
gnunet-3a373a240a1f38d064428223d8cbd453fe652288.zip
- don't allow more than 64 messages in the input buffer of the owner
Diffstat (limited to 'src')
-rw-r--r--src/mesh/gnunet-service-mesh.c32
1 files changed, 19 insertions, 13 deletions
diff --git a/src/mesh/gnunet-service-mesh.c b/src/mesh/gnunet-service-mesh.c
index 9bd1bf183..bada66388 100644
--- a/src/mesh/gnunet-service-mesh.c
+++ b/src/mesh/gnunet-service-mesh.c
@@ -2177,6 +2177,8 @@ tunnel_send_bck_data_ack (struct MeshTunnel *t)
2177static void 2177static void
2178tunnel_send_fwd_ack (struct MeshTunnel *t, uint16_t type) 2178tunnel_send_fwd_ack (struct MeshTunnel *t, uint16_t type)
2179{ 2179{
2180 struct MeshTunnelReliability *rel = t->fwd_rel;
2181 uint64_t delta_mid;
2180 uint32_t ack; 2182 uint32_t ack;
2181 int delta; 2183 int delta;
2182 2184
@@ -2224,17 +2226,22 @@ tunnel_send_fwd_ack (struct MeshTunnel *t, uint16_t type)
2224 2226
2225 /* Ok, ACK might be necessary, what PID to ACK? */ 2227 /* Ok, ACK might be necessary, what PID to ACK? */
2226 delta = t->queue_max - t->next_fc.queue_n; 2228 delta = t->queue_max - t->next_fc.queue_n;
2229 if (NULL != t->owner && GNUNET_YES == t->reliable && NULL != rel->head_sent)
2230 delta_mid = rel->mid_sent - rel->head_sent->mid;
2231 else
2232 delta_mid = 0;
2227 if (0 > delta || (GNUNET_YES == t->reliable && 2233 if (0 > delta || (GNUNET_YES == t->reliable &&
2228 NULL != t->owner && 2234 NULL != t->owner &&
2229 t->fwd_rel->n_sent > 10)) 2235 (rel->n_sent > 10 || delta_mid > 64)))
2230 delta = 0; 2236 delta = 0;
2231 if (NULL != t->owner && delta > 1) 2237 if (NULL != t->owner && delta > 1)
2232 delta = 1; 2238 delta = 1;
2233 ack = t->prev_fc.last_pid_recv + delta; 2239 ack = t->prev_fc.last_pid_recv + delta;
2234 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " FWD ACK %u\n", ack); 2240 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " FWD ACK %u\n", ack);
2235 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2241 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2236 " last %u, qmax %u, q %u\n", 2242 " last pid %u, last ack %u, qmax %u, q %u\n",
2237 t->prev_fc.last_pid_recv, t->queue_max, t->next_fc.queue_n); 2243 t->prev_fc.last_pid_recv, t->prev_fc.last_ack_sent,
2244 t->queue_max, t->next_fc.queue_n);
2238 if (ack == t->prev_fc.last_ack_sent && GNUNET_NO == t->force_ack) 2245 if (ack == t->prev_fc.last_ack_sent && GNUNET_NO == t->force_ack)
2239 { 2246 {
2240 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Not sending FWD ACK, not needed\n"); 2247 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Not sending FWD ACK, not needed\n");
@@ -2470,11 +2477,14 @@ tunnel_free_reliable_message (struct MeshReliableMessage *copy)
2470 2477
2471 rel = copy->rel; 2478 rel = copy->rel;
2472 time = GNUNET_TIME_absolute_get_duration (copy->timestamp); 2479 time = GNUNET_TIME_absolute_get_duration (copy->timestamp);
2480 rel->expected_delay.rel_value *= 7;
2473 rel->expected_delay.rel_value += time.rel_value; 2481 rel->expected_delay.rel_value += time.rel_value;
2474 rel->expected_delay.rel_value /= 2; 2482 rel->expected_delay.rel_value /= 8;
2475 rel->n_sent--; 2483 rel->n_sent--;
2476 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "!!! Freeing %llu\n", copy->mid); 2484 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "!!! Freeing %llu\n", copy->mid);
2477 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " n_sent %u\n", rel->n_sent); 2485 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " n_sent %u\n", rel->n_sent);
2486 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "!!! took %s\n",
2487 GNUNET_STRINGS_relative_time_to_string (time, GNUNET_NO));
2478 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "!!! new expected delay %s\n", 2488 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "!!! new expected delay %s\n",
2479 GNUNET_STRINGS_relative_time_to_string (rel->expected_delay, 2489 GNUNET_STRINGS_relative_time_to_string (rel->expected_delay,
2480 GNUNET_NO)); 2490 GNUNET_NO));
@@ -2621,17 +2631,11 @@ tunnel_retransmit_message (void *cls,
2621 /* Message not found in the queue */ 2631 /* Message not found in the queue */
2622 if (NULL == q) 2632 if (NULL == q)
2623 { 2633 {
2624 struct GNUNET_TIME_Relative diff;
2625
2626 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "!!! RETRANSMIT %llu\n", copy->mid); 2634 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "!!! RETRANSMIT %llu\n", copy->mid);
2627 diff = GNUNET_TIME_absolute_get_duration (copy->timestamp);
2628 diff = GNUNET_TIME_relative_divide (diff, 10);
2629 copy->timestamp = GNUNET_TIME_absolute_subtract (GNUNET_TIME_absolute_get(),
2630 diff);
2631 2635
2632 fc->last_ack_sent++; 2636 fc->last_ack_sent++;
2633 payload->pid = htonl (fc->last_pid_recv + 1);
2634 fc->last_pid_recv++; 2637 fc->last_pid_recv++;
2638 payload->pid = htonl (fc->last_pid_recv);
2635 send_prebuilt_message (&payload->header, hop, t); 2639 send_prebuilt_message (&payload->header, hop, t);
2636 GNUNET_STATISTICS_update (stats, "# data retransmitted", 1, GNUNET_NO); 2640 GNUNET_STATISTICS_update (stats, "# data retransmitted", 1, GNUNET_NO);
2637 } 2641 }
@@ -3433,6 +3437,9 @@ queue_send (void *cls, size_t size, void *buf)
3433 case GNUNET_MESSAGE_TYPE_MESH_UNICAST: 3437 case GNUNET_MESSAGE_TYPE_MESH_UNICAST:
3434 t->next_fc.last_pid_sent = pid; 3438 t->next_fc.last_pid_sent = pid;
3435 tunnel_send_fwd_ack (t, GNUNET_MESSAGE_TYPE_MESH_UNICAST); 3439 tunnel_send_fwd_ack (t, GNUNET_MESSAGE_TYPE_MESH_UNICAST);
3440 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
3441 "!!! SEND %llu\n",
3442 GNUNET_ntohll ( ((struct GNUNET_MESH_Data *) buf)->mid ));
3436 break; 3443 break;
3437 case GNUNET_MESSAGE_TYPE_MESH_TO_ORIGIN: 3444 case GNUNET_MESSAGE_TYPE_MESH_TO_ORIGIN:
3438 t->prev_fc.last_pid_sent = pid; 3445 t->prev_fc.last_pid_sent = pid;
@@ -4017,7 +4024,6 @@ handle_mesh_unicast (void *cls, const struct GNUNET_PeerIdentity *peer,
4017 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 4024 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
4018 "Received PID %u, (prev %u), ACK %u\n", 4025 "Received PID %u, (prev %u), ACK %u\n",
4019 pid, t->prev_fc.last_pid_recv, t->prev_fc.last_ack_sent); 4026 pid, t->prev_fc.last_pid_recv, t->prev_fc.last_ack_sent);
4020 tunnel_send_fwd_ack(t, GNUNET_MESSAGE_TYPE_MESH_POLL);
4021 return GNUNET_OK; 4027 return GNUNET_OK;
4022 } 4028 }
4023 4029