Pox主动openflow规则

Pox proactive openflow rule

我创建了一个规则,当它连接到控制器时添加到打开的 vswitch。该规则允许 h1 与位于同一交换机上的 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")))

在典型的 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进行通信。