samples/bluetooth/mtu_update/README.html · samples/bluetooth/mtu_update/README.rst 공식 원문 ↗

Zephyr 3.7.0 · Bluetooth · ATT/L2CAP

Bluetooth MTU Update

두 device의 MTU 중 작은 값을 사용하며 TX MTU와 RX buffer를 함께 맞춥니다.

Official pathsamples/bluetooth/mtu_update/README.html
Source filesamples/bluetooth/mtu_update/README.rst
Source versionZephyr 3.7.0
TranslationFull · reviewed

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

Part 1

요약·해설

CONFIG_BT_L2CAP_TX_MTU·CONFIG_BT_BUF_ACL_RX_SIZE와 EATT header 크기를 설명합니다.

ATT

Symmetric MTU

L2CAP header

4 octets

EATT overhead

6 octets

Part 2

접을 수 있는 영어 원문 전체

영어 원문 전체 펼치기
원문 SHA-256 1403247449B11AA57A98FA41CA9D991E7B69446FBCF4D804C15A1C21500A577A
.. _bluetooth_mtu_update_sample:

Bluetooth: MTU Update
#####################

Q&A:
****

  Question: What do I have to do to update my ATT MTU?

| Answer: To get an ATT MTU of x octets, do the following:
| Set :kconfig:option:`CONFIG_BT_L2CAP_TX_MTU` to at least x
| Set :kconfig:option:`CONFIG_BT_BUF_ACL_RX_SIZE` to at least x + L2CAP header
  size (4 octets).
| Set :kconfig:option:`CONFIG_BT_BUF_ACL_RX_SIZE` to at least x + L2CAP header +
  SDU length field length (6 octets) if using
  :kconfig:option:`CONFIG_BT_EATT`.
| Ensure the remote side supports the same MTUs.

  Question: I only want to *send* large packets. I don't need to receive large
  ones.
  Do I still need to set :kconfig:option:`CONFIG_BT_BUF_ACL_RX_SIZE`?

Answer: Yes. [#mtu_exchange]_ The Bluetooth specification mandates a symmetric MTU for ATT.

Overview:
*********

This sample demonstrates the exchange of MTU between two devices to allow a
large notification to be sent.
Updating the MTU can be useful to send bigger packets and so have a better
throughput.

To be able to send a large notification both the server and the client need to
update their MTU. The MTU is not a negotiated value, the client and the server
will exchange their MTUs and choose the minimum of the two. Thus the two MTU can
be set to a different value, but the MTU of the server must be greater or equal
to the MTU of the client.

According to the Bluetooth specification, [#mtu]_ MTU is the maximum size of
SDUs.
However, in Zephyr, we can assume that it also represents the maximum size of
the PDUs. Because, in Bluetooth LE, [#sud_encapsulation]_ unless we are using L2CAP dynamic
channels, SDUs are not segmented.
The Kconfig symbol used to configure the size of the TX MTU is
:kconfig:option:`CONFIG_BT_L2CAP_TX_MTU`. There is no Kconfig symbol to update
the size of the RX MTU, because Zephyr uses a buffer pool for ACL RX buffers
coming from the controller.
The L2CAP RX MTU is defined as the maximum size of ACL RX buffers minus the
L2CAP header size.
That maximum ACL RX buffer size is configured with
:kconfig:option:`CONFIG_BT_BUF_ACL_RX_SIZE`.
The resulting L2CAP RX MTU will be the value of this Kconfig symbol minus the
L2CAP header size.

.. figure:: ../../../../../../samples/bluetooth/mtu_update/img/mtu.svg
     :align: center
     :alt: Diagram of the MTUs and their corresponding Kconfig symbols

     Diagram of the MTUs and their corresponding Kconfig symbols

Hardware Setup
**************

This sample use two applications, two devices need to be setup.
The first one should be flashed with the central and the second one with the
peripheral.

The two devices will connect only if they are close to each other, because of
RSSI filtering.

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

This sample can be found under :zephyr_file:`samples/bluetooth/mtu_update` in
the Zephyr tree.

See :ref:`bluetooth samples section <bluetooth-samples>` for details.

If the devices are close enough, the central should connect to the peripheral
and send his MTU to the other device. If the MTU exchange succeeds, the central
should subscribe and then the peripheral will send a large notification. Right
after receiving the notification the central should unsubscribe.

Here are the outputs you should have on the devices:

Central:

.. code-block:: console

  *** Booting Zephyr OS build zephyr-v3.2.0-2251-g95d8943c69ce ***
  Bluetooth initialized
  Scanning successfully started
  Device found: EB:BF:36:26:42:09 (random) (RSSI -34)
  Connected: EB:BF:36:26:42:09 (random)
  mtu_exchange: Current MTU = 23
  mtu_exchange: Exchange MTU...
  mtu_exchange_cb: MTU exchange successful (247)
  [ATTRIBUTE] handle 16
  [ATTRIBUTE] handle 17
  [ATTRIBUTE] handle 19
  [SUBSCRIBED]
  [NOTIFICATION] data 0x20004b73 length 100
  [UNSUBSCRIBED]

Peripheral:

.. code-block:: console

  *** Booting Zephyr OS build zephyr-v3.2.0-2251-g95d8943c69ce ***
  Updated MTU: TX: 23 RX: 23 bytes
  Updated MTU: TX: 247 RX: 247 bytes
  MTU Test Update: notifications enabled
  MTU Test Update: notifications disabled

References
**********

.. [#mtu_exchange] Bluetooth Core Specification v. 5.3: Vol. 3, Part F, 3.4.2
.. [#mtu] Bluetooth Core Specification v. 5.3: Vol. 3, Part A, 5.1
.. [#sud_encapsulation] Bluetooth Core Specification v. 5.3: Vol. 3, Part A, 7.3

Part 3

한국어 전문 번역

질문과 답변

질문: ATT MTU를 갱신하려면 무엇을 해야 합니까?

답변: ATT MTU를 x octet으로 만들려면 다음 조건을 충족해야 합니다.

  • CONFIG_BT_L2CAP_TX_MTU를 최소 x로 설정합니다.
  • CONFIG_BT_BUF_ACL_RX_SIZE를 최소 x + L2CAP header 크기인 4 octet으로 설정합니다.
  • CONFIG_BT_EATT를 사용한다면 CONFIG_BT_BUF_ACL_RX_SIZE를 최소 x + L2CAP header + SDU length field 크기인 6 octet으로 설정합니다.
  • Remote side가 같은 MTU를 지원하는지 확인합니다.

질문: 큰 packet을 보내기만 하고 받을 필요는 없습니다. 그래도 CONFIG_BT_BUF_ACL_RX_SIZE를 설정해야 합니까?

답변: 그렇습니다. Bluetooth specification은 ATT MTU가 대칭이어야 한다고 규정합니다.

개요

두 device가 MTU를 교환하여 큰 notification을 보낼 수 있게 하는 sample입니다. MTU를 키우면 더 큰 packet을 보내 throughput을 높일 수 있습니다.

큰 notification을 보내려면 Server와 Client가 모두 자신의 MTU를 갱신해야 합니다. MTU는 협상해 하나의 값을 만드는 값이 아닙니다. Client와 Server가 각자의 MTU를 교환한 뒤 두 값 중 작은 값을 선택합니다. 두 MTU를 서로 다르게 설정할 수 있지만 Server의 MTU는 Client의 MTU보다 크거나 같아야 합니다.

Bluetooth specification에서 MTU는 SDU의 최대 크기입니다. 다만 Zephyr에서는 MTU가 PDU의 최대 크기도 나타낸다고 볼 수 있습니다. Bluetooth LE에서는 L2CAP dynamic channel을 사용하지 않는 한 SDU를 segmentation하지 않기 때문입니다.

TX MTU 크기는 CONFIG_BT_L2CAP_TX_MTU로 설정합니다. RX MTU 크기를 직접 바꾸는 Kconfig symbol은 없습니다. Zephyr가 Controller에서 오는 ACL RX buffer에 buffer pool을 사용하기 때문입니다.

L2CAP RX MTU는 최대 ACL RX buffer 크기에서 L2CAP header 크기를 뺀 값입니다. 최대 ACL RX buffer 크기는 CONFIG_BT_BUF_ACL_RX_SIZE로 설정하므로, 최종 L2CAP RX MTU는 이 Kconfig 값에서 L2CAP header 크기를 뺀 값입니다.

MTU와 대응 Kconfig symbol 관계도
MTU와 각 MTU에 대응하는 Kconfig symbol. Zephyr 3.7.0 공식 도식.

Hardware 구성

이 sample은 두 application을 사용하므로 device 두 대가 필요합니다. 첫 번째 device에는 Central을, 두 번째 device에는 Peripheral을 flash합니다.

RSSI filtering을 사용하므로 두 device가 서로 가까이 있을 때만 연결됩니다.

Build와 실행

이 sample은 Zephyr tree의 samples/bluetooth/mtu_update에 있습니다. 자세한 공통 절차는 Bluetooth sample section을 참조하십시오.

Device가 충분히 가까우면 Central이 Peripheral에 연결해 자신의 MTU를 보냅니다. MTU 교환이 성공하면 Central이 subscribe하고 Peripheral이 큰 notification을 보냅니다. Central은 notification을 받은 직후 unsubscribe합니다.

Central에서 예상되는 출력은 다음과 같습니다.

*** Booting Zephyr OS build zephyr-v3.2.0-2251-g95d8943c69ce ***
Bluetooth initialized
Scanning successfully started
Device found: EB:BF:36:26:42:09 (random) (RSSI -34)
Connected: EB:BF:36:26:42:09 (random)
mtu_exchange: Current MTU = 23
mtu_exchange: Exchange MTU...
mtu_exchange_cb: MTU exchange successful (247)
[ATTRIBUTE] handle 16
[ATTRIBUTE] handle 17
[ATTRIBUTE] handle 19
[SUBSCRIBED]
[NOTIFICATION] data 0x20004b73 length 100
[UNSUBSCRIBED]

Peripheral에서 예상되는 출력은 다음과 같습니다.

*** Booting Zephyr OS build zephyr-v3.2.0-2251-g95d8943c69ce ***
Updated MTU: TX: 23 RX: 23 bytes
Updated MTU: TX: 247 RX: 247 bytes
MTU Test Update: notifications enabled
MTU Test Update: notifications disabled

참고 문헌

  1. Bluetooth Core Specification v5.3, Vol. 3, Part F, 3.4.2: ATT MTU exchange와 대칭 MTU.
  2. Bluetooth Core Specification v5.3, Vol. 3, Part A, 5.1: MTU와 SDU 최대 크기.
  3. Bluetooth Core Specification v5.3, Vol. 3, Part A, 7.3: SDU encapsulation과 segmentation.

Source

출처

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