Droptest: unify packet handling 72/7672/3
authorRobert Varga <robert.varga@pantheon.sk>
Wed, 4 Jun 2014 07:43:53 +0000 (09:43 +0200)
committerRobert Varga <robert.varga@pantheon.sk>
Mon, 9 Jun 2014 11:59:13 +0000 (13:59 +0200)
Rework the two implementation to make sure they do equivalent
processing, such that the difference between the two really is only the
way they propage changes through the system.

Change-Id: I01cb2daea78747a5659d04da65c810188b3e38c6
Signed-off-by: Robert Varga <robert.varga@pantheon.sk>
drop-test/src/main/java/org/opendaylight/openflowplugin/droptest/AbstractDropTest.java [new file with mode: 0644]
drop-test/src/main/java/org/opendaylight/openflowplugin/droptest/DropTestCommiter.java
drop-test/src/main/java/org/opendaylight/openflowplugin/droptest/DropTestRpcProvider.java
drop-test/src/main/java/org/opendaylight/openflowplugin/droptest/DropTestRpcSender.java

diff --git a/drop-test/src/main/java/org/opendaylight/openflowplugin/droptest/AbstractDropTest.java b/drop-test/src/main/java/org/opendaylight/openflowplugin/droptest/AbstractDropTest.java
new file mode 100644 (file)
index 0000000..d1ded2c
--- /dev/null
@@ -0,0 +1,133 @@
+/**
+ * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowplugin.droptest;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.concurrent.atomic.AtomicIntegerFieldUpdater;
+
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DropActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.drop.action._case.DropAction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.drop.action._case.DropActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Instructions;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.InstructionsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ApplyActionsCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.apply.actions._case.ApplyActionsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRef;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetSourceBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketProcessingListener;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketReceived;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+abstract class AbstractDropTest implements PacketProcessingListener {
+    private static final Logger LOG = LoggerFactory.getLogger(AbstractDropTest.class);
+
+    private static final AtomicIntegerFieldUpdater<AbstractDropTest> SENT_UPDATER = AtomicIntegerFieldUpdater.newUpdater(AbstractDropTest.class, "_sent");
+    private volatile int _sent;
+
+    private static final AtomicIntegerFieldUpdater<AbstractDropTest> RCVD_UPDATER = AtomicIntegerFieldUpdater.newUpdater(AbstractDropTest.class, "_rcvd");
+    private volatile int _rcvd;
+
+    private static final AtomicIntegerFieldUpdater<AbstractDropTest> EXCS_UPDATER = AtomicIntegerFieldUpdater.newUpdater(AbstractDropTest.class, "_excs");
+    private volatile int _excs;
+
+    public final DropTestStats getStats() {
+        return new DropTestStats(this._sent, this._rcvd, this._excs);
+    }
+
+    public final void clearStats(){
+        this._sent = 0;
+        this._rcvd = 0;
+        this._excs = 0;
+    }
+
+    @Override
+    public final void onPacketReceived(final PacketReceived notification) {
+        LOG.debug("onPacketReceived - Entering - {}", notification);
+
+        RCVD_UPDATER.incrementAndGet(this);
+
+        try {
+            final byte[] rawPacket = notification.getPayload();
+
+            // LOG.debug("onPacketReceived - received Packet on Node {} and NodeConnector {} payload {}",
+            //        nodeKey.getId(), ncKey.getId(), Hex.encodeHexString(rawPacket));
+
+            final byte[] srcMac = Arrays.copyOfRange(rawPacket, 6, 12);
+
+            //LOG.debug("onPacketReceived - received Packet on Node {} and NodeConnector {} srcMac {}",
+            //        nodeKey.getId(), ncKey.getId(), Hex.encodeHexString(srcMac));
+
+            final MatchBuilder match = new MatchBuilder();
+            final EthernetMatchBuilder ethernetMatch = new EthernetMatchBuilder();
+            final EthernetSourceBuilder ethSourceBuilder = new EthernetSourceBuilder();
+
+            //TODO: use HEX, use binary form
+            //Hex.decodeHex("000000000001".toCharArray());
+
+            ethSourceBuilder.setAddress(new MacAddress(DropTestUtils.macToString(srcMac)));
+            ethernetMatch.setEthernetSource(ethSourceBuilder.build());
+            match.setEthernetMatch(ethernetMatch.build());
+
+            final DropActionBuilder dab = new DropActionBuilder();
+            final DropAction dropAction = dab.build();
+            final ActionBuilder ab = new ActionBuilder();
+            ab.setOrder(0);
+            ab.setAction(new DropActionCaseBuilder().setDropAction(dropAction).build());
+
+            // Add our drop action to a list
+            final List<Action> actionList = Collections.singletonList(ab.build());
+
+            // Create an Apply Action
+            final ApplyActionsBuilder aab = new ApplyActionsBuilder();
+            aab.setAction(actionList);
+
+            // Wrap our Apply Action in an Instruction
+            final InstructionBuilder ib = new InstructionBuilder();
+            ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
+
+            // Put our Instruction in a list of Instructions
+            final InstructionsBuilder isb = new InstructionsBuilder();;
+            final List<Instruction> instructions = Collections.singletonList(ib.build());
+            isb.setInstruction(instructions);
+
+            // Get the Ingress nodeConnectorRef
+            final NodeConnectorRef ncr = notification.getIngress();
+
+            // Get the instance identifier for the nodeConnectorRef
+            final InstanceIdentifier<?> ncri = ncr.getValue();
+
+            // Get the instanceID for the Node in the tree above us
+            final NodeKey node = ncri.firstKeyOf(Node.class, NodeKey.class);
+
+            processPacket(node, match.build(), isb.build());
+            SENT_UPDATER.incrementAndGet(this);
+        } catch (Exception e) {
+            // TODO Auto-generated catch block
+            LOG.error("Failed to process packet", e);
+            EXCS_UPDATER.incrementAndGet(this);
+        }
+
+        LOG.debug("onPacketReceived - Leaving", notification);
+    }
+
+    protected abstract void processPacket(NodeKey node, Match match, Instructions instructions);
+}
index 06b61c4ce7aa2f85cc799f67f441003ac6e3c94d..7bc0f65e2777d1ff18cdb6a004bc2acdf8e44289 100644 (file)
@@ -7,14 +7,9 @@
  */
 package org.opendaylight.openflowplugin.droptest;
 
-import org.apache.commons.codec.binary.Hex;
+import java.math.BigInteger;
+
 import org.opendaylight.controller.sal.binding.api.data.DataModificationTransaction;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DropActionCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.drop.action._case.DropAction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.drop.action._case.DropActionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table;
@@ -24,124 +19,33 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.ta
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowCookie;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowModFlags;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.InstructionsBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ApplyActionsCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.apply.actions._case.ApplyActionsBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRef;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Instructions;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetSourceBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatchBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketProcessingListener;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketReceived;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import java.math.BigInteger;
-import java.util.ArrayList;
-import java.util.Arrays;
+import com.google.common.base.Preconditions;
 
-@SuppressWarnings("all")
-public class DropTestCommiter implements PacketProcessingListener {
+public class DropTestCommiter extends AbstractDropTest {
     private final static Logger LOG = LoggerFactory.getLogger(DropTestProvider.class);
 
-    private final DropTestProvider _manager;
-
-    private int _sent;
-    private int _rcvd;
-    
-    public DropTestStats getStats(){
-       return new DropTestStats(this._sent, this._rcvd);
-    }
-    
-    public void clearStats(){
-       this._sent = 0;
-       this._rcvd = 0;
-   }
-
-    public DropTestProvider getManager() {
-        return this._manager;
-    }
+    private final DropTestProvider manager;
 
     public DropTestCommiter(final DropTestProvider manager) {
-        this._manager = manager;
+        this.manager = Preconditions.checkNotNull(manager);
     }
 
-    public void onPacketReceived(final PacketReceived notification) {
-        // LOG.debug("onPacketReceived - Entering - " + notification);
-
-       synchronized(this) {
-               this._rcvd++;
-       }
-       
-       // Get the Ingress nodeConnectorRef
-        final NodeConnectorRef ncr = notification.getIngress();
-
-        // Get the instance identifier for the nodeConnectorRef
-        final InstanceIdentifier<NodeConnector> ncri = (InstanceIdentifier<NodeConnector>) ncr.getValue();
-
-        final NodeConnectorKey ncKey = InstanceIdentifier.<NodeConnector, NodeConnectorKey>keyOf(ncri);
-
-        // Get the instanceID for the Node in the tree above us
-        final InstanceIdentifier<Node> nodeInstanceId = ncri.<Node>firstIdentifierOf(Node.class);
-        final NodeKey nodeKey = InstanceIdentifier.<Node, NodeKey>keyOf(nodeInstanceId);
-        final byte[] rawPacket = notification.getPayload();
-
-        // LOG.debug("onPacketReceived - received Packet on Node {} and NodeConnector {} payload {}",
-        //        nodeKey.getId(), ncKey.getId(), Hex.encodeHexString(rawPacket));
-
-        final byte[] srcMac = Arrays.copyOfRange(rawPacket, 6, 12);
-
-        //LOG.debug("onPacketReceived - received Packet on Node {} and NodeConnector {} srcMac {}",
-        //        nodeKey.getId(), ncKey.getId(), Hex.encodeHexString(srcMac));
-
-        final MatchBuilder match = new MatchBuilder();
-        final EthernetMatchBuilder ethernetMatch = new EthernetMatchBuilder();
-        final EthernetSourceBuilder ethSourceBuilder = new EthernetSourceBuilder();
-
-        //TODO: use HEX, use binary form
-        //Hex.decodeHex("000000000001".toCharArray());
-
-        ethSourceBuilder.setAddress(new MacAddress(DropTestUtils.macToString(srcMac)));
-        ethernetMatch.setEthernetSource(ethSourceBuilder.build());
-        match.setEthernetMatch(ethernetMatch.build());
-
-        final DropActionBuilder dab = new DropActionBuilder();
-        final DropAction dropAction = dab.build();
-        final ActionBuilder ab = new ActionBuilder();
-        ab.setOrder(0);
-        ab.setAction(new DropActionCaseBuilder().setDropAction(dropAction).build());
-
-        // Add our drop action to a list
-        final ArrayList<Action> actionList = new ArrayList<Action>();
-        actionList.add(ab.build());
-
-        // Create an Apply Action
-        final ApplyActionsBuilder aab = new ApplyActionsBuilder();
-        aab.setAction(actionList);
-
-        // Wrap our Apply Action in an Instruction
-        final InstructionBuilder ib = new InstructionBuilder();
-        ib.setOrder(0);
-        ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
-
-        // Put our Instruction in a list of Instructions
-        final InstructionsBuilder isb = new InstructionsBuilder();
-        final ArrayList<Instruction> instructions = new ArrayList<Instruction>();
-        instructions.add(ib.build());
-        isb.setInstruction(instructions);
+    @Override
+    protected void processPacket(final NodeKey node, final Match match, final Instructions instructions) {
 
         // Finally build our flow
         final FlowBuilder fb = new FlowBuilder();
-        fb.setMatch(match.build());
-        fb.setInstructions(isb.build());
+        fb.setMatch(match);
+        fb.setInstructions(instructions);
         fb.setId(new FlowId(Long.toString(fb.hashCode())));
         fb.setPriority(4);
         fb.setBufferId(0L);
@@ -157,22 +61,18 @@ public class DropTestCommiter implements PacketProcessingListener {
         // Construct the flow instance id
         final InstanceIdentifier<Flow> flowInstanceId =
                 InstanceIdentifier.builder(Nodes.class) // File under nodes
-                        .child(Node.class, nodeKey) // A particular node indentified by nodeKey
+                        .child(Node.class, node) // A particular node indentified by nodeKey
                         .augmentation(FlowCapableNode.class) // That is flow capable, only FlowCapableNodes have tables
-                        .child(Table.class, new TableKey(new Short(((short) 0)))) // In the table identified by TableKey
+                        .child(Table.class, new TableKey((short) 0)) // In the table identified by TableKey
                         .child(Flow.class, new FlowKey(fb.getId())) // A flow identified by flowKey
                         .build();
 
         final Flow flow = fb.build();
-        final DataModificationTransaction transaction = this._manager.getDataService().beginTransaction();
+        final DataModificationTransaction transaction = manager.getDataService().beginTransaction();
 
         // LOG.debug("onPacketReceived - About to write flow - " + flow);
         transaction.putConfigurationData(flowInstanceId, flow);
         transaction.commit();
         // LOG.debug("onPacketReceived - About to write flow commited");
-       synchronized(this) {
-               this._sent++;
-       }
-
     }
 }
index 4c920122135c83f70401a2ee611d1648302f11da..587505a8a8ad0da428f0638915f6ec5befbac897 100644 (file)
@@ -40,25 +40,26 @@ public class DropTestRpcProvider implements AutoCloseable {
     }
 
     public void start() {
-        this.commiter = new DropTestRpcSender(this, this.getFlowService());;
+        this.commiter = new DropTestRpcSender(this.getFlowService());
         this.listenerRegistration = this.getNotificationService().registerNotificationListener(this.commiter);
         LOG.debug("DropTestProvider Started.");
     }
-    
+
     public DropTestStats getStats() {
-       if(this.commiter != null) {
-               return this.commiter.getStats();
-       } else {
-               return new DropTestStats("Not initialized yet.");               
-       }
+        if(this.commiter != null) {
+            return this.commiter.getStats();
+        } else {
+            return new DropTestStats("Not initialized yet.");
+        }
     }
-    
+
     public void clearStats() {
-       if(this.commiter != null) {
-               this.commiter.clearStats();
-       }
+        if(this.commiter != null) {
+            this.commiter.clearStats();
+        }
     }
 
+    @Override
     public void close() {
         try {
             LOG.debug("DropTestProvider stopped.");
index a90d310c473ca672ff2999f95949d65729ee1d62..2da724dcdb19c78e6bf67768614d1603cb9719b6 100644 (file)
 package org.opendaylight.openflowplugin.droptest;
 
 import java.math.BigInteger;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-import java.util.concurrent.atomic.AtomicIntegerFieldUpdater;
 
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DropActionCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.drop.action._case.DropAction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.drop.action._case.DropActionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowInputBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.SalFlowService;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowCookie;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowModFlags;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.InstructionsBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ApplyActionsCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.apply.actions._case.ApplyActionsBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRef;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Instructions;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetSourceBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatchBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketProcessingListener;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketReceived;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-@SuppressWarnings("all")
-public class DropTestRpcSender implements PacketProcessingListener {
+public class DropTestRpcSender extends AbstractDropTest {
     private final static Logger LOG = LoggerFactory.getLogger(DropTestProvider.class);
 
-    private final DropTestRpcProvider _manager;
-    private final SalFlowService _flowService;
+    private final SalFlowService flowService;
 
-    private static final AtomicIntegerFieldUpdater<DropTestRpcSender> SENT_UPDATER = AtomicIntegerFieldUpdater.newUpdater(DropTestRpcSender.class, "_sent");
-    private volatile int _sent;
-
-    private static final AtomicIntegerFieldUpdater<DropTestRpcSender> RCVD_UPDATER = AtomicIntegerFieldUpdater.newUpdater(DropTestRpcSender.class, "_rcvd");
-    private volatile int _rcvd;
-
-    private static final AtomicIntegerFieldUpdater<DropTestRpcSender> EXCS_UPDATER = AtomicIntegerFieldUpdater.newUpdater(DropTestRpcSender.class, "_excs");
-    private volatile int _excs;
-
-    public DropTestStats getStats() {
-        return new DropTestStats(this._sent, this._rcvd, this._excs);
-    }
-
-    public void clearStats(){
-        this._sent = 0;
-        this._rcvd = 0;
-        this._excs = 0;
-   }
-
-    public DropTestRpcProvider getManager() {
-        return this._manager;
-    }
-
-    public SalFlowService getFlowService() {
-        return this._flowService;
-    }
-
-    public DropTestRpcSender(final DropTestRpcProvider manager, final SalFlowService flowService) {
-        this._manager = manager;
-        this._flowService = flowService;
+    public DropTestRpcSender(final SalFlowService flowService) {
+        this.flowService = flowService;
     }
 
     @Override
-    public void onPacketReceived(final PacketReceived notification) {
-        // LOG.debug("onPacketReceived - Entering - " + notification);
-
-        RCVD_UPDATER.incrementAndGet(this);
-
-        try {
-            // Get the Ingress nodeConnectorRef
-            final NodeConnectorRef ncr = notification.getIngress();
-
-            // Get the instance identifier for the nodeConnectorRef
-            final InstanceIdentifier<NodeConnector> ncri = (InstanceIdentifier<NodeConnector>) ncr.getValue();
-            final NodeConnectorKey ncKey = InstanceIdentifier.<NodeConnector, NodeConnectorKey>keyOf(ncri);
-
-            // Get the instanceID for the Node in the tree above us
-            final InstanceIdentifier<Node> nodeInstanceId = ncri.<Node>firstIdentifierOf(Node.class);
-            final NodeKey nodeKey = InstanceIdentifier.<Node, NodeKey>keyOf(nodeInstanceId);
-            final byte[] rawPacket = notification.getPayload();
-
-            // LOG.debug("onPacketReceived - received Packet on Node {} and NodeConnector {} payload {}",
-            //        nodeKey.getId(), ncKey.getId(), Hex.encodeHexString(rawPacket));
-
-            final byte[] srcMac = Arrays.copyOfRange(rawPacket, 6, 12);
-
-            //LOG.debug("onPacketReceived - received Packet on Node {} and NodeConnector {} srcMac {}",
-            //        nodeKey.getId(), ncKey.getId(), Hex.encodeHexString(srcMac));
-
-
-            final MatchBuilder match = new MatchBuilder();
-            final EthernetMatchBuilder ethernetMatch = new EthernetMatchBuilder();
-            final EthernetSourceBuilder ethSourceBuilder = new EthernetSourceBuilder();
-
-            //TODO: use HEX, use binary form
-            //Hex.decodeHex("000000000001".toCharArray());
-
-            ethSourceBuilder.setAddress(new MacAddress(DropTestUtils.macToString(srcMac)));
-            ethernetMatch.setEthernetSource(ethSourceBuilder.build());
-            match.setEthernetMatch(ethernetMatch.build());
-            final DropActionBuilder dab = new DropActionBuilder();
-            final DropAction dropAction = dab.build();
-            final ActionBuilder ab = new ActionBuilder();
-            ab.setAction(new DropActionCaseBuilder().setDropAction(dropAction).build());
-
-            // Add our drop action to a list
-            final List<Action> actionList = Collections.singletonList(ab.build());
-
-            // Create an Apply Action
-            final ApplyActionsBuilder aab = new ApplyActionsBuilder();
-            aab.setAction(actionList);
-
-            // Wrap our Apply Action in an Instruction
-            final InstructionBuilder ib = new InstructionBuilder();
-            ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
-
-            // Put our Instruction in a list of Instructions
-            final InstructionsBuilder isb = new InstructionsBuilder();;
-            final List<Instruction> instructions = Collections.singletonList(ib.build());
-            isb.setInstruction(instructions);
-
-            // Finally build our flow
-            final AddFlowInputBuilder fb = new AddFlowInputBuilder();
-            fb.setMatch(match.build());
-            fb.setInstructions(isb.build());
-            //fb.setId(new FlowId(Long.toString(fb.hashCode)));
-
-            // Construct the flow instance id
-            final InstanceIdentifier<Node> flowInstanceId = InstanceIdentifier
-                    .builder(Nodes.class) // File under nodes
-                    .child(Node.class, nodeKey).toInstance(); // A particular node identified by nodeKey
-            fb.setNode(new NodeRef(flowInstanceId));
-
-            fb.setPriority(4);
-            fb.setBufferId(0L);
-            final BigInteger value = BigInteger.valueOf(10);
-            fb.setCookie(new FlowCookie(value));
-            fb.setCookieMask(new FlowCookie(value));
-            fb.setTableId((short) 0);
-            fb.setHardTimeout(300);
-            fb.setIdleTimeout(240);
-            fb.setFlags(new FlowModFlags(false, false, false, false, false));
-
-            // Add flow
-            this.getFlowService().addFlow(fb.build());
-            SENT_UPDATER.incrementAndGet(this);
-        } catch (Exception e) {
-            // TODO Auto-generated catch block
-            LOG.error("Failed to process packet", e);
-            EXCS_UPDATER.incrementAndGet(this);
-        }
+    protected void processPacket(final NodeKey node, final Match match, final Instructions instructions) {
+
+        // Finally build our flow
+        final AddFlowInputBuilder fb = new AddFlowInputBuilder();
+        fb.setMatch(match);
+        fb.setInstructions(instructions);
+        //fb.setId(new FlowId(Long.toString(fb.hashCode)));
+
+        // Construct the flow instance id
+        final InstanceIdentifier<Node> flowInstanceId = InstanceIdentifier
+                .builder(Nodes.class) // File under nodes
+                .child(Node.class, node).toInstance(); // A particular node identified by nodeKey
+        fb.setNode(new NodeRef(flowInstanceId));
+
+        fb.setPriority(4);
+        fb.setBufferId(0L);
+        final BigInteger value = BigInteger.valueOf(10);
+        fb.setCookie(new FlowCookie(value));
+        fb.setCookieMask(new FlowCookie(value));
+        fb.setTableId((short) 0);
+        fb.setHardTimeout(300);
+        fb.setIdleTimeout(240);
+        fb.setFlags(new FlowModFlags(false, false, false, false, false));
+
+        // Add flow
+        flowService.addFlow(fb.build());
     }
 }