lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <OSZP286MB140443F792102C93E5D8A1D795859@OSZP286MB1404.JPNP286.PROD.OUTLOOK.COM>
Date:   Sat, 9 Jul 2022 02:34:04 +0000
From:   Feng Gao <gfree.wind@...look.com>
To:     Eric Dumazet <edumazet@...gle.com>
CC:     David Miller <davem@...emloft.net>,
        Jakub Kicinski <kuba@...nel.org>,
        Paolo Abeni <pabeni@...hat.com>,
        netdev <netdev@...r.kernel.org>, Gao Feng <gfree.wind@...il.com>
Subject: Re: [PATCH net] pktgen: Fix the inaccurate bps calculation

Thanks Eric. Now I get the kb is 1000 b, and the kib is 1024 b.

Actually I find the result of pktgen is more than the nic's physical rate during my tests. Then I made a few changes to make it consistent with real traffic.

This patch is one trivial of those changes. It seems this one isn't right
I will refine other changes, and commit another patch. 

Thank you again.

________________________________________
To: Eric Dumazet <edumazet@...gle.com>
From : gfree.wind@...look.com
cc: David Miller; Jakub Kicinski; Paolo Abeni; netdev; Gao Feng
subject: Re: [PATCH net] pktgen: Fix the inaccurate bps calculation

On Fri, Jul 8, 2022 at 5:14 PM <gfree.wind@...look.com> wrote:
>
> From: Gao Feng <gfree.wind@...il.com>
>
> The prior codes use 1000000 as divisor to convert to the Mbps. But it isn't
> accurate, because the NIC uses 1024*1024 from bps to Mbps. The result of
> the codes is 1.05 times as the real value, even it may cause the result is
> more than the nic's physical rate.


1Mbit = 1,000,000 bits per second.

https://nam12.safelinks.protection.outlook.com/?url=https%3A%2F%2Fen.wikipedia.org%2Fwiki%2FMegabit&amp;data=05%7C01%7C%7C791d6d1813ed4a8c172008da60fae5e4%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637928928004350385%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&amp;sdata=NPbYWxCfGihq5RCfKIHOHt3oUpoljc2Jk0uSprnjEF8%3D&amp;reserved=0

Current code is right IMO.

>
> Signed-off-by: Gao Feng <gfree.wind@...il.com>
> ---
>  net/core/pktgen.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/net/core/pktgen.c b/net/core/pktgen.c
> index 84b62cd7bc57..e5cd3da63035 100644
> --- a/net/core/pktgen.c
> +++ b/net/core/pktgen.c
> @@ -3305,7 +3305,7 @@ static void show_results(struct pktgen_dev *pkt_dev, int nr_frags)
>         }
>
>         mbps = bps;
> -       do_div(mbps, 1000000);
> +       do_div(mbps, 1024 * 1024);
>         p += sprintf(p, "  %llupps %lluMb/sec (%llubps) errors: %llu",
>                      (unsigned long long)pps,
>                      (unsigned long long)mbps,
> --
> 2.20.1
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ