Java 类org.projectfloodlight.openflow.protocol.OFFlowRemoved 实例源码

项目:athena    文件:FeatureCollectorProvider.java   
@Override
        public void flowRemovedProcess(Dpid dpid, OFFlowRemoved flowRemoved) {
            FlowRemovedFeature frf = new FlowRemovedFeature();

            UnitFlowRemovedInformation ufri = new UnitFlowRemovedInformation(flowRemoved.getReason(),
                    flowRemoved.getDurationSec(), flowRemoved.getDurationNsec(),
                    flowRemoved.getIdleTimeout(), flowRemoved.getHardTimeout(),
                    flowRemoved.getPacketCount().getValue(), flowRemoved.getByteCount().getValue());
            Date date = new java.sql.Timestamp(Calendar.getInstance().getTime().getTime());

            ufri.setDate(date);

            FeatureIndex fi = matchToFeatureIndex(flowRemoved.getMatch());
            fi.setSwitchDatapathId(dpid.value());

            // extract rich feature -> store to UnitFlowstatistics
            ufri = (UnitFlowRemovedInformation) extractRichFeature(fi, ufri, AthenaFeatureField.FLOW_REMOVED);
            frf.addFeatureData(fi, ufri);

//            printFlowRemovedLFT(frStatisticsLFT);
            providerService.flowRemovedHandler(frf);
        }
项目:iTAP-controller    文件:ObfuscationSwitchStateManager.java   
@Override
public net.floodlightcontroller.core.IListener.Command receive(
        IOFSwitch sw, OFMessage msg, FloodlightContext cntx) {
    System.out.println("flow expired: "+sw.toString() + msg.toString());

    //OFFlowRemoved flowRemoved = (OFFlowRemoved) msg;

    if (!switchStates.containsKey(sw))
        switchStates.put(sw, new ObfuscationSwitchState(sw));

    if (msg.getType() == OFType.FLOW_REMOVED) {
        OFFlowRemoved flowRemoved = (OFFlowRemoved) msg;
        System.out.println("flow expired: "+sw.toString() + "dst: " + flowRemoved.getCookie());
        long dst = flowRemoved.getCookie().getValue();
        ObfuscationHeader oHeader = new ObfuscationHeader();
        Match match = flowRemoved.getMatch();

        switchStates.get(sw).removeDestinationID(dst);

    }

    return Command.CONTINUE;
}
项目:floodlight-hardware    文件:LearningSwitch.java   
@Override
public Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx) {
    switch (msg.getType()) {
    case PACKET_IN:
        System.out.println("SXT_DBG:LearningSwitch:514----receive  packet_in");
        return this.processPacketInMessage(sw, (OFPacketIn) msg, cntx);
    case FLOW_REMOVED:
        return this.processFlowRemovedMessage(sw, (OFFlowRemoved) msg);
    case ERROR:
        log.info("received an error {} from switch {}", msg, sw);
        return Command.CONTINUE;
    default:
        log.error("received an unexpected message {} from switch {}", msg, sw);
        return Command.CONTINUE;
    }
}
项目:floodlight    文件:LearningSwitch.java   
@Override
public Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx) {
    switch (msg.getType()) {
        case PACKET_IN:
            return this.processPacketInMessage(sw, (OFPacketIn) msg, cntx);
        case FLOW_REMOVED:
            return this.processFlowRemovedMessage(sw, (OFFlowRemoved) msg);
        case ERROR:
            log.info("received an error {} from switch {}", msg, sw);
            return Command.CONTINUE;
        default:
            break;
    }
    log.error("received an unexpected message {} from switch {}", msg, sw);
    return Command.CONTINUE;
}
项目:floodlight    文件:StaticFlowEntryPusher.java   
/**
 * Handles a flow removed message from a switch. If the flow was removed
 * and we did not explicitly delete it we re-install it. If we explicitly
 * removed the flow we stop the processing of the flow removed message.
 * @param sw The switch that sent the flow removed message.
 * @param msg The flow removed message.
 * @param cntx The associated context.
 * @return Whether to continue processing this message.
 */
public Command handleFlowRemoved(IOFSwitch sw, OFFlowRemoved msg, FloodlightContext cntx) {
    U64 cookie = msg.getCookie();
    /**
     * This is just to sanity check our assumption that static flows
     * never expire.
     */
    if (AppCookie.extractApp(cookie) == STATIC_FLOW_APP_ID) {
        if (OFFlowRemovedReason.DELETE.equals(msg.getReason()))
            log.error("Got a FlowRemove message for a infinite " +
                    "timeout flow: {} from switch {}", msg, sw);
        // Stop the processing chain since we sent the delete.
        return Command.STOP;
    }

    return Command.CONTINUE;
}
项目:athena    文件:FlowEntryBuilder.java   
public FlowEntryBuilder(DeviceId deviceId, OFFlowRemoved removed, DriverService driverService) {
    this.match = removed.getMatch();
    this.removed = removed;
    this.deviceId = deviceId;
    this.instructions = null;
    this.stat = null;
    this.flowMod = null;
    this.type = FlowType.REMOVED;
    this.driverService = driverService;
}
项目:fresco_floodlight    文件:SecurityKernel.java   
private Command handleFlowRemovedMessage(IOFSwitch sw, OFFlowRemoved ofr){
    HashMap<Long, FlowAlias> faList = cMap.get(sw.getId());

    if (faList != null){
        if (faList.remove(ofr.getCookie()) != null){
            log.debug("Clear Flow Alias corresponding to removed Flow Mod.");

        }else{//cannot find to-remove flow alias
            log.error("Cannot find Flow Alias corresponding to removed Flow Mod.");
        }
    }

    cMap.put(sw.getId(), faList);
    return Command.CONTINUE;
}
项目:fresco_floodlight    文件:SecurityKernel.java   
@Override
public net.floodlightcontroller.core.IListener.Command receive(IOFSwitch sw, OFMessage msg,
        FloodlightContext cntx) {

    switch (msg.getType()) {
    case FLOW_REMOVED:
        return this.handleFlowRemovedMessage(sw, (OFFlowRemoved) msg);  
    default:
        return Command.CONTINUE;
    }

}
项目:fresco_floodlight    文件:LearningSwitch.java   
/**
 * Processes a flow removed message. We will delete the learned MAC/VLAN mapping from
 * the switch's table.
 * @param sw The switch that sent the flow removed message.
 * @param flowRemovedMessage The flow removed message.
 * @return Whether to continue processing this message or stop.
 */
private Command processFlowRemovedMessage(IOFSwitch sw, OFFlowRemoved flowRemovedMessage) {
    if (!flowRemovedMessage.getCookie().equals(U64.of(LearningSwitch.LEARNING_SWITCH_COOKIE))) {
        return Command.CONTINUE;
    }
    if (log.isTraceEnabled()) {
        log.trace("{} flow entry removed {}", sw, flowRemovedMessage);
    }
    Match match = flowRemovedMessage.getMatch();
    // When a flow entry expires, it means the device with the matching source
    // MAC address and VLAN either stopped sending packets or moved to a different
    // port.  If the device moved, we can't know where it went until it sends
    // another packet, allowing us to re-learn its port.  Meanwhile we remove
    // it from the macVlanToPortMap to revert to flooding packets to this device.
    this.removeFromPortMap(sw, match.get(MatchField.ETH_SRC), 
            match.get(MatchField.VLAN_VID) == null 
            ? VlanVid.ZERO 
            : match.get(MatchField.VLAN_VID).getVlanVid());

    // Also, if packets keep coming from another device (e.g. from ping), the
    // corresponding reverse flow entry will never expire on its own and will
    // send the packets to the wrong port (the matching input port of the
    // expired flow entry), so we must delete the reverse entry explicitly.
    Match.Builder mb = sw.getOFFactory().buildMatch();
    mb.setExact(MatchField.ETH_SRC, match.get(MatchField.ETH_DST))                         
    .setExact(MatchField.ETH_DST, match.get(MatchField.ETH_SRC));
    if (match.get(MatchField.VLAN_VID) != null) {
        mb.setExact(MatchField.VLAN_VID, match.get(MatchField.VLAN_VID));                    
    }
    this.writeFlowMod(sw, OFFlowModCommand.DELETE, OFBufferId.NO_BUFFER, mb.build(), match.get(MatchField.IN_PORT));
    return Command.CONTINUE;
}
项目:fresco_floodlight    文件:LearningSwitch.java   
@Override
public Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx) {
    switch (msg.getType()) {
    case PACKET_IN:
        return this.processPacketInMessage(sw, (OFPacketIn) msg, cntx);
    case FLOW_REMOVED:
        return this.processFlowRemovedMessage(sw, (OFFlowRemoved) msg);
    case ERROR:
        log.info("received an error {} from switch {}", msg, sw);
        return Command.CONTINUE;
    default:
        log.error("received an unexpected message {} from switch {}", msg, sw);
        return Command.CONTINUE;
    }
}
项目:fresco_floodlight    文件:StaticFlowEntryPusher.java   
@Override
public Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx) {
    switch (msg.getType()) {
    case FLOW_REMOVED:
        return handleFlowRemoved(sw, (OFFlowRemoved) msg, cntx);
    default:
        return Command.CONTINUE;
    }
}
项目:fresco_floodlight    文件:OFSwitchHandshakeHandler.java   
/**
 * Process an OF message received on the channel and
 * update state accordingly.
 *
 * The main "event" of the state machine. Process the received message,
 * send follow up message if required and update state if required.
 *
 * Switches on the message type and calls more specific event handlers
 * for each individual OF message type. If we receive a message that
 * is supposed to be sent from a controller to a switch we throw
 * a SwitchStateExeption.
 *
 * The more specific handlers can also throw SwitchStateExceptions
 *
 * @param h The OFChannelHandler that received the message
 * @param m The message we received.
 * @throws SwitchStateException
 * @throws IOException
 */
void processOFMessage(OFMessage m) {
    roleChanger.checkTimeout();
    switch(m.getType()) {
    case BARRIER_REPLY:
        processOFBarrierReply((OFBarrierReply) m);
        break;
    case ERROR:
        processOFError((OFErrorMsg) m);
        break;
    case FLOW_REMOVED:
        processOFFlowRemoved((OFFlowRemoved) m);
        break;
    case GET_CONFIG_REPLY:
        processOFGetConfigReply((OFGetConfigReply) m);
        break;
    case PACKET_IN:
        processOFPacketIn((OFPacketIn) m);
        break;
    case PORT_STATUS:
        processOFPortStatus((OFPortStatus) m);
        break;
    case QUEUE_GET_CONFIG_REPLY:
        processOFQueueGetConfigReply((OFQueueGetConfigReply) m);
        break;
    case STATS_REPLY:
        processOFStatsReply((OFStatsReply) m);
        break;
    case ROLE_REPLY:
        processOFRoleReply((OFRoleReply) m);
        break;
    case EXPERIMENTER:
        processOFExperimenter((OFExperimenter) m);
        break;
    default:
        illegalMessageReceived(m);
        break;
    }
}
项目:iTAP-controller    文件:LearningSwitch.java   
/**
 * Processes a flow removed message. We will delete the learned MAC/VLAN mapping from
 * the switch's table.
 * @param sw The switch that sent the flow removed message.
 * @param flowRemovedMessage The flow removed message.
 * @return Whether to continue processing this message or stop.
 */
private Command processFlowRemovedMessage(IOFSwitch sw, OFFlowRemoved flowRemovedMessage) {
    if (!flowRemovedMessage.getCookie().equals(U64.of(LearningSwitch.LEARNING_SWITCH_COOKIE))) {
        return Command.CONTINUE;
    }
    if (log.isTraceEnabled()) {
        log.trace("{} flow entry removed {}", sw, flowRemovedMessage);
    }
    Match match = flowRemovedMessage.getMatch();
    // When a flow entry expires, it means the device with the matching source
    // MAC address and VLAN either stopped sending packets or moved to a different
    // port.  If the device moved, we can't know where it went until it sends
    // another packet, allowing us to re-learn its port.  Meanwhile we remove
    // it from the macVlanToPortMap to revert to flooding packets to this device.
    this.removeFromPortMap(sw, match.get(MatchField.ETH_SRC), 
            match.get(MatchField.VLAN_VID) == null 
            ? VlanVid.ZERO 
            : match.get(MatchField.VLAN_VID).getVlanVid());

    // Also, if packets keep coming from another device (e.g. from ping), the
    // corresponding reverse flow entry will never expire on its own and will
    // send the packets to the wrong port (the matching input port of the
    // expired flow entry), so we must delete the reverse entry explicitly.
    Match.Builder mb = sw.getOFFactory().buildMatch();
    mb.setExact(MatchField.ETH_SRC, match.get(MatchField.ETH_DST))                         
    .setExact(MatchField.ETH_DST, match.get(MatchField.ETH_SRC));
    if (match.get(MatchField.VLAN_VID) != null) {
        mb.setExact(MatchField.VLAN_VID, match.get(MatchField.VLAN_VID));                    
    }
    this.writeFlowMod(sw, OFFlowModCommand.DELETE, OFBufferId.NO_BUFFER, mb.build(), match.get(MatchField.IN_PORT));
    return Command.CONTINUE;
}
项目:iTAP-controller    文件:LearningSwitch.java   
@Override
public Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx) {
    switch (msg.getType()) {
    case PACKET_IN:
        return this.processPacketInMessage(sw, (OFPacketIn) msg, cntx);
    case FLOW_REMOVED:
        return this.processFlowRemovedMessage(sw, (OFFlowRemoved) msg);
    case ERROR:
        log.info("received an error {} from switch {}", msg, sw);
        return Command.CONTINUE;
    default:
        log.error("received an unexpected message {} from switch {}", msg, sw);
        return Command.CONTINUE;
    }
}
项目:iTAP-controller    文件:StaticFlowEntryPusher.java   
@Override
@LogMessageDoc(level="ERROR",
message="Got a FlowRemove message for a infinite " +
        "timeout flow: {flow} from switch {switch}",
        explanation="Flows with infinite timeouts should not expire. " +
                "The switch has expired the flow anyway.",
                recommendation=LogMessageDoc.REPORT_SWITCH_BUG)
public Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx) {
    switch (msg.getType()) {
    case FLOW_REMOVED:
        return handleFlowRemoved(sw, (OFFlowRemoved) msg, cntx);
    default:
        return Command.CONTINUE;
    }
}
项目:iTAP-controller    文件:OFSwitchHandshakeHandler.java   
/**
 * Process an OF message received on the channel and
 * update state accordingly.
 *
 * The main "event" of the state machine. Process the received message,
 * send follow up message if required and update state if required.
 *
 * Switches on the message type and calls more specific event handlers
 * for each individual OF message type. If we receive a message that
 * is supposed to be sent from a controller to a switch we throw
 * a SwitchStateExeption.
 *
 * The more specific handlers can also throw SwitchStateExceptions
 *
 * @param h The OFChannelHandler that received the message
 * @param m The message we received.
 * @throws SwitchStateException
 * @throws IOException
 */
void processOFMessage(OFMessage m) {
    roleChanger.checkTimeout();
    switch(m.getType()) {
    case BARRIER_REPLY:
        processOFBarrierReply((OFBarrierReply) m);
        break;
    case ERROR:
        processOFError((OFErrorMsg) m);
        break;
    case FLOW_REMOVED:
        processOFFlowRemoved((OFFlowRemoved) m);
        break;
    case GET_CONFIG_REPLY:
        processOFGetConfigReply((OFGetConfigReply) m);
        break;
    case PACKET_IN:
        processOFPacketIn((OFPacketIn) m);
        break;
    case PORT_STATUS:
        processOFPortStatus((OFPortStatus) m);
        break;
    case QUEUE_GET_CONFIG_REPLY:
        processOFQueueGetConfigReply((OFQueueGetConfigReply) m);
        break;
    case STATS_REPLY:
        processOFStatsReply((OFStatsReply) m);
        break;
    case ROLE_REPLY:
        processOFRoleReply((OFRoleReply) m);
        break;
    case EXPERIMENTER:
        processOFExperimenter((OFExperimenter) m);
        break;
    default:
        illegalMessageReceived(m);
        break;
    }
}
项目:SDN-Multicast    文件:LearningSwitch.java   
/**
 * Processes a flow removed message. We will delete the learned MAC/VLAN mapping from
 * the switch's table.
 * @param sw The switch that sent the flow removed message.
 * @param flowRemovedMessage The flow removed message.
 * @return Whether to continue processing this message or stop.
 */
private Command processFlowRemovedMessage(IOFSwitch sw, OFFlowRemoved flowRemovedMessage) {
    if (!flowRemovedMessage.getCookie().equals(U64.of(LearningSwitch.LEARNING_SWITCH_COOKIE))) {
        return Command.CONTINUE;
    }
    if (log.isTraceEnabled()) {
        log.trace("{} flow entry removed {}", sw, flowRemovedMessage);
    }
    Match match = flowRemovedMessage.getMatch();
    // When a flow entry expires, it means the device with the matching source
    // MAC address and VLAN either stopped sending packets or moved to a different
    // port.  If the device moved, we can't know where it went until it sends
    // another packet, allowing us to re-learn its port.  Meanwhile we remove
    // it from the macVlanToPortMap to revert to flooding packets to this device.
    this.removeFromPortMap(sw, match.get(MatchField.ETH_SRC), 
            match.get(MatchField.VLAN_VID) == null 
            ? VlanVid.ZERO 
            : match.get(MatchField.VLAN_VID).getVlanVid());

    // Also, if packets keep coming from another device (e.g. from ping), the
    // corresponding reverse flow entry will never expire on its own and will
    // send the packets to the wrong port (the matching input port of the
    // expired flow entry), so we must delete the reverse entry explicitly.
    Match.Builder mb = sw.getOFFactory().buildMatch();
    mb.setExact(MatchField.ETH_SRC, match.get(MatchField.ETH_DST))                         
    .setExact(MatchField.ETH_DST, match.get(MatchField.ETH_SRC));
    if (match.get(MatchField.VLAN_VID) != null) {
        mb.setExact(MatchField.VLAN_VID, match.get(MatchField.VLAN_VID));                    
    }
    this.writeFlowMod(sw, OFFlowModCommand.DELETE, OFBufferId.NO_BUFFER, mb.build(), match.get(MatchField.IN_PORT));
    return Command.CONTINUE;
}
项目:SDN-Multicast    文件:LearningSwitch.java   
@Override
public Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx) {
    switch (msg.getType()) {
    case PACKET_IN:
        return this.processPacketInMessage(sw, (OFPacketIn) msg, cntx);
    case FLOW_REMOVED:
        return this.processFlowRemovedMessage(sw, (OFFlowRemoved) msg);
    case ERROR:
        log.info("received an error {} from switch {}", msg, sw);
        return Command.CONTINUE;
    default:
        log.error("received an unexpected message {} from switch {}", msg, sw);
        return Command.CONTINUE;
    }
}
项目:SDN-Multicast    文件:StaticFlowEntryPusher.java   
@Override
public Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx) {
    switch (msg.getType()) {
    case FLOW_REMOVED:
        return handleFlowRemoved(sw, (OFFlowRemoved) msg, cntx);
    default:
        return Command.CONTINUE;
    }
}
项目:SDN-Multicast    文件:OFSwitchHandshakeHandler.java   
/**
 * Process an OF message received on the channel and
 * update state accordingly.
 *
 * The main "event" of the state machine. Process the received message,
 * send follow up message if required and update state if required.
 *
 * Switches on the message type and calls more specific event handlers
 * for each individual OF message type. If we receive a message that
 * is supposed to be sent from a controller to a switch we throw
 * a SwitchStateExeption.
 *
 * The more specific handlers can also throw SwitchStateExceptions
 *
 * @param h The OFChannelHandler that received the message
 * @param m The message we received.
 * @throws SwitchStateException
 * @throws IOException
 */
void processOFMessage(OFMessage m) {
    roleChanger.checkTimeout();
    switch(m.getType()) {
    case BARRIER_REPLY:
        processOFBarrierReply((OFBarrierReply) m);
        break;
    case ERROR:
        processOFError((OFErrorMsg) m);
        break;
    case FLOW_REMOVED:
        processOFFlowRemoved((OFFlowRemoved) m);
        break;
    case GET_CONFIG_REPLY:
        processOFGetConfigReply((OFGetConfigReply) m);
        break;
    case PACKET_IN:
        processOFPacketIn((OFPacketIn) m);
        break;
    case PORT_STATUS:
        processOFPortStatus((OFPortStatus) m);
        break;
    case QUEUE_GET_CONFIG_REPLY:
        processOFQueueGetConfigReply((OFQueueGetConfigReply) m);
        break;
    case STATS_REPLY:
        processOFStatsReply((OFStatsReply) m);
        break;
    case ROLE_REPLY:
        processOFRoleReply((OFRoleReply) m);
        break;
    case EXPERIMENTER:
        processOFExperimenter((OFExperimenter) m);
        break;
    default:
        illegalMessageReceived(m);
        break;
    }
}
项目:arscheduler    文件:LearningSwitch.java   
/**
 * Processes a flow removed message. We will delete the learned MAC/VLAN mapping from
 * the switch's table.
 * @param sw The switch that sent the flow removed message.
 * @param flowRemovedMessage The flow removed message.
 * @return Whether to continue processing this message or stop.
 */
private Command processFlowRemovedMessage(IOFSwitch sw, OFFlowRemoved flowRemovedMessage) {
    if (!flowRemovedMessage.getCookie().equals(U64.of(LearningSwitch.LEARNING_SWITCH_COOKIE))) {
        return Command.CONTINUE;
    }
    if (log.isTraceEnabled()) {
        log.trace("{} flow entry removed {}", sw, flowRemovedMessage);
    }
    Match match = flowRemovedMessage.getMatch();
    // When a flow entry expires, it means the device with the matching source
    // MAC address and VLAN either stopped sending packets or moved to a different
    // port.  If the device moved, we can't know where it went until it sends
    // another packet, allowing us to re-learn its port.  Meanwhile we remove
    // it from the macVlanToPortMap to revert to flooding packets to this device.
    this.removeFromPortMap(sw, match.get(MatchField.ETH_SRC), 
            match.get(MatchField.VLAN_VID) == null 
            ? VlanVid.ZERO 
            : match.get(MatchField.VLAN_VID).getVlanVid());

    // Also, if packets keep coming from another device (e.g. from ping), the
    // corresponding reverse flow entry will never expire on its own and will
    // send the packets to the wrong port (the matching input port of the
    // expired flow entry), so we must delete the reverse entry explicitly.
    Match.Builder mb = sw.getOFFactory().buildMatch();
    mb.setExact(MatchField.ETH_SRC, match.get(MatchField.ETH_DST))                         
    .setExact(MatchField.ETH_DST, match.get(MatchField.ETH_SRC));
    if (match.get(MatchField.VLAN_VID) != null) {
        mb.setExact(MatchField.VLAN_VID, match.get(MatchField.VLAN_VID));                    
    }
    this.writeFlowMod(sw, OFFlowModCommand.DELETE, OFBufferId.NO_BUFFER, mb.build(), match.get(MatchField.IN_PORT));
    return Command.CONTINUE;
}
项目:arscheduler    文件:LearningSwitch.java   
@Override
public Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx) {
    switch (msg.getType()) {
    case PACKET_IN:
        return this.processPacketInMessage(sw, (OFPacketIn) msg, cntx);
    case FLOW_REMOVED:
        return this.processFlowRemovedMessage(sw, (OFFlowRemoved) msg);
    case ERROR:
        log.info("received an error {} from switch {}", msg, sw);
        return Command.CONTINUE;
    default:
        log.error("received an unexpected message {} from switch {}", msg, sw);
        return Command.CONTINUE;
    }
}
项目:arscheduler    文件:StaticFlowEntryPusher.java   
@Override
public Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx) {
    switch (msg.getType()) {
    case FLOW_REMOVED:
        return handleFlowRemoved(sw, (OFFlowRemoved) msg, cntx);
    default:
        return Command.CONTINUE;
    }
}
项目:floodlight1.2-delay    文件:LearningSwitch.java   
/**
 * Processes a flow removed message. We will delete the learned MAC/VLAN mapping from
 * the switch's table.
 * @param sw The switch that sent the flow removed message.
 * @param flowRemovedMessage The flow removed message.
 * @return Whether to continue processing this message or stop.
 */
private Command processFlowRemovedMessage(IOFSwitch sw, OFFlowRemoved flowRemovedMessage) {
    if (!flowRemovedMessage.getCookie().equals(U64.of(LearningSwitch.LEARNING_SWITCH_COOKIE))) {
        return Command.CONTINUE;
    }
    if (log.isTraceEnabled()) {
        log.trace("{} flow entry removed {}", sw, flowRemovedMessage);
    }
    Match match = flowRemovedMessage.getMatch();
    // When a flow entry expires, it means the device with the matching source
    // MAC address and VLAN either stopped sending packets or moved to a different
    // port.  If the device moved, we can't know where it went until it sends
    // another packet, allowing us to re-learn its port.  Meanwhile we remove
    // it from the macVlanToPortMap to revert to flooding packets to this device.
    this.removeFromPortMap(sw, match.get(MatchField.ETH_SRC), 
            match.get(MatchField.VLAN_VID) == null 
            ? VlanVid.ZERO 
            : match.get(MatchField.VLAN_VID).getVlanVid());

    // Also, if packets keep coming from another device (e.g. from ping), the
    // corresponding reverse flow entry will never expire on its own and will
    // send the packets to the wrong port (the matching input port of the
    // expired flow entry), so we must delete the reverse entry explicitly.
    Match.Builder mb = sw.getOFFactory().buildMatch();
    mb.setExact(MatchField.ETH_SRC, match.get(MatchField.ETH_DST))                         
    .setExact(MatchField.ETH_DST, match.get(MatchField.ETH_SRC));
    if (match.get(MatchField.VLAN_VID) != null) {
        mb.setExact(MatchField.VLAN_VID, match.get(MatchField.VLAN_VID));                    
    }
    this.writeFlowMod(sw, OFFlowModCommand.DELETE, OFBufferId.NO_BUFFER, mb.build(), match.get(MatchField.IN_PORT));
    return Command.CONTINUE;
}
项目:floodlight1.2-delay    文件:LearningSwitch.java   
@Override
public Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx) {
    switch (msg.getType()) {
    case PACKET_IN:
        return this.processPacketInMessage(sw, (OFPacketIn) msg, cntx);
    case FLOW_REMOVED:
        return this.processFlowRemovedMessage(sw, (OFFlowRemoved) msg);
    case ERROR:
        log.info("received an error {} from switch {}", msg, sw);
        return Command.CONTINUE;
    default:
        log.error("received an unexpected message {} from switch {}", msg, sw);
        return Command.CONTINUE;
    }
}
项目:floodlight1.2-delay    文件:StaticFlowEntryPusher.java   
@Override
public Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx) {
    switch (msg.getType()) {
    case FLOW_REMOVED:
        return handleFlowRemoved(sw, (OFFlowRemoved) msg, cntx);
    default:
        return Command.CONTINUE;
    }
}
项目:floodlight1.2-delay    文件:OFSwitchHandshakeHandler.java   
/**
 * Process an OF message received on the channel and
 * update state accordingly.
 *
 * The main "event" of the state machine. Process the received message,
 * send follow up message if required and update state if required.
 *
 * Switches on the message type and calls more specific event handlers
 * for each individual OF message type. If we receive a message that
 * is supposed to be sent from a controller to a switch we throw
 * a SwitchStateExeption.
 *
 * The more specific handlers can also throw SwitchStateExceptions
 *
 * @param h The OFChannelHandler that received the message
 * @param m The message we received.
 * @throws SwitchStateException
 * @throws IOException
 */
void processOFMessage(OFMessage m) {
    roleChanger.checkTimeout();
    switch(m.getType()) {
    case BARRIER_REPLY:
        processOFBarrierReply((OFBarrierReply) m);
        break;
    case ERROR:
        processOFError((OFErrorMsg) m);
        break;
    case FLOW_REMOVED:
        processOFFlowRemoved((OFFlowRemoved) m);
        break;
    case GET_CONFIG_REPLY:
        processOFGetConfigReply((OFGetConfigReply) m);
        break;
    case PACKET_IN:
        processOFPacketIn((OFPacketIn) m);
        break;
    case PORT_STATUS:
        processOFPortStatus((OFPortStatus) m);
        break;
    case QUEUE_GET_CONFIG_REPLY:
        processOFQueueGetConfigReply((OFQueueGetConfigReply) m);
        break;
    case STATS_REPLY:
        processOFStatsReply((OFStatsReply) m);
        break;
    case ROLE_REPLY:
        processOFRoleReply((OFRoleReply) m);
        break;
    case EXPERIMENTER:
        processOFExperimenter((OFExperimenter) m);
        break;
    default:
        illegalMessageReceived(m);
        break;
    }
}
项目:floodlight-hardware    文件:LearningSwitch.java   
/**
 * Processes a flow removed message. We will delete the learned MAC/VLAN mapping from
 * the switch's table.
 * @param sw The switch that sent the flow removed message.
 * @param flowRemovedMessage The flow removed message.
 * @return Whether to continue processing this message or stop.
 */
private Command processFlowRemovedMessage(IOFSwitch sw, OFFlowRemoved flowRemovedMessage) {
    if (!flowRemovedMessage.getCookie().equals(U64.of(LearningSwitch.LEARNING_SWITCH_COOKIE))) {
        return Command.CONTINUE;
    }
    if (log.isTraceEnabled()) {
        log.trace("{} flow entry removed {}", sw, flowRemovedMessage);
    }
    Match match = flowRemovedMessage.getMatch();
    // When a flow entry expires, it means the device with the matching source
    // MAC address and VLAN either stopped sending packets or moved to a different
    // port.  If the device moved, we can't know where it went until it sends
    // another packet, allowing us to re-learn its port.  Meanwhile we remove
    // it from the macVlanToPortMap to revert to flooding packets to this device.
    this.removeFromPortMap(sw, match.get(MatchField.ETH_SRC),
            match.get(MatchField.VLAN_VID) == null
            ? VlanVid.ZERO
            : match.get(MatchField.VLAN_VID).getVlanVid());

    // Also, if packets keep coming from another device (e.g. from ping), the
    // corresponding reverse flow entry will never expire on its own and will
    // send the packets to the wrong port (the matching input port of the
    // expired flow entry), so we must delete the reverse entry explicitly.
    Match.Builder mb = sw.getOFFactory().buildMatch();
    mb.setExact(MatchField.ETH_SRC, match.get(MatchField.ETH_DST))
    .setExact(MatchField.ETH_DST, match.get(MatchField.ETH_SRC));
    if (match.get(MatchField.VLAN_VID) != null) {
        mb.setExact(MatchField.VLAN_VID, match.get(MatchField.VLAN_VID));
    }
    this.writeFlowMod(sw, OFFlowModCommand.DELETE, OFBufferId.NO_BUFFER, mb.build(), match.get(MatchField.IN_PORT));
    return Command.CONTINUE;
}
项目:floodlight-hardware    文件:StaticFlowEntryPusher.java   
@Override
public Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx) {
    switch (msg.getType()) {
    case FLOW_REMOVED:
        return handleFlowRemoved(sw, (OFFlowRemoved) msg, cntx);
    default:
        return Command.CONTINUE;
    }
}
项目:floodlight-hardware    文件:OFSwitchHandshakeHandler.java   
/**
 * Process an OF message received on the channel and
 * update state accordingly.
 *
 * The main "event" of the state machine. Process the received message,
 * send follow up message if required and update state if required.
 *
 * Switches on the message type and calls more specific event handlers
 * for each individual OF message type. If we receive a message that
 * is supposed to be sent from a controller to a switch we throw
 * a SwitchStateExeption.
 *
 * The more specific handlers can also throw SwitchStateExceptions
 *
 * @param h The OFChannelHandler that received the message
 * @param m The message we received.
 * @throws SwitchStateException
 * @throws IOException
 */
void processOFMessage(OFMessage m) {
    roleChanger.checkTimeout();
    switch(m.getType()) {
    case BARRIER_REPLY:
        processOFBarrierReply((OFBarrierReply) m);
        break;
    case ERROR:
        processOFError((OFErrorMsg) m);
        break;
    case FLOW_REMOVED:
        processOFFlowRemoved((OFFlowRemoved) m);
        break;
    case GET_CONFIG_REPLY:
        processOFGetConfigReply((OFGetConfigReply) m);
        break;
    case PACKET_IN:
        processOFPacketIn((OFPacketIn) m);
        break;
    case PORT_STATUS:
        processOFPortStatus((OFPortStatus) m);
        break;
    case QUEUE_GET_CONFIG_REPLY:
        processOFQueueGetConfigReply((OFQueueGetConfigReply) m);
        break;
    case STATS_REPLY:
        processOFStatsReply((OFStatsReply) m);
        break;
    case ROLE_REPLY:
        processOFRoleReply((OFRoleReply) m);
        break;
    case EXPERIMENTER:
        processOFExperimenter((OFExperimenter) m);
        break;
    default:
        illegalMessageReceived(m);
        break;
    }
}
项目:ACAMPController    文件:LearningSwitch.java   
/**
 * Processes a flow removed message. We will delete the learned MAC/VLAN mapping from
 * the switch's table.
 * @param sw The switch that sent the flow removed message.
 * @param flowRemovedMessage The flow removed message.
 * @return Whether to continue processing this message or stop.
 */
private Command processFlowRemovedMessage(IOFSwitch sw, OFFlowRemoved flowRemovedMessage) {
    if (!flowRemovedMessage.getCookie().equals(U64.of(LearningSwitch.LEARNING_SWITCH_COOKIE))) {
        return Command.CONTINUE;
    }
    if (log.isTraceEnabled()) {
        log.trace("{} flow entry removed {}", sw, flowRemovedMessage);
    }
    Match match = flowRemovedMessage.getMatch();
    // When a flow entry expires, it means the device with the matching source
    // MAC address and VLAN either stopped sending packets or moved to a different
    // port.  If the device moved, we can't know where it went until it sends
    // another packet, allowing us to re-learn its port.  Meanwhile we remove
    // it from the macVlanToPortMap to revert to flooding packets to this device.
    this.removeFromPortMap(sw, match.get(MatchField.ETH_SRC), 
            match.get(MatchField.VLAN_VID) == null 
            ? VlanVid.ZERO 
            : match.get(MatchField.VLAN_VID).getVlanVid());

    // Also, if packets keep coming from another device (e.g. from ping), the
    // corresponding reverse flow entry will never expire on its own and will
    // send the packets to the wrong port (the matching input port of the
    // expired flow entry), so we must delete the reverse entry explicitly.
    Match.Builder mb = sw.getOFFactory().buildMatch();
    mb.setExact(MatchField.ETH_SRC, match.get(MatchField.ETH_DST))                         
    .setExact(MatchField.ETH_DST, match.get(MatchField.ETH_SRC));
    if (match.get(MatchField.VLAN_VID) != null) {
        mb.setExact(MatchField.VLAN_VID, match.get(MatchField.VLAN_VID));                    
    }
    this.writeFlowMod(sw, OFFlowModCommand.DELETE, OFBufferId.NO_BUFFER, mb.build(), match.get(MatchField.IN_PORT));
    return Command.CONTINUE;
}
项目:ACAMPController    文件:LearningSwitch.java   
@Override
public Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx) {
    switch (msg.getType()) {
    case PACKET_IN:
        return this.processPacketInMessage(sw, (OFPacketIn) msg, cntx);
    case FLOW_REMOVED:
        return this.processFlowRemovedMessage(sw, (OFFlowRemoved) msg);
    case ERROR:
        log.info("received an error {} from switch {}", msg, sw);
        return Command.CONTINUE;
    default:
        log.error("received an unexpected message {} from switch {}", msg, sw);
        return Command.CONTINUE;
    }
}
项目:ACAMPController    文件:StaticFlowEntryPusher.java   
@Override
public Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx) {
    switch (msg.getType()) {
    case FLOW_REMOVED:
        return handleFlowRemoved(sw, (OFFlowRemoved) msg, cntx);
    default:
        return Command.CONTINUE;
    }
}
项目:ACAMPController    文件:OFSwitchHandshakeHandler.java   
/**
 * Process an OF message received on the channel and
 * update state accordingly.
 *
 * The main "event" of the state machine. Process the received message,
 * send follow up message if required and update state if required.
 *
 * Switches on the message type and calls more specific event handlers
 * for each individual OF message type. If we receive a message that
 * is supposed to be sent from a controller to a switch we throw
 * a SwitchStateExeption.
 *
 * The more specific handlers can also throw SwitchStateExceptions
 *
 * @param h The OFChannelHandler that received the message
 * @param m The message we received.
 * @throws SwitchStateException
 * @throws IOException
 */
void processOFMessage(OFMessage m) {
    roleChanger.checkTimeout();
    switch(m.getType()) {
    case BARRIER_REPLY:
        processOFBarrierReply((OFBarrierReply) m);
        break;
    case ERROR:
        processOFError((OFErrorMsg) m);
        break;
    case FLOW_REMOVED:
        processOFFlowRemoved((OFFlowRemoved) m);
        break;
    case GET_CONFIG_REPLY:
        processOFGetConfigReply((OFGetConfigReply) m);
        break;
    case PACKET_IN:
        processOFPacketIn((OFPacketIn) m);
        break;
    case PORT_STATUS:
        processOFPortStatus((OFPortStatus) m);
        break;
    case QUEUE_GET_CONFIG_REPLY:
        processOFQueueGetConfigReply((OFQueueGetConfigReply) m);
        break;
    case STATS_REPLY:
        processOFStatsReply((OFStatsReply) m);
        break;
    case ROLE_REPLY:
        processOFRoleReply((OFRoleReply) m);
        break;
    case EXPERIMENTER:
        processOFExperimenter((OFExperimenter) m);
        break;
    default:
        illegalMessageReceived(m);
        break;
    }
}
项目:fast-failover-demo    文件:LearningSwitch.java   
/**
 * Processes a flow removed message. We will delete the learned MAC/VLAN mapping from
 * the switch's table.
 * @param sw The switch that sent the flow removed message.
 * @param flowRemovedMessage The flow removed message.
 * @return Whether to continue processing this message or stop.
 */
private Command processFlowRemovedMessage(IOFSwitch sw, OFFlowRemoved flowRemovedMessage) {
    if (!flowRemovedMessage.getCookie().equals(U64.of(LearningSwitch.LEARNING_SWITCH_COOKIE))) {
        return Command.CONTINUE;
    }
    if (log.isTraceEnabled()) {
        log.trace("{} flow entry removed {}", sw, flowRemovedMessage);
    }
    Match match = flowRemovedMessage.getMatch();
    // When a flow entry expires, it means the device with the matching source
    // MAC address and VLAN either stopped sending packets or moved to a different
    // port.  If the device moved, we can't know where it went until it sends
    // another packet, allowing us to re-learn its port.  Meanwhile we remove
    // it from the macVlanToPortMap to revert to flooding packets to this device.
    this.removeFromPortMap(sw, match.get(MatchField.ETH_SRC), 
            match.get(MatchField.VLAN_VID) == null 
            ? VlanVid.ZERO 
            : match.get(MatchField.VLAN_VID).getVlanVid());

    // Also, if packets keep coming from another device (e.g. from ping), the
    // corresponding reverse flow entry will never expire on its own and will
    // send the packets to the wrong port (the matching input port of the
    // expired flow entry), so we must delete the reverse entry explicitly.
    Match.Builder mb = sw.getOFFactory().buildMatch();
    mb.setExact(MatchField.ETH_SRC, match.get(MatchField.ETH_DST))                         
    .setExact(MatchField.ETH_DST, match.get(MatchField.ETH_SRC));
    if (match.get(MatchField.VLAN_VID) != null) {
        mb.setExact(MatchField.VLAN_VID, match.get(MatchField.VLAN_VID));                    
    }
    this.writeFlowMod(sw, OFFlowModCommand.DELETE, OFBufferId.NO_BUFFER, mb.build(), match.get(MatchField.IN_PORT));
    return Command.CONTINUE;
}
项目:fast-failover-demo    文件:LearningSwitch.java   
@Override
public Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx) {
    switch (msg.getType()) {
    case PACKET_IN:
        return this.processPacketInMessage(sw, (OFPacketIn) msg, cntx);
    case FLOW_REMOVED:
        return this.processFlowRemovedMessage(sw, (OFFlowRemoved) msg);
    case ERROR:
        log.info("received an error {} from switch {}", msg, sw);
        return Command.CONTINUE;
    default:
        log.error("received an unexpected message {} from switch {}", msg, sw);
        return Command.CONTINUE;
    }
}
项目:fast-failover-demo    文件:StaticFlowEntryPusher.java   
@Override
@LogMessageDoc(level="ERROR",
message="Got a FlowRemove message for a infinite " +
        "timeout flow: {flow} from switch {switch}",
        explanation="Flows with infinite timeouts should not expire. " +
                "The switch has expired the flow anyway.",
                recommendation=LogMessageDoc.REPORT_SWITCH_BUG)
public Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx) {
    switch (msg.getType()) {
    case FLOW_REMOVED:
        return handleFlowRemoved(sw, (OFFlowRemoved) msg, cntx);
    default:
        return Command.CONTINUE;
    }
}
项目:fast-failover-demo    文件:OFSwitchHandshakeHandler.java   
/**
 * Process an OF message received on the channel and
 * update state accordingly.
 *
 * The main "event" of the state machine. Process the received message,
 * send follow up message if required and update state if required.
 *
 * Switches on the message type and calls more specific event handlers
 * for each individual OF message type. If we receive a message that
 * is supposed to be sent from a controller to a switch we throw
 * a SwitchStateExeption.
 *
 * The more specific handlers can also throw SwitchStateExceptions
 *
 * @param h The OFChannelHandler that received the message
 * @param m The message we received.
 * @throws SwitchStateException
 * @throws IOException
 */
void processOFMessage(OFMessage m) {
    roleChanger.checkTimeout();
    switch(m.getType()) {
    case BARRIER_REPLY:
        processOFBarrierReply((OFBarrierReply) m);
        break;
    case ERROR:
        processOFError((OFErrorMsg) m);
        break;
    case FLOW_REMOVED:
        processOFFlowRemoved((OFFlowRemoved) m);
        break;
    case GET_CONFIG_REPLY:
        processOFGetConfigReply((OFGetConfigReply) m);
        break;
    case PACKET_IN:
        processOFPacketIn((OFPacketIn) m);
        break;
    case PORT_STATUS:
        processOFPortStatus((OFPortStatus) m);
        break;
    case QUEUE_GET_CONFIG_REPLY:
        processOFQueueGetConfigReply((OFQueueGetConfigReply) m);
        break;
    case STATS_REPLY:
        processOFStatsReply((OFStatsReply) m);
        break;
    case ROLE_REPLY:
        processOFRoleReply((OFRoleReply) m);
        break;
    case EXPERIMENTER:
        processOFExperimenter((OFExperimenter) m);
        break;
    default:
        illegalMessageReceived(m);
        break;
    }
}
项目:ravikumaran201504    文件:FlowEntryBuilder.java   
public FlowEntryBuilder(Dpid dpid, OFFlowRemoved removed, Type tableType) {
    this.match = removed.getMatch();
    this.removed = removed;

    this.dpid = dpid;
    this.instructions = null;
    this.stat = null;
    this.flowMod = null;
    this.type = FlowType.REMOVED;
    this.tableType = tableType;

}
项目:floodlightLB    文件:LearningSwitch.java   
/**
 * Processes a flow removed message. We will delete the learned MAC/VLAN mapping from
 * the switch's table.
 * @param sw The switch that sent the flow removed message.
 * @param flowRemovedMessage The flow removed message.
 * @return Whether to continue processing this message or stop.
 */
private Command processFlowRemovedMessage(IOFSwitch sw, OFFlowRemoved flowRemovedMessage) {
    if (!flowRemovedMessage.getCookie().equals(U64.of(LearningSwitch.LEARNING_SWITCH_COOKIE))) {
        return Command.CONTINUE;
    }
    if (log.isTraceEnabled()) {
        log.trace("{} flow entry removed {}", sw, flowRemovedMessage);
    }
    Match match = flowRemovedMessage.getMatch();
    // When a flow entry expires, it means the device with the matching source
    // MAC address and VLAN either stopped sending packets or moved to a different
    // port.  If the device moved, we can't know where it went until it sends
    // another packet, allowing us to re-learn its port.  Meanwhile we remove
    // it from the macVlanToPortMap to revert to flooding packets to this device.
    this.removeFromPortMap(sw, match.get(MatchField.ETH_SRC), 
            match.get(MatchField.VLAN_VID) == null 
            ? VlanVid.ZERO 
            : match.get(MatchField.VLAN_VID).getVlanVid());

    // Also, if packets keep coming from another device (e.g. from ping), the
    // corresponding reverse flow entry will never expire on its own and will
    // send the packets to the wrong port (the matching input port of the
    // expired flow entry), so we must delete the reverse entry explicitly.
    Match.Builder mb = sw.getOFFactory().buildMatch();
    mb.setExact(MatchField.ETH_SRC, match.get(MatchField.ETH_DST))                         
    .setExact(MatchField.ETH_DST, match.get(MatchField.ETH_SRC));
    if (match.get(MatchField.VLAN_VID) != null) {
        mb.setExact(MatchField.VLAN_VID, match.get(MatchField.VLAN_VID));                    
    }
    this.writeFlowMod(sw, OFFlowModCommand.DELETE, OFBufferId.NO_BUFFER, mb.build(), match.get(MatchField.IN_PORT));
    return Command.CONTINUE;
}