How to use pyspinel-cli and sniffer based on new board and radio?

336 views
Skip to first unread message

Carry Irving

unread,
May 25, 2018, 4:01:07 AM5/25/18
to openthread-users
Hi all,

I have tried porting openthread on new board and radio(Freedom K64 with mbed OS and MRF24J40). Everything works fine when I using CLI commands. CLI nodes can communicate to OTBR with the help of NCP, such as scanning each other, creating a new Thread network and the other can join it successfully.
But I am facing a challenge during debuging NCP using pyspinel-cli. It works fine when some commands are given, such as "ipaddr", "panid". But it shows me Error when "thread start" or "scan" are given.
What's more. I am going to capture packages between CLI nodes using pyspinel-sniffer. Wireshark and sniffer running well with the following command:

sudo python sniffer.py -c 11 -n 1 -u /dev/ttyACM0 | sudo wireshark -k -i -


and it shows me:
Initializing sniffer...
SUCCESS: sniffer initialized
Sniffing...

But there is nothing on wireshark when I give "ping", "scan" command to the CLI. I think the most likely reason is that some configuration is missing when compiling the NCP code , but I can't find it out.

-DMBEDTLS_CONFIG_FILE=\"mbedtls-config.h" \
       
-DOPENTHREAD_CONFIG_FILE=\"openthread-mbed-config.h" \
       
-DOPENTHREAD_FTD=1 \
       
-DOPENTHREAD_ENABLE_NCP=1 \
       
-DOPENTHREAD_ENABLE_NCP_MTD=0 \
       
-DOPENTHREAD_ENABLE_NCP_FTD=1 \
       
-DOPENTHREAD_ENABLE_NCP_UART=1 \
       
-DOPENTHREAD_ENABLE_NCP_SPI=0



Thanks a lot.
Xiangcai.

openthread-mbed-config.h

Jonathan Hui

unread,
May 25, 2018, 2:18:21 PM5/25/18
to Harry Potter, openthread-users
Every NCP build should include the necessary capabilities to enable packet sniffing.

To enable packet sniffing, the radio driver needs to properly support the `otPlatRadioSetPromiscuous()` platform API, which is not generally needed for normal Thread operation.

Can you validate that the radio driver is receiving arbitrary IEEE 802.15.4 frames after calling `otPlatRadioSetPromiscuous()` with `true`?

--
Jonathan Hui

--
You received this message because you are subscribed to the Google Groups "openthread-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to openthread-use...@googlegroups.com.
To post to this group, send email to openthre...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/openthread-users/09a7c772-97b2-4ae2-86cf-2b555985e550%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Carry Irving

unread,
May 26, 2018, 3:47:34 AM5/26/18
to openthread-users
Hi Jonathan,

I have validated that the radio can receive arbitrary MAC frames after command "promiscuous enable" is given on CLI Node.

CLI 1: > promiscuous enable[INFO]---------: execute command: promiscuous enable
[DEBG]-MAC-----: Idle mode: Radio receiving on channel 11
CLI 2: > scan
CLI 1: [INFO]-MAC-----: Frame rx failed, error:DestinationAddressFiltered, len:10, seqnum:0, type:Cmd(Beac
Done
============================================[len =  10]============================
| 03 08 00 FF FF FF FF 07 00 00 .. .. .. .. .. ..| ? ? ? ? ? ? ? ? ? ? . . . . . .|
-----------------------------------------------------------------------------------

Thanks,
Xiangcai.

Carry Irving

unread,
May 26, 2018, 4:04:38 AM5/26/18
to openthre...@googlegroups.com

I have noticed that the `otPlatRadioSetPromiscuous()` has never be called after NCP Node running. But the radio will be set to monitor mode during sniffer initialization.

(sniffer.py)
    result
= wpan_api.prop_set_value(SPINEL.PROP_PHY_ENABLED, 1)

    result
= wpan_api.prop_set_value(SPINEL.PROP_MAC_FILTER_MODE, SPINEL.MAC_FILTER_MODE_MONITOR)
   
if result is None:
       
return False
...

    result
= wpan_api.prop_set_value(SPINEL.PROP_MAC_RAW_STREAM_ENABLED, 1)


Debug NCP using pyspinel-cli tool:

spinel-cli > ncp-raw 1
PROP_VALUE_SET
[tid=1]: MAC_RAW_STREAM_ENABLED
Done
spinel
-cli > ncp-raw
PROP_VALUE_GET
[tid=1]: MAC_RAW_STREAM_ENABLED
1
Done
spinel
-cli > ncp-filter 1
PROP_VALUE_SET
[tid=1]: MAC_FILTER_MODE
Done
spinel
-cli > ncp-filter
PROP_VALUE_GET
[tid=1]: MAC_FILTER_MODE
0
Done
spinel
-cli > ncp-filter 2
PROP_VALUE_SET
[tid=1]: MAC_FILTER_MODE
Done
spinel
-cli > ncp-filter
PROP_VALUE_GET
[tid=1]: MAC_FILTER_MODE
0
Done


I found the state of mac filter mode is always 0. In other words, the radio may be still in Normal MAC filtering mode after sniffer intialization. Is this the reason?

Set MAC filter mode:

       
0 = MAC_FILTER_MODE_NORMAL    Normal MAC filtering is in place.
       
1 = MAC_FILTER_MODE_PROMISCUOUS    All MAC packets matching network are passed up the stack.
       
2 = MAC_FILTER_MODE_MONITOR    All decoded MAC packets are passed up the stack.


Shu Chen

unread,
May 26, 2018, 9:07:57 AM5/26/18
to Carry Irving, openthread-users
The NCP radio is supposed to be set to promiscuous mode by the cmd: link. Please double check it could call into the otPlatRadioSetPromiscuous(): link.

Also, Please add --enable-raw-link-api build option when building NCP firmware, to better support Sniffer use case.

Thanks,
Shu

On Sat, May 26, 2018 at 4:04 PM, Carry Irving <xiangcai...@gmail.com> wrote:

And I have found that the `otPlatRadioSetPromiscuous()` has never be called after NCP Node starting. Is this the reason? The radio will be set to promiscuous mode during sniffer initializing?

--
You received this message because you are subscribed to the Google Groups "openthread-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to openthread-users+unsubscribe@googlegroups.com.
To post to this group, send email to openthread-users@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/openthread-users/81fd4541-68a9-4002-b9a0-992ca2a71d51%40googlegroups.com.

Carry Irving

unread,
May 31, 2018, 8:13:47 AM5/31/18
to openthre...@googlegroups.com
Hi, Shu Chen

I have found the problem can be solved by commenting the following two lines in sniffer.py:

def sniffer_init(wpan_api, options):
   
...
   
# wpan_api.cmd_send(SPINEL.CMD_RESET)
   
# time.sleep(1)

I used the release version
v1.0.0a2 before and this bug has been fixed in the lastest repo.

Thanks for your kind help!

Jonathan Hui

unread,
May 31, 2018, 4:16:09 PM5/31/18
to Harry Potter, openthread-users
Great to hear you got things working.

FWIW, PR#33 add the `--no_reset` flag that allows skipping the NCP reset sequence, which can cause issues on some platforms.

--
Jonathan Hui

On Thu, May 31, 2018 at 5:13 AM Carry Irving <xiangcai...@gmail.com> wrote:
Hi, Shu Chen

I have solved the problem by commenting the following two lines in sniffer.py:

def sniffer_init(wpan_api, options):
    ...
    # wpan_api.cmd_send(SPINEL.CMD_RESET)
    # time.sleep(1)

Thanks for your kind help!

--
You received this message because you are subscribed to the Google Groups "openthread-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to openthread-use...@googlegroups.com.
To post to this group, send email to openthre...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/openthread-users/61a18e86-31bd-4899-a764-3045d45fb482%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages