Пример #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
static int
traffic_init_files(void)
{
    static int created = 0;

    if (created)
	return;
    created = 1;

    /* open the output files */
    if (doplot_packets)
	plotter_packets =
	    new_plotter(NULL,
			PLOTTER_PACKETS_FILENAME,
			"packets per second over time by port",
			"time","packets/second",
			NULL);
    if (doplot_bytes)
	plotter_bytes =
	    new_plotter(NULL,
			PLOTTER_BYTES_FILENAME,
			"bytes per second over time by port",
			"time","bytes/second",
			NULL);
    if (doplot_active)
	plotter_active =
	    new_plotter(NULL,
			PLOTTER_ACTIVE_FILENAME,
			"active connections over time by port",
			"time","active connections",
			NULL);
    if (doplot_idle)
	plotter_idle =
	    new_plotter(NULL,
			PLOTTER_IDLE_FILENAME,
			"idle connections over time by port",
			"time","idle connections",
			NULL);
    if (doplot_open)
	plotter_open =
	    new_plotter(NULL,
			PLOTTER_OPEN_FILENAME,
			"open connections over time by port",
			"time","open connections",
			NULL);
    if (doplot_i_open)
	plotter_i_open =
	    new_plotter(NULL,
			PLOTTER_I_OPEN_FILENAME,
			"open connections over time by port - instantaneous",
			"time","number of connections",
			NULL);
    if (doplot_openclose) {
	plotter_openclose =
	    new_plotter(NULL,
			PLOTTER_OPENCLOSE_FILENAME,
			"connections opened and closed over time",
			"time","number of connections",
			NULL);
	line_num_opens = new_line(plotter_openclose, "Number Opens", "green");
	line_num_closes = new_line(plotter_openclose, "Number Closes", "red");
	line_open_conns = new_line(plotter_openclose, "Total Open", "blue");
    }
    if (doplot_halfopen) {
	plotter_halfopen =
	    new_plotter(NULL,
			PLOTTER_HALFOPEN_FILENAME,
			"half open connections over time",
			"time","number of half open connections",
			NULL);
	line_num_halfopens = new_line(plotter_halfopen,
				      "Halfopen Conns", "green");
    }
    if (doplot_pureacks) {
	plotter_pureacks =
	    new_plotter(NULL,
			PLOTTER_PUREACKS_FILENAME,
			"pure acks (no data) per second over time",
			"time","pureacks/second",
			NULL);
    }

    if (doplot_loss) {
	plotter_loss =
	    new_plotter(NULL,
			PLOTTER_LOSS_FILENAME,
			"packet loss per second over time",
			"time","events/second",
			NULL);
	line_dupacks = new_line(plotter_loss, "Triple Dupacks", "yellow");
	line_rexmits = new_line(plotter_loss, "Retransmits", "blue");
    }

    if (doplot_rtt) {
	plotter_rtt =
	    new_plotter(NULL,
			PLOTTER_RTT_FILENAME,
			"RTT over time",
			"time","RTT (msecs)",
			NULL);
	line_rtt_min = new_line(plotter_rtt, "Min RTT", "green");
	line_rtt_max = new_line(plotter_rtt, "Max RTT", "red");
	line_rtt_avg = new_line(plotter_rtt, "Average RTT", "blue");
    }

    if (doplot_data) {
	plotter_data =
	    new_plotter(NULL,
			PLOTTER_DATA_FILENAME,
			"Total Data Sent Over Time",
			"time","total bytes",
			NULL);
	line_data_all = new_line(plotter_data, "All Data", "blue");
	line_data_nonrexmit = new_line(plotter_data, "Non-Rexmitted Data", "red");
    }

    if (doplot_long) {
	char title[100];
	snprintf(title,sizeof(title),"connections still open after %d seconds\n",
		longconn_duration);
	plotter_long =
	    new_plotter(NULL,
			PLOTTER_LONG_FILENAME,
			title,
			"time","number of connections",
			NULL);
    }
}
Пример #3
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;
}