~ubuntu-branches/ubuntu/dapper/flow-tools/dapper

« back to all changes in this revision

Viewing changes to src/flow-stat.c

  • Committer: Bazaar Package Importer
  • Author(s): Radu Spineanu
  • Date: 2005-06-02 20:12:57 UTC
  • mfrom: (1.1.1 upstream) (2.1.1 sarge)
  • Revision ID: james.westby@ubuntu.com-20050602201257-jv0qdk3hjhpdf04b
Tags: 1:0.68-2
Fixed a bashism in init script (closes: #311568)

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24
24
 * SUCH DAMAGE.
25
25
 *
26
 
 *      $Id: flow-stat.c,v 1.45 2003/11/25 06:12:54 maf Exp $
 
26
 *      $Id: flow-stat.c,v 1.46 2004/11/03 02:12:36 maf Exp $
27
27
 */
28
28
 
29
29
#include "ftconfig.h"
624
624
 
625
625
  if (fs0.nflows) {
626
626
 
627
 
    fs0.aflowtime = fs0.time / fs0.nflows;
628
 
    fs0.aps = fs0.noctets / fs0.npackets;
629
 
    fs0.afs = fs0.noctets / fs0.nflows;
630
 
    fs0.apf = fs0.npackets / fs0.nflows;
 
627
    fs0.aflowtime = (fs0.nflows != 0) ? fs0.time / (float)fs0.nflows : 0;
 
628
    fs0.aps = (fs0.npackets != 0) ? fs0.noctets / (float)fs0.npackets : 0;
 
629
    fs0.afs = (fs0.nflows != 0) ? fs0.noctets / (float)fs0.nflows : 0;
 
630
    fs0.apf = (fs0.nflows != 0) ?  fs0.npackets / (float)fs0.nflows : 0;
631
631
    fs0.fps = (float)fs0.nflows / ((fs0.end - fs0.start) / 1000);
632
632
    fs0.aos = ((float)(fs0.noctets*8) / 1000) / ((fs0.end - fs0.start) / 1000);
633
 
    fs0.time_real = fs0.time_end - fs0.time_start;
634
 
  
635
 
    fs0.fps_real = (float)fs0.nflows / (float)fs0.time_real;
636
 
    fs0.aos_real = ((float)(fs0.noctets*8) / 1000) / (fs0.time_real);
 
633
    fs0.time_real = (fs0.npackets != 0) ? fs0.time_end - fs0.time_start : 0;
 
634
 
 
635
    fs0.fps_real = (fs0.time_real != 0) ? ((float)fs0.nflows /
 
636
      (float)fs0.time_real) : 0; 
 
637
    fs0.aos_real = (fs0.time_real != 0) ? (((float)(fs0.noctets*8) / 1000) /
 
638
      (fs0.time_real)) : 0;
637
639
  
638
640
    strcpy(fmt_buf, "Total Flows                     : ");
639
641
    fmt_uint64(fmt_buf+34, fs0.nflows, FMT_JUST_LEFT);
656
658
    puts(fmt_buf);
657
659
  
658
660
    strcpy(fmt_buf, "Duration of data (1/1000 secs)  : ");
659
 
    fmt_uint64(fmt_buf+34, (fs0.end - fs0.start), FMT_JUST_LEFT);
 
661
    fmt_uint64(fmt_buf+34, (fs0.npackets != 0) ? (fs0.end - fs0.start) : 0,
 
662
      FMT_JUST_LEFT);
660
663
    puts(fmt_buf);
661
664
  
662
665
    printf("Average flow time (1/1000 secs) : %4.4f\n", fs0.aflowtime);