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 6692B4260C for ; Tue, 19 Sep 2023 18:36:09 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 560A14027A; Tue, 19 Sep 2023 18:36:09 +0200 (CEST) Received: from mail-pg1-f179.google.com (mail-pg1-f179.google.com [209.85.215.179]) by mails.dpdk.org (Postfix) with ESMTP id 26A6640277 for ; Tue, 19 Sep 2023 18:36:08 +0200 (CEST) Received: by mail-pg1-f179.google.com with SMTP id 41be03b00d2f7-577fb90bb76so3218369a12.2 for ; Tue, 19 Sep 2023 09:36:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1695141367; x=1695746167; darn=dpdk.org; h=content-transfer-encoding:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=8PUtF1ykN22jQg1bvGWZdoNPF3oUMn0LEoFc7bQnCGw=; b=K8nYmgh/MegBKfdBwcmDSVnaaCVv6aI0fLn77dxW309oD2UJeFkrKEziYQwR3QbKFv 1Xf2jBpei4jyJAOjboQrnhf6AioBepBUl6mJwspKa7dxJby/RBMYjdKv+j3gOYEzAPqD 37fmezE7tnY4/tqCWVQMfNqHzo6T9/tbAVk0tFy2wRBGgJY90fXhjRBvzsP5cVA4qQHG 2cWJwgTjv8WjLl2cueO+k3xwiXN+vq83VCqHsjAf4TR6MwgTbzaMvVeSuZhZ4K2QXGrx ZZBxA7d0qhn/UlWx0pCjm7f59xLQpM7PxjguJtMrHFFzy7H67iuW6wG3TUG5rznormFX cuKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695141367; x=1695746167; h=content-transfer-encoding:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=8PUtF1ykN22jQg1bvGWZdoNPF3oUMn0LEoFc7bQnCGw=; b=rrWLFQS1xEMMB4kQ49qVWTiIyTaGoKP/gYO/iUl6kaQ4LL2bxMkaB7KxsaCbEGwg1P 8mCwh2Wz0atBiyLu/OQfUEi9jOmaE4BKlxrFsosSh7dWFqKNh1n8k7fPy270KkBzHRrf RVHA5zRt2KX3GcrKwxhagV17ynllL7tApwGP5oL5K85hnAZUX5JODPdnhOuoUzNaGrQt n6aF/Kkol+J/vFCNL0cegY4qlyyZcZXFOseuYJtSFglcc0hn2Nq1h1K6OHliJIx34iXe vhomSbMsnMaOdU57wYGW3g8vVYr/Y+VQIIzyfdfnpvaDQRtlHxx/Gkhwnv+POneIwBsV p8jw== X-Gm-Message-State: AOJu0Yyu8DYbMT9RIrTqQ1MUeyuaksrCn55AxrhjcwXN9JiWnsViUCYZ 9WuBBkWazEEMitO8zeNynRDo+5CYEgVFAO7HpvRmaNOwW00= X-Google-Smtp-Source: AGHT+IHP2Y+VOwbgvgkZfHxUu7lORKyN6Hgmj4ISBZal3Tf0Sd72EjaOMd7MoCV3GW4N8e0jaKbXLDgI5P90NYcMg+w= X-Received: by 2002:a17:90a:bd06:b0:263:4305:4e82 with SMTP id y6-20020a17090abd0600b0026343054e82mr273549pjr.6.1695141366862; Tue, 19 Sep 2023 09:36:06 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Isaac Boukris Date: Tue, 19 Sep 2023 19:35:55 +0300 Message-ID: Subject: Re: dumpcap: timestamp is years ahead when in pcapng format To: users@dpdk.org, Stephen Hemminger Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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 Looking with git log, i found the original line was: return pcapng_time.ns + (delta * NSEC_PER_SEC) / rte_get_tsc_hz(); Testing that does show a wrapping issue, e.g. (it stays around 08:05). 2023-09-19 08:05:24.372037 IP _gateway.domain > Rocky8.38358: 31975 NXDomain 0/0/0 (46) 10 2023-09-19 08:05:21.577497 ARP, Request who-has _gateway tell Rocky8, length 46 2023-09-19 08:05:21.577599 ARP, Reply _gateway is-at 00:50:56:f8:92:76 (oui Unknown), length 46 13 2023-09-19 08:05:22.833897 IP 192.168.202.1.50886 > 239.255.255.250.ssdp: UDP, length 174 However with my change it looks fine and always increments. I dropped all the parenthesis: return pcapng_time.ns + delta / pcapng_time.tsc_hz * NSEC_PER_SEC; On Tue, Sep 19, 2023 at 5:40=E2=80=AFPM Isaac Boukris = wrote: > > Hi Stephen, > > Machine: vm on a laptop with i7 core > rte_get_timer_hz() =3D 2500000000 > rte_get_tsc_hz() =3D 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 -t= tttr - > 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 =3D cycles - pcapng_time.cycles; > - if (unlikely(delta >=3D pcapng_time.tsc_hz)) { > - if (likely(delta < pcapng_time.tsc_hz * 2)) { > - delta -=3D pcapng_time.tsc_hz; > - pcapng_time.cycles +=3D pcapng_time.tsc_hz; > - pcapng_time.ns +=3D NSEC_PER_SEC; > - } else { > - secs =3D rte_reciprocal_divide_u64(delta, > &pcapng_time.tsc_hz_inverse); > - delta -=3D secs * pcapng_time.tsc_hz; > - pcapng_time.cycles +=3D secs * pcapng_time.tsc_hz= ; > - pcapng_time.ns +=3D secs * NSEC_PER_SEC; > - } > - } > > - return pcapng_time.ns + rte_reciprocal_divide_u64(delta * NSEC_PE= R_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 -t= tttr - > 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!