<?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>Mesh LPN RX race condition</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/42473/mesh-lpn-rx-race-condition</link><description>Suppose node L is in a friendship with node F. Consider the following: 
 
 1. Some other node C sends a message to L. 
 2. F hears the message, and saves the message into L&amp;#39;s friend queue. 
 3. L also happens to be scanning (e.g. L is currently in a Friend</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 22 Jan 2020 14:40:24 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/42473/mesh-lpn-rx-race-condition" /><item><title>RE: Mesh LPN RX race condition</title><link>https://devzone.nordicsemi.com/thread/230394?ContentTypeID=1</link><pubDate>Wed, 22 Jan 2020 14:40:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b1a4bf08-0cec-46cd-9938-7c974ae6b5d7</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Yes it fixed in SDK v3.2.&amp;nbsp;&lt;br /&gt;Just a note, our latest version is&amp;nbsp;SDK v4.0&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Mesh LPN RX race condition</title><link>https://devzone.nordicsemi.com/thread/230172?ContentTypeID=1</link><pubDate>Tue, 21 Jan 2020 20:04:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:efbe60c7-fa60-487b-9832-d5a4103bdeae</guid><dc:creator>BubDev</dc:creator><description>&lt;p&gt;Just checking if this was fixed in mesh sdk 3.2.0?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Mesh LPN RX race condition</title><link>https://devzone.nordicsemi.com/thread/166086?ContentTypeID=1</link><pubDate>Wed, 16 Jan 2019 17:46:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2ad01be3-349e-4269-8549-c08faf29be1b</guid><dc:creator>isundaylee</dc:creator><description>&lt;p&gt;Great! Thanks for the update.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Mesh LPN RX race condition</title><link>https://devzone.nordicsemi.com/thread/165967?ContentTypeID=1</link><pubDate>Wed, 16 Jan 2019 12:41:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6befe173-586c-4006-aa6e-56d26f0e1e48</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Thanks Isundaylee for the detailed report.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;We have checked and found an issue with our implementation in SDK v3.1&amp;nbsp;&lt;/p&gt;
&lt;p&gt;We will try to come up with a fix and let you know if we have one.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Mesh LPN RX race condition</title><link>https://devzone.nordicsemi.com/thread/165507?ContentTypeID=1</link><pubDate>Mon, 14 Jan 2019 14:25:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6d3c2278-bd32-47fd-b736-5a672f655fc0</guid><dc:creator>isundaylee</dc:creator><description>&lt;p&gt;BTW the log above is for the similar scenario I described in my comment: &amp;quot;A similar thing can happen when L sends to a group address G which L also subscribes to itself. In this case the recorded Friend Poll reply will get discarded in the 4th if statement in `&lt;span&gt;deobfuscated_header_is_valid`.&amp;quot;, which&amp;nbsp;repros&amp;nbsp;deterministically every time.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Mesh LPN RX race condition</title><link>https://devzone.nordicsemi.com/thread/165503?ContentTypeID=1</link><pubDate>Mon, 14 Jan 2019 14:22:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0c7cd992-a550-479b-8d11-8ba929eddd3a</guid><dc:creator>isundaylee</dc:creator><description>&lt;p&gt;I added the following lines:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="diff"&gt;diff --git a/mesh_sdk/mesh/core/src/lpn.c b/mesh_sdk/mesh/core/src/lpn.c
index 9d8d0f6a..717d48be 100755
--- a/mesh_sdk/mesh/core/src/lpn.c
+++ b/mesh_sdk/mesh/core/src/lpn.c
@@ -655,6 +655,7 @@ static void receive_delay_handle(timestamp_t timestamp, void * p_context)
 {
     (void)timestamp;

+    __LOG(LOG_SRC_APP, LOG_LEVEL_ERROR, &amp;quot;Scanning...&amp;quot;);
     scanner_enable();
     m_lpn.timeout_scheduler.cb = timeout_handle;
     timestamp_t new_timestamp = timer_now() + ((uint32_t) p_context);
@@ -946,6 +947,7 @@ void mesh_lpn_rx_notify(const network_packet_metadata_t * p_net_metadata)

     if (m_lpn.p_subman_data == NULL)
     {
+        __LOG(LOG_SRC_APP, LOG_LEVEL_ERROR, &amp;quot;FSN incremented.&amp;quot;);
         m_lpn.fsn++;
     }

diff --git a/mesh_sdk/mesh/core/src/net_packet.c b/mesh_sdk/mesh/core/src/net_packet.c
index c195104b..9d451633 100755
--- a/mesh_sdk/mesh/core/src/net_packet.c
+++ b/mesh_sdk/mesh/core/src/net_packet.c
@@ -127,6 +127,7 @@ static inline bool deobfuscated_header_is_valid(const network_packet_metadata_t
      * the packet here, but since the decryption would have failed anyway, it doesn&amp;#39;t matter. */
     if (msg_cache_entry_exists(p_net_metadata-&amp;gt;src, p_net_metadata-&amp;gt;internal.sequence_number))
     {
+        __LOG(LOG_SRC_APP, LOG_LEVEL_ERROR, &amp;quot;Packet dropped: Message cache.&amp;quot;);
         __INTERNAL_EVENT_PUSH(INTERNAL_EVENT_PACKET_DROPPED, PACKET_DROPPED_NETWORK_CACHE, net_packet_len, p_net_packet);
         return false;
     }
@@ -135,6 +136,7 @@ static inline bool deobfuscated_header_is_valid(const network_packet_metadata_t
     nrf_mesh_address_t dummy;
     if (nrf_mesh_rx_address_get(p_net_metadata-&amp;gt;src, &amp;amp;dummy))
     {
+        __LOG(LOG_SRC_APP, LOG_LEVEL_ERROR, &amp;quot;Packet dropped: Self-sent.&amp;quot;);
         return false;
     }&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Here&amp;#39;s the log:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;[      8.104] [   INFO    ] Received a Friend Update.
[      8.104] [   INFO    ] Friend poll completed.
[     14.029] [   INFO    ] User button pressed.
[     14.029] [***********] TX: [aop: 0x8203]
[     14.030] [***********] TX: Msg: 0100
[     14.030] [***********] TX: [aop: 0x8203]
[     14.030] [***********] TX: Msg: 0100
[     14.030] [***********] TX: [aop: 0x8203]
[     14.030] [***********] TX: Msg: 0100
[     14.030] [   INFO    ] Received LED set request: ON
[     16.074] [!! ERROR !!] Scanning...
[     16.204] [!! ERROR !!] Packet dropped: Self-sent.
[     16.228] [!! ERROR !!] Packet dropped: Self-sent.
[     16.430] [!! ERROR !!] Scanning...
[     16.564] [!! ERROR !!] Packet dropped: Self-sent.
[     16.584] [!! ERROR !!] Packet dropped: Self-sent.
[     16.785] [!! ERROR !!] Scanning...
[     16.905] [***********] TX: [aop: 0x0004]
[     16.905] [***********] TX: Msg: 00FFFF
[     16.923] [!! ERROR !!] Packet dropped: Self-sent.
[     16.944] [!! ERROR !!] Packet dropped: Self-sent.
[     17.141] [!! ERROR !!] Scanning...
[     17.284] [!! ERROR !!] Packet dropped: Self-sent.
[     17.308] [!! ERROR !!] Packet dropped: Self-sent.
[     17.497] [!! ERROR !!] Scanning...
[     17.644] [!! ERROR !!] Packet dropped: Self-sent.
[     17.664] [!! ERROR !!] Packet dropped: Self-sent.
[     17.852] [!! ERROR !!] Scanning...
[     18.003] [!! ERROR !!] Packet dropped: Self-sent.
[     18.108] [!! ERROR !!] Friendship terminated with 0x0021. Reason: 2.&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;At 14.029 I pressed the button, which sends a Generic OnOff Set message to 0xCAFE. The LPN node also subscribes to 0xCAFE, and hears the message directly (probably through a local loopback?) at 14.030. In the following Friend Poll process the Friend Poll replies are all rejected as self-sent (4th if-statement), and FSN is never incremented.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Mesh LPN RX race condition</title><link>https://devzone.nordicsemi.com/thread/165496?ContentTypeID=1</link><pubDate>Mon, 14 Jan 2019 14:02:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:558c49c3-cbd8-40b0-8cd9-93f15b81e947</guid><dc:creator>isundaylee</dc:creator><description>&lt;p&gt;Thanks for the information! I did upgrade to v3.1.0 due to the other LPN bug, but this seems to be a separate one that still repros on v3.1.0.&lt;/p&gt;
&lt;p&gt;Can you elaborate a bit on &amp;quot;&lt;span&gt;LPN should not receive packet to itself when it&amp;#39;s in friendship&amp;quot;? Do you mean that LPN should not process&amp;nbsp;packets that it hears directly (i.e. not from a&amp;nbsp;Friend)? In this case what seems to happen is that: 1) LPN sends a Friend Poll, 2) LPN waits for Receive Delay,&amp;nbsp;and starts scanning for replies to the Friend Poll, 3) while the scanner in on, the LPN node&amp;nbsp;hears a direct message before hearing the Friend Poll&amp;nbsp;response. Is there code in the SDK that instructs LPN to ignore all the packets it&amp;nbsp;hears directly?&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;To&amp;nbsp;confirm:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;1) I added log statements to the 3rd and 4th if-statements in `deobfuscated_header_is_valid`. They are hit.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;2) I added a log statement in `mesh_lpn_rx_notify` right before `m_lpn.fsn++`. They are not hit, thus&amp;nbsp;confirming that the Friend Poll reply messages never reached the LPN module.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I can provide some log files if that is helpful.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Thank you!&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Mesh LPN RX race condition</title><link>https://devzone.nordicsemi.com/thread/165395?ContentTypeID=1</link><pubDate>Mon, 14 Jan 2019 10:13:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:14744051-fc82-4dea-95d5-f0d2961355de</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Hi Isundaylee,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thanks for reporting this. However, by design, our LPN should not receive packet to itself when it&amp;#39;s in friendship. You can have a look at the LPN life cycle figure &lt;a href="https://www.nordicsemi.com/DocLib/Content/SDK_Doc/Mesh_SDK/v3-1-0/md_doc_introduction_lpn_concept"&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;But we suspect it might be due to another bug we found in SDK v3.0 and fixed in SDK v3.1. Could you reproduce the issue on SDK v3.1 ?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;In addition, could you explain a little bit on how you figured out that the LPN discard packet from friend, do you have some log ?&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Mesh LPN RX race condition</title><link>https://devzone.nordicsemi.com/thread/165339?ContentTypeID=1</link><pubDate>Mon, 14 Jan 2019 05:27:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b9b9e826-2913-4291-8726-183ebba9c34c</guid><dc:creator>isundaylee</dc:creator><description>&lt;p&gt;Thank you! &lt;span class="emoticon" data-url="https://devzone.nordicsemi.com/cfs-file/__key/system/emoji/1f642.svg" title="Slight smile"&gt;&amp;#x1f642;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Mesh LPN RX race condition</title><link>https://devzone.nordicsemi.com/thread/165338?ContentTypeID=1</link><pubDate>Mon, 14 Jan 2019 05:27:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9f549b41-5296-4674-a4c1-7fa1f966cbfb</guid><dc:creator>isundaylee</dc:creator><description>&lt;p&gt;A similar thing can happen when L sends to a group address G which L also subscribes to itself. In this case the recorded Friend Poll reply will get discarded in the 4th if statement in `&lt;span&gt;deobfuscated_header_is_valid`.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Mesh LPN RX race condition</title><link>https://devzone.nordicsemi.com/thread/165331?ContentTypeID=1</link><pubDate>Mon, 14 Jan 2019 01:07:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ced4b127-65e9-4477-9b1d-903cfb480947</guid><dc:creator>natersoz</dc:creator><description>&lt;p&gt;Very nice analysis!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>