Skip to content

at86rf2xx: do not set src pan compression on init#5759

Closed
cgundogan wants to merge 2 commits intoRIOT-OS:masterfrom
cgundogan:pr/at86rf2xx/src_comp
Closed

at86rf2xx: do not set src pan compression on init#5759
cgundogan wants to merge 2 commits intoRIOT-OS:masterfrom
cgundogan:pr/at86rf2xx/src_comp

Conversation

@cgundogan
Copy link
Copy Markdown
Member

@cgundogan cgundogan commented Aug 18, 2016

Depends on #5525 #5685

Currently, the at86rf2xx driver sets the src pan compression on initialization. Doing this when building the 802.15.4 header instead (like e.g. proposed by @aeneby in #5525 #5685 ) is more dynamic, so that the flag is still set/unset correctly iff the pan id changes.

aeneby and others added 2 commits August 18, 2016 14:22
According to section 7.5.6.1 of 802.15.4-2003, packets destined for
the same PAN from which they were sent must have their intra-PAN
flag set, and the source PAN omitted from the transmitted frame.
@cgundogan cgundogan added Area: network Area: Networking Area: drivers Area: Device drivers labels Aug 18, 2016
@miri64
Copy link
Copy Markdown
Member

miri64 commented Aug 18, 2016

Do you mean #5685? Also: What happens if the flag is set?

@cgundogan
Copy link
Copy Markdown
Member Author

yes #5685

Also: What happens if the flag is set?

Can you rephrase? The flag is set by default currently and this leads to the src pan being compressed (elided from the header). This is no problem for now (and correct), because there is no case where ieee802154_set_Frame_hdr() is called with different src and dst pans (https://github.com/RIOT-OS/RIOT/blob/master/sys/net/gnrc/link_layer/netdev2/gnrc_netdev2_ieee802154.c#L185).

iff ieee802154_set_Frame_hdr() gets called with different pan ids in the future, then this flag must be unset (this is still missing in #5685 )

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

miri64 commented Aug 18, 2016

You unset it, yes. But what happens now, if someone sets it later on?

@cgundogan
Copy link
Copy Markdown
Member Author

You unset it, yes. But what happens now, if someone sets it later on?

If you set it later, then you have the same functionality as before.

@cgundogan
Copy link
Copy Markdown
Member Author

as a side note, NETDEV2_IEEE802154_PAN_COMP does not correspond to a register of the device.

@aeneby
Copy link
Copy Markdown
Member

aeneby commented Aug 19, 2016

I don't really understand how PAN compression is relevant to the driver at all... is the NETDEV2_IEEE802154_PAN_COMP flag even necessary?

@miri64
Copy link
Copy Markdown
Member

miri64 commented Aug 19, 2016

I don't really understand how PAN compression is relevant to the driver at all... is the NETDEV2_IEEE802154_PAN_COMP flag even necessary?

If src_pan == dst_pan but the compression shouldn't be used eg. I already had the problem, that there is a bug in lwIP that it just ignores that bit and always skips the source PAN.

@aeneby
Copy link
Copy Markdown
Member

aeneby commented Aug 19, 2016

If src_pan == dst_pan but the compression shouldn't be used

That would be an invalid frame though, according to the 802.15.4 spec.

@miri64
Copy link
Copy Markdown
Member

miri64 commented Aug 19, 2016

Yes, but for Interop its sometimes necessary to provide behavior beyond the spec until a bug is fixed ;-) (I don't say that its not wrong, just that lwIP is doing it wrong atm).

@aeneby
Copy link
Copy Markdown
Member

aeneby commented Aug 19, 2016

I don't really know enough about lwIP to comment, but if lwIP is doing it wrong then it needs to be fixed in lwIP, not broken in RIOT - two wrongs don't make a right :)

@thomaseichinger
Copy link
Copy Markdown
Member

If src_pan == dst_pan but the compression shouldn't be used

That would be an invalid frame though, according to the 802.15.4 spec.

@aeneby Could you point me to where in the 802.15.4 spec this is specified? Or which version of 802.15.4? As far as I read point 5.2.1.1.5 it is possible to have the two PAN IDs set to the same value without the need to use compression.

@aeneby
Copy link
Copy Markdown
Member

aeneby commented Aug 19, 2016

@thomaseichinger, you have a point. In the 2003 spec it was quite clear, since it was called the "Intra-PAN" field. With this definition, it simply doesn't make sense to have src and dst PANs the same without this bit being set (and therefore the src PAN removed). However in the 2011 spec, the name has changed to "PAN ID Compression" field, even though the functional definition remains basically the same. I guess this would allow Intra-PAN packets to be sent with both src and dst PANs specified, according to the semantic definition of this field...?

Now I'm not 100% sure, I will think over it.

@miri64
Copy link
Copy Markdown
Member

miri64 commented Aug 19, 2016

@aeneby

I don't really know enough about lwIP to comment, but if lwIP is doing it wrong then it needs to be fixed in lwIP, not broken in RIOT - two wrongs don't make a right :)

I agree with you and I finally came around to open an issue on the lwIP side, but I know enough about lwIP to say that changes to mainline are quite slow (6lowpan took 1.5 years to get to master, my issue about the incorrect fragmentation [a very pressing issue] is still open after ~6 month and the last non-RC release was nearly 4 years ago). So as a workaround I would still have this kind of option provided (in case they provide the fragmentation fix first ^^).

@thomaseichinger, you have a point. In the 2003 spec it was quite clear, since it was called the "Intra-PAN" field. With this definition, it simply doesn't make sense to have src and dst PANs the same without this bit being set (and therefore the src PAN removed). However in the 2011 spec, the name has changed to "PAN ID Compression" field, even though the functional definition remains basically the same. I guess this would allow Intra-PAN packets to be sent with both src and dst PANs specified, according to the semantic definition of this field...?

Now I'm not 100% sure, I will think over it.

To me it reads that the compression is basically optional. Yes it makes sense to compress the source PAN away if it is identical, but I wouldn't say its completely wrong to include it regardless.

@thomaseichinger
Copy link
Copy Markdown
Member

Referencing the 2011 802.15.4 spec

5.2.1.1.5 PAN ID Compression field
The PAN ID Compression field specifies whether the MAC frame is to be sent containing only one of the PAN identifier fields when both source and destination addresses are present. If this field is set to one and both the source and destination addresses are present, the frame shall contain only the Destination PAN Identifier field, and the Source PAN Identifier field shall be assumed equal to that of the destination. If this field is set to zero, then the PAN Identifier field shall be present if and only if the corresponding address is present.

I think the argumentation is just the other way around. If the bit is set there must only be one PAN ID while there are no rules constraining the usage of PAN IDs if the bit is not set. At least in the 2011 version. (I also didn't get my hands on the most recent 2015 version yet.)

The interesting part I think is however, as, at least the at86rf231, to my knowledge implements IEEE 802.15.4 2006, how behavior of the hardware frame filters looks like in that case. (I don't have the 2006 version around right now.)

@miri64
Copy link
Copy Markdown
Member

miri64 commented Aug 19, 2016

(to be clear: the faulty behavior of lwIP in my eyes is that they completely ignore the compression bit, not that they include the source PAN, even if it is identical to the destination PAN).

@thomaseichinger
Copy link
Copy Markdown
Member

@miri64 This is undisputed and the discussion not necessarily prevents from moving forward with this PR as AFAIK RIOT should be able to deal with two same PAN IDs anyways.

@miri64
Copy link
Copy Markdown
Member

miri64 commented Aug 19, 2016

@miri64 This is undisputed and the discussion not necessarily prevents from moving forward with this PR as AFAIK RIOT should be able to deal with two same PAN IDs anyways.

But #5685 takes away this option.

@thomaseichinger
Copy link
Copy Markdown
Member

@miri64 I think it's totally standard conform if RIOT does PAN ID compression, my note was more about the receiving side. RIOT should be able to process a frame that doesn't have the compression bit set and two identical PAN IDs.

@aeneby
Copy link
Copy Markdown
Member

aeneby commented Aug 19, 2016

After doing some careful reading, here is my interpretation (I'll try to stay relevant to this PR):

  • According to the 802.15.4-2003 spec, any frame with identical source and destination PANs is invalid
  • In the 802.15.4-2011 spec, the meaning of the field has changed; it is valid, albeit wasteful, for a frame to contain identical source and destination PANs
  • In the 802.15.4-2015 spec... who knows, because I don't enjoy reading standards documents enough to pay ~$400 for the privilege. Does anyone have access to this?

What does this mean for this PR?

  • It does in fact make some sense to have the NETDEV2_IEEE802154_PAN_COMP flag since, in theory at least, it's valid to send intra-PAN packets without using PAN compression
  • In practice though, I don't see why you would ever want to do this. Doesn't that mean this should be left as true by default?
  • While ieee802154: Set intra-PAN flag for packets where src/dst PANs match #5685 does enforce the only really sensible behaviour, strictly speaking it is perhaps wrong to do so - we should not be modifying this flag based on src and dst PANs, but rather using this flag to determine what to do if the src and dst PANs are the same (compress or not compress)

The main issue is that, since each version of the 802.15.4 supersedes the ones before it, 802.15.4-2015 should be the one we are following. So there is still a missing piece of the puzzle here.

@aeneby
Copy link
Copy Markdown
Member

aeneby commented Aug 19, 2016

RIOT should be able to process a frame that doesn't have the compression bit set and two identical PAN IDs.

According to my interpretation of the 2011 spec, yes, this is correct. Interesting to note though that Linux will drop such frames.

@aeneby
Copy link
Copy Markdown
Member

aeneby commented Aug 22, 2016

See #5685 (comment).

So in short, it looks like frames with identical src and dst PAN IDs are invalid again in the 2015 spec. Further, it's clear that the MAC layer should be automatically handling PAN ID compression. So actually, provided the linked text is accurate, I don't see any reason for the NETDEV2_IEEE802154_PAN_COMP flag to exist at all.

at86rf2xx_set_txpower(dev, AT86RF2XX_DEFAULT_TXPOWER);
/* set default options */
at86rf2xx_set_option(dev, NETDEV2_IEEE802154_PAN_COMP, true);
at86rf2xx_set_option(dev, NETDEV2_IEEE802154_PAN_COMP, false);
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.

If this option is ignored anyway, shouldn't the code for at86rf2xx_set_option be disabled anyway?

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.

For this option I mean.

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.

@miri64 I think you're right. There is no explicit implementation behind this option, so simply removing this line would probably be the most logical thing?

@PeterKietzmann
Copy link
Copy Markdown
Member

How about me use this PR just for removing at86rf2xx_set_option(dev, NETDEV2_IEEE802154_PAN_COMP, false); from the driver and handle the rest in #5685

@miri64
Copy link
Copy Markdown
Member

miri64 commented Sep 26, 2016

@PeterKietzmann +1


if (dst_pan.u16 == src_pan.u16) {
flags |= IEEE802154_FCF_PAN_COMP;
}
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.

@miri64
Copy link
Copy Markdown
Member

miri64 commented Sep 30, 2016

Alternative in #5897

@cgundogan
Copy link
Copy Markdown
Member Author

No objection to close once #5897 is merged.

@PeterKietzmann
Copy link
Copy Markdown
Member

Closing in favour of #5897.

@cgundogan cgundogan deleted the pr/at86rf2xx/src_comp branch October 4, 2016 09:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: drivers Area: Device drivers Area: network Area: Networking State: waiting for other PR State: The PR requires another PR to be merged first

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants