<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Maximum NUS packet payload with BLE data length extension.</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/111900/maximum-nus-packet-payload-with-ble-data-length-extension</link><description>Hi! 
 I am confused regarding NUS, L2CAP, ATT and GATT. 
 We are using NUS with data length extension to communicate between two nRF52840 boards and want to maximize packet size to increase transfer efficiency. Question is what is the maximum payload</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 10 Jun 2024 07:52:56 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/111900/maximum-nus-packet-payload-with-ble-data-length-extension" /><item><title>RE: Maximum NUS packet payload with BLE data length extension.</title><link>https://devzone.nordicsemi.com/thread/488034?ContentTypeID=1</link><pubDate>Mon, 10 Jun 2024 07:52:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:24f9c7dd-1b33-4e78-bb76-3ff69c68f568</guid><dc:creator>Hieu</dc:creator><description>&lt;p&gt;Regarding Massage Integrity Check bits, please refer to&amp;nbsp;&lt;span&gt;Vol 6, Part B, 2.4, Data Channel PDU:&lt;/span&gt;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&lt;em&gt;The MIC field shall not be included in an un-encrypted Link Layer connection,&lt;br /&gt;or in an encrypted Link Layer connection with a data channel PDU with a zero&lt;br /&gt;length Payload.&lt;br /&gt;The MIC field shall be included in an encrypted Link Layer connection, with a&lt;br /&gt;data channel PDU with a non-zero length Payload and shall be calculated as&lt;br /&gt;specified in [Vol. 6] Part E, Section 1.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;The 4 bytes is only taken in an encrypted link.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Maximum NUS packet payload with BLE data length extension.</title><link>https://devzone.nordicsemi.com/thread/487969?ContentTypeID=1</link><pubDate>Fri, 07 Jun 2024 19:41:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e3715344-1e39-40fa-ae7c-bfea22cf7398</guid><dc:creator>kat829</dc:creator><description>&lt;p&gt;I see. &lt;/p&gt;
&lt;p&gt;The remaining 4 bytes that are not accounted for in the calculation are message integrity check I assume.&lt;/p&gt;
&lt;p&gt;- &amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/12211/ble-packet-structure"&gt;https://devzone.nordicsemi.com/f/nordic-q-a/12211/ble-packet-structure&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;- &lt;a href="https://i0.wp.com/embeddedcentric.com/wp-content/uploads/2019/03/BLE-Packets-Types.png?ssl=1"&gt;https://i0.wp.com/embeddedcentric.com/wp-content/uploads/2019/03/BLE-Packets-Types.png?ssl=1&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Thanks!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Maximum NUS packet payload with BLE data length extension.</title><link>https://devzone.nordicsemi.com/thread/487964?ContentTypeID=1</link><pubDate>Fri, 07 Jun 2024 18:50:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a12a89f3-b4e7-4123-afdd-cda71d9e8600</guid><dc:creator>Hieu</dc:creator><description>&lt;p&gt;Hi kat829,&lt;/p&gt;
&lt;p&gt;You are going into details here, and it is a little difficult to keep things simplified, but I will try.&lt;/p&gt;
[quote user=""]- BLE specification limits payload to 251[/quote]
&lt;p&gt;In the context where you want the BLE packet to not get fragmented, yes.&lt;/p&gt;
&lt;p&gt;The Bluetooth Spec v4.2 limit a Link Layer packet to&amp;nbsp;just 257 byte of payload.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Subtracting mandatory 2 bytes of Link Layer headers, we are left with maximum 255 bytes for the entire L2CAP packet.&lt;/p&gt;
&lt;p&gt;Subtracting 4 bytes of L2CAP headers, we are left with 251 bytes for the L2CAP payload. &lt;br /&gt;However, that is 251 bytes of L2CAP payload per &lt;em&gt;&lt;strong&gt;one&lt;/strong&gt;&lt;/em&gt; Link Layer packet, because one L2CAP can be segmented&amp;nbsp;and carried by multiple Link Layer packets.&lt;/p&gt;
[quote user=""]&lt;ul&gt;&lt;li&gt;- GPT claims that NUS-handled data are always enclosed in a L2CAP packet, thus adding 4 byte header and reducing effective payload to 247&lt;/li&gt;
&lt;li&gt;- NUS operates within GATT, but that is supposed to somehow not eat up any more data of the packet&lt;/li&gt;&lt;/ul&gt;[/quote]
&lt;p&gt;GATT does eat up more data. The ATT (no typo, GATT is based on ATT)&amp;nbsp;does eat up at least 3 more bytes, leaving you with only 244.&lt;/p&gt;
&lt;p&gt;This is true for Write, Notify, Read. Some other ATT operations&amp;nbsp;require more bytes.&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;At the end of all this, you need to remember that the&amp;nbsp;packet data length is negotiated between the Central and Peripheral devices. &lt;br /&gt;The Central is the&amp;nbsp;one ultimately decide the data length, and it might be lower, making&amp;nbsp;a NUS transmission of 244 bytes still fragmented.&amp;nbsp;&lt;br /&gt;Having said that,&amp;nbsp;in most real cases, the maximum discussed above can be achieved; but please keep this fact in mind.&lt;br /&gt;If keeping the packet not fragmented is an absolute concern, you can adapt&amp;nbsp;the&amp;nbsp;data size dynamically based on the negotiated data length.&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;For more details, refer to these sections of the Bluetooth Specification:&lt;/p&gt;
&lt;p&gt;Link Layer&lt;br /&gt;Vol 6, Part B, 2.1 Packet format for the LE Uncoded PHY&lt;br /&gt;Vol 6, Part B, 2.4.1 Data Physical Channel PDU&lt;/p&gt;
&lt;p&gt;L2CAP&lt;br /&gt;Vol 3, Part A, 3.1: Data packet format, Connection-oriented channels in Basic L2CAP mode&lt;/p&gt;
&lt;p&gt;ATT&lt;br /&gt;Vol 3, Part F, 3.3: Attribute PDU&lt;/p&gt;
&lt;p&gt;Hieu&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>