/* $Id: mcl_stats.cpp,v 1.2 2003/10/27 09:55:48 roca Exp $ */ /* * Copyright (c) 1999-2003 INRIA - Universite Paris 6 - All rights reserved * (main author: Vincent Roca - vincent.roca@inrialpes.fr) * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, * USA. */ #include "mcl_includes.h" /****** Statistical functions ******/ void mcl_print_tx_profile (mclcb_t *mclcb) { int i; txlvl_t *tl; float tps = (float) mclcb->rate_l0; float kbps_per_du = (float)((mclcb->payload_size * 8) * tps / 1000.0); ASSERT(mclcb->verbose > 0); for (i = 0, tl = mclcb->txlvl_tab; i < MAX_TX_LEVEL; i++, tl++) { /* ticks per second (this is an int!) */ PRINT_OUT((mcl_stdout, "TX rate on layer %d: rate=%.2f kbps (%.2f pkts/s) cumul_rate=%.2f kbps\n", i, (float)tl->du_per_tick * kbps_per_du, (float)tl->du_per_tick * tps, (float)tl->rate * kbps_per_du)) if (mclcb->single_layer_mode) { break; } } } /* * Print sending side statistics */ void mcl_print_tx_stats (mclcb_t *mclcb) { int i; int max_i = MAX_TX_LEVEL; stats_t *sp; struct timeval tv; ASSERT(mclcb->statistics); sp = &(mclcb->stats); tv = mcl_get_tvtime(); PRINT_OUT((stdout, "\n--- TX STATISTICS at t=%ld.%06ld ---\n", tv.tv_sec, tv.tv_usec)) #ifdef NEVERDEF PRINT_OUT((mcl_stdout, "\n--- TX STATISTICS at t=%d ---\n", mcl_time_count)) #endif PRINT_OUT((mcl_stdout, "\tPayload: tx_src_bytes=%ld tx_fec_bytes=%ld\n\ttx bytes per layer:\t", sp->tx_bytes, sp->tx_fec_bytes)) for (i=0; i < max_i; i++) { PRINT_OUT((mcl_stdout, "%ld\t", sp->tx_bytes_per_lvl[i])) } PRINT_OUT((mcl_stdout, "\n\ttx_src_pkts=%ld tx_fec_pkts=%ld\n\ttx pkts per layer:\t", sp->tx_pkts, sp->tx_fec_pkts)) for (i=0; i < max_i; i++) { PRINT_OUT((mcl_stdout, "%ld\t", sp->tx_pkts_per_lvl[i])) } PRINT_OUT((mcl_stdout, "\n\tPayload+SIG: tot_snt=%ld tot_rx=%ld bytes\n\tbuf_space=%ld max_buf_space=%ld adu_announced=%ld\n", sp->tx_totbytes, sp->rx_totbytes, sp->buf_space, sp->max_buf_space, sp->adus_announced)) #ifdef SIMUL_LOSSES if (sp->tx_simul_loss_sent > 0) { PRINT_OUT((mcl_stdout, "\tsimul_losses: lost=%ld loss_ratio=%.3f\n", sp->tx_simul_loss_lost, (float)sp->tx_simul_loss_lost/(float)sp->tx_simul_loss_sent)) } #endif // mclcb->stats_time_count = STATS_PERIOD / MCL_TIMER_PERIOD; /* for periodic stats print */ } /* * Print receiving side statistics */ void mcl_print_rx_stats (mclcb_t *mclcb) { int i; int max_i = MAX_TX_LEVEL; stats_t *sp; struct timeval tv; ASSERT(mclcb->statistics); sp = &(mclcb->stats); tv = mcl_get_tvtime(); PRINT_OUT((stdout, "\n--- RX STATISTICS at t=%ld.%06ld ---\n", tv.tv_sec, tv.tv_usec)) #ifdef NEVERDEF PRINT_OUT((mcl_stdout, "\n--- RX STATISTICS at t=%d ---\n", mcl_time_count)) #endif PRINT_OUT((mcl_stdout, "\tADUs completed/announced: %ld / %ld\n", sp->adus_compl, sp->adus_announced)) /* * Byte stats */ PRINT_OUT((mcl_stdout, "\trx_src_bytes=%ld rx_fec_bytes=%ld including dup_bytes=%ld\n\tbytes per layer:\t", sp->rx_bytes, sp->rx_fec_bytes, sp->rx_dupl_bytes)) for (i=0; i < max_i; i++) { PRINT_OUT((mcl_stdout, "%ld\t", sp->rx_bytes_per_lvl[i])) } /* * Packet stats */ PRINT_OUT((mcl_stdout, "\n\trx_src_pkts=%ld rx_fec_pkts=%ld including dup_pkts=%ld lost_pkts=%ld\n\tdup/rx=%.3f rx/undup=%.3f\n\tpkts per layer: \t", sp->rx_pkts, sp->rx_fec_pkts, sp->rx_dupl_pkts, sp->rx_lost_pkts, (float)sp->rx_dupl_pkts / (float)(sp->rx_pkts + sp->rx_fec_pkts), (float)(sp->rx_pkts + sp->rx_fec_pkts) / (float)(sp->rx_pkts + sp->rx_fec_pkts - sp->rx_dupl_pkts))) for (i=0; i < max_i; i++) { PRINT_OUT((mcl_stdout, "%ld\t", sp->rx_pkts_per_lvl[i])) } PRINT_OUT((mcl_stdout, "\n\tundup pkts per layer:\t")) for (i=0; i < max_i; i++) { PRINT_OUT((mcl_stdout, "%ld\t", sp->rx_undup_pkts_per_lvl[i])) } PRINT_OUT((mcl_stdout, "\n\tlost pkts per layer:\t")) for (i=0; i < max_i; i++) { PRINT_OUT((mcl_stdout, "%ld\t", sp->rx_lost_per_lvl[i])) } PRINT_OUT((mcl_stdout, "\n\tData+SIG: tot_snt=%ld tot_rx=%ld bytes\n\tbuf_space=%ld max_buf_space=%ld\n\terrors=%ld bad_demux_label=%ld adu_announced=%ld adu_completed=%ld\n", sp->tx_totbytes, sp->rx_totbytes, sp->buf_space, sp->max_buf_space, sp->errors, sp->bad_demux_label, sp->adus_announced, sp->adus_compl)) // mclcb->stats_time_count = STATS_PERIOD / MCL_TIMER_PERIOD; /* for periodic stats print */ } /* * End of reception stats */ void mcl_print_final_stats (mclcb_t *mclcb) { int i; stats_t *sp; ASSERT(mclcb->statistics); sp = &(mclcb->stats); PRINT_OUT((mcl_stdout, "\n--- END OF RX TIMES ---\n")) i = sp->finish_index - 1; if (i < 0) i = MAX_FIN_TIME - 1; do { ASSERT(i >= 0 && i < MAX_FIN_TIME); if (sp->finish_times[i][STATS_FIN_TIME] == 0 && sp->finish_times[i][STATS_SEQ] == 0) return; PRINT_OUT((mcl_stdout, "\t\tADU seq=%d time=%d\n", (int)sp->finish_times[i][STATS_SEQ], (int)sp->finish_times[i][STATS_FIN_TIME])) i--; if (i < 0) i = MAX_FIN_TIME - 1; } while (i != sp->finish_index); } #ifdef GET_SYSINFO /* * */ void mcl_print_sysinfo (mclcb_t *mclcb) { struct timeval time; time = mcl_get_tvtime(); PRINT_OUT((mcl_stdout, "\n%ld.%06ld\tsysinfo ", time.tv_sec, time.tv_usec)) /* * edit as required... choose user and appli name... * ugly but simple! */ #if defined(SOLARIS) system("ps -uroca -o pcpu,pmem,vsz,comm | grep mcl"); /* system("top -Uroca -b -d1 | grep mcl &"); */ #elif defined(LINUX) /* broken on linux... */ /* * if (mclcb->sender) * system("top -b -n1 | grep mclsend &"); * else * system("top -b -n1 | grep mclrecv &"); */ #endif } #endif /* GET_SYSINFO */