connectivity/networking/native_sim_setup.html · connectivity/networking/native_sim_setup.rst 공식 원문 ↗

Zephyr 3.7.0 · Connectivity · Host Simulation

native_sim board에서 Networking 사용

Linux host와 Native Simulator를 TAP interface 또는 socket offload로 연결해 echo server를 검증합니다.

Official pathconnectivity/networking/native_sim_setup.html
Source fileconnectivity/networking/native_sim_setup.rst
Source versionZephyr 3.7.0
TranslationFull · reviewed

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

Part 1

요약·해설

세 terminal을 이용한 TAP 구성과 root 권한이 필요 없는 localhost socket offload 구성을 각각 설명합니다.

TAP

net-tools · tuntap

Offload

BSD sockets · loopback

Tests

UDP · TCP

Part 2

접을 수 있는 영어 원문 전체

영어 원문 전체 펼치기
원문 SHA-256 38D192477CB278BE60720469E15BCCBC71A241D75FAD3EAF85DC97110FE7A6D4
.. _networking_with_native_sim:

Networking with native_sim board
################################

.. contents::
    :local:
    :depth: 2

Using virtual/TAP Ethernet driver
*********************************

This paragraph describes how to set up a virtual network between a (Linux) host
and a Zephyr application running in a :ref:`native_sim <native_sim>` board.

In this example, the :zephyr:code-sample:`sockets-echo-server` sample application from
the Zephyr source distribution is run in native_sim board. The Zephyr
native_sim board instance is connected to a Linux host using a tuntap device
which is modeled in Linux as an Ethernet network interface.

Prerequisites
=============

On the Linux Host, fetch the Zephyr ``net-tools`` project, which is located
in a separate Git repository:

.. code-block:: console

   git clone https://github.com/zephyrproject-rtos/net-tools


Basic Setup
===========

For the steps below, you will need three terminal windows:

* Terminal #1 is terminal window with net-tools being the current
  directory (``cd net-tools``)
* Terminal #2 is your usual Zephyr development terminal,
  with the Zephyr environment initialized.
* Terminal #3 is the console to the running Zephyr native_sim
  instance (optional).

Step 1 - Create Ethernet interface
----------------------------------

Before starting native_sim with network emulation, a network interface
should be created.

In terminal #1, type:

.. code-block:: console

   ./net-setup.sh

You can tweak the behavior of the net-setup.sh script. See various options
by running ``net-setup.sh`` like this:

.. code-block:: console

   ./net-setup.sh --help


Step 2 - Start app in native_sim board
--------------------------------------

Build and start the ``echo_server`` sample application.

In terminal #2, type:

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


Step 3 - Connect to console (optional)
--------------------------------------

The console window should be launched automatically when the Zephyr instance is
started but if it does not show up, you can manually connect to the console.
The native_sim board will print a string like this when it starts:

.. code-block:: console

   UART connected to pseudotty: /dev/pts/5

You can manually connect to it like this:

.. code-block:: console

   screen /dev/pts/5

Using offloaded sockets
***********************

The main advantage over `Using virtual/TAP Ethernet driver`_ is not needing to
setup a virtual network interface on the host machine. This means that no
leveraged (root) privileges are needed.

Step 1 - Start app in native_sim board
======================================

Build and start the ``echo_server`` sample application:

.. zephyr-app-commands::
   :zephyr-app: samples/net/sockets/echo_server
   :host-os: unix
   :board: native_sim
   :gen-args: -DEXTRA_CONF_FILE=overlay-nsos.conf
   :goals: run
   :compact:

Step 2 - run echo-client from net-tools
=======================================

On the Linux Host, fetch the Zephyr ``net-tools`` project, which is located
in a separate Git repository:

.. code-block:: console

   git clone https://github.com/zephyrproject-rtos/net-tools

.. note::

   Native Simulator with the offloaded sockets network driver is using the same
   network interface/namespace as any other (Linux) application that uses BSD
   sockets API. This means that :zephyr:code-sample:`sockets-echo-server` and
   ``echo-client`` applications will communicate over localhost/loopback
   interface (address ``127.0.0.1``).

To run UDP test, type:

.. code-block:: console

   ./echo-client 127.0.0.1

For TCP test, type:

.. code-block:: console

   ./echo-client -t 127.0.0.1

Part 3

한국어 전문 번역

native_sim board에서 Networking 사용

Virtual/TAP Ethernet driver 사용

이 절은 Linux host와 native_sim board에서 실행하는 Zephyr application 사이에 virtual network를 설정하는 방법을 설명합니다.

예제에서는 Zephyr source distribution의 sockets echo server sample을 native_sim board에서 실행합니다. Zephyr native_sim instance는 Linux에서 Ethernet network interface로 모델링되는 tuntap device를 통해 Linux host와 연결됩니다.

사전 준비

Linux host에서 별도 Git repository에 있는 Zephyr net-tools project를 내려받습니다.

git clone https://github.com/zephyrproject-rtos/net-tools

기본 설정

아래 단계를 수행하려면 terminal window 세 개가 필요합니다.

  • Terminal #1: net-tools를 현재 directory로 둔 terminal(cd net-tools)
  • Terminal #2: Zephyr environment를 초기화한 일반적인 Zephyr development terminal
  • Terminal #3: 실행 중인 Zephyr native_sim instance의 console이며 선택 사항

1단계: Ethernet interface 생성

Network emulation을 사용하는 native_sim을 시작하기 전에 network interface를 만들어야 합니다.

Terminal #1에서 다음 명령을 실행합니다.

./net-setup.sh

net-setup.sh script의 동작은 option으로 조정할 수 있습니다. 다음 명령으로 사용 가능한 option을 확인합니다.

./net-setup.sh --help

2단계: native_sim board에서 application 시작

Echo server sample application을 build하고 실행합니다.

Terminal #2의 초기화된 Zephyr workspace에서 다음과 같이 native_sim 대상으로 실행합니다.

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

3단계: Console 연결(선택 사항)

Zephyr instance가 시작되면 console window가 자동으로 열려야 합니다. 창이 나타나지 않으면 console에 수동으로 연결할 수 있습니다.

Native_sim board는 시작 시 다음과 비슷한 문자열을 출력합니다.

UART connected to pseudotty: /dev/pts/5

출력된 pseudotty에 다음처럼 연결합니다.

screen /dev/pts/5

Offloaded socket 사용

Virtual/TAP Ethernet driver 방식과 비교한 가장 큰 장점은 host machine에 virtual network interface를 설정할 필요가 없다는 점입니다. 따라서 높은 권한, 즉 root privilege도 필요하지 않습니다.

1단계: native_sim board에서 application 시작

Socket offload overlay를 사용해 echo server sample application을 build하고 실행합니다.

west build -b native_sim samples/net/sockets/echo_server -- -DEXTRA_CONF_FILE=overlay-nsos.conf 뒤 build target을 실행합니다.

2단계: net-tools의 echo-client 실행

Linux host에서 별도 Git repository의 Zephyr net-tools project를 내려받습니다.

git clone https://github.com/zephyrproject-rtos/net-tools

UDP test는 다음 명령으로 실행합니다.

./echo-client 127.0.0.1

TCP test는 다음 명령으로 실행합니다.

./echo-client -t 127.0.0.1

Source

출처

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