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

Zephyr 3.7.0 · Samples · Networking · UDP/TCP

Echo server (advanced)

Board별 overlay로 network와 TLS를 구성하고 QEMU server를 Linux echo-client에서 시험합니다.

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

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

Part 1

요약·해설

Client와 짝을 이루는 packet 반환 흐름, 모든 overlay와 양방향 host/QEMU 시험 절차를 보존합니다.

Protocols

UDP · TCP

Network

OT · 802.15.4

Security

TLS

Part 2

접을 수 있는 영어 원문 전체

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

   Implement a UDP/TCP server that sends received packets back to the sender.

Overview
********

The echo-server sample application for Zephyr implements a UDP/TCP server
that complements the echo-client sample application: the echo-server listens
for incoming IPv4 or IPv6 packets (sent by the echo client) and simply sends
them back.

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

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-server application inside QEMU. This is
described in :ref:`networking_with_qemu`.

There are configuration files for different boards and setups in the
echo-server 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.

- :file:`overlay-tunnel.conf`
  This overlay config enables support for IP tunneling.

Build echo-server sample application like this:

.. zephyr-app-commands::
   :zephyr-app: samples/net/sockets/echo_server
   :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_server
   :host-os: unix
   :board: nrf52840dk/nrf52840
   :conf: "prj.conf overlay-ot.conf"
   :goals: run
   :compact:

Example building for the samr21_xpro with RF2XX driver support:

.. zephyr-app-commands::
   :zephyr-app: samples/net/sockets/echo_server
   :host-os: unix
   :board: [samr21_xpro | sam4e_xpro | 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/ttyACM0

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_server
   :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 used by the sample can be found in the sample's ``src``
directory. The default certificates used by Socket Echo Server and
:zephyr:code-sample:`sockets-echo-client` enable establishing a secure connection
between the samples.

Running echo-client in Linux Host
=================================

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

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

Run echo-server application in QEMU:

.. zephyr-app-commands::
   :zephyr-app: samples/net/sockets/echo_server
   :host-os: unix
   :board: qemu_x86
   :goals: run
   :compact:

In a terminal window:

.. code-block:: console

    $ sudo ./echo-client -i tap0 2001:db8::1

Note that echo-server must be running in QEMU before you start the
echo-client application in host terminal window.

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-client` sample documentation for an alternate
way of running, with the echo-server on the Linux host and the echo-client
in QEMU.

Part 3

한국어 전문 번역

개요

Zephyr의 echo-server sample application은 echo-client sample과 짝을 이루는 UDP/TCP server를 구현합니다. Echo-server는 echo client가 보낸 incoming IPv4 또는 IPv6 packet을 기다렸다가 그대로 되돌려 보냅니다.

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

요구 사항

빌드 및 실행

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

Echo-server 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 지원을 활성화합니다.
  • overlay-tunnel.conf: IP tunneling 지원을 활성화합니다.

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

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

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

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

RF2XX driver 지원을 포함해 지정된 SAM board용으로 build하고 flash하는 예:

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

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

$ minicom -D /dev/ttyACM0

TLS 지원 활성화

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

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

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

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

Linux Host에서 echo-client 실행

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

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

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

west build -b qemu_x86 samples/net/sockets/echo_server
west build -t run

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

$ sudo ./echo-client -i tap0 2001:db8::1

Host terminal window에서 echo-client application을 시작하기 전에 QEMU에서 echo-server가 실행 중이어야 합니다.

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

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

Source

출처

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