Changeset 6463f32
- Timestamp:
- 03/01/17 11:48:37 (4 years ago)
- Branches:
- cachetimestamps, develop, dpdk-ndag, etsilive, master, rc-4.0.3, rc-4.0.4, ringdecrementfix, ringperformance
- Children:
- 14b7489
- Parents:
- d0a067f (diff), 204d65b (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent. - Files:
-
- 18 added
- 24 edited
Legend:
- Unmodified
- Added
- Removed
-
.gitignore
r864bd71 rcaf7841 81 81 test/test-wireless 82 82 test/test-write 83 test/DPDK_source/ 84 test/DPDK_builds/ 83 85 tools/traceanon/traceanon 84 86 tools/traceanon/traceanon_parallel -
AUTHORS
r67b6d9e r6450950 15 15 16 16 * Matt Brown for getting us into Debian and keeping us up to date. 17 * Brad Cowie for packaging libtrace4 for Debian and Ubuntu 17 18 * Alistair King for reporting and suggesting fixes for numerous bugs, 18 19 particularly in libwandio … … 27 28 * Robert Edmonds for tidying up the libpacketdump plugin install 28 29 * Martin Bligh for patching in support for nanosecond pcap traces 30 * Teemu Rytilahti for adding support for SIT 31 * "EaseTheWorld" for their work with improving the packet statistics API, as 32 well as reporting several bugs 33 * Richard Cziva for contributing to the DPDK support 29 34 * Jamie Curtis for fixing a couple of bugs many many years ago 30 35 * Brendon Jones for creating the original Windows DLLs and writing bits of -
README
r864bd71 rd759ee1 1 libtrace 4.0. 01 libtrace 4.0.1 2 2 3 3 --------------------------------------------------------------------------- 4 Copyright (c) 2007-201 6The University of Waikato, Hamilton, New Zealand.4 Copyright (c) 2007-2017 The University of Waikato, Hamilton, New Zealand. 5 5 All rights reserved. 6 6 -
configure.in
r32a3ec5 rd759ee1 4 4 # and in the README 5 5 6 AC_INIT([libtrace],[4.0. 0],[contact@wand.net.nz],[libtrace])6 AC_INIT([libtrace],[4.0.1],[contact@wand.net.nz],[libtrace]) 7 7 8 8 LIBTRACE_MAJOR=4 9 9 LIBTRACE_MID=0 10 LIBTRACE_MINOR= 010 LIBTRACE_MINOR=1 11 11 12 12 # OpenSolaris hides libraries like libncurses in /usr/gnu/lib, which is not … … 387 387 # Check for DPDK 388 388 AC_ARG_WITH(dpdk, 389 AS_HELP_STRING(--with-dpdk,include DPDK live capture support ( Must set RTE_SDK/_TARGET environment variable)),389 AS_HELP_STRING(--with-dpdk,include DPDK live capture support (From either the RTE_SDK/_TARGET environment variable or the dpdk-dev package)), 390 390 [ 391 391 if test "$withval" = no … … 402 402 libtrace_dpdk=false 403 403 if test "$want_dpdk" != no; then 404 saved_ldflags="$LDFLAGS" 405 # Add to our libpath location 406 LDFLAGS="$LDFLAGS -L$RTE_SDK/$RTE_TARGET/lib/" 407 # Test that the library exists, we cannot be sure of what extra library flags need to be added 408 # this could change in the next version which would make the test fail 409 #AC_CHECK_LIB(intel_dpdk, rte_eal_init, dpdk_found=1, dpdk_found=0, -lpthread -lm -lrt) 410 411 # So instead simply check for existence 412 AC_CHECK_FILE("$RTE_SDK/$RTE_TARGET/lib/libintel_dpdk.a", dpdk_found=1, dpdk_found=0) 413 # Revert back 414 LDFLAGS="$saved_ldflags" 415 if test "$dpdk_found" = 1; then 416 # Save these now so that they can be re-exported later 404 # So instead simply check for existence 405 if test "$RTE_SDK" != ""; then 406 AC_CHECK_FILE("$RTE_SDK/$RTE_TARGET/lib/libintel_dpdk.a", dpdk_found="libintel_dpdk.a", dpdk_found=0) 407 fi 408 # DPDK 2.1.0+ renames this to libdpdk from libintel_dpdk 409 if test "$dpdk_found" = 0 -a "$RTE_SDK" != ""; then 410 AC_CHECK_FILE("$RTE_SDK/$RTE_TARGET/lib/libdpdk.a", dpdk_found="libdpdk.a", dpdk_found=0) 411 fi 412 if test "$dpdk_found" != 0 -a "$RTE_SDK" != ""; then 413 # Save these now so that they can be re-exported later 417 414 AC_SUBST([RTE_TARGET]) 418 419 420 LIBTRACE_LIBS="$LIBTRACE_LIBS -Wl,--whole-archive -Wl,-l:libintel_dpdk.a-Wl,--no-whole-archive -Wl,-lm"415 AC_SUBST([RTE_SDK]) 416 # Force dpdk library to be statically linked to allow compiler optimisations 417 LIBTRACE_LIBS="$LIBTRACE_LIBS -Wl,--whole-archive -Wl,-l:$dpdk_found -Wl,--no-whole-archive -Wl,-lm" 421 418 AC_DEFINE(HAVE_DPDK,1,[conditional for building with DPDK live capture support]) 422 419 libtrace_dpdk=true 420 fi 421 if test "$RTE_SDK" = ""; then 422 AC_MSG_NOTICE([No RTE_SDK given, checking for system dpdk-dev package]) 423 # Search the system, maybe it is installed? Ethdev is one of the main libraries 424 AC_CHECK_LIB(ethdev, rte_eth_dev_configure, dpdk_found="system", dpdk_found=0) 425 # We also need to check that rte.vars.mk is installed from dpdk-dev (as well as libdpdk-dev) 426 if test "$dpdk_found" != 0 -a -e /usr/share/dpdk/mk/rte.vars.mk ; then 427 RTE_TARGET="x86_64-default-linuxapp-gcc" 428 RTE_SDK="/usr/share/dpdk/" 429 RTE_INCLUDE="/usr/include/dpdk" 430 AC_SUBST([RTE_TARGET]) 431 AC_SUBST([RTE_SDK]) 432 AC_SUBST([RTE_INCLUDE]) 433 # include libethdev this is part of DPDK 434 LIBTRACE_LIBS="$LIBTRACE_LIBS -lethdev" 435 # Include all rte libs note we need to escape '[' and ']' 436 LIBTRACE_LIBS="$LIBTRACE_LIBS $(ldconfig -p | sed 's/.*lib\([[^.]]*\).*/-l\1/' | grep rte_ | tr '\n' ' ')" 437 AC_MSG_NOTICE([Building against system DPDK]) 438 439 AC_DEFINE(HAVE_DPDK,1,[conditional for building with DPDK live capture support]) 440 libtrace_dpdk=true 441 fi 423 442 fi 424 443 fi … … 471 490 if test "$ac_cv_search_dlopen" != "none required"; then 472 491 LIBPKTDUMP_LIBS="$LIBPKTDUMP_LIBS $ac_cv_search_dlopen" 473 if test "$dpdk_found" = 1; then492 if test "$dpdk_found" != 0; then 474 493 LIBTRACE_LIBS="$LIBTRACE_LIBS -Wl,$ac_cv_search_dlopen" 475 494 fi -
lib/Makefile.am
re63d80d r4db5b98 1 1 lib_LTLIBRARIES = libtrace.la 2 include_HEADERS = libtrace.h dagformat.h lt_inttypes.h daglegacy.h \ 3 rt_protocol.h erftypes.h libtrace_parallel.h \ 2 include_HEADERS = libtrace.h libtrace_parallel.h 3 pkginclude_HEADERS = dagformat.h lt_inttypes.h daglegacy.h \ 4 rt_protocol.h erftypes.h \ 4 5 data-struct/ring_buffer.h data-struct/object_cache.h \ 5 data-struct/vector.h data-struct/message_queue.h\6 data-struct/vector.h \ 6 7 data-struct/deque.h data-struct/linked_list.h \ 7 data-struct/ sliding_window.h hash_toeplitz.h \8 data-struct/buckets.h8 data-struct/buckets.h data-struct/sliding_window.h \ 9 data-struct/message_queue.h hash_toeplitz.h 9 10 10 11 AM_CFLAGS=@LIBCFLAGS@ @CFLAG_VISIBILITY@ -pthread -
lib/format_bpf.c
ree6e802 r5e3f16c 497 497 498 498 /* Timed out -- check if we should halt */ 499 if ( libtrace_halt)500 return 0;499 if ((ret=is_halted(libtrace)) != -1) 500 return ret; 501 501 } 502 502 -
lib/format_dag25.c
ree6e802 rdb84bb2 1304 1304 return -2; 1305 1305 1306 if ( libtrace_halt)1307 return 0;1306 if ((numbytes=is_halted(libtrace)) != -1) 1307 return numbytes; 1308 1308 /* Block until we see a packet */ 1309 1309 continue; … … 1313 1313 1314 1314 packet->trace = libtrace; 1315 1315 1316 /* Prepare the libtrace packet */ 1316 1317 if (dag_prepare_packet_stream(libtrace, stream_data, packet, erfptr, … … 1324 1325 } 1325 1326 1327 packet->order = erf_get_erf_timestamp(packet); 1326 1328 packet->error = packet->payload ? htons(erfptr->rlen) : 1327 1329 erf_get_framing_length(packet); -
lib/format_dpdk.c
ree6e802 rdb84bb2 23 23 * 24 24 * 25 * /25 * 26 26 * Kit capture format. 27 27 * … … 69 69 * code (that we still attempt to support). 70 70 * 71 * DPDK v1.7.1is recommended.72 * However 1. 5 to 1.8 arelikely supported.71 * DPDK 16.04 or newer is recommended. 72 * However 1.6 and newer are still likely supported. 73 73 */ 74 74 #include <rte_eal.h> … … 145 145 #else 146 146 # define DPDK_USE_NULL_QUEUE_CONFIG 0 147 #endif 148 149 /* 2.0.0-rc1 150 * Unifies RSS hash between cards 151 */ 152 #if RTE_VERSION >= RTE_VERSION_NUM(2, 0, 0, 1) 153 # define RX_RSS_FLAGS (ETH_RSS_IP | ETH_RSS_UDP | ETH_RSS_TCP | \ 154 ETH_RSS_SCTP) 155 #else 156 # define RX_RSS_FLAGS (ETH_RSS_IPV4_UDP | ETH_RSS_IPV6 | ETH_RSS_IPV4 | \ 157 ETH_RSS_IPV4_TCP | ETH_RSS_IPV6_TCP |\ 158 ETH_RSS_IPV6_UDP) 159 #endif 160 161 /* v16.07-rc1 - deprecated 162 * rte_mempool_avail_count to replace rte_mempool_count 163 * rte_mempool_in_use_count to replace rte_mempool_free_count 164 */ 165 #if RTE_VERSION < RTE_VERSION_NUM(16, 7, 0, 1) 166 #define rte_mempool_avail_count rte_mempool_count 167 #define rte_mempool_in_use_count rte_mempool_free_count 147 168 #endif 148 169 … … 170 191 #endif 171 192 193 /* 16.04-rc3 ETH_LINK_SPEED_X are replaced with ETH_SPEED_NUM_X. 194 * ETH_LINK_SPEED_ are reused as flags, ugly. 195 * We use the new way in this code. 196 */ 197 #ifndef ETH_SPEED_NUM_1G 198 #define ETH_SPEED_NUM_1G ETH_LINK_SPEED_1000 199 #define ETH_SPEED_NUM_10G ETH_LINK_SPEED_10G 200 #define ETH_SPEED_NUM_20G ETH_LINK_SPEED_20G 201 #define ETH_SPEED_NUM_40G ETH_LINK_SPEED_40G 202 #endif 172 203 173 204 /* The default size of memory buffers to use - This is the max size of standard … … 175 206 #define RX_MBUF_SIZE 1514 176 207 177 /* The minimum number of memory buffers per queue tx or rx. Search for 178 * _MIN_RING_DESC in DPDK. The largest minimum is 64 for 10GBit cards. 179 */ 180 #define MIN_NB_BUF 64 208 /* The minimum number of memory buffers per queue tx or rx. Based on 209 * the requirement of the memory pool with 128 per thread buffers, needing 210 * at least 128*1.5 = 192 buffers. Our code allocates 128*2 to be safe. 211 */ 212 #define MIN_NB_BUF 128 181 213 182 214 /* Number of receive memory buffers to use … … 185 217 * This can be increased in the driver and here. 186 218 * Should be at least MIN_NB_BUF. 187 */ 188 #define NB_RX_MBUF 4096 219 * We choose 2K rather than 4K because it enables the usage of sse vector 220 * drivers which are significantly faster than using the larger buffer. 221 */ 222 #define NB_RX_MBUF (4096/2) 189 223 190 224 /* Number of send memory buffers to use. … … 203 237 /* For single threaded libtrace we read packets as a batch/burst 204 238 * this is the maximum size of said burst */ 205 #define BURST_SIZE 50239 #define BURST_SIZE 32 206 240 207 241 #define MBUF(x) ((struct rte_mbuf *) x) … … 229 263 * 230 264 * Make sure you understand what these are doing before enabling them. 231 * They might make traces incompat able with other builds etc.265 * They might make traces incompatible with other builds etc. 232 266 * 233 267 * These are also included to show how to do somethings which aren't … … 240 274 /* Use clock_gettime() for nanosecond resolution rather than gettimeofday() 241 275 * only turn on if you know clock_gettime is a vsyscall on your system 242 * o verwise could be a large overhead. Again gettimeofday() should be276 * otherwise could be a large overhead. Again gettimeofday() should be 243 277 * vsyscall also if it's not you should seriously consider updating your 244 278 * kernel. … … 297 331 int lcore; 298 332 #if HAS_HW_TIMESTAMPS_82580 299 /* Timestamping only relev ent to RX */333 /* Timestamping only relevant to RX */ 300 334 uint64_t ts_first_sys; /* Sytem timestamp of the first packet in nanoseconds */ 301 335 uint32_t wrap_count; /* Number of times the NIC clock has wrapped around completely */ … … 330 364 #endif 331 365 char mempool_name[MEMPOOL_NAME_LEN]; /* The name of the mempool that we are using */ 332 uint8_t rss_key[40]; // This is the RSS KEY 366 enum hasher_types hasher_type; 367 uint8_t *rss_key; 333 368 /* To improve single-threaded performance we always batch reading 334 369 * packets, in a burst, otherwise the parallel library does this for us */ … … 822 857 FORMAT(libtrace)->burst_size = 0; 823 858 FORMAT(libtrace)->burst_offset = 0; 859 FORMAT(libtrace)->hasher_type = HASHER_BALANCE; 860 FORMAT(libtrace)->rss_key = NULL; 824 861 825 862 /* Make our first stream */ … … 899 936 case HASHER_BALANCE: 900 937 case HASHER_UNIDIRECTIONAL: 901 toeplitz_create_unikey(FORMAT(libtrace)->rss_key);902 return 0;903 938 case HASHER_BIDIRECTIONAL: 904 toeplitz_create_bikey(FORMAT(libtrace)->rss_key); 939 FORMAT(libtrace)->hasher_type = *(enum hasher_types*)data; 940 if (FORMAT(libtrace)->rss_key) 941 free(FORMAT(libtrace)->rss_key); 942 FORMAT(libtrace)->rss_key = NULL; 905 943 return 0; 906 944 case HASHER_CUSTOM: 907 // We don't support these945 // Let libtrace do this 908 946 return -1; 909 947 } … … 958 996 .rx_adv_conf = { 959 997 .rss_conf = { 960 // .rss_key = &rss_key, // We set this per format 961 .rss_hf = ETH_RSS_IPV4_UDP | ETH_RSS_IPV6 | ETH_RSS_IPV4 | ETH_RSS_IPV4_TCP | ETH_RSS_IPV6_TCP | ETH_RSS_IPV6_UDP, 998 .rss_hf = RX_RSS_FLAGS, 962 999 }, 963 1000 }, … … 1087 1124 int i; 1088 1125 struct rte_config *cfg = rte_eal_get_configuration(); 1126 (void) socket; 1089 1127 1090 1128 pthread_mutex_lock(&dpdk_lock); … … 1246 1284 fprintf(stderr, "DPDK memory pool not empty %d of %d, please " 1247 1285 "free all packets before finishing a trace\n", 1248 rte_mempool_ count(mempool), mempool->size);1286 rte_mempool_avail_count(mempool), mempool->size); 1249 1287 } 1250 1288 … … 1315 1353 return -1; 1316 1354 } 1355 } 1356 1357 /* Generate the hash key, based on the device */ 1358 uint8_t rss_size = 52; // 52 for i40e, 40 for others, use the largest by default 1359 // In new versions DPDK we can query the size 1360 #if RTE_VERSION >= RTE_VERSION_NUM(2, 1, 0, 0) 1361 struct rte_eth_dev_info dev_info; 1362 rte_eth_dev_info_get(format_data->port, &dev_info); 1363 rss_size = dev_info.hash_key_size; 1364 #endif 1365 if (rss_size != 0) { 1366 format_data->rss_key = malloc(rss_size); 1367 if (format_data->hasher_type == HASHER_BIDIRECTIONAL) { 1368 toeplitz_ncreate_bikey(format_data->rss_key, rss_size); 1369 } else { 1370 toeplitz_ncreate_unikey(format_data->rss_key, rss_size); 1371 } 1372 port_conf.rx_adv_conf.rss_conf.rss_key = format_data->rss_key; 1373 #if RTE_VERSION >= RTE_VERSION_NUM(1, 7, 0, 1) 1374 port_conf.rx_adv_conf.rss_conf.rss_key_len = rss_size; 1375 #endif 1376 } else { 1377 fprintf(stderr, "DPDK couldn't configure RSS hashing!"); 1317 1378 } 1318 1379 … … 1720 1781 libtrace_list_deinit(FORMAT(libtrace)->per_stream); 1721 1782 /* filter here if we used it */ 1783 if (FORMAT(libtrace)->rss_key) 1784 free(FORMAT(libtrace)->rss_key); 1722 1785 free(libtrace->format_data); 1723 1786 } … … 1842 1905 retry_calc_wiretime: 1843 1906 switch (format_data->link_speed) { 1844 case ETH_ LINK_SPEED_40G:1845 wire_time /= ETH_ LINK_SPEED_40G;1907 case ETH_SPEED_NUM_40G: 1908 wire_time /= ETH_SPEED_NUM_40G; 1846 1909 break; 1847 case ETH_ LINK_SPEED_20G:1848 wire_time /= ETH_ LINK_SPEED_20G;1910 case ETH_SPEED_NUM_20G: 1911 wire_time /= ETH_SPEED_NUM_20G; 1849 1912 break; 1850 case ETH_ LINK_SPEED_10G:1851 wire_time /= ETH_ LINK_SPEED_10G;1913 case ETH_SPEED_NUM_10G: 1914 wire_time /= ETH_SPEED_NUM_10G; 1852 1915 break; 1853 case ETH_ LINK_SPEED_1000:1854 wire_time /= ETH_ LINK_SPEED_1000;1916 case ETH_SPEED_NUM_1G: 1917 wire_time /= ETH_SPEED_NUM_1G; 1855 1918 break; 1856 1919 case 0: … … 2072 2135 if (mesg && libtrace_message_queue_count(mesg) > 0) 2073 2136 return READ_MESSAGE; 2074 if ( libtrace_halt)2075 return READ_EOF;2137 if ((nb_rx=is_halted(libtrace)) != (size_t) -1) 2138 return nb_rx; 2076 2139 /* Wait a while, polling on memory degrades performance 2077 2140 * This relieves the pressure on memory allowing the NIC to DMA */ … … 2091 2154 int i; 2092 2155 dpdk_per_stream_t *stream = t->format_data; 2156 struct dpdk_addt_hdr * hdr; 2093 2157 2094 2158 nb_rx = dpdk_read_packet_stream (libtrace, stream, &t->messages, … … 2107 2171 packets[i]->trace = libtrace; 2108 2172 packets[i]->error = 1; 2173 hdr = (struct dpdk_addt_hdr *) 2174 ((struct rte_mbuf*) pkts_burst[i] + 1); 2175 packets[i]->order = hdr->timestamp; 2109 2176 dpdk_prepare_packet(libtrace, packets[i], packets[i]->buffer, packets[i]->type, 0); 2110 2177 } … … 2194 2261 stats->captured = dev_stats.ipackets; 2195 2262 2196 /* Not that we support adding filters but if we did this2197 * would work */2198 stats->filtered += dev_stats.fdirmiss;2199 2200 2263 stats->dropped_valid = true; 2201 2264 stats->dropped = dev_stats.imissed; 2202 2265 2266 #if RTE_VERSION >= RTE_VERSION_NUM(16, 4, 0, 2) 2267 /* DPDK commit 86057c fixes ensures missed does not get counted as 2268 * errors */ 2269 stats->errors_valid = true; 2270 stats->errors = dev_stats.ierrors; 2271 #else 2203 2272 /* DPDK errors includes drops */ 2204 2273 stats->errors_valid = true; 2205 2274 stats->errors = dev_stats.ierrors - dev_stats.imissed; 2206 2275 #endif 2207 2276 stats->received_valid = true; 2208 2277 stats->received = dev_stats.ipackets + dev_stats.imissed; … … 2217 2286 libtrace_packet_t *packet) { 2218 2287 libtrace_eventobj_t event = {0,0,0.0,0}; 2219 int nb_rx; /* Number of receive packets we've read */ 2220 struct rte_mbuf* pkts_burst[1]; /* Array of 1 pointer(s) to rx buffers */ 2288 size_t nb_rx; /* Number of received packets we've read */ 2221 2289 2222 2290 do { 2223 2291 2224 /* See if we already have a packet waiting */ 2225 nb_rx = rte_eth_rx_burst(FORMAT(trace)->port, 2226 FORMAT_DATA_FIRST(trace)->queue_id, 2227 pkts_burst, 1); 2228 2229 if (nb_rx > 0) { 2292 /* No packets waiting in our buffer? Try and read some more */ 2293 if (FORMAT(trace)->burst_size == FORMAT(trace)->burst_offset) { 2294 nb_rx = rte_eth_rx_burst(FORMAT(trace)->port, 2295 FORMAT_DATA_FIRST(trace)->queue_id, 2296 FORMAT(trace)->burst_pkts, BURST_SIZE); 2297 if (nb_rx > 0) { 2298 dpdk_ready_pkts(trace, FORMAT_DATA_FIRST(trace), 2299 FORMAT(trace)->burst_pkts, nb_rx); 2300 FORMAT(trace)->burst_size = nb_rx; 2301 FORMAT(trace)->burst_offset = 0; 2302 } 2303 } 2304 2305 /* Now do we have packets waiting? */ 2306 if (FORMAT(trace)->burst_size != FORMAT(trace)->burst_offset) { 2230 2307 /* Free the last packet buffer */ 2231 2308 if (packet->buffer != NULL) { … … 2239 2316 packet->type = TRACE_RT_DATA_DPDK; 2240 2317 event.type = TRACE_EVENT_PACKET; 2241 dpdk_ready_pkts(trace, FORMAT_DATA_FIRST(trace), pkts_burst, 1);2242 packet->buffer = FORMAT(trace)->burst_pkts[0];2318 packet->buffer = FORMAT(trace)->burst_pkts[ 2319 FORMAT(trace)->burst_offset++]; 2243 2320 dpdk_prepare_packet(trace, packet, packet->buffer, packet->type, 0); 2244 2321 event.size = 1; // TODO should be bytes read, which essentially useless anyway … … 2269 2346 2270 2347 static void dpdk_help(void) { 2271 printf("dpdk format module: $Revision: 1752 $\n");2348 printf("dpdk format module: %s (%d) \n", rte_version(), RTE_VERSION); 2272 2349 printf("Supported input URIs:\n"); 2273 2350 printf("\tdpdk:<domain:bus:devid.func>-<coreid>\n"); -
lib/format_linux_common.c
r1d780e4 rdb84bb2 315 315 libtrace_filter_t *filter = FORMAT_DATA->filter; 316 316 317 stream->last_timestamp = 0; 318 317 319 /* Create a raw socket for reading packets on */ 318 320 stream->fd = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL)); -
lib/format_linux_common.h
ree6e802 rdb84bb2 257 257 * that every ring can get setup the same */ 258 258 libtrace_list_t *per_stream; 259 259 260 }; 260 261 … … 287 288 /* The ring buffer layout */ 288 289 struct tpacket_req req; 290 uint64_t last_timestamp; 289 291 } ALIGN_STRUCT(CACHE_LINE_SIZE); 290 292 291 #define ZERO_LINUX_STREAM {-1, MAP_FAILED, 0, {0,0,0,0} }293 #define ZERO_LINUX_STREAM {-1, MAP_FAILED, 0, {0,0,0,0}, 0} 292 294 293 295 -
lib/format_linux_int.c
ree6e802 rdb84bb2 215 215 return -1; 216 216 } else { 217 if ( libtrace_halt)218 return READ_EOF;217 if ((ret=is_halted(libtrace)) != -1) 218 return ret; 219 219 } 220 220 } … … 286 286 } 287 287 288 288 289 /* Buffer contains all of our packet (including our custom header) so 289 290 * we just need to get prepare_packet to set all our packet pointers … … 294 295 return -1; 295 296 297 if (hdr->timestamptype == TS_TIMEVAL) { 298 packet->order = (((uint64_t)hdr->tv.tv_sec) << 32) 299 + ((((uint64_t)hdr->tv.tv_usec) << 32) /1000000); 300 } else if (hdr->timestamptype == TS_TIMESPEC) { 301 packet->order = (((uint64_t)hdr->ts.tv_sec) << 32) 302 + ((((uint64_t)hdr->ts.tv_nsec) << 32) /1000000000); 303 } else { 304 packet->order = 0; 305 } 306 307 if (packet->order <= stream->last_timestamp) { 308 packet->order = stream->last_timestamp + 1; 309 } 310 311 stream->last_timestamp = packet->order; 312 296 313 return hdr->wirelen+sizeof(*hdr); 297 314 } -
lib/format_linux_ring.c
ree6e802 rdb84bb2 447 447 #ifdef HAVE_NETPACKET_PACKET_H 448 448 #define LIBTRACE_MIN(a,b) ((a)<(b) ? (a) : (b)) 449 /* We use TP_STATUS_LIBTRACE to ensure we don't loop back on ourself 450 * and read the same packet twice if an old packet has not yet been freed */ 451 #define TP_STATUS_LIBTRACE 0xFFFFFFFF 452 449 453 inline static int linuxring_read_stream(libtrace_t *libtrace, 450 454 libtrace_packet_t *packet, … … 470 474 * ready for consumption. 471 475 */ 472 while (!(header->tp_status & TP_STATUS_USER)) { 476 while (!(header->tp_status & TP_STATUS_USER) || 477 header->tp_status == TP_STATUS_LIBTRACE) { 478 if ((ret=is_halted(libtrace)) != -1) 479 return ret; 473 480 pollset[0].fd = stream->fd; 474 481 pollset[0].events = POLLIN; … … 509 516 } 510 517 } else { 511 /* Poll timed out - check if we should exit */ 512 if (libtrace_halt) 513 return 0; 518 /* Poll timed out - check if we should exit on next loop */ 514 519 continue; 515 520 } 516 521 } 517 518 522 packet->buffer = header; 519 523 packet->trace = libtrace; 524 525 header->tp_status = TP_STATUS_LIBTRACE; 520 526 521 527 /* If a snaplen was configured, automatically truncate the packet to … … 531 537 stream->rxring_offset++; 532 538 stream->rxring_offset %= stream->req.tp_frame_nr; 539 540 packet->order = (((uint64_t)TO_TP_HDR2(packet->buffer)->tp_sec) << 32) 541 + ((((uint64_t)TO_TP_HDR2(packet->buffer)->tp_nsec) 542 << 32) / 1000000000); 543 544 if (packet->order <= stream->last_timestamp) { 545 packet->order = stream->last_timestamp + 1; 546 } 547 548 stream->last_timestamp = packet->order; 549 533 550 534 551 /* We just need to get prepare_packet to set all our packet pointers … … 574 591 /* Fetch the current frame */ 575 592 header = GET_CURRENT_BUFFER(FORMAT_DATA_FIRST); 576 if (header->tp_status & TP_STATUS_USER) { 593 if (header->tp_status & TP_STATUS_USER && 594 header->tp_status != TP_STATUS_LIBTRACE) { 577 595 /* We have a frame waiting */ 578 596 event.size = trace_read_packet(libtrace, packet); -
lib/format_pcap.c
r631fdbc r5e3f16c 447 447 case 1: break; /* no error */ 448 448 case 0: 449 if ( libtrace_halt)450 return 0;449 if ((ret=is_halted(libtrace)) != -1) 450 return ret; 451 451 continue; /* timeout expired */ 452 452 case -1: -
lib/hash_toeplitz.c
ree6e802 r6f7cd4b 71 71 * Creates a random unidirectional RSS key - a ip or ip+port combination in 72 72 * the opposite directions will most likely get different hashes. 73 * @param key An array of bytes to retrieve the RSS key 74 * @param num The number of bytes in key 75 */ 76 void toeplitz_ncreate_unikey(uint8_t *key, size_t num) { 77 size_t i; 78 unsigned int seed = time(NULL); 79 for (i = 0; i < num; i++) { 80 key[i] = (uint8_t) rand_r(&seed); 81 } 82 } 83 84 /** 85 * Creates a random 40 byte unidirectional RSS key - a ip or ip+port combination 86 * in the opposite directions will most likely get different hashes. 73 87 * @param key must have 40 bytes of space to retrieve random the key 74 */ 88 */ 75 89 void toeplitz_create_unikey(uint8_t *key) { 76 int i; 77 unsigned int seed = time(NULL); 78 for (i = 0; i < 40; i++) { 79 key[i] = (uint8_t) rand_r(&seed); 80 } 90 toeplitz_ncreate_unikey(key, 40); 81 91 } 82 92 … … 85 95 * in opposite directions will receive the same hash 86 96 * @param key must have 40 bytes of space to retrieve random the key 87 */ 88 void toeplitz_create_bikey(uint8_t *key) { 97 * @param num The number of bytes in the key, must be a multiple of 2 98 */ 99 void toeplitz_ncreate_bikey(uint8_t *key, size_t num) { 89 100 unsigned int seed = time(NULL); 90 int i; 101 size_t i; 102 if (num % 2 != 0) { 103 perror("Can not create a bidirectional key for an odd length key"); 104 } 91 105 // Every thing is 16bit (port=16, ipv4=32, ipv6=128 92 106 // aligned so this will make the hash bidirectional 93 107 uint16_t bi_key = (uint16_t) rand_r(&seed); 94 108 uint16_t *bi_rep = (uint16_t *) key; 95 for (i = 0; i < 20; i++) {109 for (i = 0; i < num/2; i++) { 96 110 bi_rep[i] = bi_key; 97 111 } 112 } 113 114 /** 115 * Create a 40 byte bidirectional RSS key, i.e. ip and ip+port configurations 116 * in opposite directions will receive the same hash 117 * @param key An array of bytes to retrieve the RSS key 118 */ 119 void toeplitz_create_bikey(uint8_t *key) { 120 toeplitz_ncreate_bikey(key, 40); 98 121 } 99 122 … … 106 129 } 107 130 toeplitz_hash_expand_key(conf); 131 conf->hash_ipv4 = 1; 132 conf->hash_ipv6 = 1; 133 conf->hash_tcp_ipv4 = 1; 134 conf->x_hash_udp_ipv4 = 1; 135 conf->hash_tcp_ipv6 = 1; 136 conf->x_hash_udp_ipv6 = 1; 108 137 } 109 138 -
lib/hash_toeplitz.h
ree6e802 r6f7cd4b 58 58 void toeplitz_init_config(toeplitz_conf_t *conf, bool bidirectional); 59 59 uint64_t toeplitz_hash_packet(const libtrace_packet_t * pkt, const toeplitz_conf_t *cnf); 60 void toeplitz_ncreate_bikey(uint8_t *key, size_t num); 60 61 void toeplitz_create_bikey(uint8_t *key); 62 void toeplitz_ncreate_unikey(uint8_t *key, size_t num); 61 63 void toeplitz_create_unikey(uint8_t *key); 62 64 -
lib/libtrace.h.in
r0cdd231 r317e903 260 260 /** If the packet has allocated its own memory the buffer_control should be 261 261 * set to TRACE_CTRL_PACKET, so that the memory will be freed when the packet 262 * is destroyed. If the packet has been zero copied out of memory owned by262 * is destroyed. If the packet has been zero-copied out of memory owned by 263 263 * something else, e.g. a DAG card, it should be TRACE_CTRL_EXTERNAL. 264 264 * … … 282 282 /** Enumeration of error codes */ 283 283 enum { 284 /** No Error has occur ed.... yet. */284 /** No Error has occurred.... yet. */ 285 285 TRACE_ERR_NOERROR = 0, 286 286 /** The URI passed to trace_create() is unsupported, or badly formed */ … … 336 336 #endif 337 337 TRACE_DLT_PPP_SERIAL = 50, 338 TRACE_DLT_LINKTYPE_RAW = 101, /**< See TRACE_DLT_RAW for expla inations of pain. */338 TRACE_DLT_LINKTYPE_RAW = 101, /**< See TRACE_DLT_RAW for explanations of pain. */ 339 339 TRACE_DLT_C_HDLC = 104, 340 340 TRACE_DLT_IEEE802_11 = 105, … … 548 548 uint64_t hash; /**< A hash of the packet as supplied by the user */ 549 549 int error; /**< The error status of pread_packet */ 550 uint64_t internalid; /** Internal i ndentifier for the pkt */550 uint64_t internalid; /** Internal identifier for the pkt */ 551 551 void *srcbucket; 552 552 } libtrace_packet_t; … … 576 576 TRACE_RADIOTAP_LOCK_QUALITY = 7, /**< Barker Code lock quality (uint16) */ 577 577 TRACE_RADIOTAP_TX_ATTENUATION = 8, /**< TX attenuation as unitless distance from max power (uint16) */ 578 TRACE_RADIOTAP_DB_TX_ATTENUATION = 9, /**< TX attenu tation as dB from max power (uint16) */578 TRACE_RADIOTAP_DB_TX_ATTENUATION = 9, /**< TX attenuation as dB from max power (uint16) */ 579 579 TRACE_RADIOTAP_DBM_TX_POWER = 10, /**< TX Power in dBm (int8) */ 580 580 TRACE_RADIOTAP_ANTENNA = 11, /**< Antenna frame was rx'd or tx'd on (uint8) */ … … 869 869 #define LIBTRACE_GRE_FLAG_VERMASK 0x0007 870 870 871 872 /* PPTP GRE (RFC2637) */ 873 #define LIBTRACE_GRE_FLAG_ACK 0x0080 874 #define LIBTRACE_GRE_PPTP_VERSION 0x0001 875 871 876 /** Libtrace local definition of VXLAN Header 872 877 * (draft-mahalingam-dutt-dcops-vxlan) … … 1182 1187 * @param [out] format A pointer that will be updated to point to an allocated 1183 1188 * string holding the format component of the URI 1184 * @return NULL if an error occur ed, otherwise return a pointer to the uridata1189 * @return NULL if an error occurred, otherwise return a pointer to the uridata 1185 1190 * component 1186 1191 * … … 1207 1212 * - rt:hostname:port 1208 1213 * 1209 * If an error occur ed when attempting to open the trace file, a1214 * If an error occurred when attempting to open the trace file, a 1210 1215 * trace is still returned so trace_is_err() should be called to find out 1211 * if an error occur ed. The trace is created in the configuration state, you1216 * if an error occurred. The trace is created in the configuration state, you 1212 1217 * must call trace_start before attempting to read packets from the trace. 1213 1218 */ … … 1238 1243 * - pcap:/path/to/pcap/file 1239 1244 * 1240 * If an error occur ed when attempting to open the output trace, a trace is1245 * If an error occurred when attempting to open the output trace, a trace is 1241 1246 * still returned but trace_errno will be set. Use trace_is_err_out() and 1242 1247 * trace_perror_output() to get more information. … … 1377 1382 } trace_option_output_t; 1378 1383 1379 /* To add a new stat field update this list, and the relev ent places in1384 /* To add a new stat field update this list, and the relevant places in 1380 1385 * libtrace_stat_t structure. 1381 1386 */ … … 1430 1435 uint64_t filtered; 1431 1436 1432 /** The total number of good packets which have been rece vied. Including1437 /** The total number of good packets which have been received. Including 1433 1438 * those which are dropped and filtered. This does not include errors. 1434 1439 * … … 1610 1615 * Returns statistic counters for a trace, for a parallel trace this is a 1611 1616 * combined total. 1612 * Where possible these are retri ved atomically, however this behaviour depends1617 * Where possible these are retrieved atomically, however this behaviour depends 1613 1618 * on the underlying trace format. 1614 1619 * … … 1631 1636 /** 1632 1637 * Returns statistic counters for a single thread of a trace. 1633 * Where possible these are retri ved atomically, however this behaviour depends1638 * Where possible these are retrieved atomically, however this behaviour depends 1634 1639 * on the underlying trace format. 1635 1640 * 1636 1641 * @param trace The input trace to examine. 1637 * @param t An optional thread to received stats for or NULL to retri ve stats1642 * @param t An optional thread to received stats for or NULL to retrieve stats 1638 1643 * for the current thread 1639 1644 * @param stats Filled upon return with statistics about the trace, check the … … 1734 1739 * function should be avoided where possible. 1735 1740 * 1736 * @par The reason you would want to use this function is that a zero copied1741 * @par The reason you would want to use this function is that a zero-copied 1737 1742 * packet from a device will be stored using memory owned by the device which 1738 1743 * may be a limited resource. Copying the packet will ensure that the packet … … 2693 2698 * 2694 2699 * @note This function only works for OSPF version 2 packets. 2695 * @note trace_get_next_ospf_lsa_v2() should be sub equently used to process the LSAs2700 * @note trace_get_next_ospf_lsa_v2() should be subsequently used to process the LSAs 2696 2701 */ 2697 2702 DLLEXPORT SIMPLE_FUNCTION … … 2716 2721 * 2717 2722 * @note This function only works for OSPF version 2 packets. 2718 * @note trace_get_next_ospf_lsa_header_v2() should be sub equently used to process the LSA headers2723 * @note trace_get_next_ospf_lsa_header_v2() should be subsequently used to process the LSA headers 2719 2724 */ 2720 2725 DLLEXPORT SIMPLE_FUNCTION … … 2739 2744 * 2740 2745 * @note This function only works for OSPF version 2 packets. 2741 * @note trace_get_next_ospf_link_v2() should be sub equently used to process2746 * @note trace_get_next_ospf_link_v2() should be subsequently used to process 2742 2747 * the links 2743 2748 */ -
lib/libtrace_int.h
ree6e802 r5e3f16c 327 327 /** Synchronise writes/reads across this format object and attached threads etc */ 328 328 pthread_mutex_t libtrace_lock; 329 /** Packet read lock, seperate from libtrace_lock as to not block while reading a burst */ 330 pthread_mutex_t read_packet_lock; 329 331 /** State */ 330 332 enum trace_state state; … … 606 608 * @return The size of the packet read (in bytes) including the capture 607 609 * framing header, or -1 if an error occurs. 0 is returned in the 608 * event of an EOF .610 * event of an EOF or -2 in the case of interrupting the parallel API. 609 611 * 610 612 * If no packets are available for reading, this function should block … … 1032 1034 */ 1033 1035 extern volatile int libtrace_halt; 1036 1037 /** 1038 * Used by a format to check if trace_interrupt or if a trace_pause/stop has 1039 * been called. Provides backwards compatibility with traditional read 1040 * functions when trace_read_packet() is used by the parallel API. 1041 * 1042 * Returns -1 if not halting otherwise returns the code that the read 1043 * operation should pass on. 1044 */ 1045 static inline int is_halted(libtrace_t *trace) { 1046 if (!(libtrace_halt || trace->state == STATE_PAUSING)) { 1047 return -1; 1048 } else if (libtrace_halt) { 1049 return READ_EOF; 1050 } else { 1051 return READ_MESSAGE; 1052 } 1053 } 1034 1054 1035 1055 /** Registers a new capture format module. -
lib/protocols_l2.c
ree6e802 r99351e3 313 313 switch(ntohs(ppp->protocol)) { 314 314 case 0x0021: *type = TRACE_ETHERTYPE_IP; break; 315 case 0x0057: *type = TRACE_ETHERTYPE_IPV6; break; 315 316 /* If it isn't IP, then it is probably PPP control and 316 317 * I can't imagine anyone caring about that too much … … 395 396 case 0x0021: /* IP */ 396 397 *type = TRACE_ETHERTYPE_IP; 398 break; 399 case 0x0057: /* IPV6 */ 400 *type = TRACE_ETHERTYPE_IPV6; 397 401 break; 398 402 case 0xc021: /* Link Control Protocol */ -
lib/protocols_transport.c
ree6e802 r317e903 549 549 uint32_t *remaining) 550 550 { 551 uint8_t flags = ntohs(gre->flags); 551 552 uint32_t size = 4; /* GRE is 4 bytes long by default */ 552 553 if (remaining && *remaining < size) { … … 555 556 } 556 557 557 if ((ntohs(gre->flags) & LIBTRACE_GRE_FLAG_CHECKSUM) != 0) { 558 size += 4; /* An extra 4 bytes. */ 559 } 560 561 if ((ntohs(gre->flags) & LIBTRACE_GRE_FLAG_KEY) != 0) { 562 size += 4; /* An extra 4 bytes. */ 563 } 564 565 if ((ntohs(gre->flags) & LIBTRACE_GRE_FLAG_SEQ) != 0) { 566 size += 4; /* An extra 4 bytes. */ 558 if((flags & LIBTRACE_GRE_FLAG_VERMASK) == LIBTRACE_GRE_PPTP_VERSION) { 559 size += 4; 560 561 if ((flags & LIBTRACE_GRE_FLAG_SEQ) != 0) { 562 size += 4; 563 } 564 if ((flags & LIBTRACE_GRE_FLAG_ACK) != 0) { 565 size += 4; 566 } 567 } else { 568 569 if ((ntohs(gre->flags) & LIBTRACE_GRE_FLAG_CHECKSUM) != 0) { 570 size += 4; /* An extra 4 bytes. */ 571 } 572 573 if ((ntohs(gre->flags) & LIBTRACE_GRE_FLAG_KEY) != 0) { 574 size += 4; /* An extra 4 bytes. */ 575 } 576 577 if ((ntohs(gre->flags) & LIBTRACE_GRE_FLAG_SEQ) != 0) { 578 size += 4; /* An extra 4 bytes. */ 579 } 567 580 } 568 581 -
lib/trace.c
r0cdd231 radb2c4c 261 261 /* Parallel inits */ 262 262 ASSERT_RET(pthread_mutex_init(&libtrace->libtrace_lock, NULL), == 0); 263 ASSERT_RET(pthread_mutex_init(&libtrace->read_packet_lock, NULL), == 0); 263 264 ASSERT_RET(pthread_cond_init(&libtrace->perpkt_cond, NULL), == 0); 264 265 libtrace->state = STATE_NEW; … … 385 386 /* Parallel inits */ 386 387 ASSERT_RET(pthread_mutex_init(&libtrace->libtrace_lock, NULL), == 0); 388 ASSERT_RET(pthread_mutex_init(&libtrace->read_packet_lock, NULL), == 0); 387 389 ASSERT_RET(pthread_cond_init(&libtrace->perpkt_cond, NULL), == 0); 388 390 libtrace->state = STATE_NEW; // TODO MAYBE DEAD … … 548 550 549 551 /* Finish the last packet we read - for backwards compatibility */ 550 if ( libtrace->last_packet)552 if (!libtrace_parallel && libtrace->last_packet) 551 553 trace_fin_packet(libtrace->last_packet); 552 554 assert(libtrace->last_packet == NULL); … … 680 682 681 683 ASSERT_RET(pthread_mutex_destroy(&libtrace->libtrace_lock), == 0); 684 ASSERT_RET(pthread_mutex_destroy(&libtrace->read_packet_lock), == 0); 682 685 ASSERT_RET(pthread_cond_destroy(&libtrace->perpkt_cond), == 0); 683 686 … … 694 697 695 698 /* Finish any the last packet we read - for backwards compatibility */ 696 if ( libtrace->last_packet) {699 if (!libtrace_parallel && libtrace->last_packet) { 697 700 trace_fin_packet(libtrace->last_packet); 698 701 } … … 758 761 759 762 ASSERT_RET(pthread_mutex_destroy(&libtrace->libtrace_lock), == 0); 763 ASSERT_RET(pthread_mutex_destroy(&libtrace->read_packet_lock), == 0); 760 764 ASSERT_RET(pthread_cond_destroy(&libtrace->perpkt_cond), == 0); 761 765 … … 833 837 packet->trace->format->fin_packet(packet); 834 838 } 835 if (packet->trace && packet->trace->last_packet == packet) 839 if (!libtrace_parallel && packet->trace && 840 packet->trace->last_packet == packet) { 836 841 packet->trace->last_packet = NULL; 842 } 837 843 838 844 if (packet->buf_control == TRACE_CTRL_PACKET && packet->buffer) { … … 864 870 865 871 if (packet->trace) { 866 pthread_mutex_lock(&packet->trace->libtrace_lock); 867 if (packet->trace->last_packet == packet) 868 packet->trace->last_packet = NULL; 869 pthread_mutex_unlock(&packet->trace->libtrace_lock); 872 if (!libtrace_parallel && packet->trace->last_packet == packet) 873 packet->trace->last_packet = NULL; 870 874 } 871 875 … … 921 925 size_t ret; 922 926 int filtret; 927 if ((ret=is_halted(libtrace)) != (size_t)-1) 928 return ret; 923 929 /* Store the trace we are reading from into the packet opaque 924 930 * structure */ 925 931 packet->trace = libtrace; 926 932 ret=libtrace->format->read_packet(libtrace,packet); 927 if (ret==(size_t)-1 || ret==0) { 933 if (ret==(size_t)READ_MESSAGE || 934 ret==(size_t)-1 || ret==0) { 928 935 packet->trace = NULL; 929 936 return ret; … … 953 960 ++libtrace->accepted_packets; 954 961 ++libtrace->sequence_number; 955 if ( packet->trace == libtrace)962 if (!libtrace_parallel && packet->trace == libtrace) 956 963 libtrace->last_packet = packet; 957 964 … … 996 1003 997 1004 packet->trace = trace; 998 pthread_mutex_lock(&trace->libtrace_lock); 999 trace->last_packet = packet; 1000 pthread_mutex_unlock(&trace->libtrace_lock); 1005 if (!libtrace_parallel) 1006 trace->last_packet = packet; 1001 1007 /* Clear packet cache */ 1002 1008 trace_clear_cache(packet); -
lib/trace_parallel.c
ree6e802 rdb84bb2 677 677 if (!trace->pread) { 678 678 assert(packets[0]); 679 ASSERT_RET(pthread_mutex_lock(&trace->libtrace_lock), == 0); 679 680 nb_packets = trace_read_packet(trace, packets[0]); 681 ASSERT_RET(pthread_mutex_unlock(&trace->libtrace_lock), == 0); 680 682 packets[0]->error = nb_packets; 681 683 if (nb_packets > 0) … … 787 789 libtrace_ocache_alloc(&trace->packet_freelist, (void **) &packet, 1, 1); 788 790 assert(packet); 789 790 if (libtrace_halt) {791 packet->error = 0;792 break;793 }794 791 795 792 // Check for messages that we expect MESSAGE_DO_PAUSE, (internal messages only) … … 821 818 822 819 if ((packet->error = trace_read_packet(trace, packet)) <1) { 823 break; /* We are EOF or error'd either way we stop */ 820 if (packet->error == READ_MESSAGE) { 821 pkt_skipped = 1; 822 continue; 823 } else { 824 break; /* We are EOF or error'd either way we stop */ 825 } 824 826 } 825 827 … … 889 891 //bool tick_hit = false; 890 892 891 ASSERT_RET(pthread_mutex_lock(&libtrace-> libtrace_lock), == 0);893 ASSERT_RET(pthread_mutex_lock(&libtrace->read_packet_lock), == 0); 892 894 /* Read nb_packets */ 893 895 for (i = 0; i < nb_packets; ++i) { 894 if (libtrace_halt) { 895 break; 896 if (libtrace_message_queue_count(&t->messages) > 0) { 897 if ( i==0 ) { 898 ASSERT_RET(pthread_mutex_unlock(&libtrace->read_packet_lock), == 0); 899 return READ_MESSAGE; 900 } else { 901 break; 902 } 896 903 } 897 904 packets[i]->error = trace_read_packet(libtrace, packets[i]); … … 900 907 /* We'll catch this next time if we have already got packets */ 901 908 if ( i==0 ) { 902 ASSERT_RET(pthread_mutex_unlock(&libtrace-> libtrace_lock), == 0);909 ASSERT_RET(pthread_mutex_unlock(&libtrace->read_packet_lock), == 0); 903 910 return packets[i]->error; 904 911 } else { … … 916 923 store_first_packet(libtrace, packets[0], t); 917 924 } 918 ASSERT_RET(pthread_mutex_unlock(&libtrace-> libtrace_lock), == 0);925 ASSERT_RET(pthread_mutex_unlock(&libtrace->read_packet_lock), == 0); 919 926 /* XXX TODO this needs to be inband with packets, or we don't bother in this case 920 927 if (tick_hit) { … … 1007 1014 /* Check if we are newer than the previous 'first' packet */ 1008 1015 size_t first = libtrace->first_packets.first; 1009 if (trace_get_seconds(dup) < 1010 trace_get_seconds(libtrace->first_packets.packets[first].packet)) 1016 struct timeval cur_ts = trace_get_timeval(dup); 1017 struct timeval first_ts = trace_get_timeval(libtrace->first_packets.packets[first].packet); 1018 if (timercmp(&cur_ts, &first_ts, <)) 1011 1019 libtrace->first_packets.first = t->perpkt_num; 1012 1020 } … … 1336 1344 trace_set_capture_length(packets[i], 1337 1345 libtrace->snaplen); 1338 trace_packet_set_order(packets[i], trace_get_erf_timestamp(packets[i]));1339 1346 } 1340 1347 } while(ret == 0); … … 1471 1478 libtrace->config.reporter_thold = 100; 1472 1479 if (libtrace->config.burst_size <= 0) 1473 libtrace->config.burst_size = 10;1480 libtrace->config.burst_size = 32; 1474 1481 if (libtrace->config.thread_cache_size <= 0) 1475 libtrace->config.thread_cache_size = 20;1482 libtrace->config.thread_cache_size = 64; 1476 1483 if (libtrace->config.cache_size <= 0) 1477 1484 libtrace->config.cache_size = (libtrace->config.hasher_queue_size + 1) * libtrace->perpkt_thread_count; … … 1707 1714 libtrace->perpkt_threads = NULL; 1708 1715 /* Set a global which says we are using a parallel trace. This is 1709 * for backwards compat ability due to changes when destroying packets */1716 * for backwards compatibility due to changes when destroying packets */ 1710 1717 libtrace_parallel = 1; 1711 1718 … … 1728 1735 if (libtrace->perpkt_thread_count > 1) 1729 1736 libtrace->pread = trace_pread_packet_first_in_first_served; 1737 /* Don't wait for a burst of packets if the format is 1738 * live as this could block ring based formats and 1739 * introduces delay. */ 1740 if (libtrace->format->info.live) { 1741 libtrace->config.burst_size = 1; 1742 } 1730 1743 else 1731 1744 /* Use standard read_packet */ -
test/test-live.c
r8decff7 rcac1d92 171 171 if (!stat->received_valid) { 172 172 printf("\tInfo: trace does not support received counter\n"); 173 } else if (stat->received != 100) { 174 ERROR("Trace received %zu/100 packets\n", stat->received); 173 } else if (stat->received != (uint32_t) test_size) { 174 ERROR("Trace received %zu/%u packets\n", stat->received, 175 (uint32_t)test_size); 175 176 } 176 177 -
test/test-tracetime-parallel.c
r8decff7 rb148e3b 232 232 233 233 trace_set_reporter_thold(trace, 1); 234 trace_set_burst_size(trace, 10); 234 235 235 236 // Start it -
tools/tracertstats/tracertstats.c
ree6e802 r0b4b388 258 258 } 259 259 trace_set_combiner(trace, &combiner_ordered, (libtrace_generic_t){0}); 260 trace_set_tracetime(trace, true);261 260 trace_set_perpkt_threads(trace, threadcount); 262 261 trace_set_burst_size(trace, burstsize); … … 264 263 if (trace_get_information(trace)->live) { 265 264 trace_set_tick_interval(trace, (int) (packet_interval * 1000)); 265 } else { 266 trace_set_tracetime(trace, true); 266 267 } 267 268
Note: See TracChangeset
for help on using the changeset viewer.