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