SDN第三次上机作业
1.创建以下拓扑(可采用任意方式)
创建拓扑的代码如下:
#! /usr/bin/python
from mininet.topo import Topo
from mininet.net import Mininet
from mininet.node import RemoteController,CPULimitedHost
from mininet.link import TCLink
class MyTopo(Topo):
def __init__(self):
Topo.__init__(self)
# add switch
sw1 = self.addSwitch('sw1')
sw2 = self.addSwitch('sw2')
# add host
h1 = self.addHost('h1')
h2 = self.addHost('h2')
h3 = self.addHost('h3')
h4 = self.addHost('h4')
h5 = self.addHost('h5')
h6 = self.addHost('h6')
self.addLink(sw1, h1, 1, 1)
self.addLink(sw1, h2, 2, 1)
self.addLink(sw1, h3, 3, 1)
self.addLink(sw2, h4, 1, 1)
self.addLink(sw2, h5, 2, 1)
self.addLink(sw2, h6, 3, 1)
self.addLink(sw1, sw2, 4, 4)
topos = { 'mytopo': ( lambda: MyTopo() ) }
验证与拓扑的正确性:
2.利用OVS命令下发流表,实现VLAN功能
下发流表(S1):
下发流表(S2):
3.利用OVS命令查看流表
查看流表(S1)
查看流表(S2)