首页 > 解决方案 > Iperf 卡在 mininet 自定义拓扑中

问题描述

我在模拟 Ubuntu Xenial 的 Vagrant 虚拟机上使用 mininet(我的笔记本电脑运行 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 流量,但我不明白为什么,当我iperf h1 h4在 mininet 提示符下键入命令时,会导致连接超时;如果我在不同的终端上同时运行客户端和服务器,结果相同。

当然我知道我必须在我的代码中添加一些东西,但我真的看不出在哪里..任何帮助将不胜感激!

标签: pythonvirtual-machinemininetryu

解决方案


推荐阅读