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


Java OFMessage类代码示例

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


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

示例1: moveToWaitHello

import org.openflow.protocol.OFMessage; //导入依赖的package包/类
@Test
public void moveToWaitHello() throws Exception {
    resetChannel();
    channel.write(capture(writeCapture));
    expectLastCall().andReturn(null).once();
    replay(channel);
    // replay unused mocks
    replay(messageEvent);

    handler.channelConnected(ctx, channelStateEvent);

    List<OFMessage> msgs = getMessagesFromCapture();
    assertEquals(1, msgs.size());
    assertEquals(OFType.HELLO, msgs.get(0).getType());
    assertEquals(OFChannelHandler.ChannelState.WAIT_HELLO,
                 handler.getStateForTesting());
    verifyUniqueXids(msgs);
}
 
开发者ID:JianqingJiang,项目名称:QoS-floodlight,代码行数:19,代码来源:OFChannelHandlerTest.java

示例2: 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

示例3: 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

示例4: 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

示例5: clearFlowMods

import org.openflow.protocol.OFMessage; //导入依赖的package包/类
/**
 * @param sw
 *            The switch we wish to remove flows from
 * @param outPort
 *            The specific Output Action OutPort of specific flows we wish
 *            to delete
 */
public void clearFlowMods(IOFSwitch sw, Short outPort) {
    // Delete all pre-existing flows with the same output action port or
    // outPort
    OFMatch match = new OFMatch().setWildcards(OFMatch.OFPFW_ALL);
    OFMessage fm = ((OFFlowMod) floodlightProvider.getOFMessageFactory()
                                                  .getMessage(OFType.FLOW_MOD)).setMatch(match)
                                                                               .setCommand(OFFlowMod.OFPFC_DELETE)
                                                                               .setOutPort(outPort)
                                                                               .setLength(U16.t(OFFlowMod.MINIMUM_LENGTH));
    try {
        List<OFMessage> msglist = new ArrayList<OFMessage>(1);
        msglist.add(fm);
        sw.write(msglist, cntx);
    } catch (Exception e) {
        log.error("Failed to clear flows on switch {} - {}", this, e);
    }
}
 
开发者ID:JianqingJiang,项目名称:QoS-floodlight,代码行数:25,代码来源:PortDownReconciliation.java

示例6: writeOFMessagesToSwitch

import org.openflow.protocol.OFMessage; //导入依赖的package包/类
/**
 * Writes a list of OFMessages to a switch
 * @param dpid The datapath ID of the switch to write to
 * @param messages The list of OFMessages to write.
 */
@LogMessageDoc(level="ERROR",
        message="Tried to write to switch {switch} but got {error}",
        explanation="An I/O error occured while trying to write a " +
                "static flow to a switch",
        recommendation=LogMessageDoc.CHECK_SWITCH)
private void writeOFMessagesToSwitch(long dpid, List<OFMessage> messages) {
    IOFSwitch ofswitch = floodlightProvider.getSwitch(dpid);
    if (ofswitch != null) {  // is the switch connected
        try {
            if (log.isDebugEnabled()) {
                log.debug("Sending {} new entries to {}", messages.size(), dpid);
            }
            ofswitch.write(messages, null);
            ofswitch.flush();
        } catch (IOException e) {
            log.error("Tried to write to switch {} but got {}", dpid, e.getMessage());
        }
    }
}
 
开发者ID:JianqingJiang,项目名称:QoS-floodlight,代码行数:25,代码来源:StaticFlowEntryPusher.java

示例7: moveToWaitConfigReply

import org.openflow.protocol.OFMessage; //导入依赖的package包/类
/** Move the channel from scratch to WAIT_CONFIG_REPLY state
 * Builds on moveToWaitFeaturesReply
 * adds testing for WAIT_FEATURES_REPLY state
 */
@Test
public void moveToWaitConfigReply() throws Exception {
    moveToWaitFeaturesReply();
    resetChannel();
    channel.write(capture(writeCapture));
    expectLastCall().andReturn(null).atLeastOnce();
    replay(channel);

    sendMessageToHandlerWithControllerReset(Collections.<OFMessage>singletonList(featuresReply));

    List<OFMessage> msgs = getMessagesFromCapture();
    assertEquals(3, msgs.size());
    assertEquals(OFType.SET_CONFIG, msgs.get(0).getType());
    OFSetConfig sc = (OFSetConfig)msgs.get(0);
    assertEquals((short)0xffff, sc.getMissSendLength());
    assertEquals(OFType.BARRIER_REQUEST, msgs.get(1).getType());
    assertEquals(OFType.GET_CONFIG_REQUEST, msgs.get(2).getType());
    verifyUniqueXids(msgs);
    assertEquals(OFChannelHandler.ChannelState.WAIT_CONFIG_REPLY,
                 handler.getStateForTesting());
}
 
开发者ID:JianqingJiang,项目名称:QoS-floodlight,代码行数:26,代码来源:OFChannelHandlerTest.java

示例8: updatePacketInCountersLocal

import org.openflow.protocol.OFMessage; //导入依赖的package包/类
@Override
public void updatePacketInCountersLocal(IOFSwitch sw, OFMessage m, Ethernet eth) {
    if (((OFPacketIn)m).getPacketData().length <= 0) {
        return;
    }
    CounterKeyTuple countersKey = this.getCountersKey(sw, m, eth);
    Map<CounterKeyTuple, MutableInt> pktin_buffer = this.pktin_local_buffer.get();
    MutableInt currval = pktin_buffer.get(countersKey);

    if (currval == null) {
        this.createPacketInCounters(sw, m, eth); // create counters as side effect (if required)
        currval = new MutableInt();
        pktin_buffer.put(countersKey, currval);
    }
    currval.increment();
    return;
}
 
开发者ID:JianqingJiang,项目名称:QoS-floodlight,代码行数:18,代码来源:CounterStore.java

示例9: write

import org.openflow.protocol.OFMessage; //导入依赖的package包/类
/**
 * write the messag to the switch according to our dampening settings
 * @param sw
 * @param msg
 * @param cntx
 * @param flush true to flush the packet immidiately
 * @return true if the message was written to the switch, false if
 * the message was dampened. 
 * @throws IOException
 */
public boolean write(IOFSwitch sw, OFMessage msg,
                    FloodlightContext cntx, boolean flush) 
        throws IOException {
    if (! msgTypesToCache.contains(msg.getType())) {
        sw.writeThrottled(msg, cntx);
        if (flush) {
            sw.flush();
        }
        return true;
    }
    
    DamperEntry entry = new DamperEntry(msg, sw);
    if (cache.update(entry)) {
        // entry exists in cache. Dampening.
        return false; 
    } else {
        sw.writeThrottled(msg, cntx);
        if (flush) {
            sw.flush();
        }
        return true;
    }
}
 
开发者ID:JianqingJiang,项目名称:QoS-floodlight,代码行数:34,代码来源:OFMessageDamper.java

示例10: 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

示例11: 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

示例12: flush

import org.openflow.protocol.OFMessage; //导入依赖的package包/类
@Override
public void flush() {
    Map<IOFSwitch,List<OFMessage>> msg_buffer_map = local_msg_buffer.get();
    List<OFMessage> msglist = msg_buffer_map.get(this);
    if ((msglist != null) && (msglist.size() > 0)) {
        /* ============================ BIG CAVEAT ===============================
         * This code currently works, but relies on undocumented behavior of
         * netty.
         *
         * The method org.jboss.netty.channel.Channel.write(Object)
         * (invoked from this.write(List<OFMessage> msg) is currently
         * documented to be <emph>asynchronous</emph>. If the method /were/ truely
         * asynchronous, this would break our code (because we are clearing the
         * msglist right after calling write.
         *
         * For now, Netty actually invokes the conversion pipeline before doing
         * anything asynchronous, so we are safe. But we should probably change
         * that behavior.
         */
        this.write(msglist);
        msglist.clear();
    }
}
 
开发者ID:JianqingJiang,项目名称:QoS-floodlight,代码行数:24,代码来源:OFSwitchBase.java

示例13: sendNxRoleRequest

import org.openflow.protocol.OFMessage; //导入依赖的package包/类
/**
 * Send NX role request message to the switch requesting the specified
 * role.
 *
 * @param sw switch to send the role request message to
 * @param role role to request
 */
private int sendNxRoleRequest(Role role)
        throws IOException {

    int xid = sw.getNextTransactionId();
    // Convert the role enum to the appropriate integer constant used
    // in the NX role request message
    int nxRole = role.toNxRole();

    // Construct the role request message
    OFVendor roleRequest = (OFVendor)BasicFactory.getInstance()
            .getMessage(OFType.VENDOR);
    roleRequest.setXid(xid);
    roleRequest.setVendor(OFNiciraVendorData.NX_VENDOR_ID);
    OFRoleRequestVendorData roleRequestData = new OFRoleRequestVendorData();
    roleRequestData.setRole(nxRole);
    roleRequest.setVendorData(roleRequestData);
    roleRequest.setLengthU(OFVendor.MINIMUM_LENGTH +
            roleRequestData.getLength());

    // Send it to the switch
    sw.write(Collections.<OFMessage>singletonList(roleRequest),
             new FloodlightContext());

    return xid;
}
 
开发者ID:JianqingJiang,项目名称:QoS-floodlight,代码行数:33,代码来源:OFChannelHandler.java

示例14: sendHandshakeSetConfig

import org.openflow.protocol.OFMessage; //导入依赖的package包/类
/**
 * Send the configuration requests to tell the switch we want full
 * packets
 * @throws IOException
 */
private void sendHandshakeSetConfig() throws IOException {
    List<OFMessage> msglist = new ArrayList<OFMessage>(3);

    // Ensure we receive the full packet via PacketIn
    // FIXME: We don't set the reassembly flags.
    OFSetConfig configSet = (OFSetConfig) BasicFactory.getInstance()
            .getMessage(OFType.SET_CONFIG);
    configSet.setMissSendLength((short) 0xffff)
        .setLengthU(OFSwitchConfig.MINIMUM_LENGTH);
    configSet.setXid(handshakeTransactionIds--);
    msglist.add(configSet);

    // Barrier
    OFBarrierRequest barrier = (OFBarrierRequest) BasicFactory.getInstance()
            .getMessage(OFType.BARRIER_REQUEST);
    barrier.setXid(handshakeTransactionIds--);
    msglist.add(barrier);

    // Verify (need barrier?)
    OFGetConfigRequest configReq = (OFGetConfigRequest)
            BasicFactory.getInstance().getMessage(OFType.GET_CONFIG_REQUEST);
    configReq.setXid(handshakeTransactionIds--);
    msglist.add(configReq);
    channel.write(msglist);
}
 
开发者ID:JianqingJiang,项目名称:QoS-floodlight,代码行数:31,代码来源:OFChannelHandler.java

示例15: dispatchMessage

import org.openflow.protocol.OFMessage; //导入依赖的package包/类
public void dispatchMessage(IOFSwitch sw, OFMessage msg, FloodlightContext bc) {
    List<IOFMessageListener> theListeners = listeners.get(msg.getType()).getOrderedListeners();
    if (theListeners != null) {
        Command result = Command.CONTINUE;
        Iterator<IOFMessageListener> it = theListeners.iterator();
        if (OFType.PACKET_IN.equals(msg.getType())) {
            OFPacketIn pi = (OFPacketIn)msg;
            Ethernet eth = new Ethernet();
            eth.deserialize(pi.getPacketData(), 0, pi.getPacketData().length);
            IFloodlightProviderService.bcStore.put(bc,
                    IFloodlightProviderService.CONTEXT_PI_PAYLOAD,
                    eth);
        }
        while (it.hasNext() && !Command.STOP.equals(result)) {
            result = it.next().receive(sw, msg, bc);
        }
    }
}
 
开发者ID:JianqingJiang,项目名称:QoS-floodlight,代码行数:19,代码来源:MockFloodlightProvider.java


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