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

Zephyr 3.7.0 · Samples · Networking · File transfer

TFTP client

QEMU·native_sim networking을 설정하고 server address·port·DNS resolver를 구성합니다.

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

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

Part 1

요약·해설

GET·PUT, default endpoint, hostname mode와 실제 hex dump 출력을 보존합니다.

Protocol

TFTP over UDP

Default

192.0.2.2:69

Operations

GET · PUT

Part 2

접을 수 있는 영어 원문 전체

영어 원문 전체 펼치기
원문 SHA-256 407B9F20B94A34803FDFFB179159A58B2E7696B6DF4B023BD6E22F7F47AAFC3C
.. zephyr:code-sample:: tftp-client
   :name: TFTP client
   :relevant-api: tftp_client

   Use the TFTP client library to get/put files from/to a TFTP server.

Overview
********

Trivial File Transfer Protocol (TFTP) is a simple lockstep File Transfer Protocol
based on UDP, and is designed to get a file from or put a file onto a remote host.

This TFTP client sample application for Zephyr implements the TFTP client library
and establishes a connection to a TFTP server on standard port 69.

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

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

- :ref:`networking_with_eth_qemu`, :ref:`networking_with_qemu` or :ref:`networking_with_native_sim`
- Linux machine

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

There are configuration files for various setups in the
samples/net/tftp_client directory:

- :file:`prj.conf`
  This is the standard default config.

Build the tftp-client sample application like this:

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

The easiest way to setup this sample application is to build and run it
as a native_sim application or as a QEMU target using the default configuration :file:`prj.conf`.
This requires a small amount of setup described in :ref:`networking_with_eth_qemu`, :ref:`networking_with_qemu` and :ref:`networking_with_native_sim`.

Build the tftp-client sample application for :ref:`native_sim <native_sim>` like this:

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

Download and run a TFTP server (like TFTPd), then create file1.bin (with data) and newfile.bin.

Please note that default IP server address is 192.0.2.2 and default port is 69.
To specify an IP server address and/or port, change these configurations in ``prj.conf``:

.. code-block:: cfg

    CONFIG_TFTP_APP_SERVER="10.0.0.10"
    CONFIG_TFTP_APP_PORT="70"

To connect to server using hostname, enable DNS resolver by changing these two
configurations in ``prj.conf``:

.. code-block:: cfg

    CONFIG_DNS_RESOLVER=y
    CONFIG_TFTP_APP_SERVER="my-tftp-server.org"

Sample output
==================================

This sample can be run on :ref:`native_sim<native_sim>` while running a TFTP server on the host
machine.

Launch :command:`net-setup.sh` in net-tools:

.. code-block:: bash

   net-setup.sh

.. code-block:: bash

    <inf> net_config: Initializing network
    <inf> net_config: IPv4 address: 192.0.2.1
    <inf> net_tftp_client_app: Run TFTP client
    <inf> net_tftp_client_app: Received data:
            74 65 73 74 74 66 74 70  66 6f 72 7a 65 70 68 79 |testtftp forzephy
            72 0a                                            |r.
    <inf> net_tftp_client_app: TFTP client get done
    <inf> net_tftp_client_app: TFTP client put done

Part 3

한국어 전문 번역

개요

TFTP(Trivial File Transfer Protocol)는 UDP 기반의 간단한 lockstep File Transfer Protocol로, remote host에서 file을 가져오거나 remote host에 file을 올리도록 설계되었습니다.

Zephyr의 이 TFTP client sample application은 TFTP client library를 구현하고 standard port 69의 TFTP server에 connection을 수립해 file GET과 PUT을 수행합니다.

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

요구 사항

빌드 및 실행

samples/net/tftp_client directory에는 여러 setup용 configuration file이 있습니다.

  • prj.conf: Standard default configuration입니다.

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

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

가장 간단한 설정 방법은 default prj.conf를 사용해 native_sim application 또는 QEMU target으로 build하고 실행하는 것입니다. 필요한 설정은 위의 QEMU Ethernet, QEMU와 native_sim networking 문서에 설명되어 있습니다.

native_sim용 TFTP client sample application은 다음과 같이 build하고 실행합니다.

west build -b native_sim samples/net/tftp_client
west build -t run

TFTPd 같은 TFTP server를 내려받아 실행한 뒤 data가 있는 file1.bin과 newfile.bin을 만듭니다.

Default server IP address는 192.0.2.2이고 default port는 69입니다. Server IP address 또는 port를 지정하려면 prj.conf에서 다음 configuration을 바꿉니다.

CONFIG_TFTP_APP_SERVER="10.0.0.10"
CONFIG_TFTP_APP_PORT="70"

Hostname으로 server에 연결하려면 prj.conf에서 다음 두 configuration을 바꾸어 DNS resolver를 활성화합니다.

CONFIG_DNS_RESOLVER=y
CONFIG_TFTP_APP_SERVER="my-tftp-server.org"

Sample 출력

Host machine에서 TFTP server를 실행하면서 이 sample을 native_sim에서 실행할 수 있습니다.

net-tools에서 net-setup.sh를 시작합니다. 이어지는 공식 출력은 수신 data의 hex dump와 GET·PUT 완료 상태를 보여 줍니다.

net-setup.sh
<inf> net_config: Initializing network
<inf> net_config: IPv4 address: 192.0.2.1
<inf> net_tftp_client_app: Run TFTP client
<inf> net_tftp_client_app: Received data:
        74 65 73 74 74 66 74 70  66 6f 72 7a 65 70 68 79 |testtftp forzephy
        72 0a                                            |r.
<inf> net_tftp_client_app: TFTP client get done
<inf> net_tftp_client_app: TFTP client put done

Source

출처

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