samples/net/sockets/echo_client/README.html · samples/net/sockets/echo_client/README.rst 공식 원문 ↗

Zephyr 3.7.0 · Samples · Networking · UDP/TCP

Echo client (advanced)

OpenThread·802.15.4·TLS·SOCKS5 구성을 선택해 QEMU 또는 hardware에서 echo server를 검증합니다.

Official pathsamples/net/sockets/echo_client/README.html
Source filesamples/net/sockets/echo_client/README.rst
Source versionZephyr 3.7.0
TranslationFull · reviewed

본문 기준: Zephyr 3.7.0 LTS3 · 이후 유지보수 패치는 별도입니다.

Part 1

요약·해설

Configuration overlay, certificate, proxy address와 Linux host 연동 순서를 command까지 보존합니다.

Protocols

UDP · TCP

Security

TLS · SOCKS5

Targets

QEMU · Hardware

Part 2

접을 수 있는 영어 원문 전체

영어 원문 전체 펼치기
원문 SHA-256 D77218578776612DEBFA000E6AE21C559D27ECF8EF9CB9AD2FA70CED6EC84DF3
.. zephyr:code-sample:: sockets-echo-client
   :name: Echo client (advanced)
   :relevant-api: bsd_sockets tls_credentials

   Implement a client that sends IP packets, waits for data to be sent back, and verifies it.

Overview
********

The echo-client sample application for Zephyr implements a UDP/TCP client
that will send IPv4 or IPv6 packets, wait for the data to be sent back,
and then verify it matches the data that was sent.

The source code for this sample application can be found at:
:zephyr_file:`samples/net/sockets/echo_client`.

Requirements
************

- :ref:`networking_with_host`

Building and Running
********************

There are multiple ways to use this application. One of the most common
usage scenario is to run echo-client application inside QEMU. This is
described in :ref:`networking_with_qemu`.

There are configuration files for different boards and setups in the
echo-client directory:

- :file:`prj.conf`
  Generic config file, normally you should use this.

- :file:`overlay-ot.conf`
  This overlay config enables support for OpenThread.

- :file:`overlay-802154.conf`
  This overlay config enables support for native IEEE 802.15.4 connectivity.
  Note, that by default IEEE 802.15.4 L2 uses unacknowledged communication. To
  improve connection reliability, acknowledgments can be enabled with shell
  command: ``ieee802154 ack set``.

- :file:`overlay-qemu_802154.conf`
  This overlay config enables support for two QEMU's when simulating
  IEEE 802.15.4 network that are connected together.

- :file:`overlay-tls.conf`
  This overlay config enables support for TLS.

Build echo-client sample application like this:

.. zephyr-app-commands::
   :zephyr-app: samples/net/sockets/echo_client
   :board: <board to use>
   :conf: <config file to use>
   :goals: build
   :compact:

Example building for the nrf52840dk/nrf52840 with OpenThread support:

.. zephyr-app-commands::
   :zephyr-app: samples/net/sockets/echo_client
   :host-os: unix
   :board: nrf52840dk/nrf52840
   :conf: "prj.conf overlay-ot.conf"
   :goals: run
   :compact:

Example building for the IEEE 802.15.4 RF2XX transceiver:

.. zephyr-app-commands::
   :zephyr-app: samples/net/sockets/echo_client
   :host-os: unix
   :board: [samr21_xpro | sam4s_xplained | sam_v71_xult/samv71q21]
   :gen-args: -DEXTRA_CONF_FILE=overlay-802154.conf
   :goals: build flash
   :compact:

In a terminal window you can check if communication is happen:

.. code-block:: console

    $ minicom -D /dev/ttyACM1



Enabling TLS support
====================

Enable TLS support in the sample by building the project with the
``overlay-tls.conf`` overlay file enabled, for example, using these commands:

.. zephyr-app-commands::
   :zephyr-app: samples/net/sockets/echo_client
   :board: qemu_x86
   :conf: "prj.conf overlay-tls.conf"
   :goals: build
   :compact:

An alternative way is to specify ``-DEXTRA_CONF_FILE=overlay-tls.conf`` when
running ``west build`` or ``cmake``.

The certificate and private key used by the sample can be found in the sample's
``src`` directory. The default certificates used by Socket Echo Client and
:zephyr:code-sample:`sockets-echo-server` enable establishing a secure connection
between the samples.

SOCKS5 proxy support
====================

It is also possible to connect to the echo-server through a SOCKS5 proxy.
To enable it, use ``-DEXTRA_CONF_FILE=overlay-socks5.conf`` when running ``west
build`` or  ``cmake``.

By default, to make the testing easier, the proxy is expected to run on the
same host as the echo-server in Linux host.

To start a proxy server, for example a builtin SOCKS server support in ssh
can be used (-D option). Use the following command to run it on your host
with the default port:

For IPv4 proxy server:

.. code-block:: console

        $ ssh -N -D 0.0.0.0:1080 localhost

For IPv6 proxy server:

.. code-block:: console

        $ ssh -N -D [::]:1080 localhost

Run both commands if you are testing IPv4 and IPv6.

To connect to a proxy server that is not running under the same IP as the
echo-server or uses a different port number, modify the following values
in echo_client/src/tcp.c.

.. code-block:: c

        #define SOCKS5_PROXY_V4_ADDR IPV4_ADDR
        #define SOCKS5_PROXY_V6_ADDR IPV6_ADDR
        #define SOCKS5_PROXY_PORT    1080

Running echo-server in Linux Host
=================================

There is one useful testing scenario that can be used with Linux host.
Here echo-client is run in QEMU and echo-server is run in Linux host.

To use QEMU for testing, follow the :ref:`networking_with_qemu` guide.

In a terminal window:

.. code-block:: console

    $ sudo ./echo-server -i tap0

Run echo-client application in QEMU:

.. zephyr-app-commands::
   :zephyr-app: samples/net/sockets/echo_client
   :host-os: unix
   :board: qemu_x86
   :conf: "prj.conf overlay-linux.conf"
   :goals: run
   :compact:

Note that echo-server must be running in the Linux host terminal window
before you start the echo-client application in QEMU.
Exit QEMU by pressing :kbd:`CTRL+A` :kbd:`x`.

You can verify TLS communication with a Linux host as well. See
https://github.com/zephyrproject-rtos/net-tools documentation for information
on how to test TLS with Linux host samples.

See the :zephyr:code-sample:`sockets-echo-server` documentation for an alternate
way of running, with the echo-client on the Linux host and the echo-server
in QEMU.

Part 3

한국어 전문 번역

개요

Zephyr의 echo-client sample application은 IPv4 또는 IPv6 packet을 보내고, 되돌아온 data를 기다린 다음, 수신 data가 보낸 data와 일치하는지 검증하는 UDP/TCP client를 구현합니다.

이 sample application의 source code는 samples/net/sockets/echo_client에서 찾을 수 있습니다.

요구 사항

빌드 및 실행

이 application을 사용하는 방법은 여러 가지입니다. 가장 흔한 사용 시나리오 중 하나는 QEMU 안에서 echo-client application을 실행하는 것이며, Networking with QEMU 문서에서 설명합니다.

Echo-client directory에는 board와 구성별 configuration file이 있습니다.

  • prj.conf: 일반 configuration file이며 보통 이 file을 사용합니다.
  • overlay-ot.conf: OpenThread 지원을 활성화하는 overlay configuration입니다.
  • overlay-802154.conf: Native IEEE 802.15.4 연결을 활성화합니다. IEEE 802.15.4 L2는 기본적으로 acknowledgement 없는 통신을 사용합니다. Connection reliability를 높이려면 shell에서 ieee802154 ack set으로 acknowledgement를 활성화할 수 있습니다.
  • overlay-qemu_802154.conf: 서로 연결된 IEEE 802.15.4 network를 simulation할 때 두 QEMU instance를 지원합니다.
  • overlay-tls.conf: TLS 지원을 활성화합니다.

Echo-client sample application의 일반 build 방법은 다음과 같습니다.

west build -b <board to use> samples/net/sockets/echo_client -- -DCONF_FILE=<config file to use>

OpenThread 지원을 포함해 nrf52840dk/nrf52840용으로 build하고 실행하는 예:

west build -b nrf52840dk/nrf52840 samples/net/sockets/echo_client -- -DCONF_FILE="prj.conf overlay-ot.conf"
west build -t run

IEEE 802.15.4 RF2XX transceiver용으로 build하고 flash하는 예:

west build -b [samr21_xpro | sam4s_xplained | sam_v71_xult/samv71q21] samples/net/sockets/echo_client -- -DEXTRA_CONF_FILE=overlay-802154.conf
west flash

Terminal window에서 다음 명령으로 communication이 이루어지는지 확인할 수 있습니다.

$ minicom -D /dev/ttyACM1

TLS 지원 활성화

overlay-tls.conf overlay file을 활성화하여 project를 build하면 sample의 TLS 지원을 켤 수 있습니다. 예를 들면 다음과 같습니다.

west build -b qemu_x86 samples/net/sockets/echo_client -- -DCONF_FILE="prj.conf overlay-tls.conf"

다른 방법으로 west build 또는 cmake를 실행할 때 -DEXTRA_CONF_FILE=overlay-tls.conf를 지정할 수 있습니다.

Sample이 사용하는 certificate와 private key는 sample의 src directory에 있습니다. Socket Echo Client와 Socket Echo Server가 기본으로 사용하는 certificate는 두 sample 사이에 secure connection을 수립할 수 있게 합니다.

SOCKS5 proxy 지원

SOCKS5 proxy를 거쳐 echo-server에 연결할 수도 있습니다. 이를 활성화하려면 west build 또는 cmake 실행 시 -DEXTRA_CONF_FILE=overlay-socks5.conf를 사용합니다.

Test를 쉽게 하기 위해 proxy는 기본적으로 Linux host에서 echo-server와 같은 host에 실행된다고 가정합니다.

Proxy server를 시작할 때는 예를 들어 ssh에 내장된 SOCKS server 지원(-D option)을 사용할 수 있습니다. 기본 port로 IPv4 proxy server를 실행하는 명령은 다음과 같습니다.

$ ssh -N -D 0.0.0.0:1080 localhost

IPv6 proxy server 명령:

$ ssh -N -D [::]:1080 localhost

IPv4와 IPv6를 모두 시험한다면 두 명령을 모두 실행합니다.

Echo-server와 다른 IP에서 실행되거나 다른 port number를 사용하는 proxy server에 연결하려면 echo_client/src/tcp.c의 다음 값을 수정합니다.

#define SOCKS5_PROXY_V4_ADDR IPV4_ADDR
#define SOCKS5_PROXY_V6_ADDR IPV6_ADDR
#define SOCKS5_PROXY_PORT    1080

Linux Host에서 echo-server 실행

Linux host와 함께 사용할 수 있는 유용한 test 시나리오가 있습니다. Echo-client는 QEMU에서 실행하고 echo-server는 Linux host에서 실행합니다.

QEMU test 설정은 Networking with QEMU guide를 따릅니다.

Terminal window에서 Linux echo-server를 실행합니다.

$ sudo ./echo-server -i tap0

QEMU에서 echo-client application을 실행합니다.

west build -b qemu_x86 samples/net/sockets/echo_client -- -DCONF_FILE="prj.conf overlay-linux.conf"
west build -t run

QEMU에서 echo-client application을 시작하기 전에 Linux host terminal window에서 echo-server가 실행 중이어야 합니다. CTRL+A에 이어 x를 눌러 QEMU를 종료합니다.

Linux host와의 TLS communication도 검증할 수 있습니다. 시험 방법은 Zephyr net-tools documentation을 참고하십시오.

반대로 Linux host에서 echo-client를 실행하고 QEMU에서 echo-server를 실행하는 방법은 Socket Echo Server sample 문서를 참고하십시오.

Source

출처

영어 원문에는 문단, 문서 지시문, 표, 코드, 코드 심벌, 경로를 그대로 보존했습니다.