Use BigInteger.valueOf()
[openflowplugin.git] / test-provider / src / main / java / org / opendaylight / openflowplugin / test / OpenflowpluginTestCommandProvider.java
1 /*
2  * Copyright (c) 2013 Ericsson , Inc. and others.  All rights reserved.
3  *
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
7  */
8
9 package org.opendaylight.openflowplugin.test;
10
11 import com.google.common.util.concurrent.CheckedFuture;
12 import com.google.common.util.concurrent.FutureCallback;
13 import com.google.common.util.concurrent.Futures;
14 import java.math.BigInteger;
15 import java.util.ArrayList;
16 import java.util.Collection;
17 import java.util.List;
18 import java.util.concurrent.ExecutorService;
19 import java.util.concurrent.Executors;
20 import java.util.concurrent.TimeUnit;
21 import org.eclipse.osgi.framework.console.CommandInterpreter;
22 import org.eclipse.osgi.framework.console.CommandProvider;
23 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
24 import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
25 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
26 import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
27 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
28 import org.opendaylight.controller.sal.binding.api.NotificationService;
29 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Dscp;
30 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Prefix;
31 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6Address;
32 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6FlowLabel;
33 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6Prefix;
34 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber;
35 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Uri;
36 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress;
37 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.VlanCfi;
38 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.ControllerActionCaseBuilder;
39 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.CopyTtlInCaseBuilder;
40 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.CopyTtlOutCaseBuilder;
41 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DecMplsTtlCaseBuilder;
42 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DecNwTtlCaseBuilder;
43 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DropActionCaseBuilder;
44 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.FloodActionCaseBuilder;
45 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.FloodAllActionCaseBuilder;
46 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.GroupActionCaseBuilder;
47 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.HwPathActionCaseBuilder;
48 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.LoopbackActionCaseBuilder;
49 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.OutputActionCaseBuilder;
50 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopMplsActionCaseBuilder;
51 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopPbbActionCaseBuilder;
52 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopVlanActionCaseBuilder;
53 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushMplsActionCaseBuilder;
54 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushPbbActionCaseBuilder;
55 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushVlanActionCaseBuilder;
56 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetDlDstActionCaseBuilder;
57 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetDlSrcActionCaseBuilder;
58 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetDlTypeActionCaseBuilder;
59 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetFieldCaseBuilder;
60 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetMplsTtlActionCaseBuilder;
61 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNextHopActionCaseBuilder;
62 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwDstActionCaseBuilder;
63 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwSrcActionCaseBuilder;
64 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwTosActionCaseBuilder;
65 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwTtlActionCaseBuilder;
66 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetQueueActionCaseBuilder;
67 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetTpDstActionCaseBuilder;
68 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetTpSrcActionCaseBuilder;
69 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetVlanCfiActionCaseBuilder;
70 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetVlanIdActionCaseBuilder;
71 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetVlanPcpActionCaseBuilder;
72 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.StripVlanActionCaseBuilder;
73 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SwPathActionCaseBuilder;
74 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.controller.action._case.ControllerActionBuilder;
75 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.copy.ttl.in._case.CopyTtlInBuilder;
76 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.copy.ttl.out._case.CopyTtlOutBuilder;
77 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.dec.mpls.ttl._case.DecMplsTtlBuilder;
78 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.dec.nw.ttl._case.DecNwTtl;
79 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.dec.nw.ttl._case.DecNwTtlBuilder;
80 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.drop.action._case.DropAction;
81 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.drop.action._case.DropActionBuilder;
82 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.flood.action._case.FloodActionBuilder;
83 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.flood.all.action._case.FloodAllActionBuilder;
84 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.group.action._case.GroupActionBuilder;
85 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.hw.path.action._case.HwPathActionBuilder;
86 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.loopback.action._case.LoopbackActionBuilder;
87 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.output.action._case.OutputActionBuilder;
88 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.pop.mpls.action._case.PopMplsActionBuilder;
89 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.pop.pbb.action._case.PopPbbActionBuilder;
90 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.pop.vlan.action._case.PopVlanActionBuilder;
91 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.push.mpls.action._case.PushMplsActionBuilder;
92 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.push.pbb.action._case.PushPbbActionBuilder;
93 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.push.vlan.action._case.PushVlanActionBuilder;
94 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.dl.dst.action._case.SetDlDstActionBuilder;
95 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.dl.src.action._case.SetDlSrcActionBuilder;
96 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.dl.type.action._case.SetDlTypeActionBuilder;
97 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.field._case.SetFieldBuilder;
98 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.mpls.ttl.action._case.SetMplsTtlActionBuilder;
99 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.next.hop.action._case.SetNextHopActionBuilder;
100 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.dst.action._case.SetNwDstActionBuilder;
101 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.src.action._case.SetNwSrcActionBuilder;
102 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.tos.action._case.SetNwTosActionBuilder;
103 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.ttl.action._case.SetNwTtlActionBuilder;
104 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.queue.action._case.SetQueueActionBuilder;
105 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.tp.dst.action._case.SetTpDstActionBuilder;
106 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.tp.src.action._case.SetTpSrcActionBuilder;
107 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.vlan.cfi.action._case.SetVlanCfiActionBuilder;
108 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.vlan.id.action._case.SetVlanIdActionBuilder;
109 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.vlan.pcp.action._case.SetVlanPcpActionBuilder;
110 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.strip.vlan.action._case.StripVlanActionBuilder;
111 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.sw.path.action._case.SwPathActionBuilder;
112 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action;
113 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder;
114 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionKey;
115 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.address.Ipv4Builder;
116 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
117 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId;
118 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table;
119 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey;
120 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow;
121 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder;
122 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey;
123 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.SalFlowListener;
124 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowCookie;
125 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowModFlags;
126 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.OutputPortValues;
127 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.InstructionsBuilder;
128 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
129 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ApplyActionsCaseBuilder;
130 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.GoToTableCaseBuilder;
131 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.MeterCaseBuilder;
132 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.WriteMetadataCaseBuilder;
133 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.apply.actions._case.ApplyActionsBuilder;
134 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.go.to.table._case.GoToTableBuilder;
135 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.meter._case.MeterBuilder;
136 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.write.metadata._case.WriteMetadataBuilder;
137 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction;
138 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionBuilder;
139 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionKey;
140 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId;
141 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
142 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef;
143 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
144 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
145 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeBuilder;
146 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
147 import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.EtherType;
148 import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanId;
149 import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanPcp;
150 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterId;
151 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.arp.match.fields.ArpSourceHardwareAddressBuilder;
152 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.arp.match.fields.ArpTargetHardwareAddressBuilder;
153 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetDestinationBuilder;
154 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetSourceBuilder;
155 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetTypeBuilder;
156 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ipv6.match.fields.Ipv6ExtHeaderBuilder;
157 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ipv6.match.fields.Ipv6LabelBuilder;
158 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatchBuilder;
159 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Icmpv4MatchBuilder;
160 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Icmpv6MatchBuilder;
161 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.IpMatchBuilder;
162 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.MetadataBuilder;
163 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.ProtocolMatchFieldsBuilder;
164 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.TcpFlagMatchBuilder;
165 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.TunnelBuilder;
166 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.VlanMatchBuilder;
167 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.ArpMatchBuilder;
168 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4Match;
169 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4MatchBuilder;
170 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6MatchBuilder;
171 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.TunnelIpv4MatchBuilder;
172 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.SctpMatchBuilder;
173 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.TcpMatchBuilder;
174 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.UdpMatchBuilder;
175 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.protocol.match.fields.PbbBuilder;
176 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.vlan.match.fields.VlanIdBuilder;
177 import org.opendaylight.yang.gen.v1.urn.opendaylight.node.error.service.rev140410.NodeErrorListener;
178 import org.opendaylight.yangtools.concepts.Registration;
179 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
180 import org.osgi.framework.BundleContext;
181 import org.slf4j.Logger;
182 import org.slf4j.LoggerFactory;
183
184 public class OpenflowpluginTestCommandProvider implements CommandProvider {
185
186     private static final Logger LOG = LoggerFactory.getLogger(OpenflowpluginTestCommandProvider.class);
187
188     private DataBroker dataBroker;
189     private final BundleContext ctx;
190     private FlowBuilder testFlow;
191     private static final String ORIGINAL_FLOW_NAME = "Foo";
192     private static final String UPDATED_FLOW_NAME = "Bar";
193     private static final String IPV4_PREFIX = "10.0.0.1/24";
194     private static final String DEST_MAC_ADDRESS = "ff:ff:ff:ff:ff:ff";
195     private static final String SRC_MAC_ADDRESS = "00:00:00:00:23:ae";
196     private final SalFlowListener flowEventListener = new FlowEventListenerLoggingImpl();
197     private final NodeErrorListener nodeErrorListener = new NodeErrorListenerLoggingImpl();
198     private static NotificationService notificationService;
199
200     public OpenflowpluginTestCommandProvider(BundleContext ctx) {
201         this.ctx = ctx;
202     }
203
204     public void onSessionInitiated(ProviderContext session) {
205         notificationService = session.getSALService(NotificationService.class);
206         // For switch events
207         notificationService.registerNotificationListener(flowEventListener);
208         notificationService.registerNotificationListener(nodeErrorListener);
209         dataBroker = session.getSALService(DataBroker.class);
210         ctx.registerService(CommandProvider.class.getName(), this, null);
211         createTestFlow(createTestNode(null), null, null);
212     }
213
214     private NodeBuilder createTestNode(String nodeId) {
215         String localNodeId;
216         
217         if (nodeId == null) {
218             localNodeId = OpenflowpluginTestActivator.NODE_ID;
219         } else {
220             localNodeId = nodeId;
221         }
222         
223         NodeBuilder builder = new NodeBuilder();
224         builder.setId(new NodeId(localNodeId));
225         builder.setKey(new NodeKey(builder.getId()));
226         return builder;
227     }
228
229     private InstanceIdentifier<Node> nodeBuilderToInstanceId(NodeBuilder node) {
230         return InstanceIdentifier.create(Nodes.class).child(Node.class, node.getKey());
231     }
232
233     private FlowBuilder createTestFlow(NodeBuilder nodeBuilder, String flowTypeArg, String tableId) {
234         final long TEST_ID = 123;
235         
236         FlowBuilder flow = new FlowBuilder();
237         long id = TEST_ID;
238
239         String flowType = flowTypeArg;
240         if (flowType == null) {
241             flowType = "f1";
242         }
243
244         flow.setPriority(2);
245
246         switch (flowType) {
247             case "f1":
248                 id += 1;
249                 flow.setMatch(createMatch1().build());
250                 flow.setInstructions(createDecNwTtlInstructions().build());
251                 break;
252             case "f2":
253                 id += 2;
254                 flow.setMatch(createMatch2().build());
255                 flow.setInstructions(createDropInstructions().build());
256                 break;
257             case "f3":
258                 id += 3;
259                 flow.setMatch(createMatch3().build());
260                 flow.setInstructions(createDropInstructions().build());
261                 break;
262             case "f4":
263                 id += 4;
264                 flow.setMatch(createEthernetMatch().build());
265                 flow.setInstructions(createDropInstructions().build());
266                 break;
267             case "f5":
268                 id += 5;
269                 flow.setMatch(createMatch1().build());
270                 flow.setInstructions(createAppyActionInstruction().build());
271                 break;
272             case "f6":
273                 id += 6;
274                 flow.setMatch(createMatch1().build());
275                 flow.setInstructions(createGotoTableInstructions().build());
276                 break;
277             case "f7":
278                 id += 7;
279                 flow.setMatch(createMatch1().build());
280                 flow.setInstructions(createMeterInstructions().build());
281                 break;
282             case "f8":
283                 id += 8;
284                 flow.setMatch(createMatch1().build());
285                 flow.setInstructions(createAppyActionInstruction1().build());
286                 break;
287             case "f9":
288                 id += 9;
289                 flow.setMatch(createMatch1().build());
290                 flow.setInstructions(createAppyActionInstruction2().build());
291                 break;
292             case "f10":
293                 id += 10;
294                 flow.setMatch(createMatch1().build());
295                 flow.setInstructions(createAppyActionInstruction3().build());
296                 break;
297             case "f11":
298                 id += 11;
299                 flow.setMatch(createMatch1().build());
300                 flow.setInstructions(createAppyActionInstruction4().build());
301                 break;
302             case "f12":
303                 id += 12;
304                 flow.setMatch(createMatch1().build());
305                 flow.setInstructions(createAppyActionInstruction5().build());
306                 break;
307             case "f13":
308                 id += 13;
309                 flow.setMatch(createMatch1().build());
310                 flow.setInstructions(createAppyActionInstruction6().build());
311                 break;
312             case "f14":
313                 id += 14;
314                 flow.setMatch(createMatch1().build());
315                 flow.setInstructions(createAppyActionInstruction7().build());
316                 break;
317             case "f15":
318                 id += 15;
319                 flow.setMatch(createMatch1().build());
320                 flow.setInstructions(createAppyActionInstruction8().build());
321                 break;
322             case "f16":
323                 id += 16;
324                 flow.setMatch(createMatch1().build());
325                 flow.setInstructions(createAppyActionInstruction9().build());
326                 break;
327             case "f17":
328                 id += 17;
329                 flow.setMatch(createMatch1().build());
330                 flow.setInstructions(createAppyActionInstruction10().build());
331                 break;
332             case "f18":
333                 id += 18;
334                 flow.setMatch(createMatch1().build());
335                 flow.setInstructions(createAppyActionInstruction11().build());
336                 break;
337             case "f19":
338                 id += 19;
339                 flow.setMatch(createMatch1().build());
340                 flow.setInstructions(createAppyActionInstruction12().build());
341                 break;
342             case "f20":
343                 id += 20;
344                 flow.setMatch(createMatch1().build());
345                 flow.setInstructions(createAppyActionInstruction13().build());
346                 break;
347             case "f21":
348                 id += 21;
349                 flow.setMatch(createMatch1().build());
350                 flow.setInstructions(createAppyActionInstruction14().build());
351                 break;
352             case "f22":
353                 id += 22;
354                 flow.setMatch(createMatch1().build());
355                 flow.setInstructions(createAppyActionInstruction15().build());
356                 break;
357             case "f23":
358                 id += 23;
359                 // f23 can be used as test-case for generating error notification
360                 // if the particular group is not configured - tested
361                 flow.setMatch(createMatch1().build());
362                 flow.setInstructions(createAppyActionInstruction16().build());
363                 break;
364             case "f24":
365                 id += 24;
366                 flow.setMatch(createMatch1().build());
367                 flow.setInstructions(createAppyActionInstruction17().build());
368                 break;
369             case "f25":
370                 id += 25;
371                 flow.setMatch(createMatch1().build());
372                 flow.setInstructions(createAppyActionInstruction18().build());
373                 break;
374             case "f26":
375                 id += 26;
376                 flow.setMatch(createMatch1().build());
377                 flow.setInstructions(createAppyActionInstruction19().build());
378                 break;
379             case "f27":
380                 id += 27;
381                 flow.setMatch(createMatch1().build());
382                 flow.setInstructions(createMetadataInstructions().build());
383                 break;
384             case "f28":
385                 id += 28;
386                 flow.setMatch(createMatch1().build());
387                 flow.setInstructions(createAppyActionInstruction20().build());
388                 break;
389             case "f29":
390                 id += 29;
391                 flow.setMatch(createMatch1().build());
392                 flow.setInstructions(createAppyActionInstruction21().build());
393                 break;
394             case "f30":
395                 id += 30;
396                 flow.setMatch(createMatch1().build());
397                 flow.setInstructions(createAppyActionInstruction22().build());
398                 break;
399             case "f31":
400                 id += 31;
401                 flow.setMatch(createMatch1().build());
402                 flow.setInstructions(createAppyActionInstruction23(nodeBuilder.getId()).build());
403                 break;
404             case "f32":
405                 id += 32;
406                 flow.setMatch(createMatch1().build());
407                 flow.setInstructions(createAppyActionInstruction24().build());
408                 break;
409             case "f33":
410                 id += 33;
411                 flow.setMatch(createMatch1().build());
412                 flow.setInstructions(createAppyActionInstruction25().build());
413                 break;
414             case "f34":
415                 id += 34;
416                 flow.setMatch(createMatch1().build());
417                 flow.setInstructions(createAppyActionInstruction26().build());
418                 break;
419             case "f35":
420                 id += 35;
421                 flow.setMatch(createMatch1().build());
422                 flow.setInstructions(createAppyActionInstruction27().build());
423                 break;
424             case "f36":
425                 id += 36;
426                 flow.setMatch(createMatch1().build());
427                 flow.setInstructions(createAppyActionInstruction28().build());
428                 break;
429             case "f37":
430                 id += 37;
431                 flow.setMatch(createMatch1().build());
432                 flow.setInstructions(createAppyActionInstruction29().build());
433                 break;
434             case "f38":
435                 id += 38;
436                 flow.setMatch(createMatch1().build());
437                 flow.setInstructions(createAppyActionInstruction30().build());
438                 break;
439             case "f39":
440                 id += 39;
441                 flow.setMatch(createMatch1().build());
442                 flow.setInstructions(createAppyActionInstruction31().build());
443                 break;
444             case "f40":
445                 id += 40;
446                 flow.setMatch(createMatch1().build());
447                 flow.setInstructions(createAppyActionInstruction32().build());
448                 break;
449             case "f41":
450                 id += 41;
451                 flow.setMatch(createMatch1().build());
452                 flow.setInstructions(createAppyActionInstruction33().build());
453                 break;
454             case "f42":
455                 id += 42;
456                 flow.setMatch(createMatch1().build());
457                 flow.setInstructions(createAppyActionInstruction34().build());
458                 break;
459             case "f43":
460                 id += 43;
461                 flow.setMatch(createICMPv6Match().build());
462                 flow.setInstructions(createDecNwTtlInstructions().build());
463                 break;
464             case "f44":
465                 id += 44;
466                 flow.setMatch(createInphyportMatch(nodeBuilder.getId()).build());
467                 flow.setInstructions(createDropInstructions().build());
468                 break;
469             case "f45":
470                 id += 45;
471                 flow.setMatch(createMetadataMatch().build());
472                 flow.setInstructions(createDropInstructions().build());
473                 break;
474             case "f46":
475                 id += 46;
476                 flow.setMatch(createL3IPv6Match().build());
477                 flow.setInstructions(createDecNwTtlInstructions().build());
478                 break;
479             case "f47":
480                 id += 47;
481                 flow.setMatch(createL4SCTPMatch().build());
482                 flow.setInstructions(createAppyActionInstruction().build());
483                 break;
484             case "f48":
485                 id += 48;
486                 flow.setMatch(createTunnelIDMatch().build());
487                 flow.setInstructions(createGotoTableInstructions().build());
488                 break;
489             case "f49":
490                 id += 49;
491                 flow.setMatch(createVlanMatch().build());
492                 flow.setInstructions(createMeterInstructions().build());
493                 break;
494             case "f50":
495                 id += 50;
496                 flow.setMatch(createPbbMatch().build());
497                 flow.setInstructions(createMeterInstructions().build());
498                 break;
499             case "f51":
500                 id += 51;
501                 flow.setMatch(createVlanMatch().build());
502                 flow.setInstructions(createDropInstructions().build());
503                 break;
504             case "f52":
505                 id += 52;
506                 flow.setMatch(createL4TCPMatch().build());
507                 flow.setInstructions(createDropInstructions().build());
508                 break;
509
510             case "f53":
511                 id += 53;
512                 flow.setMatch(createL4UDPMatch().build());
513                 flow.setInstructions(createDropInstructions().build());
514                 break;
515             case "f54":
516                 id += 54;
517                 flow.setMatch(new MatchBuilder().build());
518                 flow.setInstructions(createSentToControllerInstructions().build());
519                 flow.setPriority(0);
520                 break;
521             case "f55":
522                 id += 55;
523                 flow.setMatch(createToSMatch().build());
524                 flow.setInstructions(createDropInstructions().build());
525                 break;
526             case "f56":
527                 id += 56;
528                 flow.setMatch(createToSMatch().build());
529                 flow.setInstructions(createOutputInstructions("INPORT", 10).build());
530                 break;
531             case "f57":
532                 id += 57;
533                 flow.setMatch(createToSMatch().build());
534                 flow.setInstructions(createOutputInstructions("FLOOD", 20).build());
535                 break;
536             case "f58":
537                 id += 58;
538                 flow.setMatch(createToSMatch().build());
539                 flow.setInstructions(createOutputInstructions("ALL", 30).build());
540                 break;
541             case "f59":
542                 id += 59;
543                 flow.setMatch(createToSMatch().build());
544                 flow.setInstructions(createOutputInstructions("NORMAL", 40).build());
545                 break;
546             case "f60":
547                 id += 60;
548                 flow.setMatch(createToSMatch().build());
549                 flow.setInstructions(createOutputInstructions("LOCAL", 50).build());
550                 break;
551             case "f61":
552                 id += 61;
553                 flow.setMatch(createToSMatch().build());
554                 flow.setInstructions(createOutputInstructions("TABLE", 60).build());
555                 break;
556             case "f62":
557                 id += 62;
558                 flow.setMatch(createToSMatch().build());
559                 flow.setInstructions(createOutputInstructions("NONE", 70).build());
560                 break;
561             case "f63":
562                 id += 63;
563                 flow.setMatch(createToSMatch().build());
564                 flow.setInstructions(createStripVlanInstructions().build());
565                 flow.setBarrier(Boolean.TRUE);
566                 break;
567             case "f64":
568                 id += 64;
569                 flow.setMatch(createMatch1().build());
570                 flow.setInstructions(createAppyActionInstruction35().build());
571                 break;
572             case "f65":
573                 id += 65;
574                 flow.setMatch(createMatch1().build());
575                 flow.setInstructions(createAppyActionInstruction36().build());
576                 break;
577             case "f66":
578                 id += 66;
579                 flow.setMatch(createMatch1().build());
580                 flow.setInstructions(createAppyActionInstruction37().build());
581                 break;
582             case "f67":
583                 id += 67;
584                 flow.setMatch(createMatch1().build());
585                 flow.setInstructions(createAppyActionInstruction38().build());
586                 break;
587             case "f68":
588                 id += 68;
589                 flow.setMatch(createL4TCPMatch().build());
590                 flow.setInstructions(createAppyActionInstruction39().build());
591                 break;
592             case "f69":
593                 id += 69;
594                 flow.setMatch(createL4UDPMatch().build());
595                 flow.setInstructions(createAppyActionInstruction40().build());
596                 break;
597             case "f70":
598                 id += 70;
599                 flow.setMatch(createL4SCTPMatch().build());
600                 flow.setInstructions(createAppyActionInstruction41().build());
601                 break;
602             case "f71":
603                 id += 71;
604                 flow.setMatch(createICMPv4Match().build());
605                 flow.setInstructions(createAppyActionInstruction42().build());
606                 break;
607             case "f72":
608                 id += 72;
609                 flow.setMatch(createArpMatch().build());
610                 flow.setInstructions(createAppyActionInstruction43().build());
611                 break;
612             case "f73":
613                 id += 73;
614                 flow.setMatch(createL3IPv6Match().build());
615                 flow.setInstructions(createAppyActionInstruction44().build());
616                 break;
617             case "f74":
618                 id += 74;
619                 flow.setMatch(createICMPv6Match().build());
620                 flow.setInstructions(createAppyActionInstruction45().build());
621                 break;
622             case "f75":
623                 id += 75;
624                 flow.setMatch(createMplsMatch().build());
625                 flow.setInstructions(createAppyActionInstruction46().build());
626                 break;
627             case "f76":
628                 id += 76;
629                 flow.setMatch(createPbbMatch().build());
630                 flow.setInstructions(createAppyActionInstruction47().build());
631                 break;
632             case "f77":
633                 id += 77;
634                 flow.setMatch(createTunnelIDMatch().build());
635                 flow.setInstructions(createAppyActionInstruction48().build());
636                 break;
637             case "f78":
638                 id += 78;
639                 flow.setMatch(createMatch33().build());
640                 flow.setInstructions(createDropInstructions().build());
641                 break;
642             case "f79":
643                 id += 79;
644                 flow.setMatch(createICMPv6Match1().build());
645                 flow.setInstructions(createDecNwTtlInstructions().build());
646                 break;
647             case "f80":
648                 id += 80;
649                 flow.setMatch(createVlanMatch().build());
650                 flow.setInstructions(createAppyActionInstruction88().build());
651                 break;
652             case "f81":
653                 id += 81;
654                 flow.setMatch(createLLDPMatch().build());
655                 flow.setInstructions(createSentToControllerInstructions().build());
656                 break;
657             case "f82":
658                 id += 82;
659                 flow.setMatch(createToSMatch().build());
660                 flow.setInstructions(createOutputInstructions().build());
661                 break;
662             case "f83":
663                 // Test TCP_Flag Match
664                 id += 83; 
665                 flow.setMatch(createTcpFlagMatch().build());
666                 flow.setInstructions(createDropInstructions().build());
667                 break;
668             case "f84":
669                 id += 84;
670                 // match vlan=10,dl_vlan_pcp=3
671                 flow.setMatch(createVlanMatch().build()); 
672                 // vlan_pcp=4
673                 flow.setInstructions(createAppyActionInstruction88().build()); 
674                 break;
675             case "f85":
676                 // Test Tunnel IPv4 Src (e.g. set_field:172.16.100.200->tun_src)
677                 id += 85; 
678                 flow.setMatch(createMatch3().build());
679                 flow.setInstructions(createTunnelIpv4SrcInstructions().build());
680                 break;
681             case "f86":
682                 // Test Tunnel IPv4 Dst (e.g. set_field:172.16.100.100->tun_dst)
683                 id += 86; 
684                 flow.setMatch(createMatch1().build());
685                 flow.setInstructions(createTunnelIpv4DstInstructions().build());
686                 break;
687             default:
688                 LOG.warn("flow type not understood: {}", flowType);
689         }
690
691         FlowKey key = new FlowKey(new FlowId(Long.toString(id)));
692         if (null == flow.isBarrier()) {
693             flow.setBarrier(Boolean.FALSE);
694         }
695         BigInteger value = BigInteger.valueOf(10);
696         flow.setCookie(new FlowCookie(value));
697         flow.setCookieMask(new FlowCookie(value));
698         flow.setHardTimeout(0);
699         flow.setIdleTimeout(0);
700         flow.setInstallHw(false);
701         flow.setStrict(false);
702         flow.setContainerName(null);
703         flow.setFlags(new FlowModFlags(false, false, false, false, true));
704         flow.setId(new FlowId("12"));
705         flow.setTableId(getTableId(tableId));
706
707         flow.setKey(key);
708         flow.setFlowName(ORIGINAL_FLOW_NAME + "X" + flowType);
709         testFlow = flow;
710         return flow;
711     }
712
713
714     private FlowBuilder createTestFlowPerfTest(String flowTypeArg, String tableId, int id) {
715         FlowBuilder flow = new FlowBuilder();
716         String flowType = flowTypeArg;
717         int flowId = id;
718         
719         if (flowType == null) {
720             flowType = "f1";
721         }
722
723         flow.setPriority(flowId);
724
725         switch (flowType) {
726             case "f1":
727                 flowId += 1;
728                 flow.setMatch(createMatch1().build());
729                 flow.setInstructions(createDecNwTtlInstructions().build());
730                 break;
731             default:
732                 LOG.warn("flow type not understood: {}", flowType);
733         }
734
735         FlowKey key = new FlowKey(new FlowId(Long.toString(flowId)));
736         if (null == flow.isBarrier()) {
737             flow.setBarrier(Boolean.FALSE);
738         }
739         BigInteger value = BigInteger.valueOf(10);
740         flow.setCookie(new FlowCookie(value));
741         flow.setCookieMask(new FlowCookie(value));
742         flow.setHardTimeout(0);
743         flow.setIdleTimeout(0);
744         flow.setInstallHw(false);
745         flow.setStrict(false);
746         flow.setContainerName(null);
747         flow.setFlags(new FlowModFlags(false, false, false, false, true));
748         flow.setId(new FlowId("12"));
749         flow.setTableId(getTableId(tableId));
750
751         flow.setKey(key);
752         flow.setFlowName(ORIGINAL_FLOW_NAME + "X" + flowType);
753         testFlow = flow;
754         return flow;
755     }
756
757     private FlowBuilder createtablemiss() {
758         FlowBuilder flow = new FlowBuilder();
759         long id = 456;
760         MatchBuilder matchBuilder = new MatchBuilder();
761         flow.setMatch(matchBuilder.build());
762         flow.setInstructions(createSentToControllerInstructions().build());
763         flow.setPriority(0);
764         flow.setTableId((short) 0);
765         FlowKey key = new FlowKey(new FlowId(Long.toString(id)));
766         flow.setKey(key);
767         testFlow = flow;
768         return flow;
769     }
770
771     private short getTableId(String tableId) {
772         final short TABLE_ID = 2;
773         short table = TABLE_ID;
774         try {
775             table = Short.parseShort(tableId);
776         } catch (Exception ex) {
777             LOG.info("Parsing String tableId {} failed. Continuing with default tableId {}.", 
778                     tableId, table);
779         }
780         return table;
781     }
782
783     /**
784      * @return
785      */
786     private static InstructionsBuilder createDecNwTtlInstructions() {
787         DecNwTtlBuilder ta = new DecNwTtlBuilder();
788         DecNwTtl decNwTtl = ta.build();
789         ActionBuilder ab = new ActionBuilder();
790         ab.setAction(new DecNwTtlCaseBuilder().setDecNwTtl(decNwTtl).build());
791         ab.setKey(new ActionKey(0));
792         // Add our drop action to a list
793         List<Action> actionList = new ArrayList<Action>();
794         actionList.add(ab.build());
795
796         // Create an Apply Action
797         ApplyActionsBuilder aab = new ApplyActionsBuilder();
798         aab.setAction(actionList);
799
800         // Wrap our Apply Action in an Instruction
801         InstructionBuilder ib = new InstructionBuilder();
802         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
803         ib.setKey(new InstructionKey(0));
804         ib.setOrder(0);
805
806         // Put our Instruction in a list of Instructions
807         InstructionsBuilder isb = new InstructionsBuilder();
808         List<Instruction> instructions = new ArrayList<Instruction>();
809         instructions.add(ib.build());
810         ib.setKey(new InstructionKey(0));
811         isb.setInstruction(instructions);
812         return isb;
813     }
814
815     /**
816      * @return
817      */
818     private static InstructionsBuilder createMeterInstructions() {
819
820         MeterBuilder aab = new MeterBuilder();
821         aab.setMeterId(new MeterId(new Long(1)));
822
823         InstructionBuilder ib = new InstructionBuilder();
824         ib.setInstruction(new MeterCaseBuilder().setMeter(aab.build()).build());
825
826         // Put our Instruction in a list of Instructions
827         InstructionsBuilder isb = new InstructionsBuilder();
828         List<Instruction> instructions = new ArrayList<Instruction>();
829         ib.setKey(new InstructionKey(0));
830         instructions.add(ib.build());
831         isb.setInstruction(instructions);
832         return isb;
833     }
834
835     private static InstructionsBuilder createMetadataInstructions() {
836
837         WriteMetadataBuilder aab = new WriteMetadataBuilder();
838         aab.setMetadata(BigInteger.valueOf(10));
839         aab.setMetadataMask(BigInteger.valueOf(10));
840
841         InstructionBuilder ib = new InstructionBuilder();
842         ib.setInstruction(new WriteMetadataCaseBuilder().setWriteMetadata(aab.build()).build());
843
844         // Put our Instruction in a list of Instructions
845         InstructionsBuilder isb = new InstructionsBuilder();
846         List<Instruction> instructions = new ArrayList<Instruction>();
847         ib.setKey(new InstructionKey(0));
848         instructions.add(ib.build());
849         isb.setInstruction(instructions);
850         return isb;
851     }
852
853     private static InstructionsBuilder createGotoTableInstructions() {
854
855         GoToTableBuilder aab = new GoToTableBuilder();
856         aab.setTableId((short) 5);
857
858         InstructionBuilder ib = new InstructionBuilder();
859         ib.setInstruction(new GoToTableCaseBuilder().setGoToTable(aab.build()).build());
860
861         // Put our Instruction in a list of Instructions
862         InstructionsBuilder isb = new InstructionsBuilder();
863         List<Instruction> instructions = new ArrayList<Instruction>();
864         ib.setKey(new InstructionKey(0));
865         instructions.add(ib.build());
866         isb.setInstruction(instructions);
867         return isb;
868     }
869
870     private static InstructionsBuilder createDropInstructions() {
871         DropActionBuilder dab = new DropActionBuilder();
872         DropAction dropAction = dab.build();
873         ActionBuilder ab = new ActionBuilder();
874         ab.setAction(new DropActionCaseBuilder().setDropAction(dropAction).build());
875         ab.setKey(new ActionKey(0));
876         // Add our drop action to a list
877         List<Action> actionList = new ArrayList<Action>();
878         actionList.add(ab.build());
879         ab.setKey(new ActionKey(0));
880         // Create an Apply Action
881         ApplyActionsBuilder aab = new ApplyActionsBuilder();
882         aab.setAction(actionList);
883
884         // Wrap our Apply Action in an Instruction
885         InstructionBuilder ib = new InstructionBuilder();
886         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
887
888         // Put our Instruction in a list of Instructions
889         InstructionsBuilder isb = new InstructionsBuilder();
890         List<Instruction> instructions = new ArrayList<Instruction>();
891         ib.setKey(new InstructionKey(0));
892         instructions.add(ib.build());
893         isb.setInstruction(instructions);
894         return isb;
895     }
896
897     private static InstructionsBuilder createAppyActionInstruction() {
898
899         List<Action> actionList = new ArrayList<Action>();
900         ActionBuilder ab = new ActionBuilder();
901         ControllerActionBuilder controller = new ControllerActionBuilder();
902         controller.setMaxLength(5);
903         ab.setAction(new ControllerActionCaseBuilder().setControllerAction(controller.build()).build());
904         ab.setKey(new ActionKey(0));
905         actionList.add(ab.build());
906         // Create an Apply Action
907         ApplyActionsBuilder aab = new ApplyActionsBuilder();
908         aab.setAction(actionList);
909
910         // Wrap our Apply Action in an Instruction
911         InstructionBuilder ib = new InstructionBuilder();
912         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
913
914         // Put our Instruction in a list of Instructions
915         InstructionsBuilder isb = new InstructionsBuilder();
916         List<Instruction> instructions = new ArrayList<Instruction>();
917         ib.setKey(new InstructionKey(0));
918         instructions.add(ib.build());
919         isb.setInstruction(instructions);
920         return isb;
921     }
922
923     private static InstructionsBuilder createAppyActionInstruction1() {
924
925         List<Action> actionList = new ArrayList<Action>();
926         ActionBuilder ab = new ActionBuilder();
927
928         OutputActionBuilder output = new OutputActionBuilder();
929         output.setMaxLength(56);
930         Uri value = new Uri("PCEP");
931         output.setOutputNodeConnector(value);
932         ab.setAction(new OutputActionCaseBuilder().setOutputAction(output.build()).build());
933         ab.setKey(new ActionKey(0));
934         actionList.add(ab.build());
935         // Create an Apply Action
936         ApplyActionsBuilder aab = new ApplyActionsBuilder();
937         aab.setAction(actionList);
938
939         // Wrap our Apply Action in an Instruction
940         InstructionBuilder ib = new InstructionBuilder();
941         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
942
943         // Put our Instruction in a list of Instructions
944         InstructionsBuilder isb = new InstructionsBuilder();
945         List<Instruction> instructions = new ArrayList<Instruction>();
946         ib.setKey(new InstructionKey(0));
947         instructions.add(ib.build());
948         isb.setInstruction(instructions);
949         return isb;
950     }
951
952     private static InstructionsBuilder createOutputInstructions() {
953
954         // test case for Output Port works if the particular port exists
955         // this particular test-case is for Port : 1
956         // tested as (addMDFlow openflow:<dpid> f82)
957         List<Action> actionList = new ArrayList<Action>();
958         ActionBuilder ab = new ActionBuilder();
959         OutputActionBuilder output = new OutputActionBuilder();
960
961         Uri value = new Uri("1");
962         output.setOutputNodeConnector(value);
963         ab.setAction(new OutputActionCaseBuilder().setOutputAction(output.build()).build());
964         ab.setOrder(0);
965         ab.setKey(new ActionKey(0));
966         actionList.add(ab.build());
967         // Create an Apply Action
968         ApplyActionsBuilder aab = new ApplyActionsBuilder();
969         aab.setAction(actionList);
970
971         // Wrap our Apply Action in an Instruction
972         InstructionBuilder ib = new InstructionBuilder();
973         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
974         ib.setOrder(0);
975         ib.setKey(new InstructionKey(0));
976
977         // Put our Instruction in a list of Instructions
978         InstructionsBuilder isb = new InstructionsBuilder();
979         List<Instruction> instructions = new ArrayList<Instruction>();
980         instructions.add(ib.build());
981         isb.setInstruction(instructions);
982         return isb;
983     }
984
985     private static InstructionsBuilder createSentToControllerInstructions() {
986         List<Action> actionList = new ArrayList<Action>();
987         ActionBuilder ab = new ActionBuilder();
988
989         OutputActionBuilder output = new OutputActionBuilder();
990         output.setMaxLength(Integer.valueOf(0xffff));
991         Uri value = new Uri(OutputPortValues.CONTROLLER.toString());
992         output.setOutputNodeConnector(value);
993         ab.setAction(new OutputActionCaseBuilder().setOutputAction(output.build()).build());
994         ab.setOrder(0);
995         ab.setKey(new ActionKey(0));
996         actionList.add(ab.build());
997         // Create an Apply Action
998         ApplyActionsBuilder aab = new ApplyActionsBuilder();
999         aab.setAction(actionList);
1000
1001         // Wrap our Apply Action in an Instruction
1002         InstructionBuilder ib = new InstructionBuilder();
1003         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1004         ib.setOrder(0);
1005         ib.setKey(new InstructionKey(0));
1006
1007         // Put our Instruction in a list of Instructions
1008         InstructionsBuilder isb = new InstructionsBuilder();
1009         List<Instruction> instructions = new ArrayList<Instruction>();
1010         instructions.add(ib.build());
1011         isb.setInstruction(instructions);
1012         return isb;
1013     }
1014
1015     private static InstructionsBuilder createOutputInstructions(String outputType, int outputValue) {
1016         List<Action> actionList = new ArrayList<Action>();
1017         ActionBuilder ab = new ActionBuilder();
1018
1019         OutputActionBuilder output = new OutputActionBuilder();
1020         output.setMaxLength(outputValue);
1021         Uri value = new Uri(outputType);
1022         output.setOutputNodeConnector(value);
1023         ab.setAction(new OutputActionCaseBuilder().setOutputAction(output.build()).build());
1024         ab.setOrder(0);
1025         ab.setKey(new ActionKey(0));
1026         actionList.add(ab.build());
1027         // Create an Apply Action
1028         ApplyActionsBuilder aab = new ApplyActionsBuilder();
1029         aab.setAction(actionList);
1030
1031         // Wrap our Apply Action in an Instruction
1032         InstructionBuilder ib = new InstructionBuilder();
1033         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1034         ib.setOrder(0);
1035         ib.setKey(new InstructionKey(0));
1036
1037         // Put our Instruction in a list of Instructions
1038         InstructionsBuilder isb = new InstructionsBuilder();
1039         List<Instruction> instructions = new ArrayList<Instruction>();
1040         instructions.add(ib.build());
1041         isb.setInstruction(instructions);
1042         return isb;
1043     }
1044
1045     private static InstructionsBuilder createStripVlanInstructions() {
1046         List<Action> actionList = new ArrayList<Action>();
1047         ActionBuilder ab = new ActionBuilder();
1048
1049         StripVlanActionBuilder stripActionBuilder = new StripVlanActionBuilder();
1050         ab.setAction(new StripVlanActionCaseBuilder().setStripVlanAction(stripActionBuilder.build()).build());
1051         ab.setOrder(0);
1052         ab.setKey(new ActionKey(0));
1053         actionList.add(ab.build());
1054         // Create an Apply Action
1055         ApplyActionsBuilder aab = new ApplyActionsBuilder();
1056         aab.setAction(actionList);
1057
1058         // Wrap our Apply Action in an Instruction
1059         InstructionBuilder ib = new InstructionBuilder();
1060         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1061         ib.setOrder(0);
1062         ib.setKey(new InstructionKey(0));
1063
1064         // Put our Instruction in a list of Instructions
1065         InstructionsBuilder isb = new InstructionsBuilder();
1066         List<Instruction> instructions = new ArrayList<Instruction>();
1067         instructions.add(ib.build());
1068         isb.setInstruction(instructions);
1069         return isb;
1070     }
1071
1072     private static InstructionsBuilder createAppyActionInstruction2() {
1073
1074         List<Action> actionList = new ArrayList<Action>();
1075         ActionBuilder ab = new ActionBuilder();
1076
1077         PushMplsActionBuilder push = new PushMplsActionBuilder();
1078         push.setEthernetType(Integer.valueOf(0x8847));
1079         ab.setAction(new PushMplsActionCaseBuilder().setPushMplsAction(push.build()).build());
1080         ab.setKey(new ActionKey(0));
1081         actionList.add(ab.build());
1082         // Create an Apply Action
1083         ApplyActionsBuilder aab = new ApplyActionsBuilder();
1084         aab.setAction(actionList);
1085
1086         // Wrap our Apply Action in an Instruction
1087         InstructionBuilder ib = new InstructionBuilder();
1088         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1089
1090         // Put our Instruction in a list of Instructions
1091         InstructionsBuilder isb = new InstructionsBuilder();
1092         List<Instruction> instructions = new ArrayList<Instruction>();
1093         ib.setKey(new InstructionKey(0));
1094         instructions.add(ib.build());
1095         isb.setInstruction(instructions);
1096         return isb;
1097     }
1098
1099     private static InstructionsBuilder createAppyActionInstruction3() {
1100
1101         List<Action> actionList = new ArrayList<Action>();
1102         ActionBuilder ab = new ActionBuilder();
1103
1104         PushPbbActionBuilder pbb = new PushPbbActionBuilder();
1105         pbb.setEthernetType(Integer.valueOf(0x88E7));
1106         ab.setAction(new PushPbbActionCaseBuilder().setPushPbbAction(pbb.build()).build());
1107         ab.setKey(new ActionKey(0));
1108         actionList.add(ab.build());
1109         // Create an Apply Action
1110         ApplyActionsBuilder aab = new ApplyActionsBuilder();
1111         aab.setAction(actionList);
1112
1113         // Wrap our Apply Action in an Instruction
1114         InstructionBuilder ib = new InstructionBuilder();
1115         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1116
1117         // Put our Instruction in a list of Instructions
1118         InstructionsBuilder isb = new InstructionsBuilder();
1119         List<Instruction> instructions = new ArrayList<Instruction>();
1120         ib.setKey(new InstructionKey(0));
1121         instructions.add(ib.build());
1122         isb.setInstruction(instructions);
1123         return isb;
1124     }
1125
1126     private static InstructionsBuilder createAppyActionInstruction4() {
1127
1128         List<Action> actionList = new ArrayList<Action>();
1129         ActionBuilder ab = new ActionBuilder();
1130
1131         PushVlanActionBuilder vlan = new PushVlanActionBuilder();
1132         vlan.setEthernetType(Integer.valueOf(0x8100));
1133         ab.setAction(new PushVlanActionCaseBuilder().setPushVlanAction(vlan.build()).build());
1134         ab.setKey(new ActionKey(0));
1135         actionList.add(ab.build());
1136
1137         // Create an Apply Action
1138         ApplyActionsBuilder aab = new ApplyActionsBuilder();
1139         aab.setAction(actionList);
1140
1141         // Wrap our Apply Action in an Instruction
1142         InstructionBuilder ib = new InstructionBuilder();
1143         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1144
1145         // Put our Instruction in a list of Instructions
1146         InstructionsBuilder isb = new InstructionsBuilder();
1147         List<Instruction> instructions = new ArrayList<Instruction>();
1148         ib.setKey(new InstructionKey(0));
1149         instructions.add(ib.build());
1150         isb.setInstruction(instructions);
1151         return isb;
1152     }
1153
1154     private static InstructionsBuilder createAppyActionInstruction5() {
1155
1156         List<Action> actionList = new ArrayList<Action>();
1157         ActionBuilder ab = new ActionBuilder();
1158
1159         SetDlDstActionBuilder setdl = new SetDlDstActionBuilder();
1160         setdl.setAddress(new MacAddress("00:05:b9:7c:81:5f"));
1161         ab.setAction(new SetDlDstActionCaseBuilder().setSetDlDstAction(setdl.build()).build());
1162         ab.setKey(new ActionKey(0));
1163         actionList.add(ab.build());
1164         // Create an Apply Action
1165         ApplyActionsBuilder aab = new ApplyActionsBuilder();
1166         aab.setAction(actionList);
1167
1168         // Wrap our Apply Action in an Instruction
1169         InstructionBuilder ib = new InstructionBuilder();
1170         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1171
1172         // Put our Instruction in a list of Instructions
1173         InstructionsBuilder isb = new InstructionsBuilder();
1174         List<Instruction> instructions = new ArrayList<Instruction>();
1175         ib.setKey(new InstructionKey(0));
1176         instructions.add(ib.build());
1177         isb.setInstruction(instructions);
1178         return isb;
1179     }
1180
1181     private static InstructionsBuilder createAppyActionInstruction6() {
1182
1183         List<Action> actionList = new ArrayList<Action>();
1184         ActionBuilder ab = new ActionBuilder();
1185
1186         SetDlSrcActionBuilder src = new SetDlSrcActionBuilder();
1187         src.setAddress(new MacAddress("00:05:b9:7c:81:5f"));
1188         ab.setAction(new SetDlSrcActionCaseBuilder().setSetDlSrcAction(src.build()).build());
1189         ab.setKey(new ActionKey(0));
1190         actionList.add(ab.build());
1191
1192         // Create an Apply Action
1193         ApplyActionsBuilder aab = new ApplyActionsBuilder();
1194         aab.setAction(actionList);
1195
1196         // Wrap our Apply Action in an Instruction
1197         InstructionBuilder ib = new InstructionBuilder();
1198         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1199
1200         // Put our Instruction in a list of Instructions
1201         InstructionsBuilder isb = new InstructionsBuilder();
1202         List<Instruction> instructions = new ArrayList<Instruction>();
1203         ib.setKey(new InstructionKey(0));
1204         instructions.add(ib.build());
1205         isb.setInstruction(instructions);
1206         return isb;
1207     }
1208
1209     private static InstructionsBuilder createAppyActionInstruction7() {
1210
1211         List<Action> actionList = new ArrayList<Action>();
1212         ActionBuilder ab = new ActionBuilder();
1213
1214         SetVlanIdActionBuilder vl = new SetVlanIdActionBuilder();
1215         VlanId a = new VlanId(4000);
1216         vl.setVlanId(a);
1217         ab.setAction(new SetVlanIdActionCaseBuilder().setSetVlanIdAction(vl.build()).build());
1218         ab.setKey(new ActionKey(0));
1219         actionList.add(ab.build());
1220         // Create an Apply Action
1221         ApplyActionsBuilder aab = new ApplyActionsBuilder();
1222         aab.setAction(actionList);
1223
1224         // Wrap our Apply Action in an Instruction
1225         InstructionBuilder ib = new InstructionBuilder();
1226         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1227
1228         // Put our Instruction in a list of Instructions
1229         InstructionsBuilder isb = new InstructionsBuilder();
1230         List<Instruction> instructions = new ArrayList<Instruction>();
1231         ib.setKey(new InstructionKey(0));
1232         instructions.add(ib.build());
1233         isb.setInstruction(instructions);
1234         return isb;
1235     }
1236
1237     private static InstructionsBuilder createAppyActionInstruction8() {
1238
1239         List<Action> actionList = new ArrayList<Action>();
1240         ActionBuilder ab = new ActionBuilder();
1241
1242         SetVlanPcpActionBuilder pcp = new SetVlanPcpActionBuilder();
1243         VlanPcp pcp1 = new VlanPcp((short) 2);
1244         pcp.setVlanPcp(pcp1);
1245         ab.setAction(new SetVlanPcpActionCaseBuilder().setSetVlanPcpAction(pcp.build()).build());
1246         ab.setKey(new ActionKey(0));
1247         actionList.add(ab.build());
1248         // Create an Apply Action
1249         ApplyActionsBuilder aab = new ApplyActionsBuilder();
1250         aab.setAction(actionList);
1251
1252         // Wrap our Apply Action in an Instruction
1253         InstructionBuilder ib = new InstructionBuilder();
1254         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1255
1256         // Put our Instruction in a list of Instructions
1257         InstructionsBuilder isb = new InstructionsBuilder();
1258         List<Instruction> instructions = new ArrayList<Instruction>();
1259         ib.setKey(new InstructionKey(0));
1260         instructions.add(ib.build());
1261         isb.setInstruction(instructions);
1262         return isb;
1263     }
1264
1265     private static InstructionsBuilder createAppyActionInstruction88() {
1266
1267         List<Action> actionList = new ArrayList<Action>();
1268         ActionBuilder ab = new ActionBuilder();
1269
1270         SetVlanPcpActionBuilder pcp = new SetVlanPcpActionBuilder();
1271         // the code point is a 3-bit(0-7) field representing the frame priority level
1272         VlanPcp pcp1 = new VlanPcp((short) 4);
1273         pcp.setVlanPcp(pcp1);
1274         ab.setAction(new SetVlanPcpActionCaseBuilder().setSetVlanPcpAction(pcp.build()).build());
1275         ab.setKey(new ActionKey(0));
1276         actionList.add(ab.build());
1277         // Create an Apply Action
1278         ApplyActionsBuilder aab = new ApplyActionsBuilder();
1279         aab.setAction(actionList);
1280
1281         // Wrap our Apply Action in an Instruction
1282         InstructionBuilder ib = new InstructionBuilder();
1283         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1284
1285         // Put our Instruction in a list of Instructions
1286         InstructionsBuilder isb = new InstructionsBuilder();
1287         List<Instruction> instructions = new ArrayList<Instruction>();
1288         ib.setKey(new InstructionKey(0));
1289         instructions.add(ib.build());
1290         isb.setInstruction(instructions);
1291         return isb;
1292     }
1293
1294     private static InstructionsBuilder createAppyActionInstruction9() {
1295
1296         List<Action> actionList = new ArrayList<Action>();
1297         ActionBuilder ab = new ActionBuilder();
1298
1299         CopyTtlInBuilder ttlin = new CopyTtlInBuilder();
1300         ab.setAction(new CopyTtlInCaseBuilder().setCopyTtlIn(ttlin.build()).build());
1301         ab.setKey(new ActionKey(0));
1302         actionList.add(ab.build());
1303         // Create an Apply Action
1304         ApplyActionsBuilder aab = new ApplyActionsBuilder();
1305         aab.setAction(actionList);
1306
1307         // Wrap our Apply Action in an Instruction
1308         InstructionBuilder ib = new InstructionBuilder();
1309         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1310
1311         // Put our Instruction in a list of Instructions
1312         InstructionsBuilder isb = new InstructionsBuilder();
1313         List<Instruction> instructions = new ArrayList<Instruction>();
1314         ib.setKey(new InstructionKey(0));
1315         instructions.add(ib.build());
1316         isb.setInstruction(instructions);
1317         return isb;
1318     }
1319
1320     private static InstructionsBuilder createAppyActionInstruction10() {
1321
1322         List<Action> actionList = new ArrayList<Action>();
1323         ActionBuilder ab = new ActionBuilder();
1324
1325         CopyTtlOutBuilder ttlout = new CopyTtlOutBuilder();
1326         ab.setAction(new CopyTtlOutCaseBuilder().setCopyTtlOut(ttlout.build()).build());
1327         ab.setKey(new ActionKey(0));
1328         actionList.add(ab.build());
1329         // Create an Apply Action
1330         ApplyActionsBuilder aab = new ApplyActionsBuilder();
1331         aab.setAction(actionList);
1332
1333         // Wrap our Apply Action in an Instruction
1334         InstructionBuilder ib = new InstructionBuilder();
1335         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1336
1337         // Put our Instruction in a list of Instructions
1338         InstructionsBuilder isb = new InstructionsBuilder();
1339         List<Instruction> instructions = new ArrayList<Instruction>();
1340         ib.setKey(new InstructionKey(0));
1341         instructions.add(ib.build());
1342         isb.setInstruction(instructions);
1343         return isb;
1344     }
1345
1346     private static InstructionsBuilder createAppyActionInstruction11() {
1347
1348         List<Action> actionList = new ArrayList<Action>();
1349         ActionBuilder ab = new ActionBuilder();
1350
1351         DecMplsTtlBuilder mpls = new DecMplsTtlBuilder();
1352         ab.setAction(new DecMplsTtlCaseBuilder().setDecMplsTtl(mpls.build()).build());
1353         ab.setKey(new ActionKey(0));
1354         actionList.add(ab.build());
1355         // Create an Apply Action
1356         ApplyActionsBuilder aab = new ApplyActionsBuilder();
1357         aab.setAction(actionList);
1358
1359         // Wrap our Apply Action in an Instruction
1360         InstructionBuilder ib = new InstructionBuilder();
1361         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1362         ib.setKey(new InstructionKey(0));
1363         ib.setOrder(0);
1364
1365         // Put our Instruction in a list of Instruction
1366         InstructionsBuilder isb = new InstructionsBuilder();
1367         List<Instruction> instructions = new ArrayList<Instruction>();
1368         instructions.add(ib.build());
1369         isb.setInstruction(instructions);
1370         return isb;
1371     }
1372
1373     private static InstructionsBuilder createAppyActionInstruction12() {
1374
1375         List<Action> actionList = new ArrayList<Action>();
1376         ActionBuilder ab = new ActionBuilder();
1377
1378         DecNwTtlBuilder nwttl = new DecNwTtlBuilder();
1379         ab.setAction(new DecNwTtlCaseBuilder().setDecNwTtl(nwttl.build()).build());
1380         ab.setKey(new ActionKey(0));
1381         actionList.add(ab.build());
1382
1383         // Create an Apply Action
1384         ApplyActionsBuilder aab = new ApplyActionsBuilder();
1385         aab.setAction(actionList);
1386
1387         // Wrap our Apply Action in an Instruction
1388         InstructionBuilder ib = new InstructionBuilder();
1389         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1390
1391         // Put our Instruction in a list of Instructions
1392         InstructionsBuilder isb = new InstructionsBuilder();
1393         List<Instruction> instructions = new ArrayList<Instruction>();
1394         ib.setKey(new InstructionKey(0));
1395         instructions.add(ib.build());
1396         isb.setInstruction(instructions);
1397         return isb;
1398     }
1399
1400     private static InstructionsBuilder createAppyActionInstruction13() {
1401
1402         List<Action> actionList = new ArrayList<Action>();
1403         ActionBuilder ab = new ActionBuilder();
1404
1405         DropActionBuilder drop = new DropActionBuilder();
1406         ab.setAction(new DropActionCaseBuilder().setDropAction(drop.build()).build());
1407         ab.setKey(new ActionKey(0));
1408         actionList.add(ab.build());
1409
1410         // Create an Apply Action
1411         ApplyActionsBuilder aab = new ApplyActionsBuilder();
1412         aab.setAction(actionList);
1413
1414         // Wrap our Apply Action in an Instruction
1415         InstructionBuilder ib = new InstructionBuilder();
1416         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1417
1418         // Put our Instruction in a list of Instructions
1419         InstructionsBuilder isb = new InstructionsBuilder();
1420         List<Instruction> instructions = new ArrayList<Instruction>();
1421         ib.setKey(new InstructionKey(0));
1422         instructions.add(ib.build());
1423         isb.setInstruction(instructions);
1424         return isb;
1425     }
1426
1427     private static InstructionsBuilder createAppyActionInstruction14() {
1428
1429         List<Action> actionList = new ArrayList<Action>();
1430         ActionBuilder ab = new ActionBuilder();
1431
1432         FloodActionBuilder fld = new FloodActionBuilder();
1433         ab.setAction(new FloodActionCaseBuilder().setFloodAction(fld.build()).build());
1434         ab.setKey(new ActionKey(0));
1435         actionList.add(ab.build());
1436         // Create an Apply Action
1437         ApplyActionsBuilder aab = new ApplyActionsBuilder();
1438         aab.setAction(actionList);
1439
1440         // Wrap our Apply Action in an Instruction
1441         InstructionBuilder ib = new InstructionBuilder();
1442         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1443
1444         // Put our Instruction in a list of Instructions
1445         InstructionsBuilder isb = new InstructionsBuilder();
1446         List<Instruction> instructions = new ArrayList<Instruction>();
1447         ib.setKey(new InstructionKey(0));
1448         instructions.add(ib.build());
1449         isb.setInstruction(instructions);
1450         return isb;
1451     }
1452
1453     private static InstructionsBuilder createAppyActionInstruction15() {
1454
1455         List<Action> actionList = new ArrayList<Action>();
1456         ActionBuilder ab = new ActionBuilder();
1457
1458         FloodAllActionBuilder fldall = new FloodAllActionBuilder();
1459         ab.setAction(new FloodAllActionCaseBuilder().setFloodAllAction(fldall.build()).build());
1460         ab.setKey(new ActionKey(0));
1461         actionList.add(ab.build());
1462         // Create an Apply Action
1463         ApplyActionsBuilder aab = new ApplyActionsBuilder();
1464         aab.setAction(actionList);
1465
1466         // Wrap our Apply Action in an Instruction
1467         InstructionBuilder ib = new InstructionBuilder();
1468         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1469
1470         // Put our Instruction in a list of Instructions
1471         InstructionsBuilder isb = new InstructionsBuilder();
1472         List<Instruction> instructions = new ArrayList<Instruction>();
1473         ib.setKey(new InstructionKey(0));
1474         instructions.add(ib.build());
1475         isb.setInstruction(instructions);
1476         return isb;
1477     }
1478
1479     private static InstructionsBuilder createAppyActionInstruction16() {
1480
1481         List<Action> actionList = new ArrayList<Action>();
1482         ActionBuilder ab = new ActionBuilder();
1483
1484         GroupActionBuilder groupActionB = new GroupActionBuilder();
1485         groupActionB.setGroupId(1L);
1486         groupActionB.setGroup("0");
1487         ab.setAction(new GroupActionCaseBuilder().setGroupAction(groupActionB.build()).build());
1488         ab.setKey(new ActionKey(0));
1489         actionList.add(ab.build());
1490
1491         // Create an Apply Action
1492         ApplyActionsBuilder aab = new ApplyActionsBuilder();
1493         aab.setAction(actionList);
1494
1495         // Wrap our Apply Action in an Instruction
1496         InstructionBuilder ib = new InstructionBuilder();
1497         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1498
1499         // Put our Instruction in a list of Instructions
1500         InstructionsBuilder isb = new InstructionsBuilder();
1501         List<Instruction> instructions = new ArrayList<Instruction>();
1502         ib.setKey(new InstructionKey(0));
1503         instructions.add(ib.build());
1504         isb.setInstruction(instructions);
1505         return isb;
1506     }
1507
1508     private static InstructionsBuilder createAppyActionInstruction17() {
1509
1510         List<Action> actionList = new ArrayList<Action>();
1511         ActionBuilder ab = new ActionBuilder();
1512
1513         HwPathActionBuilder hwPathB = new HwPathActionBuilder();
1514         ab.setAction(new HwPathActionCaseBuilder().setHwPathAction(hwPathB.build()).build());
1515         ab.setKey(new ActionKey(0));
1516         actionList.add(ab.build());
1517         // Create an Apply Action
1518         ApplyActionsBuilder aab = new ApplyActionsBuilder();
1519         aab.setAction(actionList);
1520
1521         // Wrap our Apply Action in an Instruction
1522         InstructionBuilder ib = new InstructionBuilder();
1523         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1524
1525         // Put our Instruction in a list of Instructions
1526         InstructionsBuilder isb = new InstructionsBuilder();
1527         List<Instruction> instructions = new ArrayList<Instruction>();
1528         ib.setKey(new InstructionKey(0));
1529         instructions.add(ib.build());
1530         isb.setInstruction(instructions);
1531         return isb;
1532     }
1533
1534     private static InstructionsBuilder createAppyActionInstruction18() {
1535
1536         List<Action> actionList = new ArrayList<Action>();
1537         ActionBuilder ab = new ActionBuilder();
1538
1539         LoopbackActionBuilder loopbackActionBuilder = new LoopbackActionBuilder();
1540         ab.setAction(new LoopbackActionCaseBuilder().setLoopbackAction(loopbackActionBuilder.build()).build());
1541         ab.setKey(new ActionKey(0));
1542         actionList.add(ab.build());
1543
1544         // Create an Apply Action
1545         ApplyActionsBuilder aab = new ApplyActionsBuilder();
1546         aab.setAction(actionList);
1547
1548         // Wrap our Apply Action in an Instruction
1549         InstructionBuilder ib = new InstructionBuilder();
1550         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1551
1552         // Put our Instruction in a list of Instructions
1553         InstructionsBuilder isb = new InstructionsBuilder();
1554         List<Instruction> instructions = new ArrayList<Instruction>();
1555         ib.setKey(new InstructionKey(0));
1556         instructions.add(ib.build());
1557         isb.setInstruction(instructions);
1558         return isb;
1559     }
1560
1561     private static InstructionsBuilder createAppyActionInstruction19() {
1562
1563         List<Action> actionList = new ArrayList<Action>();
1564         ActionBuilder ab = new ActionBuilder();
1565
1566         PopMplsActionBuilder popMplsActionBuilder = new PopMplsActionBuilder();
1567         popMplsActionBuilder.setEthernetType(0XB);
1568         ab.setAction(new PopMplsActionCaseBuilder().setPopMplsAction(popMplsActionBuilder.build()).build());
1569         ab.setKey(new ActionKey(0));
1570         actionList.add(ab.build());
1571         // Create an Apply Action
1572         ApplyActionsBuilder aab = new ApplyActionsBuilder();
1573         aab.setAction(actionList);
1574
1575         // Wrap our Apply Action in an Instruction
1576         InstructionBuilder ib = new InstructionBuilder();
1577         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1578
1579         // Put our Instruction in a list of Instructions
1580         InstructionsBuilder isb = new InstructionsBuilder();
1581         List<Instruction> instructions = new ArrayList<Instruction>();
1582         ib.setKey(new InstructionKey(0));
1583         instructions.add(ib.build());
1584         isb.setInstruction(instructions);
1585         return isb;
1586     }
1587
1588     private static InstructionsBuilder createAppyActionInstruction20() {
1589
1590         List<Action> actionList = new ArrayList<Action>();
1591         ActionBuilder ab = new ActionBuilder();
1592
1593         PopPbbActionBuilder popPbbActionBuilder = new PopPbbActionBuilder();
1594         ab.setAction(new PopPbbActionCaseBuilder().setPopPbbAction(popPbbActionBuilder.build()).build());
1595         ab.setKey(new ActionKey(0));
1596         actionList.add(ab.build());
1597         // Create an Apply Action
1598         ApplyActionsBuilder aab = new ApplyActionsBuilder();
1599         aab.setAction(actionList);
1600
1601         // Wrap our Apply Action in an Instruction
1602         InstructionBuilder ib = new InstructionBuilder();
1603         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1604
1605         // Put our Instruction in a list of Instructions
1606         InstructionsBuilder isb = new InstructionsBuilder();
1607         List<Instruction> instructions = new ArrayList<Instruction>();
1608         ib.setKey(new InstructionKey(0));
1609         instructions.add(ib.build());
1610         isb.setInstruction(instructions);
1611         return isb;
1612     }
1613
1614     private static InstructionsBuilder createAppyActionInstruction21() {
1615
1616         List<Action> actionList = new ArrayList<Action>();
1617         ActionBuilder ab = new ActionBuilder();
1618
1619         PopVlanActionBuilder popVlanActionBuilder = new PopVlanActionBuilder();
1620         ab.setAction(new PopVlanActionCaseBuilder().setPopVlanAction(popVlanActionBuilder.build()).build());
1621         ab.setKey(new ActionKey(0));
1622         actionList.add(ab.build());
1623
1624         // Create an Apply Action
1625         ApplyActionsBuilder aab = new ApplyActionsBuilder();
1626         aab.setAction(actionList);
1627
1628         // Wrap our Apply Action in an Instruction
1629         InstructionBuilder ib = new InstructionBuilder();
1630         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1631
1632         // Put our Instruction in a list of Instructions
1633         InstructionsBuilder isb = new InstructionsBuilder();
1634         List<Instruction> instructions = new ArrayList<Instruction>();
1635         ib.setKey(new InstructionKey(0));
1636         instructions.add(ib.build());
1637         isb.setInstruction(instructions);
1638         return isb;
1639     }
1640
1641     private static InstructionsBuilder createAppyActionInstruction22() {
1642
1643         List<Action> actionList = new ArrayList<Action>();
1644         ActionBuilder ab = new ActionBuilder();
1645
1646         SetDlTypeActionBuilder setDlTypeActionBuilder = new SetDlTypeActionBuilder();
1647         setDlTypeActionBuilder.setDlType(new EtherType(8L));
1648         ab.setAction(new SetDlTypeActionCaseBuilder().setSetDlTypeAction(setDlTypeActionBuilder.build()).build());
1649         ab.setKey(new ActionKey(0));
1650         actionList.add(ab.build());
1651
1652         // Create an Apply Action
1653         ApplyActionsBuilder aab = new ApplyActionsBuilder();
1654         aab.setAction(actionList);
1655
1656         // Wrap our Apply Action in an Instruction
1657         InstructionBuilder ib = new InstructionBuilder();
1658         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1659
1660         // Put our Instruction in a list of Instructions
1661         InstructionsBuilder isb = new InstructionsBuilder();
1662         List<Instruction> instructions = new ArrayList<Instruction>();
1663         ib.setKey(new InstructionKey(0));
1664         instructions.add(ib.build());
1665         isb.setInstruction(instructions);
1666         return isb;
1667     }
1668
1669     private static InstructionsBuilder createAppyActionInstruction23(NodeId nodeId) {
1670
1671         List<Action> actionList = new ArrayList<Action>();
1672         ActionBuilder ab = new ActionBuilder();
1673
1674         SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
1675         setFieldBuilder.setInPort(new NodeConnectorId(nodeId + ":2"));
1676         ab.setKey(new ActionKey(0));
1677         actionList.add(ab.build());
1678
1679         // Create an Apply Action
1680         ApplyActionsBuilder aab = new ApplyActionsBuilder();
1681         aab.setAction(actionList);
1682
1683         // Wrap our Apply Action in an Instruction
1684         InstructionBuilder ib = new InstructionBuilder();
1685         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1686
1687         // Put our Instruction in a list of Instructions
1688         InstructionsBuilder isb = new InstructionsBuilder();
1689         List<Instruction> instructions = new ArrayList<Instruction>();
1690         ib.setKey(new InstructionKey(0));
1691         instructions.add(ib.build());
1692         isb.setInstruction(instructions);
1693         return isb;
1694     }
1695
1696     private static InstructionsBuilder createAppyActionInstruction24() {
1697
1698         List<Action> actionList = new ArrayList<Action>();
1699         ActionBuilder ab = new ActionBuilder();
1700
1701         SetMplsTtlActionBuilder setMplsTtlActionBuilder = new SetMplsTtlActionBuilder();
1702         setMplsTtlActionBuilder.setMplsTtl((short) 0X1);
1703         ab.setAction(new SetMplsTtlActionCaseBuilder().setSetMplsTtlAction(setMplsTtlActionBuilder.build()).build());
1704         ab.setKey(new ActionKey(0));
1705         actionList.add(ab.build());
1706
1707         // Create an Apply Action
1708         ApplyActionsBuilder aab = new ApplyActionsBuilder();
1709         aab.setAction(actionList);
1710
1711         // Wrap our Apply Action in an Instruction
1712         InstructionBuilder ib = new InstructionBuilder();
1713         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1714
1715         // Put our Instruction in a list of Instructions
1716         InstructionsBuilder isb = new InstructionsBuilder();
1717         List<Instruction> instructions = new ArrayList<Instruction>();
1718         ib.setKey(new InstructionKey(0));
1719         instructions.add(ib.build());
1720         isb.setInstruction(instructions);
1721         return isb;
1722     }
1723
1724     private static InstructionsBuilder createAppyActionInstruction25() {
1725
1726         List<Action> actionList = new ArrayList<Action>();
1727         ActionBuilder ab = new ActionBuilder();
1728
1729         SetNextHopActionBuilder setNextHopActionBuilder = new SetNextHopActionBuilder();
1730         Ipv4Builder ipnext = new Ipv4Builder();
1731         Ipv4Prefix prefix = new Ipv4Prefix(IPV4_PREFIX);
1732         ipnext.setIpv4Address(prefix);
1733         setNextHopActionBuilder.setAddress(ipnext.build());
1734         ab.setAction(new SetNextHopActionCaseBuilder().setSetNextHopAction(setNextHopActionBuilder.build()).build());
1735         ab.setKey(new ActionKey(0));
1736         actionList.add(ab.build());
1737
1738         // Create an Apply Action
1739         ApplyActionsBuilder aab = new ApplyActionsBuilder();
1740         aab.setAction(actionList);
1741
1742         // Wrap our Apply Action in an Instruction
1743         InstructionBuilder ib = new InstructionBuilder();
1744         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1745
1746         // Put our Instruction in a list of Instructions
1747         InstructionsBuilder isb = new InstructionsBuilder();
1748         List<Instruction> instructions = new ArrayList<Instruction>();
1749         ib.setKey(new InstructionKey(0));
1750         instructions.add(ib.build());
1751         isb.setInstruction(instructions);
1752         return isb;
1753     }
1754
1755     private static InstructionsBuilder createAppyActionInstruction26() {
1756
1757         List<Action> actionList = new ArrayList<Action>();
1758         ActionBuilder ab = new ActionBuilder();
1759
1760         SetNwDstActionBuilder setNwDstActionBuilder = new SetNwDstActionBuilder();
1761         Ipv4Builder ipdst = new Ipv4Builder();
1762         Ipv4Prefix prefixdst = new Ipv4Prefix("10.0.0.21/24");
1763         ipdst.setIpv4Address(prefixdst);
1764         setNwDstActionBuilder.setAddress(ipdst.build());
1765         ab.setAction(new SetNwDstActionCaseBuilder().setSetNwDstAction(setNwDstActionBuilder.build()).build());
1766         ab.setKey(new ActionKey(0));
1767         actionList.add(ab.build());
1768
1769         // Create an Apply Action
1770         ApplyActionsBuilder aab = new ApplyActionsBuilder();
1771         aab.setAction(actionList);
1772
1773         // Wrap our Apply Action in an Instruction
1774         InstructionBuilder ib = new InstructionBuilder();
1775         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1776
1777         // Put our Instruction in a list of Instructions
1778         InstructionsBuilder isb = new InstructionsBuilder();
1779         List<Instruction> instructions = new ArrayList<Instruction>();
1780         ib.setKey(new InstructionKey(0));
1781         instructions.add(ib.build());
1782         isb.setInstruction(instructions);
1783         return isb;
1784     }
1785
1786     private static InstructionsBuilder createAppyActionInstruction27() {
1787
1788         List<Action> actionList = new ArrayList<Action>();
1789         ActionBuilder ab = new ActionBuilder();
1790
1791         SetNwSrcActionBuilder setNwsrcActionBuilder = new SetNwSrcActionBuilder();
1792         Ipv4Builder ipsrc = new Ipv4Builder();
1793         Ipv4Prefix prefixsrc = new Ipv4Prefix("10.0.23.21/24");
1794         ipsrc.setIpv4Address(prefixsrc);
1795         setNwsrcActionBuilder.setAddress(ipsrc.build());
1796         ab.setAction(new SetNwSrcActionCaseBuilder().setSetNwSrcAction(setNwsrcActionBuilder.build()).build());
1797         ab.setKey(new ActionKey(0));
1798         actionList.add(ab.build());
1799
1800         // Create an Apply Action
1801         ApplyActionsBuilder aab = new ApplyActionsBuilder();
1802         aab.setAction(actionList);
1803
1804         // Wrap our Apply Action in an Instruction
1805         InstructionBuilder ib = new InstructionBuilder();
1806         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1807
1808         // Put our Instruction in a list of Instructions
1809         InstructionsBuilder isb = new InstructionsBuilder();
1810         List<Instruction> instructions = new ArrayList<Instruction>();
1811         ib.setKey(new InstructionKey(0));
1812         instructions.add(ib.build());
1813         isb.setInstruction(instructions);
1814         return isb;
1815     }
1816
1817     private static InstructionsBuilder createAppyActionInstruction28() {
1818
1819         List<Action> actionList = new ArrayList<Action>();
1820         ActionBuilder ab = new ActionBuilder();
1821
1822         SetNwTosActionBuilder setNwTosActionBuilder = new SetNwTosActionBuilder();
1823         setNwTosActionBuilder.setTos(8);
1824         ab.setAction(new SetNwTosActionCaseBuilder().setSetNwTosAction(setNwTosActionBuilder.build()).build());
1825         ab.setKey(new ActionKey(0));
1826         actionList.add(ab.build());
1827         // Create an Apply Action
1828         ApplyActionsBuilder aab = new ApplyActionsBuilder();
1829         aab.setAction(actionList);
1830
1831         // Wrap our Apply Action in an Instruction
1832         InstructionBuilder ib = new InstructionBuilder();
1833         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1834
1835         // Put our Instruction in a list of Instructions
1836         InstructionsBuilder isb = new InstructionsBuilder();
1837         List<Instruction> instructions = new ArrayList<Instruction>();
1838         ib.setKey(new InstructionKey(0));
1839         instructions.add(ib.build());
1840         isb.setInstruction(instructions);
1841         return isb;
1842     }
1843
1844     private static InstructionsBuilder createAppyActionInstruction29() {
1845
1846         List<Action> actionList = new ArrayList<Action>();
1847         ActionBuilder ab = new ActionBuilder();
1848
1849         SetNwTtlActionBuilder setNwTtlActionBuilder = new SetNwTtlActionBuilder();
1850         setNwTtlActionBuilder.setNwTtl((short) 1);
1851         ab.setAction(new SetNwTtlActionCaseBuilder().setSetNwTtlAction(setNwTtlActionBuilder.build()).build());
1852         ab.setKey(new ActionKey(0));
1853         actionList.add(ab.build());
1854
1855         // Create an Apply Action
1856         ApplyActionsBuilder aab = new ApplyActionsBuilder();
1857         aab.setAction(actionList);
1858
1859         // Wrap our Apply Action in an Instruction
1860         InstructionBuilder ib = new InstructionBuilder();
1861         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1862
1863         // Put our Instruction in a list of Instructions
1864         InstructionsBuilder isb = new InstructionsBuilder();
1865         List<Instruction> instructions = new ArrayList<Instruction>();
1866         ib.setKey(new InstructionKey(0));
1867         instructions.add(ib.build());
1868         isb.setInstruction(instructions);
1869         return isb;
1870     }
1871
1872     private static InstructionsBuilder createAppyActionInstruction30() {
1873
1874         List<Action> actionList = new ArrayList<Action>();
1875         ActionBuilder ab = new ActionBuilder();
1876
1877         SetQueueActionBuilder setQueueActionBuilder = new SetQueueActionBuilder();
1878         setQueueActionBuilder.setQueueId(1L);
1879         ab.setAction(new SetQueueActionCaseBuilder().setSetQueueAction(setQueueActionBuilder.build()).build());
1880         ab.setKey(new ActionKey(0));
1881         actionList.add(ab.build());
1882         // Create an Apply Action
1883         ApplyActionsBuilder aab = new ApplyActionsBuilder();
1884         aab.setAction(actionList);
1885
1886         // Wrap our Apply Action in an Instruction
1887         InstructionBuilder ib = new InstructionBuilder();
1888         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1889
1890         // Put our Instruction in a list of Instructions
1891         InstructionsBuilder isb = new InstructionsBuilder();
1892         List<Instruction> instructions = new ArrayList<Instruction>();
1893         ib.setKey(new InstructionKey(0));
1894         instructions.add(ib.build());
1895         isb.setInstruction(instructions);
1896         return isb;
1897     }
1898
1899     private static InstructionsBuilder createAppyActionInstruction31() {
1900
1901         List<Action> actionList = new ArrayList<Action>();
1902         ActionBuilder ab = new ActionBuilder();
1903
1904         SetTpDstActionBuilder setTpDstActionBuilder = new SetTpDstActionBuilder();
1905         setTpDstActionBuilder.setPort(new PortNumber(109));
1906
1907         ab.setAction(new SetTpDstActionCaseBuilder().setSetTpDstAction(setTpDstActionBuilder.build()).build());
1908         ab.setKey(new ActionKey(0));
1909         actionList.add(ab.build());
1910         // Create an Apply Action
1911         ApplyActionsBuilder aab = new ApplyActionsBuilder();
1912         aab.setAction(actionList);
1913
1914         // Wrap our Apply Action in an Instruction
1915         InstructionBuilder ib = new InstructionBuilder();
1916         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1917
1918         // Put our Instruction in a list of Instructions
1919         InstructionsBuilder isb = new InstructionsBuilder();
1920         List<Instruction> instructions = new ArrayList<Instruction>();
1921         ib.setKey(new InstructionKey(0));
1922         instructions.add(ib.build());
1923         isb.setInstruction(instructions);
1924         return isb;
1925     }
1926
1927     private static InstructionsBuilder createAppyActionInstruction32() {
1928
1929         List<Action> actionList = new ArrayList<Action>();
1930         ActionBuilder ab = new ActionBuilder();
1931
1932         SetTpSrcActionBuilder setTpSrcActionBuilder = new SetTpSrcActionBuilder();
1933         setTpSrcActionBuilder.setPort(new PortNumber(109));
1934         ab.setAction(new SetTpSrcActionCaseBuilder().setSetTpSrcAction(setTpSrcActionBuilder.build()).build());
1935         ab.setKey(new ActionKey(0));
1936         actionList.add(ab.build());
1937
1938         // Create an Apply Action
1939         ApplyActionsBuilder aab = new ApplyActionsBuilder();
1940         aab.setAction(actionList);
1941
1942         // Wrap our Apply Action in an Instruction
1943         InstructionBuilder ib = new InstructionBuilder();
1944         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1945
1946         // Put our Instruction in a list of Instructions
1947         InstructionsBuilder isb = new InstructionsBuilder();
1948         List<Instruction> instructions = new ArrayList<Instruction>();
1949         ib.setKey(new InstructionKey(0));
1950         instructions.add(ib.build());
1951         isb.setInstruction(instructions);
1952         return isb;
1953     }
1954
1955     private static InstructionsBuilder createAppyActionInstruction33() {
1956
1957         List<Action> actionList = new ArrayList<Action>();
1958         ActionBuilder ab = new ActionBuilder();
1959
1960         SetVlanCfiActionBuilder setVlanCfiActionBuilder = new SetVlanCfiActionBuilder();
1961         setVlanCfiActionBuilder.setVlanCfi(new VlanCfi(2));
1962         ab.setAction(new SetVlanCfiActionCaseBuilder().setSetVlanCfiAction(setVlanCfiActionBuilder.build()).build());
1963         ab.setKey(new ActionKey(0));
1964         actionList.add(ab.build());
1965
1966         // Create an Apply Action
1967         ApplyActionsBuilder aab = new ApplyActionsBuilder();
1968         aab.setAction(actionList);
1969
1970         // Wrap our Apply Action in an Instruction
1971         InstructionBuilder ib = new InstructionBuilder();
1972         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1973
1974         // Put our Instruction in a list of Instructions
1975         InstructionsBuilder isb = new InstructionsBuilder();
1976         List<Instruction> instructions = new ArrayList<Instruction>();
1977         ib.setKey(new InstructionKey(0));
1978         instructions.add(ib.build());
1979         isb.setInstruction(instructions);
1980         return isb;
1981     }
1982
1983     private static InstructionsBuilder createAppyActionInstruction34() {
1984
1985         List<Action> actionList = new ArrayList<Action>();
1986         ActionBuilder ab = new ActionBuilder();
1987
1988         SwPathActionBuilder swPathAction = new SwPathActionBuilder();
1989         ab.setAction(new SwPathActionCaseBuilder().setSwPathAction(swPathAction.build()).build());
1990         ab.setKey(new ActionKey(0));
1991         actionList.add(ab.build());
1992
1993         // Create an Apply Action
1994         ApplyActionsBuilder aab = new ApplyActionsBuilder();
1995         aab.setAction(actionList);
1996
1997         // Wrap our Apply Action in an Instruction
1998         InstructionBuilder ib = new InstructionBuilder();
1999         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
2000
2001         // Put our Instruction in a list of Instructions
2002         InstructionsBuilder isb = new InstructionsBuilder();
2003         List<Instruction> instructions = new ArrayList<Instruction>();
2004         ib.setKey(new InstructionKey(0));
2005         instructions.add(ib.build());
2006         isb.setInstruction(instructions);
2007         return isb;
2008     }
2009
2010     private static InstructionsBuilder createAppyActionInstruction35() {
2011
2012         List<Action> actionList = new ArrayList<Action>();
2013         ActionBuilder ab = new ActionBuilder();
2014         ActionBuilder ab1 = new ActionBuilder();
2015         ActionBuilder ab2 = new ActionBuilder();
2016
2017         SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
2018         SetFieldBuilder setFieldBuilder1 = new SetFieldBuilder();
2019         SetFieldBuilder setFieldBuilder2 = new SetFieldBuilder();
2020
2021         // Ethernet
2022         EthernetMatchBuilder ethernetMatch = new EthernetMatchBuilder();
2023         EthernetSourceBuilder ethSourceBuilder = new EthernetSourceBuilder();
2024         ethSourceBuilder.setAddress(new MacAddress("00:00:00:00:00:01"));
2025         EthernetMatchBuilder ethernetMatch1 = new EthernetMatchBuilder();
2026         EthernetDestinationBuilder ethDestBuilder = new EthernetDestinationBuilder();
2027         ethDestBuilder.setAddress(new MacAddress("00:00:00:00:00:02"));
2028         EthernetMatchBuilder ethernetMatch2 = new EthernetMatchBuilder();
2029         EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
2030         ethTypeBuilder.setType(new EtherType(0x86ddL));
2031
2032         ethernetMatch.setEthernetSource(ethSourceBuilder.build());
2033         ethernetMatch1.setEthernetDestination(ethDestBuilder.build());
2034         ethernetMatch2.setEthernetType(ethTypeBuilder.build());
2035         setFieldBuilder.setEthernetMatch(ethernetMatch.build());
2036         setFieldBuilder1.setEthernetMatch(ethernetMatch1.build());
2037         setFieldBuilder2.setEthernetMatch(ethernetMatch2.build());
2038         ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
2039         ab.setKey(new ActionKey(0));
2040         actionList.add(ab.build());
2041
2042         ab1.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder1.build()).build());
2043         ab1.setKey(new ActionKey(1));
2044         actionList.add(ab1.build());
2045
2046         ab2.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder2.build()).build());
2047         ab2.setKey(new ActionKey(2));
2048         actionList.add(ab2.build());
2049
2050         ApplyActionsBuilder aab = new ApplyActionsBuilder();
2051         aab.setAction(actionList);
2052
2053         InstructionBuilder ib = new InstructionBuilder();
2054         ib.setKey(new InstructionKey(0));
2055         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
2056
2057         // Put our Instruction in a list of Instructions
2058         InstructionsBuilder isb = new InstructionsBuilder();
2059         List<Instruction> instructions = new ArrayList<Instruction>();
2060         ib.setKey(new InstructionKey(0));
2061         instructions.add(ib.build());
2062         isb.setInstruction(instructions);
2063         return isb;
2064     }
2065
2066     private static InstructionsBuilder createAppyActionInstruction36() {
2067
2068         List<Action> actionList = new ArrayList<Action>();
2069         ActionBuilder ab = new ActionBuilder();
2070         ActionBuilder ab1 = new ActionBuilder();
2071
2072         SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
2073         SetFieldBuilder setFieldBuilder1 = new SetFieldBuilder();
2074
2075         // Vlan
2076         VlanMatchBuilder vlanBuilder = new VlanMatchBuilder();
2077         VlanMatchBuilder vlanBuilder1 = new VlanMatchBuilder();
2078         VlanIdBuilder vlanIdBuilder = new VlanIdBuilder();
2079         VlanId vlanId = new VlanId(10);
2080         VlanPcp vpcp = new VlanPcp((short) 3);
2081         vlanBuilder.setVlanPcp(vpcp);
2082         vlanBuilder1.setVlanId(vlanIdBuilder.setVlanId(vlanId).setVlanIdPresent(true).build());
2083         setFieldBuilder.setVlanMatch(vlanBuilder.build());
2084         setFieldBuilder1.setVlanMatch(vlanBuilder1.build());
2085         ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
2086         ab.setKey(new ActionKey(0));
2087         actionList.add(ab.build());
2088         ab1.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder1.build()).build());
2089         ab1.setKey(new ActionKey(1));
2090         actionList.add(ab1.build());
2091
2092         ApplyActionsBuilder aab = new ApplyActionsBuilder();
2093         aab.setAction(actionList);
2094
2095         InstructionBuilder ib = new InstructionBuilder();
2096         ib.setKey(new InstructionKey(0));
2097         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
2098
2099         // Put our Instruction in a list of Instructions
2100         InstructionsBuilder isb = new InstructionsBuilder();
2101         List<Instruction> instructions = new ArrayList<Instruction>();
2102         instructions.add(ib.build());
2103         isb.setInstruction(instructions);
2104         return isb;
2105     }
2106
2107     private static InstructionsBuilder createAppyActionInstruction37() {
2108
2109         List<Action> actionList = new ArrayList<Action>();
2110         ActionBuilder ab = new ActionBuilder();
2111         ActionBuilder ab1 = new ActionBuilder();
2112         ActionBuilder ab2 = new ActionBuilder();
2113
2114         SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
2115         SetFieldBuilder setFieldBuilder1 = new SetFieldBuilder();
2116         SetFieldBuilder setFieldBuilder2 = new SetFieldBuilder();
2117         // Ip
2118         IpMatchBuilder ipmatch = new IpMatchBuilder();
2119         IpMatchBuilder ipmatch1 = new IpMatchBuilder();
2120         IpMatchBuilder ipmatch2 = new IpMatchBuilder();
2121         Dscp dscp = new Dscp((short) 3);
2122         ipmatch.setIpDscp(dscp);
2123         ipmatch1.setIpEcn((short) 2);
2124         ipmatch2.setIpProtocol((short) 120);
2125         setFieldBuilder.setIpMatch(ipmatch.build());
2126         ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
2127         ab.setKey(new ActionKey(0));
2128         actionList.add(ab.build());
2129
2130         setFieldBuilder1.setIpMatch(ipmatch1.build());
2131         ab1.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder1.build()).build());
2132         ab1.setKey(new ActionKey(1));
2133         actionList.add(ab1.build());
2134
2135         setFieldBuilder2.setIpMatch(ipmatch2.build());
2136         ab2.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder2.build()).build());
2137         ab2.setKey(new ActionKey(2));
2138         actionList.add(ab2.build());
2139
2140         ApplyActionsBuilder aab = new ApplyActionsBuilder();
2141         aab.setAction(actionList);
2142
2143         InstructionBuilder ib = new InstructionBuilder();
2144         ib.setKey(new InstructionKey(0));
2145         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
2146
2147         // Put our Instruction in a list of Instructions
2148         InstructionsBuilder isb = new InstructionsBuilder();
2149         List<Instruction> instructions = new ArrayList<Instruction>();
2150         instructions.add(ib.build());
2151         isb.setInstruction(instructions);
2152         return isb;
2153     }
2154
2155     private static InstructionsBuilder createAppyActionInstruction38() {
2156
2157         List<Action> actionList = new ArrayList<Action>();
2158         ActionBuilder ab = new ActionBuilder();
2159         ActionBuilder ab1 = new ActionBuilder();
2160
2161         SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
2162         SetFieldBuilder setFieldBuilder1 = new SetFieldBuilder();
2163         // IPv4
2164         Ipv4MatchBuilder ipv4Match = new Ipv4MatchBuilder();
2165         Ipv4MatchBuilder ipv4Match1 = new Ipv4MatchBuilder();
2166         Ipv4Prefix dstip = new Ipv4Prefix("200.71.9.5210");
2167         Ipv4Prefix srcip = new Ipv4Prefix("100.1.1.1");
2168         ipv4Match1.setIpv4Destination(dstip);
2169         ipv4Match.setIpv4Source(srcip);
2170         setFieldBuilder.setLayer3Match(ipv4Match.build());
2171         ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
2172         ab.setKey(new ActionKey(0));
2173         actionList.add(ab.build());
2174
2175         setFieldBuilder1.setLayer3Match(ipv4Match1.build());
2176         ab1.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder1.build()).build());
2177         ab1.setKey(new ActionKey(1));
2178         actionList.add(ab1.build());
2179
2180         ApplyActionsBuilder aab = new ApplyActionsBuilder();
2181         aab.setAction(actionList);
2182
2183         InstructionBuilder ib = new InstructionBuilder();
2184         ib.setKey(new InstructionKey(0));
2185         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
2186
2187         // Put our Instruction in a list of Instructions
2188         InstructionsBuilder isb = new InstructionsBuilder();
2189         List<Instruction> instructions = new ArrayList<Instruction>();
2190         instructions.add(ib.build());
2191         isb.setInstruction(instructions);
2192         return isb;
2193     }
2194
2195     private static InstructionsBuilder createAppyActionInstruction39() {
2196
2197         List<Action> actionList = new ArrayList<Action>();
2198         ActionBuilder ab = new ActionBuilder();
2199         ActionBuilder ab1 = new ActionBuilder();
2200
2201         SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
2202         SetFieldBuilder setFieldBuilder1 = new SetFieldBuilder();
2203
2204         // Tcp
2205         PortNumber tcpsrcport = new PortNumber(1213);
2206         PortNumber tcpdstport = new PortNumber(646);
2207         TcpMatchBuilder tcpmatch = new TcpMatchBuilder();
2208         TcpMatchBuilder tcpmatch1 = new TcpMatchBuilder();
2209         tcpmatch.setTcpSourcePort(tcpsrcport);
2210         tcpmatch1.setTcpDestinationPort(tcpdstport);
2211         setFieldBuilder.setLayer4Match(tcpmatch.build());
2212         ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
2213         ab.setKey(new ActionKey(0));
2214         actionList.add(ab.build());
2215
2216         setFieldBuilder1.setLayer4Match(tcpmatch1.build());
2217         ab1.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder1.build()).build());
2218         ab1.setKey(new ActionKey(1));
2219         actionList.add(ab.build());
2220
2221         ApplyActionsBuilder aab = new ApplyActionsBuilder();
2222         aab.setAction(actionList);
2223
2224         InstructionBuilder ib = new InstructionBuilder();
2225         ib.setKey(new InstructionKey(0));
2226         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
2227
2228         // Put our Instruction in a list of Instructions
2229         InstructionsBuilder isb = new InstructionsBuilder();
2230         List<Instruction> instructions = new ArrayList<Instruction>();
2231         instructions.add(ib.build());
2232         isb.setInstruction(instructions);
2233         return isb;
2234     }
2235
2236     private static InstructionsBuilder createAppyActionInstruction40() {
2237
2238         List<Action> actionList = new ArrayList<Action>();
2239         ActionBuilder ab = new ActionBuilder();
2240         ActionBuilder ab1 = new ActionBuilder();
2241
2242         SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
2243         SetFieldBuilder setFieldBuilder1 = new SetFieldBuilder();
2244
2245         // Udp
2246         PortNumber udpsrcport = new PortNumber(1325);
2247         PortNumber udpdstport = new PortNumber(42);
2248         UdpMatchBuilder udpmatch = new UdpMatchBuilder();
2249         UdpMatchBuilder udpmatch1 = new UdpMatchBuilder();
2250         udpmatch.setUdpDestinationPort(udpdstport);
2251         udpmatch1.setUdpSourcePort(udpsrcport);
2252         setFieldBuilder.setLayer4Match(udpmatch.build());
2253         ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
2254         ab.setKey(new ActionKey(0));
2255         actionList.add(ab.build());
2256
2257         setFieldBuilder1.setLayer4Match(udpmatch1.build());
2258         ab1.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder1.build()).build());
2259         ab1.setKey(new ActionKey(1));
2260         actionList.add(ab1.build());
2261
2262         ApplyActionsBuilder aab = new ApplyActionsBuilder();
2263         aab.setAction(actionList);
2264
2265         InstructionBuilder ib = new InstructionBuilder();
2266         ib.setKey(new InstructionKey(0));
2267         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
2268
2269         // Put our Instruction in a list of Instructions
2270         InstructionsBuilder isb = new InstructionsBuilder();
2271         List<Instruction> instructions = new ArrayList<Instruction>();
2272         instructions.add(ib.build());
2273         isb.setInstruction(instructions);
2274         return isb;
2275     }
2276
2277     private static InstructionsBuilder createAppyActionInstruction41() {
2278
2279         List<Action> actionList = new ArrayList<Action>();
2280         ActionBuilder ab = new ActionBuilder();
2281         ActionBuilder ab1 = new ActionBuilder();
2282
2283         SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
2284         SetFieldBuilder setFieldBuilder1 = new SetFieldBuilder();
2285
2286         // Sctp
2287         SctpMatchBuilder sctpmatch = new SctpMatchBuilder();
2288         SctpMatchBuilder sctpmatch1 = new SctpMatchBuilder();
2289         PortNumber srcport = new PortNumber(1435);
2290         PortNumber dstport = new PortNumber(22);
2291         sctpmatch.setSctpSourcePort(srcport);
2292         sctpmatch1.setSctpDestinationPort(dstport);
2293         setFieldBuilder.setLayer4Match(sctpmatch.build());
2294         ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
2295         ab.setKey(new ActionKey(0));
2296         actionList.add(ab.build());
2297
2298         setFieldBuilder1.setLayer4Match(sctpmatch1.build());
2299         ab1.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder1.build()).build());
2300         ab1.setKey(new ActionKey(1));
2301         actionList.add(ab1.build());
2302
2303         ApplyActionsBuilder aab = new ApplyActionsBuilder();
2304         aab.setAction(actionList);
2305
2306         InstructionBuilder ib = new InstructionBuilder();
2307         ib.setKey(new InstructionKey(0));
2308         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
2309
2310         // Put our Instruction in a list of Instructions
2311         InstructionsBuilder isb = new InstructionsBuilder();
2312         List<Instruction> instructions = new ArrayList<Instruction>();
2313         instructions.add(ib.build());
2314         isb.setInstruction(instructions);
2315         return isb;
2316     }
2317
2318     private static InstructionsBuilder createAppyActionInstruction42() {
2319
2320         List<Action> actionList = new ArrayList<Action>();
2321         ActionBuilder ab = new ActionBuilder();
2322         ActionBuilder ab1 = new ActionBuilder();
2323         SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
2324         SetFieldBuilder setFieldBuilder1 = new SetFieldBuilder();
2325
2326         // Icmpv4
2327         Icmpv4MatchBuilder icmpv4match = new Icmpv4MatchBuilder();
2328         Icmpv4MatchBuilder icmpv4match1 = new Icmpv4MatchBuilder();
2329         icmpv4match.setIcmpv4Type((short) 8);
2330         icmpv4match1.setIcmpv4Code((short) 0);
2331         setFieldBuilder.setIcmpv4Match(icmpv4match.build());
2332         ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
2333         ab.setKey(new ActionKey(0));
2334         actionList.add(ab.build());
2335
2336         setFieldBuilder1.setIcmpv4Match(icmpv4match1.build());
2337         ab1.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder1.build()).build());
2338         ab1.setKey(new ActionKey(1));
2339         actionList.add(ab1.build());
2340
2341         ApplyActionsBuilder aab = new ApplyActionsBuilder();
2342         aab.setAction(actionList);
2343
2344         InstructionBuilder ib = new InstructionBuilder();
2345         ib.setKey(new InstructionKey(0));
2346         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
2347
2348         // Put our Instruction in a list of Instructions
2349         InstructionsBuilder isb = new InstructionsBuilder();
2350         List<Instruction> instructions = new ArrayList<Instruction>();
2351         instructions.add(ib.build());
2352         isb.setInstruction(instructions);
2353         return isb;
2354     }
2355
2356     private static InstructionsBuilder createAppyActionInstruction43() {
2357
2358         List<Action> actionList = new ArrayList<Action>();
2359         ActionBuilder ab = new ActionBuilder();
2360         ActionBuilder ab1 = new ActionBuilder();
2361         ActionBuilder ab2 = new ActionBuilder();
2362         ActionBuilder ab3 = new ActionBuilder();
2363         ActionBuilder ab4 = new ActionBuilder();
2364
2365         SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
2366         SetFieldBuilder setFieldBuilder1 = new SetFieldBuilder();
2367         SetFieldBuilder setFieldBuilder2 = new SetFieldBuilder();
2368         SetFieldBuilder setFieldBuilder3 = new SetFieldBuilder();
2369         SetFieldBuilder setFieldBuilder4 = new SetFieldBuilder();
2370
2371         // setting the values of ARP
2372         MacAddress macdest = new MacAddress(DEST_MAC_ADDRESS);
2373         MacAddress macsrc = new MacAddress(SRC_MAC_ADDRESS);
2374         Ipv4Prefix dstiparp = new Ipv4Prefix("200.71.9.52");
2375         Ipv4Prefix srciparp = new Ipv4Prefix("100.1.1.1");
2376         // create ARP match action
2377         ArpMatchBuilder arpmatch = new ArpMatchBuilder();
2378         ArpMatchBuilder arpmatch1 = new ArpMatchBuilder();
2379         ArpMatchBuilder arpmatch2 = new ArpMatchBuilder();
2380         ArpMatchBuilder arpmatch3 = new ArpMatchBuilder();
2381         ArpMatchBuilder arpmatch4 = new ArpMatchBuilder();
2382         ArpSourceHardwareAddressBuilder arpsrc = new ArpSourceHardwareAddressBuilder();
2383         arpsrc.setAddress(macsrc);
2384         ArpTargetHardwareAddressBuilder arpdst = new ArpTargetHardwareAddressBuilder();
2385         arpdst.setAddress(macdest);
2386         arpmatch.setArpOp(2);
2387         arpmatch1.setArpSourceHardwareAddress(arpsrc.build());
2388         arpmatch2.setArpTargetHardwareAddress(arpdst.build());
2389         arpmatch3.setArpSourceTransportAddress(srciparp);
2390         arpmatch4.setArpTargetTransportAddress(dstiparp);
2391         setFieldBuilder.setLayer3Match(arpmatch.build());
2392         ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
2393         ab.setKey(new ActionKey(0));
2394         actionList.add(ab.build());
2395
2396         setFieldBuilder1.setLayer3Match(arpmatch1.build());
2397         ab1.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder1.build()).build());
2398         ab1.setKey(new ActionKey(1));
2399         actionList.add(ab1.build());
2400
2401         setFieldBuilder2.setLayer3Match(arpmatch2.build());
2402         ab2.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder2.build()).build());
2403         ab2.setKey(new ActionKey(2));
2404         actionList.add(ab2.build());
2405
2406         setFieldBuilder3.setLayer3Match(arpmatch3.build());
2407         ab3.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder3.build()).build());
2408         ab3.setKey(new ActionKey(3));
2409         actionList.add(ab3.build());
2410
2411         setFieldBuilder4.setLayer3Match(arpmatch4.build());
2412         ab4.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder4.build()).build());
2413         ab4.setKey(new ActionKey(4));
2414         actionList.add(ab4.build());
2415
2416         ApplyActionsBuilder aab = new ApplyActionsBuilder();
2417         aab.setAction(actionList);
2418
2419         InstructionBuilder ib = new InstructionBuilder();
2420         ib.setKey(new InstructionKey(0));
2421         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
2422
2423         // Put our Instruction in a list of Instructions
2424         InstructionsBuilder isb = new InstructionsBuilder();
2425         List<Instruction> instructions = new ArrayList<Instruction>();
2426         instructions.add(ib.build());
2427         isb.setInstruction(instructions);
2428         return isb;
2429     }
2430
2431     private static InstructionsBuilder createAppyActionInstruction44() {
2432
2433         List<Action> actionLists = new ArrayList<Action>();
2434         ActionBuilder ab = new ActionBuilder();
2435         SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
2436         ActionBuilder ab1 = new ActionBuilder();
2437         SetFieldBuilder setFieldBuilder1 = new SetFieldBuilder();
2438         ActionBuilder ab5 = new ActionBuilder();
2439         SetFieldBuilder setFieldBuilder5 = new SetFieldBuilder();
2440         ActionBuilder ab6 = new ActionBuilder();
2441         SetFieldBuilder setFieldBuilder6 = new SetFieldBuilder();
2442
2443         // IPv6
2444         Ipv6MatchBuilder ipv6Builder = new Ipv6MatchBuilder();
2445         Ipv6MatchBuilder ipv6Builder1 = new Ipv6MatchBuilder();
2446         Ipv6MatchBuilder ipv6Builder5 = new Ipv6MatchBuilder();
2447         Ipv6MatchBuilder ipv6Builder6 = new Ipv6MatchBuilder();
2448
2449         Ipv6Prefix dstip6 = new Ipv6Prefix("2002::2");
2450         Ipv6Prefix srcip6 = new Ipv6Prefix("2001:0:0:0:0:0:0:1");
2451         Ipv6ExtHeaderBuilder nextheader = new Ipv6ExtHeaderBuilder();
2452         nextheader.setIpv6Exthdr(58);
2453         Ipv6LabelBuilder ipv6label = new Ipv6LabelBuilder();
2454         Ipv6FlowLabel label = new Ipv6FlowLabel(10028L);
2455         ipv6label.setIpv6Flabel(label);
2456
2457         ipv6Builder.setIpv6Source(srcip6);
2458         ipv6Builder1.setIpv6Destination(dstip6);
2459         ipv6Builder5.setIpv6ExtHeader(nextheader.build());
2460         ipv6Builder6.setIpv6Label(ipv6label.build());
2461
2462         setFieldBuilder.setLayer3Match(ipv6Builder.build());
2463         ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
2464         ab.setKey(new ActionKey(0));
2465         actionLists.add(ab.build());
2466
2467         setFieldBuilder1.setLayer3Match(ipv6Builder1.build());
2468         ab1.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder1.build()).build());
2469         ab1.setKey(new ActionKey(1));
2470         actionLists.add(ab1.build());
2471
2472         setFieldBuilder5.setLayer3Match(ipv6Builder5.build());
2473         ab5.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder5.build()).build());
2474         ab5.setKey(new ActionKey(5));
2475         actionLists.add(ab5.build());
2476
2477         setFieldBuilder6.setLayer3Match(ipv6Builder6.build());
2478         ab6.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder6.build()).build());
2479         ab6.setKey(new ActionKey(6));
2480         actionLists.add(ab6.build());
2481
2482         ApplyActionsBuilder aab = new ApplyActionsBuilder();
2483         aab.setAction(actionLists);
2484
2485         InstructionBuilder ib = new InstructionBuilder();
2486         ib.setKey(new InstructionKey(0));
2487         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
2488
2489         // Put our Instruction in a list of Instructions
2490         InstructionsBuilder isb = new InstructionsBuilder();
2491         List<Instruction> instructions = new ArrayList<Instruction>();
2492         instructions.add(ib.build());
2493         isb.setInstruction(instructions);
2494         return isb;
2495     }
2496
2497     private static InstructionsBuilder createAppyActionInstruction45() {
2498
2499         List<Action> actionList = new ArrayList<Action>();
2500         ActionBuilder ab = new ActionBuilder();
2501         SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
2502         ActionBuilder ab1 = new ActionBuilder();
2503         SetFieldBuilder setFieldBuilder1 = new SetFieldBuilder();
2504
2505         // Icmpv6
2506         Icmpv6MatchBuilder icmpv6match = new Icmpv6MatchBuilder();
2507         Icmpv6MatchBuilder icmpv6match1 = new Icmpv6MatchBuilder();
2508         icmpv6match.setIcmpv6Type((short) 135);
2509         icmpv6match1.setIcmpv6Code((short) 0);
2510         setFieldBuilder.setIcmpv6Match(icmpv6match.build());
2511         ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
2512         ab.setKey(new ActionKey(0));
2513         actionList.add(ab.build());
2514
2515         setFieldBuilder1.setIcmpv6Match(icmpv6match1.build());
2516         ab1.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder1.build()).build());
2517         ab1.setKey(new ActionKey(1));
2518         actionList.add(ab1.build());
2519
2520         ApplyActionsBuilder aab = new ApplyActionsBuilder();
2521         aab.setAction(actionList);
2522
2523         InstructionBuilder ib = new InstructionBuilder();
2524         ib.setKey(new InstructionKey(0));
2525         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
2526
2527         // Put our Instruction in a list of Instructions
2528         InstructionsBuilder isb = new InstructionsBuilder();
2529         List<Instruction> instructions = new ArrayList<Instruction>();
2530         instructions.add(ib.build());
2531         isb.setInstruction(instructions);
2532         return isb;
2533     }
2534
2535     private static InstructionsBuilder createAppyActionInstruction46() {
2536
2537         List<Action> actionList = new ArrayList<Action>();
2538         ActionBuilder ab = new ActionBuilder();
2539         SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
2540         ActionBuilder ab1 = new ActionBuilder();
2541         SetFieldBuilder setFieldBuilder1 = new SetFieldBuilder();
2542         ActionBuilder ab2 = new ActionBuilder();
2543         SetFieldBuilder setFieldBuilder2 = new SetFieldBuilder();
2544
2545         // MPLS
2546         ProtocolMatchFieldsBuilder protomatch = new ProtocolMatchFieldsBuilder();
2547         ProtocolMatchFieldsBuilder protomatch1 = new ProtocolMatchFieldsBuilder();
2548         ProtocolMatchFieldsBuilder protomatch2 = new ProtocolMatchFieldsBuilder();
2549         protomatch.setMplsLabel((long) 36008);
2550         protomatch1.setMplsTc((short) 4);
2551         protomatch2.setMplsBos((short) 1);
2552         setFieldBuilder.setProtocolMatchFields(protomatch.build());
2553         ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
2554         ab.setKey(new ActionKey(0));
2555         actionList.add(ab.build());
2556
2557         setFieldBuilder1.setProtocolMatchFields(protomatch1.build());
2558         ab1.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder1.build()).build());
2559         ab1.setKey(new ActionKey(1));
2560         actionList.add(ab1.build());
2561
2562         setFieldBuilder2.setProtocolMatchFields(protomatch2.build());
2563         ab2.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder2.build()).build());
2564         ab2.setKey(new ActionKey(2));
2565         actionList.add(ab2.build());
2566
2567         ApplyActionsBuilder aab = new ApplyActionsBuilder();
2568         aab.setAction(actionList);
2569
2570         InstructionBuilder ib = new InstructionBuilder();
2571         ib.setKey(new InstructionKey(0));
2572         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
2573
2574         // Put our Instruction in a list of Instructions
2575         InstructionsBuilder isb = new InstructionsBuilder();
2576         List<Instruction> instructions = new ArrayList<Instruction>();
2577         instructions.add(ib.build());
2578         isb.setInstruction(instructions);
2579         return isb;
2580     }
2581
2582     private static InstructionsBuilder createAppyActionInstruction47() {
2583
2584         List<Action> actionList = new ArrayList<Action>();
2585         ActionBuilder ab = new ActionBuilder();
2586         SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
2587         // PBB
2588         ProtocolMatchFieldsBuilder protomatch = new ProtocolMatchFieldsBuilder();
2589         protomatch.setPbb(new PbbBuilder().setPbbIsid(4L).setPbbMask((new BigInteger(new byte[]{0, 1, 0, 0}).longValue())).build());
2590         setFieldBuilder.setProtocolMatchFields(protomatch.build());
2591         ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
2592         actionList.add(ab.build());
2593
2594         ApplyActionsBuilder aab = new ApplyActionsBuilder();
2595         aab.setAction(actionList);
2596
2597         InstructionBuilder ib = new InstructionBuilder();
2598         ib.setKey(new InstructionKey(0));
2599         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
2600
2601         // Put our Instruction in a list of Instructions
2602         InstructionsBuilder isb = new InstructionsBuilder();
2603         List<Instruction> instructions = new ArrayList<Instruction>();
2604         instructions.add(ib.build());
2605         isb.setInstruction(instructions);
2606         return isb;
2607     }
2608
2609     private static InstructionsBuilder createAppyActionInstruction48() {
2610
2611         List<Action> actionList = new ArrayList<Action>();
2612         ActionBuilder ab = new ActionBuilder();
2613         SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
2614         // Tunnel
2615         TunnelBuilder tunnel = new TunnelBuilder();
2616         tunnel.setTunnelId(BigInteger.valueOf(10668));
2617         setFieldBuilder.setTunnel(tunnel.build());
2618         ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
2619         ab.setKey(new ActionKey(0));
2620         actionList.add(ab.build());
2621
2622         ApplyActionsBuilder aab = new ApplyActionsBuilder();
2623         aab.setAction(actionList);
2624
2625         InstructionBuilder ib = new InstructionBuilder();
2626         ib.setKey(new InstructionKey(0));
2627         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
2628
2629         // Put our Instruction in a list of Instructions
2630         InstructionsBuilder isb = new InstructionsBuilder();
2631         List<Instruction> instructions = new ArrayList<Instruction>();
2632         instructions.add(ib.build());
2633         isb.setInstruction(instructions);
2634         return isb;
2635     }
2636
2637     private static InstructionsBuilder createTunnelIpv4DstInstructions() {
2638
2639         List<Action> actionList = new ArrayList<Action>();
2640         ActionBuilder ab = new ActionBuilder();
2641         // Build the tunnel endpoint destination IPv4 address
2642         SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
2643         Ipv4Prefix dstIp = new Ipv4Prefix("172.16.100.100");
2644         // Add the mew IPv4 object as the tunnel destination
2645         TunnelIpv4MatchBuilder tunnelIpv4DstMatchBuilder = new TunnelIpv4MatchBuilder();
2646         tunnelIpv4DstMatchBuilder.setTunnelIpv4Destination(dstIp);
2647         setFieldBuilder.setLayer3Match(tunnelIpv4DstMatchBuilder.build());
2648         // Add the IPv4 tunnel dst to the set_field value
2649         ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
2650         ab.setOrder(0);
2651         ab.setKey(new ActionKey(0));
2652         actionList.add(ab.build());
2653         // Resulting action is a per/flow src TEP (set_field:172.16.100.100->tun_dst)
2654         ApplyActionsBuilder aab = new ApplyActionsBuilder();
2655         aab.setAction(actionList);
2656         // Add the action to the ordered list of Instructions
2657         InstructionBuilder ib = new InstructionBuilder();
2658         ib.setOrder(0);
2659         ib.setKey(new InstructionKey(0));
2660         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
2661         // Add the Instruction in a list of Instructions
2662         InstructionsBuilder isb = new InstructionsBuilder();
2663         List<Instruction> instructions = new ArrayList<Instruction>();
2664         instructions.add(ib.build());
2665         isb.setInstruction(instructions);
2666         return isb;
2667     }
2668
2669     private static InstructionsBuilder createTunnelIpv4SrcInstructions() {
2670
2671         List<Action> actionList = new ArrayList<Action>();
2672         ActionBuilder ab = new ActionBuilder();
2673         // Build the tunnel endpoint source IPv4 address
2674         SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
2675         Ipv4Prefix dstIp = new Ipv4Prefix("172.16.100.200");
2676         // Add the new IPv4 object as the tunnel destination
2677         TunnelIpv4MatchBuilder tunnelIpv4MatchBuilder = new TunnelIpv4MatchBuilder();
2678         tunnelIpv4MatchBuilder.setTunnelIpv4Source(dstIp);
2679         setFieldBuilder.setLayer3Match(tunnelIpv4MatchBuilder.build());
2680         // Add the IPv4 tunnel src to the set_field value
2681         ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
2682         ab.setOrder(0);
2683         ab.setKey(new ActionKey(0));
2684         actionList.add(ab.build());
2685         // Resulting action is a per/flow src TEP (set_field:172.16.100.100->tun_src)
2686         ApplyActionsBuilder aab = new ApplyActionsBuilder();
2687         aab.setAction(actionList);
2688         // Add the action to the ordered list of Instructions
2689         InstructionBuilder ib = new InstructionBuilder();
2690         ib.setOrder(0);
2691         ib.setKey(new InstructionKey(0));
2692         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
2693         // Put our Instruction in a list of Instructions
2694         InstructionsBuilder isb = new InstructionsBuilder();
2695         List<Instruction> instructions = new ArrayList<Instruction>();
2696         instructions.add(ib.build());
2697         isb.setInstruction(instructions);
2698         return isb;
2699     }
2700
2701     private static MatchBuilder createLLDPMatch() {
2702         MatchBuilder match = new MatchBuilder();
2703         EthernetMatchBuilder eth = new EthernetMatchBuilder();
2704         EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
2705         ethTypeBuilder.setType(new EtherType(0x88ccL));
2706         eth.setEthernetType(ethTypeBuilder.build());
2707         match.setEthernetMatch(eth.build());
2708         return match;
2709     }
2710
2711     /**
2712      * @return
2713      */
2714     private static MatchBuilder createMatch1() {
2715         MatchBuilder match = new MatchBuilder();
2716         Ipv4MatchBuilder ipv4Match = new Ipv4MatchBuilder();
2717         Ipv4Prefix prefix = new Ipv4Prefix(IPV4_PREFIX);;
2718         ipv4Match.setIpv4Destination(prefix);
2719         Ipv4Match i4m = ipv4Match.build();
2720         match.setLayer3Match(i4m);
2721
2722         EthernetMatchBuilder eth = new EthernetMatchBuilder();
2723         EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
2724         ethTypeBuilder.setType(new EtherType(0x0800L));
2725         eth.setEthernetType(ethTypeBuilder.build());
2726         match.setEthernetMatch(eth.build());
2727         return match;
2728     }
2729
2730
2731     /**
2732      * @return
2733      */
2734     private static MatchBuilder createMatch2() {
2735         MatchBuilder match = new MatchBuilder();
2736         Ipv4MatchBuilder ipv4Match = new Ipv4MatchBuilder();
2737         Ipv4Prefix prefix = new Ipv4Prefix("10.0.0.1");
2738         ipv4Match.setIpv4Source(prefix);
2739         Ipv4Match i4m = ipv4Match.build();
2740         match.setLayer3Match(i4m);
2741
2742         EthernetMatchBuilder eth = new EthernetMatchBuilder();
2743         EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
2744         ethTypeBuilder.setType(new EtherType(0x0800L));
2745         eth.setEthernetType(ethTypeBuilder.build());
2746         match.setEthernetMatch(eth.build());
2747         return match;
2748     }
2749
2750     /**
2751      * @return
2752      */
2753     private static MatchBuilder createMatch3() {
2754         MatchBuilder match = new MatchBuilder();
2755         EthernetMatchBuilder ethernetMatch = new EthernetMatchBuilder();
2756         EthernetSourceBuilder ethSourceBuilder = new EthernetSourceBuilder();
2757         ethSourceBuilder.setAddress(new MacAddress("00:00:00:00:00:01"));
2758         ethernetMatch.setEthernetSource(ethSourceBuilder.build());
2759         match.setEthernetMatch(ethernetMatch.build());
2760
2761         return match;
2762     }
2763
2764     /**
2765      * @return
2766      */
2767     private static MatchBuilder createICMPv6Match1() {
2768
2769         MatchBuilder match = new MatchBuilder();
2770         EthernetMatchBuilder eth = new EthernetMatchBuilder();
2771         EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
2772         ethTypeBuilder.setType(new EtherType(0x86ddL));
2773         eth.setEthernetType(ethTypeBuilder.build());
2774         match.setEthernetMatch(eth.build());
2775
2776         // ipv4 version
2777         IpMatchBuilder ipmatch = new IpMatchBuilder(); 
2778         ipmatch.setIpProtocol((short) 256);
2779         match.setIpMatch(ipmatch.build());
2780         
2781         // icmpv6
2782         Icmpv6MatchBuilder icmpv6match = new Icmpv6MatchBuilder();
2783         
2784         // match
2785         icmpv6match.setIcmpv6Type((short) 135);
2786         icmpv6match.setIcmpv6Code((short) 1);
2787         match.setIcmpv6Match(icmpv6match.build());
2788
2789         return match;
2790     }
2791
2792     private static MatchBuilder createMatch33() {
2793
2794         MatchBuilder match = new MatchBuilder();
2795         Ipv4MatchBuilder ipv4Match = new Ipv4MatchBuilder();
2796         Ipv4Prefix prefix = new Ipv4Prefix("10.0.0.10");
2797         ipv4Match.setIpv4Source(prefix);
2798         Ipv4Match i4m = ipv4Match.build();
2799         match.setLayer3Match(i4m);
2800
2801         EthernetMatchBuilder eth = new EthernetMatchBuilder();
2802         EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
2803         ethTypeBuilder.setType(new EtherType(0xfffeL));
2804         eth.setEthernetType(ethTypeBuilder.build());
2805         match.setEthernetMatch(eth.build());
2806         return match;
2807     }
2808
2809     private static MatchBuilder createInphyportMatch(NodeId nodeId) {
2810         MatchBuilder match = new MatchBuilder();
2811         match.setInPort(new NodeConnectorId(nodeId + ":202"));
2812         match.setInPhyPort(new NodeConnectorId(nodeId + ":10122"));
2813         return match;
2814     }
2815
2816     private static MatchBuilder createEthernetMatch() {
2817         MatchBuilder match = new MatchBuilder();
2818         EthernetMatchBuilder ethmatch = new EthernetMatchBuilder(); // ethernettype
2819         // match
2820         EthernetTypeBuilder ethtype = new EthernetTypeBuilder();
2821         EtherType type = new EtherType(0x0800L);
2822         ethmatch.setEthernetType(ethtype.setType(type).build());
2823
2824         EthernetDestinationBuilder ethdest = new EthernetDestinationBuilder(); // ethernet
2825         // macaddress
2826         // match
2827         MacAddress macdest = new MacAddress(DEST_MAC_ADDRESS);
2828         ethdest.setAddress(macdest);
2829         ethdest.setMask(new MacAddress("ff:ff:ff:00:00:00"));
2830
2831         ethmatch.setEthernetDestination(ethdest.build());
2832
2833         EthernetSourceBuilder ethsrc = new EthernetSourceBuilder();
2834         MacAddress macsrc = new MacAddress(SRC_MAC_ADDRESS);
2835         ethsrc.setAddress(macsrc);
2836         ethsrc.setMask(new MacAddress("ff:ff:00:00:00:00"));
2837
2838         ethmatch.setEthernetSource(ethsrc.build());
2839         match.setEthernetMatch(ethmatch.build());
2840         return match;
2841
2842     }
2843
2844     /**
2845      * @return
2846      */
2847
2848     private static MatchBuilder createVlanMatch() {
2849         MatchBuilder match = new MatchBuilder();
2850         // vlan match
2851         VlanMatchBuilder vlanBuilder = new VlanMatchBuilder(); 
2852         VlanIdBuilder vlanIdBuilder = new VlanIdBuilder();
2853         VlanId vlanId = new VlanId(10);
2854         VlanPcp vpcp = new VlanPcp((short) 3);
2855         vlanBuilder.setVlanPcp(vpcp);
2856         vlanIdBuilder.setVlanId(vlanId);
2857         vlanIdBuilder.setVlanIdPresent(true);
2858         vlanBuilder.setVlanId(vlanIdBuilder.build());
2859         match.setVlanMatch(vlanBuilder.build());
2860         return match;
2861     }
2862
2863     /**
2864      * @return
2865      */
2866     private static MatchBuilder createArpMatch() {
2867         MatchBuilder match = new MatchBuilder();
2868
2869         EthernetMatchBuilder ethmatch = new EthernetMatchBuilder();
2870         MacAddress macdest = new MacAddress(DEST_MAC_ADDRESS);
2871         MacAddress macsrc = new MacAddress(SRC_MAC_ADDRESS);
2872
2873         EthernetTypeBuilder ethtype = new EthernetTypeBuilder();
2874         EtherType type = new EtherType(0x0806L);
2875         ethmatch.setEthernetType(ethtype.setType(type).build());
2876
2877         // ipv4 match
2878         Ipv4Prefix dstip = new Ipv4Prefix("200.71.9.52/10"); 
2879         Ipv4Prefix srcip = new Ipv4Prefix("100.1.1.1/8");
2880
2881         // arp match
2882         ArpMatchBuilder arpmatch = new ArpMatchBuilder(); 
2883         ArpSourceHardwareAddressBuilder arpsrc = new ArpSourceHardwareAddressBuilder();
2884         arpsrc.setAddress(macsrc);
2885         arpsrc.setMask(new MacAddress("ff:ff:ff:00:00:00"));
2886         ArpTargetHardwareAddressBuilder arpdst = new ArpTargetHardwareAddressBuilder();
2887         arpdst.setAddress(macdest);
2888         arpdst.setMask(new MacAddress("ff:ff:00:00:00:00"));
2889         arpmatch.setArpOp(2);
2890         arpmatch.setArpSourceHardwareAddress(arpsrc.build());
2891         arpmatch.setArpTargetHardwareAddress(arpdst.build());
2892         arpmatch.setArpSourceTransportAddress(srcip);
2893         arpmatch.setArpTargetTransportAddress(dstip);
2894
2895         match.setEthernetMatch(ethmatch.build());
2896         match.setLayer3Match(arpmatch.build());
2897
2898         return match;
2899     }
2900
2901
2902     /**
2903      * @return
2904      */
2905     private static MatchBuilder createL3IPv4Match() {
2906         MatchBuilder match = new MatchBuilder();
2907
2908         EthernetMatchBuilder eth = new EthernetMatchBuilder();
2909         EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
2910         ethTypeBuilder.setType(new EtherType(0x0800L));
2911         eth.setEthernetType(ethTypeBuilder.build());
2912         match.setEthernetMatch(eth.build());
2913
2914         Ipv4MatchBuilder ipv4Match = new Ipv4MatchBuilder();
2915         // ipv4 match
2916         Ipv4Prefix dstip = new Ipv4Prefix("200.71.9.52/10"); 
2917         Ipv4Prefix srcip = new Ipv4Prefix("100.1.1.1/8");
2918         Ipv4MatchBuilder ipv4match = new Ipv4MatchBuilder();
2919         ipv4match.setIpv4Destination(dstip);
2920         ipv4match.setIpv4Source(srcip);
2921         match.setLayer3Match(ipv4match.build());
2922
2923         return match;
2924
2925     }
2926
2927     /**
2928      * @return
2929      */
2930     private static MatchBuilder createL3IPv6Match() {
2931         MatchBuilder match = new MatchBuilder();
2932
2933         EthernetMatchBuilder eth = new EthernetMatchBuilder();
2934         EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
2935         ethTypeBuilder.setType(new EtherType(0x86ddL));
2936         eth.setEthernetType(ethTypeBuilder.build());
2937         match.setEthernetMatch(eth.build());
2938
2939         Ipv6Prefix dstip6 = new Ipv6Prefix("2002::2/64");
2940         Ipv6Prefix srcip6 = new Ipv6Prefix("2001:0:0:0:0:0:0:1/56");
2941         Ipv6Address ndtarget = new Ipv6Address("2001:db8:0:1:fd97:f9f0:a810:782e");
2942         MacAddress ndsll = new MacAddress("c2:00:54:f5:00:00");
2943         MacAddress ndtll = new MacAddress("00:0c:29:0e:4c:67");
2944         Ipv6ExtHeaderBuilder nextheader = new Ipv6ExtHeaderBuilder();
2945         nextheader.setIpv6Exthdr(58);
2946         Ipv6LabelBuilder ipv6label = new Ipv6LabelBuilder();
2947         Ipv6FlowLabel label = new Ipv6FlowLabel(10028L);
2948         ipv6label.setIpv6Flabel(label);
2949         ipv6label.setFlabelMask(new Ipv6FlowLabel(1L));
2950
2951         Icmpv6MatchBuilder icmpv6match = new Icmpv6MatchBuilder(); // icmpv6
2952         // match
2953         icmpv6match.setIcmpv6Type((short) 135);
2954         icmpv6match.setIcmpv6Code((short) 0);
2955         match.setIcmpv6Match(icmpv6match.build());
2956
2957         Ipv6MatchBuilder ipv6match = new Ipv6MatchBuilder();
2958         // ipv6match.setIpv6Source(srcip6);
2959         // ipv6match.setIpv6Destination(dstip6);
2960         // ipv6match.setIpv6ExtHeader(nextheader.build());
2961         ipv6match.setIpv6NdSll(ndsll);
2962         ipv6match.setIpv6NdTll(ndtll);
2963         // ipv6match.setIpv6NdTarget(ndtarget);
2964         ipv6match.setIpv6Label(ipv6label.build());
2965
2966         match.setLayer3Match(ipv6match.build());
2967
2968         return match;
2969     }
2970
2971     /**
2972      * @return
2973      */
2974
2975     private static MatchBuilder createICMPv4Match() {
2976         MatchBuilder match = new MatchBuilder();
2977         EthernetMatchBuilder eth = new EthernetMatchBuilder();
2978         EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
2979         ethTypeBuilder.setType(new EtherType(0x0800L));
2980         eth.setEthernetType(ethTypeBuilder.build());
2981         match.setEthernetMatch(eth.build());
2982
2983         IpMatchBuilder ipmatch = new IpMatchBuilder(); // ipv4 version
2984         ipmatch.setIpProtocol((short) 1);
2985         match.setIpMatch(ipmatch.build());
2986
2987         Icmpv4MatchBuilder icmpv4match = new Icmpv4MatchBuilder(); // icmpv4
2988         // match
2989         icmpv4match.setIcmpv4Type((short) 8);
2990         icmpv4match.setIcmpv4Code((short) 0);
2991         match.setIcmpv4Match(icmpv4match.build());
2992         return match;
2993     }
2994
2995     /**
2996      * @return
2997      */
2998     private static MatchBuilder createICMPv6Match() {
2999
3000         MatchBuilder match = new MatchBuilder();
3001         EthernetMatchBuilder eth = new EthernetMatchBuilder();
3002         EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
3003         ethTypeBuilder.setType(new EtherType(0x86ddL));
3004         eth.setEthernetType(ethTypeBuilder.build());
3005         match.setEthernetMatch(eth.build());
3006
3007         IpMatchBuilder ipmatch = new IpMatchBuilder(); // ipv4 version
3008         ipmatch.setIpProtocol((short) 58);
3009         match.setIpMatch(ipmatch.build());
3010
3011         Icmpv6MatchBuilder icmpv6match = new Icmpv6MatchBuilder(); // icmpv6
3012         // match
3013         icmpv6match.setIcmpv6Type((short) 135);
3014         icmpv6match.setIcmpv6Code((short) 1);
3015         match.setIcmpv6Match(icmpv6match.build());
3016
3017         return match;
3018     }
3019
3020     /**
3021      * @return
3022      */
3023     private static MatchBuilder createToSMatch() {
3024         MatchBuilder match = new MatchBuilder();
3025         EthernetMatchBuilder ethmatch = new EthernetMatchBuilder();
3026         EthernetTypeBuilder ethtype = new EthernetTypeBuilder();
3027         EtherType type = new EtherType(0x0800L);
3028         ethmatch.setEthernetType(ethtype.setType(type).build());
3029         match.setEthernetMatch(ethmatch.build());
3030
3031         IpMatchBuilder ipmatch = new IpMatchBuilder(); // ipv4 version
3032         ipmatch.setIpProtocol((short) 6);
3033         Dscp dscp = new Dscp((short) 8);
3034         ipmatch.setIpDscp(dscp);
3035         match.setIpMatch(ipmatch.build());
3036         return match;
3037     }
3038
3039     /**
3040      * @return
3041      */
3042
3043     private static MatchBuilder createL4TCPMatch() {
3044         MatchBuilder match = new MatchBuilder();
3045
3046         EthernetMatchBuilder eth = new EthernetMatchBuilder();
3047         EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
3048         ethTypeBuilder.setType(new EtherType(0x0800L));
3049         eth.setEthernetType(ethTypeBuilder.build());
3050         match.setEthernetMatch(eth.build());
3051
3052         IpMatchBuilder ipmatch = new IpMatchBuilder(); // ipv4 version
3053         ipmatch.setIpProtocol((short) 6);
3054         match.setIpMatch(ipmatch.build());
3055
3056         PortNumber srcport = new PortNumber(1213);
3057         PortNumber dstport = new PortNumber(646);
3058         TcpMatchBuilder tcpmatch = new TcpMatchBuilder(); // tcp match
3059         tcpmatch.setTcpSourcePort(srcport);
3060         tcpmatch.setTcpDestinationPort(dstport);
3061         match.setLayer4Match(tcpmatch.build());
3062
3063         return match;
3064     }
3065
3066     /**
3067      * @return
3068      */
3069     private static MatchBuilder createL4UDPMatch() {
3070         MatchBuilder match = new MatchBuilder();
3071
3072         EthernetMatchBuilder eth = new EthernetMatchBuilder();
3073         EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
3074         ethTypeBuilder.setType(new EtherType(0x0800L));
3075         eth.setEthernetType(ethTypeBuilder.build());
3076         match.setEthernetMatch(eth.build());
3077
3078         IpMatchBuilder ipmatch = new IpMatchBuilder(); // ipv4 version
3079         ipmatch.setIpProtocol((short) 17);
3080         match.setIpMatch(ipmatch.build());
3081
3082         PortNumber srcport = new PortNumber(1325);
3083         PortNumber dstport = new PortNumber(42);
3084         UdpMatchBuilder udpmatch = new UdpMatchBuilder(); // udp match
3085         udpmatch.setUdpDestinationPort(dstport);
3086         udpmatch.setUdpSourcePort(srcport);
3087         match.setLayer4Match(udpmatch.build());
3088
3089         return match;
3090     }
3091
3092     /**
3093      * @return
3094      */
3095     private static MatchBuilder createL4SCTPMatch() {
3096         MatchBuilder match = new MatchBuilder();
3097
3098         EthernetMatchBuilder eth = new EthernetMatchBuilder();
3099         EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
3100         ethTypeBuilder.setType(new EtherType(0x0800L));
3101         eth.setEthernetType(ethTypeBuilder.build());
3102         match.setEthernetMatch(eth.build());
3103
3104         IpMatchBuilder ipmatch = new IpMatchBuilder(); // ipv4 version
3105         ipmatch.setIpProtocol((short) 132);
3106         match.setIpMatch(ipmatch.build());
3107
3108         SctpMatchBuilder sctpmatch = new SctpMatchBuilder();
3109         PortNumber srcport = new PortNumber(1435);
3110         PortNumber dstport = new PortNumber(22);
3111         sctpmatch.setSctpSourcePort(srcport);
3112         sctpmatch.setSctpDestinationPort(dstport);
3113         match.setLayer4Match(sctpmatch.build());
3114
3115         return match;
3116     }
3117
3118     /**
3119      * @return
3120      */
3121     private static MatchBuilder createMetadataMatch() {
3122         MatchBuilder match = new MatchBuilder();
3123         byte[] metamask = new byte[]{(byte) -1, (byte) -1, (byte) -1, 0, 0, 0, (byte) 1, (byte) 1};
3124         MetadataBuilder metadata = new MetadataBuilder(); // metadata match
3125         metadata.setMetadata(BigInteger.valueOf(500L));
3126         metadata.setMetadataMask(new BigInteger(1, metamask));
3127         match.setMetadata(metadata.build());
3128
3129         return match;
3130     }
3131
3132     /**
3133      * @return
3134      */
3135     private static MatchBuilder createMplsMatch() {
3136         MatchBuilder match = new MatchBuilder();
3137
3138         EthernetMatchBuilder eth = new EthernetMatchBuilder();
3139         EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
3140         ethTypeBuilder.setType(new EtherType(0x8847L));
3141         eth.setEthernetType(ethTypeBuilder.build());
3142         match.setEthernetMatch(eth.build());
3143
3144         ProtocolMatchFieldsBuilder protomatch = new ProtocolMatchFieldsBuilder(); // mpls
3145         // match
3146         protomatch.setMplsLabel((long) 36008);
3147         protomatch.setMplsTc((short) 4);
3148         protomatch.setMplsBos((short) 1);
3149         match.setProtocolMatchFields(protomatch.build());
3150
3151         return match;
3152
3153     }
3154
3155     /**
3156      * @return
3157      */
3158     private static MatchBuilder createPbbMatch() {
3159         MatchBuilder match = new MatchBuilder();
3160
3161         EthernetMatchBuilder eth = new EthernetMatchBuilder();
3162         EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
3163         ethTypeBuilder.setType(new EtherType(0x88E7L));
3164         eth.setEthernetType(ethTypeBuilder.build());
3165         match.setEthernetMatch(eth.build());
3166
3167         ProtocolMatchFieldsBuilder protomatch = new ProtocolMatchFieldsBuilder(); // mpls
3168         // match
3169         protomatch.setPbb(new PbbBuilder().setPbbIsid(4L).setPbbMask(new BigInteger(new byte[]{0, 1, 0, 0}).longValue()).build());
3170         match.setProtocolMatchFields(protomatch.build());
3171
3172         return match;
3173
3174     }
3175
3176     /**
3177      * @return
3178      */
3179     private static MatchBuilder createTunnelIDMatch() {
3180         MatchBuilder match = new MatchBuilder();
3181         TunnelBuilder tunnel = new TunnelBuilder(); // tunnel id match
3182         tunnel.setTunnelId(BigInteger.valueOf(10668));
3183         byte[] mask = new byte[]{(byte) -1, (byte) -1, (byte) -1, 0, 0, 0, (byte) 1, (byte) 1};
3184         tunnel.setTunnelMask(new BigInteger(1, mask));
3185         match.setTunnel(tunnel.build());
3186
3187         return match;
3188     }
3189
3190     /**
3191      * Test match for TCP_Flags
3192      *
3193      * @return match containing Ethertype (0x0800), IP Protocol (TCP), TCP_Flag (SYN)
3194      */
3195     //FIXME: move to extensible support
3196     private static MatchBuilder createTcpFlagMatch() {
3197         MatchBuilder match = new MatchBuilder();
3198
3199         // Ethertype match
3200         EthernetMatchBuilder ethernetType = new EthernetMatchBuilder();
3201         EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
3202         ethTypeBuilder.setType(new EtherType(0x0800L));
3203         ethernetType.setEthernetType(ethTypeBuilder.build());
3204         match.setEthernetMatch(ethernetType.build());
3205
3206         // TCP Protocol Match
3207         IpMatchBuilder ipMatch = new IpMatchBuilder(); // ipv4 version
3208         ipMatch.setIpProtocol((short) 6);
3209         match.setIpMatch(ipMatch.build());
3210
3211         // TCP Port Match
3212         PortNumber dstPort = new PortNumber(80);
3213         TcpMatchBuilder tcpMatch = new TcpMatchBuilder();
3214         tcpMatch.setTcpDestinationPort(dstPort);
3215         match.setLayer4Match(tcpMatch.build());
3216         /**
3217          * Defined TCP Flag values in OVS v2.1+
3218          * TCP_FIN 0x001 / TCP_SYN 0x002 / TCP_RST 0x004
3219          * TCP_PSH 0x008 / TCP_ACK 0x010 / TCP_URG 0x020
3220          * TCP_ECE 0x040 / TCP_CWR 0x080 / TCP_NS  0x100
3221          */
3222         TcpFlagMatchBuilder tcpFlagMatch = new TcpFlagMatchBuilder();
3223         tcpFlagMatch.setTcpFlag(0x002);
3224         match.setTcpFlagMatch(tcpFlagMatch.build());
3225
3226         return match;
3227     }
3228
3229     public void _removeMDFlow(final CommandInterpreter ci) {
3230         ReadWriteTransaction modification = dataBroker.newReadWriteTransaction();
3231         NodeBuilder tn = createTestNode(ci.nextArgument());
3232         String flowtype = ci.nextArgument();
3233         FlowBuilder tf;
3234         if (flowtype.equals("fTM")) {
3235             tf = createtablemiss();
3236         } else {
3237             tf = createTestFlow(tn, flowtype, ci.nextArgument());
3238         }
3239         InstanceIdentifier<Flow> path1 = InstanceIdentifier.create(Nodes.class).child(Node.class, tn.getKey())
3240                 .augmentation(FlowCapableNode.class).child(Table.class, new TableKey(tf.getTableId()))
3241                 .child(Flow.class, tf.getKey());
3242         modification.delete(LogicalDatastoreType.CONFIGURATION, path1);
3243         CheckedFuture<Void, TransactionCommitFailedException> commitFuture = modification.submit();
3244         Futures.addCallback(commitFuture, new FutureCallback<Void>() {
3245             @Override
3246             public void onSuccess(Void aVoid) {
3247                 ci.println("Status of Group Data Loaded Transaction: success.");
3248             }
3249
3250             @Override
3251             public void onFailure(Throwable throwable) {
3252                 LOG.error(throwable.getMessage(), throwable);
3253                 ci.println(String.format("Status of Group Data Loaded Transaction : failure. Reason : %s", throwable));
3254             }
3255         });
3256     }
3257
3258     /**
3259      * @param ci arguments: switchId flowType tableNum
3260      *           <p/>
3261      *           <pre>
3262      *                     e.g.: addMDFlow openflow:1 f1 42
3263      *                     </pre>
3264      */
3265     public void _addMDFlow(CommandInterpreter ci) {
3266         NodeBuilder tn = createTestNode(ci.nextArgument());
3267         String flowtype = ci.nextArgument();
3268         FlowBuilder tf;
3269         if (flowtype.equals("fTM")) {
3270             tf = createtablemiss();
3271         } else {
3272             tf = createTestFlow(tn, flowtype, ci.nextArgument());
3273         }
3274         writeFlow(ci, tf, tn);
3275     }
3276
3277     private void writeFlow(final CommandInterpreter ci, FlowBuilder flow, NodeBuilder nodeBuilder) {
3278         ReadWriteTransaction modification = dataBroker.newReadWriteTransaction();
3279         InstanceIdentifier<Flow> path1 = InstanceIdentifier.create(Nodes.class)
3280                 .child(Node.class, nodeBuilder.getKey()).augmentation(FlowCapableNode.class)
3281                 .child(Table.class, new TableKey(flow.getTableId())).child(Flow.class, flow.getKey());
3282         modification.merge(LogicalDatastoreType.CONFIGURATION, nodeBuilderToInstanceId(nodeBuilder), nodeBuilder.build(), true);
3283         modification.merge(LogicalDatastoreType.CONFIGURATION, path1, flow.build(), true);
3284         CheckedFuture<Void, TransactionCommitFailedException> commitFuture = modification.submit();
3285         Futures.addCallback(commitFuture, new FutureCallback<Void>() {
3286             @Override
3287             public void onSuccess(Void aVoid) {
3288                 ci.println("Status of Group Data Loaded Transaction: success.");
3289             }
3290
3291             @Override
3292             public void onFailure(Throwable throwable) {
3293                 LOG.error(throwable.getMessage(), throwable);
3294                 ci.println(String.format("Status of Group Data Loaded Transaction : failure. Reason : %s", throwable));
3295             }
3296         });
3297     }
3298
3299     public void _modifyMDFlow(CommandInterpreter ci) {
3300         NodeBuilder tn = createTestNode(ci.nextArgument());
3301         FlowBuilder tf = createTestFlow(tn, ci.nextArgument(), ci.nextArgument());
3302         tf.setFlowName(UPDATED_FLOW_NAME);
3303         writeFlow(ci, tf, tn);
3304         tf.setFlowName(ORIGINAL_FLOW_NAME);
3305         writeFlow(ci, tf, tn);
3306     }
3307
3308     private static NodeRef createNodeRef(String string) {
3309         NodeKey key = new NodeKey(new NodeId(string));
3310         InstanceIdentifier<Node> path = InstanceIdentifier.create(Nodes.class).child(Node.class, key);
3311
3312         return new NodeRef(path);
3313     }
3314
3315     @Override
3316     public String getHelp() {
3317         return "No help";
3318     }
3319
3320     /*
3321      * usage testSwitchFlows <numberOfSwitches> <numberOfFlows> <warmup iterations> <Number Of Threads>
3322      * ex: _perfFlowTest 10 5 1 2
3323      */
3324     public void _perfFlowTest(CommandInterpreter ci) {
3325
3326         String numberOfSwtichesStr = ci.nextArgument();
3327         String numberOfFlowsStr = ci.nextArgument();
3328         String warmupIterationsStr = ci.nextArgument();
3329         String threadCountStr = ci.nextArgument();
3330         String warmUpStr = ci.nextArgument();
3331
3332         Collection<String> testResults = null;
3333         if (testResults == null) {
3334             testResults = new ArrayList<String>();
3335         }
3336
3337         int numberOfSwtiches = 0;
3338         int numberOfFlows = 0;
3339         int warmupIterations = 0;
3340         boolean warmUpIterations = false;
3341
3342         int threadCount = 0;
3343         if (numberOfSwtichesStr != null && !numberOfSwtichesStr.trim().equals("")) {
3344             numberOfSwtiches = Integer.parseInt(numberOfSwtichesStr);
3345         } else {
3346             numberOfSwtiches = 2;
3347         }
3348
3349         if (numberOfFlowsStr != null && !numberOfFlowsStr.trim().equals("")) {
3350             numberOfFlows = Integer.parseInt(numberOfFlowsStr);
3351         } else {
3352             numberOfFlows = 2;
3353         }
3354
3355         if (warmupIterationsStr != null && !warmupIterationsStr.trim().equals("")) {
3356             warmupIterations = Integer.parseInt(warmupIterationsStr);
3357         } else {
3358             warmupIterations = 2;
3359         }
3360
3361         if (threadCountStr != null && !threadCountStr.trim().equals("")) {
3362             threadCount = Integer.parseInt(threadCountStr);
3363         } else {
3364             threadCount = 2;
3365         }
3366         if (warmUpStr != null && !warmUpStr.trim().equals("") && warmUpStr.trim().equals("true")) {
3367             warmUpIterations = true;
3368         } else {
3369             warmUpIterations = false;
3370         }
3371         ci.println("*     Test Configurations*");
3372         ci.println("*     numberOfSwtiches:::" + numberOfSwtiches + "");
3373         ci.println("*     numberOfFlows:::" + numberOfFlows + "");
3374         ci.println("*     warmupIterations:::" + warmupIterations + "");
3375         ci.println("*     Number of Threads :::" + threadCount + "");
3376         ci.println("*     Warmup Required? :::" + warmUpIterations + "");
3377
3378         String dataPath = "openflow:1";
3379         NodeBuilder tn;
3380         FlowBuilder tf;
3381         String tableId = "0";
3382         if (warmUpIterations) {
3383             ci.println("----Warmup Started-----");
3384             for (int j = 1; j <= warmupIterations; j++) {
3385                 for (int i = 1; i <= numberOfSwtiches; i++) {
3386                     dataPath = "openflow:" + i;
3387                     tn = createTestNode(dataPath);
3388                     for (int flow = 1; flow < numberOfFlows; flow++) {
3389                         tf = createTestFlowPerfTest("f1", tableId, flow);
3390                         writeFlow(ci, tf, tn);
3391                     }
3392                 }
3393             }
3394
3395             ci.println("----Warmup Done-----");
3396         }
3397         try {
3398             ExecutorService executor = Executors.newFixedThreadPool(threadCount);
3399             int tableID = 0;
3400             for (int t = 0; t < threadCount; t++) {
3401                 tableID = t + 1;
3402                 Runnable tRunnable = new TestFlowThread(numberOfSwtiches, numberOfFlows, ci, t, tableID);
3403                 executor.execute(tRunnable);
3404             }
3405             executor.shutdown();
3406             executor.awaitTermination(1, TimeUnit.SECONDS);
3407         } catch (Exception e) {
3408             ci.println("Exception:" + e.getMessage());
3409         }
3410     }
3411
3412     public class TestFlowThread implements Runnable {
3413
3414         int numberOfSwitches;
3415         int numberOfFlows;
3416         int testTime;
3417         CommandInterpreter ci;
3418         int testFlowsAdded;
3419         int theadNumber;
3420         Collection<String> testResults = null;
3421         int tableID = 0;
3422
3423         TestFlowThread(int numberOfSwtiches, int numberOfFlows, CommandInterpreter ci, int t, int tableID) {
3424             this.numberOfSwitches = numberOfSwtiches;
3425             this.numberOfFlows = numberOfFlows;
3426             this.ci = ci;
3427             this.theadNumber = t;
3428             this.tableID = tableID;
3429         }
3430
3431         @Override
3432         public void run() {
3433             executeFlow();
3434         }
3435
3436         public void executeFlow() {
3437
3438             String dataPath = "openflow:1";
3439             NodeBuilder tn;
3440             FlowBuilder tf;
3441             //String tableId = "0";
3442
3443             ci.println("New Thread started with id:  ID_"
3444                     + this.theadNumber);
3445             int totalNumberOfFlows = 0;
3446             long startTime = System.currentTimeMillis();
3447
3448             for (int i = 1; i <= this.numberOfSwitches; i++) {
3449                 dataPath = "openflow:" + i;
3450                 tn = createTestNode(dataPath);
3451                 for (int flow2 = 1; flow2 <= this.numberOfFlows; flow2++) {
3452                     tf = createTestFlowPerfTest("f1", "" + this.tableID, flow2);
3453                     writeFlow(this.ci, tf, tn);
3454                     totalNumberOfFlows++;
3455                 }
3456             }
3457             long endTime = System.currentTimeMillis();
3458             long timeInSeconds = Math.round((endTime - startTime) / 1000);
3459             if (timeInSeconds > 0) {
3460                 ci.println("Total flows added in Thread:" + this.theadNumber + ": Flows/Sec::" + Math.round(totalNumberOfFlows / timeInSeconds));
3461             } else {
3462                 ci.println("Total flows added in Thread:" + this.theadNumber + ": Flows/Sec::" + totalNumberOfFlows);
3463             }
3464         }
3465
3466     }
3467
3468     /*
3469      * usage testAllFlows <dp>
3470      * ex: _perfFlowTest 1
3471      */
3472     public void _testAllFlows(CommandInterpreter ci) {
3473         String dataPathID = ci.nextArgument();
3474         int numberOfFlows = 82;
3475         if (dataPathID == null || dataPathID.trim().equals("")) {
3476             dataPathID = "1";
3477         }
3478         ci.println("*     Test All Flows        *");
3479         ci.println("*     dataPathID:::" + dataPathID + "");
3480         String dataPath = "openflow:" + dataPathID;
3481         String tableId = "0";
3482         NodeBuilder tn = createTestNode(dataPath);
3483         FlowBuilder tf;
3484         for (int flow = 1; flow < numberOfFlows; flow++) {
3485             String flowID = "f" + flow;
3486             try {
3487                 tf = createTestFlow(tn, flowID, tableId);
3488                 writeFlow(ci, tf, tn);
3489             } catch (Exception e) {
3490                 ci.println("--Test Failed--Issue found while adding flow" + flow);
3491                 break;
3492             }
3493         }
3494     }
3495 }