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