source: tools/tracereport/drops_report.c @ 624c2da

4.0.1-hotfixescachetimestampsdevelopdpdk-ndagetsilivegetfragoffhelplibtrace4ndag_formatpfringrc-4.0.1rc-4.0.2rc-4.0.3rc-4.0.4ringdecrementfixringperformanceringtimestampfixes
Last change on this file since 624c2da was 4423dc7, checked in by Perry Lorier <perry@…>, 14 years ago

Add support to various tools for outputting the number of dropped packets
they've seen

  • Property mode set to 100644
File size: 1.5 KB
RevLine 
[4423dc7]1#include <inttypes.h>
2#include <stdio.h>
3#include <stdbool.h>
4#include <time.h>
5#include <string.h>
6#include "libtrace.h"
7#include "tracereport.h"
8#include "report.h"
9
10static uint64_t received_packets = 0;
11static uint64_t filtered_packets = 0;
12static uint64_t dropped_packets = 0;
13static uint64_t accepted_packets = 0;
14
15static bool has_received=false;
16static bool has_filtered=false;
17static bool has_dropped=false;
18static bool has_accepted=false;
19
20void drops_per_trace(libtrace_t *trace)
21{
22        uint64_t packets;
23
24        packets = trace_get_received_packets(trace);
25        if (packets != UINT64_MAX) {
26                received_packets+=packets;
27                has_received=true;
28        }
29
30        packets = trace_get_filtered_packets(trace);
31        if (packets != UINT64_MAX) {
32                filtered_packets+=packets;
33                has_filtered=true;
34        }
35
36        packets = trace_get_dropped_packets(trace);
37        if (packets != UINT64_MAX) {
38                dropped_packets+=packets;
39                has_dropped=true;
40        }
41
42        packets = trace_get_accepted_packets(trace);
43        if (packets != UINT64_MAX) {
44                accepted_packets+=packets;
45                has_accepted=true;
46        }
47}
48
49
50void drops_report(void)
51{
52        FILE *out = fopen("drop.rpt", "w");
53        if (!out) {
54                perror("fopen");
55                return;
56        }
57        if (has_received)
58                fprintf(out, "Received Packets: %" PRIu64 "\n", received_packets);
59        if (has_filtered)
60                fprintf(out, "Filtered Packets: %" PRIu64 "\n", filtered_packets);
61        if (has_dropped)
62                fprintf(out, "Dropped Packets: %" PRIu64 "\n", dropped_packets);
63
64        if (has_accepted)
65                fprintf(out, "Accepted Packets: %" PRIu64 "\n", accepted_packets);
66        fclose(out);
67}
Note: See TracBrowser for help on using the repository browser.