
至于你的TBF设置,用了TBF自身提供的两个途径
TBF叫做Token Bucket Filter.总体的思路就是数据包要领到Token(令牌)才能被发送,而令牌的产生速率收到rate这个参数的限制。Token是一个抽象的概念,Token的大小都是指的Token所指向的数据包的大小。
当要发送的速率低于令牌产生的速度时,所有的数据包都能领到Token,并且多余的Token会在你的Buffer里积累。积累的上限由Buffer/Burst这个参数指定。
当发送的速率等于Token产生的速度时,Token正好被完全消耗,所有的数据包都会发送,并且buffer不会积累多余的Token
当发送的速率大于Token的速率,如果Buffer里还有多余的Token,就会开始消耗Buffer的Token,同时允许数据包通过。如果buffer的Token耗尽,数据包就不被允许通过,并且进入Txqueue(发送队列)排队。如果排队的尺寸大于limit(你的第一个TBF有指定),则队列不能再增长,新到来的数据包会被drop。
明白上面的概念之后你的两条命令的区别也就容易看懂了。
第一个是用的Buffer/Limit
Buffer就是瞬间可以额外提供的Token的数量。Rate限制了你的持续上传速率为1Mb/s,然后在你长时间网络流量很低时,你得Token会积累,最后你可以有Buffer这么大(1600b)的缓冲无视rate的限制(可以瞬间发送1600b,所以叫做突发)。至于后面的limit 3000,是指你当你的缓冲区(Txqueue)超过3000b时,新来的包会被Drop
第二个用的是Burst/latency/rate组合
这里的burst和上面的buffer含义完全相同,都是能够以高于rate所限定的速度发送的数据量(4Mb,比第一个的大很多)。至于Latency,是对应limit的量。Latency规定的是数据包能在Txqueue中呆的最长的时间(你的是1S),在Txqueue中呆超过1s的包都会被Drop。所以结合你的rate来计算,latency 1s+rate 1Mbit/s 等价于 limit为1Mbit*1s=1Mb
*tc只能规整egress traffic,就是从NIC流出的流量(上传),对于下载,要用IFB将ingress(下载)模拟成egress
首先,需要先明确,绑定的各种模式0 - Sets a round-robin policy for fault tolerance and load balancing. Transmissions are received and sent out sequentially on each bonded slave interface beginning with the first one available.
1 - Sets an active-backup policy for fault tolerance. Transmissions are received and sent out via the first available bonded slave interface. Another bonded slave interface is only used if the active bonded slave interface fails.
2 - Sets an XOR (exclusive-or) policy for fault tolerance and load balancing. Using this method, the interface matches up the incoming request's MAC address with the MAC address for one of the slave NICs. Once this link is established, transmissions are sent out sequentially beginning with the first available interface.
3 - Sets a broadcast policy for fault tolerance. All transmissions are sent on all slave interfaces.
4 - Sets an IEEE 802.3ad dynamic link aggregation policy. Creates aggregation groups that share the same speed and duplex settings. Transmits and receives on all slaves in the active aggregator. Requires a switch that is 802.3ad compliant.
5 - Sets a Transmit Load Balancing (TLB) policy for fault tolerance and load balancing. The outgoing traffic is distributed according to the current load on each slave interface. Incoming traffic is received by the current slave. If the receiving slave fails, another slave takes over the MAC address of the failed slave.
6 - Sets an Active Load Balancing (ALB) policy for fault tolerance and load balancing. Includes transmit and receive load balancing for IPV4 traffic. Receive load balancing is achieved through ARP negotiation.
需要注意的是MODE 0仅仅能实现网卡轮询,但同一时间只有一个网卡生效,总体带宽还是1个网卡的带宽。
这里,我们需要开启交换机的802.3ad,并设置mode=4来实现带宽增倍
注意,在上面这个BLOG里的mode需要改一下:
vi /etc/modprobe.conf
alias bond0 bonding
options bond0 miimon=100 mode=4 lacp_rate=1
我们用iperf工具来测试带宽,由于mode 4模式使用mac地址分配那个网卡参与工作,因此,需要多台测试机进行测试
10.199.81.39作为server,10.199.81.40及10.199.81.42作为client,如果两个client均能达到1000Mbits,那也就意味着带宽是翻倍了。
server:
# iperf -s -w 1M
------------------------------------------------------------
Server listening on TCP port 5001
TCP window size: 2.00 MByte (WARNING: requested 1.00 MByte)
------------------------------------------------------------
[ 4] local 10.199.81.39 port 5001 connected with 10.199.81.40 port 9951
[ 5] local 10.199.81.39 port 5001 connected with 10.199.81.42 port 61211
[ ID] Interval Transfer Bandwidth
[ 4] 0.0-100.0 sec 11.1 GBytes 949 Mbits/sec
[ 5] 0.0-100.0 sec 11.1 GBytes 949 Mbits/sec
达到了带宽翻倍的目的
linux言叙关注
Linux系统bond配置 原创
2020-02-23 15:19:24
5点赞
linux言叙
码龄7年
关注
1、bond简介
bond是多块物理网卡虚拟为一块网卡,使多块网卡看起来像一块网卡。
2、bond优点
linux系统下配置bond,通过网卡绑定可增加服务器可靠性,同时可增加网络带宽,提供稳定的网络服务。
3、bond模式
(1)mode=1:在主备模式下,只有主网卡工作,备份网卡不工作,只有当一个网络接口失效时(例如交换机掉电等),为了不会出现网络中断,系统会按照配置指定的网卡顺序启动工作,保证机器仍能对外服务,起到了失效保护功能。
(2)mode=0:在负载均衡模式下,两块网卡都工作,提供两倍带宽。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)