net: zperf: Extract zperf into library
Make a library out of the zperf shell sample. This makes to enable the module in any application, not only the dedicated sample. Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
This commit is contained in:
parent
2670fc9b67
commit
2091b34820
|
@ -13,3 +13,4 @@ Networking APIs
|
|||
system_mgmt.rst
|
||||
tsn.rst
|
||||
gsm_modem.rst
|
||||
zperf.rst
|
||||
|
|
103
doc/connectivity/networking/api/zperf.rst
Normal file
103
doc/connectivity/networking/api/zperf.rst
Normal file
|
@ -0,0 +1,103 @@
|
|||
.. _zperf:
|
||||
|
||||
zperf: Network Traffic Generator
|
||||
################################
|
||||
|
||||
.. contents::
|
||||
:local:
|
||||
:depth: 2
|
||||
|
||||
Overview
|
||||
********
|
||||
|
||||
zperf is a shell utility which allows to generate network traffic in Zephyr. The
|
||||
tool may be used to evaluate network bandwidth.
|
||||
|
||||
zperf is compatible with iPerf_2.0.5. Note that in newer iPerf versions,
|
||||
an error message like this is printed and the server reported statistics
|
||||
are missing.
|
||||
|
||||
.. code-block:: console
|
||||
|
||||
LAST PACKET NOT RECEIVED!!!
|
||||
|
||||
zperf can be enabled in any application, a dedicated sample is also present
|
||||
in Zephyr. See :ref:`zperf sample application <zperf-sample>` for details.
|
||||
|
||||
Sample Usage
|
||||
************
|
||||
|
||||
If Zephyr acts as a client, iPerf must be executed in server mode.
|
||||
For example, the following command line must be used for UDP testing:
|
||||
|
||||
.. code-block:: console
|
||||
|
||||
$ iperf -s -l 1K -u -V -B 2001:db8::2
|
||||
|
||||
For TCP testing, the command line would look like this:
|
||||
|
||||
.. code-block:: console
|
||||
|
||||
$ iperf -s -l 1K -V -B 2001:db8::2
|
||||
|
||||
|
||||
In the Zephyr console, zperf can be executed as follows:
|
||||
|
||||
.. code-block:: console
|
||||
|
||||
zperf udp upload 2001:db8::2 5001 10 1K 1M
|
||||
|
||||
|
||||
For TCP the zperf command would look like this:
|
||||
|
||||
.. code-block:: console
|
||||
|
||||
zperf tcp upload 2001:db8::2 5001 10 1K 1M
|
||||
|
||||
|
||||
If the IP addresses of Zephyr and the host machine are specified in the
|
||||
config file, zperf can be started as follows:
|
||||
|
||||
.. code-block:: console
|
||||
|
||||
zperf udp upload2 v6 10 1K 1M
|
||||
|
||||
|
||||
or like this if you want to test TCP:
|
||||
|
||||
.. code-block:: console
|
||||
|
||||
zperf tcp upload2 v6 10 1K 1M
|
||||
|
||||
|
||||
If Zephyr is acting as a server, set the download mode as follows for UDP:
|
||||
|
||||
.. code-block:: console
|
||||
|
||||
zperf udp download 5001
|
||||
|
||||
|
||||
or like this for TCP:
|
||||
|
||||
.. code-block:: console
|
||||
|
||||
zperf tcp download 5001
|
||||
|
||||
|
||||
and in the host side, iPerf must be executed with the following
|
||||
command line if you are testing UDP:
|
||||
|
||||
.. code-block:: console
|
||||
|
||||
$ iperf -l 1K -u -V -c 2001:db8::1 -p 5001
|
||||
|
||||
|
||||
and this if you are testing TCP:
|
||||
|
||||
.. code-block:: console
|
||||
|
||||
$ iperf -l 1K -V -c 2001:db8::1 -p 5001
|
||||
|
||||
|
||||
iPerf output can be limited by using the -b option if Zephyr is not
|
||||
able to receive all the packets in orderly manner.
|
|
@ -7,15 +7,4 @@ project(zperf)
|
|||
|
||||
target_sources(app PRIVATE
|
||||
src/main.c
|
||||
src/shell_utils.c
|
||||
src/zperf_session.c
|
||||
src/zperf_shell.c
|
||||
src/zperf_udp_receiver.c
|
||||
src/zperf_udp_uploader.c
|
||||
src/zperf_tcp_receiver.c
|
||||
src/zperf_tcp_uploader.c
|
||||
)
|
||||
|
||||
target_include_directories(app PRIVATE
|
||||
${ZEPHYR_BASE}/subsys/net/ip
|
||||
)
|
||||
|
|
|
@ -6,8 +6,8 @@ zperf: Network Traffic Generator
|
|||
Description
|
||||
***********
|
||||
|
||||
zperf is a network traffic generator for Zephyr that may be used to
|
||||
evaluate network bandwidth.
|
||||
The zperf sample demonstrates the :ref:`zperf shell utility <zperf>`, which
|
||||
allows to evaluate network bandwidth.
|
||||
|
||||
Features
|
||||
*********
|
||||
|
@ -46,77 +46,5 @@ to setup the network environment.
|
|||
Usage
|
||||
*****
|
||||
|
||||
If Zephyr acts as a client, iPerf must be executed in server mode.
|
||||
For example, the following command line must be used for UDP testing:
|
||||
|
||||
.. code-block:: console
|
||||
|
||||
$ iperf -s -l 1K -u -V -B 2001:db8::2
|
||||
|
||||
For TCP testing, the command line would look like this:
|
||||
|
||||
.. code-block:: console
|
||||
|
||||
$ iperf -s -l 1K -V -B 2001:db8::2
|
||||
|
||||
|
||||
In the Zephyr console, zperf can be executed as follows:
|
||||
|
||||
.. code-block:: console
|
||||
|
||||
zperf udp upload 2001:db8::2 5001 10 1K 1M
|
||||
|
||||
|
||||
For TCP the zperf command would look like this:
|
||||
|
||||
.. code-block:: console
|
||||
|
||||
zperf tcp upload 2001:db8::2 5001 10 1K 1M
|
||||
|
||||
|
||||
If the IP addresses of Zephyr and the host machine are specified in the
|
||||
config file, zperf can be started as follows:
|
||||
|
||||
.. code-block:: console
|
||||
|
||||
zperf udp upload2 v6 10 1K 1M
|
||||
|
||||
|
||||
or like this if you want to test TCP:
|
||||
|
||||
.. code-block:: console
|
||||
|
||||
zperf tcp upload2 v6 10 1K 1M
|
||||
|
||||
|
||||
If Zephyr is acting as a server, set the download mode as follows for UDP:
|
||||
|
||||
.. code-block:: console
|
||||
|
||||
zperf udp download 5001
|
||||
|
||||
|
||||
or like this for TCP:
|
||||
|
||||
.. code-block:: console
|
||||
|
||||
zperf tcp download 5001
|
||||
|
||||
|
||||
and in the host side, iPerf must be executed with the following
|
||||
command line if you are testing UDP:
|
||||
|
||||
.. code-block:: console
|
||||
|
||||
$ iperf -l 1K -u -V -c 2001:db8::1 -p 5001
|
||||
|
||||
|
||||
and this if you are testing TCP:
|
||||
|
||||
.. code-block:: console
|
||||
|
||||
$ iperf -l 1K -V -c 2001:db8::1 -p 5001
|
||||
|
||||
|
||||
iPerf output can be limited by using the -b option if Zephyr is not
|
||||
able to receive all the packets in orderly manner.
|
||||
See :ref:`zperf library documentation <zperf>` for more information about
|
||||
the library usage.
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
CONFIG_NETWORKING=y
|
||||
CONFIG_NET_ZPERF=y
|
||||
CONFIG_NET_LOG=y
|
||||
CONFIG_NET_IPV6=y
|
||||
CONFIG_NET_IPV4=y
|
||||
|
|
|
@ -12,6 +12,7 @@ add_subdirectory_ifdef(CONFIG_NET_SOCKETS sockets)
|
|||
add_subdirectory_ifdef(CONFIG_TLS_CREDENTIALS tls_credentials)
|
||||
add_subdirectory_ifdef(CONFIG_NET_CONNECTION_MANAGER conn_mgr)
|
||||
add_subdirectory_ifdef(CONFIG_NET_CAPTURE capture)
|
||||
add_subdirectory_ifdef(CONFIG_NET_ZPERF zperf)
|
||||
|
||||
if (CONFIG_DNS_RESOLVER
|
||||
OR CONFIG_MDNS_RESPONDER
|
||||
|
|
|
@ -39,4 +39,6 @@ source "subsys/net/lib/conn_mgr/Kconfig"
|
|||
|
||||
source "subsys/net/lib/capture/Kconfig"
|
||||
|
||||
source "subsys/net/lib/zperf/Kconfig"
|
||||
|
||||
endmenu
|
||||
|
|
17
subsys/net/lib/zperf/CMakeLists.txt
Normal file
17
subsys/net/lib/zperf/CMakeLists.txt
Normal file
|
@ -0,0 +1,17 @@
|
|||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
zephyr_library_named(zperf)
|
||||
|
||||
zephyr_library_sources(
|
||||
shell_utils.c
|
||||
zperf_session.c
|
||||
zperf_shell.c
|
||||
zperf_udp_receiver.c
|
||||
zperf_udp_uploader.c
|
||||
zperf_tcp_receiver.c
|
||||
zperf_tcp_uploader.c
|
||||
)
|
||||
|
||||
zephyr_library_include_directories(
|
||||
${ZEPHYR_BASE}/subsys/net/ip
|
||||
)
|
19
subsys/net/lib/zperf/Kconfig
Normal file
19
subsys/net/lib/zperf/Kconfig
Normal file
|
@ -0,0 +1,19 @@
|
|||
# Copyright (c) 2022 Nordic Semiconductor ASA
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
menuconfig NET_ZPERF
|
||||
bool "zperf shell utility"
|
||||
depends on SHELL
|
||||
help
|
||||
This option enables zperf shell utility, which allows to generate
|
||||
network traffic and evaluate network bandwidth.
|
||||
|
||||
if NET_ZPERF
|
||||
|
||||
module = NET_ZPERF
|
||||
module-dep = NET_LOG
|
||||
module-str = Log level for zperf
|
||||
module-help = Enable debug message of zperf libray.
|
||||
source "subsys/net/Kconfig.template.log_config.net"
|
||||
|
||||
endif
|
|
@ -5,7 +5,6 @@
|
|||
*/
|
||||
|
||||
#include <ctype.h>
|
||||
#include <zephyr/sys/printk.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
|
@ -5,7 +5,7 @@
|
|||
*/
|
||||
|
||||
#include <zephyr/logging/log.h>
|
||||
LOG_MODULE_DECLARE(net_zperf_sample, LOG_LEVEL_DBG);
|
||||
LOG_MODULE_DECLARE(net_zperf, CONFIG_NET_ZPERF_LOG_LEVEL);
|
||||
|
||||
#include <zephyr/zephyr.h>
|
||||
|
||||
|
@ -29,7 +29,7 @@ struct session *get_session(const struct sockaddr *addr,
|
|||
const struct sockaddr_in6 *addr6 = (const struct sockaddr_in6 *)addr;
|
||||
|
||||
if (proto != SESSION_TCP && proto != SESSION_UDP) {
|
||||
printk("Error! unsupported proto.\n");
|
||||
NET_ERR("Error! unsupported proto.\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -92,7 +92,7 @@ struct session *get_tcp_session(int sock)
|
|||
int i = 0;
|
||||
|
||||
if (sock < 0) {
|
||||
printk("Error! Invalid socket.\n");
|
||||
NET_ERR("Error! Invalid socket.\n");
|
||||
return NULL;
|
||||
}
|
||||
|
|
@ -5,14 +5,13 @@
|
|||
*/
|
||||
|
||||
#include <zephyr/logging/log.h>
|
||||
LOG_MODULE_REGISTER(net_zperf_sample, LOG_LEVEL_DBG);
|
||||
LOG_MODULE_REGISTER(net_zperf, CONFIG_NET_ZPERF_LOG_LEVEL);
|
||||
|
||||
#include <ctype.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <zephyr/zephyr.h>
|
||||
#include <zephyr/sys/printk.h>
|
||||
#include <zephyr/shell/shell.h>
|
||||
|
||||
#include <zephyr/net/net_ip.h>
|
|
@ -5,15 +5,13 @@
|
|||
*/
|
||||
|
||||
#include <zephyr/logging/log.h>
|
||||
LOG_MODULE_DECLARE(net_zperf_sample, LOG_LEVEL_DBG);
|
||||
LOG_MODULE_DECLARE(net_zperf, CONFIG_NET_ZPERF_LOG_LEVEL);
|
||||
|
||||
#include <zephyr/zephyr.h>
|
||||
|
||||
#include <zephyr/linker/sections.h>
|
||||
#include <zephyr/toolchain.h>
|
||||
|
||||
#include <zephyr/sys/printk.h>
|
||||
|
||||
#include <zephyr/net/socket.h>
|
||||
|
||||
#include "zperf.h"
|
|
@ -5,12 +5,11 @@
|
|||
*/
|
||||
|
||||
#include <zephyr/logging/log.h>
|
||||
LOG_MODULE_DECLARE(net_zperf_sample, LOG_LEVEL_DBG);
|
||||
LOG_MODULE_DECLARE(net_zperf, CONFIG_NET_ZPERF_LOG_LEVEL);
|
||||
|
||||
#include <zephyr/zephyr.h>
|
||||
|
||||
#include <errno.h>
|
||||
#include <zephyr/sys/printk.h>
|
||||
|
||||
#include <zephyr/net/socket.h>
|
||||
|
|
@ -5,13 +5,12 @@
|
|||
*/
|
||||
|
||||
#include <zephyr/logging/log.h>
|
||||
LOG_MODULE_DECLARE(net_zperf_sample, LOG_LEVEL_DBG);
|
||||
LOG_MODULE_DECLARE(net_zperf, CONFIG_NET_ZPERF_LOG_LEVEL);
|
||||
|
||||
#include <zephyr/linker/sections.h>
|
||||
#include <zephyr/toolchain.h>
|
||||
|
||||
#include <zephyr/zephyr.h>
|
||||
#include <zephyr/sys/printk.h>
|
||||
|
||||
#include <zephyr/net/socket.h>
|
||||
|
|
@ -5,12 +5,10 @@
|
|||
*/
|
||||
|
||||
#include <zephyr/logging/log.h>
|
||||
LOG_MODULE_DECLARE(net_zperf_sample, LOG_LEVEL_DBG);
|
||||
LOG_MODULE_DECLARE(net_zperf, CONFIG_NET_ZPERF_LOG_LEVEL);
|
||||
|
||||
#include <zephyr/zephyr.h>
|
||||
|
||||
#include <zephyr/sys/printk.h>
|
||||
|
||||
#include <zephyr/net/socket.h>
|
||||
|
||||
#include "zperf.h"
|
Loading…
Reference in a new issue