Changeset aa27e1e for examples


Ignore:
Timestamp:
10/26/04 16:16:27 (16 years ago)
Author:
Daniel Lawson <dlawson@…>
Branches:
4.0.1-hotfixes, cachetimestamps, develop, dpdk-ndag, etsilive, getfragoff, help, libtrace4, master, ndag_format, pfring, rc-4.0.1, rc-4.0.2, rc-4.0.3, rc-4.0.4, ringdecrementfix, ringperformance, ringtimestampfixes
Children:
a6d38b6
Parents:
678048a
Message:

added loss detection to 'capture'

Location:
examples/capture
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • examples/capture/Makefile

    r678048a raa27e1e  
    44
    55INCLUDE = -I$(PREFIX)/include
    6 CFLAGS = -Wall -Wimplicit -Wformat -pipe -g -O2
     6CFLAGS = -Wall -Wimplicit -Wformat -pipe -g -O2 -D_FILE_OFFSET_BITES=64
    77CFLAGS += $(INCLUDE)
    88libdir = -L$(PREFIX)/lib
  • examples/capture/capture.c

    r678048a raa27e1e  
    5252typedef enum counter_type {
    5353        BYTES = 0,
    54         PACKETS = 1
     54        PACKETS = 1,
     55        LOSS = 2,
    5556} counter_type_t;
    5657
    57 #define MAXCOUNTERTYPE (PACKETS + 1)
     58#define MAXCOUNTERTYPE (LOSS + 1)
    5859
    5960uint32_t counter[MAXCOUNTERTYPE];
     
    7071
    7172        if (hdrcount >= 10) {
    72                 printf("Byte count:                     Packet count: \n");
     73                printf("Byte count:     Packet count:           Loss count\n");
    7374                hdrcount = 0;
    7475        }
    7576        hdrcount++;
    76         printf("\t\t%d\t\t\t%d \n",
     77        printf("\t\t%d\t\t%d\t\t%d \n",
    7778                        counter[BYTES],
    78                         counter[PACKETS]);
     79                        counter[PACKETS],
     80                        counter[LOSS]);
    7981        counter[BYTES] = 0;
    8082        counter[PACKETS] = 0;
     83        counter[LOSS] = 0;
    8184        docalc=0;
    8285}
     
    109112        if (argc == 2) {
    110113                uri = strdup(argv[1]);
    111                 filename = "./output";
     114                filename = 0;
    112115        }
    113116
     
    115118                uri = strdup(argv[1]);
    116119                filename = strdup(argv[2]);
     120                fout = fopen(filename,"w");
    117121        }
    118 
    119         fout = fopen(filename,"w");
     122       
    120123        // create an trace to uri
    121124        trace = trace_create(uri);
     
    135138                counter[BYTES] += ntohs(erfptr->rlen);
    136139                counter[PACKETS] ++;
     140                counter[LOSS] += ntohs(erfptr->lctr);
    137141
    138142                if(docalc) {
    139143                        secondreport();
    140144                }
    141 
    142                 fwrite(erfptr,psize,1,fout);
     145               
     146                if (filename)
     147                        fwrite(erfptr,psize,1,fout);
    143148
    144149
Note: See TracChangeset for help on using the changeset viewer.