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);
}
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;
}
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);
}
Aggregations