Search in sources :

Example 1 with SendEvent

use of org.opendaylight.openflowjava.protocol.impl.clients.SendEvent 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 SendEvent

use of org.opendaylight.openflowjava.protocol.impl.clients.SendEvent 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 SendEvent

use of org.opendaylight.openflowjava.protocol.impl.clients.SendEvent 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 4 with SendEvent

use of org.opendaylight.openflowjava.protocol.impl.clients.SendEvent 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)

Example 5 with SendEvent

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

the class IntegrationTest method testHandshakeAndEcho.

/**
 * Library integration and communication test with handshake + echo exchange.
 */
@Test
public void testHandshakeAndEcho() throws Exception {
    setUp(TransportProtocol.TCP);
    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.TCP, ClientType.SIMPLE);
    final OFClient firstClient = clients.get(0);
    firstClient.getScenarioDone().get();
    LOGGER.debug("testHandshakeAndEcho() 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

ClientEvent (org.opendaylight.openflowjava.protocol.impl.clients.ClientEvent)7 SendEvent (org.opendaylight.openflowjava.protocol.impl.clients.SendEvent)7 WaitForMessageEvent (org.opendaylight.openflowjava.protocol.impl.clients.WaitForMessageEvent)7 ArrayDeque (java.util.ArrayDeque)4 SleepEvent (org.opendaylight.openflowjava.protocol.impl.clients.SleepEvent)4 Test (org.junit.Test)3 OFClient (org.opendaylight.openflowjava.protocol.impl.clients.OFClient)3 ScenarioHandler (org.opendaylight.openflowjava.protocol.impl.clients.ScenarioHandler)3