Search in sources :

Example 1 with Ping

use of org.openkilda.messaging.model.Ping in project open-kilda by telstra.

the class UniFlowPingResponseTest method serializeLoop.

@Test
public void serializeLoop() throws Exception {
    NetworkEndpoint endpointAlpha = new NetworkEndpoint(new SwitchId("ff:fe:00:00:00:00:00:01"), 8);
    NetworkEndpoint endpointBeta = new NetworkEndpoint(new SwitchId("ff:fe:00:00:00:00:00:02"), 10);
    UniFlowPingResponse origin = new UniFlowPingResponse(new Ping(endpointBeta, endpointAlpha, new FlowTransitEncapsulation(4, FlowEncapsulationType.TRANSIT_VLAN), 5), new PingMeters(3L, 2L, 1L), null);
    InfoMessage wrapper = new InfoMessage(origin, System.currentTimeMillis(), getClass().getSimpleName());
    serializer.serialize(wrapper);
    InfoMessage decodedWrapper = (InfoMessage) serializer.deserialize();
    InfoData decoded = decodedWrapper.getData();
    Assert.assertEquals(String.format("%s object have been mangled in serialisation/deserialization loop", origin.getClass().getName()), origin, decoded);
}
Also used : NetworkEndpoint(org.openkilda.messaging.model.NetworkEndpoint) InfoMessage(org.openkilda.messaging.info.InfoMessage) InfoData(org.openkilda.messaging.info.InfoData) Ping(org.openkilda.messaging.model.Ping) FlowTransitEncapsulation(org.openkilda.model.FlowTransitEncapsulation) SwitchId(org.openkilda.model.SwitchId) PingMeters(org.openkilda.messaging.model.PingMeters) Test(org.junit.Test)

Example 2 with Ping

use of org.openkilda.messaging.model.Ping in project open-kilda by telstra.

the class PingRequestCommandWriteOkTest method writeError.

@Test
public void writeError() throws Exception {
    final DatapathId dpIdWriteError = DatapathId.of(0x0000fffe00000005L);
    IOFSwitch switchWriteError = createMock(IOFSwitch.class);
    expect(switchService.getActiveSwitch(dpIdWriteError)).andReturn(switchWriteError).anyTimes();
    expect(switchWriteError.getId()).andReturn(dpIdWriteError).anyTimes();
    expect(switchWriteError.getOFFactory()).andReturn(new OFFactoryVer13()).anyTimes();
    expect(switchWriteError.getLatency()).andReturn(U64.of(5)).anyTimes();
    expect(switchWriteError.write(anyObject(OFMessage.class))).andReturn(false);
    switchIntoTestMode();
    Ping ping = makePing(switchWriteError, switchBeta);
    PingRequestCommand command = makeCommand(ping);
    command.call();
    verifySentErrorResponse(ping, Errors.WRITE_FAILURE);
}
Also used : IOFSwitch(net.floodlightcontroller.core.IOFSwitch) OFMessage(org.projectfloodlight.openflow.protocol.OFMessage) OFFactoryVer13(org.projectfloodlight.openflow.protocol.ver13.OFFactoryVer13) Ping(org.openkilda.messaging.model.Ping) DatapathId(org.projectfloodlight.openflow.types.DatapathId) Test(org.junit.Test)

Example 3 with Ping

use of org.openkilda.messaging.model.Ping in project open-kilda by telstra.

the class PingServiceTest method testWrapUnwrapCycleVxlan.

@Test
public void testWrapUnwrapCycleVxlan() throws Exception {
    Ping ping = new Ping(new NetworkEndpoint(new SwitchId(dpIdAlpha.getLong()), 8), new NetworkEndpoint(new SwitchId(dpIdBeta.getLong()), 9), new FlowTransitEncapsulation(2, FlowEncapsulationType.VXLAN), 3);
    moduleContext.getServiceImpl(InputService.class).addTranslator(eq(OFType.PACKET_IN), anyObject(PingInputTranslator.class));
    replayAll();
    pingService.setup(moduleContext);
    byte[] payload = new byte[] { 0x31, 0x32, 0x33, 0x34, 0x35 };
    byte[] wrapped = pingService.wrapData(ping, payload).serialize();
    IPacket ethernet = new Ethernet().deserialize(wrapped, 0, wrapped.length);
    Assert.assertTrue(ethernet instanceof Ethernet);
    IPacket ipv4 = ethernet.getPayload();
    Assert.assertTrue(ipv4 instanceof IPv4);
    IPacket udp = ipv4.getPayload();
    Assert.assertTrue(udp instanceof UDP);
    Assert.assertEquals(((UDP) udp).getSourcePort(), TransportPort.of(SwitchManager.STUB_VXLAN_UDP_SRC));
    Assert.assertEquals(((UDP) udp).getDestinationPort(), TransportPort.of(SwitchManager.VXLAN_UDP_DST));
    byte[] udpPayload = udp.getPayload().serialize();
    Vxlan vxlan = (Vxlan) new Vxlan().deserialize(udpPayload, 0, udpPayload.length);
    Assert.assertEquals((int) ping.getTransitEncapsulation().getId(), vxlan.getVni());
    byte[] vxlanPayload = vxlan.getPayload().serialize();
    IPacket decoded = new Ethernet().deserialize(vxlanPayload, 0, vxlanPayload.length);
    Assert.assertTrue(decoded instanceof Ethernet);
    PingWiredView parsed = pingService.unwrapData(dpIdBeta, (Ethernet) decoded);
    Assert.assertNotNull(parsed);
    Assert.assertArrayEquals(payload, parsed.getPayload());
    Assert.assertTrue(parsed.getVlanStack().isEmpty());
}
Also used : UDP(net.floodlightcontroller.packet.UDP) IPacket(net.floodlightcontroller.packet.IPacket) Vxlan(org.openkilda.floodlight.shared.packet.Vxlan) NetworkEndpoint(org.openkilda.messaging.model.NetworkEndpoint) IPv4(net.floodlightcontroller.packet.IPv4) FlowTransitEncapsulation(org.openkilda.model.FlowTransitEncapsulation) SwitchId(org.openkilda.model.SwitchId) InputService(org.openkilda.floodlight.service.of.InputService) PingWiredView(org.openkilda.floodlight.model.PingWiredView) Ping(org.openkilda.messaging.model.Ping) Ethernet(net.floodlightcontroller.packet.Ethernet) Test(org.junit.Test)

Example 4 with Ping

use of org.openkilda.messaging.model.Ping in project open-kilda by telstra.

the class FlowPingResponseTest method serializeLoop.

@Test
public void serializeLoop() throws Exception {
    NetworkEndpoint endpointAlpha = new NetworkEndpoint(new SwitchId("ff:fe:00:00:00:00:00:01"), 8);
    NetworkEndpoint endpointBeta = new NetworkEndpoint(new SwitchId("ff:fe:00:00:00:00:00:02"), 10);
    UniFlowPingResponse forward = new UniFlowPingResponse(new Ping(endpointAlpha, endpointBeta, new FlowTransitEncapsulation(4, FlowEncapsulationType.TRANSIT_VLAN), 5), new PingMeters(1L, 2L, 3L), null);
    UniFlowPingResponse reverse = new UniFlowPingResponse(new Ping(endpointBeta, endpointAlpha, new FlowTransitEncapsulation(4, FlowEncapsulationType.TRANSIT_VLAN), 5), new PingMeters(3L, 2L, 1L), null);
    FlowPingResponse origin = new FlowPingResponse("flowId-" + getClass().getSimpleName(), forward, reverse, null);
    InfoMessage wrapper = new InfoMessage(origin, System.currentTimeMillis(), getClass().getSimpleName());
    serializer.serialize(wrapper);
    InfoMessage decodedWrapper = (InfoMessage) serializer.deserialize();
    InfoData decoded = decodedWrapper.getData();
    Assert.assertEquals(String.format("%s object have been mangled in serialisation/deserialization loop", origin.getClass().getName()), origin, decoded);
}
Also used : NetworkEndpoint(org.openkilda.messaging.model.NetworkEndpoint) InfoMessage(org.openkilda.messaging.info.InfoMessage) InfoData(org.openkilda.messaging.info.InfoData) Ping(org.openkilda.messaging.model.Ping) FlowTransitEncapsulation(org.openkilda.model.FlowTransitEncapsulation) SwitchId(org.openkilda.model.SwitchId) PingMeters(org.openkilda.messaging.model.PingMeters) Test(org.junit.Test)

Example 5 with Ping

use of org.openkilda.messaging.model.Ping in project open-kilda by telstra.

the class Blacklist method filter.

private void filter(Tuple input, PingContext pingContext) throws PipelineException {
    final Ping ping = pingContext.getPing();
    if (blacklist.contains(ping)) {
        log.debug("{} canceled due to blacklist match", pingContext);
        return;
    }
    Values output = new Values(pingContext, pullContext(input));
    getOutput().emit(input, output);
}
Also used : Ping(org.openkilda.messaging.model.Ping) Values(org.apache.storm.tuple.Values)

Aggregations

Ping (org.openkilda.messaging.model.Ping)9 Test (org.junit.Test)7 NetworkEndpoint (org.openkilda.messaging.model.NetworkEndpoint)7 SwitchId (org.openkilda.model.SwitchId)6 FlowTransitEncapsulation (org.openkilda.model.FlowTransitEncapsulation)5 Ethernet (net.floodlightcontroller.packet.Ethernet)3 IPacket (net.floodlightcontroller.packet.IPacket)3 InputService (org.openkilda.floodlight.service.of.InputService)3 InfoMessage (org.openkilda.messaging.info.InfoMessage)3 PingWiredView (org.openkilda.floodlight.model.PingWiredView)2 InfoData (org.openkilda.messaging.info.InfoData)2 PingMeters (org.openkilda.messaging.model.PingMeters)2 OFMessage (org.projectfloodlight.openflow.protocol.OFMessage)2 OFFactoryVer13 (org.projectfloodlight.openflow.protocol.ver13.OFFactoryVer13)2 DatapathId (org.projectfloodlight.openflow.types.DatapathId)2 FloodlightContext (net.floodlightcontroller.core.FloodlightContext)1 IOFSwitch (net.floodlightcontroller.core.IOFSwitch)1 IPv4 (net.floodlightcontroller.packet.IPv4)1 UDP (net.floodlightcontroller.packet.UDP)1 Values (org.apache.storm.tuple.Values)1