当前位置: 首页>>代码示例>>Java>>正文


Java OFMessage.getType方法代码示例

本文整理汇总了Java中org.openflow.protocol.OFMessage.getType方法的典型用法代码示例。如果您正苦于以下问题:Java OFMessage.getType方法的具体用法?Java OFMessage.getType怎么用?Java OFMessage.getType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.openflow.protocol.OFMessage的用法示例。


在下文中一共展示了OFMessage.getType方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: receive

import org.openflow.protocol.OFMessage; //导入方法依赖的package包/类
@Override
public Command receive(IOFSwitch sw, OFMessage msg,
                       FloodlightContext cntx) {
    switch (msg.getType()) {
        case PACKET_IN:
            IRoutingDecision decision = null;
            if (cntx != null)
                 decision =
                         IRoutingDecision.rtStore.get(cntx,
                                                      IRoutingDecision.CONTEXT_DECISION);

            return this.processPacketInMessage(sw,
                                               (OFPacketIn) msg,
                                               decision,
                                               cntx);
        default:
            break;
    }
    return Command.CONTINUE;
}
 
开发者ID:JianqingJiang,项目名称:QoS-floodlight,代码行数:21,代码来源:ForwardingBase.java

示例2: receive

import org.openflow.protocol.OFMessage; //导入方法依赖的package包/类
@Override
public net.floodlightcontroller.core.IListener.Command receive(
		IOFSwitch sw, OFMessage msg, FloodlightContext cntx) {
	
	//do not process packet if not enabled
	if (!this.enabled) {
		return Command.CONTINUE;
	}
	//logger.debug("Message Recieved: Type - {}",msg.getType().toString());
	//Listen for Packets that match Policies
	switch (msg.getType()) {
       case PACKET_IN:
       	//logger.debug("PACKET_IN recieved");
       	byte[] packetData = OFMessage.getData(sw, msg, cntx);
       	//Temporary match from packet to compare
       	OFMatch tmpMatch = new OFMatch();
       	tmpMatch.loadFromPacket(packetData, OFPort.OFPP_NONE.getValue());
       	checkIfQoSApplied(tmpMatch);
           break;
       default:
           return Command.CONTINUE;
       }
	return Command.CONTINUE;
}
 
开发者ID:JianqingJiang,项目名称:QoS-floodlight,代码行数:25,代码来源:QoS.java

示例3: receive

import org.openflow.protocol.OFMessage; //导入方法依赖的package包/类
@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;
}
 
开发者ID:JianqingJiang,项目名称:QoS-floodlight,代码行数:17,代码来源:LearningSwitch.java

示例4: receive

import org.openflow.protocol.OFMessage; //导入方法依赖的package包/类
@Override
public Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx) {
    if (!this.enabled)
        return Command.CONTINUE;

    switch (msg.getType()) {
    case PACKET_IN:
        IRoutingDecision decision = null;
        if (cntx != null) {
            decision = IRoutingDecision.rtStore.get(cntx,
                    IRoutingDecision.CONTEXT_DECISION);

            return this.processPacketInMessage(sw, (OFPacketIn) msg,
                    decision, cntx);
        }
        break;
    default:
        break;
    }

    return Command.CONTINUE;
}
 
开发者ID:JianqingJiang,项目名称:QoS-floodlight,代码行数:23,代码来源:Firewall.java

示例5: write

import org.openflow.protocol.OFMessage; //导入方法依赖的package包/类
@Override
public void write(OFMessage m, FloodlightContext bc) {
    if (channel == null || !isConnected())
        return;
        //throws IOException {
    Map<IOFSwitch,List<OFMessage>> msg_buffer_map = local_msg_buffer.get();
    List<OFMessage> msg_buffer = msg_buffer_map.get(this);
    if (msg_buffer == null) {
        msg_buffer = new ArrayList<OFMessage>();
        msg_buffer_map.put(this, msg_buffer);
    }

    this.floodlightProvider.handleOutgoingMessage(this, m, bc);
    msg_buffer.add(m);

    if ((msg_buffer.size() >= Controller.BATCH_MAX_SIZE) ||
        ((m.getType() != OFType.PACKET_OUT) && (m.getType() != OFType.FLOW_MOD))) {
        this.write(msg_buffer);
        msg_buffer.clear();
    }
}
 
开发者ID:JianqingJiang,项目名称:QoS-floodlight,代码行数:22,代码来源:OFSwitchBase.java

示例6: receive

import org.openflow.protocol.OFMessage; //导入方法依赖的package包/类
@Override
public Command receive(IOFSwitch sw, OFMessage msg,
                       FloodlightContext cntx) {
    switch (msg.getType()) {
        case PACKET_IN:
            cntIncoming.updateCounterNoFlush();
            return this.processPacketInMessage(sw,
                                               (OFPacketIn) msg, cntx);
        default:
            break;
    }
    return Command.CONTINUE;
}
 
开发者ID:JianqingJiang,项目名称:QoS-floodlight,代码行数:14,代码来源:DeviceManagerImpl.java

示例7: receive

import org.openflow.protocol.OFMessage; //导入方法依赖的package包/类
@Override
public Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx) {
    switch (msg.getType()) {
        case PACKET_IN:
            return processPacketIn(sw, (OFPacketIn)msg, cntx);
        default:
            break;
    }
    log.warn("Received unexpected message {}", msg);
    return Command.CONTINUE;
}
 
开发者ID:JianqingJiang,项目名称:QoS-floodlight,代码行数:12,代码来源:VirtualNetworkFilter.java

示例8: receive

import org.openflow.protocol.OFMessage; //导入方法依赖的package包/类
@Override
public Command receive(IOFSwitch sw, OFMessage msg,
                       FloodlightContext cntx) {
    switch (msg.getType()) {
        case PACKET_IN:
            ctrIncoming.updateCounterNoFlush();
            return this.handlePacketIn(sw.getId(), (OFPacketIn) msg,
                                       cntx);
        default:
            break;
    }
    return Command.CONTINUE;
}
 
开发者ID:JianqingJiang,项目名称:QoS-floodlight,代码行数:14,代码来源:LinkDiscoveryManager.java

示例9: receive

import org.openflow.protocol.OFMessage; //导入方法依赖的package包/类
@Override
public net.floodlightcontroller.core.IListener.Command
        receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx) {
    switch (msg.getType()) {
        case PACKET_IN:
            return processPacketIn(sw, (OFPacketIn)msg, cntx);
        default:
            break;
    }
    log.warn("Received unexpected message {}", msg);
    return Command.CONTINUE;
}
 
开发者ID:JianqingJiang,项目名称:QoS-floodlight,代码行数:13,代码来源:LoadBalancer.java

示例10: receive

import org.openflow.protocol.OFMessage; //导入方法依赖的package包/类
@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;
    }
}
 
开发者ID:JianqingJiang,项目名称:QoS-floodlight,代码行数:16,代码来源:StaticFlowEntryPusher.java

示例11: receive

import org.openflow.protocol.OFMessage; //导入方法依赖的package包/类
@Override
public Command receive(IOFSwitch sw, OFMessage msg,
                       FloodlightContext cntx) {
    switch (msg.getType()) {
        case PACKET_IN:
            ctrIncoming.updateCounterNoFlush();
            return this.processPacketInMessage(sw,
                                               (OFPacketIn) msg, cntx);
        default:
            break;
    }

    return Command.CONTINUE;
}
 
开发者ID:JianqingJiang,项目名称:QoS-floodlight,代码行数:15,代码来源:TopologyManager.java

示例12: processOFMessage

import org.openflow.protocol.OFMessage; //导入方法依赖的package包/类
@Override
void processOFMessage(OFChannelHandler h, OFMessage m)
        throws IOException {
    if (m.getType() == OFType.ECHO_REQUEST)
        processOFEchoRequest(h, (OFEchoRequest)m);
    else {
        // FIXME: other message to handle here?
        h.sw.processDriverHandshakeMessage(m);
        if (h.sw.isDriverHandshakeComplete()) {
            h.gotoWaitInitialRoleState();
        }
    }
}
 
开发者ID:JianqingJiang,项目名称:QoS-floodlight,代码行数:14,代码来源:OFChannelHandler.java

示例13: inputThrottled

import org.openflow.protocol.OFMessage; //导入方法依赖的package包/类
/**
 * Determine if this message should be dropped.
 *
 * We compute the current rate by taking a timestamp every 100 messages.
 * Could change to a more complex scheme if more accuracy is needed.
 *
 * Enable throttling if the rate goes above packetInRateThresholdHigh
 * Disable throttling when the rate drops below packetInRateThresholdLow
 *
 * While throttling is enabled, we do the following:
 *  - Remove duplicate packetIn's mapped to the same OFMatch
 *  - After filtering, if packetIn rate per host (mac) is above
 *    packetInRatePerMacThreshold, push a flow mod to block mac on port
 *  - After filtering, if packetIn rate per port is above
 *    packetInRatePerPortThreshold, push a flow mod to block port
 *  - Allow blocking flow mods have a hard timeout and expires automatically
 *
 * TODO: keep a history of all events related in input throttling
 *
 * @param ofm
 * @return
 */
@Override
public boolean inputThrottled(OFMessage ofm) {
    if (ofm.getType() != OFType.PACKET_IN) {
        return false;
    }
    ctrSwitchPktin.updateCounterNoFlush();
    // Compute current packet in rate
    messageCount++;
    if (messageCount % 1000 == 0) {
        long now = System.currentTimeMillis();
        if (now != lastMessageTime) {
            currentRate = (int) (1000000 / (now - lastMessageTime));
            lastMessageTime = now;
        } else {
            currentRate = Integer.MAX_VALUE;
        }
    }
    if (!packetInThrottleEnabled) {
        if (currentRate <= packetInRateThresholdHigh) {
            return false; // most common case
        }
        enablePacketInThrottle();
    } else if (currentRate < packetInRateThresholdLow) {
        disablePacketInThrottle();
        return false;
    }

    // Now we are in the slow path where we need to do filtering
    // First filter based on OFMatch
    OFPacketIn pin = (OFPacketIn)ofm;
    OFMatch match = new OFMatch();
    match.loadFromPacket(pin.getPacketData(), pin.getInPort());
    if (ofMatchCache.update(match)) {
       ctrSwitchPktinDrops.updateCounterNoFlush();
        return true;
    }

    // We have packet in with a distinct flow, check per mac rate
    messageCountUniqueOFMatch++;
    if ((messageCountUniqueOFMatch % packetInRatePerMacThreshold) == 1) {
        checkPerSourceMacRate(pin);
    }

    // Check per port rate
    if ((messageCountUniqueOFMatch % packetInRatePerPortThreshold) == 1) {
        checkPerPortRate(pin);
    }
    return false;
}
 
开发者ID:JianqingJiang,项目名称:QoS-floodlight,代码行数:72,代码来源:OFSwitchBase.java

示例14: sendPacket

import org.openflow.protocol.OFMessage; //导入方法依赖的package包/类
protected void sendPacket(HashSet<String> matchedFilters, IOFSwitch sw, 
        OFMessage msg, FloodlightContext cntx, boolean sync) 
                throws TException {
    Message sendMsg = new Message();
    Packet packet = new Packet();
    ChannelBuffer bb;
    sendMsg.setPacket(packet);

    List<String> sids = new ArrayList<String>(matchedFilters);

    sendMsg.setSessionIDs(sids);
    packet.setMessageType(OFMessageType.findByValue((msg.getType().ordinal())));

    switch (msg.getType()) {
        case PACKET_IN:
            OFPacketIn pktIn = (OFPacketIn)msg;
            packet.setSwPortTuple(new SwitchPortTuple(sw.getId(), 
                                                      pktIn.getInPort()));
            bb = ChannelBuffers.buffer(pktIn.getLength());
            pktIn.writeTo(bb);
            packet.setData(OFMessage.getData(sw, msg, cntx));
            break;
        case PACKET_OUT:
            OFPacketOut pktOut = (OFPacketOut)msg;
            packet.setSwPortTuple(new SwitchPortTuple(sw.getId(), 
                                                      pktOut.getInPort()));
            bb = ChannelBuffers.buffer(pktOut.getLength());
            pktOut.writeTo(bb);
            packet.setData(OFMessage.getData(sw, msg, cntx));
            break;
        case FLOW_MOD:
            OFFlowMod offlowMod = (OFFlowMod)msg;
            packet.setSwPortTuple(new SwitchPortTuple(sw.getId(), 
                                                      offlowMod.
                                                      getOutPort()));
            bb = ChannelBuffers.buffer(offlowMod.getLength());
            offlowMod.writeTo(bb);
            packet.setData(OFMessage.getData(sw, msg, cntx));
            break;
        default:
            packet.setSwPortTuple(new SwitchPortTuple(sw.getId(), 
                                                      (short)0));
            String strData = "Unknown packet";
            packet.setData(strData.getBytes());
            break;
    }

    try {
        if (transport == null || 
            !transport.isOpen() || 
            packetClient == null) {
            if (!connectToPSServer()) {
                // No need to sendPacket if can't make connection to 
                // the server
                return;
            }
        }
        if (sync) {
            log.debug("Send packet sync: {}", packet.toString());
            packetClient.pushMessageSync(sendMsg);
        } else {
            log.debug("Send packet sync: ", packet.toString());
            packetClient.pushMessageAsync(sendMsg);
        }
    } catch (Exception e) {
        log.error("Error while sending packet", e);
        disconnectFromPSServer();
        connectToPSServer();
    }
}
 
开发者ID:JianqingJiang,项目名称:QoS-floodlight,代码行数:71,代码来源:OFMessageFilterManager.java

示例15: SwitchDriverSubHandshakeCompleted

import org.openflow.protocol.OFMessage; //导入方法依赖的package包/类
public SwitchDriverSubHandshakeCompleted(OFMessage m) {
    super("Sub-Handshake is already complete but received message " +
          m.getType());
}
 
开发者ID:JianqingJiang,项目名称:QoS-floodlight,代码行数:5,代码来源:SwitchDriverSubHandshakeCompleted.java


注:本文中的org.openflow.protocol.OFMessage.getType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。