LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 10-17-2018, 11:44 AM   #1
Vejimart
LQ Newbie
 
Registered: Oct 2018
Posts: 1

Rep: Reputation: Disabled
Sending 6lowpan packets over an 802.15.4 link between two raspberry pi, the last few bytes of every packet get messed up or turned to zeros


I am using Raspbian GNU/Linux 9 (stretch) with kernel 4.14.74-v7+. I didn't have to recompile the kernel myself because it already included 6lowpan, as well as the driver for the radio module I am using (MRF24j40).

I had to compile the device tree overlay though (source found at https://bergzand.net/6lowpan-on-linu...berry-pis.html), because it wasn't available in the /boot/overlays directory

mrf24j40.dts device tree source file:

Code:
/dts-v1/;
/plugin/;

/ {
        compatible = "bcrm,bcm2708";

        fragment@0 {
                target = <&spi0>;
                __overlay__ {
                        #address-cells = <1>;
                        #size-cells = <0>;
                        status = "okay";

                        mrf24j40@0 {
                                status = "okay";
                                compatible = "mrf24j40";
                                spi-max-frequency = <5000000>;
                                reg = <1>;
                                interrupts = <23 8>;
                                interrupt-parent = <&gpio>;
                        };

                        spidev@0 {
                                status = "disabled";
                        };
                };
        };
};
I compiled the .dts file with the command:

Code:
sudo dtc -@ -O dtb -o mrf24j40.dtb mrf24j40.dts
I then edited the /etc/rc.local so that every time the system starts it sets the wpan0 pan_id, adds the lowpan0 interface, adds a known IPV6 address to it, brings up both wpan0 and lowpan0 and starts the babel routing protocol.

/etc/rc.local:

Code:
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.

# Print the IP address
_IP=$(hostname -I) || true
if [ "$_IP" ]; then
  printf "My IP address is %s\n" "$_IP"
fi

#AD-HOC
sudo ip link add link wpan0 name lowpan0 type lowpan &
sudo iwpan dev wpan0 set pan_id 0xbeef &
sudo ip link set wpan0 up &
sleep 1
sudo ip link set lowpan0 up &


#BABEL
sudo ip address add fd00:1234:5678::161/64 dev lowpan0 &
sudo babeld lowpan0 &

exit 0
After doing all of that on both raspberries (let's name them RP1 and RP2), I reboot them and check that everything is fine with "ip a" command. wpan0 and lowpan0 show up at numbers 4 and 5.

Code:
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether b8:27:eb:04:60:8c brd ff:ff:ff:ff:ff:ff
    inet 192.168.2.161/24 brd 192.168.2.255 scope global eth0
       valid_lft forever preferred_lft forever
    inet6 fe80::ba27:ebff:fe04:608c/64 scope link 
       valid_lft forever preferred_lft forever
3: wpan0: <BROADCAST,NOARP,UP,LOWER_UP> mtu 123 qdisc pfifo_fast state UNKNOWN group default qlen 300
    link/ieee802.15.4 52:e6:da:6b:f7:74:c8:6f brd ff:ff:ff:ff:ff:ff:ff:ff
4: wlan0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast state DOWN group default qlen 1000
    link/ether b8:27:eb:51:35:d9 brd ff:ff:ff:ff:ff:ff
5: lowpan0@wpan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1280 qdisc noqueue state UNKNOWN group default qlen 1000
    link/6lowpan 52:e6:da:6b:f7:74:c8:6f brd ff:ff:ff:ff:ff:ff:ff:ff
    inet6 fd00:1234:5678::161/64 scope global 
       valid_lft forever preferred_lft forever
    inet6 fe80::50e6:da6b:f774:c86f/64 scope link 
       valid_lft forever preferred_lft forever

They can ping other, but packets return incomplete.

Code:
pi@raspberrypi:~ $ ping fd00:1234:5678::171
PING fd00:1234:5678::171(fd00:1234:5678::171) 56 data bytes
64 bytes from fd00:1234:5678::171: icmp_seq=1 ttl=64 time=15.7 ms
wrong data byte #45 should be 0x2d but was 0x0
#8	8 9 a b c d e f 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f 20 21 22 23 24 25 26 27 
#40	28 29 2a 2b 2c 0 0 0 0 0 0 0 0 0 0 0 
64 bytes from fd00:1234:5678::171: icmp_seq=2 ttl=64 time=12.3 ms
wrong data byte #45 should be 0x2d but was 0x0
#8	8 9 a b c d e f 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f 20 21 22 23 24 25 26 27 
#40	28 29 2a 2b 2c 0 0 0 0 0 0 0 0 0 0 0 
64 bytes from fd00:1234:5678::171: icmp_seq=3 ttl=64 time=13.9 ms
wrong data byte #45 should be 0x2d but was 0x0
#8	8 9 a b c d e f 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f 20 21 22 23 24 25 26 27 
#40	28 29 2a 2b 2c 0 0 0 0 0 0 0 0 0 0 0 
64 bytes from fd00:1234:5678::171: icmp_seq=5 ttl=64 time=13.6 ms
wrong data byte #45 should be 0x2d but was 0x0
#8	8 9 a b c d e f 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f 20 21 22 23 24 25 26 27 
#40	28 29 2a 2b 2c 0 0 0 0 0 0 0 0 0 0 0 
^C
--- fd00:1234:5678::171 ping statistics ---
5 packets transmitted, 4 received, 20% packet loss, time 4040ms
rtt min/avg/max/mdev = 12.385/13.946/15.756/1.203 ms
To see what's going on, I decided to ping RP2 from RP1 as a background process:

Code:
ping fd00:1234:5678::171 &> /dev/null&
And then run tcpdump on both machines simultaneously.

Code:
sudo tcpdump -i wpan0
The first packets of the output from RP1:

Code:
pi@raspberrypi:~ $ sudo tcpdump -i wpan0
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on wpan0, link-type IEEE802_15_4_NOFCS (IEEE 802.15.4 without FCS), capture size 262144 bytes
16:26:05.150857 IEEE 802.15.4 Data packet 
	0x0000:  6a00 092f e33a fd00 1234 5678 0000 0000  j../.:...4Vx....
	0x0010:  0000 0000 0161 fd00 1234 5678 0000 0000  .....a...4Vx....
	0x0020:  0000 0000 0171 8000 9bfa 0442 001c 8d54  .....q.....B...T
	0x0030:  c75b cf4c 0200 0809 0a0b 0c0d 0e0f 1011  .[.L............
	0x0040:  1213 1415 1617 1819 1a1b 1c1d 1e1f 2021  ...............!
	0x0050:  2223 2425 2627 2829 2a2b 2c2d 2e2f 3031  "#$%&'()*+,-./01
	0x0060:  3233 3435 3637                           234567
16:26:05.164598 IEEE 802.15.4 Data packet 
	0x0000:  6a00 069a f03a fd00 1234 5678 0000 0000  j....:...4Vx....
	0x0010:  0000 0000 0171 fd00 1234 5678 0000 0000  .....q...4Vx....
	0x0020:  0000 0000 0161 8100 9627 0442 001c 8d54  .....a...'.B...T
	0x0030:  c75b cf4c 0200 0809 0a0b 0c0d 0e0f 1011  .[.L............
	0x0040:  1213 1415 1617 1819 1a1b 1c1d 1e1f 2021  ...............!
	0x0050:  2223 2425 2627 2829 2a2b 2c00 0000 0000  "#$%&'()*+,.....
	0x0060:  0000 0000 0000                           ......
16:26:06.152282 IEEE 802.15.4 Data packet 
	0x0000:  6a00 092f e33a fd00 1234 5678 0000 0000  j../.:...4Vx....
	0x0010:  0000 0000 0161 fd00 1234 5678 0000 0000  .....a...4Vx....
	0x0020:  0000 0000 0171 8000 06f4 0442 001d 8e54  .....q.....B...T
	0x0030:  c75b 6352 0200 0809 0a0b 0c0d 0e0f 1011  .[cR............
	0x0040:  1213 1415 1617 1819 1a1b 1c1d 1e1f 2021  ...............!
	0x0050:  2223 2425 2627 2829 2a2b 2c2d 2e2f 3031  "#$%&'()*+,-./01
	0x0060:  3233 3435 3637                           234567
16:26:06.167591 IEEE 802.15.4 Data packet 
	0x0000:  6a00 069a f03a fd00 1234 5678 0000 0000  j....:...4Vx....
	0x0010:  0000 0000 0171 fd00 1234 5678 0000 0000  .....q...4Vx....
	0x0020:  0000 0000 0161 8100 0121 0442 001d 8e54  .....a...!.B...T
	0x0030:  c75b 6352 0200 0809 0a0b 0c0d 0e0f 1011  .[cR............
	0x0040:  1213 1415 1617 1819 1a1b 1c1d 1e1f 2021  ...............!
	0x0050:  2223 2425 2627 2829 2a2b 2c00 0000 0000  "#$%&'()*+,.....
	0x0060:  0000 0000 0000                           ......
And from RP2:

Code:
pi@raspberrypi:~ $ sudo tcpdump -i wpan0
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on wpan0, link-type IEEE802_15_4_NOFCS (IEEE 802.15.4 without FCS), capture size 262144 bytes
16:26:05.152328 IEEE 802.15.4 Data packet 
	0x0000:  6a00 092f e33a fd00 1234 5678 0000 0000  j../.:...4Vx....
	0x0010:  0000 0000 0161 fd00 1234 5678 0000 0000  .....a...4Vx....
	0x0020:  0000 0000 0171 8000 9bfa 0442 001c 8d54  .....q.....B...T
	0x0030:  c75b cf4c 0200 0809 0a0b 0c0d 0e0f 1011  .[.L............
	0x0040:  1213 1415 1617 1819 1a1b 1c1d 1e1f 2021  ...............!
	0x0050:  2223 2425 2627 2829 2a2b 2c00 0000 0000  "#$%&'()*+,.....
	0x0060:  0000 0000 0000                           ......
16:26:05.152480 IEEE 802.15.4 Data packet 
	0x0000:  6a00 069a f03a fd00 1234 5678 0000 0000  j....:...4Vx....
	0x0010:  0000 0000 0171 fd00 1234 5678 0000 0000  .....q...4Vx....
	0x0020:  0000 0000 0161 8100 9627 0442 001c 8d54  .....a...'.B...T
	0x0030:  c75b cf4c 0200 0809 0a0b 0c0d 0e0f 1011  .[.L............
	0x0040:  1213 1415 1617 1819 1a1b 1c1d 1e1f 2021  ...............!
	0x0050:  2223 2425 2627 2829 2a2b 2c00 0000 0000  "#$%&'()*+,.....
	0x0060:  0000 0000 0000                           ......
16:26:06.155346 IEEE 802.15.4 Data packet 
	0x0000:  6a00 092f e33a fd00 1234 5678 0000 0000  j../.:...4Vx....
	0x0010:  0000 0000 0161 fd00 1234 5678 0000 0000  .....a...4Vx....
	0x0020:  0000 0000 0171 8000 06f4 0442 001d 8e54  .....q.....B...T
	0x0030:  c75b 6352 0200 0809 0a0b 0c0d 0e0f 1011  .[cR............
	0x0040:  1213 1415 1617 1819 1a1b 1c1d 1e1f 2021  ...............!
	0x0050:  2223 2425 2627 2829 2a2b 2c00 0000 0000  "#$%&'()*+,.....
	0x0060:  0000 0000 0000                           ......
16:26:06.155490 IEEE 802.15.4 Data packet 
	0x0000:  6a00 069a f03a fd00 1234 5678 0000 0000  j....:...4Vx....
	0x0010:  0000 0000 0171 fd00 1234 5678 0000 0000  .....q...4Vx....
	0x0020:  0000 0000 0161 8100 0121 0442 001d 8e54  .....a...!.B...T
	0x0030:  c75b 6352 0200 0809 0a0b 0c0d 0e0f 1011  .[cR............
	0x0040:  1213 1415 1617 1819 1a1b 1c1d 1e1f 2021  ...............!
	0x0050:  2223 2425 2627 2829 2a2b 2c00 0000 0000  "#$%&'()*+,.....
	0x0060:  0000 0000 0000                           ......
As it can be seen on the output from tcpdump on RP1 and RP2, pings leave RP1 with the right sequence starting at byte 0x0036 (0809 0a0b 0c0d ... 3233 3435 3637), but when they arrive at RP2 the last few bytes are all zeros. I then tried pinging with fewer bytes with:

Code:
ping fd00:1234:5678::171 -s 45
And it seems like the maximum ping length it can consistently and reliably do is 45 bytes (53 total with the other bytes the ping adds). My initial thought was that perhaps lowering the SPI frequency at which the raspberry communicates with the radio module could solve the problem, but after doing so and sending pings from RP1 to RP2, the last few bytes just went from being all zeros to another sequence that consistently appears at the end of every ping that returns to RP1.

tcpdump on RP1:

Code:
pi@raspberrypi:~ $ sudo tcpdump -i wpan0
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on wpan0, link-type IEEE802_15_4_NOFCS (IEEE 802.15.4 without FCS), capture size 262144 bytes
17:04:35.990921 IEEE 802.15.4 Data packet 
	0x0000:  6a00 084e 4a3a fd00 1234 5678 0000 0000  j..NJ:...4Vx....
	0x0010:  0000 0000 0161 fd00 1234 5678 0000 0000  .....a...4Vx....
	0x0020:  0000 0000 0171 8000 084a 041d 0017 935d  .....q...J.....]
	0x0030:  c75b 501e 0f00 0809 0a0b 0c0d 0e0f 1011  .[P.............
	0x0040:  1213 1415 1617 1819 1a1b 1c1d 1e1f 2021  ...............!
	0x0050:  2223 2425 2627 2829 2a2b 2c2d 2e2f 3031  "#$%&'()*+,-./01
	0x0060:  3233 3435 3637                           234567
17:04:36.016204 IEEE 802.15.4 Data packet 
	0x0000:  6a00 047c 9e3a fd00 1234 5678 0000 0000  j..|.:...4Vx....
	0x0010:  0000 0000 0171 fd00 1234 5678 0000 0000  .....q...4Vx....
	0x0020:  0000 0000 0161 8100 0277 041d 0017 935d  .....a...w.....]
	0x0030:  c75b 501e 0f00 0809 0a0b 0c0d 0e0f 1011  .[P.............
	0x0040:  1213 1415 1617 1819 1a1b 1c1d 1e1f 2021  ...............!
	0x0050:  2223 2425 2627 2829 2a2b 2c01 3201 3101  "#$%&'()*+,.2.1.
	0x0060:  3001 30bf 3500                           0.0.5.
17:04:36.991550 IEEE 802.15.4 Data packet 
	0x0000:  6a00 084e 4a3a fd00 1234 5678 0000 0000  j..NJ:...4Vx....
	0x0010:  0000 0000 0161 fd00 1234 5678 0000 0000  .....a...4Vx....
	0x0020:  0000 0000 0171 8000 9046 041d 0018 945d  .....q...F.....]
	0x0030:  c75b c720 0f00 0809 0a0b 0c0d 0e0f 1011  .[..............
	0x0040:  1213 1415 1617 1819 1a1b 1c1d 1e1f 2021  ...............!
	0x0050:  2223 2425 2627 2829 2a2b 2c2d 2e2f 3031  "#$%&'()*+,-./01
	0x0060:  3233 3435 3637                           234567
17:04:37.018686 IEEE 802.15.4 Data packet 
	0x0000:  6a00 047c 9e3a fd00 1234 5678 0000 0000  j..|.:...4Vx....
	0x0010:  0000 0000 0171 fd00 1234 5678 0000 0000  .....q...4Vx....
	0x0020:  0000 0000 0161 8100 8a73 041d 0018 945d  .....a...s.....]
	0x0030:  c75b c720 0f00 0809 0a0b 0c0d 0e0f 1011  .[..............
	0x0040:  1213 1415 1617 1819 1a1b 1c1d 1e1f 2021  ...............!
	0x0050:  2223 2425 2627 2829 2a2b 2c01 3201 3101  "#$%&'()*+,.2.1.
	0x0060:  3001 30bf 3500                           0.0.5.
tcpdump on RP2:

Code:
pi@raspberrypi:~ $ sudo tcpdump -i wpan0
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on wpan0, link-type IEEE802_15_4_NOFCS (IEEE 802.15.4 without FCS), capture size 262144 bytes
17:04:36.011400 IEEE 802.15.4 Data packet 
	0x0000:  6a00 084e 4a3a fd00 1234 5678 0000 0000  j..NJ:...4Vx....
	0x0010:  0000 0000 0161 fd00 1234 5678 0000 0000  .....a...4Vx....
	0x0020:  0000 0000 0171 8000 084a 041d 0017 935d  .....q...J.....]
	0x0030:  c75b 501e 0f00 0809 0a0b 0c0d 0e0f 1011  .[P.............
	0x0040:  1213 1415 1617 1819 1a1b 1c1d 1e1f 2021  ...............!
	0x0050:  2223 2425 2627 2829 2a2b 2c00 0000 0000  "#$%&'()*+,.....
	0x0060:  0000 0000 0000                           ......
17:04:36.011551 IEEE 802.15.4 Data packet 
	0x0000:  6a00 047c 9e3a fd00 1234 5678 0000 0000  j..|.:...4Vx....
	0x0010:  0000 0000 0171 fd00 1234 5678 0000 0000  .....q...4Vx....
	0x0020:  0000 0000 0161 8100 0277 041d 0017 935d  .....a...w.....]
	0x0030:  c75b 501e 0f00 0809 0a0b 0c0d 0e0f 1011  .[P.............
	0x0040:  1213 1415 1617 1819 1a1b 1c1d 1e1f 2021  ...............!
	0x0050:  2223 2425 2627 2829 2a2b 2c00 0000 0000  "#$%&'()*+,.....
	0x0060:  0000 0000 0000                           ......
17:04:37.013560 IEEE 802.15.4 Data packet 
	0x0000:  6a00 084e 4a3a fd00 1234 5678 0000 0000  j..NJ:...4Vx....
	0x0010:  0000 0000 0161 fd00 1234 5678 0000 0000  .....a...4Vx....
	0x0020:  0000 0000 0171 8000 9046 041d 0018 945d  .....q...F.....]
	0x0030:  c75b c720 0f00 0809 0a0b 0c0d 0e0f 1011  .[..............
	0x0040:  1213 1415 1617 1819 1a1b 1c1d 1e1f 2021  ...............!
	0x0050:  2223 2425 2627 2829 2a2b 2c00 0000 0000  "#$%&'()*+,.....
	0x0060:  0000 0000 0000                           ......
17:04:37.013691 IEEE 802.15.4 Data packet 
	0x0000:  6a00 047c 9e3a fd00 1234 5678 0000 0000  j..|.:...4Vx....
	0x0010:  0000 0000 0171 fd00 1234 5678 0000 0000  .....q...4Vx....
	0x0020:  0000 0000 0161 8100 8a73 041d 0018 945d  .....a...s.....]
	0x0030:  c75b c720 0f00 0809 0a0b 0c0d 0e0f 1011  .[..............
	0x0040:  1213 1415 1617 1819 1a1b 1c1d 1e1f 2021  ...............!
	0x0050:  2223 2425 2627 2829 2a2b 2c00 0000 0000  "#$%&'()*+,.....
	0x0060:  0000 0000 0000                           ......

That's the point when i realized i had no idea what was going on or how get the packets to be transmitted and received without errors. Perhaps the kernel i am using has some bugs that will get solved if i compile a new one myself or if i use a newer one, or perhaps i am missing some important configuration.

I really appreciate any kind of help you can provide, thanks in advance.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Raspberry Pi not receiving packets > 1472 Bytes ruffy91 Linux - Networking 3 09-26-2018 01:08 PM
ntpd sending IPv6 packets with source link-local, destination global? psycroptic Linux - Networking 2 02-08-2015 07:39 PM
What are the limitations of 802.15.4/6LOWPAN in Linux kernal? tanusri.roy12@gmail.com Linux - Newbie 1 07-28-2014 03:58 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 11:52 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration