forked from sonic-net/sonic-buildimage
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ECMP calculator tool (sonic-net#12482)
- Why I did it Added ECMP calculator tool. - How I did it New files were added. - How to verify it Manual tests performed according to tests chapter in HLD Automated tests will be added by verification.
- Loading branch information
Showing
6 changed files
with
1,371 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
136 changes: 136 additions & 0 deletions
136
platform/mellanox/docker-syncd-mlnx/ecmp_calculator/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
# SONiC ECMP Calculator | ||
|
||
## Description | ||
An equal cost multipath (ECMP) is formed when routing table contains multiple next hop addresses for the same destination IP address. | ||
ECMP will load balance the outbound traffic between the IP interfaces. | ||
The purpose of ECMP calculator is to calculate which IP interface ECMP will choose and return the physical interface packet will egress from. | ||
Packet is defined by a JSON file given as an argument to the tool. | ||
|
||
## Usage notes | ||
1. ECMP calculator performs its calculations based on the current operational state of the router. In order to calculate the egress port, it fetches routes from HW. Routes exist in HW only for next hops with a resolved ARP. | ||
2. ECMP calculator supports only routed packets. | ||
- IPv4/IPv6 TCP/UDP packets | ||
- IPinIP and VXLAN encapsulated packets | ||
3. Changes done in the packet classification (e.g. ACL, PBR) are not taken into consideration during calculation. | ||
|
||
## Command line interface | ||
1. User shall provide the following input parameters: | ||
- JSON file describing a packet | ||
- Ingress port (e.g. "Ethernet0", must pe a physical interface) | ||
- Debug option for debug purposes (optional) | ||
- VRF name (optional) | ||
2. Usage example: | ||
``` | ||
$ show ip ecmp-egress-port --packet /tmp/packet.json --ingress-port Ethernet0 --vrf Vrf_red --debug | ||
Egress port: Ethernet4 | ||
``` | ||
ECMP calculator is a vendor specific tool. If tool was not implemented and CLI command is being called, the following message will be returned to user: | ||
``` | ||
$ show ip ecmp-egress-port --packet /tmp/packet.json --ingress-port Ethernet0 --vrf Vrf_red --debug | ||
ECMP calculator is not available in this image | ||
``` | ||
|
||
## Packet JSON | ||
1. Numbers in packet JSON must be in base-ten. | ||
2. For packets with single header, outer header shall be provided. | ||
3. The following table defines the structure of a packet JSON file. | ||
|
||
| ecmp_hash | | | | | | | | ||
|-----------|-------------|-------|-------------|-------------|--------|----------------------------------------------------------------------------------| | ||
| | packet_info | | | | object | | | ||
| | | outer | | | object | | | ||
| | | | layer2 | | object | | | ||
| | | | | smac | string | | | ||
| | | | | dmac | string | | | ||
| | | | | ethertype | number | 16bits, needed for IPv4 or IPv6 packet | | ||
| | | | | outer_vid | number | 12bits | | ||
| | | | | outer_pcp | number | 3bits | | ||
| | | | | outer_dei | number | 1bits | | ||
| | | | | inner_vid | number | QinQ | | ||
| | | | | inner_pcp | number | QinQ | | ||
| | | | | inner_dei | number | QinQ | | ||
| | | | ipv4 | | object | | | ||
| | | | | sip | string | | | ||
| | | | | dip | string | | | ||
| | | | | proto | number | 8bits | | ||
| | | | | dscp | number | 6bits | | ||
| | | | | ecn | number | 2bits | | ||
| | | | | mflag | number | 1bit | | ||
| | | | | l3_length | number | 16bits | | ||
| | | | ipv6 | | object | should not co-exist with ipv4 field | | ||
| | | | | sip | string | | | ||
| | | | | dip | string | | | ||
| | | | | mflag | number | 1bit | | ||
| | | | | next_header | number | 8bits | | ||
| | | | | dscp | number | 6bits | | ||
| | | | | ecn | number | 2bits | | ||
| | | | | l3_length | number | 16bits | | ||
| | | | | flow_label | number | 20bits | | ||
| | | | tcp_udp | | object | | | ||
| | | | | sport | number | 16bits | | ||
| | | | | dport | number | 16bits | | ||
| | | | vxlan_nvgre | | object | | | ||
| | | | | vni | number | 24bits | | ||
| | | inner | | | object | overlay | | ||
| | | | layer2 | | object | | | ||
| | | | | smac | string | | | ||
| | | | | dmac | string | | | ||
| | | | | ethertype | number | 16bits | | ||
| | | | ipv4 | | object | | | ||
| | | | | sip | string | | | ||
| | | | | dip | string | | | ||
| | | | | mflag | number | 1bit | | ||
| | | | | proto | number | 8bits | | ||
| | | | ipv6 | | object | should not co-exist with ipv4 field | | ||
| | | | | sip | string | | | ||
| | | | | dip | string | | | ||
| | | | | mflag | number | 1bit | | ||
| | | | | next_header | number | 8bits | | ||
| | | | | flow_label | number | 20bits | | ||
| | | | tcp_udp | | object | | | ||
| | | | | sport | number | 16bits | | ||
| | | | | dport | number | 16bits | | ||
|
||
4. Packet JSON file example | ||
|
||
```json | ||
{ | ||
"packet_info": { | ||
"outer": { | ||
"ipv4": { | ||
"sip": "10.10.10.10", | ||
"dip": "3.3.3.3", | ||
"proto": 17 | ||
}, | ||
"layer2": { | ||
"smac": "24:8a:07:1e:82:ed", | ||
"dmac": "1c:34:da:1c:a1:00", | ||
"ethertype": 2048 | ||
}, | ||
"tcp_udp": { | ||
"sport": 100, | ||
"dport": 4789 | ||
}, | ||
"vxlan_nvgre": { | ||
"vni": 100 | ||
} | ||
}, | ||
"inner": { | ||
"layer2": { | ||
"smac": "11:11:11:11:11:11", | ||
"dmac": "22:22:22:22:22:22", | ||
"ethertype": 2048 | ||
}, | ||
"ipv4": { | ||
"sip": "1.1.1.1", | ||
"dip": "2.2.2.3", | ||
"proto": 17, | ||
"mflag": 0 | ||
}, | ||
"tcp_udp": { | ||
"sport": 100, | ||
"dport": 200 | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.