source: tools/tracereport/tos_report.c @ d3ff1fb

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

Add trace summary

  • Property mode set to 100644
File size: 678 bytes
Line 
1#include <netdb.h>
2#include <inttypes.h>
3#include <stdio.h>
4#include "libtrace.h"
5#include "tracereport.h"
6
7static stat_t tos_stat[256] = { {0,0} } ;
8
9void tos_per_packet(struct libtrace_packet_t *packet)
10{
11        struct libtrace_ip *ip = trace_get_ip(packet);
12        if (!ip)
13                return;
14
15        tos_stat[ip->ip_tos].count++;
16        tos_stat[ip->ip_tos].bytes+=trace_get_wire_length(packet);
17}
18
19void tos_report(void)
20{
21        int i;
22        printf("# TOS breakdown:\n");
23        printf("%-20s \t%12s\t%12s\n","ToS","bytes","packets");
24        for(i=0;i<256;++i) {
25                if (tos_stat[i].count==0)
26                        continue;
27                printf("%16s0x%02x:\t%12" PRIu64 ":\t%12" PRIu64 "\n",
28                                " ",
29                                i,
30                                tos_stat[i].bytes,
31                                tos_stat[i].count);
32        }
33}
Note: See TracBrowser for help on using the repository browser.