예제 #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
DoThru(
    tcb *ptcb,
    int nbytes)
{
    double etime;
    double thruput;
    char *myname, *hisname;

    /* init, if not already done */
    if (ZERO_TIME(&ptcb->thru_firsttime)) {
	char title[210];

	ptcb->thru_firsttime = current_time;
	ptcb->thru_lasttime = current_time;
	ptcb->thru_pkts = 1;
	ptcb->thru_bytes = nbytes;
	

	/* bug fix from Michele Clark - UNC */
	if (&ptcb->ptp->a2b == ptcb) {
	    myname = ptcb->ptp->a_endpoint;
	    hisname = ptcb->ptp->b_endpoint;
	} else {
	    myname = ptcb->ptp->b_endpoint;
	    hisname = ptcb->ptp->a_endpoint;
	}
	/* create the plotter file */
	snprintf(title,sizeof(title),"%s_==>_%s (throughput)",
		myname, hisname);
	ptcb->thru_plotter = new_plotter(ptcb,NULL,title,
					 "time","thruput (bytes/sec)",
					 THROUGHPUT_FILE_EXTENSION);
	if (graph_time_zero) {
	    /* set graph zero points */
	    plotter_nothing(ptcb->thru_plotter, current_time);
	}

	/* create lines for average and instantaneous values */
	ptcb->thru_avg_line =
	    new_line(ptcb->thru_plotter, "avg. tput", "blue");
	ptcb->thru_inst_line =
	    new_line(ptcb->thru_plotter, "inst. tput", "red");

	return;
    }

    /* if no data, then nothing to do */
    if (nbytes == 0)
	return;

    /* see if we should output the stats yet */
    if (ptcb->thru_pkts+1 >= thru_interval) {

	/* compute stats for this interval */
	etime = elapsed(ptcb->thru_firsttime,current_time);
	if (etime == 0.0)
	    etime = 1000;	/* ick, what if "no time" has passed?? */
	thruput = (double) ptcb->thru_bytes / ((double) etime / 1000000.0);

	/* instantaneous plot */
	extend_line(ptcb->thru_inst_line,
		     current_time, (int) thruput);

	/* compute stats for connection lifetime */
	etime = elapsed(ptcb->ptp->first_time,current_time);
	if (etime == 0.0)
	    etime = 1000;	/* ick, what if "no time" has passed?? */
	thruput = (double) ptcb->data_bytes / ((double) etime / 1000000.0);

	/* long-term average */
	extend_line(ptcb->thru_avg_line,
		     current_time, (int) thruput);

	/* reset stats for this interval */
	ptcb->thru_firsttime = current_time;
	ptcb->thru_pkts = 0;
	ptcb->thru_bytes = 0;
    }

    /* immediate value in yellow ticks */
    if (plot_tput_instant) {
	etime = elapsed(ptcb->thru_lasttime,current_time);
	if (etime == 0.0)
	    etime = 1000;	/* ick, what if "no time" has passed?? */
	thruput = (double) nbytes / ((double) etime / 1000000.0);
	plotter_temp_color(ptcb->thru_plotter,"yellow");
	plotter_dot(ptcb->thru_plotter,
		    current_time, (int) thruput);
    }

    /* add in the latest packet */
    ptcb->thru_lasttime = current_time;
    ++ptcb->thru_pkts;
    ptcb->thru_bytes += nbytes;
}