Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/303.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python mininet中的POX:event.parsed在POX中给出了什么?下一步是什么?_Python_Controller_Mininet_Openflow_Pox - Fatal编程技术网

Python mininet中的POX:event.parsed在POX中给出了什么?下一步是什么?

Python mininet中的POX:event.parsed在POX中给出了什么?下一步是什么?,python,controller,mininet,openflow,pox,Python,Controller,Mininet,Openflow,Pox,在l3_learning.py中,类l3_开关中有一个名为\u handle\u PacketIn的方法。 现在我了解到,这个事件是当一个交换机收到一个数据包时,它与控制器联系,而该数据包在它的表中没有条目 我不明白的是这里 packet = event.parsed 现在,isinstance(packet.next,ipv4)中的packet.next是什么意思 我想我已经弄明白了 数据包是数据链路层发送到物理层的整个数据包。packet.next移除数据链路层的封装并显示IP数据包(由I

在l3_learning.py中,
类l3_开关
中有一个名为
\u handle\u PacketIn
的方法。 现在我了解到,这个事件是当一个交换机收到一个数据包时,它与控制器联系,而该数据包在它的表中没有条目

我不明白的是这里

packet = event.parsed
现在,
isinstance(packet.next,ipv4)
中的packet.next是什么意思


我想我已经弄明白了


数据包是数据链路层发送到物理层的整个数据包。packet.next移除数据链路层的封装并显示IP数据包(由IP层发送到数据链路层的数据包)。因此,为了获取源MAC地址,我们使用packet.src,为了获取源IP地址,我们使用packet.next.srcip

您在哪里找到了这方面的文档?谢谢
def _handle_PacketIn (self, event):
    dpid = event.connection.dpid
    inport = event.port
    packet = event.parsed
    if not packet.parsed:
      log.warning("%i %i ignoring unparsed packet", dpid, inport)
      return

    if dpid not in self.arpTable:
      # New switch -- create an empty table
      self.arpTable[dpid] = {}
      for fake in self.fakeways:
        self.arpTable[dpid][IPAddr(fake)] = Entry(of.OFPP_NONE,
         dpid_to_mac(dpid))

    if packet.type == ethernet.LLDP_TYPE:
      # Ignore LLDP packets
      return

    if isinstance(packet.next, ipv4):
      log.debug("%i %i IP %s => %s", dpid,inport,
                packet.next.srcip,packet.next.dstip)

      # Send any waiting packets...
      self._send_lost_buffers(dpid, packet.next.srcip, packet.src, inport)

      # Learn or update port/MAC info
      if packet.next.srcip in self.arpTable[dpid]:
        if self.arpTable[dpid][packet.next.srcip] != (inport, packet.src):
          log.info("%i %i RE-learned %s", dpid,inport,packet.next.srcip)
      else:
        log.debug("%i %i learned %s", dpid,inport,str(packet.next.srcip))
      self.arpTable[dpid][packet.next.srcip] = Entry(inport, packet.src)

      # Try to forward
      dstaddr = packet.next.dstip
      if dstaddr in self.arpTable[dpid]:
        # We have info about what port to send it out on...

        prt = self.arpTable[dpid][dstaddr].port
        mac = self.arpTable[dpid][dstaddr].mac