source: tools/tracereport/ttl_report.c @ 734dfb1

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

Add trace summary

  • Property mode set to 100644
File size: 663 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 ttl_stat[256] = { {0,0} } ;
8
9void ttl_per_packet(struct libtrace_packet_t *packet)
10{
11        struct libtrace_ip *ip = trace_get_ip(packet);
12        if (!ip)
13                return;
14
15        ttl_stat[ip->ip_ttl].count++;
16        ttl_stat[ip->ip_ttl].bytes+=trace_get_wire_length(packet);
17}
18
19void ttl_report(void)
20{
21        int i;
22        printf("# TTL breakdown:\n");
23        printf("%-20s \t%12s\t%12s\n","TTL","bytes","packets");
24        for(i=0;i<256;++i) {
25                if (ttl_stat[i].count==0)
26                        continue;
27                printf("%20i:\t%12" PRIu64 ":\t%12" PRIu64 "\n",
28                                i,
29                                ttl_stat[i].bytes,
30                                ttl_stat[i].count);
31        }
32}
Note: See TracBrowser for help on using the repository browser.