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


Java Ethernet.serialize方法代码示例

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


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

示例1: enforceMirrorAction

import net.floodlightcontroller.packet.Ethernet; //导入方法依赖的package包/类
private void enforceMirrorAction(FPContext cntx, MirrorAction ma){
	//check if the mirrored switch and port are still active
	IOFSwitch sw = switchService.getSwitch(DatapathId.of(ma.getDPID()));
	
	Ethernet eth = IFloodlightProviderService.bcStore.get(cntx.getFlowContext(),
				   IFloodlightProviderService.CONTEXT_PI_PAYLOAD);
	
	if (sw == null){
		log.error("[FRESCO] Cannot mirrow packet since the destination switch is offline");
		return;
	}
	
	if (sw.getPort(OFPort.of(ma.getPortID())) == null){
		log.error("[FRESCO] Cannot mirrow packet since the destination port is closed");
		return;
	}	
	
	//use packet-out to send out packet to a specific switch port
	OFPacketOut.Builder pob = sw.getOFFactory().buildPacketOut();

	ArrayList<OFAction> actions = new ArrayList<OFAction>();
	   	actions.add(sw.getOFFactory().actions().output(OFPort.of(ma.getPortID()),Integer.MAX_VALUE));

	   byte[] packetData = eth.serialize();
      pob.setData(packetData);
	   	
	sw.write(pob.build());
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:29,代码来源:FP_FloodlightRTE.java

示例2: sendMessage

import net.floodlightcontroller.packet.Ethernet; //导入方法依赖的package包/类
public static void sendMessage(IOFSwitch sw, OFPort inPort, MacAddress srcMac, MacAddress dstMac, 
		IPv4Address srcAddress, IPv4Address dstAddress, TransportPort srcPort, 
		TransportPort dstPort, byte[] acamp_bytes) {
	Ethernet l2 = new Ethernet();
	l2.setSourceMACAddress(srcMac);
	l2.setDestinationMACAddress(dstMac);
	l2.setEtherType(EthType.IPv4);
	IPv4 l3 = new IPv4();
	l3.setDestinationAddress(dstAddress);
	l3.setSourceAddress(srcAddress);
	l3.setTtl((byte)64);
	l3.setProtocol(IpProtocol.UDP);
	UDP l4 = new UDP();
	l4.setSourcePort(srcPort);
	l4.setDestinationPort(dstPort);
	Data l7 = new Data();
	l7.setData(acamp_bytes);
	l4.setPayload(l7);
	l3.setPayload(l4);
	l2.setPayload(l3);
	byte[] serializeData = l2.serialize();
	OFPacketOut po = sw.getOFFactory().buildPacketOut()
			.setData(serializeData)
			.setActions(Collections.singletonList((OFAction) sw.getOFFactory().actions().output(inPort, 0xffFFffFF)))
			.setInPort(OFPort.CONTROLLER)
			.build();
	sw.write(po);
}
 
开发者ID:sammyyx,项目名称:ACAMPController,代码行数:29,代码来源:ControllerAgent.java

示例3: installTCPProcessingRules

import net.floodlightcontroller.packet.Ethernet; //导入方法依赖的package包/类
private void installTCPProcessingRules(FloodlightContext cntx){
	Ethernet eth = IFloodlightProviderService.bcStore.get(cntx,IFloodlightProviderService.CONTEXT_PI_PAYLOAD);
	IPv4 ipv4 = (IPv4) eth.getPayload();
	
	int dstIP = ipv4.getDestinationAddress().getInt();
	
	IDevice dstDevice = getDeviceFromIP(dstIP);
	
	if (dstDevice == null){
		log.error("[FRESCO] cannot send out TCP packets due to failure to locate destination");
		return;
	}
	
       if (dstDevice.getAttachmentPoints().length < 1){
       	log.error("[FRESCO] can not install TCP processing"
       			+ " flow rules due to missing host location info");
        	return;
       }
       
       SwitchPort dstLocation = getLocationFromDevice(dstDevice);
       IOFSwitch sw = switchService.getSwitch(dstLocation.getSwitchDPID());
       
       if (sw == null){
       	log.error("[FRESCO] can not install TCP processing"
       			+ " due to to destionation switch is offline");
       }
	
	OFPacketOut.Builder pob = sw.getOFFactory().buildPacketOut();

       // set actions
       List<OFAction> actions = new ArrayList<OFAction>();
       actions.add(sw.getOFFactory().actions().buildOutput().
       		setPort(dstLocation.getPort()).setMaxLen(Integer.MAX_VALUE).build());

       pob.setActions(actions);
       
       byte[] packetData = eth.serialize();
       pob.setData(packetData);

       sw.write(pob.build());
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:42,代码来源:FP_FloodlightRTE.java


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