Part 1
요약·해설
6.7MB HTTP·6.6MB TLS target, archive server 사용 경고와 Zephyr 전용 TLS socket 제약을 보존합니다.
6.7MB · Repeat
SHA-256
HTTP · TLS · POSIX
Part 2
접을 수 있는 영어 원문 전체
영어 원문 전체 펼치기
6FFD33BBFF4AE1BCB11B7C3D2117272D0CC09D710DFA74AD3C4B8F0D74CBD2FA
.. zephyr:code-sample:: sockets-big-http-download
:name: Large HTTP download
:relevant-api: bsd_sockets tls_credentials
Download a large file from a web server using BSD sockets.
Overview
********
The sockets/big_http_download sample application for Zephyr implements
a simple HTTP GET client using a BSD Sockets compatible API. Unlike
the :zephyr:code-sample:`sockets-http-get` sample application, it downloads a file of
several megabytes in size, and verifies its integrity using hashing. It
also performs download repeatedly, tracking the total number of bytes
transferred. Thus, it can serve as a "load testing" application for
the Zephyr IP stack.
The source code for this sample application can be found at:
:zephyr_file:`samples/net/sockets/big_http_download`.
Requirements
************
- :ref:`networking_with_host`
- or, a board with hardware networking
- NAT/routing should be set up to allow connections to the Internet
- DNS server should be available on the host to resolve domain names
Building and Running
********************
Build the Zephyr version of the application like this:
.. zephyr-app-commands::
:zephyr-app: samples/net/sockets/big_http_download
:board: <board_to_use>
:goals: build
:compact:
After the sample starts, it issues an HTTP GET request for
http://archive.ubuntu.com/ubuntu/dists/xenial/main/installer-amd64/current/images/hd-media/vmlinuz
This site was selected as providing files of variety of sizes, together
with various hashes for them, to ease external selection and verification.
The particular file selected is 6.7MB in size, so it can show how reliably
Zephyr streams non-trivial amounts of data, while still taking a
reasonable amount of time to complete. While the file is downloaded, its
hash is computed (SHA-256 is used in the source code), and an error
message is printed if it differs from the reference value, as specified
in the source code. After a short pause, the process repeats (in an
infinite loop), while the total counter of the bytes received is kept.
Thus the application can be used to test transfers of much larger amounts
of traffic over a longer time.
You can edit the source code to issue a request to any other site on
the Internet (or on the local network, in which case no NAT/routing
setup is needed).
.. warning::
If you are doing extensive testing with this sample, please reference
a file on a local server or a special-purpose testing server of your own
on the Internet. Using files on archive.ubuntu.com is not recommended for
large-scale testing.
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/big_http_download
: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 TLS version of this sample downloads a file from
https://launchpad.net/ubuntu/+archive/primary/+sourcefiles/git/1:2.34.1-1ubuntu1/git_2.34.1.orig.tar.xz
(6.6MB). The certificates used by the sample are in the sample's ``src``
directory and are used to access the default website configured in the sample
for TLS communication (https://launchpad.net) and possible redirects. To access
a different web page over TLS, you'll need to provide a different certificate
to authenticate to that server.
Note, that TLS support in the sample depends on non-posix, TLS socket
functionality. Therefore, it is only possible to run TLS in this sample
on Zephyr.
Running application on POSIX Host
=================================
The same application source code can be built for a POSIX system, e.g.
Linux.
To build:
.. code-block:: console
$ make -f Makefile.host
To run:
.. code-block:: console
$ ./big_http_download
The behavior of the application is the same as the Zephyr version.
Part 3
한국어 전문 번역
개요
Zephyr의 sockets/big_http_download sample application은 BSD Sockets 호환 API를 사용하는 간단한 HTTP GET client를 구현합니다.
sockets-http-get sample과 달리 크기가 수 MB인 file을 내려받고 hashing으로 무결성을 검증합니다. Download를 반복하면서 전송한 전체 byte 수도 추적하므로 Zephyr IP stack의 load testing application으로 사용할 수 있습니다.
이 sample application의 source code는 samples/net/sockets/big_http_download에 있습니다.
요구 사항
- Host system과 networking 또는 hardware networking 기능이 있는 board
- Internet 연결을 허용하도록 구성한 NAT/routing
- Domain name을 resolve할 수 있도록 host에서 이용 가능한 DNS server
빌드 및 실행
Zephyr version application은 다음처럼 build합니다.
west build -b <board_to_use> samples/net/sockets/big_http_download
Sample이 시작되면 http://archive.ubuntu.com/ubuntu/dists/xenial/main/installer-amd64/current/images/hd-media/vmlinuz에 HTTP GET request를 보냅니다.
이 site는 여러 크기의 file과 각 hash를 함께 제공하므로 외부에서 download 대상을 선택하고 검증하기 쉽다는 이유로 사용했습니다. 선택한 file은 6.7MB이므로 Zephyr가 적지 않은 data를 얼마나 안정적으로 stream하는지 보여 주면서도 합리적인 시간 안에 완료됩니다.
File을 내려받는 동안 hash를 계산합니다. Source code는 SHA-256을 사용하며, 계산한 값이 source code에 지정된 reference value와 다르면 error message를 출력합니다.
짧게 쉰 뒤 같은 process를 infinite loop로 반복하며 수신한 전체 byte counter는 계속 유지합니다. 따라서 장시간에 걸쳐 훨씬 많은 traffic을 전송하는 시험으로 사용할 수 있습니다.
Source code를 수정하면 Internet의 다른 site나 local network의 site로 request를 보낼 수 있습니다. Local network를 사용하면 NAT/routing 설정이 필요하지 않습니다.
TLS 지원 활성화
overlay-tls.conf overlay file을 활성화해 project를 build하면 TLS 지원을 켤 수 있습니다. 예시는 다음과 같습니다.
west build -b qemu_x86 samples/net/sockets/big_http_download -- -DCONF_FILE="prj.conf overlay-tls.conf"
다른 방법으로 west build 또는 cmake를 실행할 때 -DEXTRA_CONF_FILE=overlay-tls.conf를 지정할 수 있습니다.
이 sample의 TLS version은 https://launchpad.net/ubuntu/+archive/primary/+sourcefiles/git/1:2.34.1-1ubuntu1/git_2.34.1.orig.tar.xz에서 6.6MB file을 내려받습니다.
Sample이 사용하는 certificate는 sample의 src directory에 있으며, TLS communication에 기본 설정된 https://launchpad.net과 redirect 대상에 접근할 때 사용합니다. TLS로 다른 web page에 접근하려면 그 server를 인증할 다른 certificate를 제공해야 합니다.
이 sample의 TLS 지원은 non-POSIX TLS socket 기능에 의존합니다. 따라서 이 sample에서 TLS는 Zephyr 위에서만 실행할 수 있습니다.
POSIX Host에서 application 실행
같은 application source code를 Linux 같은 POSIX system용으로 build할 수 있습니다.
Build 명령:
$ make -f Makefile.host
실행 명령:
$ ./big_http_download
Application 동작은 Zephyr version과 같습니다.
Source
출처
영어 원문에는 문단, 문서 지시문, 표, 코드, 코드 심벌, 경로를 그대로 보존했습니다.