【问题标题】:Pox proactive openflow rulePox 主动开放流规则
【发布时间】:2017-12-22 15:50:11
【问题描述】:

我创建了一个规则,以便在连接到控制器时添加到打开的 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")))

【问题讨论】:

  • ARP 数据包可以从 h1 传输到 h2 并返回吗?如果你在h1上运行arp,它是否知道h2的硬件地址?
  • 没有。不应该有流量意味着不再需要 arp 吗?
  • 据我所知仍然需要 ARP。您的操作系统需要知道要在数据包中写入的硬件地址。回家后我会写一个完整的答案。
  • 你是对的。一旦我配置了一个mac表,它就可以工作了。写一个答案并且不接受。谢谢您的帮助。当我将入口端口作为匹配项时,它的工作方式很奇怪。
  • 很高兴我能帮上忙!我在下面发布了完整的答案。

标签: python sdn mininet openvswitch pox


【解决方案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 进行通信。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-08-13
    • 1970-01-01
    • 2011-12-06
    • 2014-11-21
    • 2010-11-21
    • 1970-01-01
    • 2017-06-18
    • 1970-01-01
    相关资源
    最近更新 更多