Code location
Github
Experimental overview
Use two central switches that back up each other
Connect a total of four switches that backup each other
Four groups of switches with two hosts are connected below
As a small implementation of data center type network topology
The upper, middle and lower layers can be expanded to support more network hosts
It can prevent network interruption caused by single device failure in the network center area
Experimental topology
Experimental environment deployment
The establishment process is as follows
1. Open ODL
./karaf
ODL requirement components (please install them in sequence)
install odl-restconf install odl-l2switch-switch-ui install odl-openflowplugin-all install odl-mdsal-apidocs install odl-dlux-core install odl-dlux-node install odl-dlux-yangui
2. Run mininet to establish the topology
sudo mn --custom datacenter.py --topo mytopo --controller=remote,ip=127.0.0.1,port=6633 --switch ovsk,protocols=OpenFlow13
The Python code of mininet topology is as follows:
#!/usr/bin/python #Create network topology """Custom topology example Adding the 'topos' dict with a key/value pair to generate our newly defined topology enables one to pass in '--topo=mytopo' from the command line. """ from mininet.topo import Topo from mininet.net import Mininet from mininet.node import RemoteController,CPULimitedHost from mininet.link import TCLink from mininet.util import dumpNodeConnections class MyTopo( Topo ): "Simple topology example." def __init__( self ): "Create custom topo." # Initialize topology Topo.__init__( self ) L1 = 2 L2 = L1 * 2 L3 = L2 c = [] a = [] e = [] # add core ovs for i in range( L1 ): sw = self.addSwitch( 'c{}'.format( i + 1 ) ) c.append( sw ) # add aggregation ovs for i in range( L2 ): sw = self.addSwitch( 'a{}'.format( L1 + i + 1 ) ) a.append( sw ) # add edge ovs for i in range( L3 ): sw = self.addSwitch( 'e{}'.format( L1 + L2 + i + 1 ) ) e.append( sw ) # add links between core and aggregation ovs for i in range( L1 ): sw1 = c[i] for sw2 in a[i/2::L1/2]: # self.addLink(sw2, sw1, bw=10, delay='5ms', loss=10, max_queue_size=1000, use_htb=True) self.addLink( sw2, sw1 ) # add links between aggregation and edge ovs for i in range( 0, L2, 2 ): for sw1 in a[i:i+2]: for sw2 in e[i:i+2]: self.addLink( sw2, sw1 ) #add hosts and its links with edge ovs count = 1 for sw1 in e: for i in range(2): host = self.addHost( 'h{}'.format( count ) ) self.addLink( sw1, host ) count += 1 topos = { 'mytopo': ( lambda: MyTopo() ) }
3. Open http://127.0.0.1:8181/index.html#/topology To view the topology
You can also view node related information
Issue the initial flow table connection link
Note: all files in this folder have been given permission before
In the path below
sudo chmod -R 777 example-2
1. Clear all flow table items
./delflows.sh
sudo ovs-ofctl -O Openflow13 del-flows c1 sudo ovs-ofctl -O Openflow13 del-flows c2 sudo ovs-ofctl -O Openflow13 del-flows a3 sudo ovs-ofctl -O Openflow13 del-flows a4 sudo ovs-ofctl -O Openflow13 del-flows a5 sudo ovs-ofctl -O Openflow13 del-flows a6 sudo ovs-ofctl -O Openflow13 del-flows e7 sudo ovs-ofctl -O Openflow13 del-flows e8 sudo ovs-ofctl -O Openflow13 del-flows e9 sudo ovs-ofctl -O Openflow13 del-flows e10
2. Distribute the flow table (the upper, middle and lower layers are distributed together)
./add.sh
#lower stratum #e7 sudo ovs-ofctl -O OpenFlow13 add-flow e7 priority=2,in_port=1,actions=output:3,output:4 sudo ovs-ofctl -O OpenFlow13 add-flow e7 priority=2,in_port=2,actions=output:3,output:4 sudo ovs-ofctl -O OpenFlow13 add-flow e7 priority=2,in_port=3,actions=output:1,output:2,output:4 sudo ovs-ofctl -O OpenFlow13 add-flow e7 priority=2,in_port=4,actions=output:1,output:2,output:3 #e8 sudo ovs-ofctl -O OpenFlow13 add-flow e8 priority=2,in_port=1,actions=output:3,output:4 sudo ovs-ofctl -O OpenFlow13 add-flow e8 priority=2,in_port=2,actions=output:3,output:4 sudo ovs-ofctl -O OpenFlow13 add-flow e8 priority=2,in_port=3,actions=output:1,output:2,output:4 sudo ovs-ofctl -O OpenFlow13 add-flow e8 priority=2,in_port=4,actions=output:1,output:2,output:3 #e9 sudo ovs-ofctl -O OpenFlow13 add-flow e9 priority=2,in_port=1,actions=output:3,output:4 sudo ovs-ofctl -O OpenFlow13 add-flow e9 priority=2,in_port=2,actions=output:3,output:4 sudo ovs-ofctl -O OpenFlow13 add-flow e9 priority=2,in_port=3,actions=output:1,output:2,output:4 sudo ovs-ofctl -O OpenFlow13 add-flow e9 priority=2,in_port=4,actions=output:1,output:2,output:3 #e10 sudo ovs-ofctl -O OpenFlow13 add-flow e10 priority=2,in_port=1,actions=output:3,output:4 sudo ovs-ofctl -O OpenFlow13 add-flow e10 priority=2,in_port=2,actions=output:3,output:4 sudo ovs-ofctl -O OpenFlow13 add-flow e10 priority=2,in_port=3,actions=output:1,output:2,output:4 sudo ovs-ofctl -O OpenFlow13 add-flow e10 priority=2,in_port=4,actions=output:1,output:2,output:3 #middle level #a3 sudo ovs-ofctl -O OpenFlow13 add-flow a3 priority=2,in_port=1,actions=output:3,output:4 sudo ovs-ofctl -O OpenFlow13 add-flow a3 priority=2,in_port=2,actions=output:3,output:4 sudo ovs-ofctl -O OpenFlow13 add-flow a3 priority=2,in_port=3,actions=output:1,output:2,output:4 sudo ovs-ofctl -O OpenFlow13 add-flow a3 priority=2,in_port=4,actions=output:1,output:2,output:3 #a4 sudo ovs-ofctl -O OpenFlow13 add-flow a4 priority=2,in_port=1,actions=output:3,output:4 sudo ovs-ofctl -O OpenFlow13 add-flow a4 priority=2,in_port=2,actions=output:3,output:4 sudo ovs-ofctl -O OpenFlow13 add-flow a4 priority=2,in_port=3,actions=output:1,output:2,output:4 sudo ovs-ofctl -O OpenFlow13 add-flow a4 priority=2,in_port=4,actions=output:1,output:2,output:3 #a5 sudo ovs-ofctl -O OpenFlow13 add-flow a5 priority=2,in_port=1,actions=output:3,output:4 sudo ovs-ofctl -O OpenFlow13 add-flow a5 priority=2,in_port=2,actions=output:3,output:4 sudo ovs-ofctl -O OpenFlow13 add-flow a5 priority=2,in_port=3,actions=output:1,output:2,output:4 sudo ovs-ofctl -O OpenFlow13 add-flow a5 priority=2,in_port=4,actions=output:1,output:2,output:3 #a6 sudo ovs-ofctl -O OpenFlow13 add-flow a6 priority=2,in_port=1,actions=output:3,output:4 sudo ovs-ofctl -O OpenFlow13 add-flow a6 priority=2,in_port=2,actions=output:3,output:4 sudo ovs-ofctl -O OpenFlow13 add-flow a6 priority=2,in_port=3,actions=output:1,output:2,output:4 sudo ovs-ofctl -O OpenFlow13 add-flow a6 priority=2,in_port=4,actions=output:1,output:2,output:3 #bottom #c1 sudo ovs-ofctl -O OpenFlow13 add-flow c1 priority=2,in_port=1,actions=output:3,output:4 sudo ovs-ofctl -O OpenFlow13 add-flow c1 priority=2,in_port=2,actions=output:3,output:4 sudo ovs-ofctl -O OpenFlow13 add-flow c1 priority=2,in_port=3,actions=output:1,output:2 sudo ovs-ofctl -O OpenFlow13 add-flow c1 priority=2,in_port=4,actions=output:1,output:2 #c2 sudo ovs-ofctl -O OpenFlow13 add-flow c2 priority=2,in_port=1,actions=output:3,output:4 sudo ovs-ofctl -O OpenFlow13 add-flow c2 priority=2,in_port=2,actions=output:3,output:4 sudo ovs-ofctl -O OpenFlow13 add-flow c2 priority=2,in_port=3,actions=output:1,output:2 sudo ovs-ofctl -O OpenFlow13 add-flow c2 priority=2,in_port=4,actions=output:1,output:2
Test link availability
1. Run the pingall command in mininet
This indicates that the link has been successfully connected
2. Test bandwidth
h1-h2
h1-h3
h1-h7
It is not difficult to draw a conclusion: with the forwarding across the switch network, the performance decreases with the cross switch network
In order to obtain higher available bandwidth when data is transmitted across multiple switches, we use the method of dividing switches (groups) based on time period to achieve load balancing (improve available bandwidth)
Load balancing implementation
The load balance of the switch is achieved by setting the time flow table to a group of C1, A3 and A5 and a group of C2, A4 and A6 to improve the performance.
Group code together and run
./auto.py
import os import time def runteam1(): os.system("./addt1.sh") time.sleep(1) os.system("./delt2.sh") return 1; def runteam2(): os.system("./addt2.sh") time.sleep(1) os.system("./delt1.sh") return 1; os.system("./delflows.sh") os.system("./inite.sh") while(True): runteam1() runteam2()
addt1.sh Code:
#c1 sudo ovs-ofctl -O OpenFlow13 add-flow c1 priority=2,in_port=1,actions=output:3,output:4 sudo ovs-ofctl -O OpenFlow13 add-flow c1 priority=2,in_port=2,actions=output:3,output:4 sudo ovs-ofctl -O OpenFlow13 add-flow c1 priority=2,in_port=3,actions=output:1,output:2 sudo ovs-ofctl -O OpenFlow13 add-flow c1 priority=2,in_port=4,actions=output:1,output:2 #a3 sudo ovs-ofctl -O OpenFlow13 add-flow a3 priority=2,in_port=1,actions=output:3,output:4 sudo ovs-ofctl -O OpenFlow13 add-flow a3 priority=2,in_port=2,actions=output:3,output:4 sudo ovs-ofctl -O OpenFlow13 add-flow a3 priority=2,in_port=3,actions=output:1,output:2,output:4 sudo ovs-ofctl -O OpenFlow13 add-flow a3 priority=2,in_port=4,actions=output:1,output:2,output:3 #a5 sudo ovs-ofctl -O OpenFlow13 add-flow a5 priority=2,in_port=1,actions=output:3,output:4 sudo ovs-ofctl -O OpenFlow13 add-flow a5 priority=2,in_port=2,actions=output:3,output:4 sudo ovs-ofctl -O OpenFlow13 add-flow a5 priority=2,in_port=3,actions=output:1,output:2,output:4 sudo ovs-ofctl -O OpenFlow13 add-flow a5 priority=2,in_port=4,actions=output:1,output:2,output:3
delt1.sh Code:
sudo ovs-ofctl -O Openflow13 del-flows c1 sudo ovs-ofctl -O Openflow13 del-flows a3 sudo ovs-ofctl -O Openflow13 del-flows a5
After load balancing, perform the link performance test again (the test results take the mean value of three times in the same period, because the network will fluctuate)
h1-h2 because there is no link change, the bandwidth is basically unchanged
Before load balancing
After load balancing
h1-h3 bandwidth increases slightly, but the change is not obvious
Before load balancing
After load balancing
The bandwidth of h1-h7 is greatly improved and the transformation is obvious
Before load balancing
After load balancing