Search in sources :

Example 1 with Data

use of net.floodlightcontroller.packet.Data in project open-kilda by telstra.

the class PingService method wrapData.

/**
 * Wrap ping data into L2, l3 and L4 network packages.
 */
public IPacket wrapData(Ping ping, byte[] payload) throws PingImpossibleException {
    Data l7 = new Data(payload);
    UDP l4 = new UDP();
    l4.setPayload(l7);
    l4.setSourcePort(TransportPort.of(NET_L3_PORT));
    l4.setDestinationPort(TransportPort.of(NET_L3_PORT));
    IPv4 l3 = new IPv4();
    l3.setPayload(l4);
    l3.setSourceAddress(NET_L3_ADDRESS);
    l3.setDestinationAddress(NET_L3_ADDRESS);
    l3.setTtl(NET_L3_TTL);
    Ethernet l2 = new Ethernet();
    l2.setPayload(l3);
    l2.setEtherType(EthType.IPv4);
    l2.setSourceMACAddress(magicSourceMacAddress);
    DatapathId egressSwitch = DatapathId.of(ping.getDest().getDatapath().toLong());
    l2.setDestinationMACAddress(MacAddress.of(egressSwitch));
    if (FlowEncapsulationType.TRANSIT_VLAN.equals(ping.getTransitEncapsulation().getType())) {
        l2.setVlanID(ping.getTransitEncapsulation().getId().shortValue());
        return l2;
    } else if (FlowEncapsulationType.VXLAN.equals(ping.getTransitEncapsulation().getType())) {
        Vxlan vxlan = new Vxlan();
        vxlan.setPayload(l2);
        vxlan.setVni(ping.getTransitEncapsulation().getId());
        UDP udp = new UDP();
        udp.setPayload(vxlan);
        udp.setSourcePort(TransportPort.of(SwitchManager.STUB_VXLAN_UDP_SRC));
        udp.setDestinationPort(TransportPort.of(SwitchManager.VXLAN_UDP_DST));
        IPv4 ipv4 = new IPv4();
        ipv4.setPayload(udp);
        ipv4.setProtocol(IpProtocol.UDP);
        ipv4.setSourceAddress(SwitchManager.STUB_VXLAN_IPV4_SRC);
        ipv4.setDestinationAddress(SwitchManager.STUB_VXLAN_IPV4_DST);
        ipv4.setTtl(NET_L3_TTL);
        Ethernet ethernet = new Ethernet();
        ethernet.setPayload(ipv4);
        ethernet.setEtherType(EthType.IPv4);
        ethernet.setSourceMACAddress(magicSourceMacAddress);
        ethernet.setDestinationMACAddress(MacAddress.of(egressSwitch));
        return ethernet;
    }
    throw new PingImpossibleException(ping, Errors.INCORRECT_REQUEST);
}
Also used : UDP(net.floodlightcontroller.packet.UDP) Vxlan(org.openkilda.floodlight.shared.packet.Vxlan) PingImpossibleException(org.openkilda.floodlight.error.PingImpossibleException) IPv4(net.floodlightcontroller.packet.IPv4) Ethernet(net.floodlightcontroller.packet.Ethernet) Data(net.floodlightcontroller.packet.Data) DatapathId(org.projectfloodlight.openflow.types.DatapathId)

Example 2 with Data

use of net.floodlightcontroller.packet.Data in project open-kilda by telstra.

the class PathVerificationPacketInTest method getPacket.

private Ethernet getPacket() {
    UDP udp = new UDP().setDestinationPort(TransportPort.of(PathVerificationService.DISCOVERY_PACKET_UDP_PORT)).setSourcePort(TransportPort.of(PathVerificationService.DISCOVERY_PACKET_UDP_PORT));
    List<LLDPTLV> optional = Lists.newArrayList(// switch t0
    new LLDPTLV().setType(OPTIONAL_LLDPTV_PACKET_TYPE).setLength((short) 12).setValue(Arrays.concatenate(ORGANIZATIONALLY_UNIQUE_IDENTIFIER, new byte[] { SWITCH_T0_OPTIONAL_TYPE }, SWITCH_T0)), // switch t1
    new LLDPTLV().setType(OPTIONAL_LLDPTV_PACKET_TYPE).setLength((short) 12).setValue(Arrays.concatenate(ORGANIZATIONALLY_UNIQUE_IDENTIFIER, new byte[] { SWITCH_T1_OPTIONAL_TYPE }, SWITCH_T1)), // dpid
    new LLDPTLV().setType(OPTIONAL_LLDPTV_PACKET_TYPE).setLength((short) 12).setValue(Arrays.concatenate(ORGANIZATIONALLY_UNIQUE_IDENTIFIER, new byte[] { REMOTE_SWITCH_OPTIONAL_TYPE }, REMOTE_SWITCH_ID)), // timestamp
    new LLDPTLV().setType(OPTIONAL_LLDPTV_PACKET_TYPE).setLength((short) 12).setValue(Arrays.concatenate(ORGANIZATIONALLY_UNIQUE_IDENTIFIER, new byte[] { TIMESTAMP_OPTIONAL_TYPE }, TIMESTAMP)), // path ordinal
    new LLDPTLV().setType(OPTIONAL_LLDPTV_PACKET_TYPE).setLength((short) 8).setValue(Arrays.concatenate(ORGANIZATIONALLY_UNIQUE_IDENTIFIER, new byte[] { PATH_ORDINAL_OPTIONAL_TYPE }, PATH_ORDINAL)));
    DiscoveryPacket discoveryPacket = DiscoveryPacket.builder().chassisId(new LLDPTLV().setType(CHASSIS_ID_LLDPTV_PACKET_TYPE).setLength((short) 7).setValue(new byte[] { 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 })).portId(new LLDPTLV().setType(PORT_ID_LLDPTV_PACKET_TYPE).setLength((short) 3).setValue(new byte[] { 0x02, 0x00, 0x01 })).ttl(new LLDPTLV().setType(TTL_LLDPTV_PACKET_TYPE).setLength((short) 2).setValue(new byte[] { 0x00, 0x78 })).optionalTlvList(optional).build();
    udp.setPayload(new Data(discoveryPacket.serialize()));
    IPv4 ip = new IPv4().setSourceAddress("192.168.0.1").setDestinationAddress(PathVerificationService.DISCOVERY_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;
}
Also used : UDP(net.floodlightcontroller.packet.UDP) IPv4(net.floodlightcontroller.packet.IPv4) Ethernet(net.floodlightcontroller.packet.Ethernet) Data(net.floodlightcontroller.packet.Data) LLDPTLV(net.floodlightcontroller.packet.LLDPTLV)

Aggregations

Data (net.floodlightcontroller.packet.Data)2 Ethernet (net.floodlightcontroller.packet.Ethernet)2 IPv4 (net.floodlightcontroller.packet.IPv4)2 UDP (net.floodlightcontroller.packet.UDP)2 LLDPTLV (net.floodlightcontroller.packet.LLDPTLV)1 PingImpossibleException (org.openkilda.floodlight.error.PingImpossibleException)1 Vxlan (org.openkilda.floodlight.shared.packet.Vxlan)1 DatapathId (org.projectfloodlight.openflow.types.DatapathId)1