Changeset d4336d5 for tools/tracereport/ttl_report.c
- Timestamp:
- 02/21/07 14:39:26 (15 years ago)
- 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:
- 09be643
- Parents:
- c14602f
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
tools/tracereport/ttl_report.c
ra7282fb rd4336d5 5 5 #include "libtrace.h" 6 6 #include "tracereport.h" 7 #include "report.h"8 7 9 static stat_t ttl_stat[256] = { {0,0} } ; 8 static stat_t ttl_stat[4][256] = {{{0,0}}} ; 9 static bool suppress[4] = {true,true,true,true}; 10 10 11 11 void ttl_per_packet(struct libtrace_packet_t *packet) … … 14 14 if (!ip) 15 15 return; 16 int dir = trace_get_direction(packet); 17 if(dir < 0 || dir > 1) 18 dir = 2; 19 ttl_stat[dir][ip->ip_ttl].count++; 20 ttl_stat[dir][ip->ip_ttl].bytes+=trace_get_wire_length(packet); 21 suppress[dir] = false; 22 } 16 23 17 ttl_stat[ip->ip_ttl].count++; 18 ttl_stat[ip->ip_ttl].bytes+=trace_get_wire_length(packet); 24 void ttl_suppress() 25 { 26 int i; 27 printf("%-20s","Direction:"); 28 //printf("%20s", " "); 29 for(i=0;i<4;i++){ 30 if(!suppress[i]){ 31 switch(i){ 32 case 0: 33 printf("\t%24s", "Outbound "); 34 break; 35 case 1: 36 printf("\t%24s", "Inbound "); 37 break; 38 case 2: 39 printf("\t%24s", "Undefined "); 40 break; 41 default: 42 break; 43 } 44 } 45 } 46 printf("\n"); 47 printf("%-20s","TTL"); 48 for(i=0;i<4;i++){ 49 if(!suppress[i]){ 50 printf("\t%12s\t%12s", "bytes","packets"); 51 } 52 } 53 printf("\n"); 19 54 } 20 55 21 56 void ttl_report(void) 22 57 { 23 int i ;58 int i,j; 24 59 printf("# TTL breakdown:\n"); 25 printf("%-20s \t%12s\t%12s\n","TTL","bytes","packets");60 ttl_suppress(); 26 61 for(i=0;i<256;++i) { 27 if (ttl_stat[i].count==0) 62 if (ttl_stat[0][i].count==0 && 63 ttl_stat[1][i].count==0 && ttl_stat[2][i].count==0) 28 64 continue; 29 printf("%20i:\t%12" PRIu64 ":\t%12" PRIu64 "\n", 30 i, 31 ttl_stat[i].bytes, 32 ttl_stat[i].count); 65 printf("%20i:",i); 66 for(j=0;j<4;j++){ 67 if (ttl_stat[j][i].count==0){ 68 if(!suppress[j]) 69 printf("\t%24s"," "); 70 continue; 71 } 72 printf("\t%12" PRIu64 "\t%12" PRIu64, 73 ttl_stat[j][i].bytes, 74 ttl_stat[j][i].count); 75 } 76 printf("\n"); 77 } 78 79 int total; 80 for(i=0;i<4;i++){ 81 total = 0; 82 for(j=0;j<256;j++) 83 total += ttl_stat[i][j].count; 84 //printf("%s: %i\n", "Total", total); 33 85 } 34 86 }
Note: See TracChangeset
for help on using the changeset viewer.