ovs QOS

 

实验拓扑

 

 

 

拓扑实现脚本

 

ip netns add ns1
ip netns add ns2
ip netns add ns3
ip netns add ns4

ovs-vsctl add-br br0
ovs-vsctl add-br br1

ovs-vsctl add-port br0 tap1 -- set Interface tap1 type=internal
ip link set tap1 netns ns1
ip netns exec ns1 ip addr add 1.1.1.1/24 dev tap1
ip netns exec ns1 ip link set tap1 up
ip netns exec ns1 ip link set lo up

ovs-vsctl add-port br0 tap2 -- set Interface tap2 type=internal
ip link set tap2 netns ns2
ip netns exec ns2 ip addr add 1.1.1.2/24 dev tap2
ip netns exec ns2 ip link set tap2 up
ip netns exec ns2 ip link set lo up


ovs-vsctl add-port br0 tap3 -- set Interface tap3 type=internal
ip link set tap3 netns ns3
ip netns exec ns3 ip addr add 1.1.1.3/24 dev tap3
ip netns exec ns3 ip link set tap3 up
ip netns exec ns3 ip link set lo up



ip link add firstbr type veth peer name firstif

ovs-vsctl add-port br0 firstbr
ovs-vsctl add-port br1 firstif
ip link set firstbr up
ip link set firstif up

ovs-vsctl add-port br1 tap4 -- set Interface tap4 type=internal
ip link set tap4 netns ns4
ip netns exec ns4 ip addr add 1.1.1.4/24 dev tap4
ip netns exec ns4 ip link set tap4 up
ip netns exec ns4 ip link set lo up

  

  • 拓扑销毁方法
  • ip link del firstbr type veth peer name firstif
    ovs-vsctl del-br br0
    ovs-vsctl del-br br1
    ip netns del ns1
    ip netns del ns2
    ip netns del ns3
    ip netns del ns4
    

      

测试验证方法

  在服务端

 

#在ns4串口中netserver开启流量测试服务端
root@controller-VirtualBox:~# netserver
Starting netserver with host 'IN(6)ADDR_ANY' port '12865' and family AF_UNSPEC

root@controller-VirtualBox:~# netstat -ntlp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp6       0      0 :::12865                :::*                    LISTEN      14197/netserver

  在测试端

第四列为速率: 36669.53(即约36Gbps)
root@controller-VirtualBox:~# netperf -H 1.1.1.4 -t UDP_STREAM
MIGRATED UDP STREAM TEST from 0.0.0.0 (0.0.0.0) port 0 AF_INET to 1.1.1.4 (1.1.1.4) port 0 AF_INET : demo
Socket  Message  Elapsed      Messages
Size    Size     Time         Okay Errors   Throughput
bytes   bytes    secs            #      #   10^6bits/sec

212992   65507   10.00      700111      0    36688.91
212992           10.00      699741           36669.53

设置接口firstif发包速率10Mbps

ovs-vsctl set Interface firstif ingress_policing_rate=10000
ovs-vsctl set Interface firstif ingress_policing_burst=10000

  

测试结论:
如下结论,从ns1->ns4 104741.35
从ns4->ns1 10.27
也就是当流量走入接口firstif后速率限制为10Mbps,导致到ns4位10Mbps,因此回程流量(ns4->ns1)为10Mbps左右

 

root@controller-VirtualBox:~# netperf -H 1.1.1.4 -t UDP_STREAM
MIGRATED UDP STREAM TEST from 0.0.0.0 (0.0.0.0) port 0 AF_INET to 1.1.1.4 (1.1.1.4) port 0 AF_INET : demo
Socket  Message  Elapsed      Messages
Size    Size     Time         Okay Errors   Throughput
bytes   bytes    secs            #      #   10^6bits/sec

212992   65507   10.00     1998882      0    104741.35
212992           10.00         196             10.27

  

清除接口速率限制方法

 

ovs-vsctl set Interface firstif ingress_policing_rate=0
ovs-vsctl set Interface firstif ingress_policing_burst=0

  

 

posted @ 2019-03-09 15:15  请叫我刀刀  阅读(842)  评论(0编辑  收藏  举报