Iperf陷入mininet自定义拓扑

时间:2018-11-22 10:59:10

标签: python virtual-machine mininet ryu

我在Vagrant虚拟机上使用mininet,该虚拟机模拟Ubuntu Xenial(我的笔记本电脑运行Windows 10)。

以下是拓扑,其中遥控器,静态ARP和OVS内核交换机在用户空间中运行:

h1---s1----s4---h3
     | \  / |
     |  s3  |
     | /  \ |
h2---s2----s5---h4

我已经使用以下Python脚本完成了该操作:

from mininet.topo import Topo
from mininet.node import Host

class MyTopo(Topo):
    def __init__(self):
        "Create custom topo."
         Topo.__init__(self)

         leftTopHost = self.addHost('h1')
         leftBottomHost = self.addHost('h2')
         rightTopHost = self.addHost('h3')
         rightBottomHost = self.addHost('h4')
         Switch1 = self.addSwitch('s1')
         Switch2 = self.addSwitch('s2')
         Switch3 = self.addSwitch('s3')
         Switch4 = self.addSwitch('s4')
         Switch5 = self.addSwitch('s5')

         self.addLink(leftTopHost, Switch1)
         self.addLink(Switch1, Switch2)
         self.addLink(Switch1, Switch3)
         self.addLink(Switch1, Switch4)

         self.addLink(leftBottomHost, Switch2)
         self.addLink(Switch2, Switch3)
         self.addLink(Switch2, Switch5)

         self.addLink(Switch3, Switch4)
         self.addLink(Switch3, Switch5)

         self.addLink(rightTopHost, Switch4)
         self.addLink(Switch4, Switch5)

         self.addLink(rightBottomHost, Switch5)

topos = {'mytopo': (lambda: MyTopo())}

基本思想是h1和h4之间的MPLS隧道,该隧道通过交换机s1,s4和s5。我包括了我开发的Ryu应用程序的一部分(之所以称为“一部分”,是因为MPLS匹配和随后的ping h1 h4 works罚款);假设输出端口号是代码中的一个

s1中的流规则

#path h1->h4
...
match = parser.OFPMatch(in_port=1, eth_type=0x800, ip_proto=6)
actions = [parser.OFPActionOutput(4)]
inst = [parser.OFPInstructionActions(ofproto.OFPIT_APPLY_ACTIONS, actions)]
mod = parser.OFPFlowMod(datapath=datapath, priority=1, match=match, 
                        instructions=inst)
datapath.send_msg(mod)

#path h4->h1    
match = parser.OFPMatch(in_port=4, eth_type=0x800, ip_proto=6)
actions = [parser.OFPActionOutput(1)]
inst = [parser.OFPInstructionActions(ofproto.OFPIT_APPLY_ACTIONS, actions)]
mod = parser.OFPFlowMod(datapath=datapath, priority=1, match=match, 
                        instructions=inst)
datapath.send_msg(mod)

s4中的流规则

#path h1->h4
...
match = parser.OFPMatch(in_port=1, eth_type=0x800, ip_proto=6)
actions = [parser.OFPActionOutput(4)]
inst = [parser.OFPInstructionActions(ofproto.OFPIT_APPLY_ACTIONS, actions)]
mod = parser.OFPFlowMod(datapath=datapath, priority=1, match=match, 
                        instructions=inst)
datapath.send_msg(mod)

#path h4->h1
match = parser.OFPMatch(in_port=4, eth_type=0x800, ip_proto=6)
actions = [parser.OFPActionOutput(1)]
inst = [parser.OFPInstructionActions(ofproto.OFPIT_APPLY_ACTIONS, actions)]
mod = parser.OFPFlowMod(datapath=datapath, priority=1, match=match, 
                        instructions=inst)
datapath.send_msg(mod)

s5中的流规则

#path h1->h4
...
match = parser.OFPMatch(in_port=3, eth_type=0x800, ip_proto=6)
actions = [parser.OFPActionOutput(4)]
inst = [parser.OFPInstructionActions(ofproto.OFPIT_APPLY_ACTIONS, actions)]
mod = parser.OFPFlowMod(datapath=datapath, priority=1, match=match, 
                        instructions=inst)
datapath.send_msg(mod)

#path h4->h1
match = parser.OFPMatch(in_port=4, eth_type=0x800, ip_proto=6)
actions = [parser.OFPActionOutput(3)]
inst = [parser.OFPInstructionActions(ofproto.OFPIT_APPLY_ACTIONS, actions)]
mod = parser.OFPFlowMod(datapath=datapath, priority=1, match=match, 
                        instructions=inst)
datapath.send_msg(mod)

现在要解决我的问题:我想在h1和h4之间生成TCP通信,但我不明白为什么在mininet提示符下键入iperf h1 h4命令时会导致连接超时;如果我在单独的终端上同时运行客户端和服务器,则结果相同。

可以肯定的是,我知道必须在代码中添加一些内容,但是我真的看不到哪里。任何帮助将不胜感激!

0 个答案:

没有答案