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


Java FloodlightContext类代码示例

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


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

示例1: setUp

import net.floodlightcontroller.core.FloodlightContext; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
    logger = LoggerFactory.getLogger(PathVerificationFlowTest.class);
    cntx = new FloodlightContext();
    FloodlightModuleContext fmc = new FloodlightModuleContext();
    fmc.addService(IFloodlightProviderService.class, mockFloodlightProvider);

    swDescription = factory.buildDescStatsReply().build();
    swFeatures = factory.buildFeaturesReply().setNBuffers(1000).build();

    sw = EasyMock.createMock(IOFSwitch.class);
    expect(sw.getId()).andReturn(swDpid).anyTimes();
    expect(sw.getOFFactory()).andReturn(factory).anyTimes();
    expect(sw.getBuffers()).andReturn(swFeatures.getNBuffers()).anyTimes();
    expect(sw.hasAttribute(IOFSwitch.PROP_SUPPORTS_OFPP_TABLE)).andReturn(true).anyTimes();
    expect(sw.getSwitchDescription()).andReturn(new SwitchDescription(swDescription)).anyTimes();
    expect(sw.isActive()).andReturn(true).anyTimes();
    expect(sw.getLatency()).andReturn(U64.of(10L)).anyTimes();
    replay(sw);

    pvs = new PathVerificationService();
}
 
开发者ID:telstra,项目名称:open-kilda,代码行数:23,代码来源:PathVerificationFlowTest.java

示例2: dispatchMessage

import net.floodlightcontroller.core.FloodlightContext; //导入依赖的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.getData(), 0, pi.getData().length);
              IFloodlightProviderService.bcStore.put(bc,
                      IFloodlightProviderService.CONTEXT_PI_PAYLOAD,
                      eth);
          }
          while (it.hasNext() && !Command.STOP.equals(result)) {
              result = it.next().receive(sw, msg, bc);
          }
      }
// paag
      for (IControllerCompletionListener listener:completionListeners)
      	listener.onMessageConsumed(sw, msg, bc);
  }
 
开发者ID:telstra,项目名称:open-kilda,代码行数:22,代码来源:MockFloodlightProvider.java

示例3: handleOutgoingMessage

import net.floodlightcontroller.core.FloodlightContext; //导入依赖的package包/类
@Override
public void handleOutgoingMessage(IOFSwitch sw, OFMessage m) {
    FloodlightContext bc = new FloodlightContext();
    List<IOFMessageListener> msgListeners = null;
    if (listeners.containsKey(m.getType())) {
        msgListeners = listeners.get(m.getType()).getOrderedListeners();
    }

    if (msgListeners != null) {
        for (IOFMessageListener listener : msgListeners) {
            if (Command.STOP.equals(listener.receive(sw, m, bc))) {
                break;
            }
        }
    }
}
 
开发者ID:nsg-ethz,项目名称:iTAP-controller,代码行数:17,代码来源:MockFloodlightProvider.java

示例4: getSrcIP

import net.floodlightcontroller.core.FloodlightContext; //导入依赖的package包/类
@Override
public int getSrcIP(FPContext cntx) {
	FloodlightContext flCntx = cntx.getFlowContext();
	
	Ethernet eth = IFloodlightProviderService.bcStore.get(flCntx,IFloodlightProviderService.CONTEXT_PI_PAYLOAD);
	IPv4Address srcIP;
	
	if(eth.getEtherType() == EthType.IPv4)
	{		
		IPv4 ipv4 = (IPv4) eth.getPayload();
		srcIP = ipv4.getSourceAddress();
		
		return srcIP.getInt();
	}
	else if (eth.getEtherType() == EthType.ARP){
		ARP arp = (ARP) eth.getPayload();
		srcIP = arp.getSenderProtocolAddress();
		
		return srcIP.getInt();
	}
		
	//for other packets without source IP information	
	return 0;
	
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:26,代码来源:FP_LibFloodlight.java

示例5: getDstIP

import net.floodlightcontroller.core.FloodlightContext; //导入依赖的package包/类
@Override
public int getDstIP(FPContext cntx) {
	FloodlightContext flCntx = cntx.getFlowContext();
	
	Ethernet eth = IFloodlightProviderService.bcStore.get(flCntx,IFloodlightProviderService.CONTEXT_PI_PAYLOAD);
	IPv4Address dstIP;
	
	if(eth.getEtherType() == EthType.IPv4)
	{		
		IPv4 ipv4 = (IPv4) eth.getPayload();
		dstIP = ipv4.getDestinationAddress();
		return dstIP.getInt();
	}
	else if (eth.getEtherType() == EthType.ARP){
		ARP arp = (ARP) eth.getPayload();

		dstIP = arp.getTargetProtocolAddress();

		return dstIP.getInt();
	}
	
	//for other packets without destination IP information
	return 0;
	
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:26,代码来源:FP_LibFloodlight.java

示例6: getARPSenderMAC

import net.floodlightcontroller.core.FloodlightContext; //导入依赖的package包/类
@Override
public long getARPSenderMAC(FPContext cntx){
	FloodlightContext flCntx = cntx.getFlowContext();
	
	Ethernet eth = IFloodlightProviderService.bcStore.get(flCntx,IFloodlightProviderService.CONTEXT_PI_PAYLOAD);
	MacAddress senderMAC;
	
	if (eth.getEtherType() == EthType.ARP){
		ARP arp = (ARP) eth.getPayload();
		
		senderMAC = arp.getSenderHardwareAddress();
		
		return senderMAC.getLong();
	}
	
	//for other non-arp packets
	return 0;
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:19,代码来源:FP_LibFloodlight.java

示例7: createMatchFromPacket

import net.floodlightcontroller.core.FloodlightContext; //导入依赖的package包/类
protected Match createMatchFromPacket(IOFSwitch sw, OFPort inPort, FloodlightContext cntx) {
	// The packet in match will only contain the port number.
	// We need to add in specifics for the hosts we're routing between.
	Ethernet eth = IFloodlightProviderService.bcStore.get(cntx, IFloodlightProviderService.CONTEXT_PI_PAYLOAD);
	VlanVid vlan = VlanVid.ofVlan(eth.getVlanID());
	MacAddress srcMac = eth.getSourceMACAddress();
	MacAddress dstMac = eth.getDestinationMACAddress();

	Match.Builder mb = sw.getOFFactory().buildMatch();
	mb.setExact(MatchField.IN_PORT, inPort)
	.setExact(MatchField.ETH_SRC, srcMac)
	.setExact(MatchField.ETH_DST, dstMac);

	if (!vlan.equals(VlanVid.ZERO)) {
		mb.setExact(MatchField.VLAN_VID, OFVlanVidMatch.ofVlanVid(vlan));
	}

	return mb.build();
}
 
开发者ID:nsg-ethz,项目名称:iTAP-controller,代码行数:20,代码来源:LearningSwitch.java

示例8: receive

import net.floodlightcontroller.core.FloodlightContext; //导入依赖的package包/类
@Override
public net.floodlightcontroller.core.IListener.Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx) {
	Ethernet eth = IFloodlightProviderService.bcStore.get(cntx,IFloodlightProviderService.CONTEXT_PI_PAYLOAD);
	oTopologyManager.updateTopologyMappings(sw, (OFPacketIn) msg, cntx);
	
	//log.debug("receive {}",eth);
	
	if ((eth.getPayload() instanceof ARP)) {
		handleARP(sw, (OFPacketIn) msg, cntx);
	}
	else if (eth.getPayload() instanceof IPv4) {
		handleIP(sw, (OFPacketIn) msg, cntx);
	}
	else {
		//handleCbench(sw, (OFPacketIn) msg, cntx);
		//log.warn("could not handle packet {}",eth.toString());
	}
	return Command.CONTINUE;
}
 
开发者ID:nsg-ethz,项目名称:iTAP-controller,代码行数:20,代码来源:ObfuscationController.java

示例9: receive

import net.floodlightcontroller.core.FloodlightContext; //导入依赖的package包/类
public Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx) {
	OFMessage outMessage;
	HubType ht = HubType.USE_PACKET_OUT;
	switch (ht) {
	case USE_FLOW_MOD:
        outMessage = createHubFlowMod(sw, msg);
        break;
    default:
	case USE_PACKET_OUT:
        outMessage = createHubPacketOut(sw, msg);
        break;
	}
    sw.write(outMessage);
    
    return Command.CONTINUE;
}
 
开发者ID:nsg-ethz,项目名称:iTAP-controller,代码行数:17,代码来源:Hub.java

示例10: recordEndTimePktIn

import net.floodlightcontroller.core.FloodlightContext; //导入依赖的package包/类
@Override
@LogMessageDoc(level="WARN",
        message="Time to process packet-in exceeded threshold: {}",
        explanation="Time to process packet-in exceeded the configured " +
        		"performance threshold",
        recommendation=LogMessageDoc.CHECK_CONTROLLER)
public void recordEndTimePktIn(IOFSwitch sw, OFMessage m, FloodlightContext cntx) {
    if (isEnabled()) {
        long procTimeNs = System.nanoTime() - startTimePktNs;
        ctb.updatePerPacketCounters(procTimeNs);
        
        if (ptWarningThresholdInNano > 0 && 
                procTimeNs > ptWarningThresholdInNano) {
            logger.warn("Time to process packet-in exceeded threshold: {}", 
                        procTimeNs/1000);
        }
    }
}
 
开发者ID:nsg-ethz,项目名称:iTAP-controller,代码行数:19,代码来源:PktInProcessingTime.java

示例11: dropFilter

import net.floodlightcontroller.core.FloodlightContext; //导入依赖的package包/类
/**
 * If the packet-in switch port is disabled for all data traffic, then
 * the packet will be dropped.  Otherwise, the packet will follow the
 * normal processing chain.
 * @param sw
 * @param pi
 * @param cntx
 * @return
 */
protected Command dropFilter(DatapathId sw, OFPacketIn pi,
		FloodlightContext cntx) {
	Command result = Command.CONTINUE;
	OFPort inPort = (pi.getVersion().compareTo(OFVersion.OF_12) < 0 ? pi.getInPort() : pi.getMatch().get(MatchField.IN_PORT));

	// If the input port is not allowed for data traffic, drop everything.
	// BDDP packets will not reach this stage.
	if (isAllowed(sw, inPort) == false) {
		if (log.isTraceEnabled()) {
			log.trace("Ignoring packet because of topology " +
					"restriction on switch={}, port={}", sw.getLong(), inPort.getPortNumber());
			result = Command.STOP;
		}
	}
	return result;
}
 
开发者ID:nsg-ethz,项目名称:iTAP-controller,代码行数:26,代码来源:TopologyManager.java

示例12: processPacketInMessage

import net.floodlightcontroller.core.FloodlightContext; //导入依赖的package包/类
protected Command processPacketInMessage(IOFSwitch sw, OFPacketIn pi, FloodlightContext cntx) {
	// get the packet-in switch.
	Ethernet eth =
			IFloodlightProviderService.bcStore.
			get(cntx,IFloodlightProviderService.CONTEXT_PI_PAYLOAD);

	if (eth.getPayload() instanceof BSN) {
		BSN bsn = (BSN) eth.getPayload();
		if (bsn == null) return Command.STOP;
		if (bsn.getPayload() == null) return Command.STOP;

		// It could be a packet other than BSN LLDP, therefore
		// continue with the regular processing.
		if (bsn.getPayload() instanceof LLDP == false)
			return Command.CONTINUE;

		doFloodBDDP(sw.getId(), pi, cntx);
		return Command.STOP;
	} else {
		return dropFilter(sw.getId(), pi, cntx);
	}
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:23,代码来源:TopologyManager.java

示例13: handleOutgoingMessage

import net.floodlightcontroller.core.FloodlightContext; //导入依赖的package包/类
@Override
public void handleOutgoingMessage(IOFSwitch sw, OFMessage m) {
    if (sw == null)
        throw new NullPointerException("Switch must not be null");
    if (m == null)
        throw new NullPointerException("OFMessage must not be null");

    FloodlightContext bc = new FloodlightContext();

    List<IOFMessageListener> listeners = null;
    if (messageListeners.containsKey(m.getType())) {
        listeners = messageListeners.get(m.getType()).getOrderedListeners();
    }

    if (listeners != null) {
        for (IOFMessageListener listener : listeners) {
            if (Command.STOP.equals(listener.receive(sw, m, bc))) {
                break;
            }
        }
    }
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:23,代码来源:Controller.java

示例14: receive

import net.floodlightcontroller.core.FloodlightContext; //导入依赖的package包/类
@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;
}
 
开发者ID:nsg-ethz,项目名称:iTAP-controller,代码行数:24,代码来源:ObfuscationSwitchStateManager.java

示例15: receive

import net.floodlightcontroller.core.FloodlightContext; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx) {
    logger.debug("OF_ERROR: {}", msg);
    // TODO: track xid for flow id
    if (OFType.ERROR.equals(msg.getType())) {
        ErrorMessage error = new ErrorMessage(
                new ErrorData(ErrorType.INTERNAL_ERROR, ((OFErrorMsg) msg).getErrType().toString(), null),
                System.currentTimeMillis(), DEFAULT_CORRELATION_ID, Destination.WFM_TRANSACTION);
        // TODO: Most/all commands are flow related, but not all. 'kilda.flow' might
        // not be the best place to send a generic error.
        kafkaProducer.postMessage("kilda.flow", error);
    }
    return Command.CONTINUE;
}
 
开发者ID:telstra,项目名称:open-kilda,代码行数:18,代码来源:SwitchManager.java


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