本文整理汇总了Java中net.floodlightcontroller.packet.Ethernet.setSourceMACAddress方法的典型用法代码示例。如果您正苦于以下问题:Java Ethernet.setSourceMACAddress方法的具体用法?Java Ethernet.setSourceMACAddress怎么用?Java Ethernet.setSourceMACAddress使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.floodlightcontroller.packet.Ethernet
的用法示例。
在下文中一共展示了Ethernet.setSourceMACAddress方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}