Changeset e991529 for tools/tracereport/ttl_report.c
- Timestamp:
- 04/27/07 11:52:15 (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:
- bd4bec9
- Parents:
- 1dc58e0
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
tools/tracereport/ttl_report.c
rb5dc60d re991529 8 8 static stat_t ttl_stat[3][256] = {{{0,0}}} ; 9 9 static bool suppress[3] = {true,true,true}; 10 11 FILE *out = NULL; 10 12 11 13 void ttl_per_packet(struct libtrace_packet_t *packet) … … 25 27 } 26 28 27 void ttl_suppress() 28 { 29 int i; 30 printf("%-20s","Direction:"); 31 for(i=0;i<3;i++){ 32 if(!suppress[i]){ 33 switch(i){ 34 case 0: 35 printf("\t%24s", "Outbound "); 36 break; 37 case 1: 38 printf("\t%24s", "Inbound "); 39 break; 40 case 2: 41 printf("\t%24s", "Undefined "); 42 break; 43 default: 44 break; 45 } 46 } 47 } 48 printf("\n"); 49 printf("%-20s","TTL"); 50 for(i=0;i<3;i++){ 51 if(!suppress[i]){ 52 printf("\t%12s\t%12s", "bytes","packets"); 53 } 54 } 55 printf("\n"); 56 } 29 57 30 58 31 void ttl_report(void) 59 32 { 60 33 int i,j; 61 printf("# TTL breakdown:\n"); 62 ttl_suppress(); 34 out = fopen("ttl.out", "w"); 35 if (!out) { 36 perror("fopen"); 37 return; 38 } 39 fprintf(out, "%-12s\t%10s\t%16s %16s\n", 40 "TTL", 41 "DIRECTION", 42 "BYTES", 43 "PACKETS"); 63 44 for(i=0;i<256;++i) { 64 45 if (ttl_stat[0][i].count==0 && 65 46 ttl_stat[1][i].count==0 && ttl_stat[2][i].count==0) 66 47 continue; 67 printf("%20i:",i);48 fprintf(out, "%12i:",i); 68 49 for(j=0;j<3;j++){ 69 if (ttl_stat[j][i].count==0){ 70 if(!suppress[j]) 71 printf("\t%24s"," "); 72 continue; 50 if (j != 0) { 51 fprintf(out, "%12s", " "); 73 52 } 74 printf("\t%12" PRIu64 "\t%12" PRIu64, 75 ttl_stat[j][i].bytes, 76 ttl_stat[j][i].count); 53 switch (j) { 54 case 0: 55 fprintf(out, "\t%10s", "Outbound"); 56 break; 57 case 1: 58 fprintf(out, "\t%10s", "Inbound"); 59 break; 60 case 2: 61 fprintf(out, "\t%10s", "Unknown"); 62 break; 63 } 64 65 fprintf(out, "\t%16llu %16llu\n", 66 ttl_stat[j][i].bytes, 67 ttl_stat[j][i].count); 77 68 } 78 printf("\n");79 69 } 70 fclose(out); 80 71 }
Note: See TracChangeset
for help on using the changeset viewer.