<?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 packet delay with wireshark</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/65180/ble-packet-delay-with-wireshark</link><description>Dear all, 
 I&amp;#39;m using nrf52-DK with PCA10040 as sniffer. I develop 2 custom board (nRF52840) (one acting as master, one as slave) and I would like to make some considerations about packets delay. What is the most correct method to do so? I know that the</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 26 Aug 2020 14:22:25 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/65180/ble-packet-delay-with-wireshark" /><item><title>RE: BLE packet delay with wireshark</title><link>https://devzone.nordicsemi.com/thread/266541?ContentTypeID=1</link><pubDate>Wed, 26 Aug 2020 14:22:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9985597e-2ef5-4edb-9f78-5f327a8d0dfb</guid><dc:creator>Elia_pell</dc:creator><description>&lt;p&gt;Dear Edvin,&lt;/p&gt;
&lt;p&gt;Thank you for your time, but I manage to solve the problem: it was an uart problem, I was sending too many bytes on the UART and my script written to read serial ports slow down the entire process. What I manage to obtain now is no more a stair case, so I think that everything is solved.&lt;/p&gt;
&lt;p&gt;Thanks again.&lt;/p&gt;
&lt;p&gt;Elia&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE packet delay with wireshark</title><link>https://devzone.nordicsemi.com/thread/266519?ContentTypeID=1</link><pubDate>Wed, 26 Aug 2020 13:28:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:de12257b-b0f9-454a-b3fe-44e19f1fabb6</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;My Italian is a bit rusty, so I find it a bit hard to follow the application logic. I tested against nRF Connect for Desktop, and I see a bunch of notifications, but I am struggling to keep up with the logic on how they are being sendt.&lt;/p&gt;
&lt;p&gt;I see that&amp;nbsp;timer_acquisition_event_handler() is&amp;nbsp;calling&amp;nbsp;ble_cus_custom_value_update()&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;So you are sending 100 bytes every 7.5ms. What happens if one of the packets are lost? How does that affect your measurement? Will you have a queue building up? Or will you just discard the packets that aren&amp;#39;t queued properly?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I can&amp;#39;t set up the UART thing that you are using and comparing the timestamps for packets, unfortunately. But I can tell you that there is not a bug in the softdevice causing packets to be delayed.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE packet delay with wireshark</title><link>https://devzone.nordicsemi.com/thread/266467?ContentTypeID=1</link><pubDate>Wed, 26 Aug 2020 11:46:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b7667261-abf5-4bc6-8ece-6f789e5a0d40</guid><dc:creator>Elia_pell</dc:creator><description>&lt;p&gt;This is the setup of our application:&lt;/p&gt;
&lt;p&gt;- When master and central connect, I start a timer equal to the connection interval. At the end of this timer, I send a notification to the master and put on UART the same packet.&lt;/p&gt;
&lt;p&gt;- At the receveir side, I put on the UART the packet receveid.&lt;/p&gt;
&lt;p&gt;- Connection interval is set to 7.5ms&lt;/p&gt;
&lt;p&gt;- NRF_SDH_BLE_GATT_MAX_MTU_SIZE 247&lt;/p&gt;
&lt;p&gt;-&amp;nbsp;NRF_SDH_BLE_GAP_DATA_LENGTH 251&lt;/p&gt;
&lt;p&gt;- Github project: &lt;a href="https://github.com/eliapellegrino/nordic"&gt;click here&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;The return values of&amp;nbsp;&lt;span&gt;sd_ble_gatts_hvx() is correct (NRF_SUCCESS) and the packet is correctly sent (sniffing with Wireshark). Have a look, if you can, to the github project.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Thank you very muvh Edvin.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE packet delay with wireshark</title><link>https://devzone.nordicsemi.com/thread/266447?ContentTypeID=1</link><pubDate>Wed, 26 Aug 2020 10:57:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:afe01299-a96e-4a49-85a5-ca1a6a8c5911</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Do you see it as well in the application? Does it take 1 minute from you post the message until it is printed?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;How exactly do you queue your packets (the 100 bytes one)? Perhaps you are queuing up faster than the link can handle. Or you are sending faster than the UART terminal can handle. How fast/how often do you send these 100 byte messages?&lt;/p&gt;
&lt;p&gt;. Is there some way for me to reproduce this on a couple of DKs? I suspect there is some sort of misunderstanding here.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Do you check the return values from sd_ble_gatts_hvx()? (it may be called from ble_nus_data_send(), if you are using the ble_app_uart example.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE packet delay with wireshark</title><link>https://devzone.nordicsemi.com/thread/266410?ContentTypeID=1</link><pubDate>Wed, 26 Aug 2020 09:07:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4b9c973c-1fc7-4369-b589-edb5c58dae12</guid><dc:creator>Elia_pell</dc:creator><description>[quote userid="26071" url="~/f/nordic-q-a/65180/ble-packet-delay-with-wireshark/266386"]Based on the pattern that you see, does it mean that if you leave it running, it will take many seconds, and even minutes delay after enough time?[/quote]
&lt;p&gt;Yes. I will post some figure here with different payload size. The strange thing is that now this happens also for payload size &amp;lt; 50B&lt;/p&gt;
&lt;p&gt;100B:&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/100B.png"&gt;/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/100B.png&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;50B:&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/50B.png"&gt;/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/50B.png&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;5B:&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/5B.png"&gt;/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/5B.png&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;I really don&amp;#39;t understand why this behavior&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE packet delay with wireshark</title><link>https://devzone.nordicsemi.com/thread/266386?ContentTypeID=1</link><pubDate>Wed, 26 Aug 2020 08:20:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:320f056e-912c-4e56-b6aa-9a8b6d6392f1</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;[quote user="Elia_pell"][/quote]&lt;/p&gt;
&lt;p&gt;Exactly like this and I don&amp;#39;t think that this is correct, also because I expected something like this right?&lt;/p&gt;
&lt;div&gt;&lt;/div&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/65180/ble-packet-delay-with-wireshark/266224"&gt;Elia_pell said:&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;delay = 133*8 = 1064 us&lt;/div&gt;
&lt;/blockquote&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;No, because of the connection interval, you should see some delay between 0-&amp;lt;connection interval&amp;gt; ms + some processing time.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Based on the pattern that you see, does it mean that if you leave it running, it will take many seconds, and even minutes delay after enough time?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE packet delay with wireshark</title><link>https://devzone.nordicsemi.com/thread/266374?ContentTypeID=1</link><pubDate>Wed, 26 Aug 2020 07:51:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7f805b82-fcf2-43cd-8d43-3f13e8c3079c</guid><dc:creator>Elia_pell</dc:creator><description>[quote userid="26071" url="~/f/nordic-q-a/65180/ble-packet-delay-with-wireshark/266303"]Is the delay longer and longer for each message?[/quote]
&lt;p&gt;Exactly like this and I don&amp;#39;t think that this is correct, also because I expected something like this right?&lt;/p&gt;
[quote userid="92986" url="~/f/nordic-q-a/65180/ble-packet-delay-with-wireshark/266224"]delay = 133*8 = 1064 us[/quote]
&lt;p&gt;What could be the problem in your opinion?&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE packet delay with wireshark</title><link>https://devzone.nordicsemi.com/thread/266303?ContentTypeID=1</link><pubDate>Tue, 25 Aug 2020 15:36:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fcdc33a2-416e-438b-be51-5d6d2173e9ee</guid><dc:creator>Edvin</dc:creator><description>[quote user="Elia_pell"]What is strange for me is that the delay tx/rx improve during the communication[/quote]
&lt;p&gt;&amp;nbsp;Does it improve, or do you mean that it increases?&lt;/p&gt;
&lt;p&gt;If access to an oscilloscope/logic analyzer is a limitation, you can of course try to time this on one of the DKs. Start a timer that is not used by the application or the softdevice (the softdevice uses TIMER0), and sample the TIMER before TX. Then you can toggle a pin on the receiver DK. You can use this as a trigger to capture the TIMER again on the TX board using a breadboard cable. Then compare the two captures, and see how long the time is between the two.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;If you have 3 DKs, you can run the timer application there, but you should be able to do with just two.&lt;/p&gt;
&lt;p&gt;The time can be measured by something like this:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;// Choose a free timer, e.g. TIMER3 (if it is not used by your application). 


void egu_init()
{
    NVIC_ClearPendingIRQ(SWI1_EGU1_IRQn);
    NVIC_EnableIRQ(SWI1_EGU1_IRQn);
    NRF_EGU1-&amp;gt;INTENSET = (1 &amp;lt;&amp;lt; 0) | (1 &amp;lt;&amp;lt; 1);
}
void timer_init()
{
    NRF_TIMER3-&amp;gt;BITMODE                 = TIMER_BITMODE_BITMODE_32Bit &amp;lt;&amp;lt; TIMER_BITMODE_BITMODE_Pos;     // 0&amp;lt;&amp;lt;0; = 0 
    NRF_TIMER3-&amp;gt;PRESCALER               = 0;                                                            // previously 0;
    //NRF_TIMER3-&amp;gt;SHORTS                  = TIMER_SHORTS_COMPARE0_CLEAR_Msk &amp;lt;&amp;lt; TIMER_RELOAD_CC_NUM;       // 1&amp;lt;&amp;lt;0; = 1
    NRF_TIMER3-&amp;gt;MODE                    = TIMER_MODE_MODE_Timer &amp;lt;&amp;lt; TIMER_MODE_MODE_Pos;                 // 0&amp;lt;&amp;lt;0; = 0
    //NRF_TIMER3-&amp;gt;CC[TIMER_RELOAD_CC_NUM] = TIMER_RELOAD;                                                 // 1000;
}


void timer_start()
{
    NRF_TIMER3-&amp;gt;TASKS_START = 1;
}


void ppi_init(uint32_t pin_in_select)
{
    NRF_GPIOTE-&amp;gt;CONFIG[0] = GPIOTE_CONFIG_MODE_Event &amp;lt;&amp;lt; GPIOTE_CONFIG_MODE_Pos |
                            GPIOTE_CONFIG_POLARITY_Toggle &amp;lt;&amp;lt; GPIOTE_CONFIG_POLARITY_Pos |
                            pin_in_select &amp;lt;&amp;lt; GPIOTE_CONFIG_PSEL_Pos;
                            
    NRF_PPI-&amp;gt;CH[0].EEP = (uint32_t)&amp;amp;NRF_GPIOTE-&amp;gt;EVENTS_IN[0];
    NRF_PPI-&amp;gt;CH[0].TEP = NRF_PPI-&amp;gt;CH[0].TEP = (uint32_t)&amp;amp;NRF_TIMER3-&amp;gt;TASKS_CAPTURE[1];
    NRF_PPI-&amp;gt;FORK[0].TEP = (uint32_t)&amp;amp;NRF_EGU1-&amp;gt;TASKS_TRIGGER[0];
}


void compare_timers()
{
    uint32_t time1 = NRF_TIMER3-&amp;gt;CC[0];
    uint32_t time2 = NRF_TIMER3-&amp;gt;CC[1];
    uint32_t diff_ticks = time2 - time1;
    
    NRF_LOG_INFO(&amp;quot;diff ticks: %d&amp;quot;, diff_ticks);
    
    //Timer is running at 32MHz, so time_in_ms = diff_ticks/32000;
}

void SWI1_EGU1_IRQHandler(void) //Used to propagate event to the application
{
    if (NRF_EGU1-&amp;gt;EVENTS_TRIGGERED[0] != 0)
    {
        NRF_EGU1-&amp;gt;EVENTS_TRIGGERED[0] = 0;      //Reset event triggered register.
        
        compare_timers();
    }
}


void my_tx_function()
{
    NRF_TIMER3-&amp;gt;TASKS_CAPTURE[0] = 1;
    my_already_implemented_tx_function();
}


&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Note that the reason I am using PPI to read the TIMER registes is that your CPU may be busy doing something else when you receive the pulse on the pin, and ppi allows for this capture to happen without need to wait for the CPU. The EGU is used to propagate this event to the application, so that you can use it to check the difference in time.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Now, this only show how you can measure, in order to minimize delay in the UART. I still think I don&amp;#39;t understand your graph. Is the delay longer and longer for each message? If so, I suspect that there is something weird with your messages.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE packet delay with wireshark</title><link>https://devzone.nordicsemi.com/thread/266224?ContentTypeID=1</link><pubDate>Tue, 25 Aug 2020 12:07:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5566be49-963e-4082-ac55-55fa82ca6487</guid><dc:creator>Elia_pell</dc:creator><description>&lt;p&gt;Hi Edvin, thanks for the fast reply. I forgot to rename the axis in english. The y-axis is the delay in ms, while the x-axis is only the number of packet (first packet, second packet, ecc ecc), with a payload of length 100B. What is strange for me is that the delay tx/rx improve during the communication, while in theory (as you said) it would be random beetween 0 and &amp;lt;connection_interval&amp;gt; (in the application 7.5 ms).&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Of course I know about the connection interval and all the related stuff of BLE spec: I&amp;#39;m sending 100B over 1Mbps phy (Data Length extension and ATT_MTU size are set to the maximum, so I can send 100B (I have also debugged it with wireshark).&lt;/p&gt;
&lt;p&gt;The problem is that I can use an oscillosope/instrumentation only 1 times a week, and so I would like to find some strategy to compute the delay in a reliable way.&lt;/p&gt;
&lt;p&gt;So, do you agree with me that the figure is quite strange? With the time field of Wireshark can I compute the delay or only the connection interval?&lt;/p&gt;
&lt;p&gt;In theory with a payload of 100B (total PDU_SIZE = 133B), I will expect a delay around:&lt;/p&gt;
&lt;p&gt;delay = 133*8 = 1064 us&lt;/p&gt;
&lt;p&gt;Is this correct?&lt;/p&gt;
&lt;p&gt;Sorry for the long answer, I think that now it is all more clear.&lt;/p&gt;
&lt;p&gt;Thank you Edvin.&lt;/p&gt;
&lt;p&gt;Elia&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE packet delay with wireshark</title><link>https://devzone.nordicsemi.com/thread/266218?ContentTypeID=1</link><pubDate>Tue, 25 Aug 2020 11:53:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5d0ab081-5ca1-47bf-87ea-80159e1cb288</guid><dc:creator>Edvin</dc:creator><description>[quote user=""]but the result (for packet bigger than 50B) is quite strange[/quote]
&lt;p&gt;&amp;nbsp;What exactly is strange?&lt;/p&gt;
&lt;p&gt;I checked out your graph. What is the X-Axis? Number of bytes in the packet? I don&amp;#39;t understand what is strange about it. Is it the steps? How many bytes difference do you use in each sample? Is it the stair shape that you find strange?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;To measure the time between transmission and reception, one thing you can try is to just toggle a pin on the DK when you transmit (right before sd_ble_gatts_hvx()) and toggle a pin when you receive it on the other side, and use a logic analyzer to compare these two signals.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;What exactly is it that you want to measure? I don&amp;#39;t know if you are aware about the &amp;quot;connection interval&amp;quot; in BLE and how that works? Basically, the connected devices will only communicate once every connection interval. So you will see a random delay between 0 and &amp;lt;connection_interval&amp;gt; ms.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;BR,&lt;/p&gt;
&lt;p&gt;Edvin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>