1. 为什么需要Eth-Trunk在单条链路带宽不足以支撑业务运行时,在节省成本的条件下,可以通过Eth-Trunk技术将多条物理链路在逻辑上捆绑成一条链路,这条逻辑链路的带宽就等于所有物理链路的带宽之和。并且由于链路数量的提升,也实现了链路的冗余。
2. Eth-Trunk的基本组成
元素
定义
链路聚合组
LAG(Link Aggregation Group, 链路聚合组),将多条物理链路组合在一起的逻辑链路
Eth-Trunk接口
在网络设备中,链路聚合组被定义为一个Eth-Trunk接口
成员接口
链路聚合组中的每一个物理接口
成员链路
即成员接口对应的链路
活动接口
又称选中接口,即成员接口中参与数据转发的接口
非活动接口
又称非选中接口,即成员接口中不参与数据转发的接口
活动链路
活动接口对应的链路
非活动链路
非活动接口对应的连接
3. Eth-Trunk的优势增加带宽:聚合组的最终带宽等于多条活动链路的带宽之和 提高可靠性:某条活动链路故障时,流量会自动分担到其他活动链路,或者非活动链路顶上 负载分担:通过哈希算法实现各条活动链路的流量负载分担 应用简单:仅作用在两台设备之间,拓扑清晰
4. Eth-Trunk模式 4.1. 手工模式手工模式适合那些不支持LACP模式的老旧设备。
手工模式下,所有成员接口都强制为活动接口,都参与数据的转发。
手动模式的缺点在于,由于没有LACP协议报文的动态交互,因此无法检测活动链路故障 。只能简单的检测接口的物理状态UP/Down。
例如,Switch-1和Switch-2的链路聚合组包含的成员接口为g0/0/1-g0/0/3,但Switch-1却错连了Switch-2的g0/0/4:
当Switch-1将将流量负载分担到活动接口g0/0/3后,由于对端的g0/0/4不在链路聚合组中,因此会导致数据被丢弃,或者错误的转发到其他不该接收的设备上。
再一种情形就是成员接口错接到其他设备上:
这种情况也会导致数据传输错误。
4.2. LACP模式LACP是基于 IEEE 802.3ad 标准实现的链路动态聚合与解聚合的协议。
用户在手工创建完链路聚合组以及添加成员接口之后,设定为LACP模式,之后便会由LACP协议自动选择活动接口,当某个活动接口故障时,LACP协议会调度其他的成员接口成为活动接口,进行数据转发。
即使接口错连,LACP协议也能通过LACP报文的交互,自动检测出故障,并关闭相关接口,激活空余活动接口。
LACP模式又称为 M:N 模式,即M条活动链路做负载分担,N条备份链路做替补的模式。
LACP 工作过程如下:
确定主动端
两端设备互发LACPDU报文,通过比较报文中的系统优先级字段(Actor_System_Priority),值越小优先级越高,如果系统优先级相同,则比较两端的MAC地址(Actor_System),小的一端为主动端。
确定活动接口
两端设备以自己的接口优先级(Actor_Port_Priority)来确定活动接口,值越小,优先级越高,接口优先级相同时将比较接口编号,接口编号小的成为活动接口。
只有当成员接口数量超出最大活动接口数量时,才会用上述比较原则进行选举。其余成员接口将成为备份接口。
链路切换
当某条链路故障时,Eth-Trunk会在备份接口中将优先级高(值最小)的接口作为新的活动接口。故障链路恢复后,如果链路聚合组开启了抢占机制 (lacp preempt enable),则故障端口会等待抢占延时超时后重新成为活动接口。
6. 负载分担Eth-Trunk的多条物理链路可能会导致数据流的第一个帧从链路1通过,第二个帧从链路2通过,第二个帧比第一个帧先到达就可能导致数据包乱序。
为了解决这种问题,Eth-Trunk采用了逐流负载分担 的方式,通过提取数据帧的五元组,使用哈希算法计算出相应的哈希值,再根据哈希值选择对应的出接口。这样就保证了不同五元组的数据流会走不同的出接口,也实现了各活动链路上的数据负载分担。
如果报文的IP地址变化频繁(如网关出口设备),那么建议选择基于源/目的IP的负载分担方式;如果报文的MAC地址变化频繁(如二层局域网互访),那么建议选择基于源/目的MAC的负载分担方式;
如果负载分担的方式和实际业务不符合,可能会导致流量分担不均,例如,在源/目的IP地址变化频繁但是目的MAC地址固定的情况下,选择基于目的MAC的负载分担方式,会导致所有流量只跑在一条链路上。
逐流负载分担 vs 逐包负载分担:
维度
逐流负载分担
逐包负载分担
基本原理
按照五元组(源 IP、目的 IP、协议号、源端口、目的端口)或 MAC 地址等规则将报文分成不同的流,同一条流的报文始终从同一个成员接口发送
不区分数据流,以报文为单位,按报文到来的次序轮流从所有选中成员接口中选择接口发送
算法机制
采用 HASH 算法,将报文特征值(MAC/IP/端口等)映射为固定长度的 HASH 值,再根据 HASH 值映射到出接口
启用一个定时器/计数器,每来一个包计数器加 1,根据计数器的值选择出接口
报文顺序
保证包的顺序——同一数据流的帧在同一条物理链路转发
可能导致报文乱序——同一数据流的不同报文可能从不同链路到达对端
负载均衡程度
均衡程度受负载分担规则和业务流量特征影响,不能保证带宽利用率
能更为均衡地分发报文
7. 配置示例
7.1. 手工模式1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 sysname SW1 vlan batch 10 20 interface Eth-Trunk1 trunkport e0/0 /1 trunkport e0/0 /2 trunkport e0/0 /3 port link-type trunk port trunk allow-pass vlan 10 20 load-balance src-dst-mac interface Ethernet0/0/4 port link-type access port default vlan 20
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 sysname SW2 vlan batch 10 20 interface Eth-Trunk1 port link-type trunk port trunk allow-pass vlan 10 20 load-balance src-dst-mac interface Ethernet0/0/1 eth-trunk 1 interface Ethernet0/0/2 eth-trunk 1 interface Ethernet0/0/3 eth-trunk 1 interface Ethernet0/0/4 port link-type access port default vlan 20
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 <SW1>display interface brief PHY: Physical *down : administratively down (l) : loopback (s) : spoofing(b) : BFD down (e) : ETHOAM down (dl) : DLDP down (d) : Dampening SuppressedInUti/OutUti: input utility/output utility Interface PHY Protocol InUti OutUti inErrors outErrorsEth-Trunk1 up up 0 % 0 % 0 0 Ethernet0/0/1 up up 0 % 0 % 0 0 Ethernet0/0/2 up up 0 % 0 % 0 0 Ethernet0/0/3 up up 0 % 0 % 0 0
1 2 3 4 5 6 7 8 9 10 <SW1>display eth-trunk 1 Eth-Trunk1 's state information is:WorkingMode: NORMAL Hash arithmetic: According to SA-XOR-DA Least Active -linknumber: 1 Max Bandwidth-affected-linknumber: 8 Operate status: up Number Of Up Port In Trunk : 3 -------------------------------------------------------------------------------- PortName Status Weight Ethernet0/0/1 Up 1 Ethernet0/0/2 Up 1 Ethernet0/0/3 Up 1
7.2. LACP模式1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 sysname SW1 vlan batch 10 20 lacp priority 100 interface Eth-Trunk1 port link-type trunk port trunk allow-pass vlan 10 20 mode lacp -static load-balance src-dst-mac max active -linknumber 2 lacp preempt enable interface Ethernet0/0/1 eth-trunk 1 lacp priority 100 interface Ethernet0/0/2 eth-trunk 1 lacp priority 100 interface Ethernet0/0/3 eth-trunk 1 lacp priority 200 interface Ethernet0/0/4 port link-type access port default vlan 20 interface Ethernet0/0/5 port link-type access port default vlan 10
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 sysname SW2 vlan batch 10 20 interface Eth-Trunk1 port link-type trunk port trunk allow-pass vlan 10 20 mode lacp -static load-balance src-dst-mac max active -linknumber 2 trunkport e0/0 /1 trunkport e0/0 /2 trunkport e0/0 /3 interface Ethernet0/0/4 port link-type access port default vlan 20 interface Ethernet0/0/5 port link-type access port default vlan 10
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 [SW1] display eth-trunk 1 Eth-Trunk1 's state information is:Local: LAG ID: 1 WorkingMode: STATIC Preempt Delay: Disabled Hash arithmetic: According to SA-XOR-DA System Priority: 100 System ID: 4c1f-cc82-803a Least Active -linknumber: 1 Max Active -linknumber: 2 Operate status: up Number Of Up Port In Trunk : 2 -------------------------------------------------------------------------------- ActorPortName Status PortType PortPri PortNo PortKey PortState Weight Ethernet0/0/1 Selected 100M 100 2 289 10111100 1 Ethernet0/0/2 Selected 100M 100 3 289 10111100 1 Ethernet0/0/3 Unselect 100M 200 4 289 10100000 1 Partner: -------------------------------------------------------------------------------- ActorPortName SysPri SystemID PortPri PortNo PortKey PortState Ethernet0/0/1 32768 4c1f-cc18-16f2 32768 2 289 10111100 Ethernet0/0/2 32768 4c1f-cc18-16f2 32768 3 289 10111100 Ethernet0/0/3 32768 4c1f-cc18-16f2 32768 4 289 10100000
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 <SW2>display eth-trunk 1 Eth-Trunk1 's state information is:Local: LAG ID: 1 WorkingMode: STATIC Preempt Delay: Disabled Hash arithmetic: According to SA-XOR-DA System Priority: 32768 System ID: 4c1f-cc18-16f2 Least Active -linknumber: 1 Max Active -linknumber: 2 Operate status: up Number Of Up Port In Trunk : 2 -------------------------------------------------------------------------------- ActorPortName Status PortType PortPri PortNo PortKey PortState Weight Ethernet0/0/1 Selected 100M 32768 2 289 10111100 1 Ethernet0/0/2 Selected 100M 32768 3 289 10111100 1 Ethernet0/0/3 Unselect 100M 32768 4 289 10100000 1 Partner: -------------------------------------------------------------------------------- ActorPortName SysPri SystemID PortPri PortNo PortKey PortState Ethernet0/0/1 100 4c1f-cc82-803a 100 2 289 10111100 Ethernet0/0/2 100 4c1f-cc82-803a 100 3 289 10111100 Ethernet0/0/3 100 4c1f-cc82-803a 200 4 289 10100000
8. 参考https://info.support.huawei.com/info-finder/encyclopedia/zh/LACP.html https://info.support.huawei.com/info-finder/encyclopedia/zh/Eth-trunk.html https://support.huawei.com/hedex/hdx.do?docid=EDOC1000042062&id=dc_cfg_eth-trunk_0034_1&ui=1 https://support.huawei.com/hedex/hdx.do?docid=EDOC1000042062&id=dc_cfg_eth-trunk_0035_1