2 * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.openflowplugin.openflow.md.it;
10 import java.util.Stack;
12 import org.opendaylight.openflowjava.protocol.impl.clients.ClientEvent;
13 import org.opendaylight.openflowjava.protocol.impl.clients.SendEvent;
14 import org.opendaylight.openflowjava.protocol.impl.clients.SleepEvent;
15 import org.opendaylight.openflowjava.protocol.impl.clients.WaitForMessageEvent;
16 import org.opendaylight.openflowjava.util.ByteBufUtils;
19 * provisioning of most common scenarios used by testing of integration between OFLibrary, OFPlugin and MD-SAL
21 public abstract class ScenarioFactory {
23 /** version bitmap hex-string containing version 1.3 */
24 public static final String VERSION_BITMAP_13 = "00 01 00 08 00 00 00 10";
25 /** version bitmap hex-string containing versions: 1.0 + 1.3 */
26 public static final String VERSION_BITMAP_10_13 = "00 01 00 08 00 00 00 12";
29 * Creates stack with handshake needed messages.
30 * <ol> XID of messages:
31 * <li> hello sent - 00000001
32 * <li> hello waiting - 00000015
33 * <li> featuresrequest waiting - 00000002
34 * <li> featuresreply sent - 00000002
36 * @param switchVersionBitmap
38 * @param pluginVersionBitmap
39 * @return stack filled with Handshake messages
41 public static Stack<ClientEvent> createHandshakeScenarioVBM(
42 String switchVersionBitmap, short auxId, String pluginVersionBitmap) {
43 Stack<ClientEvent> stack = new Stack<>();
45 stack.add(0, new SendEvent(ByteBufUtils
46 .hexStringToBytes("04 00 00 10 00 00 00 01 "
47 + switchVersionBitmap)));
48 stack.add(0, new WaitForMessageEvent(ByteBufUtils
49 .hexStringToBytes("04 00 00 10 00 00 00 15 "
50 + pluginVersionBitmap)));
51 stack.add(0, new WaitForMessageEvent(ByteBufUtils
52 .hexStringToBytes("04 05 00 08 00 00 00 02")));
53 stack.add(0, new SendEvent(ByteBufUtils
54 .hexStringToBytes("04 06 00 20 00 00 00 02 "
55 + "00 01 02 03 04 05 06 07 " + "00 01 02 03 01 "
56 + Integer.toHexString(auxId)
57 + " 00 00 00 01 02 03 00 01 02 03")));
65 private static void addSleep(Stack<ClientEvent> stack) {
66 stack.add(0, new SleepEvent(2000));
71 * @param pluginVersionBitmap
72 * @return handshake scenario without switch version bitmap
74 public static Stack<ClientEvent> createHandshakeScenario(short auxId,
75 String pluginVersionBitmap) {
76 Stack<ClientEvent> stack = new Stack<>();
78 stack.add(0, new SendEvent(ByteBufUtils
79 .hexStringToBytes("04 00 00 08 00 00 00 01")));
80 stack.add(0, new WaitForMessageEvent(ByteBufUtils
81 .hexStringToBytes("04 00 00 10 00 00 00 15 "
82 + pluginVersionBitmap)));
83 stack.add(0, new WaitForMessageEvent(ByteBufUtils
84 .hexStringToBytes("04 05 00 08 00 00 00 02")));
85 stack.add(0, new SendEvent(ByteBufUtils
86 .hexStringToBytes("04 06 00 20 00 00 00 02 "
87 + "00 01 02 03 04 05 06 07 " + "00 01 02 03 01 "
88 + Integer.toHexString(auxId)
89 + " 00 00 00 01 02 03 00 01 02 03")));
95 * Attempt to simulate the MLX running 1.0 talking to ODL
98 * @param pluginVersionBitmap
99 * @return handshake scenario without switch version bitmap
101 public static Stack<ClientEvent> createHandshakeScenarioNoVBM_OF10_TwoHello() {
102 Stack<ClientEvent> stack = new Stack<>();
104 stack.add(0, new SendEvent(ByteBufUtils
105 .hexStringToBytes("01 00 00 08 00 00 01 67")));
106 stack.add(0, new WaitForMessageEvent(ByteBufUtils
107 .hexStringToBytes("04 00 00 10 00 00 00 15 00 01 00 08 00 00 00 12")));
108 stack.add(0, new SendEvent(ByteBufUtils
109 .hexStringToBytes("01 01 00 0c 00 00 00 15 00 00 00 00")));
110 stack.add(0, new WaitForMessageEvent(ByteBufUtils
111 .hexStringToBytes("01 00 00 08 00 00 01 68")));
112 stack.add(0, new SendEvent(ByteBufUtils
113 .hexStringToBytes("01 00 00 08 00 00 01 68")));
114 stack.add(0, new WaitForMessageEvent(ByteBufUtils
115 .hexStringToBytes("01 05 00 08 00 00 01 69")));
117 stack.add(0, new SendEvent(
119 .hexStringToBytes("01 06 00 80 00 00 01 69 cc 4e 24 1c 4a 00 00 00"
120 + " 00 00 01 00 01 00 00 00 00 00 00 07 00 00 01 0f"
121 + " 00 61 cc 4e 24 1c 4a 60 65 74 68 33 2f 31 00 00"
122 + " 00 00 00 00 00 00 00 00 00 00 00 11 00 00 00 01"
123 + " 00 00 01 40 00 00 01 40 00 00 01 40 00 00 01 40"
124 + " 00 62 cc 4e 24 1c 4a 61 65 74 68 33 2f 32 00 00"
125 + " 00 00 00 00 00 00 00 00 00 00 00 11 00 00 00 01"
126 + " 00 00 01 40 00 00 01 40 00 00 01 40 00 00 01 40")));
128 stack.add(0, new WaitForMessageEvent(ByteBufUtils
129 .hexStringToBytes("01 10 00 0c 00 00 00 01 00 00 00 00")));
131 stack.add(0, new SendEvent(
133 .hexStringToBytes("01 11 04 2c 00 00 00 01 00 00 00 00 42 72 6f 63"
134 + " 61 64 65 20 43 6f 6d 6d 75 6e 69 63 61 74 69"
135 + " 6f 6e 73 2c 20 49 6e 63 00 00 00 00 00 00 00"
136 + " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"
137 + " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"
138 + " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"
139 + " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"
140 + " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"
141 + " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"
142 + " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"
143 + " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"
144 + " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"
145 + " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"
146 + " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"
147 + " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"
148 + " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"
149 + " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"
150 + " 00 00 00 00 00 00 00 00 00 00 00 00 4d 75 6c"
151 + " 74 69 2d 53 65 72 76 69 63 65 20 49 72 6f 6e"
152 + " 77 61 72 65 00 00 00 00 00 00 00 00 00 00 00"
153 + " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"
154 + " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"
155 + " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"
156 + " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"
157 + " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"
158 + " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"
159 + " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"
160 + " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"
161 + " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"
162 + " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"
163 + " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"
164 + " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"
165 + " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"
166 + " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"
167 + " 00 00 00 00 00 00 00 00 00 00 00 00 00 4e 49"
168 + " 20 35 2e 37 00 00 00 00 00 00 00 00 00 00 00"
169 + " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"
170 + " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"
171 + " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"
172 + " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"
173 + " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"
174 + " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"
175 + " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"
176 + " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"
177 + " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"
178 + " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"
179 + " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"
180 + " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"
181 + " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"
182 + " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"
183 + " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"
184 + " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 4e"
185 + " 6f 6e 65 00 00 00 00 00 00 00 00 00 00 00 00"
186 + " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"
187 + " 00 4e 6f 6e 65 00 00 00 00 00 00 00 00 00 00"
188 + " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"
189 + " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"
190 + " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"
191 + " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"
192 + " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"
193 + " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"
194 + " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"
195 + " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"
196 + " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"
197 + " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"
198 + " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"
199 + " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"
200 + " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"
201 + " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"
202 + " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"
203 + " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"
205 stack.add(0, new WaitForMessageEvent(ByteBufUtils
206 .hexStringToBytes("01 05 00 08 00 00 01 69")));
208 stack.add(0, new SendEvent(
210 .hexStringToBytes("01 06 00 80 00 00 01 69 cc 4e 24 1c 4a 00 00 00"
211 + " 00 00 01 00 01 00 00 00 00 00 00 07 00 00 01 0f"
212 + " 00 61 cc 4e 24 1c 4a 60 65 74 68 33 2f 31 00 00"
213 + " 00 00 00 00 00 00 00 00 00 00 00 11 00 00 00 01"
214 + " 00 00 01 40 00 00 01 40 00 00 01 40 00 00 01 40"
215 + " 00 62 cc 4e 24 1c 4a 61 65 74 68 33 2f 32 00 00"
216 + " 00 00 00 00 00 00 00 00 00 00 00 11 00 00 00 01"
217 + " 00 00 01 40 00 00 01 40 00 00 01 40 00 00 01 40")));
219 stack.add(0, new SleepEvent(5000));
226 * Attempt to simulate the MLX running 1.0 talking to ODL
229 * @param pluginVersionBitmap
230 * @return handshake scenario without switch version bitmap
232 public static Stack<ClientEvent> createHandshakeScenarioNOVBM_OF10_OneHello() {
233 System.out.println("createHandshakeScenarioMininet");
234 Stack<ClientEvent> stack = new Stack<>();
236 stack.add(0, new SendEvent(ByteBufUtils
237 .hexStringToBytes("01 00 00 08 00 00 00 0d")));
238 stack.add(0, new WaitForMessageEvent(ByteBufUtils
239 .hexStringToBytes("04 00 00 10 00 00 00 15")));
240 stack.add(0, new WaitForMessageEvent(ByteBufUtils
241 .hexStringToBytes("01 00 00 08 00 00 00 0e")));
242 stack.add(0, new WaitForMessageEvent(ByteBufUtils
243 .hexStringToBytes("01 05 00 08 00 00 00 0f")));
245 stack.add(0, new SendEvent(
247 .hexStringToBytes("01 01 00 14 00 00 00 0e 00 01 00 01 01 00 00 08 00 00 00 0e")));
249 stack.add(0, new SendEvent(
251 .hexStringToBytes(" 01 06 00 b0 00 00 00 0f 00 00 00 00 00 00 00 01 00 00 01 00 fe 00"
252 + " 00 00 00 00 00 c7 00 00 0f ff 00 01 fa 01 ff 57 86 aa 73 31 2d"
253 + " 65 74 68 31 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01"
254 + " 00 00 00 c0 00 00 00 00 00 00 00 00 00 00 00 00 00 02 c2 51 d8"
255 + " 24 38 97 73 31 2d 65 74 68 32 00 00 00 00 00 00 00 00 00 00 00"
256 + " 00 00 00 00 00 00 00 00 00 c0 00 00 00 00 00 00 00 00 00 00 00"
257 + " 00 ff fe ea bd f8 db 41 40 73 31 00 00 00 00 00 00 00 00 00 00"
258 + " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"
259 + " 00 00 00 00 00 00 00")));