<?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>BLE data relay latency issues</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/107661/ble-data-relay-latency-issues</link><description>Hello, 
 I am in the process of writing my bachelors thesis about using BLE to relay data over multiple hops. 
 In my test setup, I have 5 nrf52840 that connect to each other and form a linear &amp;quot;network&amp;quot;. I can then send data to the first relay and it</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 26 Jan 2024 09:09:34 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/107661/ble-data-relay-latency-issues" /><item><title>RE: BLE data relay latency issues</title><link>https://devzone.nordicsemi.com/thread/466167?ContentTypeID=1</link><pubDate>Fri, 26 Jan 2024 09:09:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bbec813f-b85a-489e-bf0a-6603ecaac966</guid><dc:creator>jonas.woerner</dc:creator><description>&lt;p&gt;thanks for the reply. I was already using DLE and was wondering why it wasnt sending large packets. turns out I just forgot to set the ACL TX BUF size higher then 27 bytes, now its sending 251 bytes. I will now test if that fixed my latency issues, and if not I will go out into the woods with my laptop and test there&lt;span class="emoticon" data-url="https://devzone.nordicsemi.com/cfs-file/__key/system/emoji/1f605.svg" title="Sweat smile"&gt;&amp;#x1f605;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE data relay latency issues</title><link>https://devzone.nordicsemi.com/thread/466164?ContentTypeID=1</link><pubDate>Fri, 26 Jan 2024 08:56:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a15b02ba-0228-44ae-9bb2-81e8944a44a0</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I see that there is a lot of retransmissions. The most typical reason is noise or intererence, or low signal strength. But it could also be caused by other factors, like inaccurate or low frequency clocks on the devices (or misconfiguration, where you indicate that the clocks are more accurate than they are, so that the listening time (window widening) is not long enough.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Regardign fragmentation I see you send short (normal) packets with a 27 byte payload. To send longer packets you need to use data length extension. You can refer to &lt;a href="https://academy.nordicsemi.com/courses/bluetooth-low-energy-fundamentals/lessons/lesson-3-bluetooth-le-connections/topic/blefund-lesson-3-exercise-2/"&gt;exersize 2 from lesson 3&lt;/a&gt; in the&amp;nbsp;Bluetooth Low Energy Fundamentals for seeing how to do that (essentailly calling bt_conn_le_data_len_update()).&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE data relay latency issues</title><link>https://devzone.nordicsemi.com/thread/466103?ContentTypeID=1</link><pubDate>Thu, 25 Jan 2024 17:37:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d3aac1b0-efee-477f-9287-379354afb619</guid><dc:creator>jonas.woerner</dc:creator><description>&lt;p&gt;I managed to log another long delay and capture it with wireshark at the same time:&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1706204196372v1.png" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1706204203031v2.png" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;CONFIG_BT_PERIPHERAL_PREF_MIN_INT=90

CONFIG_BT_PERIPHERAL_PREF_MAX_INT=90 
CONFIG_BT_PERIPHERAL_PREF_LATENCY=0
CONFIG_BT_CTLR_DATA_LENGTH_MAX=251

CONFIG_BT_PERIPHERAL_PREF_TIMEOUT=500
CONFIG_BT_L2CAP_TX_MTU=1024
#mtu+4
CONFIG_BT_BUF_ACL_RX_SIZE=1028&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;can you spot anything abnormal? to me this still looks like Interference... but again, Im not a pro at this.&lt;/p&gt;
&lt;p&gt;also, why are there so many small fragments? I put 1Kb of data into the Zephyr write function and have set the data length max to 251, so why are there such small packets?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE data relay latency issues</title><link>https://devzone.nordicsemi.com/thread/466101?ContentTypeID=1</link><pubDate>Thu, 25 Jan 2024 17:05:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ba756948-f390-47b9-b409-9dfb1044cf60</guid><dc:creator>jonas.woerner</dc:creator><description>&lt;p&gt;I have done some furhter research, and I now know that the big delay comes from the delay between calling bt_gatt_write_without_response_cb and the successful transmission of the data.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;[00:05:30.102,783] &amp;lt;inf&amp;gt; bluart: write_blocking: transmitting 1019 bytes
[00:05:30.103,118] &amp;lt;inf&amp;gt; bluart: write_blocking: transmitting 5 bytes
[00:05:30.103,302] &amp;lt;inf&amp;gt; bluart: write_blocking: transmitting 556 bytes
[00:05:30.425,659] &amp;lt;inf&amp;gt; bluart: complete_test: TX complete
[00:05:30.426,177] &amp;lt;inf&amp;gt; bluart: complete_test: TX complete
[00:05:30.646,484] &amp;lt;inf&amp;gt; bluart: complete_test: TX complete
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;as you can see in this log, there is a total of more than 500ms between calling the write function, and the execution of the TX complete callback. this is still with 90ms connection interval, and I changed the code so that every relay waits for the full payload and only relays it once its fully received, to limit the concurrent on-air traffic.&lt;/p&gt;
&lt;p&gt;the question now is, why is there such a long time between calling write and getting the complete callback? to me this still seems like an issue with the transmitting and would confirm my earlier findings that it is due to interference. Do you also think so? Or do you know of any other causes that would cause a delay there?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE data relay latency issues</title><link>https://devzone.nordicsemi.com/thread/466063?ContentTypeID=1</link><pubDate>Thu, 25 Jan 2024 14:58:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ff68afd8-c845-4e17-b200-249c9c3529ab</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Are you in an appartment-block or similar where you have neighbours heavily using a microwave oven? That creates a lot of noise in the entier 2.4 GHz ISM band. To check if this really is the case, perhaps you could try to repeate the experiment somewhere with less 2.4 GHz traffic?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE data relay latency issues</title><link>https://devzone.nordicsemi.com/thread/466058?ContentTypeID=1</link><pubDate>Thu, 25 Jan 2024 14:50:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c66e29f5-b6a4-4d60-90d1-bbebb6507e58</guid><dc:creator>jonas.woerner</dc:creator><description>&lt;p&gt;according to the wireshark logs, there are so many lost packets, that it sums up to about a second sometimes, but Im not sure on this as lowering the transmit power and even separating the devices into different rooms didnt really change anything. Its extremely frustrating. Sometimes I can measure a hundred times without any problem and then suddenly the delay goes way up. I dont understand it.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE data relay latency issues</title><link>https://devzone.nordicsemi.com/thread/466056?ContentTypeID=1</link><pubDate>Thu, 25 Jan 2024 14:46:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6fbca34b-8587-4162-93e5-9a7616e3a504</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi Jonas,&lt;/p&gt;
&lt;p&gt;You can never avoid all packet loss, and particularily not in a congested RF environment. Bluetooth LE chagne channel every connection event though, so unless you have a very high number of devices that send a lot of data I would not expect that to be the main problem. Also, with your connection interval being less than 100 ms I do not see why loosing a few packets would suddenly lead to a 1 second latency. Perhaps there is another issue in your setup, or with how you measure the latency?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE data relay latency issues</title><link>https://devzone.nordicsemi.com/thread/465672?ContentTypeID=1</link><pubDate>Tue, 23 Jan 2024 17:56:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:07b1432c-45ea-4296-8944-06df3f660c4a</guid><dc:creator>jonas.woerner</dc:creator><description>&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/latencytest_5F00_5relays.zip"&gt;devzone.nordicsemi.com/.../latencytest_5F00_5relays.zip&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;In the attached ZIP file you will find 4 different wireshark captures and a pulseview capture.&lt;/p&gt;
&lt;p&gt;the wireshark logs show the connections between all the relays and the pulseview log shows the latency / propagation delay of each relay (rising edge = start receiving test payload, falling edge = test payload complete)&lt;/p&gt;
&lt;p&gt;the wireshark logs and the pulsseview trace show the same test, except that the first time the payload was sent it was not logged with pulseview. from the second time on, pulseview and wireshark are in sync.&lt;/p&gt;
&lt;p&gt;If you look for packet no. 10436 in relay3_4 and packet 11460 in relay2_3 (which should be payload no #62 if I didnt miscount) I think I can see exactly what you thought has happened, the relay2_3 transmission was fast according to pulseview and I cannot see any retransmissions. The relay3_4 transmission however was slow and I can see multiple retransmissions. It would be very much appreciated if you could verify my findings though, as Im not really experienced with BLE sniffing.&lt;/p&gt;
&lt;p&gt;If all the above is correct, then I think that indeed the packet loss is the cause of my latency. This would totally make sense now that I think more about it, as I observed the latency get worse and worse over time and then get better and better again, which i now would explain as the connection intervals drifting towards until spontaneous synchronisation happens and latency is at its worst, then gradually gets better. Very Interesting!&lt;/p&gt;
&lt;p&gt;One question remains though, Is there a way to optimize this behaviour and reduce the amount of packet loss in that situation?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;kind regards,&lt;/p&gt;
&lt;p&gt;Jonas&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE data relay latency issues</title><link>https://devzone.nordicsemi.com/thread/465610?ContentTypeID=1</link><pubDate>Tue, 23 Jan 2024 14:19:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fa4511f4-bd59-4e2b-9c7b-fbaba241b2fe</guid><dc:creator>jonas.woerner</dc:creator><description>&lt;p&gt;and by the way, if the problem indeed would be packet loss, my guess would be its because I have multiple BLE devices in close proximity, all transmitting simultaneously at full power. How would I try to solve this? is there even anything that could be done to solve this?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE data relay latency issues</title><link>https://devzone.nordicsemi.com/thread/465609?ContentTypeID=1</link><pubDate>Tue, 23 Jan 2024 14:17:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d6617d3f-c313-4bcb-8455-f222d6aa8d70</guid><dc:creator>jonas.woerner</dc:creator><description>&lt;p&gt;the data is sent using write without response. &lt;/p&gt;
&lt;p&gt;Tested connection intervals range from 7.5ms up to 400ms, all with the same relative results, the absolute delay is smaller on the smaller intervals.&lt;/p&gt;
&lt;p&gt;I tried with multiple event lengths too, but cant seem to see any difference, is it correct to set it using&lt;/p&gt;
&lt;div style="background-color:#1f1f1f;color:#cccccc;font-family:&amp;#39;Droid Sans Mono&amp;#39;, &amp;#39;monospace&amp;#39;, monospace;font-size:14px;font-weight:normal;line-height:19px;white-space:pre;"&gt;
&lt;div&gt;&lt;span style="color:#6a9955;"&gt;CONFIG_BT_CTLR_SDC_MAX_CONN_EVENT_LEN_DEFAULT&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;MTU is set to 1024 at the moment, but I also tried differernt values with similiar results.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I already did some sniffing and have found out that there indeed is packet loss, I didnt know that a packet loss causes the event to end though, that could go in the right direction. Its hard for me to catch the &amp;quot;long&amp;quot; packets, as the sniffer needs to be setup for a particular device prior to connecting, but I only know which device causes the latency after connecting. I will have to try with multiple sniffers setup beforehand, I will update this with a sniffer log as soon as possible.&lt;/p&gt;
&lt;p&gt;In the meanwhile, here are some pictures of the latency, a rising edge means that the first packet of my test payload has been received, a falling edge means that the payload is complete. The first image shows a case where it behaves more or less like expected, the second image shows a too high latency. this is done with 90ms connection interval.&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:342px;max-width:286px;" height="342" src="https://devzone.nordicsemi.com/resized-image/__size/572x684/__key/communityserver-discussions-components-files/4/5r_5F00_90ms_5F00_good.png" width="286" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:296px;max-width:403px;" height="296" src="https://devzone.nordicsemi.com/resized-image/__size/806x592/__key/communityserver-discussions-components-files/4/5r_5F00_90ms_5F00_baaaaaaaaaaaaaaad.png" width="403" alt=" " /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE data relay latency issues</title><link>https://devzone.nordicsemi.com/thread/465589?ContentTypeID=1</link><pubDate>Tue, 23 Jan 2024 13:37:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:612859b7-15d1-408d-ba42-99e034aeaa07</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi&amp;nbsp;Jonas,&lt;/p&gt;
&lt;p&gt;Can you say more about how you transfer the data?&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Is it as notifications or another method?&lt;/li&gt;
&lt;li&gt;What is the connection interval&lt;/li&gt;
&lt;li&gt;What is the event length?&lt;/li&gt;
&lt;li&gt;How long packets do you use?&lt;/li&gt;
&lt;li&gt;Are more/many packets typically sent per connection event?&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Also do you have any siffer trace of this, both the good case (where y0ou have low latency) and the bad case where you have high latency?&lt;/p&gt;
&lt;p&gt;Without knowing more, my gut feeling is that you are using fairly long connection events and event lengths, and send multiple packet per connection event. Is that so? If so, a packet loss could explain what you are seeing, as an event would end in that case, and the retransmission will happen in the next connection event.&lt;/p&gt;
&lt;p&gt;Einar&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>