Part 1
요약·해설
BLOB을 block과 chunk로 나누고 Push·Pull mode와 stream callback으로 전송하는 전체 protocol을 설명합니다.
4 GB
Up to 1 kbps
Push · Pull
Client · Server
Part 2
접을 수 있는 영어 원문 전체
영어 원문 전체 펼치기
072E71FAF4647BFCE52B78A8D70283612929B501BA61DCC1E0E875C4699B8EBA
.. _bluetooth_mesh_blob:
BLOB Transfer models
####################
The Binary Large Object (BLOB) Transfer models implement the Bluetooth Mesh Binary Large Object
Transfer Model specification version 1.0 and provide functionality for sending large binary objects
from a single source to many Target nodes over the Bluetooth Mesh network. It is the underlying
transport method for the :ref:`bluetooth_mesh_dfu`, but may be used for other object transfer
purposes. The implementation is in experimental state.
The BLOB Transfer models support transfers of continuous binary objects of up to 4 GB (2 \ :sup:`32`
bytes). The BLOB transfer protocol has built-in recovery procedures for packet losses, and sets up
checkpoints to ensure that all targets have received all the data before moving on. Data transfer
order is not guaranteed.
BLOB transfers are constrained by the transfer speed and reliability of the underlying mesh network.
Under ideal conditions, the BLOBs can be transferred at a rate of up to 1 kbps, allowing a 100 kB
BLOB to be transferred in 10-15 minutes. However, network conditions, transfer capabilities and
other limiting factors can easily degrade the data rate by several orders of magnitude. Tuning the
parameters of the transfer according to the application and network configuration, as well as
scheduling it to periods with low network traffic, will offer significant improvements on the speed
and reliability of the protocol. However, achieving transfer rates close to the ideal rate is
unlikely in actual deployments.
There are two BLOB Transfer models:
.. toctree::
:maxdepth: 1
blob_srv
blob_cli
The BLOB Transfer Client is instantiated on the sender node, and the BLOB Transfer Server is
instantiated on the receiver nodes.
Concepts
********
The BLOB transfer protocol introduces several new concepts to implement the BLOB transfer.
BLOBs
=====
BLOBs are binary objects up to 4 GB in size, that can contain any data the application would like to
transfer through the mesh network. The BLOBs are continuous data objects, divided into blocks and
chunks to make the transfers reliable and easy to process. No limitations are put on the contents or
structure of the BLOB, and applications are free to define any encoding or compression they'd like
on the data itself.
The BLOB transfer protocol does not provide any built-in integrity checks, encryption or
authentication of the BLOB data. However, the underlying encryption of the Bluetooth Mesh protocol
provides data integrity checks and protects the contents of the BLOB from third parties using
network and application level encryption.
Blocks
------
The binary objects are divided into blocks, typically from a few hundred to several thousand bytes
in size. Each block is transmitted separately, and the BLOB Transfer Client ensures that all BLOB
Transfer Servers have received the full block before moving on to the next. The block size is
determined by the transfer's ``block_size_log`` parameter, and is the same for all blocks in the
transfer except the last, which may be smaller. For a BLOB stored in flash memory, the block size is
typically a multiple of the flash page size of the Target devices.
Chunks
------
Each block is divided into chunks. A chunk is the smallest data unit in the BLOB transfer, and must
fit inside a single Bluetooth Mesh access message excluding the opcode (379 bytes or less). The
mechanism for transferring chunks depends on the transfer mode.
When operating in Push BLOB Transfer Mode, the chunks are sent as unacknowledged packets from the
BLOB Transfer Client to all targeted BLOB Transfer Servers. Once all chunks in a block have been
sent, the BLOB Transfer Client asks each BLOB Transfer Server if they're missing any chunks, and
resends them. This is repeated until all BLOB Transfer Servers have received all chunks, or the BLOB
Transfer Client gives up.
When operating in Pull BLOB Transfer Mode, the BLOB Transfer Server will request a small number of
chunks from the BLOB Transfer Client at a time, and wait for the BLOB Transfer Client to send them
before requesting more chunks. This repeats until all chunks have been transferred, or the BLOB
Transfer Server gives up.
Read more about the transfer modes in :ref:`bluetooth_mesh_blob_transfer_modes` section.
.. _bluetooth_mesh_blob_stream:
BLOB streams
============
In the BLOB Transfer models' APIs, the BLOB data handling is separated from the high-level transfer
handling. This split allows reuse of different BLOB storage and transfer strategies for different
applications. While the high level transfer is controlled directly by the application, the BLOB data
itself is accessed through a *BLOB stream*.
The BLOB stream is comparable to a standard library file stream. Through opening, closing, reading
and writing, the BLOB Transfer model gets full access to the BLOB data, whether it's kept in flash,
RAM, or on a peripheral. The BLOB stream is opened with an access mode (read or write) before it's
used, and the BLOB Transfer models will move around inside the BLOB's data in blocks and chunks,
using the BLOB stream as an interface.
Interaction
-----------
Before the BLOB is read or written, the stream is opened by calling its
:c:member:`open <bt_mesh_blob_io.open>` callback. When used with a BLOB Transfer Server, the BLOB
stream is always opened in write mode, and when used with a BLOB Transfer Client, it's always opened
in read mode.
For each block in the BLOB, the BLOB Transfer model starts by calling
:c:member:`block_start <bt_mesh_blob_io.block_start>`. Then, depending on the access mode, the BLOB
stream's :c:member:`wr <bt_mesh_blob_io.wr>` or :c:member:`rd <bt_mesh_blob_io.rd>` callback is
called repeatedly to move data to or from the BLOB. When the model is done processing the block, it
calls :c:member:`block_end <bt_mesh_blob_io.block_end>`. When the transfer is complete, the BLOB
stream is closed by calling :c:member:`close <bt_mesh_blob_io.close>`.
Implementations
---------------
The application may implement their own BLOB stream, or use the implementations provided by Zephyr:
.. toctree::
:maxdepth: 2
blob_flash
Transfer capabilities
=====================
Each BLOB Transfer Server may have different transfer capabilities. The transfer capabilities of
each device are controlled through the following configuration options:
* :kconfig:option:`CONFIG_BT_MESH_BLOB_SIZE_MAX`
* :kconfig:option:`CONFIG_BT_MESH_BLOB_BLOCK_SIZE_MIN`
* :kconfig:option:`CONFIG_BT_MESH_BLOB_BLOCK_SIZE_MAX`
* :kconfig:option:`CONFIG_BT_MESH_BLOB_CHUNK_COUNT_MAX`
The :kconfig:option:`CONFIG_BT_MESH_BLOB_CHUNK_COUNT_MAX` option is also used by the BLOB Transfer
Client and affects memory consumption by the BLOB Transfer Client model structure.
To ensure that the transfer can be received by as many servers as possible, the BLOB Transfer Client
can retrieve the capabilities of each BLOB Transfer Server before starting the transfer. The client
will transfer the BLOB with the highest possible block and chunk size.
.. _bluetooth_mesh_blob_transfer_modes:
Transfer modes
==============
BLOBs can be transferred using two transfer modes, Push BLOB Transfer Mode and Pull BLOB Transfer
Mode. In most cases, the transfer should be conducted in Push BLOB Transfer Mode.
In Push BLOB Transfer Mode, the send rate is controlled by the BLOB Transfer Client, which will push
all the chunks of each block without any high level flow control. Push BLOB Transfer Mode supports
any number of Target nodes, and should be the default transfer mode.
In Pull BLOB Transfer Mode, the BLOB Transfer Server will "pull" the chunks from the BLOB Transfer
Client at its own rate. Pull BLOB Transfer Mode can be conducted with multiple Target nodes, and is
intended for transferring BLOBs to Target nodes acting as :ref:`bluetooth_mesh_lpn`. When operating
in Pull BLOB Transfer Mode, the BLOB Transfer Server will request chunks from the BLOB Transfer
Client in small batches, and wait for them all to arrive before requesting more chunks. This process
is repeated until the BLOB Transfer Server has received all chunks in a block. Then, the BLOB
Transfer Client starts the next block, and the BLOB Transfer Server requests all chunks of that
block.
.. _bluetooth_mesh_blob_timeout:
Transfer timeout
================
The timeout of the BLOB transfer is based on a Timeout Base value. Both client and server use the
same Timeout Base value, but they calculate timeout differently.
The BLOB Transfer Server uses the following formula to calculate the BLOB transfer timeout::
10 * (Timeout Base + 1) seconds
For the BLOB Transfer Client, the following formula is used::
(10000 * (Timeout Base + 2)) + (100 * TTL) milliseconds
where TTL is time to live value set in the transfer.
API reference
*************
This section contains types and defines common to the BLOB Transfer models.
.. doxygengroup:: bt_mesh_blob
:project: Zephyr
:members:
Part 3
한국어 전문 번역
BLOB Transfer model
Binary Large Object(BLOB) Transfer model은 Bluetooth Mesh Binary Large Object Transfer Model specification 1.0을 구현합니다. 하나의 source에서 여러 Target node로 큰 binary object를 보내는 기능이며, Bluetooth Mesh DFU의 기반 transport로 쓰이지만 다른 object 전송에도 사용할 수 있습니다. Zephyr 3.7.0에서 이 구현은 experimental 상태입니다.
연속된 binary object를 최대 4 GB, 즉 232 byte까지 전송할 수 있습니다. Packet loss를 복구하는 절차와 모든 Target이 data를 받았는지 확인하는 checkpoint가 protocol에 들어 있지만 data가 도착하는 순서는 보장하지 않습니다.
속도와 신뢰성
실제 성능은 하부 mesh network의 속도와 신뢰성에 제한됩니다. 이상적인 조건에서는 최대 약 1 kbps로, 100 kB BLOB을 10~15분에 전송할 수 있습니다. 그러나 network 상태, 각 node의 transfer capability와 다른 제약 때문에 data rate가 여러 자릿수만큼 낮아질 수 있습니다.
Application과 network 구성에 맞게 parameter를 조정하고 traffic이 적은 시간에 전송하면 속도와 신뢰성을 크게 개선할 수 있습니다. 그래도 실제 deployment에서 이상적인 전송률에 근접하기는 어렵습니다.
두 model
- BLOB Transfer Client: 송신 node에 instance화합니다.
- BLOB Transfer Server: 수신 node마다 instance화합니다.
개념
BLOB
BLOB은 application이 mesh network를 통해 보내려는 임의 data를 담을 수 있는 최대 4 GB의 binary object입니다. 연속된 data object를 block과 chunk로 나누어 신뢰성 있게 전송하고 처리합니다. BLOB 내부 content나 구조에는 제한이 없으므로 application이 encoding과 compression을 자유롭게 정의할 수 있습니다.
BLOB transfer protocol 자체에는 BLOB data를 위한 integrity check, encryption 또는 authentication이 없습니다. 다만 하부 Bluetooth Mesh protocol의 network·application level encryption이 data integrity를 확인하고 제3자로부터 BLOB content를 보호합니다.
Block
Binary object는 보통 수백~수천 byte 크기의 block으로 나뉩니다. 각 block을 별도로 보내며 Client는 모든 Server가 block 전체를 받았는지 확인한 뒤 다음 block으로 이동합니다. Block size는 transfer의 block_size_log parameter로 결정하고 마지막 block만 더 작을 수 있습니다. Flash에 저장하는 BLOB은 보통 Target flash page size의 배수로 block size를 정합니다.
Chunk
각 block은 다시 chunk로 나뉩니다. Chunk는 BLOB transfer의 최소 data 단위이며 opcode를 제외한 Bluetooth Mesh access message 하나에 들어가야 하므로 379 byte 이하여야 합니다. Chunk를 전달하는 방식은 transfer mode에 따라 달라집니다.
Push mode
Client가 모든 Target Server에 chunk를 acknowledgment 없는 packet으로 보냅니다. 한 block의 모든 chunk를 보낸 뒤 각 Server에 누락 chunk를 묻고 누락분을 재전송합니다. 모든 Server가 모든 chunk를 받거나 Client가 포기할 때까지 반복합니다.
Pull mode
Server가 한 번에 소량의 chunk를 Client에 요청하고 Client가 전부 보낼 때까지 기다린 뒤 다음 묶음을 요청합니다. 모든 chunk가 전송되거나 Server가 포기할 때까지 반복합니다.
BLOB stream
BLOB Transfer API는 BLOB data 처리와 고수준 transfer 제어를 분리합니다. 이 구조 덕분에 application별로 flash, RAM 또는 peripheral에 맞는 storage·transfer 전략을 재사용할 수 있습니다. Application이 고수준 transfer를 직접 제어하고 실제 BLOB data는 BLOB stream을 통해 접근합니다.
BLOB stream은 표준 library file stream과 비슷합니다. Open, close, read, write operation으로 BLOB data가 어디에 있든 model이 접근합니다. 사용 전에 read 또는 write access mode로 열고, model은 stream interface를 통해 BLOB 내부를 block과 chunk 단위로 이동합니다.
상호작용 순서
- BLOB을 읽거나 쓰기 전에
bt_mesh_blob_io.opencallback을 호출합니다. Server에서는 항상 write mode, Client에서는 항상 read mode입니다. - 각 block 시작 시
bt_mesh_blob_io.block_start를 호출합니다. - Access mode에 따라
bt_mesh_blob_io.wr또는bt_mesh_blob_io.rd를 반복 호출해 data를 이동합니다. - Block 처리가 끝나면
bt_mesh_blob_io.block_end를 호출합니다. - 전체 transfer가 끝나면
bt_mesh_blob_io.close를 호출합니다.
Application이 BLOB stream을 직접 구현하거나 Zephyr가 제공하는 BLOB Flash 구현을 사용할 수 있습니다.
Transfer capability
Server마다 지원하는 transfer capability가 다를 수 있습니다. 다음 configuration option으로 device별 한계를 정합니다.
CONFIG_BT_MESH_BLOB_SIZE_MAXCONFIG_BT_MESH_BLOB_BLOCK_SIZE_MINCONFIG_BT_MESH_BLOB_BLOCK_SIZE_MAXCONFIG_BT_MESH_BLOB_CHUNK_COUNT_MAX
CONFIG_BT_MESH_BLOB_CHUNK_COUNT_MAX는 Client에서도 사용하며 Client model structure의 memory consumption에 영향을 줍니다. Client는 transfer 전에 각 Server의 capability를 조회해 가능한 한 많은 Server가 참여하도록 하고, 모든 참여 Server가 수용하는 범위에서 가장 큰 block과 chunk size를 사용합니다.
Transfer mode
BLOB은 Push와 Pull 두 mode로 전송합니다. 대부분의 경우 Push mode를 사용해야 합니다.
Push BLOB Transfer Mode
Client가 send rate를 제어하고 고수준 flow control 없이 각 block의 모든 chunk를 밀어 넣습니다. Target node 수에 제한이 없으며 기본 transfer mode로 적합합니다.
Pull BLOB Transfer Mode
Server가 자신의 속도에 맞춰 Client에서 chunk를 끌어옵니다. 여러 Target과 함께 사용할 수 있으며 특히 Low Power Node(LPN)로 동작하는 Target에 BLOB을 보낼 때 사용합니다. Server는 작은 batch로 chunk를 요청하고 모두 받을 때까지 기다립니다. Block 전체를 받은 뒤 Client가 다음 block을 시작하면 같은 절차를 반복합니다.
Transfer timeout
Timeout은 Timeout Base 값을 기준으로 합니다. Client와 Server가 같은 값을 사용하지만 계산식은 다릅니다.
Server
10 * (Timeout Base + 1) secondsClient
(10000 * (Timeout Base + 2)) + (100 * TTL) milliseconds여기서 TTL은 transfer에 설정한 time to live 값입니다.
API Reference
공식 bt_mesh_blob Doxygen group이 두 BLOB Transfer model이 공유하는 type과 define을 생성합니다.
Source
출처
영어 원문에는 문단, 문서 지시문, 표, 코드, 코드 심벌, 경로를 그대로 보존했습니다.