Bug 1035 - Invalid mask in CommandProvider for uint64/byte conversion
[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 java.math.BigInteger;
12 import java.util.ArrayList;
13 import java.util.List;
14 import java.util.concurrent.ExecutionException;
15 import java.util.concurrent.Future;
16 import java.util.List;
17 import java.util.concurrent.ExecutionException;
18 import java.util.concurrent.ExecutorService;
19 import java.util.concurrent.Executors;
20 import java.util.concurrent.Future;
21 import java.util.concurrent.TimeUnit;
22 import java.util.Collection;
23 import java.util.Iterator;
24
25 import org.eclipse.osgi.framework.console.CommandInterpreter;
26 import org.eclipse.osgi.framework.console.CommandProvider;
27 import org.opendaylight.controller.md.sal.common.api.TransactionStatus;
28 import org.opendaylight.controller.md.sal.common.api.data.DataModification;
29 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
30 import org.opendaylight.controller.sal.binding.api.NotificationService;
31 import org.opendaylight.controller.sal.binding.api.data.DataBrokerService;
32 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Dscp;
33 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Prefix;
34 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6Address;
35 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6FlowLabel;
36 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6Prefix;
37 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber;
38 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Uri;
39 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress;
40 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.VlanCfi;
41 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.ControllerActionCaseBuilder;
42 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.CopyTtlInCaseBuilder;
43 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.CopyTtlOutCaseBuilder;
44 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DecMplsTtlCaseBuilder;
45 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DecNwTtlCaseBuilder;
46 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DropActionCaseBuilder;
47 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.FloodActionCaseBuilder;
48 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.FloodAllActionCaseBuilder;
49 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.GroupActionCaseBuilder;
50 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.HwPathActionCaseBuilder;
51 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.LoopbackActionCaseBuilder;
52 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.OutputActionCaseBuilder;
53 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopMplsActionCaseBuilder;
54 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopPbbActionCaseBuilder;
55 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopVlanActionCaseBuilder;
56 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushMplsActionCaseBuilder;
57 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushPbbActionCaseBuilder;
58 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushVlanActionCaseBuilder;
59 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetDlDstActionCaseBuilder;
60 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetDlSrcActionCaseBuilder;
61 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetDlTypeActionCaseBuilder;
62 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetFieldCaseBuilder;
63 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetMplsTtlActionCaseBuilder;
64 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNextHopActionCaseBuilder;
65 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwDstActionCaseBuilder;
66 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwSrcActionCaseBuilder;
67 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwTosActionCaseBuilder;
68 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwTtlActionCaseBuilder;
69 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetQueueActionCaseBuilder;
70 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetTpDstActionCaseBuilder;
71 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetTpSrcActionCaseBuilder;
72 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetVlanCfiActionCaseBuilder;
73 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetVlanIdActionCaseBuilder;
74 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetVlanPcpActionCaseBuilder;
75 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.StripVlanActionCaseBuilder;
76 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SwPathActionCaseBuilder;
77 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.controller.action._case.ControllerActionBuilder;
78 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.copy.ttl.in._case.CopyTtlInBuilder;
79 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.copy.ttl.out._case.CopyTtlOutBuilder;
80 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.dec.mpls.ttl._case.DecMplsTtlBuilder;
81 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.dec.nw.ttl._case.DecNwTtl;
82 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.dec.nw.ttl._case.DecNwTtlBuilder;
83 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.drop.action._case.DropAction;
84 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.drop.action._case.DropActionBuilder;
85 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.flood.action._case.FloodActionBuilder;
86 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.flood.all.action._case.FloodAllActionBuilder;
87 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.group.action._case.GroupActionBuilder;
88 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.hw.path.action._case.HwPathActionBuilder;
89 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.loopback.action._case.LoopbackActionBuilder;
90 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.output.action._case.OutputActionBuilder;
91 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.pop.mpls.action._case.PopMplsActionBuilder;
92 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.pop.pbb.action._case.PopPbbActionBuilder;
93 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.pop.vlan.action._case.PopVlanActionBuilder;
94 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.push.mpls.action._case.PushMplsActionBuilder;
95 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.push.pbb.action._case.PushPbbActionBuilder;
96 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.push.vlan.action._case.PushVlanActionBuilder;
97 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.dl.dst.action._case.SetDlDstActionBuilder;
98 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.dl.src.action._case.SetDlSrcActionBuilder;
99 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.dl.type.action._case.SetDlTypeActionBuilder;
100 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.field._case.SetFieldBuilder;
101 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.mpls.ttl.action._case.SetMplsTtlActionBuilder;
102 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.next.hop.action._case.SetNextHopActionBuilder;
103 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.dst.action._case.SetNwDstActionBuilder;
104 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.src.action._case.SetNwSrcActionBuilder;
105 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.tos.action._case.SetNwTosActionBuilder;
106 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.ttl.action._case.SetNwTtlActionBuilder;
107 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.queue.action._case.SetQueueActionBuilder;
108 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.tp.dst.action._case.SetTpDstActionBuilder;
109 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.tp.src.action._case.SetTpSrcActionBuilder;
110 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.vlan.cfi.action._case.SetVlanCfiActionBuilder;
111 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.vlan.id.action._case.SetVlanIdActionBuilder;
112 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.vlan.pcp.action._case.SetVlanPcpActionBuilder;
113 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.strip.vlan.action._case.StripVlanActionBuilder;
114 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.sw.path.action._case.SwPathActionBuilder;
115 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action;
116 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder;
117 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionKey;
118 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.address.Ipv4Builder;
119 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
120 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId;
121 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table;
122 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey;
123 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow;
124 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder;
125 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey;
126 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.SalFlowListener;
127 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowCookie;
128 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowModFlags;
129 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.OutputPortValues;
130 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.InstructionsBuilder;
131 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
132 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ApplyActionsCaseBuilder;
133 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.GoToTableCaseBuilder;
134 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.MeterCaseBuilder;
135 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.WriteMetadataCaseBuilder;
136 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.apply.actions._case.ApplyActionsBuilder;
137 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.go.to.table._case.GoToTableBuilder;
138 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.meter._case.MeterBuilder;
139 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.write.metadata._case.WriteMetadataBuilder;
140 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction;
141 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionBuilder;
142 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionKey;
143 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId;
144 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
145 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef;
146 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
147 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
148 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeBuilder;
149 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
150 import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.EtherType;
151 import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanId;
152 import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanPcp;
153 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterId;
154 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.arp.match.fields.ArpSourceHardwareAddressBuilder;
155 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.arp.match.fields.ArpTargetHardwareAddressBuilder;
156 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetDestinationBuilder;
157 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetSourceBuilder;
158 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetTypeBuilder;
159 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ipv6.match.fields.Ipv6ExtHeaderBuilder;
160 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ipv6.match.fields.Ipv6LabelBuilder;
161 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatchBuilder;
162 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Icmpv4MatchBuilder;
163 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Icmpv6MatchBuilder;
164 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.IpMatchBuilder;
165 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.MetadataBuilder;
166 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.ProtocolMatchFieldsBuilder;
167 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.TcpFlagMatchBuilder;
168 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.TunnelBuilder;
169 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.VlanMatchBuilder;
170 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.ArpMatchBuilder;
171 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4Match;
172 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4MatchBuilder;
173 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6MatchBuilder;
174 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.SctpMatchBuilder;
175 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.TcpMatchBuilder;
176 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.UdpMatchBuilder;
177 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.protocol.match.fields.PbbBuilder;
178 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.vlan.match.fields.VlanIdBuilder;
179 import org.opendaylight.yang.gen.v1.urn.opendaylight.node.error.service.rev140410.NodeErrorListener;
180 import org.opendaylight.yangtools.concepts.Registration;
181 import org.opendaylight.yangtools.yang.binding.DataObject;
182 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
183 import org.opendaylight.yangtools.yang.common.RpcResult;
184 import org.osgi.framework.BundleContext;
185 import org.slf4j.Logger;
186 import org.slf4j.LoggerFactory;
187
188 public class OpenflowpluginTestCommandProvider implements CommandProvider {
189
190     private static final Logger LOG = LoggerFactory.getLogger(OpenflowpluginTestCommandProvider.class);
191
192     private DataBrokerService dataBrokerService;
193     private ProviderContext pc;
194     private final BundleContext ctx;
195     private FlowBuilder testFlow;
196     private NodeBuilder testNode;
197     private final String originalFlowName = "Foo";
198     private final String updatedFlowName = "Bar";
199     private final SalFlowListener flowEventListener = new FlowEventListenerLoggingImpl();
200     private final NodeErrorListener nodeErrorListener = new NodeErrorListenerLoggingImpl();
201     private static NotificationService notificationService;
202     private Registration<org.opendaylight.yangtools.yang.binding.NotificationListener> listener1Reg;
203     private Registration<org.opendaylight.yangtools.yang.binding.NotificationListener> listener2Reg;
204
205     public OpenflowpluginTestCommandProvider(BundleContext ctx) {
206         this.ctx = ctx;
207     }
208
209     public void onSessionInitiated(ProviderContext session) {
210         pc = session;
211         notificationService = session.getSALService(NotificationService.class);
212         // For switch events
213         listener1Reg = notificationService.registerNotificationListener(flowEventListener);
214         listener2Reg = notificationService.registerNotificationListener(nodeErrorListener);
215         dataBrokerService = session.getSALService(DataBrokerService.class);
216         ctx.registerService(CommandProvider.class.getName(), this, null);
217         createTestFlow(createTestNode(null), null, null);
218     }
219
220     private NodeBuilder createTestNode(String nodeId) {
221         if (nodeId == null) {
222             nodeId = OpenflowpluginTestActivator.NODE_ID;
223         }
224         NodeRef nodeOne = createNodeRef(nodeId);
225         NodeBuilder builder = new NodeBuilder();
226         builder.setId(new NodeId(nodeId));
227         builder.setKey(new NodeKey(builder.getId()));
228         testNode = builder;
229         return builder;
230     }
231
232     private InstanceIdentifier<Node> nodeBuilderToInstanceId(NodeBuilder node) {
233         return InstanceIdentifier.builder(Nodes.class).child(Node.class, node.getKey()).toInstance();
234     }
235
236     private FlowBuilder createTestFlow(NodeBuilder nodeBuilder, String flowTypeArg, String tableId) {
237
238         FlowBuilder flow = new FlowBuilder();
239         long id = 123;
240
241         String flowType = flowTypeArg;
242         if (flowType == null) {
243             flowType = "f1";
244         }
245         
246         flow.setPriority(2);
247
248         switch (flowType) {
249         case "f1":
250             id += 1;
251             flow.setMatch(createMatch1().build());
252             flow.setInstructions(createDecNwTtlInstructions().build());
253             break;
254         case "f2":
255             id += 2;
256             flow.setMatch(createMatch2().build());
257             flow.setInstructions(createDropInstructions().build());
258             break;
259         case "f3":
260             id += 3;
261             flow.setMatch(createMatch3().build());
262             flow.setInstructions(createDropInstructions().build());
263             break;
264         case "f4":
265             id += 4;
266             flow.setMatch(createEthernetMatch().build());
267             flow.setInstructions(createDropInstructions().build());
268             break;
269         case "f5":
270             id += 5;
271             flow.setMatch(createMatch1().build());
272             flow.setInstructions(createAppyActionInstruction().build());
273             break;
274         case "f6":
275             id += 6;
276             flow.setMatch(createMatch1().build());
277             flow.setInstructions(createGotoTableInstructions().build());
278             break;
279         case "f7":
280             id += 7;
281             flow.setMatch(createMatch1().build());
282             flow.setInstructions(createMeterInstructions().build());
283             break;
284         case "f8":
285             id += 8;
286             flow.setMatch(createMatch1().build());
287             flow.setInstructions(createAppyActionInstruction1().build());
288             break;
289         case "f9":
290             id += 9;
291             flow.setMatch(createMatch1().build());
292             flow.setInstructions(createAppyActionInstruction2().build());
293             break;
294         case "f10":
295             id += 10;
296             flow.setMatch(createMatch1().build());
297             flow.setInstructions(createAppyActionInstruction3().build());
298             break;
299         case "f11":
300             id += 11;
301             flow.setMatch(createMatch1().build());
302             flow.setInstructions(createAppyActionInstruction4().build());
303             break;
304         case "f12":
305             id += 12;
306             flow.setMatch(createMatch1().build());
307             flow.setInstructions(createAppyActionInstruction5().build());
308             break;
309         case "f13":
310             id += 13;
311             flow.setMatch(createMatch1().build());
312             flow.setInstructions(createAppyActionInstruction6().build());
313             break;
314         case "f14":
315             id += 14;
316             flow.setMatch(createMatch1().build());
317             flow.setInstructions(createAppyActionInstruction7().build());
318             break;
319         case "f15":
320             id += 15;
321             flow.setMatch(createMatch1().build());
322             flow.setInstructions(createAppyActionInstruction8().build());
323             break;
324         case "f16":
325             id += 16;
326             flow.setMatch(createMatch1().build());
327             flow.setInstructions(createAppyActionInstruction9().build());
328             break;
329         case "f17":
330             id += 17;
331             flow.setMatch(createMatch1().build());
332             flow.setInstructions(createAppyActionInstruction10().build());
333             break;
334         case "f18":
335             id += 18;
336             flow.setMatch(createMatch1().build());
337             flow.setInstructions(createAppyActionInstruction11().build());
338             break;
339         case "f19":
340             id += 19;
341             flow.setMatch(createMatch1().build());
342             flow.setInstructions(createAppyActionInstruction12().build());
343             break;
344         case "f20":
345             id += 20;
346             flow.setMatch(createMatch1().build());
347             flow.setInstructions(createAppyActionInstruction13().build());
348             break;
349         case "f21":
350             id += 21;
351             flow.setMatch(createMatch1().build());
352             flow.setInstructions(createAppyActionInstruction14().build());
353             break;
354         case "f22":
355             id += 22;
356             flow.setMatch(createMatch1().build());
357             flow.setInstructions(createAppyActionInstruction15().build());
358             break;
359         case "f23":
360             id += 23;
361             // f23 can be used as test-case for generating error notification
362             // if the particular group is not configured - tested
363             flow.setMatch(createMatch1().build());
364             flow.setInstructions(createAppyActionInstruction16().build());
365             break;
366         case "f24":
367             id += 24;
368             flow.setMatch(createMatch1().build());
369             flow.setInstructions(createAppyActionInstruction17().build());
370             break;
371         case "f25":
372             id += 25;
373             flow.setMatch(createMatch1().build());
374             flow.setInstructions(createAppyActionInstruction18().build());
375             break;
376         case "f26":
377             id += 26;
378             flow.setMatch(createMatch1().build());
379             flow.setInstructions(createAppyActionInstruction19().build());
380             break;
381         case "f27":
382             id += 27;
383             flow.setMatch(createMatch1().build());
384             flow.setInstructions(createMetadataInstructions().build());
385             break;
386         case "f28":
387             id += 28;
388             flow.setMatch(createMatch1().build());
389             flow.setInstructions(createAppyActionInstruction20().build());
390             break;
391         case "f29":
392             id += 29;
393             flow.setMatch(createMatch1().build());
394             flow.setInstructions(createAppyActionInstruction21().build());
395             break;
396         case "f30":
397             id += 30;
398             flow.setMatch(createMatch1().build());
399             flow.setInstructions(createAppyActionInstruction22().build());
400             break;
401         case "f31":
402             id += 31;
403             flow.setMatch(createMatch1().build());
404             flow.setInstructions(createAppyActionInstruction23(nodeBuilder.getId()).build());
405             break;
406         case "f32":
407             id += 32;
408             flow.setMatch(createMatch1().build());
409             flow.setInstructions(createAppyActionInstruction24().build());
410             break;
411         case "f33":
412             id += 33;
413             flow.setMatch(createMatch1().build());
414             flow.setInstructions(createAppyActionInstruction25().build());
415             break;
416         case "f34":
417             id += 34;
418             flow.setMatch(createMatch1().build());
419             flow.setInstructions(createAppyActionInstruction26().build());
420             break;
421         case "f35":
422             id += 35;
423             flow.setMatch(createMatch1().build());
424             flow.setInstructions(createAppyActionInstruction27().build());
425             break;
426         case "f36":
427             id += 36;
428             flow.setMatch(createMatch1().build());
429             flow.setInstructions(createAppyActionInstruction28().build());
430             break;
431         case "f37":
432             id += 37;
433             flow.setMatch(createMatch1().build());
434             flow.setInstructions(createAppyActionInstruction29().build());
435             break;
436         case "f38":
437             id += 38;
438             flow.setMatch(createMatch1().build());
439             flow.setInstructions(createAppyActionInstruction30().build());
440             break;
441         case "f39":
442             id += 39;
443             flow.setMatch(createMatch1().build());
444             flow.setInstructions(createAppyActionInstruction31().build());
445             break;
446         case "f40":
447             id += 40;
448             flow.setMatch(createMatch1().build());
449             flow.setInstructions(createAppyActionInstruction32().build());
450             break;
451         case "f41":
452             id += 41;
453             flow.setMatch(createMatch1().build());
454             flow.setInstructions(createAppyActionInstruction33().build());
455             break;
456         case "f42":
457             id += 42;
458             flow.setMatch(createMatch1().build());
459             flow.setInstructions(createAppyActionInstruction34().build());
460             break;
461         case "f43":
462             id += 43;
463             flow.setMatch(createICMPv6Match().build());
464             flow.setInstructions(createDecNwTtlInstructions().build());
465             break;
466         case "f44":
467             id += 44;
468             flow.setMatch(createInphyportMatch(nodeBuilder.getId()).build());
469             flow.setInstructions(createDropInstructions().build());
470             break;
471         case "f45":
472             id += 45;
473             flow.setMatch(createMetadataMatch().build());
474             flow.setInstructions(createDropInstructions().build());
475             break;
476         case "f46":
477             id += 46;
478             flow.setMatch(createL3IPv6Match().build());
479             flow.setInstructions(createDecNwTtlInstructions().build());
480             break;
481         case "f47":
482             id += 47;
483             flow.setMatch(createL4SCTPMatch().build());
484             flow.setInstructions(createAppyActionInstruction().build());
485             break;
486         case "f48":
487             id += 48;
488             flow.setMatch(createTunnelIDMatch().build());
489             flow.setInstructions(createGotoTableInstructions().build());
490             break;
491         case "f49":
492             id += 49;
493             flow.setMatch(createVlanMatch().build());
494             flow.setInstructions(createMeterInstructions().build());
495             break;
496         case "f50":
497             id += 50;
498             flow.setMatch(createPbbMatch().build());
499             flow.setInstructions(createMeterInstructions().build());
500             break;
501         case "f51":
502             id += 51;
503             flow.setMatch(createVlanMatch().build());
504             flow.setInstructions(createDropInstructions().build());
505             break;
506         case "f52":
507             id += 52;
508             flow.setMatch(createL4TCPMatch().build());
509             flow.setInstructions(createDropInstructions().build());
510             break;
511
512         case "f53":
513             id += 53;
514             flow.setMatch(createL4UDPMatch().build());
515             flow.setInstructions(createDropInstructions().build());
516             break;
517         case "f54":
518             id += 54;
519             flow.setMatch(new MatchBuilder().build());
520             flow.setInstructions(createSentToControllerInstructions().build());
521             flow.setPriority(0);
522             break;
523         case "f55":
524             id += 55;
525             flow.setMatch(createToSMatch().build());
526             flow.setInstructions(createDropInstructions().build());
527             break;
528         case "f56":
529             id += 56;
530             flow.setMatch(createToSMatch().build());
531             flow.setInstructions(createOutputInstructions("INPORT", 10).build());
532             break;
533         case "f57":
534             id += 57;
535             flow.setMatch(createToSMatch().build());
536             flow.setInstructions(createOutputInstructions("FLOOD", 20).build());
537             break;
538         case "f58":
539             id += 58;
540             flow.setMatch(createToSMatch().build());
541             flow.setInstructions(createOutputInstructions("ALL", 30).build());
542             break;
543         case "f59":
544             id += 59;
545             flow.setMatch(createToSMatch().build());
546             flow.setInstructions(createOutputInstructions("NORMAL", 40).build());
547             break;
548         case "f60":
549             id += 60;
550             flow.setMatch(createToSMatch().build());
551             flow.setInstructions(createOutputInstructions("LOCAL", 50).build());
552             break;
553         case "f61":
554             id += 61;
555             flow.setMatch(createToSMatch().build());
556             flow.setInstructions(createOutputInstructions("TABLE", 60).build());
557             break;
558         case "f62":
559             id += 62;
560             flow.setMatch(createToSMatch().build());
561             flow.setInstructions(createOutputInstructions("NONE", 70).build());
562             break;
563         case "f63":
564             id += 63;
565             flow.setMatch(createToSMatch().build());
566             flow.setInstructions(createStripVlanInstructions().build());
567             flow.setBarrier(Boolean.TRUE);
568             break;
569         case "f64":
570             id += 64;
571             flow.setMatch(createMatch1().build());
572             flow.setInstructions(createAppyActionInstruction35().build());
573             break;
574         case "f65":
575             id += 65;
576             flow.setMatch(createMatch1().build());
577             flow.setInstructions(createAppyActionInstruction36().build());
578             break;
579         case "f66":
580             id += 66;
581             flow.setMatch(createMatch1().build());
582             flow.setInstructions(createAppyActionInstruction37().build());
583             break;
584         case "f67":
585             id += 67;
586             flow.setMatch(createMatch1().build());
587             flow.setInstructions(createAppyActionInstruction38().build());
588             break;
589         case "f68":
590             id += 68;
591             flow.setMatch(createL4TCPMatch().build());
592             flow.setInstructions(createAppyActionInstruction39().build());
593             break;
594         case "f69":
595             id += 69;
596             flow.setMatch(createL4UDPMatch().build());
597             flow.setInstructions(createAppyActionInstruction40().build());
598             break;
599         case "f70":
600             id += 70;
601             flow.setMatch(createL4SCTPMatch().build());
602             flow.setInstructions(createAppyActionInstruction41().build());
603             break;
604         case "f71":
605             id += 71;
606             flow.setMatch(createICMPv4Match().build());
607             flow.setInstructions(createAppyActionInstruction42().build());
608             break;
609         case "f72":
610             id += 72;
611             flow.setMatch(createArpMatch().build());
612             flow.setInstructions(createAppyActionInstruction43().build());
613             break;
614         case "f73":
615             id += 73;
616             flow.setMatch(createL3IPv6Match().build());
617             flow.setInstructions(createAppyActionInstruction44().build());
618             break;
619         case "f74":
620             id += 74;
621             flow.setMatch(createICMPv6Match().build());
622             flow.setInstructions(createAppyActionInstruction45().build());
623             break;
624         case "f75":
625             id += 75;
626             flow.setMatch(createMplsMatch().build());
627             flow.setInstructions(createAppyActionInstruction46().build());
628             break;
629         case "f76":
630             id += 76;
631             flow.setMatch(createPbbMatch().build());
632             flow.setInstructions(createAppyActionInstruction47().build());
633             break;
634         case "f77":
635             id += 77;
636             flow.setMatch(createTunnelIDMatch().build());
637             flow.setInstructions(createAppyActionInstruction48().build());
638             break;
639         case "f78":
640             id += 78;
641             flow.setMatch(createMatch33().build());
642             flow.setInstructions(createDropInstructions().build());
643             break;
644         case "f79":
645             id += 79;
646             flow.setMatch(createICMPv6Match1().build());
647             flow.setInstructions(createDecNwTtlInstructions().build());
648             break;
649         case "f80":
650             id += 80;
651             flow.setMatch(createMatch1().build());
652             flow.setInstructions(createAppyActionInstruction88().build());
653             break;
654         case "f81":
655             id += 81;
656             flow.setMatch(createLLDPMatch().build());
657             flow.setInstructions(createSentToControllerInstructions().build());
658             break;
659         case "f82":
660             id += 82;
661             flow.setMatch(createToSMatch().build());
662             flow.setInstructions(createOutputInstructions().build());
663             break;
664         case "f83":
665             id += 83; // Test TCP_Flag Match
666             flow.setMatch(createTcpFlagMatch().build());
667             flow.setInstructions(createDropInstructions().build());
668             break;
669         default:
670             LOG.warn("flow type not understood: {}", flowType);
671         }
672
673         FlowKey key = new FlowKey(new FlowId(Long.toString(id)));
674         if (null == flow.isBarrier()) {
675             flow.setBarrier(Boolean.FALSE);
676         }
677         // flow.setBufferId(new Long(12));
678         BigInteger value = new BigInteger("10", 10);
679         // BigInteger outputPort = new BigInteger("65535", 10);
680         flow.setCookie(new FlowCookie(value));
681         flow.setCookieMask(new FlowCookie(value));
682         flow.setHardTimeout(0);
683         flow.setIdleTimeout(0);
684         flow.setInstallHw(false);
685         flow.setStrict(false);
686         flow.setContainerName(null);
687         flow.setFlags(new FlowModFlags(false, false, false, false, true));
688         flow.setId(new FlowId("12"));
689         flow.setTableId(getTableId(tableId));
690         // commenting setOutGroup and setOutPort, as by default
691         // OFPG_ANY is send
692         // enable setOutGroup and setOutPort to enable output filtering
693         // flow.setOutGroup(new Long(2));
694         // set outport to OFPP_NONE (65535) to disable remove restriction for
695         // flow
696         // flow.setOutPort(outputPort);
697
698         flow.setKey(key);
699         flow.setFlowName(originalFlowName + "X" + flowType);
700         testFlow = flow;
701         return flow;
702     }
703
704     
705     private FlowBuilder createTestFlow_perfTest(NodeBuilder nodeBuilder, String flowTypeArg, String tableId, int id) {
706
707         FlowBuilder flow = new FlowBuilder();
708         //long id = 123;
709
710         String flowType = flowTypeArg;
711         if (flowType == null) {
712             flowType = "f1";
713         }
714         
715         flow.setPriority(id);
716
717         switch (flowType) {
718         case "f1":
719             id += 1;
720             flow.setMatch(createMatch1().build());
721             flow.setInstructions(createDecNwTtlInstructions().build());
722             break;
723         default:
724             LOG.warn("flow type not understood: {}", flowType);
725         }
726
727         FlowKey key = new FlowKey(new FlowId(Long.toString(id)));
728         if (null == flow.isBarrier()) {
729             flow.setBarrier(Boolean.FALSE);
730         }
731         // flow.setBufferId(new Long(12));
732         BigInteger value = new BigInteger("10", 10);
733         // BigInteger outputPort = new BigInteger("65535", 10);
734         flow.setCookie(new FlowCookie(value));
735         flow.setCookieMask(new FlowCookie(value));
736         flow.setHardTimeout(0);
737         flow.setIdleTimeout(0);
738         flow.setInstallHw(false);
739         flow.setStrict(false);
740         flow.setContainerName(null);
741         flow.setFlags(new FlowModFlags(false, false, false, false, true));
742         flow.setId(new FlowId("12"));
743         flow.setTableId(getTableId(tableId));
744         // commenting setOutGroup and setOutPort, as by default
745         // OFPG_ANY is send
746         // enable setOutGroup and setOutPort to enable output filtering
747         // flow.setOutGroup(new Long(2));
748         // set outport to OFPP_NONE (65535) to disable remove restriction for
749         // flow
750         // flow.setOutPort(outputPort);
751
752         flow.setKey(key);
753         flow.setFlowName(originalFlowName + "X" + flowType);
754         testFlow = flow;
755         return flow;
756     }
757     private FlowBuilder createtablemiss(NodeBuilder nodeBuilder, String flowTypeArg, String tableId) {
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         short table = 2;
773         try {
774             table = Short.parseShort(tableId);
775         } catch (Exception ex) {
776             // ignore exception and continue with default value
777         }
778
779         return table;
780
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(new BigInteger("10", 10));
839         aab.setMetadataMask(new BigInteger("12", 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(new Integer(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(new Integer(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(new Integer(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(new Integer(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("10.0.0.1/24");
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("ff:ff:ff:ff:ff:ff");
2373         MacAddress macsrc = new MacAddress("00:00:00:00:23:ae");
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         /*
2439          * ActionBuilder ab2 = new ActionBuilder(); SetFieldBuilder
2440          * setFieldBuilder2 = new SetFieldBuilder(); ActionBuilder ab3 = new
2441          * ActionBuilder(); SetFieldBuilder setFieldBuilder3 = new
2442          * SetFieldBuilder(); ActionBuilder ab4 = new ActionBuilder();
2443          * SetFieldBuilder setFieldBuilder4 = new SetFieldBuilder();
2444          */
2445         ActionBuilder ab5 = new ActionBuilder();
2446         SetFieldBuilder setFieldBuilder5 = new SetFieldBuilder();
2447         ActionBuilder ab6 = new ActionBuilder();
2448         SetFieldBuilder setFieldBuilder6 = new SetFieldBuilder();
2449
2450         // IPv6
2451         Ipv6MatchBuilder ipv6Builder = new Ipv6MatchBuilder();
2452         Ipv6MatchBuilder ipv6Builder1 = new Ipv6MatchBuilder();
2453         // Ipv6MatchBuilder ipv6Builder2 = new Ipv6MatchBuilder();
2454         // Ipv6MatchBuilder ipv6Builder3 = new Ipv6MatchBuilder();
2455         // Ipv6MatchBuilder ipv6Builder4 = new Ipv6MatchBuilder();
2456         Ipv6MatchBuilder ipv6Builder5 = new Ipv6MatchBuilder();
2457         Ipv6MatchBuilder ipv6Builder6 = new Ipv6MatchBuilder();
2458
2459         Ipv6Prefix dstip6 = new Ipv6Prefix("2002::2");
2460         Ipv6Prefix srcip6 = new Ipv6Prefix("2001:0:0:0:0:0:0:1");
2461         // Ipv6Address ndtarget = new
2462         // Ipv6Address("2001:db8:0:1:fd97:f9f0:a810:782e");
2463         // MacAddress ndsll = new MacAddress("c2:00:54:f5:00:00");
2464         // MacAddress ndtll = new MacAddress("00:0c:29:0e:4c:67");
2465         Ipv6ExtHeaderBuilder nextheader = new Ipv6ExtHeaderBuilder();
2466         nextheader.setIpv6Exthdr(58);
2467         Ipv6LabelBuilder ipv6label = new Ipv6LabelBuilder();
2468         Ipv6FlowLabel label = new Ipv6FlowLabel(10028L);
2469         ipv6label.setIpv6Flabel(label);
2470
2471         ipv6Builder.setIpv6Source(srcip6);
2472         ipv6Builder1.setIpv6Destination(dstip6);
2473         // ipv6Builder2.setIpv6NdTarget(ndtarget);
2474         // ipv6Builder3.setIpv6NdSll(ndsll);
2475         // ipv6Builder4.setIpv6NdTll(ndtll);
2476         ipv6Builder5.setIpv6ExtHeader(nextheader.build());
2477         ipv6Builder6.setIpv6Label(ipv6label.build());
2478
2479         setFieldBuilder.setLayer3Match(ipv6Builder.build());
2480         ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
2481         ab.setKey(new ActionKey(0));
2482         actionLists.add(ab.build());
2483
2484         setFieldBuilder1.setLayer3Match(ipv6Builder1.build());
2485         ab1.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder1.build()).build());
2486         ab1.setKey(new ActionKey(1));
2487         actionLists.add(ab1.build());
2488
2489         /*
2490          * setFieldBuilder2.setLayer3Match(ipv6Builder2.build());
2491          * ab2.setAction(new
2492          * SetFieldCaseBuilder().setSetField(setFieldBuilder2.build()).build());
2493          * ab2.setKey(new ActionKey(2)); actionLists.add(ab2.build());
2494          *
2495          * setFieldBuilder3.setLayer3Match(ipv6Builder3.build());
2496          * ab3.setAction(new
2497          * SetFieldCaseBuilder().setSetField(setFieldBuilder3.build()).build());
2498          * ab3.setKey(new ActionKey(3)); actionLists.add(ab3.build());
2499          *
2500          * setFieldBuilder4.setLayer3Match(ipv6Builder4.build());
2501          * ab4.setAction(new
2502          * SetFieldCaseBuilder().setSetField(setFieldBuilder4.build()).build());
2503          * ab4.setKey(new ActionKey(4)); actionLists.add(ab4.build());
2504          */
2505         setFieldBuilder5.setLayer3Match(ipv6Builder5.build());
2506         ab5.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder5.build()).build());
2507         ab5.setKey(new ActionKey(5));
2508         actionLists.add(ab5.build());
2509
2510         setFieldBuilder6.setLayer3Match(ipv6Builder6.build());
2511         ab6.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder6.build()).build());
2512         ab6.setKey(new ActionKey(6));
2513         actionLists.add(ab6.build());
2514
2515         ApplyActionsBuilder aab = new ApplyActionsBuilder();
2516         aab.setAction(actionLists);
2517
2518         InstructionBuilder ib = new InstructionBuilder();
2519         ib.setKey(new InstructionKey(0));
2520         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
2521
2522         // Put our Instruction in a list of Instructions
2523         InstructionsBuilder isb = new InstructionsBuilder();
2524         List<Instruction> instructions = new ArrayList<Instruction>();
2525         instructions.add(ib.build());
2526         isb.setInstruction(instructions);
2527         return isb;
2528     }
2529
2530     private static InstructionsBuilder createAppyActionInstruction45() {
2531
2532         List<Action> actionList = new ArrayList<Action>();
2533         ActionBuilder ab = new ActionBuilder();
2534         SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
2535         ActionBuilder ab1 = new ActionBuilder();
2536         SetFieldBuilder setFieldBuilder1 = new SetFieldBuilder();
2537
2538         // Icmpv6
2539         Icmpv6MatchBuilder icmpv6match = new Icmpv6MatchBuilder();
2540         Icmpv6MatchBuilder icmpv6match1 = new Icmpv6MatchBuilder();
2541         icmpv6match.setIcmpv6Type((short) 135);
2542         icmpv6match1.setIcmpv6Code((short) 0);
2543         setFieldBuilder.setIcmpv6Match(icmpv6match.build());
2544         ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
2545         ab.setKey(new ActionKey(0));
2546         actionList.add(ab.build());
2547
2548         setFieldBuilder1.setIcmpv6Match(icmpv6match1.build());
2549         ab1.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder1.build()).build());
2550         ab1.setKey(new ActionKey(1));
2551         actionList.add(ab1.build());
2552
2553         ApplyActionsBuilder aab = new ApplyActionsBuilder();
2554         aab.setAction(actionList);
2555
2556         InstructionBuilder ib = new InstructionBuilder();
2557         ib.setKey(new InstructionKey(0));
2558         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
2559
2560         // Put our Instruction in a list of Instructions
2561         InstructionsBuilder isb = new InstructionsBuilder();
2562         List<Instruction> instructions = new ArrayList<Instruction>();
2563         instructions.add(ib.build());
2564         isb.setInstruction(instructions);
2565         return isb;
2566     }
2567
2568     private static InstructionsBuilder createAppyActionInstruction46() {
2569
2570         List<Action> actionList = new ArrayList<Action>();
2571         ActionBuilder ab = new ActionBuilder();
2572         SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
2573         ActionBuilder ab1 = new ActionBuilder();
2574         SetFieldBuilder setFieldBuilder1 = new SetFieldBuilder();
2575         ActionBuilder ab2 = new ActionBuilder();
2576         SetFieldBuilder setFieldBuilder2 = new SetFieldBuilder();
2577
2578         // MPLS
2579         ProtocolMatchFieldsBuilder protomatch = new ProtocolMatchFieldsBuilder();
2580         ProtocolMatchFieldsBuilder protomatch1 = new ProtocolMatchFieldsBuilder();
2581         ProtocolMatchFieldsBuilder protomatch2 = new ProtocolMatchFieldsBuilder();
2582         protomatch.setMplsLabel((long) 36008);
2583         protomatch1.setMplsTc((short) 4);
2584         protomatch2.setMplsBos((short) 1);
2585         setFieldBuilder.setProtocolMatchFields(protomatch.build());
2586         ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
2587         ab.setKey(new ActionKey(0));
2588         actionList.add(ab.build());
2589
2590         setFieldBuilder1.setProtocolMatchFields(protomatch1.build());
2591         ab1.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder1.build()).build());
2592         ab1.setKey(new ActionKey(1));
2593         actionList.add(ab1.build());
2594
2595         setFieldBuilder2.setProtocolMatchFields(protomatch2.build());
2596         ab2.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder2.build()).build());
2597         ab2.setKey(new ActionKey(2));
2598         actionList.add(ab2.build());
2599
2600         ApplyActionsBuilder aab = new ApplyActionsBuilder();
2601         aab.setAction(actionList);
2602
2603         InstructionBuilder ib = new InstructionBuilder();
2604         ib.setKey(new InstructionKey(0));
2605         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
2606
2607         // Put our Instruction in a list of Instructions
2608         InstructionsBuilder isb = new InstructionsBuilder();
2609         List<Instruction> instructions = new ArrayList<Instruction>();
2610         instructions.add(ib.build());
2611         isb.setInstruction(instructions);
2612         return isb;
2613     }
2614
2615     private static InstructionsBuilder createAppyActionInstruction47() {
2616
2617         List<Action> actionList = new ArrayList<Action>();
2618         ActionBuilder ab = new ActionBuilder();
2619         SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
2620         // PBB
2621         ProtocolMatchFieldsBuilder protomatch = new ProtocolMatchFieldsBuilder();
2622         protomatch.setPbb(new PbbBuilder().setPbbIsid(4L).setPbbMask((new BigInteger(new byte[] { 0, 1, 0, 0 }).longValue())).build());
2623         setFieldBuilder.setProtocolMatchFields(protomatch.build());
2624         ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
2625         actionList.add(ab.build());
2626
2627         ApplyActionsBuilder aab = new ApplyActionsBuilder();
2628         aab.setAction(actionList);
2629
2630         InstructionBuilder ib = new InstructionBuilder();
2631         ib.setKey(new InstructionKey(0));
2632         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
2633
2634         // Put our Instruction in a list of Instructions
2635         InstructionsBuilder isb = new InstructionsBuilder();
2636         List<Instruction> instructions = new ArrayList<Instruction>();
2637         instructions.add(ib.build());
2638         isb.setInstruction(instructions);
2639         return isb;
2640     }
2641
2642     private static InstructionsBuilder createAppyActionInstruction48() {
2643
2644         List<Action> actionList = new ArrayList<Action>();
2645         ActionBuilder ab = new ActionBuilder();
2646         SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
2647         // Tunnel
2648         TunnelBuilder tunnel = new TunnelBuilder();
2649         tunnel.setTunnelId(BigInteger.valueOf(10668));
2650         setFieldBuilder.setTunnel(tunnel.build());
2651         ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
2652         ab.setKey(new ActionKey(0));
2653         actionList.add(ab.build());
2654
2655         ApplyActionsBuilder aab = new ApplyActionsBuilder();
2656         aab.setAction(actionList);
2657
2658         InstructionBuilder ib = new InstructionBuilder();
2659         ib.setKey(new InstructionKey(0));
2660         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
2661
2662         // Put our Instruction in a list of Instructions
2663         InstructionsBuilder isb = new InstructionsBuilder();
2664         List<Instruction> instructions = new ArrayList<Instruction>();
2665         instructions.add(ib.build());
2666         isb.setInstruction(instructions);
2667         return isb;
2668     }
2669
2670     private static MatchBuilder createLLDPMatch() {
2671         MatchBuilder match = new MatchBuilder();
2672         EthernetMatchBuilder eth = new EthernetMatchBuilder();
2673         EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
2674         ethTypeBuilder.setType(new EtherType(0x88ccL));
2675         eth.setEthernetType(ethTypeBuilder.build());
2676         match.setEthernetMatch(eth.build());
2677         return match;
2678     }
2679
2680     /**
2681      * @return
2682      */
2683     private static MatchBuilder createMatch1() {
2684         MatchBuilder match = new MatchBuilder();
2685         Ipv4MatchBuilder ipv4Match = new Ipv4MatchBuilder();
2686         Ipv4Prefix prefix = new Ipv4Prefix("10.0.0.1/24");
2687         ipv4Match.setIpv4Destination(prefix);
2688         Ipv4Match i4m = ipv4Match.build();
2689         match.setLayer3Match(i4m);
2690
2691         EthernetMatchBuilder eth = new EthernetMatchBuilder();
2692         EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
2693         ethTypeBuilder.setType(new EtherType(0x0800L));
2694         eth.setEthernetType(ethTypeBuilder.build());
2695         match.setEthernetMatch(eth.build());
2696         return match;
2697     }
2698
2699     /**
2700      * @return
2701      */
2702     private static MatchBuilder createIPv4DstMatch() {
2703         MatchBuilder match = new MatchBuilder();
2704         Ipv4MatchBuilder ipv4Match = new Ipv4MatchBuilder();
2705         Ipv4Prefix prefix = new Ipv4Prefix("10.0.0.1/24");
2706         ipv4Match.setIpv4Destination(prefix);
2707         Ipv4Match i4m = ipv4Match.build();
2708         match.setLayer3Match(i4m);
2709
2710         return match;
2711     }
2712
2713     /**
2714      * @return
2715      */
2716     private static MatchBuilder createIPv4SrcMatch() {
2717         MatchBuilder match = new MatchBuilder();
2718         Ipv4MatchBuilder ipv4Match = new Ipv4MatchBuilder();
2719         Ipv4Prefix prefix = new Ipv4Prefix("10.20.30.40/24");
2720         ipv4Match.setIpv4Source(prefix);
2721         Ipv4Match i4m = ipv4Match.build();
2722         match.setLayer3Match(i4m);
2723
2724         EthernetMatchBuilder eth = new EthernetMatchBuilder();
2725         EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
2726         ethTypeBuilder.setType(new EtherType(0x0800L));
2727         eth.setEthernetType(ethTypeBuilder.build());
2728         match.setEthernetMatch(eth.build());
2729         return match;
2730     }
2731
2732     /**
2733      * @return
2734      */
2735     private static MatchBuilder createMatch2() {
2736         MatchBuilder match = new MatchBuilder();
2737         Ipv4MatchBuilder ipv4Match = new Ipv4MatchBuilder();
2738         Ipv4Prefix prefix = new Ipv4Prefix("10.0.0.1");
2739         ipv4Match.setIpv4Source(prefix);
2740         Ipv4Match i4m = ipv4Match.build();
2741         match.setLayer3Match(i4m);
2742
2743         EthernetMatchBuilder eth = new EthernetMatchBuilder();
2744         EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
2745         ethTypeBuilder.setType(new EtherType(0x0800L));
2746         eth.setEthernetType(ethTypeBuilder.build());
2747         match.setEthernetMatch(eth.build());
2748         return match;
2749     }
2750
2751     /**
2752      * @return
2753      */
2754     private static MatchBuilder createMatch3() {
2755         MatchBuilder match = new MatchBuilder();
2756         EthernetMatchBuilder ethernetMatch = new EthernetMatchBuilder();
2757         EthernetSourceBuilder ethSourceBuilder = new EthernetSourceBuilder();
2758         ethSourceBuilder.setAddress(new MacAddress("00:00:00:00:00:01"));
2759         ethernetMatch.setEthernetSource(ethSourceBuilder.build());
2760         match.setEthernetMatch(ethernetMatch.build());
2761
2762         return match;
2763     }
2764
2765     /**
2766      * @return
2767      */
2768     private static MatchBuilder createICMPv6Match1() {
2769
2770         MatchBuilder match = new MatchBuilder();
2771         EthernetMatchBuilder eth = new EthernetMatchBuilder();
2772         EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
2773         ethTypeBuilder.setType(new EtherType(0x86ddL));
2774         eth.setEthernetType(ethTypeBuilder.build());
2775         match.setEthernetMatch(eth.build());
2776
2777         IpMatchBuilder ipmatch = new IpMatchBuilder(); // ipv4 version
2778         ipmatch.setIpProtocol((short) 256);
2779         match.setIpMatch(ipmatch.build());
2780
2781         Icmpv6MatchBuilder icmpv6match = new Icmpv6MatchBuilder(); // icmpv6
2782                                                                    // match
2783         icmpv6match.setIcmpv6Type((short) 135);
2784         icmpv6match.setIcmpv6Code((short) 1);
2785         match.setIcmpv6Match(icmpv6match.build());
2786
2787         return match;
2788     }
2789
2790     private static MatchBuilder createMatch33() {
2791
2792         MatchBuilder match = new MatchBuilder();
2793         Ipv4MatchBuilder ipv4Match = new Ipv4MatchBuilder();
2794         Ipv4Prefix prefix = new Ipv4Prefix("10.0.0.10");
2795         ipv4Match.setIpv4Source(prefix);
2796         Ipv4Match i4m = ipv4Match.build();
2797         match.setLayer3Match(i4m);
2798
2799         EthernetMatchBuilder eth = new EthernetMatchBuilder();
2800         EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
2801         ethTypeBuilder.setType(new EtherType(0xfffeL));
2802         eth.setEthernetType(ethTypeBuilder.build());
2803         match.setEthernetMatch(eth.build());
2804         return match;
2805     }
2806
2807     private static MatchBuilder createInphyportMatch(NodeId nodeId) {
2808         MatchBuilder match = new MatchBuilder();
2809         match.setInPort(new NodeConnectorId(nodeId + ":202"));
2810         match.setInPhyPort(new NodeConnectorId(nodeId + ":10122"));
2811         return match;
2812     }
2813
2814     private static MatchBuilder createEthernetMatch() {
2815         MatchBuilder match = new MatchBuilder();
2816
2817         byte[] mask1 = new byte[] { (byte) -1, (byte) -1, 0, 0, 0, 0 };
2818         byte[] mask2 = new byte[] { (byte) -1, (byte) -1, (byte) -1, 0, 0, 0 };
2819
2820         EthernetMatchBuilder ethmatch = new EthernetMatchBuilder(); // ethernettype
2821                                                                     // match
2822         EthernetTypeBuilder ethtype = new EthernetTypeBuilder();
2823         EtherType type = new EtherType(0x0800L);
2824         ethmatch.setEthernetType(ethtype.setType(type).build());
2825
2826         EthernetDestinationBuilder ethdest = new EthernetDestinationBuilder(); // ethernet
2827                                                                                // macaddress
2828                                                                                // match
2829         MacAddress macdest = new MacAddress("ff:ff:ff:ff:ff:ff");
2830         ethdest.setAddress(macdest);
2831         ethdest.setMask(new MacAddress("ff:ff:ff:00:00:00"));
2832
2833         ethmatch.setEthernetDestination(ethdest.build());
2834
2835         EthernetSourceBuilder ethsrc = new EthernetSourceBuilder();
2836         MacAddress macsrc = new MacAddress("00:00:00:00:23:ae");
2837         ethsrc.setAddress(macsrc);
2838         ethsrc.setMask(new MacAddress("ff:ff:00:00:00:00"));
2839
2840         ethmatch.setEthernetSource(ethsrc.build());
2841         match.setEthernetMatch(ethmatch.build());
2842         return match;
2843
2844     }
2845
2846     /**
2847      * @return
2848      */
2849
2850     private static MatchBuilder createVlanMatch() {
2851         MatchBuilder match = new MatchBuilder();
2852         VlanMatchBuilder vlanBuilder = new VlanMatchBuilder(); // vlan match
2853         VlanIdBuilder vlanIdBuilder = new VlanIdBuilder();
2854         VlanId vlanId = new VlanId(10);
2855         VlanPcp vpcp = new VlanPcp((short) 3);
2856         vlanBuilder.setVlanPcp(vpcp);
2857         vlanIdBuilder.setVlanId(vlanId);
2858         vlanIdBuilder.setVlanIdPresent(true);
2859         vlanBuilder.setVlanId(vlanIdBuilder.build());
2860         match.setVlanMatch(vlanBuilder.build());
2861         return match;
2862     }
2863
2864     /**
2865      * @return
2866      */
2867     private static MatchBuilder createArpMatch() {
2868         MatchBuilder match = new MatchBuilder();
2869
2870         EthernetMatchBuilder ethmatch = new EthernetMatchBuilder();
2871         MacAddress macdest = new MacAddress("ff:ff:ff:ff:ff:ff");
2872         MacAddress macsrc = new MacAddress("00:00:00:00:23:ae");
2873
2874         byte[] mask = new byte[] { (byte) -1, (byte) -1, 0, 0, 0, 0 };
2875         byte[] mask2 = new byte[] { (byte) -1, (byte) -1, (byte) -1, 0, 0, 0 };
2876
2877         EthernetTypeBuilder ethtype = new EthernetTypeBuilder();
2878         EtherType type = new EtherType(0x0806L);
2879         ethmatch.setEthernetType(ethtype.setType(type).build());
2880
2881         Ipv4Prefix dstip = new Ipv4Prefix("200.71.9.52/10"); // ipv4 match
2882         Ipv4Prefix srcip = new Ipv4Prefix("100.1.1.1/8");
2883
2884         ArpMatchBuilder arpmatch = new ArpMatchBuilder(); // arp match
2885         ArpSourceHardwareAddressBuilder arpsrc = new ArpSourceHardwareAddressBuilder();
2886         arpsrc.setAddress(macsrc);
2887         arpsrc.setMask(new MacAddress("ff:ff:ff:00:00:00"));
2888         ArpTargetHardwareAddressBuilder arpdst = new ArpTargetHardwareAddressBuilder();
2889         arpdst.setAddress(macdest);
2890         arpdst.setMask(new MacAddress("ff:ff:00:00:00:00"));
2891         arpmatch.setArpOp(2);
2892         arpmatch.setArpSourceHardwareAddress(arpsrc.build());
2893         arpmatch.setArpTargetHardwareAddress(arpdst.build());
2894         arpmatch.setArpSourceTransportAddress(srcip);
2895         arpmatch.setArpTargetTransportAddress(dstip);
2896
2897         match.setEthernetMatch(ethmatch.build());
2898         match.setLayer3Match(arpmatch.build());
2899
2900         return match;
2901     }
2902
2903     /**
2904      * @return
2905      */
2906     private static MatchBuilder createIPMatch() {
2907         MatchBuilder match = new MatchBuilder();
2908         EthernetMatchBuilder ethmatch = new EthernetMatchBuilder();
2909         EthernetTypeBuilder ethtype = new EthernetTypeBuilder();
2910         EtherType type = new EtherType(0x0800L);
2911         ethmatch.setEthernetType(ethtype.setType(type).build());
2912         match.setEthernetMatch(ethmatch.build());
2913
2914         IpMatchBuilder ipmatch = new IpMatchBuilder(); // ipv4 version
2915         ipmatch.setIpProtocol((short) 1);
2916         Dscp dscp = new Dscp((short) 3);
2917         ipmatch.setIpDscp(dscp);
2918         ipmatch.setIpEcn((short) 2);
2919         match.setIpMatch(ipmatch.build());
2920         return match;
2921     }
2922
2923     /**
2924      * @return
2925      */
2926     private static MatchBuilder createL3IPv4Match() {
2927         MatchBuilder match = new MatchBuilder();
2928
2929         EthernetMatchBuilder eth = new EthernetMatchBuilder();
2930         EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
2931         ethTypeBuilder.setType(new EtherType(0x0800L));
2932         eth.setEthernetType(ethTypeBuilder.build());
2933         match.setEthernetMatch(eth.build());
2934
2935         Ipv4MatchBuilder ipv4Match = new Ipv4MatchBuilder();
2936         Ipv4Prefix dstip = new Ipv4Prefix("200.71.9.52/10"); // ipv4 match
2937         Ipv4Prefix srcip = new Ipv4Prefix("100.1.1.1/8");
2938         Ipv4MatchBuilder ipv4match = new Ipv4MatchBuilder();
2939         ipv4match.setIpv4Destination(dstip);
2940         ipv4match.setIpv4Source(srcip);
2941         match.setLayer3Match(ipv4match.build());
2942
2943         return match;
2944
2945     }
2946
2947     /**
2948      * @return
2949      */
2950     private static MatchBuilder createL3IPv6Match() {
2951         MatchBuilder match = new MatchBuilder();
2952
2953         EthernetMatchBuilder eth = new EthernetMatchBuilder();
2954         EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
2955         ethTypeBuilder.setType(new EtherType(0x86ddL));
2956         eth.setEthernetType(ethTypeBuilder.build());
2957         match.setEthernetMatch(eth.build());
2958
2959         Ipv6Prefix dstip6 = new Ipv6Prefix("2002::2/64");
2960         Ipv6Prefix srcip6 = new Ipv6Prefix("2001:0:0:0:0:0:0:1/56");
2961         Ipv6Address ndtarget = new Ipv6Address("2001:db8:0:1:fd97:f9f0:a810:782e");
2962         MacAddress ndsll = new MacAddress("c2:00:54:f5:00:00");
2963         MacAddress ndtll = new MacAddress("00:0c:29:0e:4c:67");
2964         Ipv6ExtHeaderBuilder nextheader = new Ipv6ExtHeaderBuilder();
2965         nextheader.setIpv6Exthdr(58);
2966         Ipv6LabelBuilder ipv6label = new Ipv6LabelBuilder();
2967         Ipv6FlowLabel label = new Ipv6FlowLabel(10028L);
2968         ipv6label.setIpv6Flabel(label);
2969         ipv6label.setFlabelMask(new Ipv6FlowLabel(1L));
2970
2971         Icmpv6MatchBuilder icmpv6match = new Icmpv6MatchBuilder(); // icmpv6
2972                                                                    // match
2973         icmpv6match.setIcmpv6Type((short) 135);
2974         icmpv6match.setIcmpv6Code((short) 0);
2975         match.setIcmpv6Match(icmpv6match.build());
2976
2977         Ipv6MatchBuilder ipv6match = new Ipv6MatchBuilder();
2978         // ipv6match.setIpv6Source(srcip6);
2979         // ipv6match.setIpv6Destination(dstip6);
2980         // ipv6match.setIpv6ExtHeader(nextheader.build());
2981         ipv6match.setIpv6NdSll(ndsll);
2982         ipv6match.setIpv6NdTll(ndtll);
2983         // ipv6match.setIpv6NdTarget(ndtarget);
2984         ipv6match.setIpv6Label(ipv6label.build());
2985
2986         match.setLayer3Match(ipv6match.build());
2987
2988         return match;
2989     }
2990
2991     /**
2992      * @return
2993      */
2994
2995     private static MatchBuilder createICMPv4Match() {
2996         MatchBuilder match = new MatchBuilder();
2997         EthernetMatchBuilder eth = new EthernetMatchBuilder();
2998         EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
2999         ethTypeBuilder.setType(new EtherType(0x0800L));
3000         eth.setEthernetType(ethTypeBuilder.build());
3001         match.setEthernetMatch(eth.build());
3002
3003         IpMatchBuilder ipmatch = new IpMatchBuilder(); // ipv4 version
3004         ipmatch.setIpProtocol((short) 1);
3005         match.setIpMatch(ipmatch.build());
3006
3007         Icmpv4MatchBuilder icmpv4match = new Icmpv4MatchBuilder(); // icmpv4
3008                                                                    // match
3009         icmpv4match.setIcmpv4Type((short) 8);
3010         icmpv4match.setIcmpv4Code((short) 0);
3011         match.setIcmpv4Match(icmpv4match.build());
3012         return match;
3013     }
3014
3015     /**
3016      * @return
3017      */
3018     private static MatchBuilder createICMPv6Match() {
3019
3020         MatchBuilder match = new MatchBuilder();
3021         EthernetMatchBuilder eth = new EthernetMatchBuilder();
3022         EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
3023         ethTypeBuilder.setType(new EtherType(0x86ddL));
3024         eth.setEthernetType(ethTypeBuilder.build());
3025         match.setEthernetMatch(eth.build());
3026
3027         IpMatchBuilder ipmatch = new IpMatchBuilder(); // ipv4 version
3028         ipmatch.setIpProtocol((short) 58);
3029         match.setIpMatch(ipmatch.build());
3030
3031         Icmpv6MatchBuilder icmpv6match = new Icmpv6MatchBuilder(); // icmpv6
3032                                                                    // match
3033         icmpv6match.setIcmpv6Type((short) 135);
3034         icmpv6match.setIcmpv6Code((short) 1);
3035         match.setIcmpv6Match(icmpv6match.build());
3036
3037         return match;
3038     }
3039
3040     /**
3041      * @return
3042      */
3043     private static MatchBuilder createToSMatch() {
3044         MatchBuilder match = new MatchBuilder();
3045         EthernetMatchBuilder ethmatch = new EthernetMatchBuilder();
3046         EthernetTypeBuilder ethtype = new EthernetTypeBuilder();
3047         EtherType type = new EtherType(0x0800L);
3048         ethmatch.setEthernetType(ethtype.setType(type).build());
3049         match.setEthernetMatch(ethmatch.build());
3050
3051         IpMatchBuilder ipmatch = new IpMatchBuilder(); // ipv4 version
3052         ipmatch.setIpProtocol((short) 6);
3053         Dscp dscp = new Dscp((short) 8);
3054         ipmatch.setIpDscp(dscp);
3055         match.setIpMatch(ipmatch.build());
3056         return match;
3057     }
3058
3059     /**
3060      * @return
3061      */
3062
3063     private static MatchBuilder createL4TCPMatch() {
3064         MatchBuilder match = new MatchBuilder();
3065
3066         EthernetMatchBuilder eth = new EthernetMatchBuilder();
3067         EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
3068         ethTypeBuilder.setType(new EtherType(0x0800L));
3069         eth.setEthernetType(ethTypeBuilder.build());
3070         match.setEthernetMatch(eth.build());
3071
3072         IpMatchBuilder ipmatch = new IpMatchBuilder(); // ipv4 version
3073         ipmatch.setIpProtocol((short) 6);
3074         match.setIpMatch(ipmatch.build());
3075
3076         PortNumber srcport = new PortNumber(1213);
3077         PortNumber dstport = new PortNumber(646);
3078         TcpMatchBuilder tcpmatch = new TcpMatchBuilder(); // tcp match
3079         tcpmatch.setTcpSourcePort(srcport);
3080         tcpmatch.setTcpDestinationPort(dstport);
3081         match.setLayer4Match(tcpmatch.build());
3082
3083         return match;
3084     }
3085
3086     /**
3087      * @return
3088      */
3089     private static MatchBuilder createL4UDPMatch() {
3090         MatchBuilder match = new MatchBuilder();
3091
3092         EthernetMatchBuilder eth = new EthernetMatchBuilder();
3093         EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
3094         ethTypeBuilder.setType(new EtherType(0x0800L));
3095         eth.setEthernetType(ethTypeBuilder.build());
3096         match.setEthernetMatch(eth.build());
3097
3098         IpMatchBuilder ipmatch = new IpMatchBuilder(); // ipv4 version
3099         ipmatch.setIpProtocol((short) 17);
3100         match.setIpMatch(ipmatch.build());
3101
3102         PortNumber srcport = new PortNumber(1325);
3103         PortNumber dstport = new PortNumber(42);
3104         UdpMatchBuilder udpmatch = new UdpMatchBuilder(); // udp match
3105         udpmatch.setUdpDestinationPort(dstport);
3106         udpmatch.setUdpSourcePort(srcport);
3107         match.setLayer4Match(udpmatch.build());
3108
3109         return match;
3110     }
3111
3112     /**
3113      * @return
3114      */
3115     private static MatchBuilder createL4SCTPMatch() {
3116         MatchBuilder match = new MatchBuilder();
3117
3118         EthernetMatchBuilder eth = new EthernetMatchBuilder();
3119         EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
3120         ethTypeBuilder.setType(new EtherType(0x0800L));
3121         eth.setEthernetType(ethTypeBuilder.build());
3122         match.setEthernetMatch(eth.build());
3123
3124         IpMatchBuilder ipmatch = new IpMatchBuilder(); // ipv4 version
3125         ipmatch.setIpProtocol((short) 132);
3126         match.setIpMatch(ipmatch.build());
3127
3128         SctpMatchBuilder sctpmatch = new SctpMatchBuilder();
3129         PortNumber srcport = new PortNumber(1435);
3130         PortNumber dstport = new PortNumber(22);
3131         sctpmatch.setSctpSourcePort(srcport);
3132         sctpmatch.setSctpDestinationPort(dstport);
3133         match.setLayer4Match(sctpmatch.build());
3134
3135         return match;
3136     }
3137
3138     /**
3139      * @return
3140      */
3141     private static MatchBuilder createMetadataMatch() {
3142         MatchBuilder match = new MatchBuilder();
3143         byte[] metamask = new byte[] { (byte) -1, (byte) -1, (byte) -1, 0, 0, 0, (byte) 1, (byte) 1 };
3144         MetadataBuilder metadata = new MetadataBuilder(); // metadata match
3145         metadata.setMetadata(BigInteger.valueOf(500L));
3146         metadata.setMetadataMask(new BigInteger(metamask));
3147         match.setMetadata(metadata.build());
3148
3149         return match;
3150     }
3151
3152     /**
3153      * @return
3154      */
3155     private static MatchBuilder createMplsMatch() {
3156         MatchBuilder match = new MatchBuilder();
3157
3158         EthernetMatchBuilder eth = new EthernetMatchBuilder();
3159         EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
3160         ethTypeBuilder.setType(new EtherType(0x8847L));
3161         eth.setEthernetType(ethTypeBuilder.build());
3162         match.setEthernetMatch(eth.build());
3163
3164         ProtocolMatchFieldsBuilder protomatch = new ProtocolMatchFieldsBuilder(); // mpls
3165         // match
3166         protomatch.setMplsLabel((long) 36008);
3167         protomatch.setMplsTc((short) 4);
3168         protomatch.setMplsBos((short) 1);
3169         match.setProtocolMatchFields(protomatch.build());
3170
3171         return match;
3172
3173     }
3174
3175     /**
3176      * @return
3177      */
3178     private static MatchBuilder createPbbMatch() {
3179         MatchBuilder match = new MatchBuilder();
3180
3181         EthernetMatchBuilder eth = new EthernetMatchBuilder();
3182         EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
3183         ethTypeBuilder.setType(new EtherType(0x88E7L));
3184         eth.setEthernetType(ethTypeBuilder.build());
3185         match.setEthernetMatch(eth.build());
3186
3187         ProtocolMatchFieldsBuilder protomatch = new ProtocolMatchFieldsBuilder(); // mpls
3188         // match
3189         protomatch.setPbb(new PbbBuilder().setPbbIsid(4L).setPbbMask(new BigInteger(new byte[] { 0, 1, 0, 0 }).longValue()).build());
3190         match.setProtocolMatchFields(protomatch.build());
3191
3192         return match;
3193
3194     }
3195
3196     /**
3197      * @return
3198      */
3199     private static MatchBuilder createTunnelIDMatch() {
3200         MatchBuilder match = new MatchBuilder();
3201         TunnelBuilder tunnel = new TunnelBuilder(); // tunnel id match
3202         tunnel.setTunnelId(BigInteger.valueOf(10668));
3203         byte[] mask = new byte[] {(byte) -1, (byte) -1, (byte) -1, 0, 0, 0, (byte) 1, (byte) 1 };
3204         tunnel.setTunnelMask(new BigInteger(1, mask));
3205         match.setTunnel(tunnel.build());
3206
3207         return match;
3208     }
3209
3210     /**
3211      * Test match for TCP_Flags
3212      * @return match containing Ethertype (0x0800), IP Protocol (TCP), TCP_Flag (SYN)
3213      */
3214     //FIXME: move to extensible support
3215     private static MatchBuilder createTcpFlagMatch() {
3216         MatchBuilder match = new MatchBuilder();
3217
3218         // Ethertype match
3219         EthernetMatchBuilder ethernetType = new EthernetMatchBuilder();
3220         EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
3221         ethTypeBuilder.setType(new EtherType(0x0800L));
3222         ethernetType.setEthernetType(ethTypeBuilder.build());
3223         match.setEthernetMatch(ethernetType.build());
3224
3225         // TCP Protocol Match
3226         IpMatchBuilder ipMatch = new IpMatchBuilder(); // ipv4 version
3227         ipMatch.setIpProtocol((short) 6);
3228         match.setIpMatch(ipMatch.build());
3229
3230         // TCP Port Match
3231         PortNumber dstPort = new PortNumber(80);
3232         TcpMatchBuilder tcpMatch = new TcpMatchBuilder();
3233         tcpMatch.setTcpDestinationPort(dstPort);
3234         match.setLayer4Match(tcpMatch.build());
3235         /**
3236         * Defined TCP Flag values in OVS v2.1+
3237         * TCP_FIN 0x001 / TCP_SYN 0x002 / TCP_RST 0x004
3238         * TCP_PSH 0x008 / TCP_ACK 0x010 / TCP_URG 0x020
3239         * TCP_ECE 0x040 / TCP_CWR 0x080 / TCP_NS  0x100
3240         */
3241         TcpFlagMatchBuilder tcpFlagMatch = new TcpFlagMatchBuilder();
3242         tcpFlagMatch.setTcpFlag(0x002);
3243         match.setTcpFlagMatch(tcpFlagMatch.build());
3244
3245         return match;
3246     }
3247
3248     public void _removeMDFlow(CommandInterpreter ci) {
3249         DataModification<InstanceIdentifier<?>, DataObject> modification = dataBrokerService.beginTransaction();
3250         NodeBuilder tn = createTestNode(ci.nextArgument());
3251         String flowtype = ci.nextArgument();
3252         FlowBuilder tf;
3253         if (flowtype.equals("fTM")) {
3254             tf = createtablemiss(tn, flowtype, ci.nextArgument());
3255         } else {
3256             tf = createTestFlow(tn, flowtype, ci.nextArgument());
3257         }
3258         InstanceIdentifier<Flow> path1 = InstanceIdentifier.builder(Nodes.class).child(Node.class, tn.getKey())
3259                 .augmentation(FlowCapableNode.class).child(Table.class, new TableKey(tf.getTableId()))
3260                 .child(Flow.class, tf.getKey()).build();
3261         modification.removeConfigurationData(path1);
3262         Future<RpcResult<TransactionStatus>> commitFuture = modification.commit();
3263         try {
3264             RpcResult<TransactionStatus> result = commitFuture.get();
3265             TransactionStatus status = result.getResult();
3266             ci.println("Status of Flow Data Loaded Transaction: " + status);
3267
3268         } catch (InterruptedException e) {
3269             LOG.error(e.getMessage(), e);
3270         } catch (ExecutionException e) {
3271             LOG.error(e.getMessage(), e);
3272         }
3273     }
3274
3275     /**
3276      * @param ci arguments: switchId flowType tableNum
3277      * 
3278      * <pre>
3279      * e.g.: addMDFlow openflow:1 f1 42
3280      * </pre>
3281      */
3282     public void _addMDFlow(CommandInterpreter ci) {
3283         NodeBuilder tn = createTestNode(ci.nextArgument());
3284         String flowtype = ci.nextArgument();
3285         FlowBuilder tf;
3286         if (flowtype.equals("fTM")) {
3287             tf = createtablemiss(tn, flowtype, ci.nextArgument());
3288         } else {
3289             tf = createTestFlow(tn, flowtype, ci.nextArgument());
3290         }
3291         writeFlow(ci, tf, tn);
3292     }
3293
3294     private void writeFlow(CommandInterpreter ci, FlowBuilder flow, NodeBuilder nodeBuilder) {
3295         DataModification<InstanceIdentifier<?>, DataObject> modification = dataBrokerService.beginTransaction();
3296         InstanceIdentifier<Flow> path1 = InstanceIdentifier.builder(Nodes.class)
3297                 .child(Node.class, nodeBuilder.getKey()).augmentation(FlowCapableNode.class)
3298                 .child(Table.class, new TableKey(flow.getTableId())).child(Flow.class, flow.getKey()).build();
3299         modification.putConfigurationData(nodeBuilderToInstanceId(nodeBuilder), nodeBuilder.build());
3300         modification.putConfigurationData(path1, flow.build());
3301         Future<RpcResult<TransactionStatus>> commitFuture = modification.commit();
3302         try {
3303             RpcResult<TransactionStatus> result = commitFuture.get();
3304             TransactionStatus status = result.getResult();
3305             ci.println("Status of Flow Data Loaded Transaction: " + status);
3306
3307         } catch (InterruptedException e) {
3308             LOG.error(e.getMessage(), e);
3309         } catch (ExecutionException e) {
3310             LOG.error(e.getMessage(), e);
3311         }
3312     }
3313
3314     public void _modifyMDFlow(CommandInterpreter ci) {
3315         NodeBuilder tn = createTestNode(ci.nextArgument());
3316         FlowBuilder tf = createTestFlow(tn, ci.nextArgument(), ci.nextArgument());
3317         tf.setFlowName(updatedFlowName);
3318         writeFlow(ci, tf, tn);
3319         tf.setFlowName(originalFlowName);
3320         writeFlow(ci, tf, tn);
3321     }
3322
3323     private static NodeRef createNodeRef(String string) {
3324         NodeKey key = new NodeKey(new NodeId(string));
3325         InstanceIdentifier<Node> path = InstanceIdentifier.builder(Nodes.class).child(Node.class, key)
3326                 .toInstance();
3327
3328         return new NodeRef(path);
3329     }
3330
3331     @Override
3332     public String getHelp() {
3333         return "No help";
3334     }
3335     
3336     /*
3337      * usage testSwitchFlows <numberOfSwitches> <numberOfFlows> <warmup iterations> <Number Of Threads>
3338      * ex: _perfFlowTest 10 5 1 2
3339      */
3340     public void _perfFlowTest(CommandInterpreter ci) {
3341         
3342         String numberOfSwtichesStr = ci.nextArgument();
3343         String numberOfFlowsStr = ci.nextArgument();
3344         String warmupIterationsStr = ci.nextArgument();
3345         String threadCountStr = ci.nextArgument();
3346         String warmUpStr = ci.nextArgument();
3347         
3348         Collection<String> testResults = null;
3349         if(testResults == null){
3350                 testResults = new ArrayList<String>();
3351         }
3352          
3353         int numberOfSwtiches = 0;
3354         int numberOfFlows = 0;
3355         int warmupIterations = 0;
3356         boolean warmUpIterations = false;
3357
3358         int threadCount = 0;
3359         if(numberOfSwtichesStr !=null && !numberOfSwtichesStr.trim().equals("")){
3360                 numberOfSwtiches = new Integer(numberOfSwtichesStr).intValue();
3361         }else {
3362                 numberOfSwtiches = 2;
3363         }
3364         
3365         if(numberOfFlowsStr !=null && !numberOfFlowsStr.trim().equals("")){
3366                 numberOfFlows = new Integer(numberOfFlowsStr).intValue();
3367         }else {
3368                 numberOfFlows = 2;
3369         }
3370         
3371         if(warmupIterationsStr !=null && !warmupIterationsStr.trim().equals("")){
3372                 warmupIterations = new Integer(warmupIterationsStr).intValue();
3373         }else {
3374                 warmupIterations = 2;
3375         }
3376         
3377         if(threadCountStr !=null && !threadCountStr.trim().equals("")){
3378                 threadCount = new Integer(threadCountStr).intValue();
3379         }else {
3380                 threadCount = 2; 
3381         }
3382          if(warmUpStr !=null && !warmUpStr.trim().equals("") && warmUpStr.trim().equals("true")){
3383              warmUpIterations = true;
3384          }else {
3385              warmUpIterations = false;
3386          }    
3387         ci.println("*     Test Configurations*");
3388         ci.println("*     numberOfSwtiches:::"+numberOfSwtiches+"");
3389         ci.println("*     numberOfFlows:::"+numberOfFlows+"");
3390         ci.println("*     warmupIterations:::"+warmupIterations+"");
3391         ci.println("*     Number of Threads :::"+threadCount+"");
3392         ci.println("*     Warmup Required? :::"+warmUpIterations+"");
3393         
3394         String dataPath="openflow:1";
3395         String flowType = "fTM";
3396         NodeBuilder tn;
3397         FlowBuilder tf;
3398         String tableId = "0";
3399         if(warmUpIterations){
3400         ci.println("----Warmup Started-----");
3401         for(int j =1; j<= warmupIterations; j++){
3402                 for(int i =1;i<=numberOfSwtiches;i++){
3403                          dataPath = "openflow:"+i;
3404                          tn = createTestNode(dataPath);
3405                         for (int flow=1;flow<numberOfFlows;flow++){
3406                                  tf = createTestFlow_perfTest(tn, "f1", tableId, flow);
3407                                  writeFlow(ci, tf, tn);
3408                         }
3409                 }
3410          }
3411
3412        ci.println("----Warmup Done-----");
3413         }
3414        try{
3415                ExecutorService executor = Executors.newFixedThreadPool(threadCount);
3416                int flowID = 0;
3417                int tableID = 0;
3418                for ( int t=0;t< threadCount;t++){
3419                    tableID = t+1;
3420                    Runnable tRunnable = new TestFlowThread(numberOfSwtiches, numberOfFlows, ci, t, tableID);
3421                    executor.execute(tRunnable);
3422                }
3423                executor.shutdown();
3424                executor.awaitTermination(1, TimeUnit.SECONDS);
3425        } catch(Exception e){
3426           ci.println("Exception:"+e.getMessage());
3427        }
3428     }
3429     
3430     public class TestFlowThread implements Runnable {
3431
3432         int numberOfSwitches;
3433         int numberOfFlows;
3434         int testTime;
3435         CommandInterpreter ci;
3436         int testFlowsAdded;
3437         int theadNumber;
3438         Collection<String> testResults = null;
3439         int tableID = 0;
3440
3441         TestFlowThread(int numberOfSwtiches, int numberOfFlows, CommandInterpreter ci, int t, int tableID) {
3442             this.numberOfSwitches = numberOfSwtiches;
3443             this.numberOfFlows = numberOfFlows;
3444             this.ci = ci;
3445             this.theadNumber = t;
3446             this.tableID = tableID;
3447         }
3448
3449         @Override
3450         public void run() {
3451             executeFlow();
3452         }
3453
3454         public void executeFlow() {
3455
3456             String dataPath = "openflow:1";
3457             NodeBuilder tn;
3458             FlowBuilder tf;
3459             //String tableId = "0";
3460
3461             ci.println("New Thread started with id:  ID_"
3462                     + this.theadNumber);
3463             int totalNumberOfFlows = 0;
3464             long startTime = System.currentTimeMillis();
3465
3466             for (int i = 1; i <= this.numberOfSwitches; i++) {
3467                 dataPath = "openflow:" + i;
3468                 tn = createTestNode(dataPath);
3469                 for (int flow2 = 1; flow2 <= this.numberOfFlows; flow2++) {
3470                     tf = createTestFlow_perfTest(tn, "f1", ""+this.tableID, flow2);
3471                     writeFlow(this.ci, tf, tn);
3472                     totalNumberOfFlows++;
3473                 }
3474             }
3475             long endTime = System.currentTimeMillis();
3476             long timeInSeconds = Math.round((endTime - startTime) / 1000);
3477             if (timeInSeconds > 0) {
3478                 ci.println("Total flows added in Thread:" + this.theadNumber + ": Flows/Sec::" + Math.round(totalNumberOfFlows / timeInSeconds));
3479             } else {
3480                 ci.println("Total flows added in Thread:" + this.theadNumber + ": Flows/Sec::" + totalNumberOfFlows);
3481             }
3482         }
3483
3484     }
3485     /*
3486      * usage testAllFlows <dp>
3487      * ex: _perfFlowTest 1
3488      */
3489     public void _testAllFlows(CommandInterpreter ci) {
3490         String dataPathID = ci.nextArgument();
3491         int numberOfFlows = 82;
3492         int threadCount = 0;
3493         if(dataPathID ==null || dataPathID.trim().equals("")){
3494                 dataPathID = "1";
3495         }
3496         ci.println("*     Test All Flows        *");
3497         ci.println("*     dataPathID:::"+dataPathID+"");
3498         String dataPath="openflow:"+dataPathID;
3499         String tableId = "0";
3500         NodeBuilder tn = createTestNode(dataPath);
3501         FlowBuilder tf;
3502                 for (int flow=1;flow<numberOfFlows;flow++){
3503                         String flowID = "f"+flow;
3504                         try{
3505                                 tf = createTestFlow(tn, flowID, tableId);
3506                                 writeFlow(ci, tf, tn);
3507                         } catch(Exception e){
3508                                 ci.println("--Test Failed--Issue found while adding flow"+ flow);
3509                                 break;
3510                         }
3511                 }
3512     }
3513 }