2 * Copyright (c) 2013, 2015 Ericsson, 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.test;
10 import com.google.common.util.concurrent.FutureCallback;
11 import com.google.common.util.concurrent.MoreExecutors;
12 import java.util.concurrent.ExecutorService;
13 import java.util.concurrent.Executors;
14 import java.util.concurrent.TimeUnit;
15 import org.eclipse.osgi.framework.console.CommandInterpreter;
16 import org.eclipse.osgi.framework.console.CommandProvider;
17 import org.opendaylight.mdsal.binding.api.DataBroker;
18 import org.opendaylight.mdsal.binding.api.NotificationService;
19 import org.opendaylight.mdsal.binding.api.ReadWriteTransaction;
20 import org.opendaylight.mdsal.common.api.CommitInfo;
21 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
22 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Dscp;
23 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix;
24 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6FlowLabel;
25 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Prefix;
26 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber;
27 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Uri;
28 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress;
29 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.VlanCfi;
30 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.ControllerActionCaseBuilder;
31 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.CopyTtlInCaseBuilder;
32 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.CopyTtlOutCaseBuilder;
33 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DecMplsTtlCaseBuilder;
34 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DecNwTtlCaseBuilder;
35 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DropActionCaseBuilder;
36 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.FloodActionCaseBuilder;
37 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.FloodAllActionCaseBuilder;
38 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.GroupActionCaseBuilder;
39 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.HwPathActionCaseBuilder;
40 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.LoopbackActionCaseBuilder;
41 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.OutputActionCaseBuilder;
42 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopMplsActionCaseBuilder;
43 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopPbbActionCaseBuilder;
44 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopVlanActionCaseBuilder;
45 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushMplsActionCaseBuilder;
46 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushPbbActionCaseBuilder;
47 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushVlanActionCaseBuilder;
48 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetDlDstActionCaseBuilder;
49 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetDlSrcActionCaseBuilder;
50 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetDlTypeActionCaseBuilder;
51 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetFieldCaseBuilder;
52 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetMplsTtlActionCaseBuilder;
53 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNextHopActionCaseBuilder;
54 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwDstActionCaseBuilder;
55 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwSrcActionCaseBuilder;
56 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwTosActionCaseBuilder;
57 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwTtlActionCaseBuilder;
58 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetQueueActionCaseBuilder;
59 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetTpDstActionCaseBuilder;
60 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetTpSrcActionCaseBuilder;
61 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetVlanCfiActionCaseBuilder;
62 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetVlanIdActionCaseBuilder;
63 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetVlanPcpActionCaseBuilder;
64 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.StripVlanActionCaseBuilder;
65 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SwPathActionCaseBuilder;
66 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.controller.action._case.ControllerActionBuilder;
67 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.copy.ttl.in._case.CopyTtlInBuilder;
68 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.copy.ttl.out._case.CopyTtlOutBuilder;
69 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.dec.mpls.ttl._case.DecMplsTtlBuilder;
70 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.dec.nw.ttl._case.DecNwTtlBuilder;
71 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.drop.action._case.DropActionBuilder;
72 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.flood.action._case.FloodActionBuilder;
73 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.flood.all.action._case.FloodAllActionBuilder;
74 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.group.action._case.GroupActionBuilder;
75 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.hw.path.action._case.HwPathActionBuilder;
76 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.loopback.action._case.LoopbackActionBuilder;
77 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.output.action._case.OutputActionBuilder;
78 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.pop.mpls.action._case.PopMplsActionBuilder;
79 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.pop.pbb.action._case.PopPbbActionBuilder;
80 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.pop.vlan.action._case.PopVlanActionBuilder;
81 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.push.mpls.action._case.PushMplsActionBuilder;
82 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.push.pbb.action._case.PushPbbActionBuilder;
83 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.push.vlan.action._case.PushVlanActionBuilder;
84 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.dl.dst.action._case.SetDlDstActionBuilder;
85 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.dl.src.action._case.SetDlSrcActionBuilder;
86 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.dl.type.action._case.SetDlTypeActionBuilder;
87 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.field._case.SetFieldBuilder;
88 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.mpls.ttl.action._case.SetMplsTtlActionBuilder;
89 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.next.hop.action._case.SetNextHopActionBuilder;
90 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.dst.action._case.SetNwDstActionBuilder;
91 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.src.action._case.SetNwSrcActionBuilder;
92 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.tos.action._case.SetNwTosActionBuilder;
93 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.ttl.action._case.SetNwTtlActionBuilder;
94 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.queue.action._case.SetQueueActionBuilder;
95 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.tp.dst.action._case.SetTpDstActionBuilder;
96 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.tp.src.action._case.SetTpSrcActionBuilder;
97 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.vlan.cfi.action._case.SetVlanCfiActionBuilder;
98 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.vlan.id.action._case.SetVlanIdActionBuilder;
99 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.vlan.pcp.action._case.SetVlanPcpActionBuilder;
100 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.strip.vlan.action._case.StripVlanActionBuilder;
101 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.sw.path.action._case.SwPathActionBuilder;
102 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder;
103 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionKey;
104 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.address.Ipv4Builder;
105 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
106 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId;
107 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table;
108 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey;
109 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow;
110 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder;
111 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey;
112 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowCookie;
113 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowModFlags;
114 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.OutputPortValues;
115 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.InstructionsBuilder;
116 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
117 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ApplyActionsCaseBuilder;
118 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.GoToTableCaseBuilder;
119 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.MeterCaseBuilder;
120 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.WriteMetadataCaseBuilder;
121 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.apply.actions._case.ApplyActionsBuilder;
122 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.go.to.table._case.GoToTableBuilder;
123 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.meter._case.MeterBuilder;
124 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.write.metadata._case.WriteMetadataBuilder;
125 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionBuilder;
126 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionKey;
127 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId;
128 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
129 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
130 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
131 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeBuilder;
132 import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.EtherType;
133 import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanId;
134 import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanPcp;
135 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterId;
136 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.arp.match.fields.ArpSourceHardwareAddressBuilder;
137 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.arp.match.fields.ArpTargetHardwareAddressBuilder;
138 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetDestinationBuilder;
139 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetSourceBuilder;
140 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetTypeBuilder;
141 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ipv6.match.fields.Ipv6ExtHeaderBuilder;
142 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ipv6.match.fields.Ipv6LabelBuilder;
143 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatchBuilder;
144 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Icmpv4MatchBuilder;
145 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Icmpv6MatchBuilder;
146 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.IpMatchBuilder;
147 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.MetadataBuilder;
148 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.ProtocolMatchFieldsBuilder;
149 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.TcpFlagsMatchBuilder;
150 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.TunnelBuilder;
151 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.VlanMatchBuilder;
152 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.ArpMatchBuilder;
153 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4Match;
154 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4MatchBuilder;
155 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6MatchBuilder;
156 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.TunnelIpv4MatchBuilder;
157 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.SctpMatchBuilder;
158 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.TcpMatchBuilder;
159 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.UdpMatchBuilder;
160 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.protocol.match.fields.PbbBuilder;
161 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.vlan.match.fields.VlanIdBuilder;
162 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
163 import org.opendaylight.yangtools.yang.binding.util.BindingMap;
164 import org.opendaylight.yangtools.yang.common.Uint16;
165 import org.opendaylight.yangtools.yang.common.Uint32;
166 import org.opendaylight.yangtools.yang.common.Uint64;
167 import org.opendaylight.yangtools.yang.common.Uint8;
168 import org.osgi.framework.BundleContext;
169 import org.slf4j.Logger;
170 import org.slf4j.LoggerFactory;
172 public class OpenflowpluginTestCommandProvider implements CommandProvider {
174 private static final Logger LOG = LoggerFactory.getLogger(OpenflowpluginTestCommandProvider.class);
176 private final DataBroker dataBroker;
177 private final BundleContext ctx;
178 private static final String ORIGINAL_FLOW_NAME = "Foo";
179 private static final String UPDATED_FLOW_NAME = "Bar";
180 private static final String IPV4_PREFIX = "10.0.0.1/24";
181 private static final String DEST_MAC_ADDRESS = "ff:ff:ff:ff:ff:ff";
182 private static final String SRC_MAC_ADDRESS = "00:00:00:00:23:ae";
184 private final NotificationService notificationService;
186 public OpenflowpluginTestCommandProvider(final DataBroker dataBroker, final NotificationService notificationService,
187 final BundleContext ctx) {
188 this.dataBroker = dataBroker;
189 this.notificationService = notificationService;
195 notificationService.registerCompositeListener(FlowEventListenerLoggingImpl.newListener());
197 ctx.registerService(CommandProvider.class.getName(), this, null);
198 createTestFlow(createTestNode(null), null, null);
201 private static NodeBuilder createTestNode(final String nodeId) {
202 return new NodeBuilder().setId(new NodeId(nodeId != null ? nodeId : OpenflowpluginTestActivator.NODE_ID));
205 private static InstanceIdentifier<Node> nodeBuilderToInstanceId(final NodeBuilder node) {
206 return InstanceIdentifier.create(Nodes.class).child(Node.class, node.key());
209 private static FlowBuilder createTestFlow(final NodeBuilder nodeBuilder, final String flowTypeArg,
210 final String tableId) {
211 final long TEST_ID = 123;
215 String flowType = flowTypeArg;
216 if (flowType == null) {
220 final FlowBuilder flow = new FlowBuilder()
221 .setPriority(Uint16.TWO);
226 flow.setMatch(createMatch1().build());
227 flow.setInstructions(createDecNwTtlInstructions().build());
231 flow.setMatch(createMatch2().build());
232 flow.setInstructions(createDropInstructions().build());
236 flow.setMatch(createMatch3().build());
237 flow.setInstructions(createDropInstructions().build());
241 flow.setMatch(createEthernetMatch().build());
242 flow.setInstructions(createDropInstructions().build());
246 flow.setMatch(createMatch1().build());
247 flow.setInstructions(createAppyActionInstruction().build());
251 flow.setMatch(createMatch1().build());
252 flow.setInstructions(createGotoTableInstructions().build());
256 flow.setMatch(createMatch1().build());
257 flow.setInstructions(createMeterInstructions().build());
261 flow.setMatch(createMatch1().build());
262 flow.setInstructions(createAppyActionInstruction1().build());
266 flow.setMatch(createMatch1().build());
267 flow.setInstructions(createAppyActionInstruction2().build());
271 flow.setMatch(createMatch1().build());
272 flow.setInstructions(createAppyActionInstruction3().build());
276 flow.setMatch(createMatch1().build());
277 flow.setInstructions(createAppyActionInstruction4().build());
281 flow.setMatch(createMatch1().build());
282 flow.setInstructions(createAppyActionInstruction5().build());
286 flow.setMatch(createMatch1().build());
287 flow.setInstructions(createAppyActionInstruction6().build());
291 flow.setMatch(createMatch1().build());
292 flow.setInstructions(createAppyActionInstruction7().build());
296 flow.setMatch(createMatch1().build());
297 flow.setInstructions(createAppyActionInstruction8().build());
301 flow.setMatch(createMatch1().build());
302 flow.setInstructions(createAppyActionInstruction9().build());
306 flow.setMatch(createMatch1().build());
307 flow.setInstructions(createAppyActionInstruction10().build());
311 flow.setMatch(createMatch1().build());
312 flow.setInstructions(createAppyActionInstruction11().build());
316 flow.setMatch(createMatch1().build());
317 flow.setInstructions(createAppyActionInstruction12().build());
321 flow.setMatch(createMatch1().build());
322 flow.setInstructions(createAppyActionInstruction13().build());
326 flow.setMatch(createMatch1().build());
327 flow.setInstructions(createAppyActionInstruction14().build());
331 flow.setMatch(createMatch1().build());
332 flow.setInstructions(createAppyActionInstruction15().build());
336 // f23 can be used as test-case for generating error notification
337 // if the particular group is not configured - tested
338 flow.setMatch(createMatch1().build());
339 flow.setInstructions(createAppyActionInstruction16().build());
343 flow.setMatch(createMatch1().build());
344 flow.setInstructions(createAppyActionInstruction17().build());
348 flow.setMatch(createMatch1().build());
349 flow.setInstructions(createAppyActionInstruction18().build());
353 flow.setMatch(createMatch1().build());
354 flow.setInstructions(createAppyActionInstruction19().build());
358 flow.setMatch(createMatch1().build());
359 flow.setInstructions(createMetadataInstructions().build());
363 flow.setMatch(createMatch1().build());
364 flow.setInstructions(createAppyActionInstruction20().build());
368 flow.setMatch(createMatch1().build());
369 flow.setInstructions(createAppyActionInstruction21().build());
373 flow.setMatch(createMatch1().build());
374 flow.setInstructions(createAppyActionInstruction22().build());
378 flow.setMatch(createMatch1().build());
379 flow.setInstructions(createAppyActionInstruction23(nodeBuilder.getId()).build());
383 flow.setMatch(createMatch1().build());
384 flow.setInstructions(createAppyActionInstruction24().build());
388 flow.setMatch(createMatch1().build());
389 flow.setInstructions(createAppyActionInstruction25().build());
393 flow.setMatch(createMatch1().build());
394 flow.setInstructions(createAppyActionInstruction26().build());
398 flow.setMatch(createMatch1().build());
399 flow.setInstructions(createAppyActionInstruction27().build());
403 flow.setMatch(createMatch1().build());
404 flow.setInstructions(createAppyActionInstruction28().build());
408 flow.setMatch(createMatch1().build());
409 flow.setInstructions(createAppyActionInstruction29().build());
413 flow.setMatch(createMatch1().build());
414 flow.setInstructions(createAppyActionInstruction30().build());
418 flow.setMatch(createMatch1().build());
419 flow.setInstructions(createAppyActionInstruction31().build());
423 flow.setMatch(createMatch1().build());
424 flow.setInstructions(createAppyActionInstruction32().build());
428 flow.setMatch(createMatch1().build());
429 flow.setInstructions(createAppyActionInstruction33().build());
433 flow.setMatch(createMatch1().build());
434 flow.setInstructions(createAppyActionInstruction34().build());
438 flow.setMatch(createICMPv6Match().build());
439 flow.setInstructions(createDecNwTtlInstructions().build());
443 flow.setMatch(createInphyportMatch(nodeBuilder.getId()).build());
444 flow.setInstructions(createDropInstructions().build());
448 flow.setMatch(createMetadataMatch().build());
449 flow.setInstructions(createDropInstructions().build());
453 flow.setMatch(createL3IPv6Match().build());
454 flow.setInstructions(createDecNwTtlInstructions().build());
458 flow.setMatch(createL4SCTPMatch().build());
459 flow.setInstructions(createAppyActionInstruction().build());
463 flow.setMatch(createTunnelIDMatch().build());
464 flow.setInstructions(createGotoTableInstructions().build());
468 flow.setMatch(createVlanMatch().build());
469 flow.setInstructions(createMeterInstructions().build());
473 flow.setMatch(createPbbMatch().build());
474 flow.setInstructions(createMeterInstructions().build());
478 flow.setMatch(createVlanMatch().build());
479 flow.setInstructions(createDropInstructions().build());
483 flow.setMatch(createL4TCPMatch().build());
484 flow.setInstructions(createDropInstructions().build());
489 flow.setMatch(createL4UDPMatch().build());
490 flow.setInstructions(createDropInstructions().build());
494 flow.setMatch(new MatchBuilder().build());
495 flow.setInstructions(createSentToControllerInstructions().build());
496 flow.setPriority(Uint16.ZERO);
500 flow.setMatch(createToSMatch().build());
501 flow.setInstructions(createDropInstructions().build());
505 flow.setMatch(createToSMatch().build());
506 flow.setInstructions(createOutputInstructions("INPORT", Uint16.TEN).build());
510 flow.setMatch(createToSMatch().build());
511 flow.setInstructions(createOutputInstructions("FLOOD", Uint16.valueOf(20)).build());
515 flow.setMatch(createToSMatch().build());
516 flow.setInstructions(createOutputInstructions("ALL", Uint16.valueOf(30)).build());
520 flow.setMatch(createToSMatch().build());
521 flow.setInstructions(createOutputInstructions("NORMAL", Uint16.valueOf(40)).build());
525 flow.setMatch(createToSMatch().build());
526 flow.setInstructions(createOutputInstructions("LOCAL", Uint16.valueOf(50)).build());
530 flow.setMatch(createToSMatch().build());
531 flow.setInstructions(createOutputInstructions("TABLE", Uint16.valueOf(60)).build());
535 flow.setMatch(createToSMatch().build());
536 flow.setInstructions(createOutputInstructions("NONE", Uint16.valueOf(70)).build());
540 flow.setMatch(createToSMatch().build());
541 flow.setInstructions(createStripVlanInstructions().build());
542 flow.setBarrier(Boolean.TRUE);
546 flow.setMatch(createMatch1().build());
547 flow.setInstructions(createAppyActionInstruction35().build());
551 flow.setMatch(createMatch1().build());
552 flow.setInstructions(createAppyActionInstruction36().build());
556 flow.setMatch(createMatch1().build());
557 flow.setInstructions(createAppyActionInstruction37().build());
561 flow.setMatch(createMatch1().build());
562 flow.setInstructions(createAppyActionInstruction38().build());
566 flow.setMatch(createL4TCPMatch().build());
567 flow.setInstructions(createAppyActionInstruction39().build());
571 flow.setMatch(createL4UDPMatch().build());
572 flow.setInstructions(createAppyActionInstruction40().build());
576 flow.setMatch(createL4SCTPMatch().build());
577 flow.setInstructions(createAppyActionInstruction41().build());
581 flow.setMatch(createICMPv4Match().build());
582 flow.setInstructions(createAppyActionInstruction42().build());
586 flow.setMatch(createArpMatch().build());
587 flow.setInstructions(createAppyActionInstruction43().build());
591 flow.setMatch(createL3IPv6Match().build());
592 flow.setInstructions(createAppyActionInstruction44().build());
596 flow.setMatch(createICMPv6Match().build());
597 flow.setInstructions(createAppyActionInstruction45().build());
601 flow.setMatch(createMplsMatch().build());
602 flow.setInstructions(createAppyActionInstruction46().build());
606 flow.setMatch(createPbbMatch().build());
607 flow.setInstructions(createAppyActionInstruction47().build());
611 flow.setMatch(createTunnelIDMatch().build());
612 flow.setInstructions(createAppyActionInstruction48().build());
616 flow.setMatch(createMatch33().build());
617 flow.setInstructions(createDropInstructions().build());
621 flow.setMatch(createICMPv6Match1().build());
622 flow.setInstructions(createDecNwTtlInstructions().build());
626 flow.setMatch(createVlanMatch().build());
627 flow.setInstructions(createAppyActionInstruction88().build());
631 flow.setMatch(createLLDPMatch().build());
632 flow.setInstructions(createSentToControllerInstructions().build());
636 flow.setMatch(createToSMatch().build());
637 flow.setInstructions(createOutputInstructions().build());
640 // Test TCP_Flag Match
642 flow.setMatch(createTcpFlagMatch().build());
643 flow.setInstructions(createDropInstructions().build());
647 // match vlan=10,dl_vlan_pcp=3
648 flow.setMatch(createVlanMatch().build());
650 flow.setInstructions(createAppyActionInstruction88().build());
653 // Test Tunnel IPv4 Src (e.g. set_field:172.16.100.200->tun_src)
655 flow.setMatch(createMatch3().build());
656 flow.setInstructions(createTunnelIpv4SrcInstructions().build());
659 // Test Tunnel IPv4 Dst (e.g. set_field:172.16.100.100->tun_dst)
661 flow.setMatch(createMatch1().build());
662 flow.setInstructions(createTunnelIpv4DstInstructions().build());
665 LOG.warn("flow type not understood: {}", flowType);
668 if (flow.getBarrier() == null) {
669 flow.setBarrier(Boolean.FALSE);
673 .setCookie(new FlowCookie(Uint64.TEN))
674 .setCookieMask(new FlowCookie(Uint64.TEN))
675 .setHardTimeout(Uint16.ZERO)
676 .setIdleTimeout(Uint16.ZERO)
679 .setContainerName(null)
680 .setFlags(new FlowModFlags(false, false, false, false, true))
681 .setId(new FlowId("12"))
682 .setTableId(getTableId(tableId))
683 .withKey(new FlowKey(new FlowId(Long.toString(id))))
684 .setFlowName(ORIGINAL_FLOW_NAME + "X" + flowType);
687 private static FlowBuilder createTestFlowPerfTest(final String flowTypeArg, final String tableId, final int id) {
688 String flowType = flowTypeArg;
691 if (flowType == null) {
695 final FlowBuilder flow = new FlowBuilder()
696 .setPriority(Uint16.valueOf(flowId));
701 flow.setMatch(createMatch1().build());
702 flow.setInstructions(createDecNwTtlInstructions().build());
705 LOG.warn("flow type not understood: {}", flowType);
708 if (flow.getBarrier() == null) {
709 flow.setBarrier(Boolean.FALSE);
713 .setCookie(new FlowCookie(Uint64.TEN))
714 .setCookieMask(new FlowCookie(Uint64.TEN))
715 .setHardTimeout(Uint16.ZERO)
716 .setIdleTimeout(Uint16.ZERO)
719 .setContainerName(null)
720 .setFlags(new FlowModFlags(false, false, false, false, true))
721 .setId(new FlowId("12"))
722 .setTableId(getTableId(tableId))
723 .withKey(new FlowKey(new FlowId(Long.toString(flowId))))
724 .setFlowName(ORIGINAL_FLOW_NAME + "X" + flowType);
727 private static FlowBuilder createtablemiss() {
728 return new FlowBuilder()
729 .setMatch(new MatchBuilder().build())
730 .setInstructions(createSentToControllerInstructions().build())
731 .setPriority(Uint16.ZERO)
732 .setTableId(Uint8.ZERO)
733 .withKey(new FlowKey(new FlowId("456")));
736 private static Uint8 getTableId(final String tableId) {
737 Uint8 table = Uint8.TWO;
739 if (tableId == null) {
744 table = Uint8.valueOf(tableId);
745 } catch (NumberFormatException ex) {
746 LOG.info("Parsing String tableId {} failed. Continuing with default tableId {}.",
752 private static InstructionsBuilder createDecNwTtlInstructions() {
753 return new InstructionsBuilder()
754 .setInstruction(BindingMap.of(new InstructionBuilder()
756 .setInstruction(new ApplyActionsCaseBuilder()
757 .setApplyActions(new ApplyActionsBuilder()
758 .setAction(BindingMap.of(new ActionBuilder()
760 .setAction(new DecNwTtlCaseBuilder().setDecNwTtl(new DecNwTtlBuilder().build()).build())
767 private static InstructionsBuilder createMeterInstructions() {
768 return new InstructionsBuilder()
769 .setInstruction(BindingMap.of(new InstructionBuilder()
771 .setInstruction(new MeterCaseBuilder()
772 .setMeter(new MeterBuilder().setMeterId(new MeterId(Uint32.ONE)).build())
777 private static InstructionsBuilder createMetadataInstructions() {
778 return new InstructionsBuilder()
779 .setInstruction(BindingMap.of(new InstructionBuilder()
780 .withKey(new InstructionKey(0))
781 .setInstruction(new WriteMetadataCaseBuilder()
782 .setWriteMetadata(new WriteMetadataBuilder()
783 .setMetadata(Uint64.TEN).setMetadataMask(Uint64.TEN)
789 private static InstructionsBuilder createGotoTableInstructions() {
790 return new InstructionsBuilder()
791 .setInstruction(BindingMap.of(new InstructionBuilder()
793 .setInstruction(new GoToTableCaseBuilder()
794 .setGoToTable(new GoToTableBuilder().setTableId(Uint8.valueOf(5)).build())
799 private static InstructionsBuilder createDropInstructions() {
800 // Wrap our Apply Action in an Instruction
801 return new InstructionsBuilder()
802 .setInstruction(BindingMap.of(new InstructionBuilder()
804 .setInstruction(new ApplyActionsCaseBuilder()
805 .setApplyActions(new ApplyActionsBuilder()
806 .setAction(BindingMap.of(new ActionBuilder()
807 .withKey(new ActionKey(0))
808 .setAction(new DropActionCaseBuilder()
809 .setDropAction(new DropActionBuilder().build())
817 private static InstructionsBuilder createAppyActionInstruction() {
818 return new InstructionsBuilder()
819 .setInstruction(BindingMap.of(new InstructionBuilder()
821 .setInstruction(new ApplyActionsCaseBuilder()
822 .setApplyActions(new ApplyActionsBuilder()
823 .setAction(BindingMap.of(new ActionBuilder()
825 .setAction(new ControllerActionCaseBuilder()
826 .setControllerAction(new ControllerActionBuilder()
827 .setMaxLength(Uint16.valueOf(5))
836 private static InstructionsBuilder createAppyActionInstruction1() {
837 return new InstructionsBuilder()
838 .setInstruction(BindingMap.of(new InstructionBuilder()
840 .setInstruction(new ApplyActionsCaseBuilder()
841 .setApplyActions(new ApplyActionsBuilder()
842 .setAction(BindingMap.of(new ActionBuilder()
844 .setAction(new OutputActionCaseBuilder()
845 .setOutputAction(new OutputActionBuilder()
846 .setMaxLength(Uint16.valueOf(56))
847 .setOutputNodeConnector(new Uri("PCEP"))
856 private static InstructionsBuilder createOutputInstructions() {
857 // test case for Output Port works if the particular port exists
858 // this particular test-case is for Port : 1
859 // tested as (addMDFlow openflow:<dpid> f82)
860 return new InstructionsBuilder()
861 .setInstruction(BindingMap.of(new InstructionBuilder()
863 .setInstruction(new ApplyActionsCaseBuilder()
864 .setApplyActions(new ApplyActionsBuilder()
865 .setAction(BindingMap.of(new ActionBuilder()
867 .setAction(new OutputActionCaseBuilder()
868 .setOutputAction(new OutputActionBuilder().setOutputNodeConnector(new Uri("1")).build())
876 private static InstructionsBuilder createOutputInstructions(final String outputType, final Uint16 outputValue) {
877 return new InstructionsBuilder()
878 .setInstruction(BindingMap.of(new InstructionBuilder()
880 .setInstruction(new ApplyActionsCaseBuilder()
881 .setApplyActions(new ApplyActionsBuilder()
882 .setAction(BindingMap.of(new ActionBuilder()
884 .setAction(new OutputActionCaseBuilder()
885 .setOutputAction(new OutputActionBuilder()
886 .setMaxLength(outputValue)
887 .setOutputNodeConnector(new Uri(outputType))
896 private static InstructionsBuilder createSentToControllerInstructions() {
897 return new InstructionsBuilder()
898 .setInstruction(BindingMap.of(new InstructionBuilder()
900 .setInstruction(new ApplyActionsCaseBuilder()
901 .setApplyActions(new ApplyActionsBuilder()
902 .setAction(BindingMap.of(new ActionBuilder()
904 .setAction(new OutputActionCaseBuilder()
905 .setOutputAction(new OutputActionBuilder()
906 .setMaxLength(Uint16.MAX_VALUE)
907 .setOutputNodeConnector(new Uri(OutputPortValues.CONTROLLER.toString()))
916 private static InstructionsBuilder createStripVlanInstructions() {
917 return new InstructionsBuilder()
918 .setInstruction(BindingMap.of(new InstructionBuilder()
920 .setInstruction(new ApplyActionsCaseBuilder()
921 .setApplyActions(new ApplyActionsBuilder()
922 .setAction(BindingMap.of(new ActionBuilder()
924 .setAction(new StripVlanActionCaseBuilder()
925 .setStripVlanAction(new StripVlanActionBuilder().build())
933 private static InstructionsBuilder createAppyActionInstruction2() {
934 return new InstructionsBuilder()
935 .setInstruction(BindingMap.of(new InstructionBuilder()
937 .setInstruction(new ApplyActionsCaseBuilder()
938 .setApplyActions(new ApplyActionsBuilder()
939 .setAction(BindingMap.of(new ActionBuilder()
941 .setAction(new PushMplsActionCaseBuilder()
942 .setPushMplsAction(new PushMplsActionBuilder()
943 .setEthernetType(Uint16.valueOf(0x8847))
952 private static InstructionsBuilder createAppyActionInstruction3() {
953 return new InstructionsBuilder()
954 .setInstruction(BindingMap.of(new InstructionBuilder()
956 .setInstruction(new ApplyActionsCaseBuilder()
957 .setApplyActions(new ApplyActionsBuilder()
958 .setAction(BindingMap.of(new ActionBuilder()
960 .setAction(new PushPbbActionCaseBuilder()
961 .setPushPbbAction(new PushPbbActionBuilder()
962 .setEthernetType(Uint16.valueOf(0x88E7))
971 private static InstructionsBuilder createAppyActionInstruction4() {
972 return new InstructionsBuilder()
973 .setInstruction(BindingMap.of(new InstructionBuilder()
975 .setInstruction(new ApplyActionsCaseBuilder()
976 .setApplyActions(new ApplyActionsBuilder()
977 .setAction(BindingMap.of(new ActionBuilder()
979 .setAction(new PushVlanActionCaseBuilder()
980 .setPushVlanAction(new PushVlanActionBuilder()
981 .setEthernetType(Uint16.valueOf(0x8100))
990 private static InstructionsBuilder createAppyActionInstruction5() {
991 return new InstructionsBuilder()
992 .setInstruction(BindingMap.of(new InstructionBuilder()
994 .setInstruction(new ApplyActionsCaseBuilder()
995 .setApplyActions(new ApplyActionsBuilder()
996 .setAction(BindingMap.of(new ActionBuilder()
998 .setAction(new SetDlDstActionCaseBuilder()
999 .setSetDlDstAction(new SetDlDstActionBuilder()
1000 .setAddress(new MacAddress("00:05:b9:7c:81:5f"))
1009 private static InstructionsBuilder createAppyActionInstruction6() {
1010 return new InstructionsBuilder()
1011 .setInstruction(BindingMap.of(new InstructionBuilder()
1013 .setInstruction(new ApplyActionsCaseBuilder()
1014 .setApplyActions(new ApplyActionsBuilder().setAction(BindingMap.of(new ActionBuilder()
1016 .setAction(new SetDlSrcActionCaseBuilder()
1017 .setSetDlSrcAction(new SetDlSrcActionBuilder()
1018 .setAddress(new MacAddress("00:05:b9:7c:81:5f"))
1026 private static InstructionsBuilder createAppyActionInstruction7() {
1027 return new InstructionsBuilder()
1028 .setInstruction(BindingMap.of(new InstructionBuilder()
1030 .setInstruction(new ApplyActionsCaseBuilder()
1031 .setApplyActions(new ApplyActionsBuilder()
1032 .setAction(BindingMap.of(new ActionBuilder()
1034 .setAction(new SetVlanIdActionCaseBuilder()
1035 .setSetVlanIdAction(new SetVlanIdActionBuilder()
1036 .setVlanId(new VlanId(Uint16.valueOf(4000))).build())
1044 private static InstructionsBuilder createAppyActionInstruction8() {
1045 return new InstructionsBuilder()
1046 .setInstruction(BindingMap.of(new InstructionBuilder()
1048 .setInstruction(new ApplyActionsCaseBuilder()
1049 .setApplyActions(new ApplyActionsBuilder()
1050 .setAction(BindingMap.of(new ActionBuilder()
1052 .setAction(new SetVlanPcpActionCaseBuilder()
1053 .setSetVlanPcpAction(new SetVlanPcpActionBuilder()
1054 .setVlanPcp(new VlanPcp(Uint8.TWO))
1063 private static InstructionsBuilder createAppyActionInstruction88() {
1064 return new InstructionsBuilder()
1065 .setInstruction(BindingMap.of(new InstructionBuilder()
1067 .setInstruction(new ApplyActionsCaseBuilder()
1068 .setApplyActions(new ApplyActionsBuilder()
1069 .setAction(BindingMap.of(new ActionBuilder()
1071 .setAction(new SetVlanPcpActionCaseBuilder()
1072 .setSetVlanPcpAction(new SetVlanPcpActionBuilder()
1073 // the code point is a 3-bit(0-7) field representing the frame priority level
1074 .setVlanPcp(new VlanPcp(Uint8.valueOf(4)))
1083 private static InstructionsBuilder createAppyActionInstruction9() {
1084 return new InstructionsBuilder()
1085 .setInstruction(BindingMap.of(new InstructionBuilder()
1087 .setInstruction(new ApplyActionsCaseBuilder()
1088 .setApplyActions(new ApplyActionsBuilder()
1089 .setAction(BindingMap.of(new ActionBuilder()
1091 .setAction(new CopyTtlInCaseBuilder().setCopyTtlIn(new CopyTtlInBuilder().build()).build())
1098 private static InstructionsBuilder createAppyActionInstruction10() {
1099 return new InstructionsBuilder()
1100 .setInstruction(BindingMap.of(new InstructionBuilder()
1102 .setInstruction(new ApplyActionsCaseBuilder()
1103 .setApplyActions(new ApplyActionsBuilder()
1104 .setAction(BindingMap.of(new ActionBuilder()
1106 .setAction(new CopyTtlOutCaseBuilder()
1107 .setCopyTtlOut(new CopyTtlOutBuilder().build())
1115 private static InstructionsBuilder createAppyActionInstruction11() {
1116 return new InstructionsBuilder()
1117 .setInstruction(BindingMap.of(new InstructionBuilder()
1119 .setInstruction(new ApplyActionsCaseBuilder()
1120 .setApplyActions(new ApplyActionsBuilder()
1121 .setAction(BindingMap.of(new ActionBuilder()
1123 .setAction(new DecMplsTtlCaseBuilder()
1124 .setDecMplsTtl(new DecMplsTtlBuilder().build())
1132 private static InstructionsBuilder createAppyActionInstruction12() {
1133 return new InstructionsBuilder()
1134 .setInstruction(BindingMap.of(new InstructionBuilder()
1136 .setInstruction(new ApplyActionsCaseBuilder()
1137 .setApplyActions(new ApplyActionsBuilder()
1138 .setAction(BindingMap.of(new ActionBuilder()
1140 .setAction(new DecNwTtlCaseBuilder().setDecNwTtl(new DecNwTtlBuilder().build()).build())
1147 private static InstructionsBuilder createAppyActionInstruction13() {
1148 return new InstructionsBuilder()
1149 .setInstruction(BindingMap.of(new InstructionBuilder()
1151 .setInstruction(new ApplyActionsCaseBuilder()
1152 .setApplyActions(new ApplyActionsBuilder()
1153 .setAction(BindingMap.of(new ActionBuilder()
1155 .setAction(new DropActionCaseBuilder()
1156 .setDropAction(new DropActionBuilder().build())
1164 private static InstructionsBuilder createAppyActionInstruction14() {
1165 return new InstructionsBuilder()
1166 .setInstruction(BindingMap.of(new InstructionBuilder()
1168 .setInstruction(new ApplyActionsCaseBuilder()
1169 .setApplyActions(new ApplyActionsBuilder()
1170 .setAction(BindingMap.of(new ActionBuilder()
1172 .setAction(new FloodActionCaseBuilder()
1173 .setFloodAction(new FloodActionBuilder().build())
1181 private static InstructionsBuilder createAppyActionInstruction15() {
1182 return new InstructionsBuilder()
1183 .setInstruction(BindingMap.of(new InstructionBuilder()
1185 .setInstruction(new ApplyActionsCaseBuilder()
1186 .setApplyActions(new ApplyActionsBuilder()
1187 .setAction(BindingMap.of(new ActionBuilder()
1189 .setAction(new FloodAllActionCaseBuilder()
1190 .setFloodAllAction(new FloodAllActionBuilder().build())
1198 private static InstructionsBuilder createAppyActionInstruction16() {
1199 return new InstructionsBuilder()
1200 .setInstruction(BindingMap.of(new InstructionBuilder()
1202 .setInstruction(new ApplyActionsCaseBuilder()
1203 .setApplyActions(new ApplyActionsBuilder()
1204 .setAction(BindingMap.of(new ActionBuilder()
1206 .setAction(new GroupActionCaseBuilder()
1207 .setGroupAction(new GroupActionBuilder().setGroupId(Uint32.ONE).setGroup("0").build())
1215 private static InstructionsBuilder createAppyActionInstruction17() {
1216 return new InstructionsBuilder()
1217 .setInstruction(BindingMap.of(new InstructionBuilder()
1219 .setInstruction(new ApplyActionsCaseBuilder()
1220 .setApplyActions(new ApplyActionsBuilder()
1221 .setAction(BindingMap.of(new ActionBuilder()
1223 .setAction(new HwPathActionCaseBuilder()
1224 .setHwPathAction(new HwPathActionBuilder().build())
1232 private static InstructionsBuilder createAppyActionInstruction18() {
1233 return new InstructionsBuilder()
1234 .setInstruction(BindingMap.of(new InstructionBuilder()
1236 .setInstruction(new ApplyActionsCaseBuilder()
1237 .setApplyActions(new ApplyActionsBuilder()
1238 .setAction(BindingMap.of(new ActionBuilder()
1240 .setAction(new LoopbackActionCaseBuilder()
1241 .setLoopbackAction(new LoopbackActionBuilder().build())
1249 private static InstructionsBuilder createAppyActionInstruction19() {
1250 return new InstructionsBuilder()
1251 .setInstruction(BindingMap.of(new InstructionBuilder()
1253 .setInstruction(new ApplyActionsCaseBuilder()
1254 .setApplyActions(new ApplyActionsBuilder()
1255 .setAction(BindingMap.of(new ActionBuilder()
1257 .setAction(new PopMplsActionCaseBuilder()
1258 .setPopMplsAction(new PopMplsActionBuilder()
1259 .setEthernetType(Uint16.valueOf(0xB))
1268 private static InstructionsBuilder createAppyActionInstruction20() {
1269 return new InstructionsBuilder()
1270 .setInstruction(BindingMap.of(new InstructionBuilder()
1272 .setInstruction(new ApplyActionsCaseBuilder()
1273 .setApplyActions(new ApplyActionsBuilder()
1274 .setAction(BindingMap.of(new ActionBuilder()
1276 .setAction(new PopPbbActionCaseBuilder()
1277 .setPopPbbAction(new PopPbbActionBuilder().build())
1285 private static InstructionsBuilder createAppyActionInstruction21() {
1286 return new InstructionsBuilder()
1287 .setInstruction(BindingMap.of(new InstructionBuilder()
1289 .setInstruction(new ApplyActionsCaseBuilder()
1290 .setApplyActions(new ApplyActionsBuilder()
1291 .setAction(BindingMap.of(new ActionBuilder()
1293 .setAction(new PopVlanActionCaseBuilder()
1294 .setPopVlanAction(new PopVlanActionBuilder().build())
1302 private static InstructionsBuilder createAppyActionInstruction22() {
1303 return new InstructionsBuilder()
1304 .setInstruction(BindingMap.of(new InstructionBuilder()
1306 .setInstruction(new ApplyActionsCaseBuilder()
1307 .setApplyActions(new ApplyActionsBuilder()
1308 .setAction(BindingMap.of(new ActionBuilder()
1310 .setAction(new SetDlTypeActionCaseBuilder()
1311 .setSetDlTypeAction(new SetDlTypeActionBuilder()
1312 .setDlType(new EtherType(Uint32.valueOf(8)))
1321 private static InstructionsBuilder createAppyActionInstruction23(final NodeId nodeId) {
1322 return new InstructionsBuilder()
1323 .setInstruction(BindingMap.of(new InstructionBuilder()
1325 .setInstruction(new ApplyActionsCaseBuilder()
1326 .setApplyActions(new ApplyActionsBuilder()
1327 .setAction(BindingMap.of(new ActionBuilder().setOrder(0).build()))
1333 private static InstructionsBuilder createAppyActionInstruction24() {
1334 return new InstructionsBuilder()
1335 .setInstruction(BindingMap.of(new InstructionBuilder()
1337 .setInstruction(new ApplyActionsCaseBuilder()
1338 .setApplyActions(new ApplyActionsBuilder()
1339 .setAction(BindingMap.of(new ActionBuilder()
1341 .setAction(new SetMplsTtlActionCaseBuilder()
1342 .setSetMplsTtlAction(new SetMplsTtlActionBuilder().setMplsTtl(Uint8.ONE).build())
1350 private static InstructionsBuilder createAppyActionInstruction25() {
1351 return new InstructionsBuilder()
1352 .setInstruction(BindingMap.of(new InstructionBuilder()
1354 .setInstruction(new ApplyActionsCaseBuilder()
1355 .setApplyActions(new ApplyActionsBuilder()
1356 .setAction(BindingMap.of(new ActionBuilder()
1358 .setAction(new SetNextHopActionCaseBuilder()
1359 .setSetNextHopAction(new SetNextHopActionBuilder()
1360 .setAddress(new Ipv4Builder().setIpv4Address(new Ipv4Prefix(IPV4_PREFIX)).build())
1369 private static InstructionsBuilder createAppyActionInstruction26() {
1370 return new InstructionsBuilder()
1371 .setInstruction(BindingMap.of(new InstructionBuilder()
1373 .setInstruction(new ApplyActionsCaseBuilder()
1374 .setApplyActions(new ApplyActionsBuilder()
1375 .setAction(BindingMap.of(new ActionBuilder()
1377 .setAction(new SetNwDstActionCaseBuilder()
1378 .setSetNwDstAction(new SetNwDstActionBuilder()
1379 .setAddress(new Ipv4Builder()
1380 .setIpv4Address(new Ipv4Prefix("10.0.0.21/24"))
1390 private static InstructionsBuilder createAppyActionInstruction27() {
1391 return new InstructionsBuilder()
1392 .setInstruction(BindingMap.of(new InstructionBuilder()
1394 .setInstruction(new ApplyActionsCaseBuilder()
1395 .setApplyActions(new ApplyActionsBuilder()
1396 .setAction(BindingMap.of(new ActionBuilder()
1398 .setAction(new SetNwSrcActionCaseBuilder()
1399 .setSetNwSrcAction(new SetNwSrcActionBuilder()
1400 .setAddress(new Ipv4Builder()
1401 .setIpv4Address(new Ipv4Prefix("10.0.23.21/24"))
1411 private static InstructionsBuilder createAppyActionInstruction28() {
1412 return new InstructionsBuilder()
1413 .setInstruction(BindingMap.of(new InstructionBuilder()
1415 .setInstruction(new ApplyActionsCaseBuilder()
1416 .setApplyActions(new ApplyActionsBuilder()
1417 .setAction(BindingMap.of(new ActionBuilder()
1419 .setAction(new SetNwTosActionCaseBuilder()
1420 .setSetNwTosAction(new SetNwTosActionBuilder().setTos(8).build())
1428 private static InstructionsBuilder createAppyActionInstruction29() {
1429 return new InstructionsBuilder()
1430 .setInstruction(BindingMap.of(new InstructionBuilder()
1432 .setInstruction(new ApplyActionsCaseBuilder()
1433 .setApplyActions(new ApplyActionsBuilder()
1434 .setAction(BindingMap.of(new ActionBuilder()
1436 .setAction(new SetNwTtlActionCaseBuilder()
1437 .setSetNwTtlAction(new SetNwTtlActionBuilder().setNwTtl(Uint8.ONE).build())
1445 private static InstructionsBuilder createAppyActionInstruction30() {
1446 return new InstructionsBuilder()
1447 .setInstruction(BindingMap.of(new InstructionBuilder()
1449 .setInstruction(new ApplyActionsCaseBuilder()
1450 .setApplyActions(new ApplyActionsBuilder()
1451 .setAction(BindingMap.of(new ActionBuilder()
1453 .setAction(new SetQueueActionCaseBuilder()
1454 .setSetQueueAction(new SetQueueActionBuilder().setQueueId(Uint32.ONE).build())
1462 private static InstructionsBuilder createAppyActionInstruction31() {
1463 return new InstructionsBuilder()
1464 .setInstruction(BindingMap.of(new InstructionBuilder()
1466 .setInstruction(new ApplyActionsCaseBuilder()
1467 .setApplyActions(new ApplyActionsBuilder()
1468 .setAction(BindingMap.of(new ActionBuilder()
1470 .setAction(new SetTpDstActionCaseBuilder()
1471 .setSetTpDstAction(new SetTpDstActionBuilder()
1472 .setPort(new PortNumber(Uint16.valueOf(109)))
1481 private static InstructionsBuilder createAppyActionInstruction32() {
1482 return new InstructionsBuilder()
1483 .setInstruction(BindingMap.of(new InstructionBuilder()
1485 .setInstruction(new ApplyActionsCaseBuilder()
1486 .setApplyActions(new ApplyActionsBuilder()
1487 .setAction(BindingMap.of(new ActionBuilder()
1489 .setAction(new SetTpSrcActionCaseBuilder()
1490 .setSetTpSrcAction(new SetTpSrcActionBuilder()
1491 .setPort(new PortNumber(Uint16.valueOf(109)))
1500 private static InstructionsBuilder createAppyActionInstruction33() {
1501 return new InstructionsBuilder()
1502 .setInstruction(BindingMap.of(new InstructionBuilder()
1504 .setInstruction(new ApplyActionsCaseBuilder()
1505 .setApplyActions(new ApplyActionsBuilder()
1506 .setAction(BindingMap.of(new ActionBuilder()
1508 .setAction(new SetVlanCfiActionCaseBuilder()
1509 .setSetVlanCfiAction(new SetVlanCfiActionBuilder().setVlanCfi(new VlanCfi(2)).build())
1517 private static InstructionsBuilder createAppyActionInstruction34() {
1518 return new InstructionsBuilder()
1519 .setInstruction(BindingMap.of(new InstructionBuilder()
1521 .setInstruction(new ApplyActionsCaseBuilder()
1522 .setApplyActions(new ApplyActionsBuilder()
1523 .setAction(BindingMap.of(new ActionBuilder()
1525 .setAction(new SwPathActionCaseBuilder()
1526 .setSwPathAction(new SwPathActionBuilder().build())
1534 private static InstructionsBuilder createAppyActionInstruction35() {
1536 return new InstructionsBuilder()
1537 .setInstruction(BindingMap.of(new InstructionBuilder()
1539 .setInstruction(new ApplyActionsCaseBuilder()
1540 .setApplyActions(new ApplyActionsBuilder()
1541 .setAction(BindingMap.of(new ActionBuilder()
1543 .setAction(new SetFieldCaseBuilder()
1544 .setSetField(new SetFieldBuilder()
1545 .setEthernetMatch(new EthernetMatchBuilder()
1546 .setEthernetSource(new EthernetSourceBuilder()
1547 .setAddress(new MacAddress("00:00:00:00:00:01"))
1552 .build(), new ActionBuilder()
1554 .setAction(new SetFieldCaseBuilder()
1555 .setSetField(new SetFieldBuilder()
1556 .setEthernetMatch(new EthernetMatchBuilder()
1557 .setEthernetDestination(new EthernetDestinationBuilder()
1558 .setAddress(new MacAddress("00:00:00:00:00:02"))
1563 .build(), new ActionBuilder()
1565 .setAction(new SetFieldCaseBuilder()
1566 .setSetField(new SetFieldBuilder()
1567 .setEthernetMatch(new EthernetMatchBuilder()
1568 .setEthernetType(new EthernetTypeBuilder()
1569 .setType(new EtherType(Uint32.valueOf(0x86dd))).build())
1579 private static InstructionsBuilder createAppyActionInstruction36() {
1580 return new InstructionsBuilder()
1581 .setInstruction(BindingMap.of(new InstructionBuilder()
1583 .setInstruction(new ApplyActionsCaseBuilder()
1584 .setApplyActions(new ApplyActionsBuilder()
1585 .setAction(BindingMap.of(new ActionBuilder()
1587 .setAction(new SetFieldCaseBuilder().setSetField(new SetFieldBuilder()
1588 .setVlanMatch(new VlanMatchBuilder()
1589 .setVlanPcp(new VlanPcp(Uint8.valueOf(3)))
1591 .build()).build()).build(), new ActionBuilder()
1593 .setAction(new SetFieldCaseBuilder().setSetField(new SetFieldBuilder()
1594 .setVlanMatch(new VlanMatchBuilder()
1595 .setVlanId(new VlanIdBuilder()
1596 .setVlanId(new VlanId(Uint16.TEN))
1597 .setVlanIdPresent(true)
1608 private static InstructionsBuilder createAppyActionInstruction37() {
1610 return new InstructionsBuilder()
1611 .setInstruction(BindingMap.of(new InstructionBuilder()
1613 .setInstruction(new ApplyActionsCaseBuilder()
1614 .setApplyActions(new ApplyActionsBuilder()
1615 .setAction(BindingMap.of(new ActionBuilder()
1617 .setAction(new SetFieldCaseBuilder()
1618 .setSetField(new SetFieldBuilder()
1619 .setIpMatch(new IpMatchBuilder().setIpDscp(new Dscp(Uint8.valueOf(3))).build())
1622 .build(), new ActionBuilder()
1624 .setAction(new SetFieldCaseBuilder()
1625 .setSetField(new SetFieldBuilder()
1626 .setIpMatch(new IpMatchBuilder().setIpEcn(Uint8.TWO).build())
1629 .build(), new ActionBuilder()
1631 .setAction(new SetFieldCaseBuilder()
1632 .setSetField(new SetFieldBuilder()
1633 .setIpMatch(new IpMatchBuilder().setIpProtocol(Uint8.valueOf(120)).build())
1641 private static InstructionsBuilder createAppyActionInstruction38() {
1643 return new InstructionsBuilder()
1644 .setInstruction(BindingMap.of(new InstructionBuilder()
1646 .setInstruction(new ApplyActionsCaseBuilder()
1647 .setApplyActions(new ApplyActionsBuilder()
1648 .setAction(BindingMap.of(new ActionBuilder()
1650 .setAction(new SetFieldCaseBuilder()
1651 .setSetField(new SetFieldBuilder()
1652 .setLayer3Match(new Ipv4MatchBuilder()
1653 .setIpv4Source(new Ipv4Prefix("100.1.1.1"))
1657 .build(), new ActionBuilder()
1659 .setAction(new SetFieldCaseBuilder()
1660 .setSetField(new SetFieldBuilder()
1661 .setLayer3Match(new Ipv4MatchBuilder()
1662 .setIpv4Destination(new Ipv4Prefix("200.71.9.5210"))
1672 // FIXME: refactor these for brevity
1674 private static InstructionsBuilder createAppyActionInstruction39() {
1675 final ActionBuilder ab = new ActionBuilder();
1676 final ActionBuilder ab1 = new ActionBuilder();
1678 final SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
1679 final SetFieldBuilder setFieldBuilder1 = new SetFieldBuilder();
1682 final PortNumber tcpsrcport = new PortNumber(Uint16.valueOf(1213));
1683 final PortNumber tcpdstport = new PortNumber(Uint16.valueOf(646));
1684 final TcpMatchBuilder tcpmatch = new TcpMatchBuilder();
1685 final TcpMatchBuilder tcpmatch1 = new TcpMatchBuilder();
1686 tcpmatch.setTcpSourcePort(tcpsrcport);
1687 tcpmatch1.setTcpDestinationPort(tcpdstport);
1688 setFieldBuilder.setLayer4Match(tcpmatch.build());
1689 ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
1692 setFieldBuilder1.setLayer4Match(tcpmatch1.build());
1693 ab1.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder1.build()).build());
1694 ab1.withKey(new ActionKey(1));
1696 return new InstructionsBuilder()
1697 .setInstruction(BindingMap.of(new InstructionBuilder()
1699 .setInstruction(new ApplyActionsCaseBuilder()
1700 .setApplyActions(new ApplyActionsBuilder()
1701 .setAction(BindingMap.of(ab.build(), ab1.build()))
1707 private static InstructionsBuilder createAppyActionInstruction40() {
1708 final ActionBuilder ab = new ActionBuilder();
1709 final ActionBuilder ab1 = new ActionBuilder();
1711 final SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
1712 final SetFieldBuilder setFieldBuilder1 = new SetFieldBuilder();
1715 final PortNumber udpsrcport = new PortNumber(Uint16.valueOf(1325));
1716 final PortNumber udpdstport = new PortNumber(Uint16.valueOf(42));
1717 final UdpMatchBuilder udpmatch = new UdpMatchBuilder();
1718 final UdpMatchBuilder udpmatch1 = new UdpMatchBuilder();
1719 udpmatch.setUdpDestinationPort(udpdstport);
1720 udpmatch1.setUdpSourcePort(udpsrcport);
1721 setFieldBuilder.setLayer4Match(udpmatch.build());
1722 ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
1725 setFieldBuilder1.setLayer4Match(udpmatch1.build());
1726 ab1.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder1.build()).build());
1727 ab1.withKey(new ActionKey(1));
1729 return new InstructionsBuilder()
1730 .setInstruction(BindingMap.of(new InstructionBuilder()
1732 .setInstruction(new ApplyActionsCaseBuilder()
1733 .setApplyActions(new ApplyActionsBuilder()
1734 .setAction(BindingMap.of(ab.build(), ab1.build()))
1740 private static InstructionsBuilder createAppyActionInstruction41() {
1741 final ActionBuilder ab = new ActionBuilder();
1742 final ActionBuilder ab1 = new ActionBuilder();
1744 final SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
1745 final SetFieldBuilder setFieldBuilder1 = new SetFieldBuilder();
1748 final SctpMatchBuilder sctpmatch = new SctpMatchBuilder();
1749 final SctpMatchBuilder sctpmatch1 = new SctpMatchBuilder();
1750 final PortNumber srcport = new PortNumber(Uint16.valueOf(1435));
1751 final PortNumber dstport = new PortNumber(Uint16.valueOf(22));
1752 sctpmatch.setSctpSourcePort(srcport);
1753 sctpmatch1.setSctpDestinationPort(dstport);
1754 setFieldBuilder.setLayer4Match(sctpmatch.build());
1755 ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
1758 setFieldBuilder1.setLayer4Match(sctpmatch1.build());
1759 ab1.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder1.build()).build());
1760 ab1.withKey(new ActionKey(1));
1762 return new InstructionsBuilder()
1763 .setInstruction(BindingMap.of(new InstructionBuilder()
1765 .setInstruction(new ApplyActionsCaseBuilder()
1766 .setApplyActions(new ApplyActionsBuilder()
1767 .setAction(BindingMap.of(ab.build(), ab1.build()))
1773 private static InstructionsBuilder createAppyActionInstruction42() {
1774 final ActionBuilder ab = new ActionBuilder();
1775 final ActionBuilder ab1 = new ActionBuilder();
1776 final SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
1777 final SetFieldBuilder setFieldBuilder1 = new SetFieldBuilder();
1780 final Icmpv4MatchBuilder icmpv4match = new Icmpv4MatchBuilder();
1781 final Icmpv4MatchBuilder icmpv4match1 = new Icmpv4MatchBuilder();
1782 icmpv4match.setIcmpv4Type(Uint8.valueOf(8));
1783 icmpv4match1.setIcmpv4Code(Uint8.ZERO);
1784 setFieldBuilder.setIcmpv4Match(icmpv4match.build());
1785 ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
1788 setFieldBuilder1.setIcmpv4Match(icmpv4match1.build());
1789 ab1.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder1.build()).build());
1790 ab1.withKey(new ActionKey(1));
1792 return new InstructionsBuilder()
1793 .setInstruction(BindingMap.of(new InstructionBuilder()
1795 .setInstruction(new ApplyActionsCaseBuilder()
1796 .setApplyActions(new ApplyActionsBuilder()
1797 .setAction(BindingMap.of(ab.build(), ab1.build()))
1803 private static InstructionsBuilder createAppyActionInstruction43() {
1804 final ActionBuilder ab = new ActionBuilder();
1805 final ActionBuilder ab1 = new ActionBuilder();
1806 final ActionBuilder ab2 = new ActionBuilder();
1807 final ActionBuilder ab3 = new ActionBuilder();
1808 final ActionBuilder ab4 = new ActionBuilder();
1810 final SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
1811 final SetFieldBuilder setFieldBuilder1 = new SetFieldBuilder();
1812 final SetFieldBuilder setFieldBuilder2 = new SetFieldBuilder();
1813 final SetFieldBuilder setFieldBuilder3 = new SetFieldBuilder();
1814 final SetFieldBuilder setFieldBuilder4 = new SetFieldBuilder();
1816 // setting the values of ARP
1817 final MacAddress macdest = new MacAddress(DEST_MAC_ADDRESS);
1818 final MacAddress macsrc = new MacAddress(SRC_MAC_ADDRESS);
1819 final Ipv4Prefix dstiparp = new Ipv4Prefix("200.71.9.52");
1820 final Ipv4Prefix srciparp = new Ipv4Prefix("100.1.1.1");
1821 // create ARP match action
1822 final ArpMatchBuilder arpmatch = new ArpMatchBuilder();
1823 final ArpMatchBuilder arpmatch1 = new ArpMatchBuilder();
1824 final ArpMatchBuilder arpmatch2 = new ArpMatchBuilder();
1825 final ArpMatchBuilder arpmatch3 = new ArpMatchBuilder();
1826 final ArpMatchBuilder arpmatch4 = new ArpMatchBuilder();
1827 final ArpSourceHardwareAddressBuilder arpsrc = new ArpSourceHardwareAddressBuilder();
1828 arpsrc.setAddress(macsrc);
1829 final ArpTargetHardwareAddressBuilder arpdst = new ArpTargetHardwareAddressBuilder();
1830 arpdst.setAddress(macdest);
1831 arpmatch.setArpOp(Uint16.TWO);
1832 arpmatch1.setArpSourceHardwareAddress(arpsrc.build());
1833 arpmatch2.setArpTargetHardwareAddress(arpdst.build());
1834 arpmatch3.setArpSourceTransportAddress(srciparp);
1835 arpmatch4.setArpTargetTransportAddress(dstiparp);
1836 setFieldBuilder.setLayer3Match(arpmatch.build());
1837 ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
1840 setFieldBuilder1.setLayer3Match(arpmatch1.build());
1841 ab1.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder1.build()).build());
1842 ab1.withKey(new ActionKey(1));
1844 setFieldBuilder2.setLayer3Match(arpmatch2.build());
1845 ab2.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder2.build()).build());
1846 ab2.withKey(new ActionKey(2));
1848 setFieldBuilder3.setLayer3Match(arpmatch3.build());
1849 ab3.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder3.build()).build());
1850 ab3.withKey(new ActionKey(3));
1852 setFieldBuilder4.setLayer3Match(arpmatch4.build());
1853 ab4.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder4.build()).build());
1854 ab4.withKey(new ActionKey(4));
1856 return new InstructionsBuilder()
1857 .setInstruction(BindingMap.of(new InstructionBuilder()
1859 .setInstruction(new ApplyActionsCaseBuilder()
1860 .setApplyActions(new ApplyActionsBuilder()
1861 .setAction(BindingMap.of(ab.build(), ab1.build(), ab2.build(), ab3.build(), ab4.build()))
1867 private static InstructionsBuilder createAppyActionInstruction44() {
1868 final ActionBuilder ab = new ActionBuilder();
1869 final SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
1870 final ActionBuilder ab1 = new ActionBuilder();
1871 final SetFieldBuilder setFieldBuilder1 = new SetFieldBuilder();
1872 final ActionBuilder ab5 = new ActionBuilder();
1873 final SetFieldBuilder setFieldBuilder5 = new SetFieldBuilder();
1874 final ActionBuilder ab6 = new ActionBuilder();
1875 final SetFieldBuilder setFieldBuilder6 = new SetFieldBuilder();
1878 final Ipv6MatchBuilder ipv6Builder = new Ipv6MatchBuilder();
1879 final Ipv6MatchBuilder ipv6Builder1 = new Ipv6MatchBuilder();
1880 final Ipv6MatchBuilder ipv6Builder5 = new Ipv6MatchBuilder();
1881 final Ipv6MatchBuilder ipv6Builder6 = new Ipv6MatchBuilder();
1883 final Ipv6Prefix dstip6 = new Ipv6Prefix("2002::2/128");
1884 final Ipv6Prefix srcip6 = new Ipv6Prefix("2001:0:0:0:0:0:0:1/128");
1885 final Ipv6ExtHeaderBuilder nextheader = new Ipv6ExtHeaderBuilder();
1886 nextheader.setIpv6Exthdr(Uint16.valueOf(58));
1887 final Ipv6LabelBuilder ipv6label = new Ipv6LabelBuilder();
1888 final Ipv6FlowLabel label = new Ipv6FlowLabel(Uint32.valueOf(10028));
1889 ipv6label.setIpv6Flabel(label);
1891 ipv6Builder.setIpv6Source(srcip6);
1892 ipv6Builder1.setIpv6Destination(dstip6);
1893 ipv6Builder5.setIpv6ExtHeader(nextheader.build());
1894 ipv6Builder6.setIpv6Label(ipv6label.build());
1896 setFieldBuilder.setLayer3Match(ipv6Builder.build());
1897 ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
1900 setFieldBuilder1.setLayer3Match(ipv6Builder1.build());
1901 ab1.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder1.build()).build());
1902 ab1.withKey(new ActionKey(1));
1904 setFieldBuilder5.setLayer3Match(ipv6Builder5.build());
1905 ab5.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder5.build()).build());
1906 ab5.withKey(new ActionKey(5));
1908 setFieldBuilder6.setLayer3Match(ipv6Builder6.build());
1909 ab6.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder6.build()).build());
1910 ab6.withKey(new ActionKey(6));
1912 return new InstructionsBuilder()
1913 .setInstruction(BindingMap.of(new InstructionBuilder()
1915 .setInstruction(new ApplyActionsCaseBuilder()
1916 .setApplyActions(new ApplyActionsBuilder()
1917 .setAction(BindingMap.of(ab.build(), ab1.build(), ab5.build(), ab6.build()))
1923 private static InstructionsBuilder createAppyActionInstruction45() {
1925 return new InstructionsBuilder()
1926 .setInstruction(BindingMap.of(new InstructionBuilder()
1928 .setInstruction(new ApplyActionsCaseBuilder()
1929 .setApplyActions(new ApplyActionsBuilder()
1930 .setAction(BindingMap.of(new ActionBuilder()
1932 .setAction(new SetFieldCaseBuilder()
1933 .setSetField(new SetFieldBuilder()
1934 .setIcmpv6Match(new Icmpv6MatchBuilder().setIcmpv6Type(Uint8.valueOf(135)).build())
1937 .build(), new ActionBuilder()
1939 .setAction(new SetFieldCaseBuilder()
1940 .setSetField(new SetFieldBuilder()
1941 .setIcmpv6Match(new Icmpv6MatchBuilder().setIcmpv6Code(Uint8.ZERO).build())
1950 private static InstructionsBuilder createAppyActionInstruction46() {
1952 return new InstructionsBuilder()
1953 .setInstruction(BindingMap.of(new InstructionBuilder()
1955 .setInstruction(new ApplyActionsCaseBuilder()
1956 .setApplyActions(new ApplyActionsBuilder()
1957 .setAction(BindingMap.of(new ActionBuilder()
1959 .setAction(new SetFieldCaseBuilder()
1960 .setSetField(new SetFieldBuilder()
1961 .setProtocolMatchFields(new ProtocolMatchFieldsBuilder()
1962 .setMplsLabel(Uint32.valueOf(36008))
1966 .build(), new ActionBuilder()
1968 .setAction(new SetFieldCaseBuilder()
1969 .setSetField(new SetFieldBuilder()
1970 .setProtocolMatchFields(new ProtocolMatchFieldsBuilder()
1971 .setMplsTc(Uint8.valueOf(4))
1975 .build(), new ActionBuilder()
1977 .setAction(new SetFieldCaseBuilder()
1978 .setSetField(new SetFieldBuilder()
1979 .setProtocolMatchFields(new ProtocolMatchFieldsBuilder()
1980 .setMplsBos(Uint8.ONE)
1990 private static InstructionsBuilder createAppyActionInstruction47() {
1991 return new InstructionsBuilder()
1992 .setInstruction(BindingMap.of(new InstructionBuilder()
1994 .setInstruction(new ApplyActionsCaseBuilder()
1995 .setApplyActions(new ApplyActionsBuilder()
1996 .setAction(BindingMap.of(new ActionBuilder()
1998 .setAction(new SetFieldCaseBuilder()
1999 .setSetField(new SetFieldBuilder()
2000 .setProtocolMatchFields(new ProtocolMatchFieldsBuilder()
2001 .setPbb(new PbbBuilder()
2002 .setPbbIsid(Uint32.valueOf(4))
2003 .setPbbMask(Uint32.valueOf(0x10000))
2014 private static InstructionsBuilder createAppyActionInstruction48() {
2015 return new InstructionsBuilder()
2016 .setInstruction(BindingMap.of(new InstructionBuilder()
2018 .setInstruction(new ApplyActionsCaseBuilder()
2019 .setApplyActions(new ApplyActionsBuilder()
2020 .setAction(BindingMap.of(new ActionBuilder()
2022 .setAction(new SetFieldCaseBuilder()
2023 .setSetField(new SetFieldBuilder()
2025 .setTunnel(new TunnelBuilder().setTunnelId(Uint64.valueOf(10668)).build()).build())
2033 private static InstructionsBuilder createTunnelIpv4DstInstructions() {
2034 return new InstructionsBuilder()
2035 .setInstruction(BindingMap.of(new InstructionBuilder()
2037 .setInstruction(new ApplyActionsCaseBuilder()
2038 .setApplyActions(new ApplyActionsBuilder()
2039 .setAction(BindingMap.of(new ActionBuilder()
2041 .setAction(new SetFieldCaseBuilder()
2042 // Add the IPv4 tunnel dst to the set_field value
2043 .setSetField(new SetFieldBuilder()
2044 .setLayer3Match(new TunnelIpv4MatchBuilder()
2045 // Add the mew IPv4 object as the tunnel destination
2046 .setTunnelIpv4Destination(new Ipv4Prefix("172.16.100.100"))
2056 private static InstructionsBuilder createTunnelIpv4SrcInstructions() {
2057 return new InstructionsBuilder()
2058 .setInstruction(BindingMap.of(new InstructionBuilder()
2060 .setInstruction(new ApplyActionsCaseBuilder()
2061 .setApplyActions(new ApplyActionsBuilder()
2062 .setAction(BindingMap.of(new ActionBuilder()
2064 .setAction(new SetFieldCaseBuilder()
2065 // Add the IPv4 tunnel src to the set_field value
2066 .setSetField(new SetFieldBuilder()
2067 .setLayer3Match(new TunnelIpv4MatchBuilder()
2068 // Add the new IPv4 object as the tunnel destination
2069 .setTunnelIpv4Source(new Ipv4Prefix("172.16.100.200"))
2079 private static MatchBuilder createLLDPMatch() {
2080 final MatchBuilder match = new MatchBuilder();
2081 final EthernetMatchBuilder eth = new EthernetMatchBuilder();
2082 final EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
2083 ethTypeBuilder.setType(new EtherType(Uint32.valueOf(0x88cc)));
2084 eth.setEthernetType(ethTypeBuilder.build());
2085 match.setEthernetMatch(eth.build());
2089 private static MatchBuilder createMatch1() {
2090 final MatchBuilder match = new MatchBuilder();
2091 final Ipv4MatchBuilder ipv4Match = new Ipv4MatchBuilder();
2092 final Ipv4Prefix prefix = new Ipv4Prefix(IPV4_PREFIX);
2093 ipv4Match.setIpv4Destination(prefix);
2094 final Ipv4Match i4m = ipv4Match.build();
2095 match.setLayer3Match(i4m);
2097 final EthernetMatchBuilder eth = new EthernetMatchBuilder();
2098 final EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
2099 ethTypeBuilder.setType(new EtherType(Uint32.valueOf(0x0800)));
2100 eth.setEthernetType(ethTypeBuilder.build());
2101 match.setEthernetMatch(eth.build());
2105 private static MatchBuilder createMatch2() {
2106 final MatchBuilder match = new MatchBuilder();
2107 final Ipv4MatchBuilder ipv4Match = new Ipv4MatchBuilder();
2108 final Ipv4Prefix prefix = new Ipv4Prefix("10.0.0.1");
2109 ipv4Match.setIpv4Source(prefix);
2110 final Ipv4Match i4m = ipv4Match.build();
2111 match.setLayer3Match(i4m);
2113 final EthernetMatchBuilder eth = new EthernetMatchBuilder();
2114 final EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
2115 ethTypeBuilder.setType(new EtherType(Uint32.valueOf(0x0800)));
2116 eth.setEthernetType(ethTypeBuilder.build());
2117 match.setEthernetMatch(eth.build());
2121 private static MatchBuilder createMatch3() {
2122 final MatchBuilder match = new MatchBuilder();
2123 final EthernetMatchBuilder ethernetMatch = new EthernetMatchBuilder();
2124 final EthernetSourceBuilder ethSourceBuilder = new EthernetSourceBuilder();
2125 ethSourceBuilder.setAddress(new MacAddress("00:00:00:00:00:01"));
2126 ethernetMatch.setEthernetSource(ethSourceBuilder.build());
2127 match.setEthernetMatch(ethernetMatch.build());
2132 private static MatchBuilder createICMPv6Match1() {
2133 return new MatchBuilder()
2134 .setEthernetMatch(new EthernetMatchBuilder()
2135 .setEthernetType(new EthernetTypeBuilder()
2136 .setType(new EtherType(Uint32.valueOf(0x86dd)))
2140 .setIpMatch(new IpMatchBuilder().setIpProtocol(Uint8.MAX_VALUE).build())
2142 .setIcmpv6Match(new Icmpv6MatchBuilder()
2143 .setIcmpv6Type(Uint8.valueOf(135))
2144 .setIcmpv6Code(Uint8.ONE)
2148 private static MatchBuilder createMatch33() {
2150 final MatchBuilder match = new MatchBuilder();
2151 final Ipv4MatchBuilder ipv4Match = new Ipv4MatchBuilder();
2152 final Ipv4Prefix prefix = new Ipv4Prefix("10.0.0.10");
2153 ipv4Match.setIpv4Source(prefix);
2154 final Ipv4Match i4m = ipv4Match.build();
2155 match.setLayer3Match(i4m);
2157 final EthernetMatchBuilder eth = new EthernetMatchBuilder();
2158 final EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
2159 ethTypeBuilder.setType(new EtherType(Uint32.valueOf(0xfffe)));
2160 eth.setEthernetType(ethTypeBuilder.build());
2161 match.setEthernetMatch(eth.build());
2165 private static MatchBuilder createInphyportMatch(final NodeId nodeId) {
2166 final MatchBuilder match = new MatchBuilder();
2167 match.setInPort(new NodeConnectorId(nodeId + ":202"));
2168 match.setInPhyPort(new NodeConnectorId(nodeId + ":10122"));
2172 private static MatchBuilder createEthernetMatch() {
2173 final MatchBuilder match = new MatchBuilder();
2174 final EthernetMatchBuilder ethmatch = new EthernetMatchBuilder(); // ethernettype
2176 final EthernetTypeBuilder ethtype = new EthernetTypeBuilder();
2177 final EtherType type = new EtherType(Uint32.valueOf(0x0800));
2178 ethmatch.setEthernetType(ethtype.setType(type).build());
2180 final EthernetDestinationBuilder ethdest = new EthernetDestinationBuilder(); // ethernet
2183 final MacAddress macdest = new MacAddress(DEST_MAC_ADDRESS);
2184 ethdest.setAddress(macdest);
2185 ethdest.setMask(new MacAddress("ff:ff:ff:00:00:00"));
2187 ethmatch.setEthernetDestination(ethdest.build());
2189 final EthernetSourceBuilder ethsrc = new EthernetSourceBuilder();
2190 final MacAddress macsrc = new MacAddress(SRC_MAC_ADDRESS);
2191 ethsrc.setAddress(macsrc);
2192 ethsrc.setMask(new MacAddress("ff:ff:00:00:00:00"));
2194 ethmatch.setEthernetSource(ethsrc.build());
2195 match.setEthernetMatch(ethmatch.build());
2200 private static MatchBuilder createVlanMatch() {
2201 final MatchBuilder match = new MatchBuilder();
2203 final VlanMatchBuilder vlanBuilder = new VlanMatchBuilder();
2204 final VlanIdBuilder vlanIdBuilder = new VlanIdBuilder();
2205 final VlanId vlanId = new VlanId(Uint16.TEN);
2206 final VlanPcp vpcp = new VlanPcp(Uint8.valueOf(3));
2207 vlanBuilder.setVlanPcp(vpcp);
2208 vlanIdBuilder.setVlanId(vlanId);
2209 vlanIdBuilder.setVlanIdPresent(true);
2210 vlanBuilder.setVlanId(vlanIdBuilder.build());
2211 match.setVlanMatch(vlanBuilder.build());
2215 private static MatchBuilder createArpMatch() {
2216 final MatchBuilder match = new MatchBuilder();
2218 final EthernetMatchBuilder ethmatch = new EthernetMatchBuilder();
2219 final MacAddress macdest = new MacAddress(DEST_MAC_ADDRESS);
2220 final MacAddress macsrc = new MacAddress(SRC_MAC_ADDRESS);
2222 final EthernetTypeBuilder ethtype = new EthernetTypeBuilder();
2223 final EtherType type = new EtherType(Uint32.valueOf(0x0806));
2224 ethmatch.setEthernetType(ethtype.setType(type).build());
2227 final Ipv4Prefix dstip = new Ipv4Prefix("200.71.9.52/10");
2228 final Ipv4Prefix srcip = new Ipv4Prefix("100.1.1.1/8");
2231 final ArpMatchBuilder arpmatch = new ArpMatchBuilder();
2232 final ArpSourceHardwareAddressBuilder arpsrc = new ArpSourceHardwareAddressBuilder();
2233 arpsrc.setAddress(macsrc);
2234 arpsrc.setMask(new MacAddress("ff:ff:ff:00:00:00"));
2235 final ArpTargetHardwareAddressBuilder arpdst = new ArpTargetHardwareAddressBuilder();
2236 arpdst.setAddress(macdest);
2237 arpdst.setMask(new MacAddress("ff:ff:00:00:00:00"));
2238 arpmatch.setArpOp(Uint16.TWO);
2239 arpmatch.setArpSourceHardwareAddress(arpsrc.build());
2240 arpmatch.setArpTargetHardwareAddress(arpdst.build());
2241 arpmatch.setArpSourceTransportAddress(srcip);
2242 arpmatch.setArpTargetTransportAddress(dstip);
2244 match.setEthernetMatch(ethmatch.build());
2245 match.setLayer3Match(arpmatch.build());
2250 private static MatchBuilder createL3IPv6Match() {
2251 final MatchBuilder match = new MatchBuilder();
2253 final EthernetMatchBuilder eth = new EthernetMatchBuilder();
2254 final EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
2255 ethTypeBuilder.setType(new EtherType(Uint32.valueOf(0x86dd)));
2256 eth.setEthernetType(ethTypeBuilder.build());
2257 match.setEthernetMatch(eth.build());
2259 final MacAddress ndsll = new MacAddress("c2:00:54:f5:00:00");
2260 final MacAddress ndtll = new MacAddress("00:0c:29:0e:4c:67");
2261 final Ipv6LabelBuilder ipv6label = new Ipv6LabelBuilder();
2262 final Ipv6FlowLabel label = new Ipv6FlowLabel(Uint32.valueOf(10028));
2263 ipv6label.setIpv6Flabel(label);
2264 ipv6label.setFlabelMask(new Ipv6FlowLabel(Uint32.ONE));
2266 final Icmpv6MatchBuilder icmpv6match = new Icmpv6MatchBuilder(); // icmpv6
2268 icmpv6match.setIcmpv6Type(Uint8.valueOf(135));
2269 icmpv6match.setIcmpv6Code(Uint8.ZERO);
2270 match.setIcmpv6Match(icmpv6match.build());
2272 final Ipv6MatchBuilder ipv6match = new Ipv6MatchBuilder();
2273 // ipv6match.setIpv6Source(srcip6);
2274 // ipv6match.setIpv6Destination(dstip6);
2275 // ipv6match.setIpv6ExtHeader(nextheader.build());
2276 ipv6match.setIpv6NdSll(ndsll);
2277 ipv6match.setIpv6NdTll(ndtll);
2278 // ipv6match.setIpv6NdTarget(ndtarget);
2279 ipv6match.setIpv6Label(ipv6label.build());
2281 match.setLayer3Match(ipv6match.build());
2286 private static MatchBuilder createICMPv4Match() {
2287 final MatchBuilder match = new MatchBuilder();
2288 final EthernetMatchBuilder eth = new EthernetMatchBuilder();
2289 final EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
2290 ethTypeBuilder.setType(new EtherType(Uint32.valueOf(0x0800)));
2291 eth.setEthernetType(ethTypeBuilder.build());
2292 match.setEthernetMatch(eth.build());
2294 final IpMatchBuilder ipmatch = new IpMatchBuilder(); // ipv4 version
2295 ipmatch.setIpProtocol(Uint8.ONE);
2296 match.setIpMatch(ipmatch.build());
2298 final Icmpv4MatchBuilder icmpv4match = new Icmpv4MatchBuilder(); // icmpv4
2300 icmpv4match.setIcmpv4Type(Uint8.valueOf(8));
2301 icmpv4match.setIcmpv4Code(Uint8.ZERO);
2302 match.setIcmpv4Match(icmpv4match.build());
2306 private static MatchBuilder createICMPv6Match() {
2308 final MatchBuilder match = new MatchBuilder();
2309 final EthernetMatchBuilder eth = new EthernetMatchBuilder();
2310 final EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
2311 ethTypeBuilder.setType(new EtherType(Uint32.valueOf(0x86dd)));
2312 eth.setEthernetType(ethTypeBuilder.build());
2313 match.setEthernetMatch(eth.build());
2315 final IpMatchBuilder ipmatch = new IpMatchBuilder(); // ipv4 version
2316 ipmatch.setIpProtocol(Uint8.valueOf(58));
2317 match.setIpMatch(ipmatch.build());
2319 final Icmpv6MatchBuilder icmpv6match = new Icmpv6MatchBuilder(); // icmpv6
2321 icmpv6match.setIcmpv6Type(Uint8.valueOf(135));
2322 icmpv6match.setIcmpv6Code(Uint8.ONE);
2323 match.setIcmpv6Match(icmpv6match.build());
2328 private static MatchBuilder createToSMatch() {
2329 final MatchBuilder match = new MatchBuilder();
2330 final EthernetMatchBuilder ethmatch = new EthernetMatchBuilder();
2331 final EthernetTypeBuilder ethtype = new EthernetTypeBuilder();
2332 final EtherType type = new EtherType(Uint32.valueOf(0x0800));
2333 ethmatch.setEthernetType(ethtype.setType(type).build());
2334 match.setEthernetMatch(ethmatch.build());
2336 final IpMatchBuilder ipmatch = new IpMatchBuilder(); // ipv4 version
2337 ipmatch.setIpProtocol(Uint8.valueOf(6));
2338 final Dscp dscp = new Dscp(Uint8.valueOf(8));
2339 ipmatch.setIpDscp(dscp);
2340 match.setIpMatch(ipmatch.build());
2344 private static MatchBuilder createL4TCPMatch() {
2345 final MatchBuilder match = new MatchBuilder();
2347 final EthernetMatchBuilder eth = new EthernetMatchBuilder();
2348 final EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
2349 ethTypeBuilder.setType(new EtherType(Uint32.valueOf(0x0800)));
2350 eth.setEthernetType(ethTypeBuilder.build());
2351 match.setEthernetMatch(eth.build());
2353 final IpMatchBuilder ipmatch = new IpMatchBuilder(); // ipv4 version
2354 ipmatch.setIpProtocol(Uint8.valueOf(6));
2355 match.setIpMatch(ipmatch.build());
2357 final PortNumber srcport = new PortNumber(Uint16.valueOf(1213));
2358 final PortNumber dstport = new PortNumber(Uint16.valueOf(646));
2359 final TcpMatchBuilder tcpmatch = new TcpMatchBuilder(); // tcp match
2360 tcpmatch.setTcpSourcePort(srcport);
2361 tcpmatch.setTcpDestinationPort(dstport);
2362 match.setLayer4Match(tcpmatch.build());
2367 private static MatchBuilder createL4UDPMatch() {
2368 final MatchBuilder match = new MatchBuilder();
2370 final EthernetMatchBuilder eth = new EthernetMatchBuilder();
2371 final EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
2372 ethTypeBuilder.setType(new EtherType(Uint32.valueOf(0x0800)));
2373 eth.setEthernetType(ethTypeBuilder.build());
2374 match.setEthernetMatch(eth.build());
2376 final IpMatchBuilder ipmatch = new IpMatchBuilder(); // ipv4 version
2377 ipmatch.setIpProtocol(Uint8.valueOf(17));
2378 match.setIpMatch(ipmatch.build());
2380 final PortNumber srcport = new PortNumber(Uint16.valueOf(1325));
2381 final PortNumber dstport = new PortNumber(Uint16.valueOf(42));
2382 final UdpMatchBuilder udpmatch = new UdpMatchBuilder(); // udp match
2383 udpmatch.setUdpDestinationPort(dstport);
2384 udpmatch.setUdpSourcePort(srcport);
2385 match.setLayer4Match(udpmatch.build());
2390 private static MatchBuilder createL4SCTPMatch() {
2391 final MatchBuilder match = new MatchBuilder();
2393 final EthernetMatchBuilder eth = new EthernetMatchBuilder();
2394 final EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
2395 ethTypeBuilder.setType(new EtherType(Uint32.valueOf(0x0800)));
2396 eth.setEthernetType(ethTypeBuilder.build());
2397 match.setEthernetMatch(eth.build());
2399 final IpMatchBuilder ipmatch = new IpMatchBuilder(); // ipv4 version
2400 ipmatch.setIpProtocol(Uint8.valueOf(132));
2401 match.setIpMatch(ipmatch.build());
2403 final SctpMatchBuilder sctpmatch = new SctpMatchBuilder();
2404 final PortNumber srcport = new PortNumber(Uint16.valueOf(1435));
2405 final PortNumber dstport = new PortNumber(Uint16.valueOf(22));
2406 sctpmatch.setSctpSourcePort(srcport);
2407 sctpmatch.setSctpDestinationPort(dstport);
2408 match.setLayer4Match(sctpmatch.build());
2413 private static MatchBuilder createMetadataMatch() {
2414 final MatchBuilder match = new MatchBuilder();
2415 final MetadataBuilder metadata = new MetadataBuilder(); // metadata match
2416 metadata.setMetadata(Uint64.valueOf(500));
2417 metadata.setMetadataMask(Uint64.valueOf(0xFFFFFF00_00000101L));
2418 match.setMetadata(metadata.build());
2423 private static MatchBuilder createMplsMatch() {
2424 final MatchBuilder match = new MatchBuilder();
2426 final EthernetMatchBuilder eth = new EthernetMatchBuilder();
2427 final EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
2428 ethTypeBuilder.setType(new EtherType(Uint32.valueOf(0x8847)));
2429 eth.setEthernetType(ethTypeBuilder.build());
2430 match.setEthernetMatch(eth.build());
2432 final ProtocolMatchFieldsBuilder protomatch = new ProtocolMatchFieldsBuilder(); // mpls
2434 protomatch.setMplsLabel(Uint32.valueOf(36008));
2435 protomatch.setMplsTc(Uint8.valueOf(4));
2436 protomatch.setMplsBos(Uint8.ONE);
2437 match.setProtocolMatchFields(protomatch.build());
2443 private static MatchBuilder createPbbMatch() {
2444 final MatchBuilder match = new MatchBuilder();
2446 final EthernetMatchBuilder eth = new EthernetMatchBuilder();
2447 final EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
2448 ethTypeBuilder.setType(new EtherType(Uint32.valueOf(0x88E7)));
2449 eth.setEthernetType(ethTypeBuilder.build());
2450 match.setEthernetMatch(eth.build());
2452 final ProtocolMatchFieldsBuilder protomatch = new ProtocolMatchFieldsBuilder(); // mpls
2454 protomatch.setPbb(new PbbBuilder().setPbbIsid(Uint32.valueOf(4)).setPbbMask(Uint32.valueOf(0x10000)).build());
2455 match.setProtocolMatchFields(protomatch.build());
2461 private static MatchBuilder createTunnelIDMatch() {
2462 final MatchBuilder match = new MatchBuilder();
2463 final TunnelBuilder tunnel = new TunnelBuilder(); // tunnel id match
2464 tunnel.setTunnelId(Uint64.valueOf(10668));
2465 tunnel.setTunnelMask(Uint64.valueOf(0xFFFFFF00_00000101L));
2466 match.setTunnel(tunnel.build());
2472 * Test match for TCP_Flags.
2474 * @return match containing Ethertype (0x0800), IP Protocol (TCP), TCP_Flag (SYN)
2476 //FIXME: move to extensible support
2477 private static MatchBuilder createTcpFlagMatch() {
2478 final MatchBuilder match = new MatchBuilder();
2481 final EthernetMatchBuilder ethernetType = new EthernetMatchBuilder();
2482 final EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
2483 ethTypeBuilder.setType(new EtherType(Uint32.valueOf(0x0800)));
2484 ethernetType.setEthernetType(ethTypeBuilder.build());
2485 match.setEthernetMatch(ethernetType.build());
2487 // TCP Protocol Match
2488 final IpMatchBuilder ipMatch = new IpMatchBuilder(); // ipv4 version
2489 ipMatch.setIpProtocol(Uint8.valueOf(6));
2490 match.setIpMatch(ipMatch.build());
2493 final PortNumber dstPort = new PortNumber(Uint16.valueOf(80));
2494 final TcpMatchBuilder tcpMatch = new TcpMatchBuilder();
2495 tcpMatch.setTcpDestinationPort(dstPort);
2496 match.setLayer4Match(tcpMatch.build());
2498 * Defined TCP Flag values in OVS v2.1+
2499 * TCP_FIN 0x001 / TCP_SYN 0x002 / TCP_RST 0x004
2500 * TCP_PSH 0x008 / TCP_ACK 0x010 / TCP_URG 0x020
2501 * TCP_ECE 0x040 / TCP_CWR 0x080 / TCP_NS 0x100
2503 final TcpFlagsMatchBuilder tcpFlagsMatch = new TcpFlagsMatchBuilder();
2504 tcpFlagsMatch.setTcpFlags(Uint16.valueOf(0x002));
2505 match.setTcpFlagsMatch(tcpFlagsMatch.build());
2510 @SuppressWarnings("checkstyle:MethodName")
2511 public void _removeMDFlow(final CommandInterpreter ci) {
2512 final ReadWriteTransaction modification = dataBroker.newReadWriteTransaction();
2513 final NodeBuilder tn = createTestNode(ci.nextArgument());
2514 final String flowtype = ci.nextArgument();
2516 if (flowtype.equals("fTM")) {
2517 tf = createtablemiss();
2519 tf = createTestFlow(tn, flowtype, ci.nextArgument());
2521 final InstanceIdentifier<Flow> path1 = InstanceIdentifier.create(Nodes.class).child(Node.class, tn.key())
2522 .augmentation(FlowCapableNode.class).child(Table.class, new TableKey(tf.getTableId()))
2523 .child(Flow.class, tf.key());
2524 modification.delete(LogicalDatastoreType.CONFIGURATION, path1);
2525 modification.commit().addCallback(new FutureCallback<CommitInfo>() {
2527 public void onSuccess(final CommitInfo notUsed) {
2528 ci.println("Status of Group Data Loaded Transaction: success.");
2532 public void onFailure(final Throwable throwable) {
2533 LOG.error("Status of Group Data Loaded Transaction : failure.", throwable);
2534 ci.println(String.format("Status of Group Data Loaded Transaction : failure. Reason : %s", throwable));
2536 }, MoreExecutors.directExecutor());
2542 * @param ci arguments: switchId flowType tableNum, e.g.: addMDFlow openflow:1 f1 42
2544 @SuppressWarnings("checkstyle:MethodName")
2545 public void _addMDFlow(final CommandInterpreter ci) {
2546 final NodeBuilder tn = createTestNode(ci.nextArgument());
2547 final String flowtype = ci.nextArgument();
2549 if (flowtype.equals("fTM")) {
2550 tf = createtablemiss();
2552 tf = createTestFlow(tn, flowtype, ci.nextArgument());
2554 writeFlow(ci, tf, tn);
2557 private void writeFlow(final CommandInterpreter ci, final FlowBuilder flow, final NodeBuilder nodeBuilder) {
2558 final ReadWriteTransaction modification = dataBroker.newReadWriteTransaction();
2559 final InstanceIdentifier<Flow> path1 = InstanceIdentifier.create(Nodes.class)
2560 .child(Node.class, nodeBuilder.key()).augmentation(FlowCapableNode.class)
2561 .child(Table.class, new TableKey(flow.getTableId())).child(Flow.class, flow.key());
2562 modification.mergeParentStructureMerge(LogicalDatastoreType.CONFIGURATION,
2563 nodeBuilderToInstanceId(nodeBuilder), nodeBuilder.build());
2564 modification.mergeParentStructureMerge(LogicalDatastoreType.CONFIGURATION, path1, flow.build());
2565 modification.commit().addCallback(new FutureCallback<CommitInfo>() {
2567 public void onSuccess(final CommitInfo notUsed) {
2568 ci.println("Status of Group Data Loaded Transaction: success.");
2572 public void onFailure(final Throwable throwable) {
2573 LOG.error("Status of Group Data Loaded Transaction : failure.", throwable);
2574 ci.println(String.format("Status of Group Data Loaded Transaction : failure. Reason : %s", throwable));
2576 }, MoreExecutors.directExecutor());
2579 @SuppressWarnings("checkstyle:MethodName")
2580 public void _modifyMDFlow(final CommandInterpreter ci) {
2581 final NodeBuilder tn = createTestNode(ci.nextArgument());
2582 final FlowBuilder tf = createTestFlow(tn, ci.nextArgument(), ci.nextArgument());
2583 tf.setFlowName(UPDATED_FLOW_NAME);
2584 writeFlow(ci, tf, tn);
2585 tf.setFlowName(ORIGINAL_FLOW_NAME);
2586 writeFlow(ci, tf, tn);
2590 public String getHelp() {
2595 * usage testSwitchFlows <numberOfSwitches> <numberOfFlows> <warmup iterations> <Number Of Threads>
2596 * ex: _perfFlowTest 10 5 1 2
2598 @SuppressWarnings("checkstyle:MethodName")
2599 public void _perfFlowTest(final CommandInterpreter ci) {
2601 final String numberOfSwtichesStr = ci.nextArgument();
2602 final String numberOfFlowsStr = ci.nextArgument();
2603 final String warmupIterationsStr = ci.nextArgument();
2604 final String threadCountStr = ci.nextArgument();
2605 final String warmUpStr = ci.nextArgument();
2607 int numberOfSwtiches = 0;
2608 int numberOfFlows = 0;
2609 int warmupIterations = 0;
2610 boolean warmUpIterations = false;
2612 int threadCount = 0;
2613 if (numberOfSwtichesStr != null && !numberOfSwtichesStr.trim().equals("")) {
2614 numberOfSwtiches = Integer.parseInt(numberOfSwtichesStr);
2616 numberOfSwtiches = 2;
2619 if (numberOfFlowsStr != null && !numberOfFlowsStr.trim().equals("")) {
2620 numberOfFlows = Integer.parseInt(numberOfFlowsStr);
2625 if (warmupIterationsStr != null && !warmupIterationsStr.trim().equals("")) {
2626 warmupIterations = Integer.parseInt(warmupIterationsStr);
2628 warmupIterations = 2;
2631 if (threadCountStr != null && !threadCountStr.trim().equals("")) {
2632 threadCount = Integer.parseInt(threadCountStr);
2636 if (warmUpStr != null && !warmUpStr.trim().equals("") && warmUpStr.trim().equals("true")) {
2637 warmUpIterations = true;
2639 warmUpIterations = false;
2641 ci.println("* Test Configurations*");
2642 ci.println("* numberOfSwtiches:::" + numberOfSwtiches + "");
2643 ci.println("* numberOfFlows:::" + numberOfFlows + "");
2644 ci.println("* warmupIterations:::" + warmupIterations + "");
2645 ci.println("* Number of Threads :::" + threadCount + "");
2646 ci.println("* Warmup Required? :::" + warmUpIterations + "");
2648 String dataPath = "openflow:1";
2651 final String tableId = "0";
2652 if (warmUpIterations) {
2653 ci.println("----Warmup Started-----");
2654 for (int j = 1; j <= warmupIterations; j++) {
2655 for (int i = 1; i <= numberOfSwtiches; i++) {
2656 dataPath = "openflow:" + i;
2657 tn = createTestNode(dataPath);
2658 for (int flow = 1; flow < numberOfFlows; flow++) {
2659 tf = createTestFlowPerfTest("f1", tableId, flow);
2660 writeFlow(ci, tf, tn);
2665 ci.println("----Warmup Done-----");
2668 final ExecutorService executor = Executors.newFixedThreadPool(threadCount);
2670 for (int t = 0; t < threadCount; t++) {
2672 final Runnable tRunnable = new TestFlowThread(numberOfSwtiches, numberOfFlows, ci, t, tableID);
2673 executor.execute(tRunnable);
2675 executor.shutdown();
2676 executor.awaitTermination(1, TimeUnit.SECONDS);
2677 } catch (InterruptedException e) {
2678 ci.println("Exception:" + e.getMessage());
2682 public class TestFlowThread implements Runnable {
2684 int numberOfSwitches;
2686 CommandInterpreter ci;
2690 TestFlowThread(final int numberOfSwtiches, final int numberOfFlows, final CommandInterpreter ci,
2691 final int threadNumber, final int tableID) {
2692 numberOfSwitches = numberOfSwtiches;
2693 this.numberOfFlows = numberOfFlows;
2695 theadNumber = threadNumber;
2696 this.tableID = tableID;
2704 public void executeFlow() {
2706 String dataPath = "openflow:1";
2709 //String tableId = "0";
2711 ci.println("New Thread started with id: ID_" + theadNumber);
2712 int totalNumberOfFlows = 0;
2713 final long startTime = System.currentTimeMillis();
2715 for (int i = 1; i <= numberOfSwitches; i++) {
2716 dataPath = "openflow:" + i;
2717 tn = createTestNode(dataPath);
2718 for (int flow2 = 1; flow2 <= numberOfFlows; flow2++) {
2719 tf = createTestFlowPerfTest("f1", "" + tableID, flow2);
2720 writeFlow(ci, tf, tn);
2721 totalNumberOfFlows++;
2724 final long endTime = System.currentTimeMillis();
2725 final long timeInSeconds = Math.round((endTime - startTime) / 1000.0F);
2726 if (timeInSeconds > 0) {
2727 ci.println("Total flows added in Thread:" + theadNumber + ": Flows/Sec::"
2728 + Math.round((float)totalNumberOfFlows / timeInSeconds));
2730 ci.println("Total flows added in Thread:" + theadNumber + ": Flows/Sec::" + totalNumberOfFlows);
2737 * usage testAllFlows <dp>
2738 * ex: _perfFlowTest 1
2740 @SuppressWarnings({ "checkstyle:MethodName", "checkstyle:IllegalCatch" })
2741 public void _testAllFlows(final CommandInterpreter ci) {
2742 String dataPathID = ci.nextArgument();
2743 final int numberOfFlows = 82;
2744 if (dataPathID == null || dataPathID.trim().equals("")) {
2747 ci.println("* Test All Flows *");
2748 ci.println("* dataPathID:::" + dataPathID + "");
2749 final String dataPath = "openflow:" + dataPathID;
2750 final String tableId = "0";
2751 final NodeBuilder tn = createTestNode(dataPath);
2753 for (int flow = 1; flow < numberOfFlows; flow++) {
2754 final String flowID = "f" + flow;
2756 tf = createTestFlow(tn, flowID, tableId);
2757 writeFlow(ci, tf, tn);
2758 } catch (RuntimeException e) {
2759 ci.println("--Test Failed--Issue found while adding flow" + flow);