Skip to content

net/netstats: L1/L2 per neighbor statistics#14448

Merged
benpicco merged 6 commits intoRIOT-OS:masterfrom
benpicco:l2-peerstats-rebased
Feb 9, 2021
Merged

net/netstats: L1/L2 per neighbor statistics#14448
benpicco merged 6 commits intoRIOT-OS:masterfrom
benpicco:l2-peerstats-rebased

Conversation

@benpicco
Copy link
Copy Markdown
Contributor

@benpicco benpicco commented Jul 6, 2020

Contribution description

This is a rebase of a previous PR to add a database for neighborhood metrics.
Those are needed for generating better routes with RPL (MR-HOF #7450).

I think it makes sense to attach this directly to the netifnetdev as originally proposed as those statistics are per-interface anyway.

Only rebase & slight cleanup done so far.

Testing procedure

When running examples/gnrc_networking you should now have a neigh command that prints statistics about neighbors.

Issues/PRs references

taken over from #6873
needed for #14623

@benpicco benpicco added Area: network Area: Networking Type: new feature The issue requests / The PR implemements a new feature for RIOT labels Jul 6, 2020
@benpicco benpicco requested review from bergzand and chrysn July 6, 2020 15:16
@benpicco benpicco marked this pull request as ready for review July 15, 2020 22:23
@benpicco benpicco force-pushed the l2-peerstats-rebased branch from 3087601 to 3e98f6c Compare September 26, 2020 22:14
@benpicco benpicco added the CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR label Sep 26, 2020
@benpicco benpicco force-pushed the l2-peerstats-rebased branch 2 times, most recently from 07c21fa to e199d59 Compare September 26, 2020 22:32
@benpicco benpicco force-pushed the l2-peerstats-rebased branch 2 times, most recently from b6e89b2 to c6a175d Compare October 9, 2020 23:09
@benpicco benpicco removed the CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR label Oct 10, 2020
@benpicco benpicco force-pushed the l2-peerstats-rebased branch from 57db5fe to 582786d Compare October 10, 2020 22:21
@chrysn
Copy link
Copy Markdown
Member

chrysn commented Oct 12, 2020

I've given this a first practical test by adding all the netstats_neighbor_* from the other example to an gnrc_border_router, where the BR is a nrf52840dongle that talks to a particle-xenon and another nrf52840dongle; both leaf nodes were continuously being pinged from upstream, and I varied the transmission properties by moving water containers into the leaf node's near field (ie touched the board).

In the quick test, the LQI and RSSI values were plausible ("-73 dBm 90" -- not great, not terrible). Other data stayed empty (while the received counter went up, sent and average tx time was 0 throughout) until I enabled more netstats (l2, ipv6, rpl) that were already active in the GNRC example -- are they actual dependencies?

ETX stayed at 200% for all links; I presume that'd need additional work for the nrf802154 driver?

When I powered off one of the leaves, its stats stayed constant (with the fresh=16) for minutes, even after I tried pinging them from the netstats board. That's consistent with the 10 minutes default before halving. Is that a good strategy? Allowing radio contact every five minutes for just a few packages to come through suffices to get what appears on the neigh interface to be a perfectly viable link, even though it only works while some door is open.

On the BR node, I'm seeing stats not only for the 6lo interfaces but for all. It's probably not urgent in this initial iteration, but is there a roadmap to not storing practically irrelevant stats there? (CDC-ECM is quite stable ;-) )

@bergzand
Copy link
Copy Markdown
Member

ETX stayed at 200% for all links; I presume that'd need additional work for the nrf802154 driver?

ETX relies on NETOPT_TX_RETRIES_NEEDED. @benpicco I don't want to shove more work on your plate, however do you think you could add an ETX_INVALID value for when the driver doesn't implement the netopt mentioned here? I don't mind if you postpone this to a follow up (not necessarily by you).

@benpicco
Copy link
Copy Markdown
Contributor Author

benpicco commented Oct 12, 2020

ETX stayed at 200% for all links; I presume that'd need additional work for the nrf802154 driver?

Can you try with USEMODULE += netdev_ieee802154_submac and #15208

On the BR node, I'm seeing stats not only for the 6lo interfaces but for all. It's probably not urgent in this initial iteration, but is there a roadmap to not storing practically irrelevant stats there? (CDC-ECM is quite stable ;-) )

Good point!

When I powered off one of the leaves, its stats stayed constant (with the fresh=16) for minutes, even after I tried pinging them from the netstats board. That's consistent with the 10 minutes default before halving. Is that a good strategy? Allowing radio contact every five minutes for just a few packages to come through suffices to get what appears on the neigh interface to be a perfectly viable link, even though it only works while some door is open.

Hmm I must admit that I didn't look much into how the 'freshness' is supposed to be used.
Maybe @bergzand still remembers? 😉

however do you think you could add an ETX_INVALID value for when the driver doesn't implement the netopt mentioned here?

How about just leaving it at 0 and then handling it like LQI and RSSI (if it's 0 set the value directly, otherwise use EWMA).

Then we can always handle 0 as invalid.

In an ideal world, all drivers would already be ported to the sub-mac and then we would fall back to software retransmissions if ETX stats are requested and the hardware does not support reporting them.

@chrysn
Copy link
Copy Markdown
Member

chrysn commented Oct 12, 2020

USEMODULE += netdev_ieee802154_submac and #15208

That makes it go down from 200% to 100% initially (as confidence is gained that the device is there), but levels at 100% even when I observe a loss of around 3% (which in first approximation means 105% ETX) or unplug the device for a minute. Funnily, it even keeps going down to 100% if, after a reboot, it is unplugged when the ETX is around 105%.

@benpicco
Copy link
Copy Markdown
Contributor Author

benpicco commented Oct 12, 2020

Ah retrans always gets re-set after send - try 4871b00.
Although I should probably just use the new ieee802154_tx_info_t.

edit nvm, still reports 0

@benpicco
Copy link
Copy Markdown
Contributor Author

ACKs are not enabled by default with the sub-MAC.
With

ifconfig 6 ack_req

I get the expected results.

Copy link
Copy Markdown
Member

@miri64 miri64 left a comment

Choose a reason for hiding this comment

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

Tested on the IoT-LAB @ Grenoble-Site:

Details
1612547335.027789;m3-102;ifconfig
1612547335.029176;m3-101;ifconfig
1612547335.030352;m3-102;Iface  6  HWaddr: 37:3F  Channel: 26  Page: 0  NID: 0x23  PHY: O-QPSK 
1612547335.030546;m3-102;          
1612547335.030868;m3-101;Iface  6  HWaddr: 1F:60  Channel: 26  Page: 0  NID: 0x23  PHY: O-QPSK 
1612547335.030987;m3-101;          
1612547335.031278;m3-102;          Long HWaddr: BA:D0:5B:74:8D:B9:37:3F 
1612547335.032674;m3-102;           TX-Power: 0dBm  State: IDLE  max. Retrans.: 3  CSMA Retries: 4 
1612547335.033352;m3-101;          Long HWaddr: A6:DA:E9:93:B3:CC:9F:60 
1612547335.033490;m3-101;           TX-Power: 0dBm  State: IDLE  max. Retrans.: 3  CSMA Retries: 4 
1612547335.035965;m3-101;          AUTOACK  ACK_REQ  CSMA  L2-PDU:102  MTU:1280  HL:64  RTR  
1612547335.036167;m3-101;          6LO  IPHC  
1612547335.036388;m3-102;          AUTOACK  ACK_REQ  CSMA  L2-PDU:102  MTU:1280  HL:64  RTR  
1612547335.036494;m3-102;          6LO  IPHC  
1612547335.037185;m3-101;          Source address length: 8
1612547335.037288;m3-101;          Link type: wireless
1612547335.037408;m3-102;          Source address length: 8
1612547335.037503;m3-102;          Link type: wireless
1612547335.038541;m3-102;          inet6 addr: fe80::b8d0:5b74:8db9:373f  scope: link  VAL
1612547335.038802;m3-101;          inet6 addr: fe80::a4da:e993:b3cc:9f60  scope: link  VAL
1612547335.039775;m3-102;          inet6 group: ff02::2
1612547335.039971;m3-102;          inet6 group: ff02::1
1612547335.040149;m3-101;          inet6 group: ff02::2
1612547335.040891;m3-102;          inet6 group: ff02::1:ffb9:373f
1612547335.041004;m3-102;          
1612547335.041320;m3-101;          inet6 group: ff02::1
1612547335.041415;m3-101;          inet6 group: ff02::1:ffcc:9f60
1612547335.041495;m3-101;          
1612547335.042022;m3-102;          Statistics for Layer 2
1612547335.042666;m3-101;          Statistics for Layer 2
1612547335.042759;m3-101;            RX packets 4  bytes 172
1612547335.043137;m3-102;            RX packets 3  bytes 129
1612547335.043234;m3-102;            TX packets 4 (Multicast: 4)  bytes 172
1612547335.044333;m3-101;            TX packets 4 (Multicast: 4)  bytes 172
1612547335.044527;m3-101;            TX succeeded 4 errors 0
1612547335.044702;m3-102;            TX succeeded 4 errors 0
1612547335.045375;m3-101;          Statistics for IPv6
1612547335.045850;m3-102;          Statistics for IPv6
1612547335.045955;m3-102;            RX packets 3  bytes 192
1612547335.046858;m3-101;            RX packets 4  bytes 256
1612547335.047068;m3-102;            TX packets 4 (Multicast: 4)  bytes 256
1612547335.048187;m3-101;            TX packets 4 (Multicast: 4)  bytes 256
1612547335.048414;m3-101;            TX succeeded 4 errors 0
1612547335.048526;m3-101;
1612547335.048719;m3-102;            TX succeeded 4 errors 0
1612547335.048794;m3-102;
neigh
1612547351.945720;m3-101;> neigh
1612547351.945985;m3-102;> neigh
1612547351.947440;m3-101;Neighbor link layer stats:
1612547351.947687;m3-101;L2 address               fresh  etx sent received   rssi  lqi avg tx time
1612547351.947846;m3-102;Neighbor link layer stats:
1612547351.947945;m3-102;L2 address               fresh  etx sent received   rssi  lqi avg tx time
1612547351.950340;m3-102;-------------------------------------------------------------------------
1612547351.952069;m3-101;-------------------------------------------------------------------------
1612547351.952298;m3-101;BA:D0:5B:74:8D:B9:37:3F      5 200%    0        5  -35 dBm 255       0 µs
1612547351.952448;m3-102;A6:DA:E9:93:B3:CC:9F:60      4 200%    0        4  -34 dBm 255       0 µs
m3-101;ping6 fe80::b8d0:5b74:8db9:373f
1612547366.086402;m3-101;> ping6 fe80::b8d0:5b74:8db9:373f
1612547366.095017;m3-101;12 bytes from fe80::b8d0:5b74:8db9:373f%6: icmp_seq=0 ttl=64 rssi=-35 dBm time=6.289 ms
1612547367.097566;m3-101;12 bytes from fe80::b8d0:5b74:8db9:373f%6: icmp_seq=1 ttl=64 rssi=-35 dBm time=8.522 ms
1612547368.097486;m3-101;12 bytes from fe80::b8d0:5b74:8db9:373f%6: icmp_seq=2 ttl=64 rssi=-34 dBm time=8.841 ms
1612547368.097682;m3-101;
1612547368.098759;m3-101;--- fe80::b8d0:5b74:8db9:373f PING statistics ---
1612547368.100137;m3-101;3 packets transmitted, 3 packets received, 0% packet loss
1612547368.101777;m3-101;round-trip min/avg/max = 6.289/7.884/8.841 ms
neigh
1612547372.243304;m3-101;> neigh
1612547372.243608;m3-102;> neigh
1612547372.245013;m3-101;Neighbor link layer stats:
1612547372.246061;m3-101;L2 address               fresh  etx sent received   rssi  lqi avg tx time
1612547372.246288;m3-102;Neighbor link layer stats:
1612547372.246406;m3-102;L2 address               fresh  etx sent received   rssi  lqi avg tx time
1612547372.247064;m3-102;-------------------------------------------------------------------------
1612547372.247222;m3-101;-------------------------------------------------------------------------
1612547372.249026;m3-101;BA:D0:5B:74:8D:B9:37:3F     12 200%    3        9  -35 dBm 255    2958 µs
1612547372.249260;m3-102;A6:DA:E9:93:B3:CC:9F:60     11 200%    3        8  -34 dBm 255    3028 µs

Works like a charm, just some tweaks for "modern RIOT" remaining.

Comment on lines +204 to +212
static inline bool l2util_addr_equal(const uint8_t *addr_a, uint8_t addr_a_len,
const uint8_t *addr_b, uint8_t addr_b_len)
{
if (addr_a_len != addr_b_len) {
return false;
}

return memcmp(addr_a, addr_b, addr_a_len) == 0;
}
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.

A test for this in tests/l2util would be nice, but can be done in a follow-up :-).

miri64
miri64 previously requested changes Feb 8, 2021
Copy link
Copy Markdown
Member

@miri64 miri64 left a comment

Choose a reason for hiding this comment

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

Some last style and code improvement nits remain. Other then that, this ready to merge, so please squash immediately.

@@ -0,0 +1 @@
../driver_netdev_common/main.c No newline at end of file
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.

I like when people know how to use Git features 🙂

@benpicco benpicco force-pushed the l2-peerstats-rebased branch 4 times, most recently from 7946254 to f1c3509 Compare February 8, 2021 19:43
@benpicco
Copy link
Copy Markdown
Contributor Author

benpicco commented Feb 8, 2021

Rebased again to the merge of #15694
Resolved the conflict gnrc_netif _send().

@benpicco benpicco requested a review from maribu February 8, 2021 19:44
@benpicco benpicco force-pushed the l2-peerstats-rebased branch from f1c3509 to 26ec165 Compare February 8, 2021 19:48
@miri64 miri64 dismissed their stale review February 8, 2021 20:25

Soft-ACK from my side. @maribu could you give this one final look regarding the usage of tx_sync in gnrc_netif's _send? Just to be on the save side.

Copy link
Copy Markdown
Member

@maribu maribu left a comment

Choose a reason for hiding this comment

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

looks good to me

@miri64
Copy link
Copy Markdown
Member

miri64 commented Feb 9, 2021

Please squash

@benpicco benpicco force-pushed the l2-peerstats-rebased branch from 58861f6 to cc9c58a Compare February 9, 2021 11:28
Copy link
Copy Markdown
Member

@miri64 miri64 left a comment

Choose a reason for hiding this comment

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

ACK!

@benpicco benpicco merged commit 5fba2c8 into RIOT-OS:master Feb 9, 2021
@benpicco benpicco deleted the l2-peerstats-rebased branch February 9, 2021 13:54
@kaspar030 kaspar030 added this to the Release 2021.04 milestone Apr 23, 2021
@kaspar030 kaspar030 added the Release notes: added Set on PRs that have been processed into the release notes for the current release. label Apr 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: network Area: Networking CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Release notes: added Set on PRs that have been processed into the release notes for the current release. Type: new feature The issue requests / The PR implemements a new feature for RIOT

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants