コード例 #1
0
    def forward_l2_packet(self, con, inport, packet, buf, bufid):
        """
    Tenta aprender o destino MAC instituído à um fluxo e enviar apenas fora de suas portas de entrada.
    Se não, usa inundação.
    :param con: Fonte do pacote.
    :param inport: Porta de entrada.
    :param packet: Pacote recebido.
    :param buf: Tamanho do Buffer.
    :param bufid: ID do Buffer.
    :return: Sem retorno.
    """
        """If we've learned the destination MAC set up a flow and
    send only out of its inport.  Else, flood.
    """
        dstaddr = EthAddr(packet.dst)
        #if not ord(dstaddr[0]) & 1 and  # what did this do?
        if self.st[con].has_key(dstaddr.toStr()):  # raw?
            prt = self.st[con][dstaddr.toStr()]  # raw?
            if prt[0] == inport:
                log.warning('**warning** learned port = inport')
                ofcommand.floodPacket(con, inport, packet, buf, bufid)

            else:
                # We know the outport, set up a flow
                log.info('installing flow for ' + str(packet))
                match = ofcommand.extractMatch(packet)
                actions = [ofcommand.Output(prt[0])]
                ofcommand.addFlowEntry(con, inport, match, actions, bufid)
                # Separate bufid, make addFlowEntry() only ADD the entry
                # send/wait for Barrier
                # sendBufferedPacket(bufid)
        else:
            # haven't learned destination MAC. Flood
            ofcommand.floodPacket(con, inport, packet, buf, bufid)
コード例 #2
0
ファイル: ofcommand_l2_switch.py プロジェクト: apanda/pox
 def forward_l2_packet(self, con, inport, packet, buf, bufid):   
   """If we've learned the destination MAC set up a flow and
   send only out of its inport.  Else, flood.
   """
   dstaddr = EthAddr(packet.dst)
   #if not ord(dstaddr[0]) & 1 and  # what did this do?
   if self.st[con].has_key(dstaddr.toStr()):   # raw?
     prt = self.st[con][dstaddr.toStr()]                          # raw?
     if  prt[0] == inport:
       log.warning('**warning** learned port = inport')
       ofcommand.floodPacket(con, inport, packet, buf, bufid)
 
     else:
       # We know the outport, set up a flow
       log.info('installing flow for ' + str(packet))
       match = ofcommand.extractMatch(packet)
       actions = [ofcommand.Output(prt[0])]
       ofcommand.addFlowEntry(con, inport, match, actions, bufid)
       # Separate bufid, make addFlowEntry() only ADD the entry
       # send/wait for Barrier
       # sendBufferedPacket(bufid)
   else:    
     # haven't learned destination MAC. Flood 
     ofcommand.floodPacket(con, inport, packet, buf, bufid)
コード例 #3
0
ファイル: l2_learning_ofcommand.py プロジェクト: YuShijia/POX
    def forward_l2_packet(self, con, inport, packet, buf, bufid):
        """If we've learned the destination MAC set up a flow and
    send only out of its inport.  Else, flood.
    """
        dstaddr = EthAddr(packet.dst)
        #if not ord(dstaddr[0]) & 1 and  # what did this do?
        if self.st[con].has_key(dstaddr.toStr()):  # raw?
            prt = self.st[con][dstaddr.toStr()]  # raw?
            if prt[0] == inport:
                log.warning('**warning** learned port = inport')
                ofcommand.floodPacket(con, inport, packet, buf, bufid)

            else:
                # We know the outport, set up a flow
                log.info('installing flow for ' + str(packet))
                match = ofcommand.extractMatch(packet)
                actions = [ofcommand.Output(prt[0])]
                ofcommand.addFlowEntry(con, inport, match, actions, bufid)
                # Separate bufid, make addFlowEntry() only ADD the entry
                # send/wait for Barrier
                # sendBufferedPacket(bufid)
        else:
            # haven't learned destination MAC. Flood
            ofcommand.floodPacket(con, inport, packet, buf, bufid)