Skip to content

native: add 802.15.4 raw driver#5582

Closed
alexaring wants to merge 6 commits intoRIOT-OS:masterfrom
linux-wpan:802154_raw
Closed

native: add 802.15.4 raw driver#5582
alexaring wants to merge 6 commits intoRIOT-OS:masterfrom
linux-wpan:802154_raw

Conversation

@alexaring
Copy link
Copy Markdown

@alexaring alexaring commented Jun 29, 2016

This pull-request adds a raw802154 driver to native board functionality.

With this driver you can run the RIOT stack on 802.15.4 Linux interfaces.
In general the basic idea is to run on monitor interfaces to test Linux 802.15.4 stack with RIOT and have some way to easily reproduce issues by running RIOT in userspace. For this use-case the Linux kernel has a virtual phy driver named "fakelb".

Furthermore it could be possible to run on normal wpan "node" interfaces as well. It should be possible if mac address settings are equal with the RIOT mac address settings. Nevertheless this needs more logic with netlink nl802154 interface and it will not work right now, because receiving expects FCS which is not available on node interfaces (again needs additional nl802154 handling).

Note: because other issues wireshark expects a FCS while sending on monitor interfaces, but there is none. Frames will be marked as corrupted but they are still correct.
To sniff the traffic, create one "wpan phy" interface more and run them as monitor (without running RIOT-OS stack on it.)

Please note also, that you can't run multiple RIOT-OS instances on one interface, it need always a separate phy. This is because we don't send frames back on a phy which actually transmit them.

At least, you need 1-2 patches which are currently on linux-wpan mailinglist http://www.spinics.net/lists/linux-wpan to make the full stuff working with fakelb driver, on other driver with monitor interface (e.g. at86rf230) it should be possible. I didn't test it with real hardware because I saw other issues to cross compile native board and when I had a cross compiled version for my arm device it didn't work because some not working assembler code. :-)

Here are the steps how to use it (with monitor interface for sniffing):

modprobe fakelb numlbs=3

ip link add link wpan0 name lowpan0 type lowpan
iwpan dev wpan0 set pan_id 0x23
ip link set wpan0 up
ip link set lowpan0 up

iwpan dev wpan1 del
iwpan phy1 interface add riot0 type monitor
ip link set riot0 up

iwpan dev wpan2 del
iwpan phy2 interface add monitor0 type monitor
ip link set monitor0 up

Starting native gnrc_networking example:

gnrc_networking.elf -r riot0 -ra

Sniffing example:

run wireshark on monitor0 interface.

Alexander Aring added 6 commits June 28, 2016 17:16
The tap interface is compile time optional currenlty. This patch makes
the tap interface runtime optional and handle it as usually argument.

Note: Documentation need to be updated for new command argument.

Signed-off-by: Alexander Aring <[email protected]>
The raw802154 driver needs to generate random data for a possible random
extended address generation. This patch allows to init hwrng twice in
case of using hwrng unit-tests and raw802154 driver.

Signed-off-by: Alexander Aring <[email protected]>
This patch moves the continue_reading to the async file api. The
raw802154 driver needs such function as well, so we move it to a shared
place.

Signed-off-by: Alexander Aring <[email protected]>
The raw802154 driver use also the async file api. This patch moves the
async file api init to startup to init the file api once.

Signed-off-by: Alexander Aring <[email protected]>
The raw802154 uses AF_PACKET SOCK_RAW api. To have some cleaner cleanup
routine which shutdown the socket before close, this patch adds such
wrapper to handle it.

Signed-off-by: Alexander Aring <[email protected]>
This patch adds the raw802154 driver to RIOT. The idea is to run of top
of an 802.15.4 monitor interface. This interface can be run on any driver,
for virtual testing the linux-wpan "fakelb" driver can be used.

There exists unsolved issues like acknowledge handling which isn't
supported right now.

Example to setup:

modprobe fakelb numlbs=2

ip link add link wpan0 name lowpan0 type lowpan
iwpan dev wpan0 set pan_id 0x23
ip link set wpan0 up
ip link set lowpan0 up

iwpan dev wpan1 del
iwpan phy1 interface add riot0 type monitor

ip link set riot0 up

Starting native gnrc_networking example:

gnrc_networking.elf -r riot0 -ra

After that you are able to run ping/etc between riot and linux stack.

Signed-off-by: Alexander Aring <[email protected]>
@Kijewski Kijewski changed the title Add native 802.15.4 raw driver native: add 802.15.4 raw driver Jun 29, 2016
@miri64 miri64 added Platform: native Platform: This PR/issue effects the native platform Area: network Area: Networking labels Jul 4, 2016
@miri64
Copy link
Copy Markdown
Member

miri64 commented Jul 4, 2016

Awesome!

@LudwigKnuepfer
Copy link
Copy Markdown
Member

I would love to test and review this but I am not certain I can manage to find enough time.

netdev2_tap_params_t p;
p.tap_name = &(argv[1]);
netdev2_tap_setup(&netdev2_tap, &p);
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a semantic change here in that the interface is optional now. It was a positional parameter before because a network application can't run without it.
If there is good reason (other than personal preference) to discard the positional parameter please explain.

@LudwigKnuepfer
Copy link
Copy Markdown
Member

I have quickly looked at all but the *netdev* files and they look good apart from what I commented on.

@miri64 reassigning to you for netdev related review. I'll keep reading here, though.

@miri64
Copy link
Copy Markdown
Member

miri64 commented Aug 5, 2016

Needs rebase (and probably some syncing with #5614). Also addressing of @LudwigKnuepfer's comments would be appreciated :-)

@alexaring
Copy link
Copy Markdown
Author

Syncing with #5614 : go ahead and apply this at first. I will rebase and try to adapt these changes to this driver. Would be nice if #5614 can care about that the tap device can be optional during runtime.

@miri64
Copy link
Copy Markdown
Member

miri64 commented Aug 5, 2016

go ahead and apply this at first.

Please rephrase, I'm not sure I understood.

Would be nice if #5614 can care about that the tap device can be optional during runtime.

Please provide a suggestion for this in #5614.

@alexaring
Copy link
Copy Markdown
Author

It's fine for me to apply #5614 at first, then I will try to adapt these changes to raw802154 driver so we could also add multiple raw802154 instances.

@miri64
Copy link
Copy Markdown
Member

miri64 commented Aug 5, 2016

kk, so you will rebase this PR to #5614?

@alexaring
Copy link
Copy Markdown
Author

Yes, I think this makes sense. I grab many code from tap stuff. So I would wait for great new features for the tap interfaces (have multiple of them) and make the same for raw802154 driver.

@miri64 miri64 added the State: waiting for other PR State: The PR requires another PR to be merged first label Aug 5, 2016
@miri64
Copy link
Copy Markdown
Member

miri64 commented Aug 5, 2016

Okay, then I label this PR as such ;-)

@miri64 miri64 added the State: WIP State: The PR is still work-in-progress and its code is not in its final presentable form yet label Aug 5, 2016
@miri64
Copy link
Copy Markdown
Member

miri64 commented Sep 26, 2016

Needs rebase.

@miri64
Copy link
Copy Markdown
Member

miri64 commented Jan 10, 2017

@alexaring ping?

1 similar comment
@miri64
Copy link
Copy Markdown
Member

miri64 commented Mar 16, 2017

@alexaring ping?

@alexaring
Copy link
Copy Markdown
Author

alexaring commented Mar 16, 2017

Sorry, currently write my thesis and have no time to working on it.

While my thesis I improved the fakelb phy stuff so you can generate easily mesh networks.
Future work: some GUI to make random/manual meshes and start RIOT or Linux or OpenThread on nodes which you want!

I have a talk about that at netdev and will report also about stupid MLE stituation which we currently have.
Here is the Link for the virtual mesh stuff:

http://netdevconf.org/2.1/news.html?news-aring-talk

After that I will look how I bring these things all upstream and I have time maybe mid of April. :-/

@jia200x
Copy link
Copy Markdown
Member

jia200x commented Apr 15, 2017

@alexaring please inform me when this PR is finished. It will be very useful for #5552 .
Cheers!

@miri64
Copy link
Copy Markdown
Member

miri64 commented Apr 15, 2017

@jia200x have you seen #6121? It's basically doing the same thing, just without root and over an adaption layer protocol.

@alexaring
Copy link
Copy Markdown
Author

alexaring commented Apr 17, 2017

well, if you run it on a virtual machine then you don't need root rights on a host pc.
This is what I used in my setup with a crazy nfsroot setup to host pc.
@jia200x look at my comment at:
https://groups.google.com/forum/#!msg/openthread-users/BXOk9JfDsqY/L_0p2N-GBgAJ

I cannot send pull-request to openthread code because google CLA, sorry.
In short it allows you a setup with RIOT native connected to OpenThread POSIX plattform.
Be aware channel settings is not currently support (but should be possible) you will listen on the same channel which the linux device class 802.15.4 phy is listen on - the native/posix platform doesn't change the channel yet when you switch it inside the process.


about the adaption layer protocol, what does that mean? Putting 802.15.4 frames in UDP Payload? That was one thing which I want to avoid and offering one kernel UAPI for doing a PHY layer where you have control about how the connections are in a mesh setup.

@beriberikix
Copy link
Copy Markdown

I'd like to bring to your attention our latest project, borderrouter, which targets Linux-based hosts with OpenThread NCPs to allow them to be Thread border routers.

@alexaring I'm curious as to why you cannot submit a PR because of the Google CLA. Any details you can share?

@aabadie aabadie modified the milestone: Release 2017.07 Jun 23, 2017
@miri64
Copy link
Copy Markdown
Member

miri64 commented Nov 15, 2017

about the adaption layer protocol, what does that mean? Putting 802.15.4 frames in UDP Payload? That was one thing which I want to avoid and offering one kernel UAPI for doing a PHY layer where you have control about how the connections are in a mesh setup.

That might help you if we are talking about real deployment, but native is first and foremost our test and demo platform. BTW: Did you find any time to work on this?

@alexaring
Copy link
Copy Markdown
Author

I met some "India kid" \o/ - I have the task to test him that he is able to send patches to linux kernel etc. I will give him these tasks - as well for RIOT native and this driver. Is that okay for you? :-)

@beriberikix what you doing in wpantund scares me and it looks like bluetooth people want to do the same... I guess to avoid GPL license.
I am afraid to sign anything which forbids me afterwards to do open source programming. E.g. I already got the offer to join the Thread Group (I even don't have money for that), but thanks I don't want to sign anything where I get trouble afterwards to put Linux support for it. Last chance is to use openthread and look how it works - makes even more fun for me.

@smlng smlng removed this from the Release 2018.01 milestone Jan 12, 2018
@miri64
Copy link
Copy Markdown
Member

miri64 commented May 29, 2018

Ping @alexaring @beriberikix? I'd really like to test this, but this requires a rebase on your part.

@miri64
Copy link
Copy Markdown
Member

miri64 commented May 29, 2018

Is that okay for you? :-)

Of course it is. As long as the work is done, I don't care who done it ;-)

@tcschmidt tcschmidt requested a review from miri64 May 30, 2018 19:15
@miri64
Copy link
Copy Markdown
Member

miri64 commented Sep 16, 2018

Now that there is #9942, can this be closed then?

@miri64
Copy link
Copy Markdown
Member

miri64 commented Sep 16, 2018

Updated in #9942.

@miri64 miri64 closed this Sep 16, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: network Area: Networking Platform: native Platform: This PR/issue effects the native platform State: waiting for other PR State: The PR requires another PR to be merged first State: WIP State: The PR is still work-in-progress and its code is not in its final presentable form yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants