本文整理汇总了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());
}
示例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);
}
示例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());
}