aboutsummaryrefslogtreecommitdiff
path: root/src/fragmentation/fragmentation.c
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/fragmentation.c
parent8af646076372f322fd772736523e890cef2d69f0 (diff)
downloadgnunet-d3c70c3bfde07f93c72effebbfd11436a5a9590c.tar.gz
gnunet-d3c70c3bfde07f93c72effebbfd11436a5a9590c.zip
nicer stats, bugfix
Diffstat (limited to 'src/fragmentation/fragmentation.c')
-rw-r--r--src/fragmentation/fragmentation.c29
1 files changed, 22 insertions, 7 deletions
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);