Search in sources :

Example 16 with OFPacketOut

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);
}
Also used : UDP(net.floodlightcontroller.packet.UDP) Ethernet(net.floodlightcontroller.packet.Ethernet) IPv4(net.floodlightcontroller.packet.IPv4) OFPacketOut(org.projectfloodlight.openflow.protocol.OFPacketOut) Test(org.junit.Test)

Example 17 with OFPacketOut

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);
}
Also used : InetSocketAddress(java.net.InetSocketAddress) OFPacketOut(org.projectfloodlight.openflow.protocol.OFPacketOut) Test(org.junit.Test)

Aggregations

OFPacketOut (org.projectfloodlight.openflow.protocol.OFPacketOut)17 Test (org.junit.Test)10 IOFSwitch (net.floodlightcontroller.core.IOFSwitch)8 Ethernet (net.floodlightcontroller.packet.Ethernet)6 JWTVerificationException (com.auth0.jwt.exceptions.JWTVerificationException)4 UnsupportedEncodingException (java.io.UnsupportedEncodingException)4 Optional (java.util.Optional)4 FloodlightModuleException (net.floodlightcontroller.core.module.FloodlightModuleException)4 IPv4 (net.floodlightcontroller.packet.IPv4)4 UDP (net.floodlightcontroller.packet.UDP)4 DatapathId (org.projectfloodlight.openflow.types.DatapathId)4 InetSocketAddress (java.net.InetSocketAddress)3 OFFactory (org.projectfloodlight.openflow.protocol.OFFactory)3 OFMessage (org.projectfloodlight.openflow.protocol.OFMessage)3 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)2 ByteBuffer (java.nio.ByteBuffer)2 IPacket (net.floodlightcontroller.packet.IPacket)2 LLDPTLV (net.floodlightcontroller.packet.LLDPTLV)2 OFPortDescPropEthernet (org.projectfloodlight.openflow.protocol.OFPortDescPropEthernet)2 IPv4Address (org.projectfloodlight.openflow.types.IPv4Address)2