예제 #1
0
/* graph RTT samples in milliseconds */
static void
graph_rtt_sample (tcptrace_context_t *context,
                  tcb * ptcb,
		  segment * pseg,
		  unsigned long etime_rtt)
{
    char title[210];
    tcptrace_runtime_options_t *options = context->options;

    /* if the FILE is NULL, open file */
    if (ptcb->rtt_plotter == NO_PLOTTER) {
	char *name_from, *name_to;
	if (ptcb == &ptcb->ptp->a2b) {
	    name_from = ptcb->ptp->a_endpoint;
	    name_to = ptcb->ptp->b_endpoint;
	} else {
	    name_from = ptcb->ptp->b_endpoint;
	    name_to = ptcb->ptp->a_endpoint;
	}
	snprintf (title, sizeof (title), "%s_==>_%s (rtt samples)",
		  name_from, name_to);
	ptcb->rtt_plotter =
	    new_plotter(context, ptcb, NULL, title, "time", "rtt (ms)",
                        RTT_GRAPH_FILE_EXTENSION);
	plotter_perm_color (ptcb->rtt_plotter, "red");

	if (options->graph_time_zero) {
	    /* set graph zero points */
	    plotter_nothing (ptcb->rtt_plotter, context->current_time);
	}
	ptcb->rtt_line = new_line (ptcb->rtt_plotter, "rtt", "red");
    }

    if (etime_rtt <= 1)
	return;

    extend_line(ptcb->rtt_line, context->current_time, (int) (etime_rtt / 1000));
}
예제 #2
0
void
extend_line(
    PLINE pline,
    timeval xval,
    int yval)
{
    PLOTTER p;

    if (!pline)
	return;

    p = pline->plotter;

#ifdef OLD
    /* attach a label to the first non-zero point */
    if (!pline->labelled) {
	if (yval != 0) {
	    plotter_temp_color(p, pline->color);
	    plotter_text(p, xval, yval, "l", pline->label);
	    pline->labelled = 1;
	}
    }
#endif

    /* attach a label midway on the first line segment above 0 */
    /* for whom the second point is NOT 0 */
    if (!pline->labelled) {
	if ((yval != 0) && (!ZERO_TIME(&pline->last_time))) {
	    timeval tv_elapsed;
	    timeval tv_avg;
	    int avg_yval;

	    /* computer elapsed time for these 2 points */
	    tv_elapsed = xval;
	    tv_sub(&tv_elapsed,pline->last_time);

	    /* divide elapsed time by 2 */
	    tv_elapsed.tv_sec /= 2;
	    tv_elapsed.tv_usec /= 2;

	    /* add 1/2 of the elapsed time to the oldest point */
	    /* (giving us the average time) */
	    tv_avg = pline->last_time;
	    tv_add(&tv_avg, tv_elapsed);

	    /* average the Y values */
	    avg_yval = (1 + pline->last_y+yval)/2;
	    /* (rounding UP, please) */

	    /* draw the label */
	    plotter_temp_color(p, pline->color);
	    plotter_text(p, tv_avg, avg_yval, "l", pline->label);

	    /* remember that it's been done */
	    pline->labelled = 1;
	}
    }

    /* draw a dot at the current point */
    plotter_perm_color(p, pline->color);
    plotter_dot(p, xval, yval);

    /* if this isn't the FIRST point, connect with a line */
    if (!ZERO_TIME(&pline->last_time)) {
	plotter_line(p,
		     xval, yval,
		     pline->last_time, pline->last_y);
    }

    /* remember this point for the next line segment */
    pline->last_time = xval;
    pline->last_y = yval;
}