Pox主动开放式ru

2024-10-06 12:32:15 发布

您现在位置:Python中文网/ 问答频道 /正文

我创建了一个规则,以便在打开的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。在

^{pr2}$

该网络由一个连接到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")))

Tags: ofeventportmatchwithactionconnection交换机
1条回答
网友
1楼 · 发布于 2024-10-06 12:32:15

在一个典型的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通信。在

相关问题 更多 >