Changeset db84bb2


Ignore:
Timestamp:
02/28/17 13:49:40 (3 years ago)
Author:
Shane Alcock <salcock@…>
Branches:
4.0.1-hotfixes, cachetimestamps, develop, dpdk-ndag, etsilive, master, ndag_format, rc-4.0.1, rc-4.0.2, rc-4.0.3, rc-4.0.4, ringdecrementfix, ringperformance, ringtimestampfixes
Children:
6fb691b, 9d29d1e
Parents:
dea08f1
Message:

Ensure packet->order is always strictly incrementing

We cannot equate timestamp with packet->order, as some timestamp
methods are not strictly monotonic (ring: and int:).

Each format is now responsible for determining packet->order
during pread, so that the format can detect and correct such
inaccuracies.

More specifically, ring: and int: will cache the last reported
timestamp per thread and if time goes backwards, the order will
be set to last+1, otherwise the timestamp will be used.

DAG and DPDK still use the timestamp for ordering, since there
have been no issues with the timestamp ordering for these formats
(thus far!).

Location:
lib
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • lib/format_dag25.c

    r5e3f16c rdb84bb2  
    13131313
    13141314        packet->trace = libtrace;
     1315
    13151316        /* Prepare the libtrace packet */
    13161317        if (dag_prepare_packet_stream(libtrace, stream_data, packet, erfptr,
     
    13241325        }
    13251326
     1327        packet->order = erf_get_erf_timestamp(packet);
    13261328        packet->error = packet->payload ? htons(erfptr->rlen) :
    13271329                                          erf_get_framing_length(packet);
  • lib/format_dpdk.c

    r174b3c7 rdb84bb2  
    21542154        int i;
    21552155        dpdk_per_stream_t *stream = t->format_data;
     2156        struct dpdk_addt_hdr * hdr;
    21562157
    21572158        nb_rx = dpdk_read_packet_stream (libtrace, stream, &t->messages,
     
    21702171                        packets[i]->trace = libtrace;
    21712172                        packets[i]->error = 1;
     2173                        hdr = (struct dpdk_addt_hdr *)
     2174                                        ((struct rte_mbuf*) pkts_burst[i] + 1);
     2175                        packets[i]->order = hdr->timestamp;
    21722176                        dpdk_prepare_packet(libtrace, packets[i], packets[i]->buffer, packets[i]->type, 0);
    21732177                }
  • lib/format_linux_common.c

    r1d780e4 rdb84bb2  
    315315        libtrace_filter_t *filter = FORMAT_DATA->filter;
    316316
     317        stream->last_timestamp = 0;
     318
    317319        /* Create a raw socket for reading packets on */
    318320        stream->fd = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL));
  • lib/format_linux_common.h

    ree6e802 rdb84bb2  
    257257         * that every ring can get setup the same */
    258258        libtrace_list_t *per_stream;
     259
    259260};
    260261
     
    287288        /* The ring buffer layout */
    288289        struct tpacket_req req;
     290        uint64_t last_timestamp;
    289291} ALIGN_STRUCT(CACHE_LINE_SIZE);
    290292
    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}
    292294
    293295
  • lib/format_linux_int.c

    r5e3f16c rdb84bb2  
    286286        }
    287287
     288
    288289        /* Buffer contains all of our packet (including our custom header) so
    289290         * we just need to get prepare_packet to set all our packet pointers
     
    294295                return -1;
    295296       
     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
    296313        return hdr->wirelen+sizeof(*hdr);
    297314}
  • lib/format_linux_ring.c

    r47c4490 rdb84bb2  
    520520                }
    521521        }
    522 
    523522        packet->buffer = header;
    524523        packet->trace = libtrace;
     524       
    525525        header->tp_status = TP_STATUS_LIBTRACE;
    526526
     
    537537        stream->rxring_offset++;
    538538        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               
    539550
    540551        /* We just need to get prepare_packet to set all our packet pointers
  • lib/trace_parallel.c

    rdea08f1 rdb84bb2  
    13441344                                        trace_set_capture_length(packets[i],
    13451345                                                        libtrace->snaplen);
    1346                                 trace_packet_set_order(packets[i], trace_get_erf_timestamp(packets[i]));
    13471346                        }
    13481347                } while(ret == 0);
Note: See TracChangeset for help on using the changeset viewer.