From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 8E91D42609 for ; Tue, 19 Sep 2023 16:40:16 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4EFC1402D2; Tue, 19 Sep 2023 16:40:16 +0200 (CEST) Received: from mail-pf1-f176.google.com (mail-pf1-f176.google.com [209.85.210.176]) by mails.dpdk.org (Postfix) with ESMTP id AEB1D402C5 for ; Tue, 19 Sep 2023 16:40:14 +0200 (CEST) Received: by mail-pf1-f176.google.com with SMTP id d2e1a72fcca58-68cbbff84f6so4753983b3a.1 for ; Tue, 19 Sep 2023 07:40:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1695134413; x=1695739213; darn=dpdk.org; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=U6Rw/F27r9xGmxGIrsp3JnTrZIk95HZdKXaQAiAjT4s=; b=dgCijvrkOp20jqnZN6WlXLkroAXT8hgKgn+GS7azr1YVp0uv74tAYO20tSw1pf0VR/ fuFr+S+2HwPWx+g8ICYpLk4Z1VlnPLlG4SH2CNXexNdLC3L+m/MhO10tCrEpyeWkRBo/ hJSHoXOlBklNKELWZbWnnqSCsHOQqSD6NvaCSsgjRCcwzhYpoIRznH9TNUq1z2V6dap3 lkkISQl1PQVen5mGOOBXDAhVciM9w/8f2LqLIJg4hNuVBbp2e1D4Z5N8MZBgE6iFB5fD WGJtLio9J5Xgiyna3ZS87xGWT/i7gjIhR61Z1g0NTmXwXGDAQCDzaStYG6gDJAX8NkW3 jxlw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695134413; x=1695739213; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=U6Rw/F27r9xGmxGIrsp3JnTrZIk95HZdKXaQAiAjT4s=; b=hZoKllg/GmpjK9G1fpkfL/qVilh8lbnPOlo1jFWMwk3GmtGiT6K43rJxo8c+bqnwn/ dRuLRArM5UNRBmupAr8pophs6tc0wGXKPXl5LvtJe2vgxZe7/iWhgEky/qT2/Po1QpEx 0ZWJYNkYWxwtx6NCng+Z0jRLRb4bflpVrep+1SWaDOLLCBdaCTiBtJIBfbdHVyepf0DE Pe3DTUqgecveU+7760CJAIpT25igjqpuz8Hf2BqG2Hwh7527TAP/+nit+wNAZj7mehE9 iOpx7m2LC9erSPguSd4yZfTmJCJ80e8Y1hw1faCS7V3bHRKPpYCfAs7a3xoXSzYo9ikl eIIg== X-Gm-Message-State: AOJu0Yx14mDydQq0RVmSHxr7ybwoVOrTRPkwRpqfwd6BKStXIpDcZ23A mo0QAiuUmRYAshYmEecVuAr8K+/AfrnK8QS/3p4XPjz+E5c= X-Google-Smtp-Source: AGHT+IF9wNCqwQoNmNa9ilulHdi6GGz00+EfpIgmAzKhzYqphLX1NFPYVOunFugdMMTchHK83QpoCsKf3ES33UtxoE0= X-Received: by 2002:a05:6a00:1486:b0:68f:bb16:d16a with SMTP id v6-20020a056a00148600b0068fbb16d16amr3750440pfu.5.1695134413415; Tue, 19 Sep 2023 07:40:13 -0700 (PDT) MIME-Version: 1.0 From: Isaac Boukris Date: Tue, 19 Sep 2023 17:40:02 +0300 Message-ID: Subject: dumpcap: timestamp is years ahead when in pcapng format To: users@dpdk.org, Stephen Hemminger Content-Type: text/plain; charset="UTF-8" X-BeenThere: users@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK usage discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: users-bounces@dpdk.org Hi Stephen, Machine: vm on a laptop with i7 core rte_get_timer_hz() = 2500000000 rte_get_tsc_hz() = 2500000000 This issue doesn't occur with pcap format, only with pcapng. When I capture on my system with dumpcap I get timestamp years ahead: [root@Rocky8 ~]# dpdk-dumpcap -i 0 -f 'not tcp port 22' -w - | tcpdump -ttttr - File: - reading from file -, link-type EN10MB (Ethernet) Packets captured: 0 dropped privs to tcpdump 2257-07-15 19:27:35.541912 IP _gateway.domain > Rocky8.36824: 42742 NXDomain 0/0/0 (44) 2257-07-15 19:27:35.541912 IP Rocky8.58223 > _gateway.domain: 22616+ PTR? 2.202.168.192.in-addr.arpa. (44) Looking at the code, I tried the below simplification in pcapng_tsc_to_ns() and it yielded good results, but I'm still not clear as the logic is quite intimidating. diff --git a/lib/pcapng/rte_pcapng.c b/lib/pcapng/rte_pcapng.c index 80d08e1..96540b4 100644 --- a/lib/pcapng/rte_pcapng.c +++ b/lib/pcapng/rte_pcapng.c @@ -79,21 +79,8 @@ static uint64_t pcapng_tsc_to_ns(uint64_t cycles) * Currently all TSCs operate below 5GHz. */ delta = cycles - pcapng_time.cycles; - if (unlikely(delta >= pcapng_time.tsc_hz)) { - if (likely(delta < pcapng_time.tsc_hz * 2)) { - delta -= pcapng_time.tsc_hz; - pcapng_time.cycles += pcapng_time.tsc_hz; - pcapng_time.ns += NSEC_PER_SEC; - } else { - secs = rte_reciprocal_divide_u64(delta, &pcapng_time.tsc_hz_inverse); - delta -= secs * pcapng_time.tsc_hz; - pcapng_time.cycles += secs * pcapng_time.tsc_hz; - pcapng_time.ns += secs * NSEC_PER_SEC; - } - } - return pcapng_time.ns + rte_reciprocal_divide_u64(delta * NSEC_PER_SEC, - &pcapng_time.tsc_hz_inverse); + return pcapng_time.ns + ((uint64_t)(delta / pcapng_time.tsc_hz) * NSEC_PER_SEC); Results: [root@Rocky8 ~]# dpdk-dumpcap -i 0 -f 'not tcp port 22' -w - | tcpdump -ttttr - File: - reading from file -, link-type EN10MB (Ethernet) Packets captured: 0 dropped privs to tcpdump 2023-09-19 05:33:18.191601 IP _gateway.domain > Rocky8.50821: 37740 NXDomain 0/0/0 (44) 2023-09-19 05:33:18.191601 IP Rocky8.57382 > _gateway.domain: 53422+ PTR? 2.202.168.192.in-addr.arpa. (44) Any thoughts on this? Thanks!