Search in sources :

Example 1 with PingImpossibleException

use of org.openkilda.floodlight.error.PingImpossibleException in project open-kilda by telstra.

the class PingRequestCommand method send.

private void send(IOFSwitch sw) throws PingImpossibleException {
    PingData data = PingData.of(ping);
    data.setSenderLatency(sw.getLatency().getValue());
    PingService pingService = getPingService();
    byte[] signedData = pingService.getSignature().sign(data);
    byte[] rawPackage = pingService.wrapData(ping, signedData).serialize();
    OFMessage message = makePacketOut(sw, rawPackage);
    if (!sw.write(message)) {
        throw new PingImpossibleException(ping, Errors.WRITE_FAILURE);
    }
    logPing.info("Send ping {}", ping);
}
Also used : PingData(org.openkilda.floodlight.model.PingData) PingImpossibleException(org.openkilda.floodlight.error.PingImpossibleException) OFMessage(org.projectfloodlight.openflow.protocol.OFMessage) PingService(org.openkilda.floodlight.service.ping.PingService)

Example 2 with PingImpossibleException

use of org.openkilda.floodlight.error.PingImpossibleException in project open-kilda by telstra.

the class PingRequestCommand method checkSource.

private IOFSwitch checkSource() throws PingImpossibleException {
    SwitchId swId = ping.getSource().getDatapath();
    IOFSwitch sw = lookupSwitch(swId);
    if (sw == null) {
        log.debug("Do not own ping's source switch {}", swId);
        // TODO(surabujin): must be changed when multi FL design will be accepted
        throw new PingImpossibleException(ping, Errors.SOURCE_NOT_AVAILABLE);
    }
    checkCapability(sw);
    return sw;
}
Also used : IOFSwitch(net.floodlightcontroller.core.IOFSwitch) PingImpossibleException(org.openkilda.floodlight.error.PingImpossibleException) SwitchId(org.openkilda.model.SwitchId)

Example 3 with PingImpossibleException

use of org.openkilda.floodlight.error.PingImpossibleException 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)

Aggregations

PingImpossibleException (org.openkilda.floodlight.error.PingImpossibleException)3 IOFSwitch (net.floodlightcontroller.core.IOFSwitch)1 Data (net.floodlightcontroller.packet.Data)1 Ethernet (net.floodlightcontroller.packet.Ethernet)1 IPv4 (net.floodlightcontroller.packet.IPv4)1 UDP (net.floodlightcontroller.packet.UDP)1 PingData (org.openkilda.floodlight.model.PingData)1 PingService (org.openkilda.floodlight.service.ping.PingService)1 Vxlan (org.openkilda.floodlight.shared.packet.Vxlan)1 SwitchId (org.openkilda.model.SwitchId)1 OFMessage (org.projectfloodlight.openflow.protocol.OFMessage)1 DatapathId (org.projectfloodlight.openflow.types.DatapathId)1