本文整理汇总了Java中net.floodlightcontroller.packet.Data类的典型用法代码示例。如果您正苦于以下问题:Java Data类的具体用法?Java Data怎么用?Java Data使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Data类属于net.floodlightcontroller.packet包,在下文中一共展示了Data类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: deserialize
import net.floodlightcontroller.packet.Data; //导入依赖的package包/类
private VerificationPacket deserialize(Ethernet eth) throws Exception {
if (eth.getPayload() instanceof IPv4) {
IPv4 ip = (IPv4) eth.getPayload();
if (ip.getPayload() instanceof UDP) {
UDP udp = (UDP) ip.getPayload();
if ((udp.getSourcePort().getPort() == PathVerificationService.VERIFICATION_PACKET_UDP_PORT)
&& (udp.getDestinationPort()
.getPort() == PathVerificationService.VERIFICATION_PACKET_UDP_PORT)) {
return new VerificationPacket((Data) udp.getPayload());
}
}
}
throw new Exception("Ethernet packet was not a verification packet");
}
示例2: createPacketIn
import net.floodlightcontroller.packet.Data; //导入依赖的package包/类
private OFPacketIn createPacketIn(String srcMAC, String dstMAC,
String srcIp, String dstIp, short vlan) {
IPacket testPacket = new Ethernet()
.setDestinationMACAddress(dstMAC)
.setSourceMACAddress(srcMAC)
.setVlanID(vlan)
.setEtherType(EthType.IPv4)
.setPayload(
new IPv4()
.setTtl((byte) 128)
.setSourceAddress(srcIp)
.setDestinationAddress(dstIp)
.setPayload(new UDP()
.setSourcePort((short) 5000)
.setDestinationPort((short) 5001)
.setPayload(new Data(new byte[] {0x01}))));
byte[] testPacketSerialized = testPacket.serialize();
OFPacketIn pi;
// build out input packet
pi = OFFactories.getFactory(OFVersion.OF_13).buildPacketIn()
.setBufferId(OFBufferId.NO_BUFFER)
.setData(testPacketSerialized)
.setReason(OFPacketInReason.NO_MATCH)
.build();
return pi;
}
示例3: generateICMPPing
import net.floodlightcontroller.packet.Data; //导入依赖的package包/类
protected byte[] generateICMPPing(InetAddress ip, MACAddress mac){
targetIP = ip;
targetMAC = mac;
IPacket packet = new IPv4()
.setProtocol(IPv4.PROTOCOL_ICMP)
.setSourceAddress(ControllerIP)
.setDestinationAddress(ip.hashCode()) //this is tricky
.setPayload(new ICMP()
.setIcmpType((byte) 8)
.setIcmpCode((byte) 0)
.setPayload(new Data(new byte[]
{0x76, (byte) 0xf2, 0x0, 0x2, 0x1, 0x1, 0x1}))
);
Ethernet ethernet = new Ethernet().setSourceMACAddress(senderMAC.toBytes())
.setDestinationMACAddress(targetMAC.toBytes())
.setEtherType(Ethernet.TYPE_IPv4);
ethernet.setPayload(packet);
return ethernet.serialize();
}
示例4: createPacketIn
import net.floodlightcontroller.packet.Data; //导入依赖的package包/类
private OFPacketIn createPacketIn(String srcMAC, String dstMAC,
String srcIp, String dstIp, short vlan) {
IPacket testPacket = new Ethernet()
.setDestinationMACAddress(dstMAC)
.setSourceMACAddress(srcMAC)
.setVlanID(vlan)
.setEtherType(Ethernet.TYPE_IPv4)
.setPayload(
new IPv4()
.setTtl((byte) 128)
.setSourceAddress(srcIp)
.setDestinationAddress(dstIp)
.setPayload(new UDP()
.setSourcePort((short) 5000)
.setDestinationPort((short) 5001)
.setPayload(new Data(new byte[] {0x01}))));
byte[] testPacketSerialized = testPacket.serialize();
OFPacketIn pi;
// build out input packet
pi = OFFactories.getFactory(OFVersion.OF_13).buildPacketIn()
.setBufferId(OFBufferId.NO_BUFFER)
.setData(testPacketSerialized)
.setReason(OFPacketInReason.NO_MATCH)
.build();
return pi;
}
示例5: prepareOFPacketIn
import net.floodlightcontroller.packet.Data; //导入依赖的package包/类
public static OFPacketIn prepareOFPacketIn(String destAddress) {
IPacket iPacket = new Ethernet()
.setDestinationMACAddress("00:11:22:33:44:55")
.setSourceMACAddress("00:44:33:22:11:00")
.setEtherType(Ethernet.TYPE_IPv4)
.setPayload(
new IPv4()
.setTtl((byte) 128)
.setSourceAddress("192.168.1.1")
.setDestinationAddress(destAddress)
.setPayload(new UDP()
.setSourcePort((short) 5000)
.setDestinationPort((short) 5001)
.setPayload(new Data(new byte[]{0x01}))));
byte[] iPacketSerialized = iPacket.serialize();
return new OFPacketIn()
.setBufferId(-1)
.setInPort((short) 1)
.setPacketData(iPacketSerialized)
.setReason(OFPacketIn.OFPacketInReason.NO_MATCH)
.setTotalLength((short) iPacketSerialized.length);
}
示例6: getPacket
import net.floodlightcontroller.packet.Data; //导入依赖的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;
}
示例7: setUp
import net.floodlightcontroller.packet.Data; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
super.setUp();
mockFloodlightProvider = getMockFloodlightProvider();
hub = new Hub();
mockFloodlightProvider.addOFMessageListener(OFType.PACKET_IN, hub);
hub.setFloodlightProvider(mockFloodlightProvider);
// Build our test packet
this.testPacket = new Ethernet()
.setDestinationMACAddress("00:11:22:33:44:55")
.setSourceMACAddress("00:44:33:22:11:00")
.setEtherType(EthType.IPv4)
.setPayload(
new IPv4()
.setTtl((byte) 128)
.setSourceAddress("192.168.1.1")
.setDestinationAddress("192.168.1.2")
.setPayload(new UDP()
.setSourcePort((short) 5000)
.setDestinationPort((short) 5001)
.setPayload(new Data(new byte[] {0x01}))));
this.testPacketSerialized = testPacket.serialize();
// Build the PacketIn
this.packetIn = (OFPacketIn) OFFactories.getFactory(OFVersion.OF_13).buildPacketIn()
.setBufferId(OFBufferId.NO_BUFFER)
.setMatch(OFFactories.getFactory(OFVersion.OF_13).buildMatch()
.setExact(MatchField.IN_PORT, OFPort.of(1))
.build())
.setData(this.testPacketSerialized)
.setReason(OFPacketInReason.NO_MATCH)
.setTotalLen((short) this.testPacketSerialized.length).build();
}
示例8: setUp
import net.floodlightcontroller.packet.Data; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
super.setUp();
mockFloodlightProvider = getMockFloodlightProvider();
hub = new Hub();
mockFloodlightProvider.addOFMessageListener(OFType.PACKET_IN, hub);
hub.setFloodlightProvider(mockFloodlightProvider);
// Build our test packet
this.testPacket = new Ethernet()
.setDestinationMACAddress("00:11:22:33:44:55")
.setSourceMACAddress("00:44:33:22:11:00")
.setEtherType(Ethernet.TYPE_IPv4)
.setPayload(
new IPv4()
.setTtl((byte) 128)
.setSourceAddress("192.168.1.1")
.setDestinationAddress("192.168.1.2")
.setPayload(new UDP()
.setSourcePort((short) 5000)
.setDestinationPort((short) 5001)
.setPayload(new Data(new byte[] {0x01}))));
this.testPacketSerialized = testPacket.serialize();
// Build the PacketIn
this.packetIn = ((OFPacketIn) mockFloodlightProvider.getOFMessageFactory().getMessage(OFType.PACKET_IN))
.setBufferId(-1)
.setInPort((short) 1)
.setPacketData(this.testPacketSerialized)
.setReason(OFPacketInReason.NO_MATCH)
.setTotalLength((short) this.testPacketSerialized.length);
}
示例9: createPacketIn
import net.floodlightcontroller.packet.Data; //导入依赖的package包/类
private OFPacketIn createPacketIn(String srcMAC, String dstMAC,
String srcIp, String dstIp, short vlan) {
IPacket testPacket = new Ethernet()
.setDestinationMACAddress(dstMAC)
.setSourceMACAddress(srcMAC)
.setVlanID(vlan)
.setEtherType(Ethernet.TYPE_IPv4)
.setPayload(
new IPv4()
.setTtl((byte) 128)
.setSourceAddress(srcIp)
.setDestinationAddress(dstIp)
.setPayload(new UDP()
.setSourcePort((short) 5000)
.setDestinationPort((short) 5001)
.setPayload(new Data(new byte[] {0x01}))));
byte[] testPacketSerialized = testPacket.serialize();
OFPacketIn pi;
// build out input packet
pi = ((OFPacketIn) BasicFactory.getInstance().getMessage(OFType.PACKET_IN))
.setBufferId(-1)
.setInPort((short) 1)
.setPacketData(testPacketSerialized)
.setReason(OFPacketInReason.NO_MATCH)
.setTotalLength((short) testPacketSerialized.length);
return pi;
}
示例10: sendMessage
import net.floodlightcontroller.packet.Data; //导入依赖的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);
}
示例11: setUp
import net.floodlightcontroller.packet.Data; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
super.setUp();
mockFloodlightProvider = getMockFloodlightProvider();
hub = new Hub();
mockFloodlightProvider.addOFMessageListener(OFType.PACKET_IN, hub);
hub.setFloodlightProvider(mockFloodlightProvider);
// Build our test packet
this.testPacket = new Ethernet()
.setDestinationMACAddress("00:11:22:33:44:55")
.setSourceMACAddress("00:44:33:22:11:00")
.setEtherType(Ethernet.TYPE_IPv4)
.setPayload(
new IPv4()
.setTtl((byte) 128)
.setSourceAddress("192.168.1.1")
.setDestinationAddress("192.168.1.2")
.setPayload(new UDP()
.setSourcePort((short) 5000)
.setDestinationPort((short) 5001)
.setPayload(new Data(new byte[] {0x01}))));
this.testPacketSerialized = testPacket.serialize();
// Build the PacketIn
this.packetIn = (OFPacketIn) OFFactories.getFactory(OFVersion.OF_13).buildPacketIn()
.setBufferId(OFBufferId.NO_BUFFER)
.setMatch(OFFactories.getFactory(OFVersion.OF_13).buildMatch()
.setExact(MatchField.IN_PORT, OFPort.of(1))
.build())
.setData(this.testPacketSerialized)
.setReason(OFPacketInReason.NO_MATCH)
.setTotalLen((short) this.testPacketSerialized.length).build();
}
示例12: createPacketIn
import net.floodlightcontroller.packet.Data; //导入依赖的package包/类
private OFPacketIn createPacketIn(String srcMAC, String dstMAC,
String srcIp, String dstIp, short vlan) {
IPacket testPacket = new Ethernet()
.setDestinationMACAddress(dstMAC)
.setSourceMACAddress(srcMAC)
.setVlanID(vlan)
.setEtherType(Ethernet.TYPE_IPv4)
.setPayload(
new IPv4()
.setTtl((byte) 128)
.setSourceAddress(srcIp)
.setDestinationAddress(dstIp)
.setPayload(new UDP()
.setSourcePort((short) 5000)
.setDestinationPort((short) 5001)
.setPayload(new Data(new byte[] {0x01}))));
byte[] testPacketSerialized = testPacket.serialize();
OFPacketIn pi;
// build out input packet
pi = ((OFPacketIn) new BasicFactory().getMessage(OFType.PACKET_IN))
.setBufferId(-1)
.setInPort((short) 1)
.setPacketData(testPacketSerialized)
.setReason(OFPacketInReason.NO_MATCH)
.setTotalLength((short) testPacketSerialized.length);
return pi;
}