Search in sources :

Example 1 with WaitForMessageEvent

use of org.opendaylight.openflowjava.protocol.impl.clients.WaitForMessageEvent in project openflowplugin by opendaylight.

the class ScenarioFactory method createHandshakeScenarioVBM.

/**
 * Creates stack with handshake needed messages.
 * <ol> XID of messages:
 *   <li> hello sent - 00000001
 *   <li> hello waiting - 00000015
 *   <li> featuresrequest waiting - 00000002
 *   <li> featuresreply sent - 00000002
 * </ol>
 * @param switchVersionBitmap
 * @param auxId
 * @param pluginVersionBitmap
 * @param addSleep if true - then add final sleep {@link #DEFAULT_SCENARIO_SLEEP}
 * @return stack filled with Handshake messages
 */
public static Deque<ClientEvent> createHandshakeScenarioVBM(String switchVersionBitmap, short auxId, String pluginVersionBitmap, boolean addSleep) {
    Deque<ClientEvent> stack = new ArrayDeque<>();
    stack.addFirst(new SendEvent(ByteBufUtils.hexStringToBytes("04 00 00 10 00 00 00 01 " + switchVersionBitmap)));
    stack.addFirst(new WaitForMessageEvent(ByteBufUtils.hexStringToBytes("04 00 00 10 00 00 00 15 " + pluginVersionBitmap)));
    stack.addFirst(new WaitForMessageEvent(ByteBufUtils.hexStringToBytes("04 05 00 08 00 00 00 02")));
    stack.addFirst(new SendEvent(ByteBufUtils.hexStringToBytes("04 06 00 20 00 00 00 02 " + "00 01 02 03 04 05 06 07 " + "00 01 02 03 01 " + Integer.toHexString(auxId) + " 00 00 00 01 02 03 00 01 02 03")));
    if (addSleep) {
        addSleep(stack);
    }
    return stack;
}
Also used : WaitForMessageEvent(org.opendaylight.openflowjava.protocol.impl.clients.WaitForMessageEvent) ClientEvent(org.opendaylight.openflowjava.protocol.impl.clients.ClientEvent) ArrayDeque(java.util.ArrayDeque) SendEvent(org.opendaylight.openflowjava.protocol.impl.clients.SendEvent)

Example 2 with WaitForMessageEvent

use of org.opendaylight.openflowjava.protocol.impl.clients.WaitForMessageEvent in project openflowplugin by opendaylight.

the class ScenarioFactory method createHandshakeScenario.

/**
 * @param auxId
 * @param pluginVersionBitmap
 * @return handshake scenario without switch version bitmap
 */
public static Deque<ClientEvent> createHandshakeScenario(short auxId, String pluginVersionBitmap) {
    Deque<ClientEvent> stack = new ArrayDeque<>();
    stack.addFirst(new SendEvent(ByteBufUtils.hexStringToBytes("04 00 00 08 00 00 00 01")));
    stack.addFirst(new WaitForMessageEvent(ByteBufUtils.hexStringToBytes("04 00 00 10 00 00 00 15 " + pluginVersionBitmap)));
    stack.addFirst(new WaitForMessageEvent(ByteBufUtils.hexStringToBytes("04 05 00 08 00 00 00 02")));
    stack.addFirst(new SendEvent(ByteBufUtils.hexStringToBytes("04 06 00 20 00 00 00 02 " + "00 01 02 03 04 05 06 07 " + "00 01 02 03 01 " + Integer.toHexString(auxId) + " 00 00 00 01 02 03 00 01 02 03")));
    addSleep(stack);
    return stack;
}
Also used : WaitForMessageEvent(org.opendaylight.openflowjava.protocol.impl.clients.WaitForMessageEvent) ClientEvent(org.opendaylight.openflowjava.protocol.impl.clients.ClientEvent) ArrayDeque(java.util.ArrayDeque) SendEvent(org.opendaylight.openflowjava.protocol.impl.clients.SendEvent)

Example 3 with WaitForMessageEvent

use of org.opendaylight.openflowjava.protocol.impl.clients.WaitForMessageEvent in project openflowplugin by opendaylight.

the class ScenarioFactory method appendPostHandshakeScenario.

/**
 * @param stack
 * @param addSleep if true - then add final sleep {@link #DEFAULT_SCENARIO_SLEEP}
 * @return
 */
public static Deque<ClientEvent> appendPostHandshakeScenario(Deque<ClientEvent> stack, boolean addSleep) {
    stack.addFirst(new WaitForMessageEvent(ByteBufUtils.hexStringToBytes("04 12 00 10 00 00 00 01 " + "00 0d 00 00 00 00 00 00")));
    stack.addFirst(new WaitForMessageEvent(ByteBufUtils.hexStringToBytes("04 12 00 10 00 00 00 02 " + "00 00 00 00 00 00 00 00")));
    if (addSleep) {
        addSleep(stack);
    }
    return stack;
}
Also used : WaitForMessageEvent(org.opendaylight.openflowjava.protocol.impl.clients.WaitForMessageEvent)

Example 4 with WaitForMessageEvent

use of org.opendaylight.openflowjava.protocol.impl.clients.WaitForMessageEvent in project openflowplugin by opendaylight.

the class IntegrationTest method testTlsHandshakeAndEcho.

/**
 * Library integration and secured communication test with handshake + echo exchange.
 */
@Test
public void testTlsHandshakeAndEcho() throws Exception {
    setUp(TransportProtocol.TLS);
    final int amountOfCLients = 1;
    final Deque<ClientEvent> scenario = ScenarioFactory.createHandshakeScenario();
    scenario.addFirst(new SleepEvent(1000));
    scenario.addFirst(new SendEvent(ByteBufUtils.hexStringToBytes("04 02 00 08 00 00 00 04")));
    scenario.addFirst(new SleepEvent(1000));
    scenario.addFirst(new WaitForMessageEvent(ByteBufUtils.hexStringToBytes("04 03 00 08 00 00 00 04")));
    final ScenarioHandler handler = new ScenarioHandler(scenario);
    final List<OFClient> clients = createAndStartClient(amountOfCLients, handler, TransportProtocol.TLS, ClientType.SIMPLE);
    final OFClient firstClient = clients.get(0);
    firstClient.getScenarioDone().get();
    LOGGER.debug("testTlsHandshakeAndEcho() Finished");
}
Also used : ScenarioHandler(org.opendaylight.openflowjava.protocol.impl.clients.ScenarioHandler) OFClient(org.opendaylight.openflowjava.protocol.impl.clients.OFClient) WaitForMessageEvent(org.opendaylight.openflowjava.protocol.impl.clients.WaitForMessageEvent) ClientEvent(org.opendaylight.openflowjava.protocol.impl.clients.ClientEvent) SendEvent(org.opendaylight.openflowjava.protocol.impl.clients.SendEvent) SleepEvent(org.opendaylight.openflowjava.protocol.impl.clients.SleepEvent) Test(org.junit.Test)

Example 5 with WaitForMessageEvent

use of org.opendaylight.openflowjava.protocol.impl.clients.WaitForMessageEvent in project openflowplugin by opendaylight.

the class IntegrationTest method testUdpHandshakeAndEcho.

/**
 * Library udp integration and communication test with handshake + echo exchange.
 */
@Test
public void testUdpHandshakeAndEcho() throws Exception {
    setUp(TransportProtocol.UDP);
    final int amountOfCLients = 1;
    final Deque<ClientEvent> scenario = ScenarioFactory.createHandshakeScenario();
    scenario.addFirst(new SleepEvent(1000));
    scenario.addFirst(new SendEvent(ByteBufUtils.hexStringToBytes("04 02 00 08 00 00 00 04")));
    scenario.addFirst(new SleepEvent(1000));
    scenario.addFirst(new WaitForMessageEvent(ByteBufUtils.hexStringToBytes("04 03 00 08 00 00 00 04")));
    final ScenarioHandler handler = new ScenarioHandler(scenario);
    final List<OFClient> clients = createAndStartClient(amountOfCLients, handler, TransportProtocol.UDP, ClientType.SIMPLE);
    final OFClient firstClient = clients.get(0);
    firstClient.getScenarioDone().get();
    LOGGER.debug("testUdpHandshakeAndEcho() Finished");
}
Also used : ScenarioHandler(org.opendaylight.openflowjava.protocol.impl.clients.ScenarioHandler) OFClient(org.opendaylight.openflowjava.protocol.impl.clients.OFClient) WaitForMessageEvent(org.opendaylight.openflowjava.protocol.impl.clients.WaitForMessageEvent) ClientEvent(org.opendaylight.openflowjava.protocol.impl.clients.ClientEvent) SendEvent(org.opendaylight.openflowjava.protocol.impl.clients.SendEvent) SleepEvent(org.opendaylight.openflowjava.protocol.impl.clients.SleepEvent) Test(org.junit.Test)

Aggregations

WaitForMessageEvent (org.opendaylight.openflowjava.protocol.impl.clients.WaitForMessageEvent)9 ClientEvent (org.opendaylight.openflowjava.protocol.impl.clients.ClientEvent)8 SendEvent (org.opendaylight.openflowjava.protocol.impl.clients.SendEvent)7 SleepEvent (org.opendaylight.openflowjava.protocol.impl.clients.SleepEvent)5 ArrayDeque (java.util.ArrayDeque)4 Test (org.junit.Test)4 ScenarioHandler (org.opendaylight.openflowjava.protocol.impl.clients.ScenarioHandler)4 OFClient (org.opendaylight.openflowjava.protocol.impl.clients.OFClient)3 DataTreeIdentifier (org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier)1 FlowCapableNode (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode)1