Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

6LoWPAN over BLE (RFC7668) #1031

Open
Dominaezzz opened this issue Jan 12, 2025 · 7 comments
Open

6LoWPAN over BLE (RFC7668) #1031

Dominaezzz opened this issue Jan 12, 2025 · 7 comments

Comments

@Dominaezzz
Copy link

I'm looking at implementing this with an ESP32 and trouble.

From reading various RFCs it seems to be a somewhat straightforward affair.
One just needs a L2CAP channel and a minimal GATT service for advertising, which trouble supports.

The network forms a star topology where the "Central" is the router and the "Peripheral"s are nodes in the network.
All communications between nodes/peripherals happen via the router/central.
Central is responsible for connecting to nodes advertising themselves as nodes.
Each node (including the router) has a link-local IPv6 address derived from the BLE mac address, but can still register additional non-link-local addresses using standard IPv6 protocols like Neighbour Solicitation (NS).

The L2CAP channel takes care throttling (with the credits system) and disassembly/re-assembly.

The IPv6 headers sent over BLE are compressed in the same format used for IEEE 802.15.4, but the conditions for when to compress are different.

Multicast is an O(n) operation (where n is the number of nodes) rather than a O(1) operation, due to the star topology.

I've mostly gotten the mac logic down, I just need a networking stack to handle the networking.

I looked into implementing the Device trait and I'm trying to figure out which medium to use. Do I need to PR a BLE medium or can I just use the Ip medium.

I'm still trying to figure out if I need to modify smoltcp to work with BLE or if I can do it all behind the Device trait.

@Dominaezzz
Copy link
Author

From discussions over Matrix with @Dirbaio it appears I just need a new medium for 6LowPan without ieee802154 headers, this can then be shipped over the L2CAP channel.

I just need to figure out if the IPv6 header compression is similar enough to just work on BLE as well

@Dominaezzz
Copy link
Author

  • The IPHC wire file needs to have ieee802154 removed from it. Not sure what the protocol-agnostic replacement is yet, maybe it could be generic. Or a EUI64 perhaps.

@thvdveld
Copy link
Contributor

We should indeed rewrite parts of the wire IPHC file. The rules differ quite a lot for compression and decompression of the source and destination address, and only using an EUI64 address will not be enough. For example, for IEEE 802.15.4, the compression is based on the use of the short link layer address, the extended link layer address, or the use of the EUI64 address, while this is not the case for BLE.

Also note that Neighbor Discovery Optimization for 6LoWPAN is not implemented yet (https://datatracker.ietf.org/doc/html/rfc6775), which defines how to handle the 6LoWPAN Context Option. This option MUST be used by the 6LBR when sending a Router Advertisement. However, we are not able yet to process it.

As @Dirbaio says, we need a new medium that only uses 6LoWPAN compression and adapt the compression and decompression for the source and destination address.

@thvdveld thvdveld changed the title 6LowPan over BLE (RFC7668) 6LoWPan over BLE (RFC7668) Jan 13, 2025
@thvdveld thvdveld changed the title 6LoWPan over BLE (RFC7668) 6LoWPAN over BLE (RFC7668) Jan 13, 2025
@Dominaezzz
Copy link
Author

Given the compression differs between the 6LoWPAN mediums, does a 6LoWPAN medium actually make sense by itself?
How would a Device let smol know which compression scheme to use?

@thvdveld
Copy link
Contributor

We can do that by using the device capabilities.
https://github.com/smoltcp-rs/smoltcp/blob/main/src/phy/mod.rs#L232-L275

@Dominaezzz
Copy link
Author

Sure but in that case the medium would have to be BLE, not 6LoWPAN.

Unless you're thinking Medium::Sixlowpan(Compression::Ble)

@Dominaezzz
Copy link
Author

After some more reading I've figured out what changes need to be made to the iphc file.
We basically need something like UnresolvedAddress to replace the use of ieee802154::Address in Repr.
I'll try making a PR for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants