- About this Manual
- Scope
- Definitions/Abbreviation
- 1 Subsystem Requirements Overview
- 2 Implementation details
- 3 Modules Design
- 3.2 Testing
- 4 Open questions
Rev | Date | Author | Change Description |
---|---|---|---|
0.1 | Mykola Faryma | Initial version |
This document provides general information about the new approach for getting byte, packet rates and port utilization in SONiC.
This document describes the high level design of the feature.
Definitions/Abbreviation | Description |
---|---|
PPS | Packets per second |
BPS | Bytes per second |
UTIL | Port utilization |
FC | Flex counter |
vid | Virtual Object Id - object identifier used in counters DB |
-
Values of BPS, PPS and UTIL should be present in the output of respective show commands by default
-
The values should be calculated over a static period of time
-
User issued clear command should have no impact on the values (see old approach)
-
There will be no conflicts with "counters per user approach" - all users see the same values(immediate rate&utilization)
-
The default interval for rates and utilization is the same as for counters(1s)
-
Th interval for rates and utilization is configurable
No changes in CLI show command output is required.
For interval configuration counterpoll
utility will be extended:
counterpoll [port_rates|rif_rates] interval <seconds>
counterpoll [port_rates|rif_rates] [enable|disable]
To configure the smoothing interval of moving average new CLI will be intrduced:
config rate smoothing_interval [all|port|rif] <interval>
Definitions/Abbreviation | Description |
---|---|
SAI_PORT_STAT_IF_IN_UCAST_PKTS | SAI port stat if in ucast pkts |
SAI_PORT_STAT_IF_IN_NON_UCAST_PKTS | SAI port stat if in non ucast pkts |
SAI_PORT_STAT_IF_OUT_UCAST_PKTS | SAI port stat if out ucast pkts |
SAI_PORT_STAT_IF_OUT_NON_UCAST_PKTS | SAI port stat if out non ucast pkts |
SAI_PORT_STAT_IF_IN_OCTETS | SAI port stat if in octets |
SAI_PORT_STAT_IF_OUT_OCTETS | SAI port stat if out octets |
SAI_ROUTER_INTERFACE_STAT_IN_OCTETS | SAI RIF Ingress byte stat count |
SAI_ROUTER_INTERFACE_STAT_IN_PACKETS | SAI RIF Ingress packet stat count |
SAI_ROUTER_INTERFACE_STAT_OUT_OCTETS | SAI RIF Egress byte stat count |
SAI_ROUTER_INTERFACE_STAT_OUT_PACKETS | SAI RIF Egress packet stat count |
[RX|TX]_BPS = (SAI_[PORT|ROUTER_INTERFACE]_STAT_IF_[IN|OUT]_OCTETS - SAI_[PORT|ROUTER_INTERFACE]_STAT_IF_[IN|OUT]_OCTETS_last)/delta
delta
= interval configured for the FC group
For port:
[RX|TX]_PPS = ((SAI_PORT_STAT_IF_[IN|OUT]_UCAST_PKTS + SAI_PORT_STAT_IF_[IN|OUT]_NON_UCAST_PKTS) - (SAI_PORT_STAT_IF_[IN|OUT]_UCAST_PKTS_last + SAI_PORT_STAT_IF_[IN|OUT]_NON_UCAST_PKTS_last))/delta
For RIF:
[RX|TX]_PPS = (SAI_ROUTER_INTERFACE_STAT_[IN|OUT]_PACKETS - SAI_ROUTER_INTERFACE_STAT_[IN|OUT]_PACKETS_last)/delta
[RX|TX]_BPS = (SAI_[PORT|ROUTER_INTERFACE]_STAT_IF_[IN|OUT]_OCTETS - SAI_[PORT|ROUTER_INTERFACE]_STAT_IF_[IN|OUT]_OCTETS_last)/delta
[RX|TX]_UTIL = [RX|TX]_BPS/[PORT|RIF]_RATE
To make the rates and utilization values more smooth, exponential moving average will be calculated. EMA approximates moving average on a window siza that can be changed dynmically. More recent values are given more weight(imapct the average more, decreasing lag). EMA allows to calculate moving average without storing a set of values. Actually all the values in the series are impacting the EMA, but the weight of older values is infinitely decreasing.
ALPHA (precalculated):
N = [PORT|RIF]_SMOOTH_INTERVAL
ALPHA = 2/(N+1)
EMA = ALPHA * VALUE + (1 - ALPHA) * EMA_last
- "RATES:port_vid"
- SAI_PORT_STAT_IF_IN_UCAST_PKTS_last
- SAI_PORT_STAT_IF_IN_NON_UCAST_PKTS_last
- SAI_PORT_STAT_IF_OUT_UCAST_PKTS_last
- SAI_PORT_STAT_IF_OUT_NON_UCAST_PKTS_last
- SAI_PORT_STAT_IF_IN_OCTETS_last
- SAI_PORT_STAT_IF_OUT_OCTETS_last
- "RATES:rif_vid"
- SAI_ROUTER_INTERFACE_STAT_IN_OCTETS_last
- SAI_ROUTER_INTERFACE_STAT_IN_PACKETS_last
- SAI_ROUTER_INTERFACE_STAT_OUT_OCTETS_last
- SAI_ROUTER_INTERFACE_STAT_OUT_PACKETS_last
-
"RATES:port_vid"
- RX_BPS
- RX_PPS
- TX_BPS
- TX_PPS
- RX_UTIL
- TX_UTIL
-
"RATES:rif_vid"
- RX_BPS
- RX_PPS
- TX_BPS
- TX_PPS
- RX_UTIL
- TX_UTIL
- "RATES"
- PORT_SMOOTH_INTERVAL
- RIF_SMOOTH_INTERVAL
- PORT_ALPHA
- RIF_ALPHA
Two new Flex Counter groups are introduced: PORT_RATES, RIF_RATES.
The calculations are performed by lua plugins. The plugins are registered to the new FC groups.
For ports it is done in portsorch, for RIFs in intfsorch. The interfaces list registered to FC is dynamic. It is handled by
addRifToFlexCounter
and removeRifFromFlexCounter
methods.
The new flex counter groups have own interval, allowing to calculate rate&util values on larger interval than the counters polling itself.
By default, the interval should be the same as for counter polling(1s).
The Lua plugin logic is simple:
- get the new & old counters from DB,
- get port&interface speeds from DB,
- perform calculations,
- write the values to DB,
- update the old counter value to current counter value
The counterpoll
utility should return an error when user tries to enable rates when the corresponding counter polling is disabled.
The counterpoll
utility should returnwarn the user who is trying to configure rates intervall less than the corresponding counter polling interval,
and configure the same interval as the counters interval.
The portstat
and intfstat
scripst will be updated to display the rates and utilization values from the DB.
The show CLI commands support a -p, --period
option, to display values calculated over a specified period of time. For this the approach of taking a snapshot of counters is more suitable. The script should use this approach when -p
option is used.
Lua plugin logic can be verified with vs tests.
Testcase | Expected behaviour |
---|---|
Mock some Port RX, TX bytes and packet counters | Plugin to calculate correct rates and util values for port |
Mock some RIF RX, TX bytes and packet counters | Plugin to calculate correct rates and util values for RIF |
Change FC group interval | Plugin to calculate correct rates and util values |