Search in sources :

Example 11 with OFPacketOut

use of org.projectfloodlight.openflow.protocol.OFPacketOut in project open-kilda by telstra.

the class SessionServiceTest method positive.

@Test
public void positive() throws Exception {
    IOFSwitch sw = createMock(IOFSwitch.class);
    setupSwitchMock(sw, dpId);
    swWriteAlwaysSuccess(sw);
    doneWithSetUp(sw);
    CompletableFuture<Optional<OFMessage>> future;
    OFPacketOut pktOut = makePacketOut(sw.getOFFactory(), 1);
    try (Session session = subject.open(context, sw)) {
        future = session.write(pktOut);
    }
    Assert.assertFalse(future.isDone());
    List<OFMessage> swActualWrite = swWriteMessages.getValues();
    Assert.assertEquals(2, swActualWrite.size());
    Assert.assertEquals(pktOut, swActualWrite.get(0));
    Assert.assertEquals(OFType.BARRIER_REQUEST, swActualWrite.get(1).getType());
    completeSessions(sw);
    Assert.assertTrue(future.isDone());
    Optional<OFMessage> response = future.get();
    Assert.assertFalse(response.isPresent());
}
Also used : IOFSwitch(net.floodlightcontroller.core.IOFSwitch) Optional(java.util.Optional) OFMessage(org.projectfloodlight.openflow.protocol.OFMessage) OFPacketOut(org.projectfloodlight.openflow.protocol.OFPacketOut) Test(org.junit.Test)

Example 12 with OFPacketOut

use of org.projectfloodlight.openflow.protocol.OFPacketOut in project open-kilda by telstra.

the class SessionServiceTest method responseBeforeClose.

@Test
public void responseBeforeClose() throws Exception {
    IOFSwitch sw = createMock(IOFSwitch.class);
    setupSwitchMock(sw, dpId);
    swWriteAlwaysSuccess(sw);
    doneWithSetUp(sw);
    OFFactory ofFactory = sw.getOFFactory();
    CompletableFuture<Optional<OFMessage>> first;
    CompletableFuture<Optional<OFMessage>> second;
    try (Session session = subject.open(context, sw)) {
        OFPacketOut egress = makePacketOut(ofFactory, 100);
        first = session.write(egress);
        second = session.write(makePacketOut(ofFactory, 1));
        // response before close
        OFMessage ingress = ofFactory.errorMsgs().buildBadRequestErrorMsg().setXid(egress.getXid()).setCode(OFBadRequestCode.BAD_PORT).build();
        subject.handleResponse(dpId, ingress);
    }
    completeSessions(sw);
    // received error response must be reported via future
    expectExceptionResponse(first, SessionErrorResponseException.class);
    // second request must be marker as completed
    expectNoResponse(second);
}
Also used : IOFSwitch(net.floodlightcontroller.core.IOFSwitch) Optional(java.util.Optional) OFMessage(org.projectfloodlight.openflow.protocol.OFMessage) OFFactory(org.projectfloodlight.openflow.protocol.OFFactory) OFPacketOut(org.projectfloodlight.openflow.protocol.OFPacketOut) Test(org.junit.Test)

Example 13 with OFPacketOut

use of org.projectfloodlight.openflow.protocol.OFPacketOut in project open-kilda by telstra.

the class PathVerificationPacketSignTest method setUp.

@Before
public void setUp() throws Exception {
    super.setUp();
    final OFPacketOut packetOut = pvs.generateDiscoveryPacket(sw1, OFPort.of(1), true, null);
    ofPacketIn = EasyMock.createMock(OFPacketIn.class);
    context = new FloodlightContext();
    expect(ofPacketIn.getType()).andReturn(OFType.PACKET_IN).anyTimes();
    expect(ofPacketIn.getXid()).andReturn(0L).anyTimes();
    expect(ofPacketIn.getVersion()).andReturn(packetOut.getVersion()).anyTimes();
    expect(ofPacketIn.getCookie()).andReturn(PathVerificationService.OF_CATCH_RULE_COOKIE);
    Match match = EasyMock.createMock(Match.class);
    expect(match.get(MatchField.IN_PORT)).andReturn(OFPort.of(1)).anyTimes();
    replay(match);
    expect(ofPacketIn.getMatch()).andReturn(match).anyTimes();
    replay(ofPacketIn);
    IPacket expected = new Ethernet().deserialize(packetOut.getData(), 0, packetOut.getData().length);
    context.getStorage().put(IFloodlightProviderService.CONTEXT_PI_PAYLOAD, expected);
    HashMap<DatapathId, IOFSwitch> switches = new HashMap<>();
    switches.put(sw1.getId(), sw1);
    switches.put(sw2.getId(), sw2);
    mockSwitchManager.setSwitches(switches);
}
Also used : IPacket(net.floodlightcontroller.packet.IPacket) IOFSwitch(net.floodlightcontroller.core.IOFSwitch) HashMap(java.util.HashMap) Ethernet(net.floodlightcontroller.packet.Ethernet) OFPacketIn(org.projectfloodlight.openflow.protocol.OFPacketIn) DatapathId(org.projectfloodlight.openflow.types.DatapathId) OFPacketOut(org.projectfloodlight.openflow.protocol.OFPacketOut) FloodlightContext(net.floodlightcontroller.core.FloodlightContext) Match(org.projectfloodlight.openflow.protocol.match.Match) Before(org.junit.Before)

Example 14 with OFPacketOut

use of org.projectfloodlight.openflow.protocol.OFPacketOut in project open-kilda by telstra.

the class PathVerificationPacketSignTest method testSignPacketMissedSign.

@Test
public void testSignPacketMissedSign() {
    replay(producerService);
    OFPacketOut noSignPacket = pvs.generateDiscoveryPacket(sw1, OFPort.of(1), false, null);
    IPacket noSignPacketData = new Ethernet().deserialize(noSignPacket.getData(), 0, noSignPacket.getData().length);
    context.getStorage().put(IFloodlightProviderService.CONTEXT_PI_PAYLOAD, noSignPacketData);
    pvs.handlePacketIn(new OfInput(sw2, ofPacketIn, context));
    verify(producerService);
}
Also used : OfInput(org.openkilda.floodlight.model.OfInput) IPacket(net.floodlightcontroller.packet.IPacket) Ethernet(net.floodlightcontroller.packet.Ethernet) OFPacketOut(org.projectfloodlight.openflow.protocol.OFPacketOut) Test(org.junit.Test)

Example 15 with OFPacketOut

use of org.projectfloodlight.openflow.protocol.OFPacketOut in project open-kilda by telstra.

the class PathVerificationCommonTests method testRoundTripLatencyTimestampOffset.

@Test
public void testRoundTripLatencyTimestampOffset() {
    OFPacketOut packet = pvs.generateDiscoveryPacket(sw, OFPort.of(1), true, null);
    assertRoundTripLatencyOffset(packet.getData(), SWITCH_T0_OPTIONAL_TYPE, ROUND_TRIP_LATENCY_T0_OFFSET);
    assertRoundTripLatencyOffset(packet.getData(), SWITCH_T1_OPTIONAL_TYPE, ROUND_TRIP_LATENCY_T1_OFFSET);
}
Also used : 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