Pox主动开放流规则

问题描述 投票:0回答:1

我创建了一个规则,当它连接到控制器时添加到一个打开的vswitch。该规则允许h1与h2通信,h2都在同一个交换机上。当与控制器的连接出现时,将添加以下规则。

event.connection.send(
                of.ofp_flow_mod(action=of.ofp_action_output(port=1), priority=45,
                                match=of.ofp_match(dl_type=0x800, nw_dst="10.0.0.7")))

由于某种原因,流程将无法工作,但如果我将其更改为匹配使用端口,而不是IP它将起作用。由于有多个交换机,我不能仅仅在端口上匹配。

起初我以为ICMP可能不是IPV4,但我确认它使用的是Tcpdump。

sudo tcpdump -e -r tcpdump.pcap dst 192.168.0.103
reading from file tcpdump.pcap, link-type EN10MB (Ethernet)
14:24:30.940749 00:a0:98:ae:2c:fe (oui Unknown) > 00:1d:ec:0e:0b:fa (oui Unknown), ethertype IPv4 (0x0800), length 98: 192.168.0.112 > 192.168.0.103: ICMP echo request, id 1962, seq 1, length 64

网络包括连接到2个叶子交换机的主干交换机和每个叶子交换机2个主机。

任何帮助将不胜感激。

def _handle_ConnectionUp(self, event):
        #dpid = event.connection.dpid
        # printing the dpid
        # log.info("Switch with DPID of %s has come up.",dpid_to_str(event.dpid))
        print("Switch with DPID of %s has come up." % (dpid_to_str(event.dpid)))

        # printing the dpid in hex
        # log.info("Switch with DPID in HEX format of %s has come up." % (hex(event.dpid)))
        print("Switch with DPID in HEX format of %s has come up." % (hex(event.dpid)))

        if event.dpid == 0x1:

            event.connection.send(
                of.ofp_flow_mod(action=of.ofp_action_output(port=2), priority=45,
                                match=of.ofp_match(in_port = 1)))
            event.connection.send(
                of.ofp_flow_mod(action=of.ofp_action_output(port=1), priority=45,
                                match=of.ofp_match(dl_type=0x800, nw_dst="10.0.0.1")))
python sdn mininet openvswitch pox
1个回答
1
投票

在典型的L2网络中,两台主机需要与ARP协议通信才能交换硬件地址,然后才能相互ping(或任何其他基于IP的协议)。

我最好的客户是,使用您当前的配置,h1可以向h2发送ARP请求(由于入口端口上的规则),但是h2无法应答。因此,h1不知道h2的硬件地址,也不能发送它的IP包。要检查此假设,您可以运行:

$ arp
Address               HWtype  HWaddress           Flags Mask            Iface
10.0.0.7                      (incomplete)                              eno1
10.0.0.254            ether   00:00:00:00:00:08   C                     eno1

例如,在这里,10.0.0.7的地址是未知的。

您至少有两个解决方案:

  1. 在h1和h2中手动设置新的ARP表项。见arp -h
  2. 让h1和h2通过添加必要的规则通过ARP进行通信。
© www.soinside.com 2019 - 2024. All rights reserved.