1.建立以下拓扑,并连接上ODL控制器。
代码如下:
from mininet.topo import Topo
class MyTopo(Topo):
def __init__(self):
# initilaize topology
Topo.__init__(self)
# add hosts and switches
h1 = self.addHost('h1')
h2 = self.addHost('h2')
h3 = self.addHost('h3')
h4 = self.addHost('h4')
sw1 = self.addSwitch('s1')
sw2 = self.addSwitch('s2')
sw3 = self.addSwitch('s3')
sw4 = self.addSwitch('s4')
# add links
self.addLink(sw1,h1, 1, 1)
self.addLink(sw1,sw2, 2, 1)
self.addLink(sw1,sw3, 3, 1)
self.addLink(sw4,sw4, 4, 1)
self.addLink(sw2,sw4, 2, 2)
self.addLink(sw3,sw4, 2, 3)
self.addLink(sw4,h2, 4 ,1)
self.addLink(sw4,h3, 5, 1)
self.addLink(sw4,h4, 6, 1)
topos = {'mytopo': (lambda: MyTopo())}
2.利用ODL下发组表、流表,实现建议负载均衡
下发流表:
sudo ovs-ofctl dump-groups s1 -O OpenFlow13
3.利用Wireshark验证负载均衡的实现
s4-eth1
s4-eth2
s4-eth3
- 其中第三步利用Wireshark验证负载均衡的实现有些难度,需要对负载均衡有比较深刻的理解。