Changeset c219603
- Timestamp:
- 03/22/06 14:25:34 (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:
- 4af54d1
- Parents:
- 9c4b5e3
- Location:
- examples/rate
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
examples/rate/rate-dir.c
rd56089a rc219603 118 118 struct libtrace_ip *ipptr = 0; 119 119 struct libtrace_packet_t *packet = trace_create_packet(); 120 120 libtrace_err_t trace_err; 121 121 122 uint32_t last_second = 0; 122 123 double ts = 0.0; … … 128 129 // create an trace to uri 129 130 trace = trace_create(uri); 130 131 if (trace_is_err(trace)) { 132 trace_err = trace_get_err(trace); 133 printf("Error in trace_create: %s\n", trace_err.problem); 134 return -1; 135 } 136 trace_start(trace); 137 if (trace_is_err(trace)) { 138 trace_err = trace_get_err(trace); 139 printf("Error in trace_start: %s\n", trace_err.problem); 140 return -1; 141 } 131 142 132 143 for (;;) { 133 if ((psize = trace_read_packet(trace, &packet)) == -1) {144 if ((psize = trace_read_packet(trace,packet)) == -1) { 134 145 // terminate 135 146 break; … … 139 150 } 140 151 141 if((ipptr = trace_get_ip( &packet)) == 0) {152 if((ipptr = trace_get_ip(packet)) == 0) { 142 153 continue; 143 154 } 144 155 145 direction = trace_get_direction( &packet);156 direction = trace_get_direction(packet); 146 157 147 158 counter[direction][BYTES][INSTANT] += ntohs(ipptr->ip_len); 148 159 counter[direction][PACKETS][INSTANT] ++; 149 160 150 ts = trace_get_seconds( &packet);161 ts = trace_get_seconds(packet); 151 162 if(last_second == 0) { 152 163 last_second = (int)ts; -
examples/rate/rate.c
rd56089a rc219603 96 96 struct libtrace_ip *ipptr = 0; 97 97 struct libtrace_packet_t *packet = trace_create_packet(); 98 libtrace_err_t trace_err; 98 99 99 100 uint32_t last_second = 0; … … 107 108 // create an trace to uri 108 109 trace = trace_create(uri); 110 if (trace_is_err(trace)) { 111 trace_err = trace_get_err(trace); 112 printf("Error in trace_create: %s\n", trace_err.problem); 113 return -1; 114 } 115 trace_start(trace); 116 if (trace_is_err(trace)) { 117 trace_err = trace_get_err(trace); 118 printf("Error in trace_start: %s\n", trace_err.problem); 119 return -1; 120 } 109 121 110 122 111 123 for (;;) { 112 if ((psize = trace_read_packet(trace, &packet)) < 1) {124 if ((psize = trace_read_packet(trace,packet)) < 1) { 113 125 // terminate 114 126 break; … … 118 130 } 119 131 120 if((ipptr = trace_get_ip( &packet)) == 0) {132 if((ipptr = trace_get_ip(packet)) == 0) { 121 133 continue; 122 134 } … … 125 137 counter[PACKETS][INSTANT] ++; 126 138 127 ts = trace_get_seconds( &packet);139 ts = trace_get_seconds(packet); 128 140 if(last_second == 0) { 129 141 last_second = (int)ts;
Note: See TracChangeset
for help on using the changeset viewer.