Merge "Bug 1072 -Add OF13 pre-req for PCP match in TestCommandProvider"
[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(createVlanMatch().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         case "f84":
670             id += 84;
671             flow.setMatch(createVlanMatch().build()); // match vlan=10,dl_vlan_pcp=3
672             flow.setInstructions(createAppyActionInstruction88().build()); // vlan_pcp=4
673             break;
674         default:
675             LOG.warn("flow type not understood: {}", flowType);
676         }
677
678         FlowKey key = new FlowKey(new FlowId(Long.toString(id)));
679         if (null == flow.isBarrier()) {
680             flow.setBarrier(Boolean.FALSE);
681         }
682         // flow.setBufferId(new Long(12));
683         BigInteger value = new BigInteger("10", 10);
684         // BigInteger outputPort = new BigInteger("65535", 10);
685         flow.setCookie(new FlowCookie(value));
686         flow.setCookieMask(new FlowCookie(value));
687         flow.setHardTimeout(0);
688         flow.setIdleTimeout(0);
689         flow.setInstallHw(false);
690         flow.setStrict(false);
691         flow.setContainerName(null);
692         flow.setFlags(new FlowModFlags(false, false, false, false, true));
693         flow.setId(new FlowId("12"));
694         flow.setTableId(getTableId(tableId));
695         // commenting setOutGroup and setOutPort, as by default
696         // OFPG_ANY is send
697         // enable setOutGroup and setOutPort to enable output filtering
698         // flow.setOutGroup(new Long(2));
699         // set outport to OFPP_NONE (65535) to disable remove restriction for
700         // flow
701         // flow.setOutPort(outputPort);
702
703         flow.setKey(key);
704         flow.setFlowName(originalFlowName + "X" + flowType);
705         testFlow = flow;
706         return flow;
707     }
708
709     
710     private FlowBuilder createTestFlow_perfTest(NodeBuilder nodeBuilder, String flowTypeArg, String tableId, int id) {
711
712         FlowBuilder flow = new FlowBuilder();
713         //long id = 123;
714
715         String flowType = flowTypeArg;
716         if (flowType == null) {
717             flowType = "f1";
718         }
719         
720         flow.setPriority(id);
721
722         switch (flowType) {
723         case "f1":
724             id += 1;
725             flow.setMatch(createMatch1().build());
726             flow.setInstructions(createDecNwTtlInstructions().build());
727             break;
728         default:
729             LOG.warn("flow type not understood: {}", flowType);
730         }
731
732         FlowKey key = new FlowKey(new FlowId(Long.toString(id)));
733         if (null == flow.isBarrier()) {
734             flow.setBarrier(Boolean.FALSE);
735         }
736         // flow.setBufferId(new Long(12));
737         BigInteger value = new BigInteger("10", 10);
738         // BigInteger outputPort = new BigInteger("65535", 10);
739         flow.setCookie(new FlowCookie(value));
740         flow.setCookieMask(new FlowCookie(value));
741         flow.setHardTimeout(0);
742         flow.setIdleTimeout(0);
743         flow.setInstallHw(false);
744         flow.setStrict(false);
745         flow.setContainerName(null);
746         flow.setFlags(new FlowModFlags(false, false, false, false, true));
747         flow.setId(new FlowId("12"));
748         flow.setTableId(getTableId(tableId));
749         // commenting setOutGroup and setOutPort, as by default
750         // OFPG_ANY is send
751         // enable setOutGroup and setOutPort to enable output filtering
752         // flow.setOutGroup(new Long(2));
753         // set outport to OFPP_NONE (65535) to disable remove restriction for
754         // flow
755         // flow.setOutPort(outputPort);
756
757         flow.setKey(key);
758         flow.setFlowName(originalFlowName + "X" + flowType);
759         testFlow = flow;
760         return flow;
761     }
762     private FlowBuilder createtablemiss(NodeBuilder nodeBuilder, String flowTypeArg, String tableId) {
763         FlowBuilder flow = new FlowBuilder();
764         long id = 456;
765         MatchBuilder matchBuilder = new MatchBuilder();
766         flow.setMatch(matchBuilder.build());
767         flow.setInstructions(createSentToControllerInstructions().build());
768         flow.setPriority(0);
769         flow.setTableId((short) 0);
770         FlowKey key = new FlowKey(new FlowId(Long.toString(id)));
771         flow.setKey(key);
772         testFlow = flow;
773         return flow;
774     }
775
776     private short getTableId(String tableId) {
777         short table = 2;
778         try {
779             table = Short.parseShort(tableId);
780         } catch (Exception ex) {
781             // ignore exception and continue with default value
782         }
783
784         return table;
785
786     }
787
788     /**
789      * @return
790      */
791     private static InstructionsBuilder createDecNwTtlInstructions() {
792         DecNwTtlBuilder ta = new DecNwTtlBuilder();
793         DecNwTtl decNwTtl = ta.build();
794         ActionBuilder ab = new ActionBuilder();
795         ab.setAction(new DecNwTtlCaseBuilder().setDecNwTtl(decNwTtl).build());
796         ab.setKey(new ActionKey(0));
797         // Add our drop action to a list
798         List<Action> actionList = new ArrayList<Action>();
799         actionList.add(ab.build());
800
801         // Create an Apply Action
802         ApplyActionsBuilder aab = new ApplyActionsBuilder();
803         aab.setAction(actionList);
804        
805         // Wrap our Apply Action in an Instruction
806         InstructionBuilder ib = new InstructionBuilder();
807         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
808         ib.setKey(new InstructionKey(0));
809         ib.setOrder(0);
810
811         // Put our Instruction in a list of Instructions
812         InstructionsBuilder isb = new InstructionsBuilder();
813         List<Instruction> instructions = new ArrayList<Instruction>();
814         instructions.add(ib.build());
815         ib.setKey(new InstructionKey(0));
816         isb.setInstruction(instructions);
817         return isb;
818     }
819
820     /**
821      * @return
822      */
823     private static InstructionsBuilder createMeterInstructions() {
824
825         MeterBuilder aab = new MeterBuilder();
826         aab.setMeterId(new MeterId(new Long(1)));
827
828         InstructionBuilder ib = new InstructionBuilder();
829         ib.setInstruction(new MeterCaseBuilder().setMeter(aab.build()).build());
830
831         // Put our Instruction in a list of Instructions
832         InstructionsBuilder isb = new InstructionsBuilder();
833         List<Instruction> instructions = new ArrayList<Instruction>();
834         ib.setKey(new InstructionKey(0));
835         instructions.add(ib.build());
836         isb.setInstruction(instructions);
837         return isb;
838     }
839
840     private static InstructionsBuilder createMetadataInstructions() {
841
842         WriteMetadataBuilder aab = new WriteMetadataBuilder();
843         aab.setMetadata(new BigInteger("10", 10));
844         aab.setMetadataMask(new BigInteger("12", 10));
845
846         InstructionBuilder ib = new InstructionBuilder();
847         ib.setInstruction(new WriteMetadataCaseBuilder().setWriteMetadata(aab.build()).build());
848
849         // Put our Instruction in a list of Instructions
850         InstructionsBuilder isb = new InstructionsBuilder();
851         List<Instruction> instructions = new ArrayList<Instruction>();
852         ib.setKey(new InstructionKey(0));
853         instructions.add(ib.build());
854         isb.setInstruction(instructions);
855         return isb;
856     }
857
858     private static InstructionsBuilder createGotoTableInstructions() {
859
860         GoToTableBuilder aab = new GoToTableBuilder();
861         aab.setTableId((short) 5);
862
863         InstructionBuilder ib = new InstructionBuilder();
864         ib.setInstruction(new GoToTableCaseBuilder().setGoToTable(aab.build()).build());
865
866         // Put our Instruction in a list of Instructions
867         InstructionsBuilder isb = new InstructionsBuilder();
868         List<Instruction> instructions = new ArrayList<Instruction>();
869         ib.setKey(new InstructionKey(0));
870         instructions.add(ib.build());
871         isb.setInstruction(instructions);
872         return isb;
873     }
874
875     private static InstructionsBuilder createDropInstructions() {
876         DropActionBuilder dab = new DropActionBuilder();
877         DropAction dropAction = dab.build();
878         ActionBuilder ab = new ActionBuilder();
879         ab.setAction(new DropActionCaseBuilder().setDropAction(dropAction).build());
880         ab.setKey(new ActionKey(0));
881         // Add our drop action to a list
882         List<Action> actionList = new ArrayList<Action>();
883         actionList.add(ab.build());
884         ab.setKey(new ActionKey(0));
885         // Create an Apply Action
886         ApplyActionsBuilder aab = new ApplyActionsBuilder();
887         aab.setAction(actionList);
888
889         // Wrap our Apply Action in an Instruction
890         InstructionBuilder ib = new InstructionBuilder();
891         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
892
893         // Put our Instruction in a list of Instructions
894         InstructionsBuilder isb = new InstructionsBuilder();
895         List<Instruction> instructions = new ArrayList<Instruction>();
896         ib.setKey(new InstructionKey(0));
897         instructions.add(ib.build());
898         isb.setInstruction(instructions);
899         return isb;
900     }
901
902     private static InstructionsBuilder createAppyActionInstruction() {
903
904         List<Action> actionList = new ArrayList<Action>();
905         ActionBuilder ab = new ActionBuilder();
906         ControllerActionBuilder controller = new ControllerActionBuilder();
907         controller.setMaxLength(5);
908         ab.setAction(new ControllerActionCaseBuilder().setControllerAction(controller.build()).build());
909         ab.setKey(new ActionKey(0));
910         actionList.add(ab.build());
911         // Create an Apply Action
912         ApplyActionsBuilder aab = new ApplyActionsBuilder();
913         aab.setAction(actionList);
914
915         // Wrap our Apply Action in an Instruction
916         InstructionBuilder ib = new InstructionBuilder();
917         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
918
919         // Put our Instruction in a list of Instructions
920         InstructionsBuilder isb = new InstructionsBuilder();
921         List<Instruction> instructions = new ArrayList<Instruction>();
922         ib.setKey(new InstructionKey(0));
923         instructions.add(ib.build());
924         isb.setInstruction(instructions);
925         return isb;
926     }
927
928     private static InstructionsBuilder createAppyActionInstruction1() {
929
930         List<Action> actionList = new ArrayList<Action>();
931         ActionBuilder ab = new ActionBuilder();
932
933         OutputActionBuilder output = new OutputActionBuilder();
934         output.setMaxLength(56);
935         Uri value = new Uri("PCEP");
936         output.setOutputNodeConnector(value);
937         ab.setAction(new OutputActionCaseBuilder().setOutputAction(output.build()).build());
938         ab.setKey(new ActionKey(0));
939         actionList.add(ab.build());
940         // Create an Apply Action
941         ApplyActionsBuilder aab = new ApplyActionsBuilder();
942         aab.setAction(actionList);
943
944         // Wrap our Apply Action in an Instruction
945         InstructionBuilder ib = new InstructionBuilder();
946         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
947
948         // Put our Instruction in a list of Instructions
949         InstructionsBuilder isb = new InstructionsBuilder();
950         List<Instruction> instructions = new ArrayList<Instruction>();
951         ib.setKey(new InstructionKey(0));
952         instructions.add(ib.build());
953         isb.setInstruction(instructions);
954         return isb;
955     }
956
957     private static InstructionsBuilder createOutputInstructions() {
958
959         // test case for Output Port works if the particular port exists
960         // this particular test-case is for Port : 1
961         // tested as (addMDFlow openflow:<dpid> f82)
962         List<Action> actionList = new ArrayList<Action>();
963         ActionBuilder ab = new ActionBuilder();
964         OutputActionBuilder output = new OutputActionBuilder();
965
966         Uri value = new Uri("1");
967         output.setOutputNodeConnector(value);
968         ab.setAction(new OutputActionCaseBuilder().setOutputAction(output.build()).build());
969         ab.setOrder(0);
970         ab.setKey(new ActionKey(0));
971         actionList.add(ab.build());
972         // Create an Apply Action
973         ApplyActionsBuilder aab = new ApplyActionsBuilder();
974         aab.setAction(actionList);
975
976         // Wrap our Apply Action in an Instruction
977         InstructionBuilder ib = new InstructionBuilder();
978         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
979         ib.setOrder(0);
980         ib.setKey(new InstructionKey(0));
981
982         // Put our Instruction in a list of Instructions
983         InstructionsBuilder isb = new InstructionsBuilder();
984         List<Instruction> instructions = new ArrayList<Instruction>();
985         instructions.add(ib.build());
986         isb.setInstruction(instructions);
987         return isb;
988     }
989
990     private static InstructionsBuilder createSentToControllerInstructions() {
991         List<Action> actionList = new ArrayList<Action>();
992         ActionBuilder ab = new ActionBuilder();
993
994         OutputActionBuilder output = new OutputActionBuilder();
995         output.setMaxLength(new Integer(0xffff));
996         Uri value = new Uri(OutputPortValues.CONTROLLER.toString());
997         output.setOutputNodeConnector(value);
998         ab.setAction(new OutputActionCaseBuilder().setOutputAction(output.build()).build());
999         ab.setOrder(0);
1000         ab.setKey(new ActionKey(0));
1001         actionList.add(ab.build());
1002         // Create an Apply Action
1003         ApplyActionsBuilder aab = new ApplyActionsBuilder();
1004         aab.setAction(actionList);
1005
1006         // Wrap our Apply Action in an Instruction
1007         InstructionBuilder ib = new InstructionBuilder();
1008         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1009         ib.setOrder(0);
1010         ib.setKey(new InstructionKey(0));
1011
1012         // Put our Instruction in a list of Instructions
1013         InstructionsBuilder isb = new InstructionsBuilder();
1014         List<Instruction> instructions = new ArrayList<Instruction>();
1015         instructions.add(ib.build());
1016         isb.setInstruction(instructions);
1017         return isb;
1018     }
1019
1020     private static InstructionsBuilder createOutputInstructions(String outputType, int outputValue) {
1021         List<Action> actionList = new ArrayList<Action>();
1022         ActionBuilder ab = new ActionBuilder();
1023
1024         OutputActionBuilder output = new OutputActionBuilder();
1025         output.setMaxLength(outputValue);
1026         Uri value = new Uri(outputType);
1027         output.setOutputNodeConnector(value);
1028         ab.setAction(new OutputActionCaseBuilder().setOutputAction(output.build()).build());
1029         ab.setOrder(0);
1030         ab.setKey(new ActionKey(0));
1031         actionList.add(ab.build());
1032         // Create an Apply Action
1033         ApplyActionsBuilder aab = new ApplyActionsBuilder();
1034         aab.setAction(actionList);
1035
1036         // Wrap our Apply Action in an Instruction
1037         InstructionBuilder ib = new InstructionBuilder();
1038         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1039         ib.setOrder(0);
1040         ib.setKey(new InstructionKey(0));
1041
1042         // Put our Instruction in a list of Instructions
1043         InstructionsBuilder isb = new InstructionsBuilder();
1044         List<Instruction> instructions = new ArrayList<Instruction>();
1045         instructions.add(ib.build());
1046         isb.setInstruction(instructions);
1047         return isb;
1048     }
1049
1050     private static InstructionsBuilder createStripVlanInstructions() {
1051         List<Action> actionList = new ArrayList<Action>();
1052         ActionBuilder ab = new ActionBuilder();
1053
1054         StripVlanActionBuilder stripActionBuilder = new StripVlanActionBuilder();
1055         ab.setAction(new StripVlanActionCaseBuilder().setStripVlanAction(stripActionBuilder.build()).build());
1056         ab.setOrder(0);
1057         ab.setKey(new ActionKey(0));
1058         actionList.add(ab.build());
1059         // Create an Apply Action
1060         ApplyActionsBuilder aab = new ApplyActionsBuilder();
1061         aab.setAction(actionList);
1062
1063         // Wrap our Apply Action in an Instruction
1064         InstructionBuilder ib = new InstructionBuilder();
1065         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1066         ib.setOrder(0);
1067         ib.setKey(new InstructionKey(0));
1068
1069         // Put our Instruction in a list of Instructions
1070         InstructionsBuilder isb = new InstructionsBuilder();
1071         List<Instruction> instructions = new ArrayList<Instruction>();
1072         instructions.add(ib.build());
1073         isb.setInstruction(instructions);
1074         return isb;
1075     }
1076
1077     private static InstructionsBuilder createAppyActionInstruction2() {
1078
1079         List<Action> actionList = new ArrayList<Action>();
1080         ActionBuilder ab = new ActionBuilder();
1081
1082         PushMplsActionBuilder push = new PushMplsActionBuilder();
1083         push.setEthernetType(new Integer(0x8847));
1084         ab.setAction(new PushMplsActionCaseBuilder().setPushMplsAction(push.build()).build());
1085         ab.setKey(new ActionKey(0));
1086         actionList.add(ab.build());
1087         // Create an Apply Action
1088         ApplyActionsBuilder aab = new ApplyActionsBuilder();
1089         aab.setAction(actionList);
1090
1091         // Wrap our Apply Action in an Instruction
1092         InstructionBuilder ib = new InstructionBuilder();
1093         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1094
1095         // Put our Instruction in a list of Instructions
1096         InstructionsBuilder isb = new InstructionsBuilder();
1097         List<Instruction> instructions = new ArrayList<Instruction>();
1098         ib.setKey(new InstructionKey(0));
1099         instructions.add(ib.build());
1100         isb.setInstruction(instructions);
1101         return isb;
1102     }
1103
1104     private static InstructionsBuilder createAppyActionInstruction3() {
1105
1106         List<Action> actionList = new ArrayList<Action>();
1107         ActionBuilder ab = new ActionBuilder();
1108
1109         PushPbbActionBuilder pbb = new PushPbbActionBuilder();
1110         pbb.setEthernetType(new Integer(0x88E7));
1111         ab.setAction(new PushPbbActionCaseBuilder().setPushPbbAction(pbb.build()).build());
1112         ab.setKey(new ActionKey(0));
1113         actionList.add(ab.build());
1114         // Create an Apply Action
1115         ApplyActionsBuilder aab = new ApplyActionsBuilder();
1116         aab.setAction(actionList);
1117
1118         // Wrap our Apply Action in an Instruction
1119         InstructionBuilder ib = new InstructionBuilder();
1120         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1121
1122         // Put our Instruction in a list of Instructions
1123         InstructionsBuilder isb = new InstructionsBuilder();
1124         List<Instruction> instructions = new ArrayList<Instruction>();
1125         ib.setKey(new InstructionKey(0));
1126         instructions.add(ib.build());
1127         isb.setInstruction(instructions);
1128         return isb;
1129     }
1130
1131     private static InstructionsBuilder createAppyActionInstruction4() {
1132
1133         List<Action> actionList = new ArrayList<Action>();
1134         ActionBuilder ab = new ActionBuilder();
1135
1136         PushVlanActionBuilder vlan = new PushVlanActionBuilder();
1137         vlan.setEthernetType(new Integer(0x8100));
1138         ab.setAction(new PushVlanActionCaseBuilder().setPushVlanAction(vlan.build()).build());
1139         ab.setKey(new ActionKey(0));
1140         actionList.add(ab.build());
1141
1142         // Create an Apply Action
1143         ApplyActionsBuilder aab = new ApplyActionsBuilder();
1144         aab.setAction(actionList);
1145
1146         // Wrap our Apply Action in an Instruction
1147         InstructionBuilder ib = new InstructionBuilder();
1148         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1149
1150         // Put our Instruction in a list of Instructions
1151         InstructionsBuilder isb = new InstructionsBuilder();
1152         List<Instruction> instructions = new ArrayList<Instruction>();
1153         ib.setKey(new InstructionKey(0));
1154         instructions.add(ib.build());
1155         isb.setInstruction(instructions);
1156         return isb;
1157     }
1158
1159     private static InstructionsBuilder createAppyActionInstruction5() {
1160
1161         List<Action> actionList = new ArrayList<Action>();
1162         ActionBuilder ab = new ActionBuilder();
1163
1164         SetDlDstActionBuilder setdl = new SetDlDstActionBuilder();
1165         setdl.setAddress(new MacAddress("00:05:b9:7c:81:5f"));
1166         ab.setAction(new SetDlDstActionCaseBuilder().setSetDlDstAction(setdl.build()).build());
1167         ab.setKey(new ActionKey(0));
1168         actionList.add(ab.build());
1169         // Create an Apply Action
1170         ApplyActionsBuilder aab = new ApplyActionsBuilder();
1171         aab.setAction(actionList);
1172
1173         // Wrap our Apply Action in an Instruction
1174         InstructionBuilder ib = new InstructionBuilder();
1175         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1176
1177         // Put our Instruction in a list of Instructions
1178         InstructionsBuilder isb = new InstructionsBuilder();
1179         List<Instruction> instructions = new ArrayList<Instruction>();
1180         ib.setKey(new InstructionKey(0));
1181         instructions.add(ib.build());
1182         isb.setInstruction(instructions);
1183         return isb;
1184     }
1185
1186     private static InstructionsBuilder createAppyActionInstruction6() {
1187
1188         List<Action> actionList = new ArrayList<Action>();
1189         ActionBuilder ab = new ActionBuilder();
1190
1191         SetDlSrcActionBuilder src = new SetDlSrcActionBuilder();
1192         src.setAddress(new MacAddress("00:05:b9:7c:81:5f"));
1193         ab.setAction(new SetDlSrcActionCaseBuilder().setSetDlSrcAction(src.build()).build());
1194         ab.setKey(new ActionKey(0));
1195         actionList.add(ab.build());
1196
1197         // Create an Apply Action
1198         ApplyActionsBuilder aab = new ApplyActionsBuilder();
1199         aab.setAction(actionList);
1200
1201         // Wrap our Apply Action in an Instruction
1202         InstructionBuilder ib = new InstructionBuilder();
1203         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1204
1205         // Put our Instruction in a list of Instructions
1206         InstructionsBuilder isb = new InstructionsBuilder();
1207         List<Instruction> instructions = new ArrayList<Instruction>();
1208         ib.setKey(new InstructionKey(0));
1209         instructions.add(ib.build());
1210         isb.setInstruction(instructions);
1211         return isb;
1212     }
1213
1214     private static InstructionsBuilder createAppyActionInstruction7() {
1215
1216         List<Action> actionList = new ArrayList<Action>();
1217         ActionBuilder ab = new ActionBuilder();
1218
1219         SetVlanIdActionBuilder vl = new SetVlanIdActionBuilder();
1220         VlanId a = new VlanId(4000);
1221         vl.setVlanId(a);
1222         ab.setAction(new SetVlanIdActionCaseBuilder().setSetVlanIdAction(vl.build()).build());
1223         ab.setKey(new ActionKey(0));
1224         actionList.add(ab.build());
1225         // Create an Apply Action
1226         ApplyActionsBuilder aab = new ApplyActionsBuilder();
1227         aab.setAction(actionList);
1228
1229         // Wrap our Apply Action in an Instruction
1230         InstructionBuilder ib = new InstructionBuilder();
1231         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1232
1233         // Put our Instruction in a list of Instructions
1234         InstructionsBuilder isb = new InstructionsBuilder();
1235         List<Instruction> instructions = new ArrayList<Instruction>();
1236         ib.setKey(new InstructionKey(0));
1237         instructions.add(ib.build());
1238         isb.setInstruction(instructions);
1239         return isb;
1240     }
1241
1242     private static InstructionsBuilder createAppyActionInstruction8() {
1243
1244         List<Action> actionList = new ArrayList<Action>();
1245         ActionBuilder ab = new ActionBuilder();
1246
1247         SetVlanPcpActionBuilder pcp = new SetVlanPcpActionBuilder();
1248         VlanPcp pcp1 = new VlanPcp((short) 2);
1249         pcp.setVlanPcp(pcp1);
1250         ab.setAction(new SetVlanPcpActionCaseBuilder().setSetVlanPcpAction(pcp.build()).build());
1251         ab.setKey(new ActionKey(0));
1252         actionList.add(ab.build());
1253         // Create an Apply Action
1254         ApplyActionsBuilder aab = new ApplyActionsBuilder();
1255         aab.setAction(actionList);
1256
1257         // Wrap our Apply Action in an Instruction
1258         InstructionBuilder ib = new InstructionBuilder();
1259         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1260
1261         // Put our Instruction in a list of Instructions
1262         InstructionsBuilder isb = new InstructionsBuilder();
1263         List<Instruction> instructions = new ArrayList<Instruction>();
1264         ib.setKey(new InstructionKey(0));
1265         instructions.add(ib.build());
1266         isb.setInstruction(instructions);
1267         return isb;
1268     }
1269
1270     private static InstructionsBuilder createAppyActionInstruction88() {
1271
1272         List<Action> actionList = new ArrayList<Action>();
1273         ActionBuilder ab = new ActionBuilder();
1274
1275         SetVlanPcpActionBuilder pcp = new SetVlanPcpActionBuilder();
1276         // the code point is a 3-bit(0-7) field representing the frame priority level
1277         VlanPcp pcp1 = new VlanPcp((short) 4);
1278         pcp.setVlanPcp(pcp1);
1279         ab.setAction(new SetVlanPcpActionCaseBuilder().setSetVlanPcpAction(pcp.build()).build());
1280         ab.setKey(new ActionKey(0));
1281         actionList.add(ab.build());
1282         // Create an Apply Action
1283         ApplyActionsBuilder aab = new ApplyActionsBuilder();
1284         aab.setAction(actionList);
1285
1286         // Wrap our Apply Action in an Instruction
1287         InstructionBuilder ib = new InstructionBuilder();
1288         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1289
1290         // Put our Instruction in a list of Instructions
1291         InstructionsBuilder isb = new InstructionsBuilder();
1292         List<Instruction> instructions = new ArrayList<Instruction>();
1293         ib.setKey(new InstructionKey(0));
1294         instructions.add(ib.build());
1295         isb.setInstruction(instructions);
1296         return isb;
1297     }
1298
1299     private static InstructionsBuilder createAppyActionInstruction9() {
1300
1301         List<Action> actionList = new ArrayList<Action>();
1302         ActionBuilder ab = new ActionBuilder();
1303
1304         CopyTtlInBuilder ttlin = new CopyTtlInBuilder();
1305         ab.setAction(new CopyTtlInCaseBuilder().setCopyTtlIn(ttlin.build()).build());
1306         ab.setKey(new ActionKey(0));
1307         actionList.add(ab.build());
1308         // Create an Apply Action
1309         ApplyActionsBuilder aab = new ApplyActionsBuilder();
1310         aab.setAction(actionList);
1311
1312         // Wrap our Apply Action in an Instruction
1313         InstructionBuilder ib = new InstructionBuilder();
1314         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1315
1316         // Put our Instruction in a list of Instructions
1317         InstructionsBuilder isb = new InstructionsBuilder();
1318         List<Instruction> instructions = new ArrayList<Instruction>();
1319         ib.setKey(new InstructionKey(0));
1320         instructions.add(ib.build());
1321         isb.setInstruction(instructions);
1322         return isb;
1323     }
1324
1325     private static InstructionsBuilder createAppyActionInstruction10() {
1326
1327         List<Action> actionList = new ArrayList<Action>();
1328         ActionBuilder ab = new ActionBuilder();
1329
1330         CopyTtlOutBuilder ttlout = new CopyTtlOutBuilder();
1331         ab.setAction(new CopyTtlOutCaseBuilder().setCopyTtlOut(ttlout.build()).build());
1332         ab.setKey(new ActionKey(0));
1333         actionList.add(ab.build());
1334         // Create an Apply Action
1335         ApplyActionsBuilder aab = new ApplyActionsBuilder();
1336         aab.setAction(actionList);
1337
1338         // Wrap our Apply Action in an Instruction
1339         InstructionBuilder ib = new InstructionBuilder();
1340         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1341
1342         // Put our Instruction in a list of Instructions
1343         InstructionsBuilder isb = new InstructionsBuilder();
1344         List<Instruction> instructions = new ArrayList<Instruction>();
1345         ib.setKey(new InstructionKey(0));
1346         instructions.add(ib.build());
1347         isb.setInstruction(instructions);
1348         return isb;
1349     }
1350
1351     private static InstructionsBuilder createAppyActionInstruction11() {
1352
1353         List<Action> actionList = new ArrayList<Action>();
1354         ActionBuilder ab = new ActionBuilder();
1355
1356         DecMplsTtlBuilder mpls = new DecMplsTtlBuilder();
1357         ab.setAction(new DecMplsTtlCaseBuilder().setDecMplsTtl(mpls.build()).build());
1358         ab.setKey(new ActionKey(0));
1359         actionList.add(ab.build());
1360         // Create an Apply Action
1361         ApplyActionsBuilder aab = new ApplyActionsBuilder();
1362         aab.setAction(actionList);
1363
1364         // Wrap our Apply Action in an Instruction
1365         InstructionBuilder ib = new InstructionBuilder();
1366         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1367         ib.setKey(new InstructionKey(0));
1368         ib.setOrder(0);
1369
1370         // Put our Instruction in a list of Instruction
1371         InstructionsBuilder isb = new InstructionsBuilder();
1372         List<Instruction> instructions = new ArrayList<Instruction>();
1373         instructions.add(ib.build());
1374         isb.setInstruction(instructions);
1375         return isb;
1376     }
1377
1378     private static InstructionsBuilder createAppyActionInstruction12() {
1379
1380         List<Action> actionList = new ArrayList<Action>();
1381         ActionBuilder ab = new ActionBuilder();
1382
1383         DecNwTtlBuilder nwttl = new DecNwTtlBuilder();
1384         ab.setAction(new DecNwTtlCaseBuilder().setDecNwTtl(nwttl.build()).build());
1385         ab.setKey(new ActionKey(0));
1386         actionList.add(ab.build());
1387
1388         // Create an Apply Action
1389         ApplyActionsBuilder aab = new ApplyActionsBuilder();
1390         aab.setAction(actionList);
1391
1392         // Wrap our Apply Action in an Instruction
1393         InstructionBuilder ib = new InstructionBuilder();
1394         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1395
1396         // Put our Instruction in a list of Instructions
1397         InstructionsBuilder isb = new InstructionsBuilder();
1398         List<Instruction> instructions = new ArrayList<Instruction>();
1399         ib.setKey(new InstructionKey(0));
1400         instructions.add(ib.build());
1401         isb.setInstruction(instructions);
1402         return isb;
1403     }
1404
1405     private static InstructionsBuilder createAppyActionInstruction13() {
1406
1407         List<Action> actionList = new ArrayList<Action>();
1408         ActionBuilder ab = new ActionBuilder();
1409
1410         DropActionBuilder drop = new DropActionBuilder();
1411         ab.setAction(new DropActionCaseBuilder().setDropAction(drop.build()).build());
1412         ab.setKey(new ActionKey(0));
1413         actionList.add(ab.build());
1414
1415         // Create an Apply Action
1416         ApplyActionsBuilder aab = new ApplyActionsBuilder();
1417         aab.setAction(actionList);
1418
1419         // Wrap our Apply Action in an Instruction
1420         InstructionBuilder ib = new InstructionBuilder();
1421         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1422
1423         // Put our Instruction in a list of Instructions
1424         InstructionsBuilder isb = new InstructionsBuilder();
1425         List<Instruction> instructions = new ArrayList<Instruction>();
1426         ib.setKey(new InstructionKey(0));
1427         instructions.add(ib.build());
1428         isb.setInstruction(instructions);
1429         return isb;
1430     }
1431
1432     private static InstructionsBuilder createAppyActionInstruction14() {
1433
1434         List<Action> actionList = new ArrayList<Action>();
1435         ActionBuilder ab = new ActionBuilder();
1436
1437         FloodActionBuilder fld = new FloodActionBuilder();
1438         ab.setAction(new FloodActionCaseBuilder().setFloodAction(fld.build()).build());
1439         ab.setKey(new ActionKey(0));
1440         actionList.add(ab.build());
1441         // Create an Apply Action
1442         ApplyActionsBuilder aab = new ApplyActionsBuilder();
1443         aab.setAction(actionList);
1444
1445         // Wrap our Apply Action in an Instruction
1446         InstructionBuilder ib = new InstructionBuilder();
1447         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1448
1449         // Put our Instruction in a list of Instructions
1450         InstructionsBuilder isb = new InstructionsBuilder();
1451         List<Instruction> instructions = new ArrayList<Instruction>();
1452         ib.setKey(new InstructionKey(0));
1453         instructions.add(ib.build());
1454         isb.setInstruction(instructions);
1455         return isb;
1456     }
1457
1458     private static InstructionsBuilder createAppyActionInstruction15() {
1459
1460         List<Action> actionList = new ArrayList<Action>();
1461         ActionBuilder ab = new ActionBuilder();
1462
1463         FloodAllActionBuilder fldall = new FloodAllActionBuilder();
1464         ab.setAction(new FloodAllActionCaseBuilder().setFloodAllAction(fldall.build()).build());
1465         ab.setKey(new ActionKey(0));
1466         actionList.add(ab.build());
1467         // Create an Apply Action
1468         ApplyActionsBuilder aab = new ApplyActionsBuilder();
1469         aab.setAction(actionList);
1470
1471         // Wrap our Apply Action in an Instruction
1472         InstructionBuilder ib = new InstructionBuilder();
1473         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1474
1475         // Put our Instruction in a list of Instructions
1476         InstructionsBuilder isb = new InstructionsBuilder();
1477         List<Instruction> instructions = new ArrayList<Instruction>();
1478         ib.setKey(new InstructionKey(0));
1479         instructions.add(ib.build());
1480         isb.setInstruction(instructions);
1481         return isb;
1482     }
1483
1484     private static InstructionsBuilder createAppyActionInstruction16() {
1485
1486         List<Action> actionList = new ArrayList<Action>();
1487         ActionBuilder ab = new ActionBuilder();
1488
1489         GroupActionBuilder groupActionB = new GroupActionBuilder();
1490         groupActionB.setGroupId(1L);
1491         groupActionB.setGroup("0");
1492         ab.setAction(new GroupActionCaseBuilder().setGroupAction(groupActionB.build()).build());
1493         ab.setKey(new ActionKey(0));
1494         actionList.add(ab.build());
1495
1496         // Create an Apply Action
1497         ApplyActionsBuilder aab = new ApplyActionsBuilder();
1498         aab.setAction(actionList);
1499
1500         // Wrap our Apply Action in an Instruction
1501         InstructionBuilder ib = new InstructionBuilder();
1502         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1503
1504         // Put our Instruction in a list of Instructions
1505         InstructionsBuilder isb = new InstructionsBuilder();
1506         List<Instruction> instructions = new ArrayList<Instruction>();
1507         ib.setKey(new InstructionKey(0));
1508         instructions.add(ib.build());
1509         isb.setInstruction(instructions);
1510         return isb;
1511     }
1512
1513     private static InstructionsBuilder createAppyActionInstruction17() {
1514
1515         List<Action> actionList = new ArrayList<Action>();
1516         ActionBuilder ab = new ActionBuilder();
1517
1518         HwPathActionBuilder hwPathB = new HwPathActionBuilder();
1519         ab.setAction(new HwPathActionCaseBuilder().setHwPathAction(hwPathB.build()).build());
1520         ab.setKey(new ActionKey(0));
1521         actionList.add(ab.build());
1522         // Create an Apply Action
1523         ApplyActionsBuilder aab = new ApplyActionsBuilder();
1524         aab.setAction(actionList);
1525
1526         // Wrap our Apply Action in an Instruction
1527         InstructionBuilder ib = new InstructionBuilder();
1528         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1529
1530         // Put our Instruction in a list of Instructions
1531         InstructionsBuilder isb = new InstructionsBuilder();
1532         List<Instruction> instructions = new ArrayList<Instruction>();
1533         ib.setKey(new InstructionKey(0));
1534         instructions.add(ib.build());
1535         isb.setInstruction(instructions);
1536         return isb;
1537     }
1538
1539     private static InstructionsBuilder createAppyActionInstruction18() {
1540
1541         List<Action> actionList = new ArrayList<Action>();
1542         ActionBuilder ab = new ActionBuilder();
1543
1544         LoopbackActionBuilder loopbackActionBuilder = new LoopbackActionBuilder();
1545         ab.setAction(new LoopbackActionCaseBuilder().setLoopbackAction(loopbackActionBuilder.build()).build());
1546         ab.setKey(new ActionKey(0));
1547         actionList.add(ab.build());
1548
1549         // Create an Apply Action
1550         ApplyActionsBuilder aab = new ApplyActionsBuilder();
1551         aab.setAction(actionList);
1552
1553         // Wrap our Apply Action in an Instruction
1554         InstructionBuilder ib = new InstructionBuilder();
1555         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1556
1557         // Put our Instruction in a list of Instructions
1558         InstructionsBuilder isb = new InstructionsBuilder();
1559         List<Instruction> instructions = new ArrayList<Instruction>();
1560         ib.setKey(new InstructionKey(0));
1561         instructions.add(ib.build());
1562         isb.setInstruction(instructions);
1563         return isb;
1564     }
1565
1566     private static InstructionsBuilder createAppyActionInstruction19() {
1567
1568         List<Action> actionList = new ArrayList<Action>();
1569         ActionBuilder ab = new ActionBuilder();
1570
1571         PopMplsActionBuilder popMplsActionBuilder = new PopMplsActionBuilder();
1572         popMplsActionBuilder.setEthernetType(0XB);
1573         ab.setAction(new PopMplsActionCaseBuilder().setPopMplsAction(popMplsActionBuilder.build()).build());
1574         ab.setKey(new ActionKey(0));
1575         actionList.add(ab.build());
1576         // Create an Apply Action
1577         ApplyActionsBuilder aab = new ApplyActionsBuilder();
1578         aab.setAction(actionList);
1579
1580         // Wrap our Apply Action in an Instruction
1581         InstructionBuilder ib = new InstructionBuilder();
1582         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1583
1584         // Put our Instruction in a list of Instructions
1585         InstructionsBuilder isb = new InstructionsBuilder();
1586         List<Instruction> instructions = new ArrayList<Instruction>();
1587         ib.setKey(new InstructionKey(0));
1588         instructions.add(ib.build());
1589         isb.setInstruction(instructions);
1590         return isb;
1591     }
1592
1593     private static InstructionsBuilder createAppyActionInstruction20() {
1594
1595         List<Action> actionList = new ArrayList<Action>();
1596         ActionBuilder ab = new ActionBuilder();
1597
1598         PopPbbActionBuilder popPbbActionBuilder = new PopPbbActionBuilder();
1599         ab.setAction(new PopPbbActionCaseBuilder().setPopPbbAction(popPbbActionBuilder.build()).build());
1600         ab.setKey(new ActionKey(0));
1601         actionList.add(ab.build());
1602         // Create an Apply Action
1603         ApplyActionsBuilder aab = new ApplyActionsBuilder();
1604         aab.setAction(actionList);
1605
1606         // Wrap our Apply Action in an Instruction
1607         InstructionBuilder ib = new InstructionBuilder();
1608         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1609
1610         // Put our Instruction in a list of Instructions
1611         InstructionsBuilder isb = new InstructionsBuilder();
1612         List<Instruction> instructions = new ArrayList<Instruction>();
1613         ib.setKey(new InstructionKey(0));
1614         instructions.add(ib.build());
1615         isb.setInstruction(instructions);
1616         return isb;
1617     }
1618
1619     private static InstructionsBuilder createAppyActionInstruction21() {
1620
1621         List<Action> actionList = new ArrayList<Action>();
1622         ActionBuilder ab = new ActionBuilder();
1623
1624         PopVlanActionBuilder popVlanActionBuilder = new PopVlanActionBuilder();
1625         ab.setAction(new PopVlanActionCaseBuilder().setPopVlanAction(popVlanActionBuilder.build()).build());
1626         ab.setKey(new ActionKey(0));
1627         actionList.add(ab.build());
1628
1629         // Create an Apply Action
1630         ApplyActionsBuilder aab = new ApplyActionsBuilder();
1631         aab.setAction(actionList);
1632
1633         // Wrap our Apply Action in an Instruction
1634         InstructionBuilder ib = new InstructionBuilder();
1635         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1636
1637         // Put our Instruction in a list of Instructions
1638         InstructionsBuilder isb = new InstructionsBuilder();
1639         List<Instruction> instructions = new ArrayList<Instruction>();
1640         ib.setKey(new InstructionKey(0));
1641         instructions.add(ib.build());
1642         isb.setInstruction(instructions);
1643         return isb;
1644     }
1645
1646     private static InstructionsBuilder createAppyActionInstruction22() {
1647
1648         List<Action> actionList = new ArrayList<Action>();
1649         ActionBuilder ab = new ActionBuilder();
1650
1651         SetDlTypeActionBuilder setDlTypeActionBuilder = new SetDlTypeActionBuilder();
1652         setDlTypeActionBuilder.setDlType(new EtherType(8L));
1653         ab.setAction(new SetDlTypeActionCaseBuilder().setSetDlTypeAction(setDlTypeActionBuilder.build()).build());
1654         ab.setKey(new ActionKey(0));
1655         actionList.add(ab.build());
1656
1657         // Create an Apply Action
1658         ApplyActionsBuilder aab = new ApplyActionsBuilder();
1659         aab.setAction(actionList);
1660
1661         // Wrap our Apply Action in an Instruction
1662         InstructionBuilder ib = new InstructionBuilder();
1663         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1664
1665         // Put our Instruction in a list of Instructions
1666         InstructionsBuilder isb = new InstructionsBuilder();
1667         List<Instruction> instructions = new ArrayList<Instruction>();
1668         ib.setKey(new InstructionKey(0));
1669         instructions.add(ib.build());
1670         isb.setInstruction(instructions);
1671         return isb;
1672     }
1673
1674     private static InstructionsBuilder createAppyActionInstruction23(NodeId nodeId) {
1675
1676         List<Action> actionList = new ArrayList<Action>();
1677         ActionBuilder ab = new ActionBuilder();
1678
1679         SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
1680         setFieldBuilder.setInPort(new NodeConnectorId(nodeId + ":2"));
1681         ab.setKey(new ActionKey(0));
1682         actionList.add(ab.build());
1683
1684         // Create an Apply Action
1685         ApplyActionsBuilder aab = new ApplyActionsBuilder();
1686         aab.setAction(actionList);
1687
1688         // Wrap our Apply Action in an Instruction
1689         InstructionBuilder ib = new InstructionBuilder();
1690         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1691
1692         // Put our Instruction in a list of Instructions
1693         InstructionsBuilder isb = new InstructionsBuilder();
1694         List<Instruction> instructions = new ArrayList<Instruction>();
1695         ib.setKey(new InstructionKey(0));
1696         instructions.add(ib.build());
1697         isb.setInstruction(instructions);
1698         return isb;
1699     }
1700
1701     private static InstructionsBuilder createAppyActionInstruction24() {
1702
1703         List<Action> actionList = new ArrayList<Action>();
1704         ActionBuilder ab = new ActionBuilder();
1705
1706         SetMplsTtlActionBuilder setMplsTtlActionBuilder = new SetMplsTtlActionBuilder();
1707         setMplsTtlActionBuilder.setMplsTtl((short) 0X1);
1708         ab.setAction(new SetMplsTtlActionCaseBuilder().setSetMplsTtlAction(setMplsTtlActionBuilder.build()).build());
1709         ab.setKey(new ActionKey(0));
1710         actionList.add(ab.build());
1711
1712         // Create an Apply Action
1713         ApplyActionsBuilder aab = new ApplyActionsBuilder();
1714         aab.setAction(actionList);
1715
1716         // Wrap our Apply Action in an Instruction
1717         InstructionBuilder ib = new InstructionBuilder();
1718         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1719
1720         // Put our Instruction in a list of Instructions
1721         InstructionsBuilder isb = new InstructionsBuilder();
1722         List<Instruction> instructions = new ArrayList<Instruction>();
1723         ib.setKey(new InstructionKey(0));
1724         instructions.add(ib.build());
1725         isb.setInstruction(instructions);
1726         return isb;
1727     }
1728
1729     private static InstructionsBuilder createAppyActionInstruction25() {
1730
1731         List<Action> actionList = new ArrayList<Action>();
1732         ActionBuilder ab = new ActionBuilder();
1733
1734         SetNextHopActionBuilder setNextHopActionBuilder = new SetNextHopActionBuilder();
1735         Ipv4Builder ipnext = new Ipv4Builder();
1736         Ipv4Prefix prefix = new Ipv4Prefix("10.0.0.1/24");
1737         ipnext.setIpv4Address(prefix);
1738         setNextHopActionBuilder.setAddress(ipnext.build());
1739         ab.setAction(new SetNextHopActionCaseBuilder().setSetNextHopAction(setNextHopActionBuilder.build()).build());
1740         ab.setKey(new ActionKey(0));
1741         actionList.add(ab.build());
1742
1743         // Create an Apply Action
1744         ApplyActionsBuilder aab = new ApplyActionsBuilder();
1745         aab.setAction(actionList);
1746
1747         // Wrap our Apply Action in an Instruction
1748         InstructionBuilder ib = new InstructionBuilder();
1749         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1750
1751         // Put our Instruction in a list of Instructions
1752         InstructionsBuilder isb = new InstructionsBuilder();
1753         List<Instruction> instructions = new ArrayList<Instruction>();
1754         ib.setKey(new InstructionKey(0));
1755         instructions.add(ib.build());
1756         isb.setInstruction(instructions);
1757         return isb;
1758     }
1759
1760     private static InstructionsBuilder createAppyActionInstruction26() {
1761
1762         List<Action> actionList = new ArrayList<Action>();
1763         ActionBuilder ab = new ActionBuilder();
1764
1765         SetNwDstActionBuilder setNwDstActionBuilder = new SetNwDstActionBuilder();
1766         Ipv4Builder ipdst = new Ipv4Builder();
1767         Ipv4Prefix prefixdst = new Ipv4Prefix("10.0.0.21/24");
1768         ipdst.setIpv4Address(prefixdst);
1769         setNwDstActionBuilder.setAddress(ipdst.build());
1770         ab.setAction(new SetNwDstActionCaseBuilder().setSetNwDstAction(setNwDstActionBuilder.build()).build());
1771         ab.setKey(new ActionKey(0));
1772         actionList.add(ab.build());
1773
1774         // Create an Apply Action
1775         ApplyActionsBuilder aab = new ApplyActionsBuilder();
1776         aab.setAction(actionList);
1777
1778         // Wrap our Apply Action in an Instruction
1779         InstructionBuilder ib = new InstructionBuilder();
1780         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1781
1782         // Put our Instruction in a list of Instructions
1783         InstructionsBuilder isb = new InstructionsBuilder();
1784         List<Instruction> instructions = new ArrayList<Instruction>();
1785         ib.setKey(new InstructionKey(0));
1786         instructions.add(ib.build());
1787         isb.setInstruction(instructions);
1788         return isb;
1789     }
1790
1791     private static InstructionsBuilder createAppyActionInstruction27() {
1792
1793         List<Action> actionList = new ArrayList<Action>();
1794         ActionBuilder ab = new ActionBuilder();
1795
1796         SetNwSrcActionBuilder setNwsrcActionBuilder = new SetNwSrcActionBuilder();
1797         Ipv4Builder ipsrc = new Ipv4Builder();
1798         Ipv4Prefix prefixsrc = new Ipv4Prefix("10.0.23.21/24");
1799         ipsrc.setIpv4Address(prefixsrc);
1800         setNwsrcActionBuilder.setAddress(ipsrc.build());
1801         ab.setAction(new SetNwSrcActionCaseBuilder().setSetNwSrcAction(setNwsrcActionBuilder.build()).build());
1802         ab.setKey(new ActionKey(0));
1803         actionList.add(ab.build());
1804
1805         // Create an Apply Action
1806         ApplyActionsBuilder aab = new ApplyActionsBuilder();
1807         aab.setAction(actionList);
1808
1809         // Wrap our Apply Action in an Instruction
1810         InstructionBuilder ib = new InstructionBuilder();
1811         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1812
1813         // Put our Instruction in a list of Instructions
1814         InstructionsBuilder isb = new InstructionsBuilder();
1815         List<Instruction> instructions = new ArrayList<Instruction>();
1816         ib.setKey(new InstructionKey(0));
1817         instructions.add(ib.build());
1818         isb.setInstruction(instructions);
1819         return isb;
1820     }
1821
1822     private static InstructionsBuilder createAppyActionInstruction28() {
1823
1824         List<Action> actionList = new ArrayList<Action>();
1825         ActionBuilder ab = new ActionBuilder();
1826
1827         SetNwTosActionBuilder setNwTosActionBuilder = new SetNwTosActionBuilder();
1828         setNwTosActionBuilder.setTos(8);
1829         ab.setAction(new SetNwTosActionCaseBuilder().setSetNwTosAction(setNwTosActionBuilder.build()).build());
1830         ab.setKey(new ActionKey(0));
1831         actionList.add(ab.build());
1832         // Create an Apply Action
1833         ApplyActionsBuilder aab = new ApplyActionsBuilder();
1834         aab.setAction(actionList);
1835
1836         // Wrap our Apply Action in an Instruction
1837         InstructionBuilder ib = new InstructionBuilder();
1838         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1839
1840         // Put our Instruction in a list of Instructions
1841         InstructionsBuilder isb = new InstructionsBuilder();
1842         List<Instruction> instructions = new ArrayList<Instruction>();
1843         ib.setKey(new InstructionKey(0));
1844         instructions.add(ib.build());
1845         isb.setInstruction(instructions);
1846         return isb;
1847     }
1848
1849     private static InstructionsBuilder createAppyActionInstruction29() {
1850
1851         List<Action> actionList = new ArrayList<Action>();
1852         ActionBuilder ab = new ActionBuilder();
1853
1854         SetNwTtlActionBuilder setNwTtlActionBuilder = new SetNwTtlActionBuilder();
1855         setNwTtlActionBuilder.setNwTtl((short) 1);
1856         ab.setAction(new SetNwTtlActionCaseBuilder().setSetNwTtlAction(setNwTtlActionBuilder.build()).build());
1857         ab.setKey(new ActionKey(0));
1858         actionList.add(ab.build());
1859
1860         // Create an Apply Action
1861         ApplyActionsBuilder aab = new ApplyActionsBuilder();
1862         aab.setAction(actionList);
1863
1864         // Wrap our Apply Action in an Instruction
1865         InstructionBuilder ib = new InstructionBuilder();
1866         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1867
1868         // Put our Instruction in a list of Instructions
1869         InstructionsBuilder isb = new InstructionsBuilder();
1870         List<Instruction> instructions = new ArrayList<Instruction>();
1871         ib.setKey(new InstructionKey(0));
1872         instructions.add(ib.build());
1873         isb.setInstruction(instructions);
1874         return isb;
1875     }
1876
1877     private static InstructionsBuilder createAppyActionInstruction30() {
1878
1879         List<Action> actionList = new ArrayList<Action>();
1880         ActionBuilder ab = new ActionBuilder();
1881
1882         SetQueueActionBuilder setQueueActionBuilder = new SetQueueActionBuilder();
1883         setQueueActionBuilder.setQueueId(1L);
1884         ab.setAction(new SetQueueActionCaseBuilder().setSetQueueAction(setQueueActionBuilder.build()).build());
1885         ab.setKey(new ActionKey(0));
1886         actionList.add(ab.build());
1887         // Create an Apply Action
1888         ApplyActionsBuilder aab = new ApplyActionsBuilder();
1889         aab.setAction(actionList);
1890
1891         // Wrap our Apply Action in an Instruction
1892         InstructionBuilder ib = new InstructionBuilder();
1893         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1894
1895         // Put our Instruction in a list of Instructions
1896         InstructionsBuilder isb = new InstructionsBuilder();
1897         List<Instruction> instructions = new ArrayList<Instruction>();
1898         ib.setKey(new InstructionKey(0));
1899         instructions.add(ib.build());
1900         isb.setInstruction(instructions);
1901         return isb;
1902     }
1903
1904     private static InstructionsBuilder createAppyActionInstruction31() {
1905
1906         List<Action> actionList = new ArrayList<Action>();
1907         ActionBuilder ab = new ActionBuilder();
1908
1909         SetTpDstActionBuilder setTpDstActionBuilder = new SetTpDstActionBuilder();
1910         setTpDstActionBuilder.setPort(new PortNumber(109));
1911
1912         ab.setAction(new SetTpDstActionCaseBuilder().setSetTpDstAction(setTpDstActionBuilder.build()).build());
1913         ab.setKey(new ActionKey(0));
1914         actionList.add(ab.build());
1915         // Create an Apply Action
1916         ApplyActionsBuilder aab = new ApplyActionsBuilder();
1917         aab.setAction(actionList);
1918
1919         // Wrap our Apply Action in an Instruction
1920         InstructionBuilder ib = new InstructionBuilder();
1921         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1922
1923         // Put our Instruction in a list of Instructions
1924         InstructionsBuilder isb = new InstructionsBuilder();
1925         List<Instruction> instructions = new ArrayList<Instruction>();
1926         ib.setKey(new InstructionKey(0));
1927         instructions.add(ib.build());
1928         isb.setInstruction(instructions);
1929         return isb;
1930     }
1931
1932     private static InstructionsBuilder createAppyActionInstruction32() {
1933
1934         List<Action> actionList = new ArrayList<Action>();
1935         ActionBuilder ab = new ActionBuilder();
1936
1937         SetTpSrcActionBuilder setTpSrcActionBuilder = new SetTpSrcActionBuilder();
1938         setTpSrcActionBuilder.setPort(new PortNumber(109));
1939         ab.setAction(new SetTpSrcActionCaseBuilder().setSetTpSrcAction(setTpSrcActionBuilder.build()).build());
1940         ab.setKey(new ActionKey(0));
1941         actionList.add(ab.build());
1942
1943         // Create an Apply Action
1944         ApplyActionsBuilder aab = new ApplyActionsBuilder();
1945         aab.setAction(actionList);
1946
1947         // Wrap our Apply Action in an Instruction
1948         InstructionBuilder ib = new InstructionBuilder();
1949         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1950
1951         // Put our Instruction in a list of Instructions
1952         InstructionsBuilder isb = new InstructionsBuilder();
1953         List<Instruction> instructions = new ArrayList<Instruction>();
1954         ib.setKey(new InstructionKey(0));
1955         instructions.add(ib.build());
1956         isb.setInstruction(instructions);
1957         return isb;
1958     }
1959
1960     private static InstructionsBuilder createAppyActionInstruction33() {
1961
1962         List<Action> actionList = new ArrayList<Action>();
1963         ActionBuilder ab = new ActionBuilder();
1964
1965         SetVlanCfiActionBuilder setVlanCfiActionBuilder = new SetVlanCfiActionBuilder();
1966         setVlanCfiActionBuilder.setVlanCfi(new VlanCfi(2));
1967         ab.setAction(new SetVlanCfiActionCaseBuilder().setSetVlanCfiAction(setVlanCfiActionBuilder.build()).build());
1968         ab.setKey(new ActionKey(0));
1969         actionList.add(ab.build());
1970
1971         // Create an Apply Action
1972         ApplyActionsBuilder aab = new ApplyActionsBuilder();
1973         aab.setAction(actionList);
1974
1975         // Wrap our Apply Action in an Instruction
1976         InstructionBuilder ib = new InstructionBuilder();
1977         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1978
1979         // Put our Instruction in a list of Instructions
1980         InstructionsBuilder isb = new InstructionsBuilder();
1981         List<Instruction> instructions = new ArrayList<Instruction>();
1982         ib.setKey(new InstructionKey(0));
1983         instructions.add(ib.build());
1984         isb.setInstruction(instructions);
1985         return isb;
1986     }
1987
1988     private static InstructionsBuilder createAppyActionInstruction34() {
1989
1990         List<Action> actionList = new ArrayList<Action>();
1991         ActionBuilder ab = new ActionBuilder();
1992
1993         SwPathActionBuilder swPathAction = new SwPathActionBuilder();
1994         ab.setAction(new SwPathActionCaseBuilder().setSwPathAction(swPathAction.build()).build());
1995         ab.setKey(new ActionKey(0));
1996         actionList.add(ab.build());
1997
1998         // Create an Apply Action
1999         ApplyActionsBuilder aab = new ApplyActionsBuilder();
2000         aab.setAction(actionList);
2001
2002         // Wrap our Apply Action in an Instruction
2003         InstructionBuilder ib = new InstructionBuilder();
2004         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
2005
2006         // Put our Instruction in a list of Instructions
2007         InstructionsBuilder isb = new InstructionsBuilder();
2008         List<Instruction> instructions = new ArrayList<Instruction>();
2009         ib.setKey(new InstructionKey(0));
2010         instructions.add(ib.build());
2011         isb.setInstruction(instructions);
2012         return isb;
2013     }
2014
2015     private static InstructionsBuilder createAppyActionInstruction35() {
2016
2017         List<Action> actionList = new ArrayList<Action>();
2018         ActionBuilder ab = new ActionBuilder();
2019         ActionBuilder ab1 = new ActionBuilder();
2020         ActionBuilder ab2 = new ActionBuilder();
2021
2022         SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
2023         SetFieldBuilder setFieldBuilder1 = new SetFieldBuilder();
2024         SetFieldBuilder setFieldBuilder2 = new SetFieldBuilder();
2025
2026         // Ethernet
2027         EthernetMatchBuilder ethernetMatch = new EthernetMatchBuilder();
2028         EthernetSourceBuilder ethSourceBuilder = new EthernetSourceBuilder();
2029         ethSourceBuilder.setAddress(new MacAddress("00:00:00:00:00:01"));
2030         EthernetMatchBuilder ethernetMatch1 = new EthernetMatchBuilder();
2031         EthernetDestinationBuilder ethDestBuilder = new EthernetDestinationBuilder();
2032         ethDestBuilder.setAddress(new MacAddress("00:00:00:00:00:02"));
2033         EthernetMatchBuilder ethernetMatch2 = new EthernetMatchBuilder();
2034         EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
2035         ethTypeBuilder.setType(new EtherType(0x86ddL));
2036
2037         ethernetMatch.setEthernetSource(ethSourceBuilder.build());
2038         ethernetMatch1.setEthernetDestination(ethDestBuilder.build());
2039         ethernetMatch2.setEthernetType(ethTypeBuilder.build());
2040         setFieldBuilder.setEthernetMatch(ethernetMatch.build());
2041         setFieldBuilder1.setEthernetMatch(ethernetMatch1.build());
2042         setFieldBuilder2.setEthernetMatch(ethernetMatch2.build());
2043         ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
2044         ab.setKey(new ActionKey(0));
2045         actionList.add(ab.build());
2046
2047         ab1.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder1.build()).build());
2048         ab1.setKey(new ActionKey(1));
2049         actionList.add(ab1.build());
2050
2051         ab2.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder2.build()).build());
2052         ab2.setKey(new ActionKey(2));
2053         actionList.add(ab2.build());
2054
2055         ApplyActionsBuilder aab = new ApplyActionsBuilder();
2056         aab.setAction(actionList);
2057
2058         InstructionBuilder ib = new InstructionBuilder();
2059         ib.setKey(new InstructionKey(0));
2060         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
2061
2062         // Put our Instruction in a list of Instructions
2063         InstructionsBuilder isb = new InstructionsBuilder();
2064         List<Instruction> instructions = new ArrayList<Instruction>();
2065         ib.setKey(new InstructionKey(0));
2066         instructions.add(ib.build());
2067         isb.setInstruction(instructions);
2068         return isb;
2069     }
2070
2071     private static InstructionsBuilder createAppyActionInstruction36() {
2072
2073         List<Action> actionList = new ArrayList<Action>();
2074         ActionBuilder ab = new ActionBuilder();
2075         ActionBuilder ab1 = new ActionBuilder();
2076
2077         SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
2078         SetFieldBuilder setFieldBuilder1 = new SetFieldBuilder();
2079
2080         // Vlan
2081         VlanMatchBuilder vlanBuilder = new VlanMatchBuilder();
2082         VlanMatchBuilder vlanBuilder1 = new VlanMatchBuilder();
2083         VlanIdBuilder vlanIdBuilder = new VlanIdBuilder();
2084         VlanId vlanId = new VlanId(10);
2085         VlanPcp vpcp = new VlanPcp((short) 3);
2086         vlanBuilder.setVlanPcp(vpcp);
2087         vlanBuilder1.setVlanId(vlanIdBuilder.setVlanId(vlanId).setVlanIdPresent(true).build());
2088         setFieldBuilder.setVlanMatch(vlanBuilder.build());
2089         setFieldBuilder1.setVlanMatch(vlanBuilder1.build());
2090         ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
2091         ab.setKey(new ActionKey(0));
2092         actionList.add(ab.build());
2093         ab1.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder1.build()).build());
2094         ab1.setKey(new ActionKey(1));
2095         actionList.add(ab1.build());
2096
2097         ApplyActionsBuilder aab = new ApplyActionsBuilder();
2098         aab.setAction(actionList);
2099
2100         InstructionBuilder ib = new InstructionBuilder();
2101         ib.setKey(new InstructionKey(0));
2102         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
2103
2104         // Put our Instruction in a list of Instructions
2105         InstructionsBuilder isb = new InstructionsBuilder();
2106         List<Instruction> instructions = new ArrayList<Instruction>();
2107         instructions.add(ib.build());
2108         isb.setInstruction(instructions);
2109         return isb;
2110     }
2111
2112     private static InstructionsBuilder createAppyActionInstruction37() {
2113
2114         List<Action> actionList = new ArrayList<Action>();
2115         ActionBuilder ab = new ActionBuilder();
2116         ActionBuilder ab1 = new ActionBuilder();
2117         ActionBuilder ab2 = new ActionBuilder();
2118
2119         SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
2120         SetFieldBuilder setFieldBuilder1 = new SetFieldBuilder();
2121         SetFieldBuilder setFieldBuilder2 = new SetFieldBuilder();
2122         // Ip
2123         IpMatchBuilder ipmatch = new IpMatchBuilder();
2124         IpMatchBuilder ipmatch1 = new IpMatchBuilder();
2125         IpMatchBuilder ipmatch2 = new IpMatchBuilder();
2126         Dscp dscp = new Dscp((short) 3);
2127         ipmatch.setIpDscp(dscp);
2128         ipmatch1.setIpEcn((short) 2);
2129         ipmatch2.setIpProtocol((short) 120);
2130         setFieldBuilder.setIpMatch(ipmatch.build());
2131         ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
2132         ab.setKey(new ActionKey(0));
2133         actionList.add(ab.build());
2134
2135         setFieldBuilder1.setIpMatch(ipmatch1.build());
2136         ab1.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder1.build()).build());
2137         ab1.setKey(new ActionKey(1));
2138         actionList.add(ab1.build());
2139
2140         setFieldBuilder2.setIpMatch(ipmatch2.build());
2141         ab2.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder2.build()).build());
2142         ab2.setKey(new ActionKey(2));
2143         actionList.add(ab2.build());
2144
2145         ApplyActionsBuilder aab = new ApplyActionsBuilder();
2146         aab.setAction(actionList);
2147
2148         InstructionBuilder ib = new InstructionBuilder();
2149         ib.setKey(new InstructionKey(0));
2150         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
2151
2152         // Put our Instruction in a list of Instructions
2153         InstructionsBuilder isb = new InstructionsBuilder();
2154         List<Instruction> instructions = new ArrayList<Instruction>();
2155         instructions.add(ib.build());
2156         isb.setInstruction(instructions);
2157         return isb;
2158     }
2159
2160     private static InstructionsBuilder createAppyActionInstruction38() {
2161
2162         List<Action> actionList = new ArrayList<Action>();
2163         ActionBuilder ab = new ActionBuilder();
2164         ActionBuilder ab1 = new ActionBuilder();
2165
2166         SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
2167         SetFieldBuilder setFieldBuilder1 = new SetFieldBuilder();
2168         // IPv4
2169         Ipv4MatchBuilder ipv4Match = new Ipv4MatchBuilder();
2170         Ipv4MatchBuilder ipv4Match1 = new Ipv4MatchBuilder();
2171         Ipv4Prefix dstip = new Ipv4Prefix("200.71.9.5210");
2172         Ipv4Prefix srcip = new Ipv4Prefix("100.1.1.1");
2173         ipv4Match1.setIpv4Destination(dstip);
2174         ipv4Match.setIpv4Source(srcip);
2175         setFieldBuilder.setLayer3Match(ipv4Match.build());
2176         ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
2177         ab.setKey(new ActionKey(0));
2178         actionList.add(ab.build());
2179
2180         setFieldBuilder1.setLayer3Match(ipv4Match1.build());
2181         ab1.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder1.build()).build());
2182         ab1.setKey(new ActionKey(1));
2183         actionList.add(ab1.build());
2184
2185         ApplyActionsBuilder aab = new ApplyActionsBuilder();
2186         aab.setAction(actionList);
2187
2188         InstructionBuilder ib = new InstructionBuilder();
2189         ib.setKey(new InstructionKey(0));
2190         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
2191
2192         // Put our Instruction in a list of Instructions
2193         InstructionsBuilder isb = new InstructionsBuilder();
2194         List<Instruction> instructions = new ArrayList<Instruction>();
2195         instructions.add(ib.build());
2196         isb.setInstruction(instructions);
2197         return isb;
2198     }
2199
2200     private static InstructionsBuilder createAppyActionInstruction39() {
2201
2202         List<Action> actionList = new ArrayList<Action>();
2203         ActionBuilder ab = new ActionBuilder();
2204         ActionBuilder ab1 = new ActionBuilder();
2205
2206         SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
2207         SetFieldBuilder setFieldBuilder1 = new SetFieldBuilder();
2208
2209         // Tcp
2210         PortNumber tcpsrcport = new PortNumber(1213);
2211         PortNumber tcpdstport = new PortNumber(646);
2212         TcpMatchBuilder tcpmatch = new TcpMatchBuilder();
2213         TcpMatchBuilder tcpmatch1 = new TcpMatchBuilder();
2214         tcpmatch.setTcpSourcePort(tcpsrcport);
2215         tcpmatch1.setTcpDestinationPort(tcpdstport);
2216         setFieldBuilder.setLayer4Match(tcpmatch.build());
2217         ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
2218         ab.setKey(new ActionKey(0));
2219         actionList.add(ab.build());
2220
2221         setFieldBuilder1.setLayer4Match(tcpmatch1.build());
2222         ab1.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder1.build()).build());
2223         ab1.setKey(new ActionKey(1));
2224         actionList.add(ab.build());
2225
2226         ApplyActionsBuilder aab = new ApplyActionsBuilder();
2227         aab.setAction(actionList);
2228
2229         InstructionBuilder ib = new InstructionBuilder();
2230         ib.setKey(new InstructionKey(0));
2231         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
2232
2233         // Put our Instruction in a list of Instructions
2234         InstructionsBuilder isb = new InstructionsBuilder();
2235         List<Instruction> instructions = new ArrayList<Instruction>();
2236         instructions.add(ib.build());
2237         isb.setInstruction(instructions);
2238         return isb;
2239     }
2240
2241     private static InstructionsBuilder createAppyActionInstruction40() {
2242
2243         List<Action> actionList = new ArrayList<Action>();
2244         ActionBuilder ab = new ActionBuilder();
2245         ActionBuilder ab1 = new ActionBuilder();
2246
2247         SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
2248         SetFieldBuilder setFieldBuilder1 = new SetFieldBuilder();
2249
2250         // Udp
2251         PortNumber udpsrcport = new PortNumber(1325);
2252         PortNumber udpdstport = new PortNumber(42);
2253         UdpMatchBuilder udpmatch = new UdpMatchBuilder();
2254         UdpMatchBuilder udpmatch1 = new UdpMatchBuilder();
2255         udpmatch.setUdpDestinationPort(udpdstport);
2256         udpmatch1.setUdpSourcePort(udpsrcport);
2257         setFieldBuilder.setLayer4Match(udpmatch.build());
2258         ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
2259         ab.setKey(new ActionKey(0));
2260         actionList.add(ab.build());
2261
2262         setFieldBuilder1.setLayer4Match(udpmatch1.build());
2263         ab1.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder1.build()).build());
2264         ab1.setKey(new ActionKey(1));
2265         actionList.add(ab1.build());
2266
2267         ApplyActionsBuilder aab = new ApplyActionsBuilder();
2268         aab.setAction(actionList);
2269
2270         InstructionBuilder ib = new InstructionBuilder();
2271         ib.setKey(new InstructionKey(0));
2272         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
2273
2274         // Put our Instruction in a list of Instructions
2275         InstructionsBuilder isb = new InstructionsBuilder();
2276         List<Instruction> instructions = new ArrayList<Instruction>();
2277         instructions.add(ib.build());
2278         isb.setInstruction(instructions);
2279         return isb;
2280     }
2281
2282     private static InstructionsBuilder createAppyActionInstruction41() {
2283
2284         List<Action> actionList = new ArrayList<Action>();
2285         ActionBuilder ab = new ActionBuilder();
2286         ActionBuilder ab1 = new ActionBuilder();
2287
2288         SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
2289         SetFieldBuilder setFieldBuilder1 = new SetFieldBuilder();
2290
2291         // Sctp
2292         SctpMatchBuilder sctpmatch = new SctpMatchBuilder();
2293         SctpMatchBuilder sctpmatch1 = new SctpMatchBuilder();
2294         PortNumber srcport = new PortNumber(1435);
2295         PortNumber dstport = new PortNumber(22);
2296         sctpmatch.setSctpSourcePort(srcport);
2297         sctpmatch1.setSctpDestinationPort(dstport);
2298         setFieldBuilder.setLayer4Match(sctpmatch.build());
2299         ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
2300         ab.setKey(new ActionKey(0));
2301         actionList.add(ab.build());
2302
2303         setFieldBuilder1.setLayer4Match(sctpmatch1.build());
2304         ab1.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder1.build()).build());
2305         ab1.setKey(new ActionKey(1));
2306         actionList.add(ab1.build());
2307
2308         ApplyActionsBuilder aab = new ApplyActionsBuilder();
2309         aab.setAction(actionList);
2310
2311         InstructionBuilder ib = new InstructionBuilder();
2312         ib.setKey(new InstructionKey(0));
2313         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
2314
2315         // Put our Instruction in a list of Instructions
2316         InstructionsBuilder isb = new InstructionsBuilder();
2317         List<Instruction> instructions = new ArrayList<Instruction>();
2318         instructions.add(ib.build());
2319         isb.setInstruction(instructions);
2320         return isb;
2321     }
2322
2323     private static InstructionsBuilder createAppyActionInstruction42() {
2324
2325         List<Action> actionList = new ArrayList<Action>();
2326         ActionBuilder ab = new ActionBuilder();
2327         ActionBuilder ab1 = new ActionBuilder();
2328         SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
2329         SetFieldBuilder setFieldBuilder1 = new SetFieldBuilder();
2330
2331         // Icmpv4
2332         Icmpv4MatchBuilder icmpv4match = new Icmpv4MatchBuilder();
2333         Icmpv4MatchBuilder icmpv4match1 = new Icmpv4MatchBuilder();
2334         icmpv4match.setIcmpv4Type((short) 8);
2335         icmpv4match1.setIcmpv4Code((short) 0);
2336         setFieldBuilder.setIcmpv4Match(icmpv4match.build());
2337         ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
2338         ab.setKey(new ActionKey(0));
2339         actionList.add(ab.build());
2340
2341         setFieldBuilder1.setIcmpv4Match(icmpv4match1.build());
2342         ab1.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder1.build()).build());
2343         ab1.setKey(new ActionKey(1));
2344         actionList.add(ab1.build());
2345
2346         ApplyActionsBuilder aab = new ApplyActionsBuilder();
2347         aab.setAction(actionList);
2348
2349         InstructionBuilder ib = new InstructionBuilder();
2350         ib.setKey(new InstructionKey(0));
2351         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
2352
2353         // Put our Instruction in a list of Instructions
2354         InstructionsBuilder isb = new InstructionsBuilder();
2355         List<Instruction> instructions = new ArrayList<Instruction>();
2356         instructions.add(ib.build());
2357         isb.setInstruction(instructions);
2358         return isb;
2359     }
2360
2361     private static InstructionsBuilder createAppyActionInstruction43() {
2362
2363         List<Action> actionList = new ArrayList<Action>();
2364         ActionBuilder ab = new ActionBuilder();
2365         ActionBuilder ab1 = new ActionBuilder();
2366         ActionBuilder ab2 = new ActionBuilder();
2367         ActionBuilder ab3 = new ActionBuilder();
2368         ActionBuilder ab4 = new ActionBuilder();
2369
2370         SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
2371         SetFieldBuilder setFieldBuilder1 = new SetFieldBuilder();
2372         SetFieldBuilder setFieldBuilder2 = new SetFieldBuilder();
2373         SetFieldBuilder setFieldBuilder3 = new SetFieldBuilder();
2374         SetFieldBuilder setFieldBuilder4 = new SetFieldBuilder();
2375
2376         // setting the values of ARP
2377         MacAddress macdest = new MacAddress("ff:ff:ff:ff:ff:ff");
2378         MacAddress macsrc = new MacAddress("00:00:00:00:23:ae");
2379         Ipv4Prefix dstiparp = new Ipv4Prefix("200.71.9.52");
2380         Ipv4Prefix srciparp = new Ipv4Prefix("100.1.1.1");
2381         // create ARP match action
2382         ArpMatchBuilder arpmatch = new ArpMatchBuilder();
2383         ArpMatchBuilder arpmatch1 = new ArpMatchBuilder();
2384         ArpMatchBuilder arpmatch2 = new ArpMatchBuilder();
2385         ArpMatchBuilder arpmatch3 = new ArpMatchBuilder();
2386         ArpMatchBuilder arpmatch4 = new ArpMatchBuilder();
2387         ArpSourceHardwareAddressBuilder arpsrc = new ArpSourceHardwareAddressBuilder();
2388         arpsrc.setAddress(macsrc);
2389         ArpTargetHardwareAddressBuilder arpdst = new ArpTargetHardwareAddressBuilder();
2390         arpdst.setAddress(macdest);
2391         arpmatch.setArpOp(2);
2392         arpmatch1.setArpSourceHardwareAddress(arpsrc.build());
2393         arpmatch2.setArpTargetHardwareAddress(arpdst.build());
2394         arpmatch3.setArpSourceTransportAddress(srciparp);
2395         arpmatch4.setArpTargetTransportAddress(dstiparp);
2396         setFieldBuilder.setLayer3Match(arpmatch.build());
2397         ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
2398         ab.setKey(new ActionKey(0));
2399         actionList.add(ab.build());
2400
2401         setFieldBuilder1.setLayer3Match(arpmatch1.build());
2402         ab1.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder1.build()).build());
2403         ab1.setKey(new ActionKey(1));
2404         actionList.add(ab1.build());
2405
2406         setFieldBuilder2.setLayer3Match(arpmatch2.build());
2407         ab2.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder2.build()).build());
2408         ab2.setKey(new ActionKey(2));
2409         actionList.add(ab2.build());
2410
2411         setFieldBuilder3.setLayer3Match(arpmatch3.build());
2412         ab3.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder3.build()).build());
2413         ab3.setKey(new ActionKey(3));
2414         actionList.add(ab3.build());
2415
2416         setFieldBuilder4.setLayer3Match(arpmatch4.build());
2417         ab4.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder4.build()).build());
2418         ab4.setKey(new ActionKey(4));
2419         actionList.add(ab4.build());
2420
2421         ApplyActionsBuilder aab = new ApplyActionsBuilder();
2422         aab.setAction(actionList);
2423
2424         InstructionBuilder ib = new InstructionBuilder();
2425         ib.setKey(new InstructionKey(0));
2426         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
2427
2428         // Put our Instruction in a list of Instructions
2429         InstructionsBuilder isb = new InstructionsBuilder();
2430         List<Instruction> instructions = new ArrayList<Instruction>();
2431         instructions.add(ib.build());
2432         isb.setInstruction(instructions);
2433         return isb;
2434     }
2435
2436     private static InstructionsBuilder createAppyActionInstruction44() {
2437
2438         List<Action> actionLists = new ArrayList<Action>();
2439         ActionBuilder ab = new ActionBuilder();
2440         SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
2441         ActionBuilder ab1 = new ActionBuilder();
2442         SetFieldBuilder setFieldBuilder1 = new SetFieldBuilder();
2443         /*
2444          * ActionBuilder ab2 = new ActionBuilder(); SetFieldBuilder
2445          * setFieldBuilder2 = new SetFieldBuilder(); ActionBuilder ab3 = new
2446          * ActionBuilder(); SetFieldBuilder setFieldBuilder3 = new
2447          * SetFieldBuilder(); ActionBuilder ab4 = new ActionBuilder();
2448          * SetFieldBuilder setFieldBuilder4 = new SetFieldBuilder();
2449          */
2450         ActionBuilder ab5 = new ActionBuilder();
2451         SetFieldBuilder setFieldBuilder5 = new SetFieldBuilder();
2452         ActionBuilder ab6 = new ActionBuilder();
2453         SetFieldBuilder setFieldBuilder6 = new SetFieldBuilder();
2454
2455         // IPv6
2456         Ipv6MatchBuilder ipv6Builder = new Ipv6MatchBuilder();
2457         Ipv6MatchBuilder ipv6Builder1 = new Ipv6MatchBuilder();
2458         // Ipv6MatchBuilder ipv6Builder2 = new Ipv6MatchBuilder();
2459         // Ipv6MatchBuilder ipv6Builder3 = new Ipv6MatchBuilder();
2460         // Ipv6MatchBuilder ipv6Builder4 = new Ipv6MatchBuilder();
2461         Ipv6MatchBuilder ipv6Builder5 = new Ipv6MatchBuilder();
2462         Ipv6MatchBuilder ipv6Builder6 = new Ipv6MatchBuilder();
2463
2464         Ipv6Prefix dstip6 = new Ipv6Prefix("2002::2");
2465         Ipv6Prefix srcip6 = new Ipv6Prefix("2001:0:0:0:0:0:0:1");
2466         // Ipv6Address ndtarget = new
2467         // Ipv6Address("2001:db8:0:1:fd97:f9f0:a810:782e");
2468         // MacAddress ndsll = new MacAddress("c2:00:54:f5:00:00");
2469         // MacAddress ndtll = new MacAddress("00:0c:29:0e:4c:67");
2470         Ipv6ExtHeaderBuilder nextheader = new Ipv6ExtHeaderBuilder();
2471         nextheader.setIpv6Exthdr(58);
2472         Ipv6LabelBuilder ipv6label = new Ipv6LabelBuilder();
2473         Ipv6FlowLabel label = new Ipv6FlowLabel(10028L);
2474         ipv6label.setIpv6Flabel(label);
2475
2476         ipv6Builder.setIpv6Source(srcip6);
2477         ipv6Builder1.setIpv6Destination(dstip6);
2478         // ipv6Builder2.setIpv6NdTarget(ndtarget);
2479         // ipv6Builder3.setIpv6NdSll(ndsll);
2480         // ipv6Builder4.setIpv6NdTll(ndtll);
2481         ipv6Builder5.setIpv6ExtHeader(nextheader.build());
2482         ipv6Builder6.setIpv6Label(ipv6label.build());
2483
2484         setFieldBuilder.setLayer3Match(ipv6Builder.build());
2485         ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
2486         ab.setKey(new ActionKey(0));
2487         actionLists.add(ab.build());
2488
2489         setFieldBuilder1.setLayer3Match(ipv6Builder1.build());
2490         ab1.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder1.build()).build());
2491         ab1.setKey(new ActionKey(1));
2492         actionLists.add(ab1.build());
2493
2494         /*
2495          * setFieldBuilder2.setLayer3Match(ipv6Builder2.build());
2496          * ab2.setAction(new
2497          * SetFieldCaseBuilder().setSetField(setFieldBuilder2.build()).build());
2498          * ab2.setKey(new ActionKey(2)); actionLists.add(ab2.build());
2499          *
2500          * setFieldBuilder3.setLayer3Match(ipv6Builder3.build());
2501          * ab3.setAction(new
2502          * SetFieldCaseBuilder().setSetField(setFieldBuilder3.build()).build());
2503          * ab3.setKey(new ActionKey(3)); actionLists.add(ab3.build());
2504          *
2505          * setFieldBuilder4.setLayer3Match(ipv6Builder4.build());
2506          * ab4.setAction(new
2507          * SetFieldCaseBuilder().setSetField(setFieldBuilder4.build()).build());
2508          * ab4.setKey(new ActionKey(4)); actionLists.add(ab4.build());
2509          */
2510         setFieldBuilder5.setLayer3Match(ipv6Builder5.build());
2511         ab5.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder5.build()).build());
2512         ab5.setKey(new ActionKey(5));
2513         actionLists.add(ab5.build());
2514
2515         setFieldBuilder6.setLayer3Match(ipv6Builder6.build());
2516         ab6.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder6.build()).build());
2517         ab6.setKey(new ActionKey(6));
2518         actionLists.add(ab6.build());
2519
2520         ApplyActionsBuilder aab = new ApplyActionsBuilder();
2521         aab.setAction(actionLists);
2522
2523         InstructionBuilder ib = new InstructionBuilder();
2524         ib.setKey(new InstructionKey(0));
2525         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
2526
2527         // Put our Instruction in a list of Instructions
2528         InstructionsBuilder isb = new InstructionsBuilder();
2529         List<Instruction> instructions = new ArrayList<Instruction>();
2530         instructions.add(ib.build());
2531         isb.setInstruction(instructions);
2532         return isb;
2533     }
2534
2535     private static InstructionsBuilder createAppyActionInstruction45() {
2536
2537         List<Action> actionList = new ArrayList<Action>();
2538         ActionBuilder ab = new ActionBuilder();
2539         SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
2540         ActionBuilder ab1 = new ActionBuilder();
2541         SetFieldBuilder setFieldBuilder1 = new SetFieldBuilder();
2542
2543         // Icmpv6
2544         Icmpv6MatchBuilder icmpv6match = new Icmpv6MatchBuilder();
2545         Icmpv6MatchBuilder icmpv6match1 = new Icmpv6MatchBuilder();
2546         icmpv6match.setIcmpv6Type((short) 135);
2547         icmpv6match1.setIcmpv6Code((short) 0);
2548         setFieldBuilder.setIcmpv6Match(icmpv6match.build());
2549         ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
2550         ab.setKey(new ActionKey(0));
2551         actionList.add(ab.build());
2552
2553         setFieldBuilder1.setIcmpv6Match(icmpv6match1.build());
2554         ab1.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder1.build()).build());
2555         ab1.setKey(new ActionKey(1));
2556         actionList.add(ab1.build());
2557
2558         ApplyActionsBuilder aab = new ApplyActionsBuilder();
2559         aab.setAction(actionList);
2560
2561         InstructionBuilder ib = new InstructionBuilder();
2562         ib.setKey(new InstructionKey(0));
2563         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
2564
2565         // Put our Instruction in a list of Instructions
2566         InstructionsBuilder isb = new InstructionsBuilder();
2567         List<Instruction> instructions = new ArrayList<Instruction>();
2568         instructions.add(ib.build());
2569         isb.setInstruction(instructions);
2570         return isb;
2571     }
2572
2573     private static InstructionsBuilder createAppyActionInstruction46() {
2574
2575         List<Action> actionList = new ArrayList<Action>();
2576         ActionBuilder ab = new ActionBuilder();
2577         SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
2578         ActionBuilder ab1 = new ActionBuilder();
2579         SetFieldBuilder setFieldBuilder1 = new SetFieldBuilder();
2580         ActionBuilder ab2 = new ActionBuilder();
2581         SetFieldBuilder setFieldBuilder2 = new SetFieldBuilder();
2582
2583         // MPLS
2584         ProtocolMatchFieldsBuilder protomatch = new ProtocolMatchFieldsBuilder();
2585         ProtocolMatchFieldsBuilder protomatch1 = new ProtocolMatchFieldsBuilder();
2586         ProtocolMatchFieldsBuilder protomatch2 = new ProtocolMatchFieldsBuilder();
2587         protomatch.setMplsLabel((long) 36008);
2588         protomatch1.setMplsTc((short) 4);
2589         protomatch2.setMplsBos((short) 1);
2590         setFieldBuilder.setProtocolMatchFields(protomatch.build());
2591         ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
2592         ab.setKey(new ActionKey(0));
2593         actionList.add(ab.build());
2594
2595         setFieldBuilder1.setProtocolMatchFields(protomatch1.build());
2596         ab1.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder1.build()).build());
2597         ab1.setKey(new ActionKey(1));
2598         actionList.add(ab1.build());
2599
2600         setFieldBuilder2.setProtocolMatchFields(protomatch2.build());
2601         ab2.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder2.build()).build());
2602         ab2.setKey(new ActionKey(2));
2603         actionList.add(ab2.build());
2604
2605         ApplyActionsBuilder aab = new ApplyActionsBuilder();
2606         aab.setAction(actionList);
2607
2608         InstructionBuilder ib = new InstructionBuilder();
2609         ib.setKey(new InstructionKey(0));
2610         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
2611
2612         // Put our Instruction in a list of Instructions
2613         InstructionsBuilder isb = new InstructionsBuilder();
2614         List<Instruction> instructions = new ArrayList<Instruction>();
2615         instructions.add(ib.build());
2616         isb.setInstruction(instructions);
2617         return isb;
2618     }
2619
2620     private static InstructionsBuilder createAppyActionInstruction47() {
2621
2622         List<Action> actionList = new ArrayList<Action>();
2623         ActionBuilder ab = new ActionBuilder();
2624         SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
2625         // PBB
2626         ProtocolMatchFieldsBuilder protomatch = new ProtocolMatchFieldsBuilder();
2627         protomatch.setPbb(new PbbBuilder().setPbbIsid(4L).setPbbMask((new BigInteger(new byte[] { 0, 1, 0, 0 }).longValue())).build());
2628         setFieldBuilder.setProtocolMatchFields(protomatch.build());
2629         ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
2630         actionList.add(ab.build());
2631
2632         ApplyActionsBuilder aab = new ApplyActionsBuilder();
2633         aab.setAction(actionList);
2634
2635         InstructionBuilder ib = new InstructionBuilder();
2636         ib.setKey(new InstructionKey(0));
2637         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
2638
2639         // Put our Instruction in a list of Instructions
2640         InstructionsBuilder isb = new InstructionsBuilder();
2641         List<Instruction> instructions = new ArrayList<Instruction>();
2642         instructions.add(ib.build());
2643         isb.setInstruction(instructions);
2644         return isb;
2645     }
2646
2647     private static InstructionsBuilder createAppyActionInstruction48() {
2648
2649         List<Action> actionList = new ArrayList<Action>();
2650         ActionBuilder ab = new ActionBuilder();
2651         SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
2652         // Tunnel
2653         TunnelBuilder tunnel = new TunnelBuilder();
2654         tunnel.setTunnelId(BigInteger.valueOf(10668));
2655         setFieldBuilder.setTunnel(tunnel.build());
2656         ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
2657         ab.setKey(new ActionKey(0));
2658         actionList.add(ab.build());
2659
2660         ApplyActionsBuilder aab = new ApplyActionsBuilder();
2661         aab.setAction(actionList);
2662
2663         InstructionBuilder ib = new InstructionBuilder();
2664         ib.setKey(new InstructionKey(0));
2665         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
2666
2667         // Put our Instruction in a list of Instructions
2668         InstructionsBuilder isb = new InstructionsBuilder();
2669         List<Instruction> instructions = new ArrayList<Instruction>();
2670         instructions.add(ib.build());
2671         isb.setInstruction(instructions);
2672         return isb;
2673     }
2674
2675     private static MatchBuilder createLLDPMatch() {
2676         MatchBuilder match = new MatchBuilder();
2677         EthernetMatchBuilder eth = new EthernetMatchBuilder();
2678         EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
2679         ethTypeBuilder.setType(new EtherType(0x88ccL));
2680         eth.setEthernetType(ethTypeBuilder.build());
2681         match.setEthernetMatch(eth.build());
2682         return match;
2683     }
2684
2685     /**
2686      * @return
2687      */
2688     private static MatchBuilder createMatch1() {
2689         MatchBuilder match = new MatchBuilder();
2690         Ipv4MatchBuilder ipv4Match = new Ipv4MatchBuilder();
2691         Ipv4Prefix prefix = new Ipv4Prefix("10.0.0.1/24");
2692         ipv4Match.setIpv4Destination(prefix);
2693         Ipv4Match i4m = ipv4Match.build();
2694         match.setLayer3Match(i4m);
2695
2696         EthernetMatchBuilder eth = new EthernetMatchBuilder();
2697         EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
2698         ethTypeBuilder.setType(new EtherType(0x0800L));
2699         eth.setEthernetType(ethTypeBuilder.build());
2700         match.setEthernetMatch(eth.build());
2701         return match;
2702     }
2703
2704     /**
2705      * @return
2706      */
2707     private static MatchBuilder createIPv4DstMatch() {
2708         MatchBuilder match = new MatchBuilder();
2709         Ipv4MatchBuilder ipv4Match = new Ipv4MatchBuilder();
2710         Ipv4Prefix prefix = new Ipv4Prefix("10.0.0.1/24");
2711         ipv4Match.setIpv4Destination(prefix);
2712         Ipv4Match i4m = ipv4Match.build();
2713         match.setLayer3Match(i4m);
2714
2715         return match;
2716     }
2717
2718     /**
2719      * @return
2720      */
2721     private static MatchBuilder createIPv4SrcMatch() {
2722         MatchBuilder match = new MatchBuilder();
2723         Ipv4MatchBuilder ipv4Match = new Ipv4MatchBuilder();
2724         Ipv4Prefix prefix = new Ipv4Prefix("10.20.30.40/24");
2725         ipv4Match.setIpv4Source(prefix);
2726         Ipv4Match i4m = ipv4Match.build();
2727         match.setLayer3Match(i4m);
2728
2729         EthernetMatchBuilder eth = new EthernetMatchBuilder();
2730         EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
2731         ethTypeBuilder.setType(new EtherType(0x0800L));
2732         eth.setEthernetType(ethTypeBuilder.build());
2733         match.setEthernetMatch(eth.build());
2734         return match;
2735     }
2736
2737     /**
2738      * @return
2739      */
2740     private static MatchBuilder createMatch2() {
2741         MatchBuilder match = new MatchBuilder();
2742         Ipv4MatchBuilder ipv4Match = new Ipv4MatchBuilder();
2743         Ipv4Prefix prefix = new Ipv4Prefix("10.0.0.1");
2744         ipv4Match.setIpv4Source(prefix);
2745         Ipv4Match i4m = ipv4Match.build();
2746         match.setLayer3Match(i4m);
2747
2748         EthernetMatchBuilder eth = new EthernetMatchBuilder();
2749         EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
2750         ethTypeBuilder.setType(new EtherType(0x0800L));
2751         eth.setEthernetType(ethTypeBuilder.build());
2752         match.setEthernetMatch(eth.build());
2753         return match;
2754     }
2755
2756     /**
2757      * @return
2758      */
2759     private static MatchBuilder createMatch3() {
2760         MatchBuilder match = new MatchBuilder();
2761         EthernetMatchBuilder ethernetMatch = new EthernetMatchBuilder();
2762         EthernetSourceBuilder ethSourceBuilder = new EthernetSourceBuilder();
2763         ethSourceBuilder.setAddress(new MacAddress("00:00:00:00:00:01"));
2764         ethernetMatch.setEthernetSource(ethSourceBuilder.build());
2765         match.setEthernetMatch(ethernetMatch.build());
2766
2767         return match;
2768     }
2769
2770     /**
2771      * @return
2772      */
2773     private static MatchBuilder createICMPv6Match1() {
2774
2775         MatchBuilder match = new MatchBuilder();
2776         EthernetMatchBuilder eth = new EthernetMatchBuilder();
2777         EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
2778         ethTypeBuilder.setType(new EtherType(0x86ddL));
2779         eth.setEthernetType(ethTypeBuilder.build());
2780         match.setEthernetMatch(eth.build());
2781
2782         IpMatchBuilder ipmatch = new IpMatchBuilder(); // ipv4 version
2783         ipmatch.setIpProtocol((short) 256);
2784         match.setIpMatch(ipmatch.build());
2785
2786         Icmpv6MatchBuilder icmpv6match = new Icmpv6MatchBuilder(); // icmpv6
2787                                                                    // match
2788         icmpv6match.setIcmpv6Type((short) 135);
2789         icmpv6match.setIcmpv6Code((short) 1);
2790         match.setIcmpv6Match(icmpv6match.build());
2791
2792         return match;
2793     }
2794
2795     private static MatchBuilder createMatch33() {
2796
2797         MatchBuilder match = new MatchBuilder();
2798         Ipv4MatchBuilder ipv4Match = new Ipv4MatchBuilder();
2799         Ipv4Prefix prefix = new Ipv4Prefix("10.0.0.10");
2800         ipv4Match.setIpv4Source(prefix);
2801         Ipv4Match i4m = ipv4Match.build();
2802         match.setLayer3Match(i4m);
2803
2804         EthernetMatchBuilder eth = new EthernetMatchBuilder();
2805         EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
2806         ethTypeBuilder.setType(new EtherType(0xfffeL));
2807         eth.setEthernetType(ethTypeBuilder.build());
2808         match.setEthernetMatch(eth.build());
2809         return match;
2810     }
2811
2812     private static MatchBuilder createInphyportMatch(NodeId nodeId) {
2813         MatchBuilder match = new MatchBuilder();
2814         match.setInPort(new NodeConnectorId(nodeId + ":202"));
2815         match.setInPhyPort(new NodeConnectorId(nodeId + ":10122"));
2816         return match;
2817     }
2818
2819     private static MatchBuilder createEthernetMatch() {
2820         MatchBuilder match = new MatchBuilder();
2821
2822         byte[] mask1 = new byte[] { (byte) -1, (byte) -1, 0, 0, 0, 0 };
2823         byte[] mask2 = new byte[] { (byte) -1, (byte) -1, (byte) -1, 0, 0, 0 };
2824
2825         EthernetMatchBuilder ethmatch = new EthernetMatchBuilder(); // ethernettype
2826                                                                     // match
2827         EthernetTypeBuilder ethtype = new EthernetTypeBuilder();
2828         EtherType type = new EtherType(0x0800L);
2829         ethmatch.setEthernetType(ethtype.setType(type).build());
2830
2831         EthernetDestinationBuilder ethdest = new EthernetDestinationBuilder(); // ethernet
2832                                                                                // macaddress
2833                                                                                // match
2834         MacAddress macdest = new MacAddress("ff:ff:ff:ff:ff:ff");
2835         ethdest.setAddress(macdest);
2836         ethdest.setMask(new MacAddress("ff:ff:ff:00:00:00"));
2837
2838         ethmatch.setEthernetDestination(ethdest.build());
2839
2840         EthernetSourceBuilder ethsrc = new EthernetSourceBuilder();
2841         MacAddress macsrc = new MacAddress("00:00:00:00:23:ae");
2842         ethsrc.setAddress(macsrc);
2843         ethsrc.setMask(new MacAddress("ff:ff:00:00:00:00"));
2844
2845         ethmatch.setEthernetSource(ethsrc.build());
2846         match.setEthernetMatch(ethmatch.build());
2847         return match;
2848
2849     }
2850
2851     /**
2852      * @return
2853      */
2854
2855     private static MatchBuilder createVlanMatch() {
2856         MatchBuilder match = new MatchBuilder();
2857         VlanMatchBuilder vlanBuilder = new VlanMatchBuilder(); // vlan match
2858         VlanIdBuilder vlanIdBuilder = new VlanIdBuilder();
2859         VlanId vlanId = new VlanId(10);
2860         VlanPcp vpcp = new VlanPcp((short) 3);
2861         vlanBuilder.setVlanPcp(vpcp);
2862         vlanIdBuilder.setVlanId(vlanId);
2863         vlanIdBuilder.setVlanIdPresent(true);
2864         vlanBuilder.setVlanId(vlanIdBuilder.build());
2865         match.setVlanMatch(vlanBuilder.build());
2866         return match;
2867     }
2868
2869     /**
2870      * @return
2871      */
2872     private static MatchBuilder createArpMatch() {
2873         MatchBuilder match = new MatchBuilder();
2874
2875         EthernetMatchBuilder ethmatch = new EthernetMatchBuilder();
2876         MacAddress macdest = new MacAddress("ff:ff:ff:ff:ff:ff");
2877         MacAddress macsrc = new MacAddress("00:00:00:00:23:ae");
2878
2879         byte[] mask = new byte[] { (byte) -1, (byte) -1, 0, 0, 0, 0 };
2880         byte[] mask2 = new byte[] { (byte) -1, (byte) -1, (byte) -1, 0, 0, 0 };
2881
2882         EthernetTypeBuilder ethtype = new EthernetTypeBuilder();
2883         EtherType type = new EtherType(0x0806L);
2884         ethmatch.setEthernetType(ethtype.setType(type).build());
2885
2886         Ipv4Prefix dstip = new Ipv4Prefix("200.71.9.52/10"); // ipv4 match
2887         Ipv4Prefix srcip = new Ipv4Prefix("100.1.1.1/8");
2888
2889         ArpMatchBuilder arpmatch = new ArpMatchBuilder(); // arp match
2890         ArpSourceHardwareAddressBuilder arpsrc = new ArpSourceHardwareAddressBuilder();
2891         arpsrc.setAddress(macsrc);
2892         arpsrc.setMask(new MacAddress("ff:ff:ff:00:00:00"));
2893         ArpTargetHardwareAddressBuilder arpdst = new ArpTargetHardwareAddressBuilder();
2894         arpdst.setAddress(macdest);
2895         arpdst.setMask(new MacAddress("ff:ff:00:00:00:00"));
2896         arpmatch.setArpOp(2);
2897         arpmatch.setArpSourceHardwareAddress(arpsrc.build());
2898         arpmatch.setArpTargetHardwareAddress(arpdst.build());
2899         arpmatch.setArpSourceTransportAddress(srcip);
2900         arpmatch.setArpTargetTransportAddress(dstip);
2901
2902         match.setEthernetMatch(ethmatch.build());
2903         match.setLayer3Match(arpmatch.build());
2904
2905         return match;
2906     }
2907
2908     /**
2909      * @return
2910      */
2911     private static MatchBuilder createIPMatch() {
2912         MatchBuilder match = new MatchBuilder();
2913         EthernetMatchBuilder ethmatch = new EthernetMatchBuilder();
2914         EthernetTypeBuilder ethtype = new EthernetTypeBuilder();
2915         EtherType type = new EtherType(0x0800L);
2916         ethmatch.setEthernetType(ethtype.setType(type).build());
2917         match.setEthernetMatch(ethmatch.build());
2918
2919         IpMatchBuilder ipmatch = new IpMatchBuilder(); // ipv4 version
2920         ipmatch.setIpProtocol((short) 1);
2921         Dscp dscp = new Dscp((short) 3);
2922         ipmatch.setIpDscp(dscp);
2923         ipmatch.setIpEcn((short) 2);
2924         match.setIpMatch(ipmatch.build());
2925         return match;
2926     }
2927
2928     /**
2929      * @return
2930      */
2931     private static MatchBuilder createL3IPv4Match() {
2932         MatchBuilder match = new MatchBuilder();
2933
2934         EthernetMatchBuilder eth = new EthernetMatchBuilder();
2935         EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
2936         ethTypeBuilder.setType(new EtherType(0x0800L));
2937         eth.setEthernetType(ethTypeBuilder.build());
2938         match.setEthernetMatch(eth.build());
2939
2940         Ipv4MatchBuilder ipv4Match = new Ipv4MatchBuilder();
2941         Ipv4Prefix dstip = new Ipv4Prefix("200.71.9.52/10"); // ipv4 match
2942         Ipv4Prefix srcip = new Ipv4Prefix("100.1.1.1/8");
2943         Ipv4MatchBuilder ipv4match = new Ipv4MatchBuilder();
2944         ipv4match.setIpv4Destination(dstip);
2945         ipv4match.setIpv4Source(srcip);
2946         match.setLayer3Match(ipv4match.build());
2947
2948         return match;
2949
2950     }
2951
2952     /**
2953      * @return
2954      */
2955     private static MatchBuilder createL3IPv6Match() {
2956         MatchBuilder match = new MatchBuilder();
2957
2958         EthernetMatchBuilder eth = new EthernetMatchBuilder();
2959         EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
2960         ethTypeBuilder.setType(new EtherType(0x86ddL));
2961         eth.setEthernetType(ethTypeBuilder.build());
2962         match.setEthernetMatch(eth.build());
2963
2964         Ipv6Prefix dstip6 = new Ipv6Prefix("2002::2/64");
2965         Ipv6Prefix srcip6 = new Ipv6Prefix("2001:0:0:0:0:0:0:1/56");
2966         Ipv6Address ndtarget = new Ipv6Address("2001:db8:0:1:fd97:f9f0:a810:782e");
2967         MacAddress ndsll = new MacAddress("c2:00:54:f5:00:00");
2968         MacAddress ndtll = new MacAddress("00:0c:29:0e:4c:67");
2969         Ipv6ExtHeaderBuilder nextheader = new Ipv6ExtHeaderBuilder();
2970         nextheader.setIpv6Exthdr(58);
2971         Ipv6LabelBuilder ipv6label = new Ipv6LabelBuilder();
2972         Ipv6FlowLabel label = new Ipv6FlowLabel(10028L);
2973         ipv6label.setIpv6Flabel(label);
2974         ipv6label.setFlabelMask(new Ipv6FlowLabel(1L));
2975
2976         Icmpv6MatchBuilder icmpv6match = new Icmpv6MatchBuilder(); // icmpv6
2977                                                                    // match
2978         icmpv6match.setIcmpv6Type((short) 135);
2979         icmpv6match.setIcmpv6Code((short) 0);
2980         match.setIcmpv6Match(icmpv6match.build());
2981
2982         Ipv6MatchBuilder ipv6match = new Ipv6MatchBuilder();
2983         // ipv6match.setIpv6Source(srcip6);
2984         // ipv6match.setIpv6Destination(dstip6);
2985         // ipv6match.setIpv6ExtHeader(nextheader.build());
2986         ipv6match.setIpv6NdSll(ndsll);
2987         ipv6match.setIpv6NdTll(ndtll);
2988         // ipv6match.setIpv6NdTarget(ndtarget);
2989         ipv6match.setIpv6Label(ipv6label.build());
2990
2991         match.setLayer3Match(ipv6match.build());
2992
2993         return match;
2994     }
2995
2996     /**
2997      * @return
2998      */
2999
3000     private static MatchBuilder createICMPv4Match() {
3001         MatchBuilder match = new MatchBuilder();
3002         EthernetMatchBuilder eth = new EthernetMatchBuilder();
3003         EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
3004         ethTypeBuilder.setType(new EtherType(0x0800L));
3005         eth.setEthernetType(ethTypeBuilder.build());
3006         match.setEthernetMatch(eth.build());
3007
3008         IpMatchBuilder ipmatch = new IpMatchBuilder(); // ipv4 version
3009         ipmatch.setIpProtocol((short) 1);
3010         match.setIpMatch(ipmatch.build());
3011
3012         Icmpv4MatchBuilder icmpv4match = new Icmpv4MatchBuilder(); // icmpv4
3013                                                                    // match
3014         icmpv4match.setIcmpv4Type((short) 8);
3015         icmpv4match.setIcmpv4Code((short) 0);
3016         match.setIcmpv4Match(icmpv4match.build());
3017         return match;
3018     }
3019
3020     /**
3021      * @return
3022      */
3023     private static MatchBuilder createICMPv6Match() {
3024
3025         MatchBuilder match = new MatchBuilder();
3026         EthernetMatchBuilder eth = new EthernetMatchBuilder();
3027         EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
3028         ethTypeBuilder.setType(new EtherType(0x86ddL));
3029         eth.setEthernetType(ethTypeBuilder.build());
3030         match.setEthernetMatch(eth.build());
3031
3032         IpMatchBuilder ipmatch = new IpMatchBuilder(); // ipv4 version
3033         ipmatch.setIpProtocol((short) 58);
3034         match.setIpMatch(ipmatch.build());
3035
3036         Icmpv6MatchBuilder icmpv6match = new Icmpv6MatchBuilder(); // icmpv6
3037                                                                    // match
3038         icmpv6match.setIcmpv6Type((short) 135);
3039         icmpv6match.setIcmpv6Code((short) 1);
3040         match.setIcmpv6Match(icmpv6match.build());
3041
3042         return match;
3043     }
3044
3045     /**
3046      * @return
3047      */
3048     private static MatchBuilder createToSMatch() {
3049         MatchBuilder match = new MatchBuilder();
3050         EthernetMatchBuilder ethmatch = new EthernetMatchBuilder();
3051         EthernetTypeBuilder ethtype = new EthernetTypeBuilder();
3052         EtherType type = new EtherType(0x0800L);
3053         ethmatch.setEthernetType(ethtype.setType(type).build());
3054         match.setEthernetMatch(ethmatch.build());
3055
3056         IpMatchBuilder ipmatch = new IpMatchBuilder(); // ipv4 version
3057         ipmatch.setIpProtocol((short) 6);
3058         Dscp dscp = new Dscp((short) 8);
3059         ipmatch.setIpDscp(dscp);
3060         match.setIpMatch(ipmatch.build());
3061         return match;
3062     }
3063
3064     /**
3065      * @return
3066      */
3067
3068     private static MatchBuilder createL4TCPMatch() {
3069         MatchBuilder match = new MatchBuilder();
3070
3071         EthernetMatchBuilder eth = new EthernetMatchBuilder();
3072         EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
3073         ethTypeBuilder.setType(new EtherType(0x0800L));
3074         eth.setEthernetType(ethTypeBuilder.build());
3075         match.setEthernetMatch(eth.build());
3076
3077         IpMatchBuilder ipmatch = new IpMatchBuilder(); // ipv4 version
3078         ipmatch.setIpProtocol((short) 6);
3079         match.setIpMatch(ipmatch.build());
3080
3081         PortNumber srcport = new PortNumber(1213);
3082         PortNumber dstport = new PortNumber(646);
3083         TcpMatchBuilder tcpmatch = new TcpMatchBuilder(); // tcp match
3084         tcpmatch.setTcpSourcePort(srcport);
3085         tcpmatch.setTcpDestinationPort(dstport);
3086         match.setLayer4Match(tcpmatch.build());
3087
3088         return match;
3089     }
3090
3091     /**
3092      * @return
3093      */
3094     private static MatchBuilder createL4UDPMatch() {
3095         MatchBuilder match = new MatchBuilder();
3096
3097         EthernetMatchBuilder eth = new EthernetMatchBuilder();
3098         EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
3099         ethTypeBuilder.setType(new EtherType(0x0800L));
3100         eth.setEthernetType(ethTypeBuilder.build());
3101         match.setEthernetMatch(eth.build());
3102
3103         IpMatchBuilder ipmatch = new IpMatchBuilder(); // ipv4 version
3104         ipmatch.setIpProtocol((short) 17);
3105         match.setIpMatch(ipmatch.build());
3106
3107         PortNumber srcport = new PortNumber(1325);
3108         PortNumber dstport = new PortNumber(42);
3109         UdpMatchBuilder udpmatch = new UdpMatchBuilder(); // udp match
3110         udpmatch.setUdpDestinationPort(dstport);
3111         udpmatch.setUdpSourcePort(srcport);
3112         match.setLayer4Match(udpmatch.build());
3113
3114         return match;
3115     }
3116
3117     /**
3118      * @return
3119      */
3120     private static MatchBuilder createL4SCTPMatch() {
3121         MatchBuilder match = new MatchBuilder();
3122
3123         EthernetMatchBuilder eth = new EthernetMatchBuilder();
3124         EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
3125         ethTypeBuilder.setType(new EtherType(0x0800L));
3126         eth.setEthernetType(ethTypeBuilder.build());
3127         match.setEthernetMatch(eth.build());
3128
3129         IpMatchBuilder ipmatch = new IpMatchBuilder(); // ipv4 version
3130         ipmatch.setIpProtocol((short) 132);
3131         match.setIpMatch(ipmatch.build());
3132
3133         SctpMatchBuilder sctpmatch = new SctpMatchBuilder();
3134         PortNumber srcport = new PortNumber(1435);
3135         PortNumber dstport = new PortNumber(22);
3136         sctpmatch.setSctpSourcePort(srcport);
3137         sctpmatch.setSctpDestinationPort(dstport);
3138         match.setLayer4Match(sctpmatch.build());
3139
3140         return match;
3141     }
3142
3143     /**
3144      * @return
3145      */
3146     private static MatchBuilder createMetadataMatch() {
3147         MatchBuilder match = new MatchBuilder();
3148         byte[] metamask = new byte[] { (byte) -1, (byte) -1, (byte) -1, 0, 0, 0, (byte) 1, (byte) 1 };
3149         MetadataBuilder metadata = new MetadataBuilder(); // metadata match
3150         metadata.setMetadata(BigInteger.valueOf(500L));
3151         metadata.setMetadataMask(new BigInteger(metamask));
3152         match.setMetadata(metadata.build());
3153
3154         return match;
3155     }
3156
3157     /**
3158      * @return
3159      */
3160     private static MatchBuilder createMplsMatch() {
3161         MatchBuilder match = new MatchBuilder();
3162
3163         EthernetMatchBuilder eth = new EthernetMatchBuilder();
3164         EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
3165         ethTypeBuilder.setType(new EtherType(0x8847L));
3166         eth.setEthernetType(ethTypeBuilder.build());
3167         match.setEthernetMatch(eth.build());
3168
3169         ProtocolMatchFieldsBuilder protomatch = new ProtocolMatchFieldsBuilder(); // mpls
3170         // match
3171         protomatch.setMplsLabel((long) 36008);
3172         protomatch.setMplsTc((short) 4);
3173         protomatch.setMplsBos((short) 1);
3174         match.setProtocolMatchFields(protomatch.build());
3175
3176         return match;
3177
3178     }
3179
3180     /**
3181      * @return
3182      */
3183     private static MatchBuilder createPbbMatch() {
3184         MatchBuilder match = new MatchBuilder();
3185
3186         EthernetMatchBuilder eth = new EthernetMatchBuilder();
3187         EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
3188         ethTypeBuilder.setType(new EtherType(0x88E7L));
3189         eth.setEthernetType(ethTypeBuilder.build());
3190         match.setEthernetMatch(eth.build());
3191
3192         ProtocolMatchFieldsBuilder protomatch = new ProtocolMatchFieldsBuilder(); // mpls
3193         // match
3194         protomatch.setPbb(new PbbBuilder().setPbbIsid(4L).setPbbMask(new BigInteger(new byte[] { 0, 1, 0, 0 }).longValue()).build());
3195         match.setProtocolMatchFields(protomatch.build());
3196
3197         return match;
3198
3199     }
3200
3201     /**
3202      * @return
3203      */
3204     private static MatchBuilder createTunnelIDMatch() {
3205         MatchBuilder match = new MatchBuilder();
3206         TunnelBuilder tunnel = new TunnelBuilder(); // tunnel id match
3207         tunnel.setTunnelId(BigInteger.valueOf(10668));
3208         byte[] mask = new byte[] {(byte) -1, (byte) -1, (byte) -1, 0, 0, 0, (byte) 1, (byte) 1 };
3209         tunnel.setTunnelMask(new BigInteger(1, mask));
3210         match.setTunnel(tunnel.build());
3211
3212         return match;
3213     }
3214
3215     /**
3216      * Test match for TCP_Flags
3217      * @return match containing Ethertype (0x0800), IP Protocol (TCP), TCP_Flag (SYN)
3218      */
3219     //FIXME: move to extensible support
3220     private static MatchBuilder createTcpFlagMatch() {
3221         MatchBuilder match = new MatchBuilder();
3222
3223         // Ethertype match
3224         EthernetMatchBuilder ethernetType = new EthernetMatchBuilder();
3225         EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
3226         ethTypeBuilder.setType(new EtherType(0x0800L));
3227         ethernetType.setEthernetType(ethTypeBuilder.build());
3228         match.setEthernetMatch(ethernetType.build());
3229
3230         // TCP Protocol Match
3231         IpMatchBuilder ipMatch = new IpMatchBuilder(); // ipv4 version
3232         ipMatch.setIpProtocol((short) 6);
3233         match.setIpMatch(ipMatch.build());
3234
3235         // TCP Port Match
3236         PortNumber dstPort = new PortNumber(80);
3237         TcpMatchBuilder tcpMatch = new TcpMatchBuilder();
3238         tcpMatch.setTcpDestinationPort(dstPort);
3239         match.setLayer4Match(tcpMatch.build());
3240         /**
3241         * Defined TCP Flag values in OVS v2.1+
3242         * TCP_FIN 0x001 / TCP_SYN 0x002 / TCP_RST 0x004
3243         * TCP_PSH 0x008 / TCP_ACK 0x010 / TCP_URG 0x020
3244         * TCP_ECE 0x040 / TCP_CWR 0x080 / TCP_NS  0x100
3245         */
3246         TcpFlagMatchBuilder tcpFlagMatch = new TcpFlagMatchBuilder();
3247         tcpFlagMatch.setTcpFlag(0x002);
3248         match.setTcpFlagMatch(tcpFlagMatch.build());
3249
3250         return match;
3251     }
3252
3253     public void _removeMDFlow(CommandInterpreter ci) {
3254         DataModification<InstanceIdentifier<?>, DataObject> modification = dataBrokerService.beginTransaction();
3255         NodeBuilder tn = createTestNode(ci.nextArgument());
3256         String flowtype = ci.nextArgument();
3257         FlowBuilder tf;
3258         if (flowtype.equals("fTM")) {
3259             tf = createtablemiss(tn, flowtype, ci.nextArgument());
3260         } else {
3261             tf = createTestFlow(tn, flowtype, ci.nextArgument());
3262         }
3263         InstanceIdentifier<Flow> path1 = InstanceIdentifier.builder(Nodes.class).child(Node.class, tn.getKey())
3264                 .augmentation(FlowCapableNode.class).child(Table.class, new TableKey(tf.getTableId()))
3265                 .child(Flow.class, tf.getKey()).build();
3266         modification.removeConfigurationData(path1);
3267         Future<RpcResult<TransactionStatus>> commitFuture = modification.commit();
3268         try {
3269             RpcResult<TransactionStatus> result = commitFuture.get();
3270             TransactionStatus status = result.getResult();
3271             ci.println("Status of Flow Data Loaded Transaction: " + status);
3272
3273         } catch (InterruptedException e) {
3274             LOG.error(e.getMessage(), e);
3275         } catch (ExecutionException e) {
3276             LOG.error(e.getMessage(), e);
3277         }
3278     }
3279
3280     /**
3281      * @param ci arguments: switchId flowType tableNum
3282      * 
3283      * <pre>
3284      * e.g.: addMDFlow openflow:1 f1 42
3285      * </pre>
3286      */
3287     public void _addMDFlow(CommandInterpreter ci) {
3288         NodeBuilder tn = createTestNode(ci.nextArgument());
3289         String flowtype = ci.nextArgument();
3290         FlowBuilder tf;
3291         if (flowtype.equals("fTM")) {
3292             tf = createtablemiss(tn, flowtype, ci.nextArgument());
3293         } else {
3294             tf = createTestFlow(tn, flowtype, ci.nextArgument());
3295         }
3296         writeFlow(ci, tf, tn);
3297     }
3298
3299     private void writeFlow(CommandInterpreter ci, FlowBuilder flow, NodeBuilder nodeBuilder) {
3300         DataModification<InstanceIdentifier<?>, DataObject> modification = dataBrokerService.beginTransaction();
3301         InstanceIdentifier<Flow> path1 = InstanceIdentifier.builder(Nodes.class)
3302                 .child(Node.class, nodeBuilder.getKey()).augmentation(FlowCapableNode.class)
3303                 .child(Table.class, new TableKey(flow.getTableId())).child(Flow.class, flow.getKey()).build();
3304         modification.putConfigurationData(nodeBuilderToInstanceId(nodeBuilder), nodeBuilder.build());
3305         modification.putConfigurationData(path1, flow.build());
3306         Future<RpcResult<TransactionStatus>> commitFuture = modification.commit();
3307         try {
3308             RpcResult<TransactionStatus> result = commitFuture.get();
3309             TransactionStatus status = result.getResult();
3310             ci.println("Status of Flow Data Loaded Transaction: " + status);
3311
3312         } catch (InterruptedException e) {
3313             LOG.error(e.getMessage(), e);
3314         } catch (ExecutionException e) {
3315             LOG.error(e.getMessage(), e);
3316         }
3317     }
3318
3319     public void _modifyMDFlow(CommandInterpreter ci) {
3320         NodeBuilder tn = createTestNode(ci.nextArgument());
3321         FlowBuilder tf = createTestFlow(tn, ci.nextArgument(), ci.nextArgument());
3322         tf.setFlowName(updatedFlowName);
3323         writeFlow(ci, tf, tn);
3324         tf.setFlowName(originalFlowName);
3325         writeFlow(ci, tf, tn);
3326     }
3327
3328     private static NodeRef createNodeRef(String string) {
3329         NodeKey key = new NodeKey(new NodeId(string));
3330         InstanceIdentifier<Node> path = InstanceIdentifier.builder(Nodes.class).child(Node.class, key)
3331                 .toInstance();
3332
3333         return new NodeRef(path);
3334     }
3335
3336     @Override
3337     public String getHelp() {
3338         return "No help";
3339     }
3340     
3341     /*
3342      * usage testSwitchFlows <numberOfSwitches> <numberOfFlows> <warmup iterations> <Number Of Threads>
3343      * ex: _perfFlowTest 10 5 1 2
3344      */
3345     public void _perfFlowTest(CommandInterpreter ci) {
3346         
3347         String numberOfSwtichesStr = ci.nextArgument();
3348         String numberOfFlowsStr = ci.nextArgument();
3349         String warmupIterationsStr = ci.nextArgument();
3350         String threadCountStr = ci.nextArgument();
3351         String warmUpStr = ci.nextArgument();
3352         
3353         Collection<String> testResults = null;
3354         if(testResults == null){
3355                 testResults = new ArrayList<String>();
3356         }
3357          
3358         int numberOfSwtiches = 0;
3359         int numberOfFlows = 0;
3360         int warmupIterations = 0;
3361         boolean warmUpIterations = false;
3362
3363         int threadCount = 0;
3364         if(numberOfSwtichesStr !=null && !numberOfSwtichesStr.trim().equals("")){
3365                 numberOfSwtiches = new Integer(numberOfSwtichesStr).intValue();
3366         }else {
3367                 numberOfSwtiches = 2;
3368         }
3369         
3370         if(numberOfFlowsStr !=null && !numberOfFlowsStr.trim().equals("")){
3371                 numberOfFlows = new Integer(numberOfFlowsStr).intValue();
3372         }else {
3373                 numberOfFlows = 2;
3374         }
3375         
3376         if(warmupIterationsStr !=null && !warmupIterationsStr.trim().equals("")){
3377                 warmupIterations = new Integer(warmupIterationsStr).intValue();
3378         }else {
3379                 warmupIterations = 2;
3380         }
3381         
3382         if(threadCountStr !=null && !threadCountStr.trim().equals("")){
3383                 threadCount = new Integer(threadCountStr).intValue();
3384         }else {
3385                 threadCount = 2; 
3386         }
3387          if(warmUpStr !=null && !warmUpStr.trim().equals("") && warmUpStr.trim().equals("true")){
3388              warmUpIterations = true;
3389          }else {
3390              warmUpIterations = false;
3391          }    
3392         ci.println("*     Test Configurations*");
3393         ci.println("*     numberOfSwtiches:::"+numberOfSwtiches+"");
3394         ci.println("*     numberOfFlows:::"+numberOfFlows+"");
3395         ci.println("*     warmupIterations:::"+warmupIterations+"");
3396         ci.println("*     Number of Threads :::"+threadCount+"");
3397         ci.println("*     Warmup Required? :::"+warmUpIterations+"");
3398         
3399         String dataPath="openflow:1";
3400         String flowType = "fTM";
3401         NodeBuilder tn;
3402         FlowBuilder tf;
3403         String tableId = "0";
3404         if(warmUpIterations){
3405         ci.println("----Warmup Started-----");
3406         for(int j =1; j<= warmupIterations; j++){
3407                 for(int i =1;i<=numberOfSwtiches;i++){
3408                          dataPath = "openflow:"+i;
3409                          tn = createTestNode(dataPath);
3410                         for (int flow=1;flow<numberOfFlows;flow++){
3411                                  tf = createTestFlow_perfTest(tn, "f1", tableId, flow);
3412                                  writeFlow(ci, tf, tn);
3413                         }
3414                 }
3415          }
3416
3417        ci.println("----Warmup Done-----");
3418         }
3419        try{
3420                ExecutorService executor = Executors.newFixedThreadPool(threadCount);
3421                int flowID = 0;
3422                int tableID = 0;
3423                for ( int t=0;t< threadCount;t++){
3424                    tableID = t+1;
3425                    Runnable tRunnable = new TestFlowThread(numberOfSwtiches, numberOfFlows, ci, t, tableID);
3426                    executor.execute(tRunnable);
3427                }
3428                executor.shutdown();
3429                executor.awaitTermination(1, TimeUnit.SECONDS);
3430        } catch(Exception e){
3431           ci.println("Exception:"+e.getMessage());
3432        }
3433     }
3434     
3435     public class TestFlowThread implements Runnable {
3436
3437         int numberOfSwitches;
3438         int numberOfFlows;
3439         int testTime;
3440         CommandInterpreter ci;
3441         int testFlowsAdded;
3442         int theadNumber;
3443         Collection<String> testResults = null;
3444         int tableID = 0;
3445
3446         TestFlowThread(int numberOfSwtiches, int numberOfFlows, CommandInterpreter ci, int t, int tableID) {
3447             this.numberOfSwitches = numberOfSwtiches;
3448             this.numberOfFlows = numberOfFlows;
3449             this.ci = ci;
3450             this.theadNumber = t;
3451             this.tableID = tableID;
3452         }
3453
3454         @Override
3455         public void run() {
3456             executeFlow();
3457         }
3458
3459         public void executeFlow() {
3460
3461             String dataPath = "openflow:1";
3462             NodeBuilder tn;
3463             FlowBuilder tf;
3464             //String tableId = "0";
3465
3466             ci.println("New Thread started with id:  ID_"
3467                     + this.theadNumber);
3468             int totalNumberOfFlows = 0;
3469             long startTime = System.currentTimeMillis();
3470
3471             for (int i = 1; i <= this.numberOfSwitches; i++) {
3472                 dataPath = "openflow:" + i;
3473                 tn = createTestNode(dataPath);
3474                 for (int flow2 = 1; flow2 <= this.numberOfFlows; flow2++) {
3475                     tf = createTestFlow_perfTest(tn, "f1", ""+this.tableID, flow2);
3476                     writeFlow(this.ci, tf, tn);
3477                     totalNumberOfFlows++;
3478                 }
3479             }
3480             long endTime = System.currentTimeMillis();
3481             long timeInSeconds = Math.round((endTime - startTime) / 1000);
3482             if (timeInSeconds > 0) {
3483                 ci.println("Total flows added in Thread:" + this.theadNumber + ": Flows/Sec::" + Math.round(totalNumberOfFlows / timeInSeconds));
3484             } else {
3485                 ci.println("Total flows added in Thread:" + this.theadNumber + ": Flows/Sec::" + totalNumberOfFlows);
3486             }
3487         }
3488
3489     }
3490     /*
3491      * usage testAllFlows <dp>
3492      * ex: _perfFlowTest 1
3493      */
3494     public void _testAllFlows(CommandInterpreter ci) {
3495         String dataPathID = ci.nextArgument();
3496         int numberOfFlows = 82;
3497         int threadCount = 0;
3498         if(dataPathID ==null || dataPathID.trim().equals("")){
3499                 dataPathID = "1";
3500         }
3501         ci.println("*     Test All Flows        *");
3502         ci.println("*     dataPathID:::"+dataPathID+"");
3503         String dataPath="openflow:"+dataPathID;
3504         String tableId = "0";
3505         NodeBuilder tn = createTestNode(dataPath);
3506         FlowBuilder tf;
3507                 for (int flow=1;flow<numberOfFlows;flow++){
3508                         String flowID = "f"+flow;
3509                         try{
3510                                 tf = createTestFlow(tn, flowID, tableId);
3511                                 writeFlow(ci, tf, tn);
3512                         } catch(Exception e){
3513                                 ci.println("--Test Failed--Issue found while adding flow"+ flow);
3514                                 break;
3515                         }
3516                 }
3517     }
3518 }