aboutsummaryrefslogtreecommitdiff
path: root/src/fragmentation
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2011-07-14 12:04:07 +0000
committerChristian Grothoff <christian@grothoff.org>2011-07-14 12:04:07 +0000
commitd3c70c3bfde07f93c72effebbfd11436a5a9590c (patch)
tree41d614addc19e63fe0becba5c6d42c521ec917d6 /src/fragmentation
parent8af646076372f322fd772736523e890cef2d69f0 (diff)
downloadgnunet-d3c70c3bfde07f93c72effebbfd11436a5a9590c.tar.gz
gnunet-d3c70c3bfde07f93c72effebbfd11436a5a9590c.zip
nicer stats, bugfix
Diffstat (limited to 'src/fragmentation')
-rw-r--r--src/fragmentation/defragmentation.c10
-rw-r--r--src/fragmentation/fragmentation.c29
2 files changed, 29 insertions, 10 deletions
diff --git a/src/fragmentation/defragmentation.c b/src/fragmentation/defragmentation.c
index cc42d3e75..6ad8d0faf 100644
--- a/src/fragmentation/defragmentation.c
+++ b/src/fragmentation/defragmentation.c
@@ -270,6 +270,10 @@ send_ack (void *cls,
270 fa.header.type = htons (GNUNET_MESSAGE_TYPE_FRAGMENT_ACK); 270 fa.header.type = htons (GNUNET_MESSAGE_TYPE_FRAGMENT_ACK);
271 fa.fragment_id = htonl (mc->fragment_id); 271 fa.fragment_id = htonl (mc->fragment_id);
272 fa.bits = GNUNET_htonll (mc->bits); 272 fa.bits = GNUNET_htonll (mc->bits);
273 GNUNET_STATISTICS_update (mc->dc->stats,
274 _("# acknowledgements sent for fragment"),
275 1,
276 GNUNET_NO);
273 dc->ackp (dc->cls, mc->fragment_id, &fa.header); 277 dc->ackp (dc->cls, mc->fragment_id, &fa.header);
274} 278}
275 279
@@ -445,7 +449,7 @@ GNUNET_DEFRAGMENT_process_fragment (struct GNUNET_DEFRAGMENT_Context *dc,
445 return GNUNET_SYSERR; 449 return GNUNET_SYSERR;
446 } 450 }
447 GNUNET_STATISTICS_update (dc->stats, 451 GNUNET_STATISTICS_update (dc->stats,
448 _("Fragments received"), 452 _("# fragments received"),
449 1, 453 1,
450 GNUNET_NO); 454 GNUNET_NO);
451 mc = dc->head; 455 mc = dc->head;
@@ -509,7 +513,7 @@ GNUNET_DEFRAGMENT_process_fragment (struct GNUNET_DEFRAGMENT_Context *dc,
509 { 513 {
510 duplicate = GNUNET_YES; 514 duplicate = GNUNET_YES;
511 GNUNET_STATISTICS_update (dc->stats, 515 GNUNET_STATISTICS_update (dc->stats,
512 _("Duplicate fragments received"), 516 _("# duplicate fragments received"),
513 1, 517 1,
514 GNUNET_NO); 518 GNUNET_NO);
515 } 519 }
@@ -533,7 +537,7 @@ GNUNET_DEFRAGMENT_process_fragment (struct GNUNET_DEFRAGMENT_Context *dc,
533 (0 == mc->bits) ) 537 (0 == mc->bits) )
534 { 538 {
535 GNUNET_STATISTICS_update (dc->stats, 539 GNUNET_STATISTICS_update (dc->stats,
536 _("Messages defragmented"), 540 _("# messages defragmented"),
537 1, 541 1,
538 GNUNET_NO); 542 GNUNET_NO);
539 /* message complete, notify! */ 543 /* message complete, notify! */
diff --git a/src/fragmentation/fragmentation.c b/src/fragmentation/fragmentation.c
index db66f5a5b..6afdc1533 100644
--- a/src/fragmentation/fragmentation.c
+++ b/src/fragmentation/fragmentation.c
@@ -49,6 +49,11 @@ struct GNUNET_FRAGMENT_Context
49 struct GNUNET_TIME_Relative delay; 49 struct GNUNET_TIME_Relative delay;
50 50
51 /** 51 /**
52 * Next allowed transmission time.
53 */
54 struct GNUNET_TIME_Absolute delay_until;
55
56 /**
52 * Time we transmitted the last message of the last round. 57 * Time we transmitted the last message of the last round.
53 */ 58 */
54 struct GNUNET_TIME_Absolute last_round; 59 struct GNUNET_TIME_Absolute last_round;
@@ -173,11 +178,11 @@ transmit_next (void *cls,
173 if (NULL != fc->tracker) 178 if (NULL != fc->tracker)
174 GNUNET_BANDWIDTH_tracker_consume (fc->tracker, fsize); 179 GNUNET_BANDWIDTH_tracker_consume (fc->tracker, fsize);
175 GNUNET_STATISTICS_update (fc->stats, 180 GNUNET_STATISTICS_update (fc->stats,
176 _("Fragments transmitted"), 181 _("# fragments transmitted"),
177 1, GNUNET_NO); 182 1, GNUNET_NO);
178 if (0 != fc->last_round.abs_value) 183 if (0 != fc->last_round.abs_value)
179 GNUNET_STATISTICS_update (fc->stats, 184 GNUNET_STATISTICS_update (fc->stats,
180 _("Fragments retransmitted"), 185 _("# fragments retransmitted"),
181 1, GNUNET_NO); 186 1, GNUNET_NO);
182 187
183 /* select next message to calculate delay */ 188 /* select next message to calculate delay */
@@ -201,6 +206,7 @@ transmit_next (void *cls,
201 fc->wack = GNUNET_YES; 206 fc->wack = GNUNET_YES;
202 } 207 }
203 fc->proc_busy = GNUNET_YES; 208 fc->proc_busy = GNUNET_YES;
209 fc->delay_until = GNUNET_TIME_relative_to_absolute (delay);
204 fc->proc (fc->proc_cls, &fh->header); 210 fc->proc (fc->proc_cls, &fh->header);
205} 211}
206 212
@@ -237,12 +243,12 @@ GNUNET_FRAGMENT_context_create (struct GNUNET_STATISTICS_Handle *stats,
237 uint64_t bits; 243 uint64_t bits;
238 244
239 GNUNET_STATISTICS_update (stats, 245 GNUNET_STATISTICS_update (stats,
240 _("Messages fragmented"), 246 _("# messages fragmented"),
241 1, GNUNET_NO); 247 1, GNUNET_NO);
242 GNUNET_assert (mtu >= 1024 + sizeof (struct FragmentHeader)); 248 GNUNET_assert (mtu >= 1024 + sizeof (struct FragmentHeader));
243 size = ntohs (msg->size); 249 size = ntohs (msg->size);
244 GNUNET_STATISTICS_update (stats, 250 GNUNET_STATISTICS_update (stats,
245 _("Total size of fragmented messages"), 251 _("# total size of fragmented messages"),
246 size, GNUNET_NO); 252 size, GNUNET_NO);
247 GNUNET_assert (size > mtu); 253 GNUNET_assert (size > mtu);
248 fc = GNUNET_malloc (sizeof (struct GNUNET_FRAGMENT_Context) + size); 254 fc = GNUNET_malloc (sizeof (struct GNUNET_FRAGMENT_Context) + size);
@@ -281,8 +287,9 @@ GNUNET_FRAGMENT_context_transmission_done (struct GNUNET_FRAGMENT_Context *fc)
281 GNUNET_assert (fc->proc_busy == GNUNET_YES); 287 GNUNET_assert (fc->proc_busy == GNUNET_YES);
282 fc->proc_busy = GNUNET_NO; 288 fc->proc_busy = GNUNET_NO;
283 GNUNET_assert (fc->task == GNUNET_SCHEDULER_NO_TASK); 289 GNUNET_assert (fc->task == GNUNET_SCHEDULER_NO_TASK);
284 fc->task = GNUNET_SCHEDULER_add_now (&transmit_next, 290 fc->task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_absolute_get_remaining (fc->delay_until),
285 fc); 291 &transmit_next,
292 fc);
286} 293}
287 294
288 295
@@ -322,11 +329,15 @@ GNUNET_FRAGMENT_process_ack (struct GNUNET_FRAGMENT_Context *fc,
322 ndelay = GNUNET_TIME_absolute_get_duration (fc->last_round); 329 ndelay = GNUNET_TIME_absolute_get_duration (fc->last_round);
323 fc->delay.rel_value = (ndelay.rel_value + 3 * fc->delay.rel_value) / 4; 330 fc->delay.rel_value = (ndelay.rel_value + 3 * fc->delay.rel_value) / 4;
324 } 331 }
332 GNUNET_STATISTICS_update (fc->stats,
333 _("# fragment acknowledgements received"),
334 1,
335 GNUNET_NO);
325 if (abits != (fc->acks & abits)) 336 if (abits != (fc->acks & abits))
326 { 337 {
327 /* ID collission or message reordering, count! This should be rare! */ 338 /* ID collission or message reordering, count! This should be rare! */
328 GNUNET_STATISTICS_update (fc->stats, 339 GNUNET_STATISTICS_update (fc->stats,
329 _("Bits removed from ACK"), 340 _("# bits removed from fragmentation ACKs"),
330 1, GNUNET_NO); 341 1, GNUNET_NO);
331 } 342 }
332 fc->acks = abits; 343 fc->acks = abits;
@@ -340,6 +351,10 @@ GNUNET_FRAGMENT_process_ack (struct GNUNET_FRAGMENT_Context *fc,
340 } 351 }
341 352
342 /* all done */ 353 /* all done */
354 GNUNET_STATISTICS_update (fc->stats,
355 _("# fragmentation transmissions completed"),
356 1,
357 GNUNET_NO);
343 if (fc->task != GNUNET_SCHEDULER_NO_TASK) 358 if (fc->task != GNUNET_SCHEDULER_NO_TASK)
344 { 359 {
345 GNUNET_SCHEDULER_cancel (fc->task); 360 GNUNET_SCHEDULER_cancel (fc->task);