[Scamper-dev] DW's code review

Matthew Luckie mjl at luckie.org.nz
Tue May 27 15:11:15 PDT 2003


> Instead of setting 'nextprobe' before the while loop and
> incrementing it inside the loop, you can try setting
> 'nextprobe' to the current time inside the loop.

the solution that i've got in the code at
http://voodoo.cs.waikato.ac.nz/~mjl12/scamper-0.9.1.tar.gz

is to check if the time has jumped relative to the nextprobe value at each
point where we decide if we should send a packet yet or not.  the code is
the following:

      /*
       * is it time to send a packet yet?
       * we need to determine if the clock has jumped by a large amount by
       * comparing the current time to the time we are scheduled to send
       * another probe.  if it has jumped, then we will reset the nextprobe
       * time to play things safe.
       */

      diff = timeval_diff_msec(&tv, &nextprobe);
      if(diff > (int64_t)wait_between || diff < (int64_t)(wait_between*-2))
	{
#ifndef NDEBUG
	  fprintf(stderr, "time has jumped, diff %lld\n", diff);
#endif
	  memcpy(&nextprobe, &tv, sizeof(struct timeval));
	  timeval_add(&nextprobe, wait_between);
	}

for the RTT miscalculation bit, i check if the RTT is sane (i.e. not
negative and not huge)

  if(timeval_cmp(&resp->tv, &trace->hops[hop].tx_time[attempt]) >= 0 &&
     trace->hops[hop].rtt.tv_sec < timeout * 2)

timeout is how long we wait for before giving up on a probe.  by default
timeout is 5, so we presume the clock has jumped if the rtt is larger than
10.

if we presume the RTT value is not sane, then we pretend we never sent
that probe, i.e:

      memset(&trace->last_tx,       0, sizeof(struct timeval));
      memset(&trace->hops[hop].rtt, 0, sizeof(struct timeval));
      trace->hops[hop].tx--;


More information about the Scamper-dev mailing list