use of org.projectfloodlight.openflow.protocol.OFPacketOut in project open-kilda by telstra.
the class PathVerificationCommonTests method testDiscoveryPacketHeadersSize.
@Test
public void testDiscoveryPacketHeadersSize() {
OFPacketOut packet = pvs.generateDiscoveryPacket(sw, OFPort.of(1), true, null);
Ethernet ethernet = (Ethernet) new Ethernet().deserialize(packet.getData(), 0, packet.getData().length);
IPv4 ipv4 = (IPv4) ethernet.getPayload();
UDP udp = (UDP) ipv4.getPayload();
assertEquals(ETHERNET_HEADER_SIZE, (ethernet.serialize().length - ipv4.getTotalLength()) * 8);
assertEquals(IP_V4_HEADER_SIZE, (ipv4.getTotalLength() - udp.getLength()) * 8);
assertEquals(UDP_HEADER_SIZE, (udp.getLength() - udp.getPayload().serialize().length) * 8);
}
use of org.projectfloodlight.openflow.protocol.OFPacketOut in project open-kilda by telstra.
the class PathVerificationPacketOutTest method testBcastPacket.
@Test
public void testBcastPacket() {
// This is Broadcast so set dstIpTarget to the broadcast IP
InetSocketAddress dstIpTarget = new InetSocketAddress(pvs.DISCOVERY_PACKET_IP_DST, 200);
// Generate the DiscoveryPacket
OFPacketOut packet = pvs.generateDiscoveryPacket(sw1, OFPort.of(1), true, null);
System.out.println("packet: " + Hex.encodeHexString(packet.getData()));
// Source MAC will always be that of sw1 for both Unicast and Broadcast
byte[] srcMac = Arrays.copyOfRange(packet.getData(), 6, 12);
assertArrayEquals(MacAddress.of(sw1.getId()).getBytes(), srcMac);
// Destination MAC should be that of BROADCAST for Broadcast Packet
byte[] dstMac = Arrays.copyOfRange(packet.getData(), 0, 6);
assertArrayEquals(MacAddress.of(VERIFICATION_BCAST_PACKET_DST).getBytes(), dstMac);
// Source IP is actual switch1 IP
byte[] srcIpActual = Arrays.copyOfRange(packet.getData(), 26, 30);
assertArrayEquals(srcIpTarget.getAddress().getAddress(), srcIpActual);
// Destination IP is that of DESTINATION BROADCAST IP
byte[] dstIpActual = Arrays.copyOfRange(packet.getData(), 30, 34);
assertArrayEquals(dstIpTarget.getAddress().getAddress(), dstIpActual);
}
Aggregations