本文整理汇总了Java中net.floodlightcontroller.packet.Ethernet.setPayload方法的典型用法代码示例。如果您正苦于以下问题:Java Ethernet.setPayload方法的具体用法?Java Ethernet.setPayload怎么用?Java Ethernet.setPayload使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.floodlightcontroller.packet.Ethernet
的用法示例。
在下文中一共展示了Ethernet.setPayload方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getPacket
import net.floodlightcontroller.packet.Ethernet; //导入方法依赖的package包/类
protected IPacket getPacket() {
UDP udp = new UDP()
.setDestinationPort(
TransportPort.of(PathVerificationService.VERIFICATION_PACKET_UDP_PORT))
.setSourcePort(
TransportPort.of(PathVerificationService.VERIFICATION_PACKET_UDP_PORT));
VerificationPacket verificationPacket = new VerificationPacket()
.setChassisId(new LLDPTLV().setType((byte) 1).setLength((short) 7)
.setValue(new byte[] {0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01}))
.setPortId(new LLDPTLV().setType((byte) 2).setLength((short) 3)
.setValue(new byte[] {0x02, 0x00, 0x01}))
.setTtl(new LLDPTLV().setType((byte) 3).setLength((short) 2)
.setValue(new byte[] {0x00, 0x78}));
udp.setPayload(new Data(verificationPacket.serialize()));
IPv4 ip = new IPv4()
.setSourceAddress("192.168.0.1")
.setDestinationAddress(PathVerificationService.VERIFICATION_PACKET_IP_DST)
.setProtocol(IpProtocol.UDP);
Ethernet eth = new Ethernet()
.setDestinationMACAddress("AA:BB:CC:DD:EE:FF")
.setSourceMACAddress("11:22:33:44:55:66")
.setEtherType(EthType.IPv4);
eth.setPayload(ip);
ip.setPayload(udp);
return eth;
}
示例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);
}