ONOS-4665 OSPF refactoring to align with ISIS design

Change-Id: If4a15d5a1c4ae3a5b2f877fa688ce07972749205
diff --git a/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/LinkInformation.java b/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/LinkInformation.java
index adc5f7d..fc1db54 100755
--- a/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/LinkInformation.java
+++ b/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/LinkInformation.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2016-present Open Networking Laboratory
+ * Copyright 2016 Open Networking Laboratory
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/LsaWrapper.java b/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/LsaWrapper.java
index 0574491..1ef4bdd 100755
--- a/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/LsaWrapper.java
+++ b/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/LsaWrapper.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2016-present Open Networking Laboratory
+ * Copyright 2016 Open Networking Laboratory
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/LsdbAge.java b/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/LsdbAge.java
index 63f4824..4983d30 100755
--- a/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/LsdbAge.java
+++ b/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/LsdbAge.java
@@ -98,4 +98,11 @@
      * @param lsaWrapper wrapper instance
      */
     public void removeLsaFromBin(LsaWrapper lsaWrapper);
+
+    /**
+     * Gets the age counter roll over.
+     *
+     * @return the age counter roll over
+     */
+    public int getAgeCounterRollOver();
 }
\ No newline at end of file
diff --git a/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/OspfAgent.java b/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/OspfAgent.java
index ccea5ac..90c986b 100755
--- a/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/OspfAgent.java
+++ b/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/OspfAgent.java
@@ -48,7 +48,8 @@
     /**
      * Notifies that got a packet of link from network and need do processing.
      *
-     * @param ospfRouter router instance
+     * @param ospfRouter  router instance
+     * @param ospfLinkTed link ted instance
      */
-    void deleteLink(OspfRouter ospfRouter);
+    void deleteLink(OspfRouter ospfRouter, OspfLinkTed ospfLinkTed);
 }
\ No newline at end of file
diff --git a/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/OspfArea.java b/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/OspfArea.java
index 9699814..4623ef5 100755
--- a/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/OspfArea.java
+++ b/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/OspfArea.java
@@ -59,7 +59,7 @@
      *
      * @return LSDB instance for this area
      */
-    public OspfLsdb database();
+    OspfLsdb database();
 
     /**
      * Checks whether an instance of the given LSA exists in the database.
@@ -67,19 +67,12 @@
      * @param lookupLsa LSA instance to lookup
      * @return LSA wrapper instance which contains the LSA
      */
-    public LsaWrapper lsaLookup(OspfLsa lookupLsa);
+    LsaWrapper lsaLookup(OspfLsa lookupLsa);
 
     /**
      * Initializes link state database, this acts as a place holder for storing the received LSA.
      */
-    public void initializeDb();
-
-    /**
-     * Sets the stub cost.
-     *
-     * @param stubCost stub cost
-     */
-    void setStubCost(int stubCost);
+    void initializeDb();
 
     /**
      * Sets the options value.
@@ -89,38 +82,6 @@
     void setOptions(int options);
 
     /**
-     * Gets area address ranges to which this area belongs to.
-     *
-     * @return list of area address ranges
-     */
-    List<OspfAreaAddressRange> addressRanges();
-
-    /**
-     * Sets the area address ranges to which this area belongs to.
-     *
-     * @param addrRangeList list of area address ranges
-     */
-    void setAddressRanges(List<OspfAreaAddressRange> addrRangeList);
-
-    /**
-     * Gets whether the area is transit capable or not.
-     * This indicates whether the area can carry data traffic that neither originates
-     * nor terminates in the area itself.
-     *
-     * @return true if transit capable, else false
-     */
-    boolean isTransitCapability();
-
-    /**
-     * Sets whether the area is transit capable or not.
-     * This indicates whether the area can carry data traffic that neither originates
-     * nor terminates in the area itself.
-     *
-     * @param transitCapability true if transit capable, else false
-     */
-    void setTransitCapability(boolean transitCapability);
-
-    /**
      * Gets external routing capability.
      * This indicates Whether AS-external-LSAs will be flooded into/throughout the area.
      *
@@ -137,13 +98,6 @@
     void setExternalRoutingCapability(boolean externalRoutingCapability);
 
     /**
-     * Gets the stub cost, which indicates if the area has been configured as a stub area.
-     *
-     * @return stub cost
-     */
-    int stubCost();
-
-    /**
      * Gets if the router is opaque enabled or not.
      * This indicates whether the router accepts opaque LSA.
      *
@@ -156,14 +110,14 @@
      *
      * @return list of interfaces
      */
-    List<OspfInterface> getInterfacesLst();
+    List<OspfInterface> ospfInterfaceList();
 
     /**
      * Sets the list of interfaces attached to this area.
      *
      * @param interfacesLst list of interface instances
      */
-    void setInterfacesLst(List<OspfInterface> interfacesLst);
+    void setOspfInterfaceList(List<OspfInterface> interfacesLst);
 
     /**
      * Gets the options value, which indicates the supported optional capabilities.
diff --git a/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/OspfController.java b/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/OspfController.java
index 522bc9e..4271177 100755
--- a/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/OspfController.java
+++ b/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/OspfController.java
@@ -15,6 +15,8 @@
  */
 package org.onosproject.ospf.controller;
 
+import com.fasterxml.jackson.databind.JsonNode;
+
 import java.util.List;
 import java.util.Set;
 
@@ -55,9 +57,9 @@
     /**
      * Updates configuration of processes.
      *
-     * @param processes process info to update
+     * @param processesNode process info to update
      */
-    public void updateConfig(List<OspfProcess> processes);
+    void updateConfig(JsonNode processesNode);
 
     /**
      * Deletes configuration parameters.
@@ -65,7 +67,7 @@
      * @param processes list of process instance
      * @param attribute attribute to delete
      */
-    public void deleteConfig(List<OspfProcess> processes, String attribute);
+    void deleteConfig(List<OspfProcess> processes, String attribute);
 
     /**
      * Gets the list of listeners registered for router events.
diff --git a/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/OspfInterface.java b/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/OspfInterface.java
index 9647a00..f8ef2c5 100755
--- a/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/OspfInterface.java
+++ b/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/OspfInterface.java
@@ -15,9 +15,10 @@
  */
 package org.onosproject.ospf.controller;
 
+import org.jboss.netty.channel.ChannelHandlerContext;
 import org.onlab.packet.Ip4Address;
 
-import java.util.HashMap;
+import java.util.Map;
 
 /**
  * Represents an OSPF Interface.
@@ -25,6 +26,34 @@
 public interface OspfInterface {
 
     /**
+     * Returns interface index.
+     *
+     * @return interface index
+     */
+    public int interfaceIndex();
+
+    /**
+     * Set interface index.
+     *
+     * @param interfaceIndex interface index
+     */
+    public void setInterfaceIndex(int interfaceIndex);
+
+    /**
+     * Returns OSPF area instance.
+     *
+     * @return OSPF area instance
+     */
+    public OspfArea ospfArea();
+
+    /**
+     * Sets OSPF area instance.
+     *
+     * @param ospfArea OSPF area instance
+     */
+    public void setOspfArea(OspfArea ospfArea);
+
+    /**
      * Gets network mask of the interface.
      *
      * @return network mask
@@ -32,29 +61,6 @@
     Ip4Address ipNetworkMask();
 
     /**
-     * Sets area id, to which the interface belongs.
-     *
-     * @param areaId area identifier
-     */
-    void setAreaId(int areaId);
-
-    /**
-     * Sets the authentication key.
-     * Interface uses this to authenticate while establishing communication with other routers.
-     *
-     * @param authKey represents authentication key
-     */
-    void setAuthKey(String authKey);
-
-    /**
-     * Sets the authentication type,
-     * Interface uses this to authenticate while establishing communication with other routers.
-     *
-     * @param authType authType represents authentication type
-     */
-    void setAuthType(String authType);
-
-    /**
      * Sets the value of BDR.
      * The BDR is calculated during adjacency formation.
      *
@@ -87,13 +93,6 @@
     void setRouterDeadIntervalTime(int routerDeadIntervalTime);
 
     /**
-     * Sets the interface cost which is the cost of sending a data packet onto the network.
-     *
-     * @param interfaceCost an integer represents interface cost
-     */
-    void setInterfaceCost(int interfaceCost);
-
-    /**
      * Sets interface type.
      * This indicates whether the interface is on point to point mode or broadcast mode.
      *
@@ -116,22 +115,6 @@
     void setIpNetworkMask(Ip4Address ipNetworkMask);
 
     /**
-     * Sets the polling interval.
-     * Polling interval indicates the interval until when the Hello Packets are
-     * sent to a dead neighbor.
-     *
-     * @param pollInterval an integer represents poll interval
-     */
-    void setPollInterval(int pollInterval);
-
-    /**
-     * Sets transmission delay.
-     *
-     * @param transmitDelay an integer represents delay
-     */
-    void setTransmitDelay(int transmitDelay);
-
-    /**
      * Sets retransmit interval which indicates the number of seconds between LSA retransmissions.
      *
      * @param reTransmitInterval an integer represents interval
@@ -153,13 +136,6 @@
     void setRouterPriority(int routerPriority);
 
     /**
-     * Gets the area id to which router belongs.
-     *
-     * @return areaId an integer value
-     */
-    int areaId();
-
-    /**
      * Gets the IP address.
      *
      * @return an string represents IP address
@@ -181,32 +157,11 @@
     int mtu();
 
     /**
-     * Gets interface cost.
-     *
-     * @return an integer representing interface cost
-     */
-    int interfaceCost();
-
-    /**
      * Gets the list of neighbors associated with the interface.
      *
      * @return listOfNeighbors as key value pair
      */
-    HashMap<String, OspfNbr> listOfNeighbors();
-
-    /**
-     * Gets poll interval.
-     *
-     * @return pollInterval an integer representing poll interval
-     */
-    int pollInterval();
-
-    /**
-     * Gets transmission delay.
-     *
-     * @return transmitDelay an integer representing delay
-     */
-    int transmitDelay();
+    Map<String, OspfNbr> listOfNeighbors();
 
     /**
      * Gets the IP address of the BDR.
@@ -223,20 +178,6 @@
     Ip4Address dr();
 
     /**
-     * Gets authentication key.
-     *
-     * @return authKey represents authentication key
-     */
-    String authKey();
-
-    /**
-     * Gets authentication type.
-     *
-     * @return authType represents authentication type
-     */
-    String authType();
-
-    /**
      * Gets hello interval time in seconds, this defines how often we send the hello packet.
      *
      * @return hello interval time in seconds
@@ -294,4 +235,54 @@
      * @param lsaKey key used to store lsa in map
      */
     void removeLsaFromNeighborMap(String lsaKey);
+
+    /**
+     * When an OSPF message received it is handed over to this method.
+     * Based on the type of the OSPF message received it will be handed over
+     * to corresponding message handler methods.
+     *
+     * @param ospfMessage received OSPF message
+     * @param ctx         channel handler context instance.
+     * @throws Exception might throws exception
+     */
+    void processOspfMessage(OspfMessage ospfMessage, ChannelHandlerContext ctx) throws Exception;
+
+    /**
+     * Represents an interface is up and connected.
+     *
+     * @throws Exception might throws exception
+     */
+    void interfaceUp() throws Exception;
+
+    /**
+     * Starts the timer which waits for configured seconds and sends Delayed Ack Packet.
+     */
+    void startDelayedAckTimer();
+
+    /**
+     * Stops the delayed acknowledge timer.
+     */
+    void stopDelayedAckTimer();
+
+    /**
+     * Starts the hello timer which sends hello packet every configured seconds.
+     */
+    void startHelloTimer();
+
+    /**
+     * Stops the hello timer.
+     */
+    void stopHelloTimer();
+
+    /**
+     * Gets called when an interface is down.
+     * All interface variables are reset, and interface timers disabled.
+     * Also all neighbor connections associated with the interface are destroyed.
+     */
+    void interfaceDown();
+
+    /**
+     * Removes all the neighbors.
+     */
+    void removeNeighbors();
 }
\ No newline at end of file
diff --git a/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/OspfLinkListener.java b/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/OspfLinkListener.java
index b9b887c..a6f17ea 100755
--- a/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/OspfLinkListener.java
+++ b/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/OspfLinkListener.java
@@ -31,7 +31,8 @@
     /**
      * Notifies that a link got removed from network.
      *
-     * @param ospfRouter router instance
+     * @param ospfRouter  router instance
+     * @param ospfLinkTed link TED information of router
      */
-    void deleteLink(OspfRouter ospfRouter);
+    void deleteLink(OspfRouter ospfRouter, OspfLinkTed ospfLinkTed);
 }
\ No newline at end of file
diff --git a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/ospfpacket/OspfMessage.java b/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/OspfMessage.java
old mode 100644
new mode 100755
similarity index 74%
rename from protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/ospfpacket/OspfMessage.java
rename to protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/OspfMessage.java
index 1ce307f..bdd3c9d
--- a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/ospfpacket/OspfMessage.java
+++ b/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/OspfMessage.java
@@ -13,12 +13,10 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.onosproject.ospf.protocol.ospfpacket;
+package org.onosproject.ospf.controller;
 
 import org.jboss.netty.buffer.ChannelBuffer;
 import org.onlab.packet.Ip4Address;
-import org.onosproject.ospf.exceptions.OspfParseException;
-import org.onosproject.ospf.protocol.util.OspfPacketType;
 
 /**
  * Representation of an OSPF message.
@@ -26,6 +24,20 @@
 public interface OspfMessage {
 
     /**
+     * Returns the interface index on which the message received.
+     *
+     * @return interface index on which the message received
+     */
+    int interfaceIndex();
+
+    /**
+     * Sets the interface index on which the message received.
+     *
+     * @param interfaceIndex interface index on which the message received
+     */
+    void setInterfaceIndex(int interfaceIndex);
+
+    /**
      * Returns the type of OSPF message.
      *
      * @return OSPF message type
@@ -36,9 +48,9 @@
      * Reads from ChannelBuffer and initializes the type of LSA.
      *
      * @param channelBuffer channel buffer instance
-     * @throws OspfParseException might throws exception while parsing buffer
+     * @throws Exception might throws exception while parsing buffer
      */
-    void readFrom(ChannelBuffer channelBuffer) throws OspfParseException;
+    void readFrom(ChannelBuffer channelBuffer) throws Exception;
 
     /**
      * Returns OSPFMessage as byte array.
diff --git a/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/OspfNbr.java b/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/OspfNbr.java
index adc12f1..ff67852 100755
--- a/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/OspfNbr.java
+++ b/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/OspfNbr.java
@@ -189,4 +189,36 @@
      * @return neighbor's state
      */
     OspfNeighborState getState();
+
+    /**
+     * Starts the inactivity timer.
+     */
+    void startInactivityTimeCheck();
+
+    /**
+     * Stops the inactivity timer.
+     */
+    void stopInactivityTimeCheck();
+
+    /**
+     * Sets router dead interval.
+     *
+     * @param routerDeadInterval router dead interval
+     */
+    void setRouterDeadInterval(int routerDeadInterval);
+
+    /**
+     * Stops the flooding timer.
+     */
+    void stopFloodingTimer();
+
+    /**
+     * Stops the Dd Retransmission executor task.
+     */
+    void stopRxMtDdTimer();
+
+    /**
+     * Stops Ls request retransmission executor task.
+     */
+    void stopRxMtLsrTimer();
 }
\ No newline at end of file
diff --git a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/util/OspfPacketType.java b/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/OspfPacketType.java
old mode 100644
new mode 100755
similarity index 77%
rename from protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/util/OspfPacketType.java
rename to protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/OspfPacketType.java
index 22832e2..0d83c5c
--- a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/util/OspfPacketType.java
+++ b/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/OspfPacketType.java
@@ -13,17 +13,32 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.onosproject.ospf.protocol.util;
+package org.onosproject.ospf.controller;
 
 /**
  * Representation of different OSPF packet types.
  */
 public enum OspfPacketType {
 
+    /**
+     * OSPF hello packet.
+     */
     HELLO(1),
+    /**
+     * OSPF device description packet.
+     */
     DD(2),
+    /**
+     * OSPF link state request packet.
+     */
     LSREQUEST(3),
+    /**
+     * OSPF link state update packet.
+     */
     LSUPDATE(4),
+    /**
+     * OSPF link state acknowledge packet.
+     */
     LSAACK(5);
 
     private int value;
diff --git a/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/TopologyForDeviceAndLink.java b/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/TopologyForDeviceAndLink.java
index 012457b..9e58527 100755
--- a/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/TopologyForDeviceAndLink.java
+++ b/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/TopologyForDeviceAndLink.java
@@ -50,7 +50,7 @@
     /**
      * Sets link information.
      *
-     * @param key                key used to store in map
+     * @param key key used to store in map
      * @param linkInformationMap link information instance
      */
     void setLinkInformationMap(String key, LinkInformation linkInformationMap);
@@ -109,4 +109,56 @@
      * @param ospfArea area instance
      */
     void updateLinkInformation(OspfLsa ospfLsa, OspfArea ospfArea);
+
+    /**
+     * Gets deviceInformation as map.
+     *
+     * @return deviceInformationMap to delete from core
+     */
+    Map<String, DeviceInformation> deviceInformationMapToDelete();
+
+    /**
+     * Sets deviceInformation as map.
+     *
+     * @param key key to store in device info map
+     * @param deviceInformationMapToDelete device information instance
+     */
+    void setDeviceInformationMapToDelete(String key, DeviceInformation deviceInformationMapToDelete);
+
+    /**
+     * Removes Device Information from deviceInformationMapToDelete.
+     *
+     * @param key key to remove device information
+     */
+    void removeDeviceInformationMapFromDeleteMap(String key);
+
+    /**
+     * Gets deviceInformation as map for Point-To-Point.
+     *
+     * @return deviceInformationMap
+     */
+    Map<String, DeviceInformation> deviceInformationMapForPointToPoint();
+
+    /**
+     * Sets deviceInformation as map for Point-To-Point..
+     *
+     * @param key key to store in device info
+     * @param deviceInformationMap device information instance
+     */
+    void setDeviceInformationMapForPointToPoint(String key, DeviceInformation deviceInformationMap);
+
+    /**
+     * Gets linkInformation as map for PointToPoint.
+     *
+     * @return linkInformationMap
+     */
+    Map<String, LinkInformation> linkInformationMapForPointToPoint();
+
+    /**
+     * Sets linkInformation as map for PointToPoint.
+     *
+     * @param key key to store link info
+     * @param linkInformationMap link information instance
+     */
+    void setLinkInformationMapForPointToPoint(String key, LinkInformation linkInformationMap);
 }
\ No newline at end of file
diff --git a/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/area/OspfAreaImpl.java b/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/area/OspfAreaImpl.java
index f4c70c0..9a7bd47 100755
--- a/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/area/OspfAreaImpl.java
+++ b/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/area/OspfAreaImpl.java
@@ -21,7 +21,6 @@
 import org.onlab.packet.Ip4Address;
 import org.onosproject.ospf.controller.LsaWrapper;
 import org.onosproject.ospf.controller.OspfArea;
-import org.onosproject.ospf.controller.OspfAreaAddressRange;
 import org.onosproject.ospf.controller.OspfInterface;
 import org.onosproject.ospf.controller.OspfLsa;
 import org.onosproject.ospf.controller.OspfLsaType;
@@ -54,28 +53,14 @@
 public class OspfAreaImpl implements OspfArea {
     private static final Logger log = LoggerFactory.getLogger(OspfAreaImpl.class);
     /**
-     * Address ranges in order to aggregate routing information at area.
-     * boundaries. Each address range is specified by an [address,mask] pair and
-     * a status indication of either Advertise or DoNotAdvertise
-     */
-    private List<OspfAreaAddressRange> addressRanges;
-    /**
-     * This parameter indicates whether the area can carry data traffic that.
-     * neither originates nor terminates in the area itself.
-     */
-    private boolean transitCapability;
-    /**
      * Whether AS-external-LSAs will be flooded into/throughout the area.
      */
     private boolean externalRoutingCapability;
-    /**
-     * Indicates the cost of the default summary-LSA.
-     */
-    private int stubCost;
+
     /**
      * Represents a list of all router's interfaces associated with this area.
      */
-    private List<OspfInterface> interfacesLst;
+    private List<OspfInterface> ospfInterfaceList;
     /**
      * The LS Database for this area. It includes router-LSAs, network-LSAs and.
      * summary-LSAs. AS-external-LSAs are hold in the OSPF class itself.
@@ -116,18 +101,15 @@
         OspfAreaImpl that = (OspfAreaImpl) o;
         return Objects.equal(areaId, that.areaId) &&
                 Objects.equal(routerId, that.routerId) &&
-                Objects.equal(addressRanges.size(), that.addressRanges.size()) &&
-                Objects.equal(transitCapability, that.transitCapability) &&
                 Objects.equal(externalRoutingCapability, that.externalRoutingCapability) &&
-                Objects.equal(stubCost, that.stubCost) &&
-                Objects.equal(interfacesLst.size(), that.interfacesLst.size()) &&
+                Objects.equal(ospfInterfaceList.size(), that.ospfInterfaceList.size()) &&
                 Objects.equal(database, that.database);
     }
 
     @Override
     public int hashCode() {
-        return Objects.hashCode(areaId, routerId, addressRanges, transitCapability, externalRoutingCapability,
-                                stubCost, interfacesLst, database);
+        return Objects.hashCode(areaId, routerId, externalRoutingCapability,
+                                ospfInterfaceList, database);
     }
 
     /**
@@ -234,7 +216,7 @@
         networkLsa.setNetworkMask(mask);
         //Adding our own router.
         networkLsa.addAttachedRouter(routerId());
-        Iterator iter = interfacesLst.iterator();
+        Iterator iter = ospfInterfaceList.iterator();
         OspfInterfaceImpl ospfInterface = null;
         while (iter.hasNext()) {
             ospfInterface = (OspfInterfaceImpl) iter.next();
@@ -310,7 +292,7 @@
      */
     private void buildLinkForRouterLsa(RouterLsa routerLsa, OspfInterface ospfInterface) {
         OspfInterfaceImpl nextInterface;
-        Iterator interfaces = interfacesLst.iterator();
+        Iterator interfaces = ospfInterfaceList.iterator();
         while (interfaces.hasNext()) {
             nextInterface = (OspfInterfaceImpl) interfaces.next();
             if (nextInterface.state() == OspfInterfaceState.DOWN) {
@@ -418,44 +400,6 @@
     }
 
     /**
-     * Gets address range.
-     *
-     * @return list of area address ranges
-     */
-    public List<OspfAreaAddressRange> addressRanges() {
-        return addressRanges;
-    }
-
-    /**
-     * Sets the area address ranges.
-     *
-     * @param addressRanges list of area address range
-     */
-    @JsonProperty("addressRange")
-    public void setAddressRanges(List<OspfAreaAddressRange> addressRanges) {
-        this.addressRanges = addressRanges;
-    }
-
-    /**
-     * Gets is transit capable or not.
-     *
-     * @return true if transit capable, else false
-     */
-    public boolean isTransitCapability() {
-        return transitCapability;
-    }
-
-    /**
-     * Sets transit capability.
-     *
-     * @param transitCapability true if transit capable, else false
-     */
-    @JsonProperty("transitCapability")
-    public void setTransitCapability(boolean transitCapability) {
-        this.transitCapability = transitCapability;
-    }
-
-    /**
      * Gets external routing capability.
      *
      * @return true if external routing capable, else false
@@ -475,41 +419,22 @@
     }
 
     /**
-     * Gets the stub cost.
-     *
-     * @return stub cost
-     */
-    public int stubCost() {
-        return stubCost;
-    }
-
-    /**
-     * Sets the stub cost.
-     *
-     * @param stubCost stub cost
-     */
-    @JsonProperty("stubCost")
-    public void setStubCost(int stubCost) {
-        this.stubCost = stubCost;
-    }
-
-    /**
      * Gets the list of interfaces in this area.
      *
      * @return list of interfaces
      */
-    public List<OspfInterface> getInterfacesLst() {
-        return interfacesLst;
+    public List<OspfInterface> ospfInterfaceList() {
+        return ospfInterfaceList;
     }
 
     /**
      * Sets the list of interfaces attached to the area.
      *
-     * @param interfacesLst list of OspfInterface instances
+     * @param ospfInterfaceList list of OspfInterface instances
      */
     @JsonProperty("interface")
-    public void setInterfacesLst(List<OspfInterface> interfacesLst) {
-        this.interfacesLst = interfacesLst;
+    public void setOspfInterfaceList(List<OspfInterface> ospfInterfaceList) {
+        this.ospfInterfaceList = ospfInterfaceList;
     }
 
     /**
@@ -522,7 +447,7 @@
     public boolean noNeighborInLsaExchangeProcess() {
         OspfInterfaceImpl nextInterface;
         OspfNeighborState nextNeighborState;
-        Iterator interfaces = interfacesLst.iterator();
+        Iterator interfaces = ospfInterfaceList.iterator();
         while (interfaces.hasNext()) {
             nextInterface = (OspfInterfaceImpl) interfaces.next();
             Iterator neighbors = nextInterface.listOfNeighbors().values().iterator();
@@ -659,19 +584,14 @@
         return MoreObjects.toStringHelper(getClass())
                 .omitNullValues()
                 .add("areaID", areaId)
-                .add("stubCost", stubCost)
-                .add("addressRanges", addressRanges)
-                .add("interfacesLst", interfacesLst)
-                .add("transitCapability", transitCapability)
+                .add("ospfInterfaceList", ospfInterfaceList)
                 .add("externalRoutingCapability", externalRoutingCapability)
                 .toString();
     }
 
     /**
      * Checks all Neighbors belonging to this Area whether they are in state lesser than the EXCHANGE.
-     * <p>
      * Creates list of such neighbors
-     * <p>
      * Returns list of neighbors who satisfy the conditions
      *
      * @param ospfInterface OSPF interface instance
@@ -716,7 +636,7 @@
     public void addToOtherNeighborLsaTxList(LsaHeader recLsa) {
         //Add the received LSA in other neighbors retransmission list.
         log.debug("OspfAreaImpl: addToOtherNeighborLsaTxList");
-        List<OspfInterface> ospfInterfaces = getInterfacesLst();
+        List<OspfInterface> ospfInterfaces = ospfInterfaceList();
         for (OspfInterface ospfInterfaceFromArea : ospfInterfaces) {
             Map neighbors = ospfInterfaceFromArea.listOfNeighbors();
             for (Object neighborIP : neighbors.keySet()) {
diff --git a/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/area/OspfInterfaceImpl.java b/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/area/OspfInterfaceImpl.java
index 19f8ef5..443bf5d 100755
--- a/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/area/OspfInterfaceImpl.java
+++ b/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/area/OspfInterfaceImpl.java
@@ -18,47 +18,93 @@
 
 import com.google.common.base.MoreObjects;
 import com.google.common.base.Objects;
+import org.jboss.netty.channel.Channel;
+import org.jboss.netty.channel.ChannelFuture;
+import org.jboss.netty.channel.ChannelHandlerContext;
 import org.onlab.packet.Ip4Address;
+import org.onosproject.ospf.controller.LsaWrapper;
+import org.onosproject.ospf.controller.OspfArea;
 import org.onosproject.ospf.controller.OspfInterface;
+import org.onosproject.ospf.controller.OspfLinkTed;
+import org.onosproject.ospf.controller.OspfLsa;
+import org.onosproject.ospf.controller.OspfMessage;
 import org.onosproject.ospf.controller.OspfNbr;
+import org.onosproject.ospf.controller.OspfNeighborState;
+import org.onosproject.ospf.controller.OspfPacketType;
+import org.onosproject.ospf.controller.OspfRouter;
+import org.onosproject.ospf.controller.TopologyForDeviceAndLink;
+import org.onosproject.ospf.controller.impl.Controller;
+import org.onosproject.ospf.controller.impl.OspfNbrImpl;
+import org.onosproject.ospf.controller.impl.TopologyForDeviceAndLinkImpl;
+import org.onosproject.ospf.controller.lsdb.LsaWrapperImpl;
+import org.onosproject.ospf.controller.lsdb.OspfLsdbImpl;
+import org.onosproject.ospf.controller.util.OspfEligibleRouter;
+import org.onosproject.ospf.controller.util.OspfInterfaceType;
 import org.onosproject.ospf.protocol.lsa.LsaHeader;
 import org.onosproject.ospf.protocol.lsa.OpaqueLsaHeader;
+import org.onosproject.ospf.protocol.ospfpacket.OspfMessageWriter;
+import org.onosproject.ospf.protocol.ospfpacket.OspfPacketHeader;
+import org.onosproject.ospf.protocol.ospfpacket.subtype.LsRequestPacket;
+import org.onosproject.ospf.protocol.ospfpacket.types.DdPacket;
+import org.onosproject.ospf.protocol.ospfpacket.types.HelloPacket;
+import org.onosproject.ospf.protocol.ospfpacket.types.LsAcknowledge;
+import org.onosproject.ospf.protocol.ospfpacket.types.LsRequest;
+import org.onosproject.ospf.protocol.ospfpacket.types.LsUpdate;
+import org.onosproject.ospf.protocol.util.ChecksumCalculator;
 import org.onosproject.ospf.protocol.util.OspfInterfaceState;
 import org.onosproject.ospf.protocol.util.OspfParameters;
+import org.onosproject.ospf.protocol.util.OspfUtil;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import java.util.ArrayList;
 import java.util.HashMap;
+import java.util.Iterator;
 import java.util.List;
+import java.util.ListIterator;
+import java.util.Map;
 import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.ScheduledFuture;
+import java.util.concurrent.TimeUnit;
 
 /**
  * Representation of an OSPF interface.
  */
 public class OspfInterfaceImpl implements OspfInterface {
     private static final Logger log = LoggerFactory.getLogger(OspfInterfaceImpl.class);
+    private int interfaceIndex;
     private Ip4Address ipAddress;
     private Ip4Address ipNetworkMask;
-    private int areaId;
+    private Channel channel = null;
     private int helloIntervalTime;
     private int routerDeadIntervalTime;
-    private int transmitDelay;
     private int routerPriority;
-    private int systemInterfaceType;
     private int interfaceType;
-    private int interfaceCost;
-    private String authType;
-    private String authKey;
-    private int pollInterval;
     private int mtu;
     private int reTransmitInterval;
     private Ip4Address dr;
     private Ip4Address bdr;
     private OspfInterfaceState state;
     private List<LsaHeader> linkStateHeaders = new ArrayList<>();
-    private HashMap<String, OspfNbr> listOfNeighbors = new HashMap<>();
-    private HashMap<String, LsaHeader> listOfNeighborMap = new HashMap<>();
+    private Map<String, OspfNbr> listOfNeighbors = new ConcurrentHashMap<>();
+    private Map<String, LsaHeader> listOfNeighborMap = new ConcurrentHashMap<>();
+    private long delay = 0;
+    private InternalHelloTimer helloTimerTask;
+    private InternalWaitTimer waitTimerTask;
+    private InternalDelayedAckTimer delayedAckTimerTask;
+    private ScheduledExecutorService exServiceHello;
+    private ScheduledExecutorService exServiceWait;
+    private ScheduledExecutorService exServiceDelayedAck;
+    private boolean isDelayedAckTimerScheduled = false;
+    private int delayedAckTimerInterval = 2500;
+    private int interfaceTypeOldValue = 0;
+    private TopologyForDeviceAndLink topologyForDeviceAndLink = new TopologyForDeviceAndLinkImpl();
+    private OspfArea ospfArea;
+    private Controller controller;
+
 
     /**
      * Gets the interface state.
@@ -79,6 +125,51 @@
     }
 
     /**
+     * Sets the netty channel.
+     *
+     * @param channel channel
+     */
+    public void setChannel(Channel channel) {
+        this.channel = channel;
+    }
+
+    /**
+     * Returns OSPF area instance.
+     *
+     * @return OSPF area instance
+     */
+    public OspfArea ospfArea() {
+        return ospfArea;
+    }
+
+    /**
+     * Sets OSPF controller instance.
+     *
+     * @param controller OSPF controller instance
+     */
+    public void setController(Controller controller) {
+        this.controller = controller;
+    }
+
+    /**
+     * Sets OSPF area instance.
+     *
+     * @param ospfArea OSPF area instance
+     */
+    public void setOspfArea(OspfArea ospfArea) {
+        this.ospfArea = ospfArea;
+    }
+
+    /**
+     * Gets interface state.
+     *
+     * @return interface state
+     */
+    public String interfaceState() {
+        return state.interfaceState();
+    }
+
+    /**
      * Gets link state headers.
      *
      * @return get the list of lsa headers
@@ -130,6 +221,33 @@
         return listOfNeighbors.get(neighborId);
     }
 
+    /**
+     * Removes all the neighbors.
+     */
+    public void removeNeighbors() {
+        Set<String> neighbors = listOfNeighbors.keySet();
+        for (String neighborId : neighbors) {
+            removeNeighbor(listOfNeighbors.get(neighborId));
+            log.debug("Neighbor removed - {}", neighborId);
+        }
+        listOfNeighbors.clear();
+    }
+
+    /**
+     * Removes neighbor from the interface neighbor map.
+     *
+     * @param ospfNeighbor OSPF neighbor instance
+     */
+    public void removeNeighbor(OspfNbr ospfNeighbor) {
+        log.debug("Neighbor removed - {}", ospfNeighbor.neighborId());
+        ospfNeighbor.stopInactivityTimeCheck();
+        ospfNeighbor.stopFloodingTimer();
+        ospfNeighbor.stopRxMtDdTimer();
+        ospfNeighbor.stopRxMtLsrTimer();
+
+        listOfNeighbors.remove(ospfNeighbor.neighborId());
+    }
+
 
     /**
      * Adds LSAHeader to map.
@@ -175,7 +293,7 @@
      *
      * @return listOfNeighbors as key value pair
      */
-    public HashMap<String, OspfNbr> listOfNeighbors() {
+    public Map<String, OspfNbr> listOfNeighbors() {
         return listOfNeighbors;
     }
 
@@ -189,6 +307,24 @@
     }
 
     /**
+     * Returns interface index.
+     *
+     * @return interface index
+     */
+    public int interfaceIndex() {
+        return interfaceIndex;
+    }
+
+    /**
+     * Set interface index.
+     *
+     * @param interfaceIndex interface index
+     */
+    public void setInterfaceIndex(int interfaceIndex) {
+        this.interfaceIndex = interfaceIndex;
+    }
+
+    /**
      * Gets the IP address.
      *
      * @return IP address
@@ -225,25 +361,6 @@
     }
 
     /**
-     * Gets the area id this interface belongs.
-     *
-     * @return area id this interface belongs
-     */
-    public int areaId() {
-        return areaId;
-    }
-
-
-    /**
-     * Sets the area id this interface belongs.
-     *
-     * @param areaId the area id this interface belongs
-     */
-    public void setAreaId(int areaId) {
-        this.areaId = areaId;
-    }
-
-    /**
      * Gets hello interval time.
      *
      * @return hello interval time
@@ -298,78 +415,6 @@
     }
 
     /**
-     * Gets interface cost.
-     *
-     * @return interface cost
-     */
-    public int interfaceCost() {
-        return interfaceCost;
-    }
-
-    /**
-     * Sets interface cost.
-     *
-     * @param interfaceCost interface cost
-     */
-    public void setInterfaceCost(int interfaceCost) {
-        this.interfaceCost = interfaceCost;
-    }
-
-    /**
-     * Gets authentication type.
-     *
-     * @return authType represents authentication type
-     */
-    public String authType() {
-        return authType;
-    }
-
-    /**
-     * Sets authentication type.
-     *
-     * @param authType authType represents authentication type
-     */
-    public void setAuthType(String authType) {
-        this.authType = authType;
-    }
-
-    /**
-     * Gets authentication key.
-     *
-     * @return authKey represents authentication key
-     */
-    public String authKey() {
-        return authKey;
-    }
-
-    /**
-     * Sets authentication key.
-     *
-     * @param authKey represents authentication key
-     */
-    public void setAuthKey(String authKey) {
-        this.authKey = authKey;
-    }
-
-    /**
-     * Gets poll interval.
-     *
-     * @return pollInterval an integer represents poll interval
-     */
-    public int pollInterval() {
-        return pollInterval;
-    }
-
-    /**
-     * Sets poll interval.
-     *
-     * @param pollInterval an integer represents poll interval
-     */
-    public void setPollInterval(int pollInterval) {
-        this.pollInterval = pollInterval;
-    }
-
-    /**
      * Gets max transfer unit.
      *
      * @return mtu an integer represents max transfer unit
@@ -442,23 +487,1071 @@
     }
 
     /**
-     * Get transmission delay.
+     * Represents an interface is up and connected.
      *
-     * @return transmission delay
+     * @throws Exception might throws exception
      */
-    public int transmitDelay() {
-        return transmitDelay;
+    public void interfaceUp() throws Exception {
+        log.debug("OSPFInterfaceChannelHandler::interfaceUp...!!!");
+        if (interfaceType() == OspfInterfaceType.POINT_TO_POINT.value()) {
+            setState(OspfInterfaceState.POINT2POINT);
+            interfaceTypeOldValue = interfaceType();
+            log.debug("OSPFInterfaceChannelHandler::InterfaceType {} state {} ",
+                      interfaceType(), state());
+        } else if (interfaceType() == OspfInterfaceType.BROADCAST.value()) {
+            //if router priority is 0, move the state to DROther
+            interfaceTypeOldValue = interfaceType();
+            if (routerPriority() == 0) {
+                setState(OspfInterfaceState.DROTHER);
+            } else {
+                log.debug("OSPFInterfaceChannelHandler::InterfaceType {} state {} RouterPriority {}",
+                          interfaceType(),
+                          state(), routerPriority());
+                setState(OspfInterfaceState.WAITING);
+                //start wait timer - like inactivity timer with router deadInterval
+                startWaitTimer();
+            }
+        }
+        // Start hello timer with interval from config - convert seconds to milliseconds
+        startHelloTimer();
+        ospfArea.refreshArea(this);
+    }
+
+
+    /**
+     * Gets called when a BDR was detected before the wait timer expired.
+     *
+     * @param ch channel instance
+     * @throws Exception might throws exception
+     */
+    public void backupSeen(Channel ch) throws Exception {
+        log.debug("OSPFInterfaceChannelHandler::backupSeen ");
+        if (state() == OspfInterfaceState.WAITING) {
+            electRouter(ch);
+        }
     }
 
     /**
-     * Sets transmission delay.
+     * Gets called when no hello message received for particular period.
      *
-     * @param transmitDelay transmission delay
+     * @param ch channel instance
+     * @throws Exception might throws exception
      */
-    public void setTransmitDelay(int transmitDelay) {
-        this.transmitDelay = transmitDelay;
+    public void waitTimer(Channel ch) throws Exception {
+        log.debug("OSPFInterfaceChannelHandler::waitTimer ");
+        //section 9.4
+        if (state() == OspfInterfaceState.WAITING) {
+            electRouter(ch);
+        }
     }
 
+    /**
+     * Initiates DR election process.
+     *
+     * @param ch netty channel instance
+     * @throws Exception might throws exception
+     */
+    public void callDrElection(Channel ch) throws Exception {
+        log.debug("OSPFInterfaceChannelHandler::callDrElection ");
+        //call when timer expired
+        //no hello message received for particular interval
+        //section 9.4
+        electRouter(ch);
+        interfaceTypeOldValue = interfaceType();
+    }
+
+    /**
+     * Neighbor change event is triggered when the router priority gets changed.
+     *
+     * @throws Exception might throws exception
+     */
+    public void neighborChange() throws Exception {
+        log.debug("OSPFInterfaceChannelHandler::neighborChange ");
+        if (state() == OspfInterfaceState.DR || state() == OspfInterfaceState.BDR ||
+                state() == OspfInterfaceState.DROTHER) {
+            electRouter(channel);
+        }
+    }
+
+    /**
+     * Gets called when an interface is down.
+     * All interface variables are reset, and interface timers disabled.
+     * Also all neighbor connections associated with the interface are destroyed.
+     */
+    public void interfaceDown() {
+        log.debug("OSPFInterfaceChannelHandler::interfaceDown ");
+        stopHelloTimer();
+        listOfNeighbors().clear();
+        setState(OspfInterfaceState.DOWN);
+    }
+
+    /**
+     * When an OSPF message received it is handed over to this method.
+     * Based on the type of the OSPF message received it will be handed over
+     * to corresponding message handler methods.
+     *
+     * @param ospfMessage received OSPF message
+     * @param ctx         channel handler context instance.
+     * @throws Exception might throws exception
+     */
+    public void processOspfMessage(OspfMessage ospfMessage, ChannelHandlerContext ctx) throws Exception {
+        log.debug("OspfChannelHandler::processOspfMessage...!!!");
+
+        if (!validateMessage(ospfMessage)) {
+            return;
+        }
+
+        switch (ospfMessage.ospfMessageType().value()) {
+            case OspfParameters.HELLO:
+                processHelloMessage(ospfMessage, ctx);
+                break;
+            case OspfParameters.DD:
+                processDdMessage(ospfMessage, ctx);
+                break;
+            case OspfParameters.LSREQUEST:
+                processLsRequestMessage(ospfMessage, ctx);
+                break;
+            case OspfParameters.LSUPDATE:
+                processLsUpdateMessage(ospfMessage, ctx);
+                break;
+            case OspfParameters.LSACK:
+                processLsAckMessage(ospfMessage, ctx);
+                break;
+            default:
+                log.debug("Unknown packet to process...!!!");
+                break;
+        }
+    }
+
+    /**
+     * Validates the OSPF message received.
+     *
+     * @param ospfMessage OSPF message.
+     * @return true if it is a valid else false.
+     * @throws Exception might throws exception
+     */
+    private boolean validateMessage(OspfMessage ospfMessage) throws Exception {
+        boolean isValid = true;
+        OspfPacketHeader header = (OspfPacketHeader) ospfMessage;
+
+        //added the check to eliminate self origin packets also two interfaces on same router.
+        if (!header.sourceIp().equals(ipAddress()) && !header.routerId().equals(
+                ospfArea.routerId())) {
+            //Verify the checksum
+            ChecksumCalculator checksum = new ChecksumCalculator();
+            if (!checksum.isValidOspfCheckSum(ospfMessage, OspfUtil.OSPFPACKET_CHECKSUM_POS1,
+                                              OspfUtil.OSPFPACKET_CHECKSUM_POS2)) {
+                log.debug("Checksum mismatch. Received packet type {} ", ospfMessage.ospfMessageType());
+                return false;
+            }
+            if (((OspfPacketHeader) ospfMessage).ospfVersion() != OspfUtil.OSPF_VERSION_2) {
+                log.debug("Received osfpMessage Version should match with Interface Version ");
+                return false;
+            }
+            if (!((OspfPacketHeader) ospfMessage).areaId().equals(ospfArea.areaId())) {
+                log.debug("Received ospf packets are from different area than our Area ID. " +
+                                  "Received Area ID {}, Our AreaId {} ",
+                          ((OspfPacketHeader) ospfMessage).areaId(), ospfArea.areaId());
+                return false;
+            }
+
+            //According to RFC-2328 (8.2)
+            /**
+             * ABR should receive packets from backbone 0.0.0.0 as we are not acting as ABR
+             * we are rejecting the packet.
+             */
+            if (((OspfPacketHeader) ospfMessage).areaId().equals(Ip4Address.valueOf("0.0.0.0"))) {
+                log.debug("ABR should receive packets from backbone 0.0.0.0 as we are not acting as " +
+                                  "ABR we are rejecting the ospf packet");
+                return false;
+            }
+            if (interfaceType() == OspfInterfaceType.BROADCAST.value() &&
+                    !OspfUtil.sameNetwork(((OspfPacketHeader) ospfMessage).sourceIp(),
+                                          ipAddress(), ipNetworkMask())) {
+                log.debug("Received packets from different subnets. Discarding...!!!");
+                return false;
+            }
+        } else {
+            isValid = false;
+        }
+
+        return isValid;
+    }
+
+    /**
+     * Processes Hello message.
+     *
+     * @param ospfMessage OSPF message instance.
+     * @param ctx         context instance.
+     * @throws Exception might throws exception
+     */
+    void processHelloMessage(OspfMessage ospfMessage, ChannelHandlerContext ctx) throws Exception {
+        Channel channel = ctx.getChannel();
+        log.debug("OspfChannelHandler::processHelloMessage...!!!");
+        HelloPacket helloPacket = (HelloPacket) ospfMessage;
+
+        // processing of hello packet as per RFC 2328 section 10.5
+        log.debug("OspfChannelHandler::processHelloMessage::Interface Type {} OSPFInterfaceState {} ",
+                  interfaceType(), state());
+
+        if (interfaceType() != OspfInterfaceType.POINT_TO_POINT.value()) {
+            if (!helloPacket.networkMask().equals(ipNetworkMask())) {
+                log.debug("OspfChannelHandler::processHelloMessage::Hello Packet Received does not " +
+                                  "match the same network mask as the configure Interface");
+                return;
+            }
+        }
+        if (helloPacket.helloInterval() != helloIntervalTime()) {
+            log.debug("OspfChannelHandler::processHelloMessage::Hello Packet Received have the same " +
+                              "hello interval as configured Interface");
+            return;
+        }
+        if (helloPacket.routerDeadInterval() != routerDeadIntervalTime()) {
+            log.debug("OspfChannelHandler::processHelloMessage::Hello Packet Received have the same " +
+                              "Router Dead interval as configured Interface");
+            return;
+        }
+
+        if (interfaceType == OspfInterfaceType.POINT_TO_POINT.value() &&
+                !helloPacket.dr().equals(OspfUtil.DEFAULTIP)) {
+            log.debug("OspfChannelHandler::processHelloMessage:: Neighbor in broadcast network");
+            return;
+        }
+
+        if (interfaceType == OspfInterfaceType.POINT_TO_POINT.value()) {
+            // to verify if the neighbor which sent the hello is present in the OSPF Interface neighboring list .
+            OspfNbr nbr;
+            if (!isNeighborInList(helloPacket.routerId().toString())) {
+                nbr = new OspfNbrImpl(ospfArea, this, helloPacket.sourceIp(),
+                                      helloPacket.routerId(), helloPacket.options(), topologyForDeviceAndLink);
+                addNeighbouringRouter(nbr);
+            } else {
+                nbr = neighbouringRouter(helloPacket.routerId().toString());
+                nbr.setRouterPriority(helloPacket.routerPriority());
+            }
+            if (!helloPacket.containsNeighbour(ospfArea.routerId())) {
+                ((OspfNbrImpl) nbr).oneWayReceived(helloPacket, channel);
+            } else {
+                ((OspfNbrImpl) nbr).twoWayReceived(helloPacket, ctx.getChannel());
+            }
+        } else if (interfaceType == OspfInterfaceType.BROADCAST.value()) {
+
+            if (state() == OspfInterfaceState.WAITING) {
+                if ((!helloPacket.dr().equals(Ip4Address.valueOf("0.0.0.0"))) &&
+                        (!helloPacket.bdr().equals(Ip4Address.valueOf("0.0.0.0")))) {
+                    stopWaitTimer();
+                    setDr(helloPacket.dr());
+                    setBdr(helloPacket.bdr());
+                    if (helloPacket.dr().equals(ipAddress())) {
+                        setState(OspfInterfaceState.DR);
+                        //refresh router Lsa
+                        ospfArea.refreshArea(this);
+                    } else if (helloPacket.bdr().equals(ipAddress())) {
+                        setState(OspfInterfaceState.BDR);
+                        //refresh router Lsa
+                        ospfArea.refreshArea(this);
+                    } else {
+                        setState(OspfInterfaceState.DROTHER);
+                        ospfArea.refreshArea(this);
+                    }
+
+                } else if (!helloPacket.dr().equals(Ip4Address.valueOf("0.0.0.0")) ||
+                        !helloPacket.bdr().equals(Ip4Address.valueOf("0.0.0.0"))) {
+                    setDr(helloPacket.dr());
+                    setBdr(helloPacket.bdr());
+                }
+                Ip4Address sourceIp = helloPacket.sourceIp();
+                OspfNbr nbr;
+                if (!isNeighborInList(helloPacket.routerId().toString())) {
+                    nbr = new OspfNbrImpl(ospfArea, this, sourceIp, helloPacket.routerId(),
+                                          helloPacket.options(), topologyForDeviceAndLink);
+                    nbr.setNeighborId(helloPacket.routerId());
+                    nbr.setNeighborBdr(helloPacket.bdr());
+                    nbr.setNeighborDr(helloPacket.dr());
+                    nbr.setRouterPriority(helloPacket.routerPriority());
+                    addNeighbouringRouter(nbr);
+                } else {
+                    nbr = neighbouringRouter(helloPacket.routerId().toString());
+                    nbr.setRouterPriority(helloPacket.routerPriority());
+                }
+                if (!helloPacket.containsNeighbour(ospfArea.routerId())) {
+                    ((OspfNbrImpl) nbr).oneWayReceived(helloPacket, channel);
+                } else {
+                    ((OspfNbrImpl) nbr).twoWayReceived(helloPacket, ctx.getChannel());
+                }
+
+                if (helloPacket.dr().equals(sourceIp)) {
+                    if (helloPacket.bdr().equals(Ip4Address.valueOf("0.0.0.0"))) {
+                        // call backup seen
+                        stopWaitTimer();
+                        backupSeen(ctx.getChannel());
+                    }
+                }
+
+                if (helloPacket.bdr().equals(sourceIp)) {
+                    // call backup seen
+                    stopWaitTimer();
+                    backupSeen(ctx.getChannel());
+                }
+            } else {
+
+                if ((!helloPacket.dr().equals(Ip4Address.valueOf("0.0.0.0")) ||
+                        !helloPacket.bdr().equals(Ip4Address.valueOf("0.0.0.0")))
+                        && routerPriority() == 0) {
+                    setDr(helloPacket.dr());
+                    setBdr(helloPacket.bdr());
+                }
+                //To verify if the neighbor which sent the hello is present in the OSPF Interface neighboring list .
+                Ip4Address sourceIp = helloPacket.sourceIp();
+                OspfNbr nbr;
+                if (!isNeighborInList(helloPacket.routerId().toString())) {
+                    nbr = new OspfNbrImpl(ospfArea, this, sourceIp, helloPacket.routerId(),
+                                          helloPacket.options(), topologyForDeviceAndLink);
+                    nbr.setNeighborId(helloPacket.routerId());
+                    nbr.setNeighborBdr(helloPacket.bdr());
+                    nbr.setNeighborDr(helloPacket.dr());
+                    nbr.setRouterPriority(helloPacket.routerPriority());
+                    addNeighbouringRouter(nbr);
+                    ((OspfNbrImpl) nbr).oneWayReceived(helloPacket, channel);
+                } else {
+                    log.debug("OspfChannelHandler::NeighborInList::helloPacket.bdr(): {}, " +
+                                      "helloPacket.dr(): {}", helloPacket.bdr(), helloPacket.dr());
+                    nbr = neighbouringRouter(helloPacket.routerId().toString());
+                    nbr.setRouterPriority(helloPacket.routerPriority());
+                    if (!helloPacket.containsNeighbour(ospfArea.routerId())) {
+                        ((OspfNbrImpl) nbr).oneWayReceived(helloPacket, channel);
+                    } else {
+                        ((OspfNbrImpl) nbr).twoWayReceived(helloPacket, ctx.getChannel());
+                    }
+                    if (nbr.routerPriority() != helloPacket.routerPriority()) {
+                        nbr.setNeighborBdr(helloPacket.bdr());
+                        nbr.setNeighborDr(helloPacket.dr());
+                        neighborChange();
+                    }
+
+
+                    if (nbr.neighborIpAddr().equals(helloPacket.dr()) &&
+                            !(nbr.neighborIpAddr().equals(nbr.neighborDr()))) {
+                        nbr.setNeighborBdr(helloPacket.bdr());
+                        nbr.setNeighborDr(helloPacket.dr());
+                        neighborChange();
+                    }
+
+                    if (!(nbr.neighborIpAddr().equals(helloPacket.dr())) &&
+                            (nbr.neighborIpAddr().equals(nbr.neighborDr()))) {
+                        nbr.setNeighborBdr(helloPacket.bdr());
+                        nbr.setNeighborDr(helloPacket.dr());
+                        neighborChange();
+                    }
+
+                    if (nbr.neighborIpAddr().equals(helloPacket.bdr()) &&
+                            !(nbr.neighborIpAddr().equals(nbr.neighborBdr()))) {
+                        nbr.setNeighborBdr(helloPacket.bdr());
+                        nbr.setNeighborDr(helloPacket.dr());
+                        neighborChange();
+                    }
+
+                    if (!(nbr.neighborIpAddr().equals(helloPacket.bdr())) &&
+                            (nbr.neighborIpAddr().equals(nbr.neighborBdr()))) {
+                        nbr.setNeighborBdr(helloPacket.bdr());
+                        nbr.setNeighborDr(helloPacket.dr());
+                        neighborChange();
+                    }
+
+                    nbr.setNeighborBdr(helloPacket.bdr());
+                    nbr.setNeighborDr(helloPacket.dr());
+                }
+
+            }
+        }
+    }
+
+    /**
+     * process the DD message which received.
+     *
+     * @param ospfMessage OSPF message instance.
+     * @param ctx         channel handler context instance
+     * @throws Exception might throws exception
+     */
+    void processDdMessage(OspfMessage ospfMessage, ChannelHandlerContext ctx) throws Exception {
+        log.debug("OspfChannelHandler::processDdMessage...!!!");
+        Channel channel = ctx.getChannel();
+        DdPacket ddPacket = (DdPacket) ospfMessage;
+        log.debug("Got DD packet from {}", ddPacket.sourceIp());
+        //check it is present in listOfNeighbors
+        Ip4Address neighbourId = ddPacket.routerId();
+        OspfNbr nbr = neighbouringRouter(neighbourId.toString());
+
+        if (nbr != null) {
+            log.debug("OspfChannelHandler::processDdMessage:: OSPFNeighborState {}", nbr.getState());
+            // set options for the NBR
+            nbr.setIsOpaqueCapable(ddPacket.isOpaqueCapable());
+            if (ddPacket.imtu() > mtu()) {
+                log.debug("the MTU size is greater than the interface MTU");
+                return;
+            }
+            if (nbr.getState() == OspfNeighborState.DOWN) {
+                return;
+            }
+            if (nbr.getState() == OspfNeighborState.ATTEMPT) {
+                return;
+            }
+            if (nbr.getState() == OspfNeighborState.TWOWAY) {
+                nbr.adjOk(channel);
+                return;
+            }
+            //if init is the state call twoWayReceived
+            if (nbr.getState() == OspfNeighborState.INIT) {
+                ((OspfNbrImpl) nbr).twoWayReceived(ddPacket, ctx.getChannel());
+            } else if (nbr.getState() == OspfNeighborState.EXSTART) {
+                //get I,M,MS Bits
+                int initialize = ddPacket.isInitialize();
+                int more = ddPacket.isMore();
+                int masterOrSlave = ddPacket.isMaster();
+                int options = ddPacket.options();
+                nbr.setOptions(options);
+
+                if (initialize == OspfUtil.INITIALIZE_SET && more == OspfUtil.MORE_SET &&
+                        masterOrSlave == OspfUtil.IS_MASTER) {
+                    if (ddPacket.getLsaHeaderList().isEmpty()) {
+                        if (OspfUtil.ipAddressToLong(ddPacket.routerId().toString()) >
+                                OspfUtil.ipAddressToLong(ospfArea.routerId().toString())) {
+                            nbr.setIsMaster(OspfUtil.IS_MASTER);
+                            ((OspfNbrImpl) nbr).setLastDdPacket(ddPacket);
+                            nbr.setDdSeqNum(ddPacket.sequenceNo());
+                            nbr.setOptions(ddPacket.options());
+                            ((OspfNbrImpl) nbr).negotiationDone(ddPacket, true, ddPacket.getLsaHeaderList(),
+                                                                ctx.getChannel());
+                        }
+                    }
+                }
+                if (initialize == OspfUtil.INITIALIZE_NOTSET && masterOrSlave == OspfUtil.NOT_MASTER) {
+                    if (nbr.ddSeqNum() == ddPacket.sequenceNo()) {
+                        if (OspfUtil.ipAddressToLong(ddPacket.routerId().toString()) <
+                                OspfUtil.ipAddressToLong(ospfArea.routerId().toString())) {
+                            ((OspfNbrImpl) nbr).setLastDdPacket(ddPacket);
+                            nbr.setOptions(ddPacket.options());
+                            nbr.setDdSeqNum(nbr.ddSeqNum() + 1);
+                            ((OspfNbrImpl) nbr).negotiationDone(ddPacket, false, ddPacket.getLsaHeaderList(),
+                                                                ctx.getChannel());
+                        }
+                    }
+                }
+
+            } else if (nbr.getState() == OspfNeighborState.EXCHANGE) {
+                //get I,M,MS Bits
+                log.debug("Neighbor state:: EXCHANGE");
+                boolean isDuplicateDDPacket = compareDdPackets(ddPacket, ((OspfNbrImpl) nbr).lastDdPacket());
+                int initialize = ddPacket.isInitialize();
+                int more = ddPacket.isMore();
+                int masterOrSlave = ddPacket.isMaster();
+                int options = ddPacket.options();
+
+                if (!isDuplicateDDPacket) {
+                    //if dd packet is not duplicate  then continue
+                    if (nbr.isMaster() != masterOrSlave) {
+                        DdPacket newResPacket =
+                                (DdPacket) ((OspfNbrImpl) nbr).seqNumMismatch("Master/Slave Inconsistency");
+                        newResPacket.setDestinationIp(ddPacket.sourceIp());
+                        log.debug("Sending back DDPacket to {}", ddPacket.sourceIp());
+                        byte[] messageToWrite = getMessage(newResPacket);
+                        ctx.getChannel().write(messageToWrite);
+                    } else if (initialize == 1) {
+                        DdPacket newResPacket =
+                                (DdPacket) ((OspfNbrImpl) nbr).seqNumMismatch("Initialize bit inconsistency");
+                        newResPacket.setDestinationIp(ddPacket.sourceIp());
+                        log.debug("Sending back DDPacket to {}", ddPacket.sourceIp());
+                        byte[] messageToWrite = getMessage(newResPacket);
+                        ctx.getChannel().write(messageToWrite);
+                    } else {
+
+                        if (masterOrSlave == OspfUtil.NOT_MASTER) {
+                            if (ddPacket.sequenceNo() == nbr.ddSeqNum()) {
+                                //Process the DD Packet
+                                ((OspfNbrImpl) nbr).processDdPacket(false, ddPacket, ctx.getChannel());
+                                log.debug("Received DD Packet");
+                            } else {
+                                DdPacket newResPacket =
+                                        (DdPacket) ((OspfNbrImpl) nbr).seqNumMismatch("Sequence Number Mismatch");
+                                newResPacket.setDestinationIp(ddPacket.sourceIp());
+                                log.debug("Sending back DDPacket to {}", ddPacket.sourceIp());
+                                byte[] messageToWrite = getMessage(newResPacket);
+                                ctx.getChannel().write(messageToWrite);
+                            }
+                        } else {
+                            //we are the slave
+                            if (ddPacket.sequenceNo() == (nbr.ddSeqNum() + 1)) {
+                                ((OspfNbrImpl) nbr).setLastDdPacket(ddPacket);
+                                ((OspfNbrImpl) nbr).processDdPacket(true, ddPacket, ctx.getChannel());
+                                log.debug("Process DD Packet");
+                            } else {
+                                DdPacket newResPacket =
+                                        (DdPacket) ((OspfNbrImpl) nbr).seqNumMismatch("options inconsistency");
+                                newResPacket.setDestinationIp(ddPacket.sourceIp());
+                                log.debug("Sending back DDPacket to {}", ddPacket.sourceIp());
+                                byte[] messageToWrite = getMessage(newResPacket);
+                                ctx.getChannel().write(messageToWrite);
+                            }
+                        }
+                    }
+                } else {
+                    if (masterOrSlave == OspfUtil.NOT_MASTER) {
+                        return;
+                    } else {
+                        DdPacket newResPacket = ((OspfNbrImpl) nbr).lastSentDdPacket();
+                        log.debug("Sending back DDPacket to {}", ddPacket.sourceIp());
+                        byte[] messageToWrite = getMessage(newResPacket);
+                        ctx.getChannel().write(messageToWrite);
+                    }
+                }
+            } else if (nbr.getState() == OspfNeighborState.LOADING || nbr.getState() == OspfNeighborState.FULL) {
+                //In case if we are slave then we have to send the last received DD Packet
+                int options = ddPacket.options();
+                if (nbr.options() != options) {
+                    OspfMessage newResPacket = ((OspfNbrImpl) nbr).seqNumMismatch("Initialize bit inconsistency");
+                    newResPacket.setDestinationIp(ddPacket.sourceIp());
+                    byte[] messageToWrite = getMessage(newResPacket);
+                    ctx.getChannel().write(messageToWrite);
+                } else if (ddPacket.isInitialize() == OspfUtil.INITIALIZE_SET) {
+                    OspfMessage newResPacket = ((OspfNbrImpl) nbr).seqNumMismatch("Initialize bit inconsistency");
+                    newResPacket.setDestinationIp(ddPacket.sourceIp());
+                    byte[] messageToWrite = getMessage(newResPacket);
+                    ctx.getChannel().write(messageToWrite);
+                }
+                boolean isDuplicate = compareDdPackets(ddPacket, ((OspfNbrImpl) nbr).lastDdPacket());
+                //we are master
+                if (nbr.isMaster() != OspfUtil.IS_MASTER) {
+                    // check if the packet is duplicate, duplicates should be discarded by the master
+                    if (isDuplicate) {
+                        log.debug("received a duplicate DD packet");
+                    }
+                } else {
+                    //The slave must respond to duplicates by repeating the last Database Description packet
+                    //that it had sent.
+                    if (isDuplicate) {
+                        ddPacket.setDestinationIp(ddPacket.sourceIp());
+                        byte[] messageToWrite = getMessage(((OspfNbrImpl) nbr).lastSentDdPacket());
+                        ctx.getChannel().write(messageToWrite);
+                        log.debug("Sending back the duplicate packet ");
+                    }
+                }
+            }
+        }
+    }
+
+    /**
+     * Process the Ls Request message.
+     *
+     * @param ospfMessage OSPF message instance.
+     * @param ctx         channel handler context instance.
+     * @throws Exception might throws exception
+     */
+    void processLsRequestMessage(OspfMessage ospfMessage, ChannelHandlerContext ctx) throws Exception {
+        log.debug("OspfChannelHandler::processLsRequestMessage...!!!");
+        Channel channel = ctx.getChannel();
+        LsRequest lsrPacket = (LsRequest) ospfMessage;
+        OspfNbr nbr = neighbouringRouter(lsrPacket.routerId().toString());
+
+        if (nbr.getState() == OspfNeighborState.EXCHANGE || nbr.getState() == OspfNeighborState.LOADING ||
+                nbr.getState() == OspfNeighborState.FULL) {
+
+            LsRequest reqMsg = (LsRequest) ospfMessage;
+            if (reqMsg.getLinkStateRequests().isEmpty()) {
+                log.debug("Received Link State Request Vector is Empty ");
+                return;
+            } else {
+                //Send the LsUpdate back
+                ListIterator<LsRequestPacket> listItr = reqMsg.getLinkStateRequests().listIterator();
+                while (listItr.hasNext()) {
+                    LsUpdate lsupdate = new LsUpdate();
+                    lsupdate.setOspfVer(OspfUtil.OSPF_VERSION);
+                    lsupdate.setOspftype(OspfPacketType.LSUPDATE.value());
+                    lsupdate.setRouterId(ospfArea.routerId());
+                    lsupdate.setAreaId(ospfArea.areaId());
+                    lsupdate.setAuthType(OspfUtil.NOT_ASSIGNED);
+                    lsupdate.setAuthentication(OspfUtil.NOT_ASSIGNED);
+                    lsupdate.setOspfPacLength(OspfUtil.NOT_ASSIGNED); // to calculate packet length
+                    lsupdate.setChecksum(OspfUtil.NOT_ASSIGNED);
+
+                    //limit to mtu
+                    int currentLength = OspfUtil.OSPF_HEADER_LENGTH + OspfUtil.FOUR_BYTES;
+                    int maxSize = mtu() -
+                            OspfUtil.LSA_HEADER_LENGTH; // subtract a normal IP header.
+                    int noLsa = 0;
+                    while (listItr.hasNext()) {
+                        LsRequestPacket lsRequest = (LsRequestPacket) listItr.next();
+                        // to verify length of the LSA
+                        LsaWrapper wrapper = ospfArea.getLsa(lsRequest.lsType(), lsRequest.linkStateId(),
+                                                             lsRequest.ownRouterId());
+                        OspfLsa ospflsa = wrapper.ospfLsa();
+                        if ((currentLength + ((LsaWrapperImpl) wrapper).lsaHeader().lsPacketLen()) >= maxSize) {
+                            listItr.previous();
+                            break;
+                        }
+                        if (ospflsa != null) {
+                            lsupdate.addLsa(ospflsa);
+                            noLsa++;
+
+                            currentLength = currentLength + ((LsaWrapperImpl) wrapper).lsaHeader().lsPacketLen();
+                        } else {
+                            nbr.badLSReq(channel);
+                        }
+                    }
+                    lsupdate.setNumberOfLsa(noLsa);
+                    //set the destination
+                    if (state() == OspfInterfaceState.DR ||
+                            state() == OspfInterfaceState.BDR ||
+                            state() == OspfInterfaceState.POINT2POINT) {
+                        lsupdate.setDestinationIp(OspfUtil.ALL_SPF_ROUTERS);
+                    } else if (state() == OspfInterfaceState.DROTHER) {
+                        lsupdate.setDestinationIp(OspfUtil.ALL_DROUTERS);
+                    }
+                    byte[] messageToWrite = getMessage(lsupdate);
+                    ctx.getChannel().write(messageToWrite);
+                }
+            }
+        }
+    }
+
+    /**
+     * Process the ls update message.
+     *
+     * @param ospfMessage OSPF message instance.
+     * @param ctx         channel handler context instance.
+     * @throws Exception might throws exception
+     */
+    void processLsUpdateMessage(OspfMessage ospfMessage, ChannelHandlerContext ctx) throws Exception {
+        log.debug("OspfChannelHandler::processLsUpdateMessage");
+        LsUpdate lsUpdate = (LsUpdate) ospfMessage;
+        String neighbourId = lsUpdate.routerId().toString();
+        //LSUpdate packet has been associated with a particular neighbor.
+        //Neighbor should not be in lesser state than Exchange.
+        if (isNeighborInList(neighbourId)) {
+            OspfNbrImpl nbr = (OspfNbrImpl) neighbouringRouter(neighbourId);
+            if (nbr.getState() == OspfNeighborState.EXCHANGE ||
+                    nbr.getState() == OspfNeighborState.LOADING) {
+                nbr.processLsUpdate(lsUpdate, ctx.getChannel());
+            } else if (nbr.getState() == OspfNeighborState.FULL) {
+                if (lsUpdate.noLsa() != 0) {
+                    List<OspfLsa> list = lsUpdate.getLsaList();
+                    Iterator itr = list.iterator();
+                    while (itr.hasNext()) {
+                        LsaHeader lsa = (LsaHeader) itr.next();
+                        nbr.processReceivedLsa(lsa, true, ctx.getChannel(), lsUpdate.sourceIp());
+                    }
+                } else {
+                    return;
+                }
+            }
+        }
+    }
+
+    /**
+     * Process the ls acknowledge message.
+     *
+     * @param ospfMessage OSPF message instance.
+     * @param ctx         channel handler context instance.
+     * @throws Exception might throws exception
+     */
+    void processLsAckMessage(OspfMessage ospfMessage, ChannelHandlerContext ctx) throws Exception {
+        log.debug("OspfChannelHandler::processLsAckMessage");
+        LsAcknowledge lsAckPacket = (LsAcknowledge) ospfMessage;
+        //check it is present in listOfNeighbors
+        OspfNbrImpl nbr = (OspfNbrImpl) neighbouringRouter(lsAckPacket.routerId().toString());
+        if (nbr != null) {
+            if (nbr.getState().getValue() < OspfNeighborState.EXCHANGE.getValue()) {
+                // discard the packet.
+                return;
+            } else {
+                // process ls acknowledgements
+                Iterator itr = lsAckPacket.getLinkStateHeaders().iterator();
+                while (itr.hasNext()) {
+                    LsaHeader lsRequest = (LsaHeader) itr.next();
+
+                    OspfLsa ospfLsa =
+                            (OspfLsa) nbr.getPendingReTxList().get(((OspfAreaImpl) ospfArea).getLsaKey(lsRequest));
+                    if (lsRequest != null && ospfLsa != null) {
+                        String isSame = ((OspfLsdbImpl) ospfArea.database()).isNewerOrSameLsa(
+                                lsRequest, (LsaHeader) ospfLsa);
+                        if (isSame.equals("same")) {
+                            nbr.getPendingReTxList().remove(((OspfAreaImpl) ospfArea).getLsaKey(lsRequest));
+                        }
+                    }
+                }
+            }
+        }
+    }
+
+    /**
+     * Compares two Dd Packets to check whether its duplicate or not.
+     *
+     * @param receivedDPacket received DD packet from network.
+     * @param lastDdPacket    Last DdPacket which we sent.
+     * @return true if it is a duplicate packet else false.
+     */
+    public boolean compareDdPackets(DdPacket receivedDPacket, DdPacket lastDdPacket) {
+        if (receivedDPacket.isInitialize() == lastDdPacket.isInitialize()) {
+            if (receivedDPacket.isMaster() == lastDdPacket.isMaster()) {
+                if (receivedDPacket.isMore() == lastDdPacket.isMore()) {
+                    if (receivedDPacket.options() == lastDdPacket.options()) {
+                        if (receivedDPacket.sequenceNo() == lastDdPacket.sequenceNo()) {
+                            return true;
+                        }
+                    }
+                }
+            }
+        }
+        return false;
+    }
+
+    /**
+     * Starts the hello timer which sends hello packet every configured seconds.
+     */
+    public void startHelloTimer() {
+        log.debug("OSPFInterfaceChannelHandler::startHelloTimer");
+        exServiceHello = Executors.newSingleThreadScheduledExecutor();
+        helloTimerTask = new InternalHelloTimer();
+        final ScheduledFuture<?> helloHandle =
+                exServiceHello.scheduleAtFixedRate(helloTimerTask, delay, helloIntervalTime, TimeUnit.SECONDS);
+    }
+
+    /**
+     * Stops the hello timer.
+     */
+    public void stopHelloTimer() {
+        log.debug("OSPFInterfaceChannelHandler::stopHelloTimer ");
+        exServiceHello.shutdown();
+    }
+
+    /**
+     * Starts the wait timer.
+     */
+    public void startWaitTimer() {
+        log.debug("OSPFNbr::startWaitTimer");
+        exServiceWait = Executors.newSingleThreadScheduledExecutor();
+        waitTimerTask = new InternalWaitTimer();
+        final ScheduledFuture<?> waitTimerHandle =
+                exServiceWait.schedule(waitTimerTask, routerDeadIntervalTime(), TimeUnit.SECONDS);
+    }
+
+    /**
+     * Stops the wait timer.
+     */
+    public void stopWaitTimer() {
+        log.debug("OSPFNbr::stopWaitTimer ");
+        exServiceWait.shutdown();
+    }
+
+    /**
+     * Starts the timer which waits for configured seconds and sends Delayed Ack Packet.
+     */
+    public void startDelayedAckTimer() {
+        if (!isDelayedAckTimerScheduled) {
+            log.debug("Started DelayedAckTimer...!!!");
+            exServiceDelayedAck = Executors.newSingleThreadScheduledExecutor();
+            delayedAckTimerTask = new InternalDelayedAckTimer();
+            final ScheduledFuture<?> delayAckHandle =
+                    exServiceDelayedAck.scheduleAtFixedRate(delayedAckTimerTask, delayedAckTimerInterval,
+                                                            delayedAckTimerInterval, TimeUnit.MILLISECONDS);
+            isDelayedAckTimerScheduled = true;
+        }
+    }
+
+    /**
+     * Stops the delayed acknowledge timer.
+     */
+    public void stopDelayedAckTimer() {
+        if (isDelayedAckTimerScheduled) {
+            log.debug("Stopped DelayedAckTimer...!!!");
+            isDelayedAckTimerScheduled = false;
+            exServiceDelayedAck.shutdown();
+        }
+    }
+
+    /**
+     * Performs DR election.
+     *
+     * @param ch Netty Channel instance.
+     * @throws Exception might throws exception
+     */
+    public void electRouter(Channel ch) throws Exception {
+
+        Ip4Address currentDr = dr();
+        Ip4Address currentBdr = bdr();
+        OspfInterfaceState oldState = state();
+        OspfInterfaceState newState;
+
+        log.debug("OSPFInterfaceChannelHandler::electRouter -> currentDr: {}, currentBdr: {}",
+                  currentDr, currentBdr);
+        List<OspfEligibleRouter> eligibleRouters = calculateListOfEligibleRouters(new OspfEligibleRouter());
+
+        log.debug("OSPFInterfaceChannelHandler::electRouter -> eligibleRouters: {}", eligibleRouters);
+        OspfEligibleRouter electedBdr = electBdr(eligibleRouters);
+        OspfEligibleRouter electedDr = electDr(eligibleRouters, electedBdr);
+
+        setBdr(electedBdr.getIpAddress());
+        setDr(electedDr.getIpAddress());
+
+        if (electedBdr.getIpAddress().equals(ipAddress()) &&
+                !electedBdr.getIpAddress().equals(currentBdr)) {
+            setState(OspfInterfaceState.BDR);
+        }
+
+        if (electedDr.getIpAddress().equals(ipAddress()) &&
+                !electedDr.getIpAddress().equals(currentDr)) {
+            setState(OspfInterfaceState.DR);
+        }
+
+        if (state() != oldState &&
+                !(state() == OspfInterfaceState.DROTHER &&
+                        oldState.value() < OspfInterfaceState.DROTHER.value())) {
+            log.debug("Recalculating as the State is changed ");
+            log.debug("OSPFInterfaceChannelHandler::electRouter -> currentDr: {}, currentBdr: {}",
+                      currentDr, currentBdr);
+            eligibleRouters = calculateListOfEligibleRouters(new OspfEligibleRouter());
+
+            log.debug("OSPFInterfaceChannelHandler::electRouter -> eligibleRouters: {}", eligibleRouters);
+            electedBdr = electBdr(eligibleRouters);
+            electedDr = electDr(eligibleRouters, electedBdr);
+
+            setBdr(electedBdr.getIpAddress());
+            setDr(electedDr.getIpAddress());
+        }
+
+        if (electedBdr.getIpAddress().equals(ipAddress()) &&
+                !electedBdr.getIpAddress().equals(currentBdr)) {
+            setState(OspfInterfaceState.BDR);
+            ospfArea.refreshArea(this);
+        }
+
+        if (electedDr.getIpAddress().equals(ipAddress()) &&
+                !electedDr.getIpAddress().equals(currentDr)) {
+            setState(OspfInterfaceState.DR);
+            //Refresh Router Lsa & Network Lsa
+            ospfArea.refreshArea(this);
+        }
+
+        if (currentDr != electedDr.getIpAddress() || currentBdr != electedBdr.getIpAddress()) {
+            Set<String> negibhorIdList;
+            negibhorIdList = listOfNeighbors().keySet();
+            for (String routerid : negibhorIdList) {
+                OspfNbrImpl nbr = (OspfNbrImpl) neighbouringRouter(routerid);
+                if (nbr.getState().getValue() >= OspfNeighborState.TWOWAY.getValue()) {
+                    nbr.adjOk(ch);
+                }
+            }
+        }
+
+        log.debug("OSPFInterfaceChannelHandler::electRouter -> ElectedDR: {}, ElectedBDR: {}",
+                  electedDr.getIpAddress(), electedBdr.getIpAddress());
+    }
+
+
+    /**
+     * BDR Election process. Find the list of eligible router to participate in the process.
+     *
+     * @param electedDr router elected as DR.
+     * @return list of eligible routers
+     */
+    public List<OspfEligibleRouter> calculateListOfEligibleRouters(OspfEligibleRouter electedDr) {
+        log.debug("OSPFNbr::calculateListOfEligibleRouters ");
+        Set<String> neighborIdList;
+        List<OspfEligibleRouter> eligibleRouters = new ArrayList<>();
+
+        neighborIdList = listOfNeighbors().keySet();
+        for (String routerId : neighborIdList) {
+            OspfNbrImpl nbr = (OspfNbrImpl) neighbouringRouter(routerId);
+            if (nbr.getState().getValue() >= OspfNeighborState.TWOWAY.getValue() &&
+                    nbr.routerPriority() > 0) {
+                OspfEligibleRouter router = new OspfEligibleRouter();
+                router.setIpAddress(nbr.neighborIpAddr());
+                router.setRouterId(nbr.neighborId());
+                router.setRouterPriority(nbr.routerPriority());
+                if (nbr.neighborDr().equals(nbr.neighborIpAddr()) ||
+                        electedDr.getIpAddress().equals(nbr.neighborIpAddr())) {
+                    router.setIsDr(true);
+                } else if (nbr.neighborBdr().equals(nbr.neighborIpAddr())) {
+                    router.setIsBdr(true);
+                }
+                eligibleRouters.add(router);
+            }
+        }
+        // interface does not have states like two and all
+        if (routerPriority() > 0) {
+            OspfEligibleRouter router = new OspfEligibleRouter();
+            router.setIpAddress(ipAddress());
+            router.setRouterId(ospfArea.routerId());
+            router.setRouterPriority(routerPriority());
+            if (dr().equals(ipAddress()) ||
+                    electedDr.getIpAddress().equals(ipAddress())) {
+                router.setIsDr(true);
+            } else if (bdr().equals(ipAddress()) &&
+                    !dr().equals(ipAddress())) {
+                router.setIsBdr(true);
+            }
+
+            eligibleRouters.add(router);
+        }
+
+        return eligibleRouters;
+    }
+
+    /**
+     * Based on router priority assigns BDR.
+     *
+     * @param eligibleRouters list of routers to participate in bdr election.
+     * @return OSPF Eligible router instance.
+     */
+    public OspfEligibleRouter electBdr(List<OspfEligibleRouter> eligibleRouters) {
+        log.debug("OSPFInterfaceChannelHandler::electBdr -> eligibleRouters: {}", eligibleRouters);
+        List<OspfEligibleRouter> declaredAsBdr = new ArrayList<>();
+        List<OspfEligibleRouter> notDrAndBdr = new ArrayList<>();
+        for (OspfEligibleRouter router : eligibleRouters) {
+            if (router.isBdr()) {
+                declaredAsBdr.add(router);
+            }
+            if (!router.isBdr() && !router.isDr()) {
+                notDrAndBdr.add(router);
+            }
+        }
+
+        OspfEligibleRouter electedBdr = new OspfEligibleRouter();
+        if (!declaredAsBdr.isEmpty()) {
+            if (declaredAsBdr.size() == 1) {
+                electedBdr = declaredAsBdr.get(0);
+            } else if (declaredAsBdr.size() > 1) {
+                electedBdr = selectRouterBasedOnPriority(declaredAsBdr);
+            }
+        } else {
+            if (notDrAndBdr.size() == 1) {
+                electedBdr = notDrAndBdr.get(0);
+            } else if (notDrAndBdr.size() > 1) {
+                electedBdr = selectRouterBasedOnPriority(notDrAndBdr);
+            }
+        }
+
+        electedBdr.setIsBdr(true);
+        electedBdr.setIsDr(false);
+
+        return electedBdr;
+    }
+
+    /**
+     * DR Election process.
+     *
+     * @param eligibleRouters list of eligible routers.
+     * @param electedBdr      Elected Bdr, OSPF eligible router instance.
+     * @return OSPF eligible router instance.
+     */
+    public OspfEligibleRouter electDr(List<OspfEligibleRouter> eligibleRouters,
+                                      OspfEligibleRouter electedBdr) {
+
+        List<OspfEligibleRouter> declaredAsDr = new ArrayList<>();
+        for (OspfEligibleRouter router : eligibleRouters) {
+            if (router.isDr()) {
+                declaredAsDr.add(router);
+            }
+        }
+
+        OspfEligibleRouter electedDr = new OspfEligibleRouter();
+        if (!declaredAsDr.isEmpty()) {
+            if (declaredAsDr.size() == 1) {
+                electedDr = declaredAsDr.get(0);
+            } else if (eligibleRouters.size() > 1) {
+                electedDr = selectRouterBasedOnPriority(declaredAsDr);
+            }
+        } else {
+            electedDr = electedBdr;
+            electedDr.setIsDr(true);
+            electedDr.setIsBdr(false);
+        }
+
+        return electedDr;
+    }
+
+    /**
+     * DR election process.
+     *
+     * @param routersList list of eligible routers.
+     * @return OSPF eligible router instance.
+     */
+    public OspfEligibleRouter selectRouterBasedOnPriority(List<OspfEligibleRouter> routersList) {
+
+        OspfEligibleRouter initialRouter = routersList.get(0);
+
+        for (int i = 1; i < routersList.size(); i++) {
+            OspfEligibleRouter router = routersList.get(i);
+            if (router.getRouterPriority() > initialRouter.getRouterPriority()) {
+                initialRouter = router;
+            } else if (router.getRouterPriority() == initialRouter.getRouterPriority()) {
+                try {
+                    if (OspfUtil.ipAddressToLong(router.getIpAddress().toString()) >
+                            OspfUtil.ipAddressToLong(initialRouter.getIpAddress().toString())) {
+                        initialRouter = router;
+                    }
+                } catch (Exception e) {
+                    log.debug("OSPFInterfaceChannelHandler::selectRouterBasedOnPriority ->" +
+                                      " eligibleRouters: {}", initialRouter);
+                }
+            }
+        }
+
+        return initialRouter;
+    }
+
+    /**
+     * Adds device information.
+     *
+     * @param ospfRouter OSPF router instance
+     */
+    public void addDeviceInformation(OspfRouter ospfRouter) {
+        controller.addDeviceDetails(ospfRouter);
+    }
+
+    /**
+     * removes device information.
+     *
+     * @param ospfRouter OSPF neighbor instance
+     */
+    public void removeDeviceInformation(OspfRouter ospfRouter) {
+        controller.removeDeviceDetails(ospfRouter);
+    }
+
+    /**
+     * Adds link information.
+     *
+     * @param ospfRouter  OSPF router instance
+     * @param ospfLinkTed list link ted instances
+     */
+    public void addLinkInformation(OspfRouter ospfRouter, OspfLinkTed ospfLinkTed) {
+        controller.addLinkDetails(ospfRouter, ospfLinkTed);
+    }
+
+    /**
+     * Removes link information.
+     *
+     * @param ospfRouter  OSPF router instance
+     * @param ospfLinkTed OSPF link TED instance
+     */
+    public void removeLinkInformation(OspfRouter ospfRouter, OspfLinkTed ospfLinkTed) {
+        controller.removeLinkDetails(ospfRouter, ospfLinkTed);
+    }
+
+    /**
+     * Gets message as bytes.
+     *
+     * @param ospfMessage OSPF message
+     * @return OSPF message
+     */
+    private byte[] getMessage(OspfMessage ospfMessage) {
+        OspfMessageWriter messageWriter = new OspfMessageWriter();
+        if (state().equals(OspfInterfaceState.POINT2POINT)) {
+            ospfMessage.setDestinationIp(OspfUtil.ALL_SPF_ROUTERS);
+        }
+        return (messageWriter.getMessage(ospfMessage, interfaceIndex, state.value()));
+    }
+
+
     @Override
     public boolean equals(Object o) {
         if (this == o) {
@@ -468,32 +1561,24 @@
             return false;
         }
         OspfInterfaceImpl that = (OspfInterfaceImpl) o;
-        return Objects.equal(areaId, that.areaId) &&
-                Objects.equal(helloIntervalTime, that.helloIntervalTime) &&
+        return Objects.equal(helloIntervalTime, that.helloIntervalTime) &&
                 Objects.equal(routerDeadIntervalTime, that.routerDeadIntervalTime) &&
-                Objects.equal(transmitDelay, that.transmitDelay) &&
                 Objects.equal(routerPriority, that.routerPriority) &&
-                Objects.equal(systemInterfaceType, that.systemInterfaceType) &&
                 Objects.equal(interfaceType, that.interfaceType) &&
-                Objects.equal(interfaceCost, that.interfaceCost) &&
-                Objects.equal(pollInterval, that.pollInterval) &&
                 Objects.equal(mtu, that.mtu) &&
                 Objects.equal(reTransmitInterval, that.reTransmitInterval) &&
                 Objects.equal(ipAddress, that.ipAddress) &&
                 Objects.equal(ipNetworkMask, that.ipNetworkMask) &&
                 Objects.equal(listOfNeighbors, that.listOfNeighbors) &&
-                Objects.equal(authType, that.authType) &&
-                Objects.equal(authKey, that.authKey) &&
                 Objects.equal(dr, that.dr) &&
                 Objects.equal(bdr, that.bdr);
     }
 
     @Override
     public int hashCode() {
-        return Objects.hashCode(ipAddress, ipNetworkMask, areaId, helloIntervalTime,
-                                routerDeadIntervalTime, transmitDelay, routerPriority, listOfNeighbors,
-                                systemInterfaceType, interfaceType, interfaceCost, authType, authKey,
-                                pollInterval, mtu, reTransmitInterval, dr, bdr);
+        return Objects.hashCode(ipAddress, ipNetworkMask, helloIntervalTime,
+                                routerDeadIntervalTime, routerPriority, listOfNeighbors,
+                                interfaceType, mtu, reTransmitInterval, dr, bdr);
     }
 
     @Override
@@ -502,19 +1587,188 @@
                 .omitNullValues()
                 .add("ipAddress", ipAddress)
                 .add("routerPriority", routerPriority)
-                .add("areaID", areaId)
                 .add("helloIntervalTime", helloIntervalTime)
                 .add("routerDeadIntervalTime", routerDeadIntervalTime)
                 .add("interfaceType", interfaceType)
-                .add("interfaceCost", interfaceCost)
-                .add("authType", authType)
-                .add("authKey", authKey)
-                .add("pollInterval", pollInterval)
                 .add("mtu", mtu)
                 .add("reTransmitInterval", reTransmitInterval)
                 .add("dr", dr)
                 .add("bdr", bdr)
-                .add("transmitDelay", transmitDelay)
                 .toString();
     }
+
+    /**
+     * Represents a Hello task which sent a hello message every configured time interval.
+     */
+    private class InternalHelloTimer implements Runnable {
+
+        /**
+         * Creates an instance of Hello Timer.
+         */
+        InternalHelloTimer() {
+        }
+
+        @Override
+        public void run() {
+            if (channel != null && channel.isOpen() && channel.isConnected()) {
+                if (interfaceType() == OspfInterfaceType.BROADCAST.value()) {
+                    if (interfaceTypeOldValue != interfaceType()) {
+                        try {
+                            callDrElection(channel);
+                        } catch (Exception e) {
+                            log.debug("Error while calling interfaceUp {}", e.getMessage());
+                        }
+                    }
+                } else {
+                    if (interfaceTypeOldValue != interfaceType()) {
+                        interfaceTypeOldValue = interfaceType();
+                    }
+                }
+                HelloPacket hellopacket = new HelloPacket();
+                //Headers
+                hellopacket.setOspfVer(OspfUtil.OSPF_VERSION);
+                hellopacket.setOspftype(OspfPacketType.HELLO.value());
+                hellopacket.setOspfPacLength(0); //will be modified while encoding
+                hellopacket.setRouterId(ospfArea.routerId());
+                hellopacket.setAreaId(ospfArea.areaId());
+                hellopacket.setChecksum(0); //will be modified while encoding
+                hellopacket.setAuthType(OspfUtil.NOT_ASSIGNED);
+                hellopacket.setAuthentication(OspfUtil.NOT_ASSIGNED);
+                //Body
+                hellopacket.setNetworkMask(ipNetworkMask());
+                hellopacket.setOptions(ospfArea.options());
+                hellopacket.setHelloInterval(helloIntervalTime());
+                hellopacket.setRouterPriority(routerPriority());
+                hellopacket.setRouterDeadInterval(routerDeadIntervalTime());
+                hellopacket.setDr(dr());
+                hellopacket.setBdr(bdr());
+
+                Map<String, OspfNbr> listOfNeighbors = listOfNeighbors();
+                Set<String> keys = listOfNeighbors.keySet();
+                Iterator itr = keys.iterator();
+                while (itr.hasNext()) {
+                    String nbrKey = (String) itr.next();
+                    OspfNbrImpl nbr = (OspfNbrImpl) listOfNeighbors.get(nbrKey);
+                    if (nbr.getState() != OspfNeighborState.DOWN) {
+                        hellopacket.addNeighbor(Ip4Address.valueOf(nbrKey));
+                    }
+                }
+                // build a hello Packet
+                if (channel == null || !channel.isOpen() || !channel.isConnected()) {
+                    log.debug("Hello Packet not sent !!.. Channel Issue...");
+                    return;
+                }
+
+                hellopacket.setDestinationIp(OspfUtil.ALL_SPF_ROUTERS);
+                byte[] messageToWrite = getMessage(hellopacket);
+                ChannelFuture future = channel.write(messageToWrite);
+                if (future.isSuccess()) {
+                    log.debug("Hello Packet successfully sent !!");
+                } else {
+                    future.awaitUninterruptibly();
+                }
+
+            }
+        }
+    }
+
+    /**
+     * Represents a Wait Timer task which waits the interface state to become WAITING.
+     * It initiates DR election process.
+     */
+    private class InternalWaitTimer implements Runnable {
+        Channel ch;
+
+        /**
+         * Creates an instance of Wait Timer.
+         */
+        InternalWaitTimer() {
+            this.ch = channel;
+        }
+
+        @Override
+        public void run() {
+            log.debug("Wait timer expires...");
+            if (ch != null && ch.isConnected()) {
+                try {
+                    waitTimer(ch);
+                } catch (Exception e) {
+                    log.debug("Exception at wait timer ...!!!");
+                }
+
+            }
+        }
+    }
+
+    /**
+     * Represents a task which sent a LS Acknowledge from the link state headers list.
+     */
+    private class InternalDelayedAckTimer implements Runnable {
+        Channel ch;
+
+        /**
+         * Creates an instance of Delayed acknowledge timer.
+         */
+        InternalDelayedAckTimer() {
+            this.ch = channel;
+        }
+
+        @Override
+        public void run() {
+            if (!linkStateHeaders().isEmpty()) {
+                isDelayedAckTimerScheduled = true;
+                if (ch != null && ch.isConnected()) {
+
+                    List<LsaHeader> listOfLsaHeadersAcknowledged = new ArrayList<>();
+                    List<LsaHeader> listOfLsaHeaders = linkStateHeaders();
+                    log.debug("Delayed Ack, Number of Lsa's to Ack {}", listOfLsaHeaders.size());
+                    Iterator itr = listOfLsaHeaders.iterator();
+                    while (itr.hasNext()) {
+                        LsAcknowledge ackContent = new LsAcknowledge();
+                        //Setting OSPF Header
+                        ackContent.setOspfVer(OspfUtil.OSPF_VERSION);
+                        ackContent.setOspftype(OspfPacketType.LSAACK.value());
+                        ackContent.setRouterId(ospfArea.routerId());
+                        ackContent.setAreaId(ospfArea.areaId());
+                        ackContent.setAuthType(OspfUtil.NOT_ASSIGNED);
+                        ackContent.setAuthentication(OspfUtil.NOT_ASSIGNED);
+                        ackContent.setOspfPacLength(OspfUtil.NOT_ASSIGNED);
+                        ackContent.setChecksum(OspfUtil.NOT_ASSIGNED);
+                        //limit to mtu
+                        int currentLength = OspfUtil.OSPF_HEADER_LENGTH;
+                        int maxSize = mtu() -
+                                OspfUtil.LSA_HEADER_LENGTH; // subtract a normal IP header.
+                        while (itr.hasNext()) {
+                            if ((currentLength + OspfUtil.LSA_HEADER_LENGTH) >= maxSize) {
+                                break;
+                            }
+                            LsaHeader lsaHeader = (LsaHeader) itr.next();
+                            ackContent.addLinkStateHeader(lsaHeader);
+                            currentLength = currentLength + OspfUtil.LSA_HEADER_LENGTH;
+                            listOfLsaHeadersAcknowledged.add(lsaHeader);
+                            log.debug("Delayed Ack, Added Lsa's to Ack {}", lsaHeader);
+                        }
+
+                        log.debug("Delayed Ack, Number of Lsa's in LsAck packet {}",
+                                  ackContent.getLinkStateHeaders().size());
+
+                        //set the destination
+                        if (state() == OspfInterfaceState.DR || state() == OspfInterfaceState.BDR
+                                || state() == OspfInterfaceState.POINT2POINT) {
+                            ackContent.setDestinationIp(OspfUtil.ALL_SPF_ROUTERS);
+                        } else if (state() == OspfInterfaceState.DROTHER) {
+                            ackContent.setDestinationIp(OspfUtil.ALL_DROUTERS);
+                        }
+                        byte[] messageToWrite = getMessage(ackContent);
+                        ch.write(messageToWrite);
+
+                        for (LsaHeader lsa : listOfLsaHeadersAcknowledged) {
+                            linkStateHeaders().remove(lsa);
+                            removeLsaFromNeighborMap(((OspfAreaImpl) ospfArea).getLsaKey(lsa));
+                        }
+                    }
+                }
+            }
+        }
+    }
 }
\ No newline at end of file
diff --git a/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/impl/Controller.java b/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/impl/Controller.java
index 3f8f967..cf24080 100755
--- a/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/impl/Controller.java
+++ b/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/impl/Controller.java
@@ -15,13 +15,15 @@
  */
 package org.onosproject.ospf.controller.impl;
 
-import org.jboss.netty.bootstrap.ServerBootstrap;
+import org.jboss.netty.bootstrap.ClientBootstrap;
 import org.jboss.netty.channel.AdaptiveReceiveBufferSizePredictor;
+import org.jboss.netty.channel.ChannelFuture;
+import org.jboss.netty.channel.ChannelFutureListener;
 import org.jboss.netty.channel.ChannelPipelineFactory;
 import org.jboss.netty.channel.FixedReceiveBufferSizePredictorFactory;
-import org.jboss.netty.channel.group.ChannelGroup;
-import org.jboss.netty.channel.group.DefaultChannelGroup;
-import org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory;
+import org.jboss.netty.channel.socket.nio.NioClientSocketChannelFactory;
+import org.onlab.packet.Ip4Address;
+import org.onlab.packet.TpPort;
 import org.onosproject.net.driver.DriverService;
 import org.onosproject.ospf.controller.OspfAgent;
 import org.onosproject.ospf.controller.OspfArea;
@@ -29,42 +31,137 @@
 import org.onosproject.ospf.controller.OspfLinkTed;
 import org.onosproject.ospf.controller.OspfProcess;
 import org.onosproject.ospf.controller.OspfRouter;
+import org.onosproject.ospf.protocol.util.OspfUtil;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import java.net.InetAddress;
 import java.net.InetSocketAddress;
 import java.net.NetworkInterface;
-import java.net.SocketException;
-import java.util.ArrayList;
-import java.util.Collections;
 import java.util.Enumeration;
-import java.util.HashSet;
-import java.util.Iterator;
 import java.util.List;
-import java.util.Set;
-import java.util.concurrent.Executor;
 import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.TimeUnit;
+
+import static org.onlab.util.Tools.groupedThreads;
 
 /**
- * Representation of the main controller class. Handles all setup and network listeners.
+ * Representation of an OSPF controller.
  */
 public class Controller {
-
-    protected static final Logger log = LoggerFactory.getLogger(Controller.class);
     protected static final int BUFFER_SIZE = 4 * 1024 * 1024;
-    private static final String PROCESS = "process";
-    private static final String AREA = "area";
-    private static final String INTERFACE = "interface";
-
-    protected int ospfPort = 7000;
-    protected int workerThreads = 16;
+    private static final Logger log = LoggerFactory.getLogger(Controller.class);
+    private static final int RETRY_INTERVAL = 4;
+    private final int peerWorkerThreads = 16;
     protected long systemStartTime;
+    byte[] configPacket = null;
+    private List<OspfProcess> processes = null;
+    private OspfInterfaceChannelHandler ospfChannelHandler;
+    private NioClientSocketChannelFactory peerExecFactory;
+    private ClientBootstrap peerBootstrap = null;
+    private TpPort isisPort = TpPort.tpPort(OspfUtil.SPORT);
+    private ScheduledExecutorService connectExecutor = null;
+    private int connectRetryCounter = 0;
+    private int connectRetryTime;
     private DriverService driverService;
     private OspfAgent agent;
-    private List<ChannelGroup> cgList = new ArrayList();
-    private List<NioServerSocketChannelFactory> execFactoryLst = new ArrayList<>();
-    private List<OspfProcess> processes;
+
+    /**
+     * Deactivates OSPF controller.
+     */
+    public void isisDeactivate() {
+        peerExecFactory.shutdown();
+    }
+
+    /**
+     * Updates the processes configuration.
+     *
+     * @param ospfProcesses list of OSPF process instances
+     * @throws Exception might throws parse exception
+     */
+    public void updateConfig(List<OspfProcess> ospfProcesses) throws Exception {
+        log.debug("Controller::UpdateConfig called");
+        configPacket = new byte[OspfUtil.CONFIG_LENGTH];
+        byte numberOfInterface = 0; // number of interfaces to configure
+        configPacket[0] = (byte) 0xFF; // its a conf packet - identifier
+        for (OspfProcess ospfProcess : ospfProcesses) {
+            log.debug("OspfProcessDetails : " + ospfProcess);
+            for (OspfArea ospfArea : ospfProcess.areas()) {
+                for (OspfInterface ospfInterface : ospfArea.ospfInterfaceList()) {
+                    log.debug("OspfInterfaceDetails : " + ospfInterface);
+                    numberOfInterface++;
+                    configPacket[2 * numberOfInterface] = (byte) ospfInterface.interfaceIndex();
+                    configPacket[(2 * numberOfInterface) + 1] = (byte) 4;
+                }
+            }
+        }
+        configPacket[1] = numberOfInterface;
+        //First time configuration
+        if (processes == null) {
+            if (ospfProcesses.size() > 0) {
+                processes = ospfProcesses;
+                connectPeer();
+            }
+        } else {
+            ospfChannelHandler.updateInterfaceMap(ospfProcesses);
+            //Send the config packet
+            ospfChannelHandler.sentConfigPacket(configPacket);
+        }
+    }
+
+    /**
+     * Initializes the netty client channel connection.
+     */
+    private void initConnection() {
+        if (peerBootstrap != null) {
+            return;
+        }
+        peerBootstrap = createPeerBootStrap();
+
+        peerBootstrap.setOption("reuseAddress", true);
+        peerBootstrap.setOption("tcpNoDelay", true);
+        peerBootstrap.setOption("keepAlive", true);
+        peerBootstrap.setOption("receiveBufferSize", Controller.BUFFER_SIZE);
+        peerBootstrap.setOption("receiveBufferSizePredictorFactory",
+                                new FixedReceiveBufferSizePredictorFactory(
+                                        Controller.BUFFER_SIZE));
+        peerBootstrap.setOption("receiveBufferSizePredictor",
+                                new AdaptiveReceiveBufferSizePredictor(64, 4096, 65536));
+        peerBootstrap.setOption("child.keepAlive", true);
+        peerBootstrap.setOption("child.tcpNoDelay", true);
+        peerBootstrap.setOption("child.sendBufferSize", Controller.BUFFER_SIZE);
+        peerBootstrap.setOption("child.receiveBufferSize", Controller.BUFFER_SIZE);
+        peerBootstrap.setOption("child.receiveBufferSizePredictorFactory",
+                                new FixedReceiveBufferSizePredictorFactory(
+                                        Controller.BUFFER_SIZE));
+        peerBootstrap.setOption("child.reuseAddress", true);
+
+        ospfChannelHandler = new OspfInterfaceChannelHandler(this, processes);
+        ChannelPipelineFactory pfact = new OspfPipelineFactory(ospfChannelHandler);
+        peerBootstrap.setPipelineFactory(pfact);
+    }
+
+    /**
+     * Creates peer boot strap.
+     *
+     * @return client bootstrap instance
+     */
+    private ClientBootstrap createPeerBootStrap() {
+
+        if (peerWorkerThreads == 0) {
+            peerExecFactory = new NioClientSocketChannelFactory(
+                    Executors.newCachedThreadPool(groupedThreads("onos/isis", "boss-%d")),
+                    Executors.newCachedThreadPool(groupedThreads("onos/isis", "worker-%d")));
+            return new ClientBootstrap(peerExecFactory);
+        } else {
+            peerExecFactory = new NioClientSocketChannelFactory(
+                    Executors.newCachedThreadPool(groupedThreads("onos/isis", "boss-%d")),
+                    Executors.newCachedThreadPool(groupedThreads("onos/isis", "worker-%d")),
+                    peerWorkerThreads);
+            return new ClientBootstrap(peerExecFactory);
+        }
+    }
 
     /**
      * Gets all configured processes.
@@ -106,36 +203,14 @@
     /**
      * Removes link details.
      *
-     * @param ospfRouter OSPF router instance
+     * @param ospfRouter  OSPF router instance
+     * @param ospfLinkTed OSPF link ted instance
      */
-    public void removeLinkDetails(OspfRouter ospfRouter) {
-        agent.deleteLink(ospfRouter);
+    public void removeLinkDetails(OspfRouter ospfRouter, OspfLinkTed ospfLinkTed) {
+        agent.deleteLink(ospfRouter, ospfLinkTed);
     }
 
     /**
-     * Creates a server bootstrap.
-     *
-     * @return ServerBootstrap bootstrap instance
-     */
-    private ServerBootstrap createServerBootStrap() {
-
-        Executor bossPool = Executors.newCachedThreadPool();
-        Executor workerPool = Executors.newCachedThreadPool();
-        NioServerSocketChannelFactory executerFactory;
-
-        if (workerThreads == 0) {
-            executerFactory = new NioServerSocketChannelFactory(bossPool, workerPool);
-            execFactoryLst.add(executerFactory);
-        } else {
-            executerFactory = new NioServerSocketChannelFactory(bossPool, workerPool, workerThreads);
-            execFactoryLst.add(executerFactory);
-        }
-
-        return new ServerBootstrap(executerFactory);
-    }
-
-
-    /**
      * Initializes internal data structures.
      */
     public void init() {
@@ -149,7 +224,7 @@
      * @param driverService driver service instance
      */
     public void start(OspfAgent ag, DriverService driverService) {
-        log.info("Starting OSPF Controller...!!!");
+        log.info("Starting OSPF controller...!!!");
         this.agent = ag;
         this.driverService = driverService;
         this.init();
@@ -159,615 +234,143 @@
      * Stops the Controller.
      */
     public void stop() {
-        log.info("Stopping OSPF Controller...!!!");
-
-        for (ChannelGroup cg : cgList) {
-            cg.close();
-        }
-
-        for (NioServerSocketChannelFactory execFactory : execFactoryLst) {
-            execFactory.shutdown();
-        }
-
+        log.info("Stopping OSPF controller...!!!");
+        isisDeactivate();
         processes.clear();
     }
 
     /**
-     * Deletes configured interface from the area.
+     * Returns interface IP by index.
      *
-     * @param processId         process id
-     * @param areaId            area id
-     * @param interfaceToDelete interface to delete
-     * @return true if operation success else false
+     * @param interfaceIndex interface index
+     * @return interface IP by index
      */
-    public boolean deleteInterfaceFromArea(String processId, String areaId, String interfaceToDelete) {
-        Iterator<OspfProcess> processItr = processes.iterator();
-
-        while (processItr.hasNext()) {
-            OspfProcess process = processItr.next();
-            if (processId.equalsIgnoreCase(process.processId())) {
-                Iterator<OspfArea> areaItr = process.areas().iterator();
-                while (areaItr.hasNext()) {
-                    OspfArea area = areaItr.next();
-                    Iterator<OspfInterface> ospfIntrItr = area.getInterfacesLst().iterator();
-                    if (area.areaId().toString().equalsIgnoreCase(areaId)) {
-                        while (ospfIntrItr.hasNext()) {
-                            OspfInterface ospfIntr = ospfIntrItr.next();
-                            if (interfaceToDelete.equalsIgnoreCase(ospfIntr.ipAddress().toString())) {
-                                ospfIntrItr.remove();
-                                log.debug("Interface With Id {} is removed from Area {}",
-                                          ospfIntr.ipAddress(), ospfIntr.areaId());
-                                return true;
-                            }
-                        }
-                    }
-                }
-            }
-        }
-
-        return false;
-    }
-
-    /*
-    * Checks area with area id exists in process.
-    *
-    * @param processId process id
-    * @param areaId area id
-    * @return true if exist else false
-    */
-    public boolean checkArea(String processId, String areaId) {
-        for (OspfProcess process : processes) {
-            if (processId.equalsIgnoreCase(process.processId())) {
-                for (OspfArea area : process.areas()) {
-                    if (area.areaId().toString().equalsIgnoreCase(areaId)) {
-                        return true;
-                    }
-                }
-            }
-        }
-        return false;
-    }
-
-    /*
-    * Checks process with process id exists or not.
-    *
-    * @param processId process id
-    * @return true if exist else false
-    */
-    public boolean checkProcess(String processId) {
-        log.debug("CheckProcess,Process Id ={} processes={}", processId, processes);
-        for (OspfProcess process : processes) {
-            if (processId.equalsIgnoreCase(process.processId())) {
-                return true;
-            }
-        }
-        return false;
-    }
-
-    /*
-    * Checks interface exists in given area.
-    *
-    * @param processId process id
-    * @param areaId area id
-    * @param ipAddress interface
-    * @return true if exist else false
-    */
-    public boolean checkInterface(String processId, String areaId, String interfaceIp) {
-        for (OspfProcess process : processes) {
-            if (processId.equalsIgnoreCase(process.processId())) {
-                for (OspfArea area : process.areas()) {
-                    if (area.areaId().toString().equalsIgnoreCase(areaId)) {
-                        for (OspfInterface ospfInterface : area.getInterfacesLst()) {
-                            if (ospfInterface.ipAddress().toString().equalsIgnoreCase(interfaceIp)) {
-                                return true;
-                            }
-                        }
-                    }
-                }
-            }
-        }
-        return false;
-    }
-
-    /**
-     * Create processes first time when no process exist.
-     * Create server bootstraps for all the interfaces in the processes.
-     *
-     * @param ospfProcesses list of OSPF processes to create
-     */
-    private void createProcessWhenNoProcessesExists(List<OspfProcess> ospfProcesses) {
-        Set<String> interfaceIpList = new HashSet<>();
-        Set<String> areaIdList = new HashSet<>();
-        if (processes != null) {
-            if (processes.size() == 0) {
-
-                processes.addAll(ospfProcesses);
-                for (OspfProcess process : ospfProcesses) {
-                    for (OspfArea area : process.areas()) {
-                        areaIdList.add(area.areaId().toString());
-                        for (OspfInterface intrfc : area.getInterfacesLst()) {
-                            interfaceIpList.add(intrfc.ipAddress().toString());
-                        }
-                    }
-                }
-                createBootStrapForCreatedInterface(interfaceIpList, areaIdList);
-            }
-        } else {
-            processes = new ArrayList<>();
-            processes.addAll(ospfProcesses);
-
-            for (OspfProcess process : ospfProcesses) {
-                for (OspfArea area : process.areas()) {
-                    areaIdList.add(area.areaId().toString());
-                    for (OspfInterface intrfc : area.getInterfacesLst()) {
-                        interfaceIpList.add(intrfc.ipAddress().toString());
-                    }
-                }
-            }
-            createBootStrapForCreatedInterface(interfaceIpList, areaIdList);
-        }
-    }
-
-    /**
-     * Creates processes when already process exist.
-     * It can be modifying existing process or adding a new process.
-     *
-     * @param ospfProcesses list of processes
-     */
-    private void createProcessWhenProcessesExists(List<OspfProcess> ospfProcesses) {
-        if (ospfProcesses != null) {
-            for (OspfProcess process : ospfProcesses) {
-                if (!checkProcess(process.processId())) {
-                    createNewProcess(process.processId(), process);
-                } else {
-                    List<OspfArea> areas = process.areas();
-                    for (OspfArea area : areas) {
-                        if (!checkArea(process.processId(), area.areaId().toString())) {
-                            createAreaInProcess(process.processId(),
-                                                area.areaId().toString(), area);
-                        } else {
-                            updateAreaInProcess(process.processId(), area.areaId().toString(), area);
-                            for (OspfInterface interfc : area.getInterfacesLst()) {
-                                if (!checkInterface(process.processId(),
-                                                    area.areaId().toString(), interfc.ipAddress().toString())) {
-                                    createInterfaceInAreaInProcess(process.processId(),
-                                                                   area.areaId().toString(), interfc);
-                                } else {
-                                    updateInterfaceParameters(process.processId(),
-                                                              area.areaId().toString(),
-                                                              interfc.ipAddress().toString(), interfc);
-                                }
-                            }
-                        }
-                    }
-                }
-            }
-        }
-    }
-
-    /**
-     * Updates the area information in already started OSPF processes.
-     *
-     * @param processId     process id
-     * @param areaId        area id
-     * @param areaFrmConfig area to update
-     */
-    public void updateAreaInProcess(String processId, String areaId, OspfArea areaFrmConfig) {
-        if (processes != null) {
-            Iterator<OspfProcess> processItr = processes.iterator();
-            while (processItr.hasNext()) {
-                OspfProcess process = processItr.next();
-                if (processId.equalsIgnoreCase(process.processId())) {
-                    Iterator<OspfArea> area = process.areas().iterator();
-                    while (area.hasNext()) {
-                        OspfArea ospfArea = area.next();
-                        if (areaId.equalsIgnoreCase(ospfArea.areaId().toString())) {
-                            ospfArea.setAddressRanges(areaFrmConfig.addressRanges());
-                            ospfArea.setRouterId(areaFrmConfig.routerId());
-                            ospfArea.setTransitCapability(areaFrmConfig.isTransitCapability());
-                            ospfArea.setExternalRoutingCapability(areaFrmConfig.isExternalRoutingCapability());
-                            ospfArea.setStubCost(areaFrmConfig.stubCost());
-                            ospfArea.setOptions(areaFrmConfig.options());
-                            ospfArea.setIsOpaqueEnabled(areaFrmConfig.isOpaqueEnabled());
-                            log.debug("updateAreaInProcess::Process Id::{}::Ospf Area with Id::{}::is " +
-                                              "updated", processId, areaId);
-                        }
-                    }
-                }
-            }
-        }
-    }
-
-    /**
-     * Updates the processes configuration.
-     *
-     * @param ospfProcesses list of OSPF processes
-     */
-    public void updateConfig(List<OspfProcess> ospfProcesses) {
-        log.info("Controller::UpdateConfig called");
-        if (processes != null) {
-            if (processes.size() == 0) {
-                createProcessWhenNoProcessesExists(ospfProcesses);
-            } else {
-                createProcessWhenProcessesExists(ospfProcesses);
-            }
-        } else {
-            createProcessWhenNoProcessesExists(ospfProcesses);
-        }
-    }
-
-    /**
-     * Deletes configuration.
-     *
-     * @param ospfProcesses OSPF processes
-     * @param attribute     attribute to delete
-     */
-    public void deleteConfig(List<OspfProcess> ospfProcesses, String attribute) {
-        log.info("Controller::UpdateConfig called");
-        if (processes != null) {
-            if (processes.size() == 0) {
-                log.debug("DeleteConfig:: No process exists");
-            } else {
-                deleteProcessWhenExists(ospfProcesses, attribute);
-            }
-        } else {
-            log.debug("DeleteConfig:: No process exists");
-        }
-    }
-
-    /**
-     * Creates a new process.
-     *
-     * @param processId process id
-     * @param process   OSPF process instance
-     */
-    private void createNewProcess(String processId, OspfProcess process) {
-        Set<String> interfaceIpList = new HashSet<>();
-        Set<String> areaIdList = new HashSet<>();
-
-        processes.add(process);
-        for (OspfArea area : process.areas()) {
-            areaIdList.add(area.areaId().toString());
-            for (OspfInterface interfc : area.getInterfacesLst()) {
-                interfaceIpList.add(interfc.ipAddress().toString());
-            }
-        }
-        log.debug("createNewProcess::List of areas in process::{} areas::{}", processId, areaIdList);
-
-        createBootStrapForCreatedInterface(interfaceIpList, areaIdList);
-
-        log.debug("createNewProcess:: all processes::{}", processes);
-    }
-
-    /**
-     * Creates a new area information in the process.
-     *
-     * @param processId process id
-     * @param areaId    area id
-     * @param area      OSPF area instance
-     */
-    private void createAreaInProcess(String processId, String areaId, OspfArea area) {
-        Set<String> interfaceIpList = new HashSet<>();
-        Set<String> areaIdList = new HashSet<>();
-
-        Iterator<OspfProcess> processItr = processes.iterator();
-        while (processItr.hasNext()) {
-            OspfProcess process = processItr.next();
-            List<OspfArea> areasInProcess = process.areas();
-            if (processId.equalsIgnoreCase(process.processId())) {
-                areasInProcess.add(area);
-
-                for (OspfInterface intrfc : area.getInterfacesLst()) {
-                    interfaceIpList.add(intrfc.ipAddress().toString());
-                }
-                areaIdList.add(area.areaId().toString());
-                log.debug("createAreaInProcess::List of areas in process Id::{} " +
-                                  "AreaId ::{} update process::{}",
-                          processId, areaId, process);
-            }
-        }
-        createBootStrapForCreatedInterface(interfaceIpList, areaIdList);
-        log.debug("createAreaInProcess:: all processes::{}", processes);
-    }
-
-    /**
-     * Creates an interface in the given area and process.
-     *
-     * @param processId     process id
-     * @param areaId        area id
-     * @param ospfInterface OSPF interface instance
-     */
-    private void createInterfaceInAreaInProcess(String processId,
-                                                String areaId, OspfInterface ospfInterface) {
-        Set<String> interfaceIpList = new HashSet<>();
-        Set<String> areaIdList = new HashSet<>();
-
-        Iterator<OspfProcess> processItr = processes.iterator();
-        while (processItr.hasNext()) {
-            OspfProcess process = processItr.next();
-            List<OspfArea> areasInProcess = process.areas();
-            if (processId.equalsIgnoreCase(process.processId())) {
-                Iterator<OspfArea> areaItr = areasInProcess.iterator();
-                while (areaItr.hasNext()) {
-                    OspfArea area = areaItr.next();
-                    if (areaId.equalsIgnoreCase(area.areaId().toString())) {
-                        area.getInterfacesLst().add(ospfInterface);
-                        interfaceIpList.add(ospfInterface.ipAddress().toString());
-
-                        log.debug("createInterfaceInAreaInProcess::Interface " +
-                                          "updated in process Id::{} AreaId ::{} Interface List{}",
-                                  processId, areaId, area.getInterfacesLst());
-
-                    }
-                }
-            }
-        }
-        createBootStrapForCreatedInterface(interfaceIpList, areaIdList);
-        log.debug("createInterfaceInAreaInProcess:: all processes::{}", processes);
-    }
-
-    /**
-     * Updates interface parameters.
-     *
-     * @param processId     process id
-     * @param areaId        area id
-     * @param interfaceId   interface id
-     * @param ospfInterface OSPF interface instance
-     */
-    private void updateInterfaceParameters(String processId, String areaId, String interfaceId,
-                                           OspfInterface ospfInterface) {
-        Iterator<OspfProcess> processItr = processes.iterator();
-        while (processItr.hasNext()) {
-            OspfProcess process = processItr.next();
-            if (processId.equalsIgnoreCase(process.processId())) {
-                Iterator<OspfArea> areItr = process.areas().iterator();
-                while (areItr.hasNext()) {
-                    OspfArea area = (OspfArea) areItr.next();
-                    if (area.areaId().toString().equalsIgnoreCase(areaId)) {
-                        Iterator<OspfInterface> intfcList = area.getInterfacesLst().iterator();
-                        while (intfcList.hasNext()) {
-                            OspfInterface intrfcObj = intfcList.next();
-                            if (interfaceId.equalsIgnoreCase(intrfcObj.ipAddress().toString())) {
-                                intrfcObj.setPollInterval(ospfInterface.pollInterval());
-                                intrfcObj.setTransmitDelay(ospfInterface.transmitDelay());
-                                intrfcObj.setBdr(ospfInterface.bdr());
-                                intrfcObj.setDr(ospfInterface.dr());
-                                intrfcObj.setAuthKey(ospfInterface.authKey());
-                                intrfcObj.setAuthType(ospfInterface.authType());
-                                intrfcObj.setHelloIntervalTime(ospfInterface.helloIntervalTime());
-                                intrfcObj.setReTransmitInterval(ospfInterface.reTransmitInterval());
-                                intrfcObj.setMtu(ospfInterface.mtu());
-                                intrfcObj.setInterfaceCost(ospfInterface.interfaceCost());
-                                intrfcObj.setInterfaceType(ospfInterface.interfaceType());
-                                intrfcObj.setRouterDeadIntervalTime(ospfInterface.routerDeadIntervalTime());
-                                intrfcObj.setRouterPriority(ospfInterface.routerPriority());
-                                intrfcObj.setIpNetworkMask(ospfInterface.ipNetworkMask());
-                                log.debug("updateInterfaceParameters::Interface updated in " +
-                                                  "process Id::{} AreaId ::{} Interface Id:{} " +
-                                                  "Updated Interface List: {}", processId, areaId,
-                                          interfaceId, intfcList);
-                            }
-                        }
-                    }
-                }
-            }
-        }
-        log.debug("updateInterfaceParameters:: all processes::{}", processes);
-    }
-
-    /**
-     * Creates server bootstrap for interface.
-     *
-     * @param interfaceIPs set of interfaces
-     * @param areaIds      set of area id's
-     */
-    private void createBootStrapForCreatedInterface(Set<String> interfaceIPs, Set<String> areaIds) {
-
-        log.debug("createBootStrapForCreatedInterface:: List of new Interfaces::{}, " +
-                          "List of new areas::{}", interfaceIPs, areaIds);
-        List<String> networkInterfaces = new ArrayList();
-        //get the connected interfaces
-        Enumeration<NetworkInterface> nets = null;
+    private Ip4Address getInterfaceIp(int interfaceIndex) {
+        Ip4Address ipAddress = null;
         try {
-            nets = NetworkInterface.getNetworkInterfaces();
-            // Check NetworkInterfaces and add the IP's
-            for (NetworkInterface netInt : Collections.list(nets)) {
-                // if the interface is up & not loopback
-                if (!netInt.isUp() && !netInt.isLoopback()) {
-                    continue;
-                }
-                //get all the InetAddresses
-                Enumeration<InetAddress> inetAddresses = netInt.getInetAddresses();
-                for (InetAddress inetAddress : Collections.list(inetAddresses)) {
-                    String ipAddress = inetAddress.getHostAddress();
-                    networkInterfaces.add(ipAddress);
+            NetworkInterface networkInterface = NetworkInterface.getByIndex(interfaceIndex);
+            Enumeration ipAddresses = networkInterface.getInetAddresses();
+            while (ipAddresses.hasMoreElements()) {
+                InetAddress address = (InetAddress) ipAddresses.nextElement();
+                if (!address.isLinkLocalAddress()) {
+                    ipAddress = Ip4Address.valueOf(address.getAddress());
+                    break;
                 }
             }
-            //Search for the address in all configured areas interfaces
-            for (OspfProcess process : processes) {
-                for (OspfArea area : process.areas()) {
-                    for (OspfInterface ospfIf : area.getInterfacesLst()) {
-                        String ipFromConfig = ospfIf.ipAddress().toString();
-                        if (interfaceIPs.contains(ipFromConfig)) {
-                            log.debug("Ip address::{} for area {} is newly created" + ipFromConfig);
-                            if (networkInterfaces.contains(ipFromConfig)) {
-                                log.debug("Both Config and Interface have ipAddress {} for area {}",
-                                          ipFromConfig, area.areaId());
-                                // if same IP address create
-                                try {
-                                    log.debug("Creating ServerBootstrap for {} @ {}", ipFromConfig, ospfPort);
+        } catch (Exception e) {
+            log.debug("Error while getting Interface IP by index");
+            return OspfUtil.DEFAULTIP;
+        }
 
-                                    final ServerBootstrap bootstrap = createServerBootStrap();
+        return ipAddress;
+    }
 
-                                    bootstrap.setOption("receiveBufferSize", Controller.BUFFER_SIZE);
-                                    bootstrap.setOption("receiveBufferSizePredictorFactory",
-                                                        new FixedReceiveBufferSizePredictorFactory(
-                                                                Controller.BUFFER_SIZE));
-                                    bootstrap.setOption("reuseAddress", true);
-                                    bootstrap.setOption("tcpNoDelay", true);
-                                    bootstrap.setOption("keepAlive", true);
+    /**
+     * Returns interface mask by index.
+     *
+     * @param interfaceIndex interface index
+     * @return interface IP by index
+     */
+    private String getInterfaceMask(int interfaceIndex) {
+        String subnetMask = null;
+        try {
+            Ip4Address ipAddress = getInterfaceIp(interfaceIndex);
+            NetworkInterface networkInterface = NetworkInterface.getByInetAddress(
+                    InetAddress.getByName(ipAddress.toString()));
+            Enumeration ipAddresses = networkInterface.getInetAddresses();
+            int index = 0;
+            while (ipAddresses.hasMoreElements()) {
+                InetAddress address = (InetAddress) ipAddresses.nextElement();
+                if (!address.isLinkLocalAddress()) {
+                    break;
+                }
+                index++;
+            }
+            int prfLen = networkInterface.getInterfaceAddresses().get(index).getNetworkPrefixLength();
+            int shft = 0xffffffff << (32 - prfLen);
+            int oct1 = ((byte) ((shft & 0xff000000) >> 24)) & 0xff;
+            int oct2 = ((byte) ((shft & 0x00ff0000) >> 16)) & 0xff;
+            int oct3 = ((byte) ((shft & 0x0000ff00) >> 8)) & 0xff;
+            int oct4 = ((byte) (shft & 0x000000ff)) & 0xff;
+            subnetMask = oct1 + "." + oct2 + "." + oct3 + "." + oct4;
+        } catch (Exception e) {
+            log.debug("Error while getting Interface network mask by index");
+            return subnetMask;
+        }
 
-                                    bootstrap.setOption("child.receiveBufferSize", Controller.BUFFER_SIZE);
-                                    bootstrap.setOption("child.receiveBufferSizePredictorFactory",
-                                                        new FixedReceiveBufferSizePredictorFactory(
-                                                                Controller.BUFFER_SIZE));
-                                    bootstrap.setOption("child.reuseAddress", true);
-                                    bootstrap.setOption("child.tcpNoDelay", true);
-                                    bootstrap.setOption("child.keepAlive", true);
-                                    bootstrap.setOption("receiveBufferSizePredictorFactory",
-                                                        new FixedReceiveBufferSizePredictorFactory(
-                                                                Controller.BUFFER_SIZE));
-                                    bootstrap.setOption("receiveBufferSizePredictor",
-                                                        new AdaptiveReceiveBufferSizePredictor(64, 1024, 65536));
+        return subnetMask;
+    }
 
-                                    ChannelPipelineFactory pfact = new OspfPipelineFactory(this, area, ospfIf);
-                                    bootstrap.setPipelineFactory(pfact);
-                                    InetSocketAddress sa = new InetSocketAddress(InetAddress.getByName(ipFromConfig),
-                                                                                 ospfPort);
+    /**
+     * Disconnects the executor.
+     */
+    public void disconnectExecutor() {
+        if (connectExecutor != null) {
+            connectExecutor.shutdown();
+            connectExecutor = null;
+        }
+    }
 
-                                    ChannelGroup cg = new DefaultChannelGroup();
-                                    cg.add(bootstrap.bind(sa));
-                                    cgList.add(cg);
+    /**
+     * Connects to peer.
+     */
+    public void connectPeer() {
+        scheduleConnectionRetry(this.connectRetryTime);
+    }
 
-                                    log.debug("Listening for connections on {}", sa);
+    /**
+     * Retry connection with exponential back-off mechanism.
+     *
+     * @param retryDelay retry delay
+     */
+    private void scheduleConnectionRetry(long retryDelay) {
+        if (this.connectExecutor == null) {
+            this.connectExecutor = Executors.newSingleThreadScheduledExecutor();
+        }
+        this.connectExecutor.schedule(new ConnectionRetry(), retryDelay, TimeUnit.MINUTES);
+    }
 
-                                } catch (Exception e) {
-                                    throw new RuntimeException(e);
-                                }
+    /**
+     * Implements ISIS connection and manages connection to peer with back-off mechanism in case of failure.
+     */
+    class ConnectionRetry implements Runnable {
+        @Override
+        public void run() {
+            log.debug("Connect to peer {}", OspfUtil.SHOST);
+            initConnection();
+            ospfChannelHandler.sentConfigPacket(configPacket);
+            InetSocketAddress connectToSocket = new InetSocketAddress(OspfUtil.SHOST, isisPort.toInt());
+            try {
+                peerBootstrap.connect(connectToSocket).addListener(new ChannelFutureListener() {
+                    @Override
+                    public void operationComplete(ChannelFuture future) throws Exception {
+                        if (!future.isSuccess()) {
+                            connectRetryCounter++;
+                            log.error("Connection failed, ConnectRetryCounter {} remote host {}", connectRetryCounter,
+                                      OspfUtil.SHOST);
+                            /*
+                             * Reconnect to peer on failure is exponential till 4 mins, later on retry after every 4
+                             * mins.
+                             */
+                            if (connectRetryTime < RETRY_INTERVAL) {
+                                connectRetryTime = (connectRetryTime != 0) ? connectRetryTime * 2 : 1;
                             }
+                            scheduleConnectionRetry(connectRetryTime);
                         } else {
-                            log.debug("Ip address::{} for area {} is not newly created" + ipFromConfig);
+                            //Send the config packet
+                            ospfChannelHandler.sentConfigPacket(configPacket);
+                            connectRetryCounter++;
+                            log.info("Connected to remote host {}, Connect Counter {}", OspfUtil.SHOST,
+                                     connectRetryCounter);
+                            disconnectExecutor();
+
+                            return;
                         }
                     }
-                    if (areaIds.contains(area.areaId().toString())) {
-                        area.initializeDb();
-                    }
-                }
-            }
-
-        } catch (SocketException e) {
-            log.error("Error occured due to SocketException::Class::{},Line::{},Method::{}",
-                      e.getStackTrace()[0].getFileName(), e.getStackTrace()[0].getLineNumber(),
-                      e.getStackTrace()[0].getMethodName());
-        }
-    }
-
-    /**
-     * Deletes given process.
-     *
-     * @param ospfProcesses list of OSPF process instance.
-     * @param attribute     attribute to delete
-     */
-    public void deleteProcessWhenExists(List<OspfProcess> ospfProcesses, String attribute) {
-        if (ospfProcesses != null) {
-            for (OspfProcess process : ospfProcesses) {
-                if (checkProcess(process.processId())) {
-                    if (PROCESS.equalsIgnoreCase(attribute)) {
-                        deleteProcess(process.processId(), process);
-                    } else {
-                        List<OspfArea> areas = process.areas();
-                        for (OspfArea area : areas) {
-                            if (checkArea(process.processId(), area.areaId().toString())) {
-                                if (AREA.equalsIgnoreCase(attribute)) {
-                                    deleteAreaFromProcess(process.processId(),
-                                                          area.areaId().toString(), area);
-                                } else {
-                                    for (OspfInterface interfc : area.getInterfacesLst()) {
-                                        if (checkInterface(process.processId(),
-                                                           area.areaId().toString(),
-                                                           interfc.ipAddress().toString())) {
-                                            if (INTERFACE.equalsIgnoreCase(attribute)) {
-                                                deleteInterfaceFromAreaProcess(process.processId(),
-                                                                               area.areaId().toString(),
-                                                                               interfc);
-                                            }
-                                        }
-                                    }
-                                }
-                            }
-                        }
-                    }
-                }
-            }
-        }
-    }
-
-    /**
-     * Deletes given process.
-     *
-     * @param processId process id
-     * @param process   OSPF process instance
-     */
-    private void deleteProcess(String processId, OspfProcess process) {
-        if (processes != null) {
-            Iterator<OspfProcess> itrProcess = processes.iterator();
-            while (itrProcess.hasNext()) {
-                OspfProcess ospfPrs = itrProcess.next();
-                if (processId.equalsIgnoreCase(ospfPrs.processId())) {
-                    itrProcess.remove();
-                }
-            }
-        }
-    }
-
-    /**
-     * Deletes area from process.
-     *
-     * @param processId process id
-     * @param areaId    area id
-     * @param area      OSPF area instance
-     */
-    private void deleteAreaFromProcess(String processId, String areaId, OspfArea area) {
-        if (processes != null) {
-            Iterator<OspfProcess> itrProcess = processes.iterator();
-            while (itrProcess.hasNext()) {
-                OspfProcess ospfPrs = itrProcess.next();
-                if (processId.equalsIgnoreCase(ospfPrs.processId())) {
-                    if (ospfPrs.areas() != null) {
-                        Iterator<OspfArea> itrArea = ospfPrs.areas().iterator();
-                        while (itrArea.hasNext()) {
-                            OspfArea ospfArea = itrArea.next();
-                            if (areaId.equalsIgnoreCase(ospfArea.areaId().toString())) {
-                                itrArea.remove();
-                            }
-                        }
-                    }
-                }
-            }
-        }
-    }
-
-    /**
-     * Deletes interface from area.
-     *
-     * @param processId         process id
-     * @param areaId            area id
-     * @param interfaceToDelete interface to delete
-     */
-    private void deleteInterfaceFromAreaProcess(String processId, String areaId, OspfInterface interfaceToDelete) {
-        if (processes != null) {
-            Iterator<OspfProcess> itrProcess = processes.iterator();
-            while (itrProcess.hasNext()) {
-                OspfProcess ospfPrs = itrProcess.next();
-                if (processId.equalsIgnoreCase(ospfPrs.processId())) {
-                    if (ospfPrs.areas() != null) {
-                        Iterator<OspfArea> itrArea = ospfPrs.areas().iterator();
-                        while (itrArea.hasNext()) {
-                            OspfArea ospfArea = itrArea.next();
-                            if (areaId.equalsIgnoreCase(ospfArea.areaId().toString())) {
-                                if (ospfArea.getInterfacesLst() != null) {
-                                    Iterator<OspfInterface> intrfcList = ospfArea.getInterfacesLst().iterator();
-                                    while (intrfcList.hasNext()) {
-                                        OspfInterface ospfItrfc = intrfcList.next();
-                                        if (interfaceToDelete.ipAddress().equals(ospfItrfc.ipAddress())) {
-                                            intrfcList.remove();
-                                        }
-                                    }
-                                }
-                            }
-                        }
-                    }
-                }
+                });
+            } catch (Exception e) {
+                log.info("Connect peer exception : " + e.toString());
+                disconnectExecutor();
             }
         }
     }
diff --git a/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/impl/OspfConfigUtil.java b/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/impl/OspfConfigUtil.java
new file mode 100755
index 0000000..df566fd
--- /dev/null
+++ b/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/impl/OspfConfigUtil.java
@@ -0,0 +1,297 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.ospf.controller.impl;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import org.onlab.packet.Ip4Address;
+import org.onosproject.ospf.controller.OspfArea;
+import org.onosproject.ospf.controller.OspfInterface;
+import org.onosproject.ospf.controller.OspfProcess;
+import org.onosproject.ospf.controller.area.OspfAreaImpl;
+import org.onosproject.ospf.controller.area.OspfInterfaceImpl;
+import org.onosproject.ospf.controller.area.OspfProcessImpl;
+import org.onosproject.ospf.protocol.util.OspfUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.net.InetAddress;
+import java.net.NetworkInterface;
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.List;
+
+/**
+ * Representation of OSPF network configuration parsing util.
+ */
+public final class OspfConfigUtil {
+    public static final String PROCESSID = "processId";
+    public static final String AREAS = "areas";
+    public static final String INTERFACEINDEX = "interfaceIndex";
+    public static final String AREAID = "areaId";
+    public static final String ROUTERID = "routerId";
+    public static final String INTERFACE = "interface";
+    public static final String HELLOINTERVAL = "helloIntervalTime";
+    public static final String ROUTERDEADINTERVAL = "routerDeadIntervalTime";
+    public static final String INTERFACETYPE = "interfaceType";
+    public static final String EXTERNALROUTINGCAPABILITY = "externalRoutingCapability";
+    protected static final Logger log = LoggerFactory.getLogger(OspfConfigUtil.class);
+    private static final String ISOPAQUE = "isOpaqueEnable";
+
+    /**
+     * Creates an instance of this.
+     */
+    private OspfConfigUtil() {
+
+    }
+
+    /**
+     * Returns list of OSPF process from the json nodes.
+     *
+     * @param jsonNodes json node instance
+     * @return list of OSPF processes.
+     */
+    public static List<OspfProcess> processes(JsonNode jsonNodes) {
+        List<OspfProcess> ospfProcesses = new ArrayList<>();
+        if (jsonNodes == null) {
+            return ospfProcesses;
+        }
+        jsonNodes.forEach(jsonNode -> {
+            List<OspfArea> areas = new ArrayList<>();
+            for (JsonNode areaNode : jsonNode.path(AREAS)) {
+                List<OspfInterface> interfaceList = new ArrayList<>();
+                for (JsonNode interfaceNode : areaNode.path(INTERFACE)) {
+                    OspfInterface ospfInterface = new OspfInterfaceImpl();
+                    String index = interfaceNode.path(INTERFACEINDEX).asText();
+                    if (isValidDigit(index)) {
+                        ospfInterface.setInterfaceIndex(Integer.parseInt(index));
+                    } else {
+                        log.debug("Wrong interface index: {}", index);
+                        continue;
+                    }
+                    ospfInterface.setIpAddress(getInterfaceIp(ospfInterface.interfaceIndex()));
+                    ospfInterface.setIpNetworkMask(Ip4Address.valueOf(getInterfaceMask(
+                            ospfInterface.interfaceIndex())));
+                    ospfInterface.setBdr(OspfUtil.DEFAULTIP);
+                    ospfInterface.setDr(OspfUtil.DEFAULTIP);
+                    String helloInterval = interfaceNode.path(HELLOINTERVAL).asText();
+                    if (isValidDigit(helloInterval)) {
+                        ospfInterface.setHelloIntervalTime(Integer.parseInt(helloInterval));
+                    } else {
+                        log.debug("Wrong hello interval: {}", helloInterval);
+                        continue;
+                    }
+                    String routerDeadInterval = interfaceNode.path(ROUTERDEADINTERVAL).asText();
+                    if (isValidDigit(routerDeadInterval)) {
+                        ospfInterface.setRouterDeadIntervalTime(Integer.parseInt(routerDeadInterval));
+                    } else {
+                        log.debug("Wrong routerDeadInterval: {}", routerDeadInterval);
+                        continue;
+                    }
+                    String interfaceType = interfaceNode.path(INTERFACETYPE).asText();
+                    if (isValidDigit(interfaceType)) {
+                        ospfInterface.setInterfaceType(Integer.parseInt(interfaceType));
+                    } else {
+                        log.debug("Wrong interfaceType: {}", interfaceType);
+                        continue;
+                    }
+                    ospfInterface.setReTransmitInterval(OspfUtil.RETRANSMITINTERVAL);
+                    ospfInterface.setMtu(OspfUtil.MTU);
+                    ospfInterface.setRouterPriority(OspfUtil.ROUTER_PRIORITY);
+                    interfaceList.add(ospfInterface);
+                }
+                OspfArea area = new OspfAreaImpl();
+                String areaId = areaNode.path(AREAID).asText();
+                if (isValidIpAddress(areaId)) {
+                    area.setAreaId(Ip4Address.valueOf(areaId));
+                } else {
+                    log.debug("Wrong areaId: {}", areaId);
+                    continue;
+                }
+                String routerId = areaNode.path(ROUTERID).asText();
+                if (isValidIpAddress(routerId)) {
+                    area.setRouterId(Ip4Address.valueOf(routerId));
+                } else {
+                    log.debug("Wrong routerId: {}", routerId);
+                    continue;
+                }
+                String routingCapability = areaNode.path(EXTERNALROUTINGCAPABILITY).asText();
+                if (isBoolean(routingCapability)) {
+                    area.setExternalRoutingCapability(Boolean.valueOf(routingCapability));
+                } else {
+                    log.debug("Wrong routingCapability: {}", routingCapability);
+                    continue;
+                }
+                String isOpaqueEnabled = areaNode.path(ISOPAQUE).asText();
+                if (isBoolean(isOpaqueEnabled)) {
+                    area.setIsOpaqueEnabled(Boolean.valueOf(isOpaqueEnabled));
+                } else {
+                    log.debug("Wrong isOpaqueEnabled: {}", isOpaqueEnabled);
+                    continue;
+                }
+                area.setOptions(OspfUtil.HELLO_PACKET_OPTIONS);
+                area.setOspfInterfaceList(interfaceList);
+                areas.add(area);
+            }
+            OspfProcess process = new OspfProcessImpl();
+            process.setProcessId(jsonNode.path(PROCESSID).asText());
+            process.setAreas(areas);
+            ospfProcesses.add(process);
+        });
+
+        return ospfProcesses;
+    }
+
+    /**
+     * Returns interface IP by index.
+     *
+     * @param interfaceIndex interface index
+     * @return interface IP by index
+     */
+    private static Ip4Address getInterfaceIp(int interfaceIndex) {
+        Ip4Address ipAddress = null;
+        try {
+            NetworkInterface networkInterface = NetworkInterface.getByIndex(interfaceIndex);
+            Enumeration ipAddresses = networkInterface.getInetAddresses();
+            while (ipAddresses.hasMoreElements()) {
+                InetAddress address = (InetAddress) ipAddresses.nextElement();
+                if (!address.isLinkLocalAddress()) {
+                    ipAddress = Ip4Address.valueOf(address.getAddress());
+                    break;
+                }
+            }
+        } catch (Exception e) {
+            log.debug("Error while getting Interface IP by index");
+            return OspfUtil.DEFAULTIP;
+        }
+        return ipAddress;
+    }
+
+    /**
+     * Returns interface MAC by index.
+     *
+     * @param interfaceIndex interface index
+     * @return interface IP by index
+     */
+    private static String getInterfaceMask(int interfaceIndex) {
+        String subnetMask = null;
+        try {
+            Ip4Address ipAddress = getInterfaceIp(interfaceIndex);
+            NetworkInterface networkInterface = NetworkInterface.getByInetAddress(
+                    InetAddress.getByName(ipAddress.toString()));
+            Enumeration ipAddresses = networkInterface.getInetAddresses();
+            int index = 0;
+            while (ipAddresses.hasMoreElements()) {
+                InetAddress address = (InetAddress) ipAddresses.nextElement();
+                if (!address.isLinkLocalAddress()) {
+                    break;
+                }
+                index++;
+            }
+            int prfLen = networkInterface.getInterfaceAddresses().get(index).getNetworkPrefixLength();
+            int shft = 0xffffffff << (32 - prfLen);
+            int oct1 = ((byte) ((shft & 0xff000000) >> 24)) & 0xff;
+            int oct2 = ((byte) ((shft & 0x00ff0000) >> 16)) & 0xff;
+            int oct3 = ((byte) ((shft & 0x0000ff00) >> 8)) & 0xff;
+            int oct4 = ((byte) (shft & 0x000000ff)) & 0xff;
+            subnetMask = oct1 + "." + oct2 + "." + oct3 + "." + oct4;
+        } catch (Exception e) {
+            log.debug("Error while getting Interface network mask by index");
+            return subnetMask;
+        }
+        return subnetMask;
+    }
+
+    /**
+     * Checks if valid digit or not.
+     *
+     * @param strInput input value
+     * @return true if valid else false
+     */
+    private static boolean isValidDigit(String strInput) {
+        boolean isValid = true;
+        if (isPrimitive(strInput)) {
+            int input = Integer.parseInt(strInput);
+            if (input < 1 || input > 255) {
+                log.debug("Wrong config input value: {}", strInput);
+                isValid = false;
+            } else {
+                isValid = true;
+            }
+
+        } else {
+            isValid = false;
+        }
+
+        return isValid;
+    }
+
+    /**
+     * Checks if primitive or not.
+     *
+     * @param value input value
+     * @return true if number else false
+     */
+    private static boolean isPrimitive(String value) {
+        boolean status = true;
+        value = value.trim();
+        if (value.length() < 1) {
+            return false;
+        }
+        for (int i = 0; i < value.length(); i++) {
+            char c = value.charAt(i);
+            if (!Character.isDigit(c)) {
+                status = false;
+                break;
+            }
+        }
+
+        return status;
+    }
+
+    /**
+     * Checks if boolean or not.
+     *
+     * @param value input value
+     * @return true if boolean else false
+     */
+    private static boolean isBoolean(String value) {
+        boolean status = false;
+        value = value.trim();
+        if (value.equals("true") || value.equals("false")) {
+            return true;
+        }
+
+        return status;
+    }
+
+    /**
+     * Checks if given id is valid or not.
+     *
+     * @param value input value
+     * @return true if valid else false
+     */
+    private static boolean isValidIpAddress(String value) {
+        boolean status = true;
+        try {
+            Ip4Address ipAddress = Ip4Address.valueOf(value);
+        } catch (Exception e) {
+            log.debug("Invalid IP address string: {}", value);
+            return false;
+        }
+
+        return status;
+    }
+}
\ No newline at end of file
diff --git a/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/impl/OspfControllerImpl.java b/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/impl/OspfControllerImpl.java
index 31067fc..83462ee 100755
--- a/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/impl/OspfControllerImpl.java
+++ b/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/impl/OspfControllerImpl.java
@@ -16,6 +16,7 @@
 
 package org.onosproject.ospf.controller.impl;
 
+import com.fasterxml.jackson.databind.JsonNode;
 import com.google.common.collect.Sets;
 import org.apache.felix.scr.annotations.Activate;
 import org.apache.felix.scr.annotations.Component;
@@ -34,7 +35,6 @@
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import java.util.ArrayList;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
@@ -111,27 +111,23 @@
     }
 
     @Override
-    public void updateConfig(List processes) {
-        List<OspfProcess> ospfProcesses = new ArrayList<>();
-        if (processes != null) {
-            for (Object process : processes) {
-                ospfProcesses.add((OspfProcess) process);
+    public void updateConfig(JsonNode processesNode) {
+        try {
+            List<OspfProcess> ospfProcesses = OspfConfigUtil.processes(processesNode);
+            //if there is interface details then update configuration
+            if (ospfProcesses.size() > 0 &&
+                    ospfProcesses.get(0).areas() != null && ospfProcesses.get(0).areas().size() > 0 &&
+                    ospfProcesses.get(0).areas().get(0) != null &&
+                    ospfProcesses.get(0).areas().get(0).ospfInterfaceList().size() > 0) {
+                ctrl.updateConfig(ospfProcesses);
             }
+        } catch (Exception e) {
+            log.debug("Error::updateConfig::{}", e.getMessage());
         }
-        log.debug("updateConfig::OspfList::processes::{}", ospfProcesses);
-        ctrl.updateConfig(ospfProcesses);
     }
 
     @Override
     public void deleteConfig(List<OspfProcess> processes, String attribute) {
-        List<OspfProcess> ospfProcesses = new ArrayList<>();
-        if (processes != null) {
-            for (Object process : processes) {
-                ospfProcesses.add((OspfProcess) process);
-            }
-        }
-        log.debug("deleteConfig::OspfList::processes::{}", ospfProcesses);
-        ctrl.deleteConfig(ospfProcesses, attribute);
     }
 
     /**
@@ -163,9 +159,9 @@
         }
 
         @Override
-        public void deleteLink(OspfRouter ospfRouter) {
+        public void deleteLink(OspfRouter ospfRouter, OspfLinkTed ospfLinkTed) {
             for (OspfLinkListener l : linkListener()) {
-                l.deleteLink(ospfRouter);
+                l.deleteLink(ospfRouter, ospfLinkTed);
             }
         }
     }
diff --git a/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/impl/OspfInterfaceChannelHandler.java b/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/impl/OspfInterfaceChannelHandler.java
index 1a2e687..09a428f 100755
--- a/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/impl/OspfInterfaceChannelHandler.java
+++ b/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/impl/OspfInterfaceChannelHandler.java
@@ -13,13 +13,9 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
 package org.onosproject.ospf.controller.impl;
 
-import org.apache.felix.scr.annotations.Reference;
-import org.apache.felix.scr.annotations.ReferenceCardinality;
 import org.jboss.netty.channel.Channel;
-import org.jboss.netty.channel.ChannelFuture;
 import org.jboss.netty.channel.ChannelHandlerContext;
 import org.jboss.netty.channel.ChannelStateEvent;
 import org.jboss.netty.channel.ExceptionEvent;
@@ -27,235 +23,203 @@
 import org.jboss.netty.handler.timeout.IdleStateAwareChannelHandler;
 import org.jboss.netty.handler.timeout.ReadTimeoutException;
 import org.onlab.packet.Ip4Address;
-import org.onosproject.ospf.controller.LsaWrapper;
 import org.onosproject.ospf.controller.OspfArea;
 import org.onosproject.ospf.controller.OspfInterface;
-import org.onosproject.ospf.controller.OspfLinkTed;
-import org.onosproject.ospf.controller.OspfLsa;
+import org.onosproject.ospf.controller.OspfMessage;
 import org.onosproject.ospf.controller.OspfNbr;
-import org.onosproject.ospf.controller.OspfNeighborState;
-import org.onosproject.ospf.controller.OspfRouter;
-import org.onosproject.ospf.controller.TopologyForDeviceAndLink;
-import org.onosproject.ospf.controller.area.OspfAreaImpl;
+import org.onosproject.ospf.controller.OspfProcess;
 import org.onosproject.ospf.controller.area.OspfInterfaceImpl;
-import org.onosproject.ospf.controller.lsdb.LsaWrapperImpl;
-import org.onosproject.ospf.controller.lsdb.OspfLsdbImpl;
-import org.onosproject.ospf.controller.util.OspfEligibleRouter;
 import org.onosproject.ospf.controller.util.OspfInterfaceType;
 import org.onosproject.ospf.exceptions.OspfParseException;
-import org.onosproject.ospf.protocol.lsa.LsaHeader;
-import org.onosproject.ospf.protocol.ospfpacket.OspfMessage;
-import org.onosproject.ospf.protocol.ospfpacket.OspfPacketHeader;
-import org.onosproject.ospf.protocol.ospfpacket.subtype.LsRequestPacket;
-import org.onosproject.ospf.protocol.ospfpacket.types.DdPacket;
-import org.onosproject.ospf.protocol.ospfpacket.types.HelloPacket;
-import org.onosproject.ospf.protocol.ospfpacket.types.LsAcknowledge;
-import org.onosproject.ospf.protocol.ospfpacket.types.LsRequest;
-import org.onosproject.ospf.protocol.ospfpacket.types.LsUpdate;
-import org.onosproject.ospf.protocol.util.ChecksumCalculator;
 import org.onosproject.ospf.protocol.util.OspfInterfaceState;
-import org.onosproject.ospf.protocol.util.OspfPacketType;
-import org.onosproject.ospf.protocol.util.OspfParameters;
-import org.onosproject.ospf.protocol.util.OspfUtil;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import java.io.IOException;
 import java.nio.channels.ClosedChannelException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
 import java.util.List;
-import java.util.ListIterator;
-import java.util.Set;
-import java.util.concurrent.Executors;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.RejectedExecutionException;
-import java.util.concurrent.ScheduledExecutorService;
-import java.util.concurrent.ScheduledFuture;
-import java.util.concurrent.TimeUnit;
 
 /**
  * Channel handler deals with the OSPF channel connection.
- * Also it dispatches messages to the appropriate handlers.
+ * Also it dispatches messages to the appropriate handlers for processing.
  */
 public class OspfInterfaceChannelHandler extends IdleStateAwareChannelHandler {
 
-    private static final Logger log =
-            LoggerFactory.getLogger(OspfInterfaceChannelHandler.class);
-    @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
-    private OspfInterface ospfInterface;
-    private OspfArea ospfArea;
-    private boolean isClosed = false;
+    private static final Logger log = LoggerFactory.getLogger(OspfInterfaceChannelHandler.class);
+    private static Map<Integer, Object> isisDb = null;
+    private Channel channel = null;
     private Controller controller;
-    private Channel channel;
-    private long delay = 0;
-    private InternalHelloTimer helloTimerTask;
-    private InternalWaitTimer waitTimerTask;
-    private InternalDelayedAckTimer delayedAckTimerTask;
-    private ScheduledExecutorService exServiceHello;
-    private ScheduledExecutorService exServiceWait;
-    private ScheduledExecutorService exServiceDelayedAck;
-    private boolean isDelayedAckTimerScheduled = false;
-    private int delayedAckTimerInterval = 2500;
-    private TopologyForDeviceAndLink topologyForDeviceAndLink;
-
-    public OspfInterfaceChannelHandler() {
-
-    }
+    private List<OspfProcess> processes = null;
+    private byte[] configPacket = null;
+    private Map<Integer, OspfInterface> ospfInterfaceMap = new ConcurrentHashMap<>();
 
     /**
      * Creates an instance of OSPF channel handler.
      *
-     * @param controller    controller instance
-     * @param ospfArea      ospf area instance
-     * @param ospfInterface ospf interface instance
+     * @param controller controller instance
+     * @param processes  list of configured processes
      */
-    public OspfInterfaceChannelHandler(Controller controller, OspfArea ospfArea, OspfInterface ospfInterface) {
-
-        this.ospfArea = ospfArea;
-        this.ospfInterface = ospfInterface;
+    public OspfInterfaceChannelHandler(Controller controller, List<OspfProcess> processes) {
         this.controller = controller;
-        ((OspfInterfaceImpl) ospfInterface).setState(OspfInterfaceState.DOWN);
-        this.ospfInterface.setDr(Ip4Address.valueOf("0.0.0.0"));
-        this.ospfInterface.setBdr(Ip4Address.valueOf("0.0.0.0"));
-        this.topologyForDeviceAndLink = new TopologyForDeviceAndLinkImpl();
+        this.processes = processes;
     }
 
     /**
-     * Represents an interface is up and connected.
+     * Initializes the interface map with interface details.
      *
      * @throws Exception might throws exception
      */
-    public void interfaceUp() throws Exception {
-        log.debug("OSPFInterfaceChannelHandler::interfaceUp...!!!");
-        if (ospfInterface.interfaceType() == OspfInterfaceType.POINT_TO_POINT.value()) {
-            ((OspfInterfaceImpl) ospfInterface).setState(OspfInterfaceState.POINT2POINT);
-            log.debug("OSPFInterfaceChannelHandler::InterfaceType {} state {} ",
-                      ospfInterface.interfaceType(), ((OspfInterfaceImpl) ospfInterface).state());
-        } else if (ospfInterface.interfaceType() == OspfInterfaceType.BROADCAST.value()) {
-            //if router priority is 0, move the state to DROther
-            if (ospfInterface.routerPriority() == 0) {
-                ((OspfInterfaceImpl) ospfInterface).setState(OspfInterfaceState.DROTHER);
-            } else {
-                log.debug("OSPFInterfaceChannelHandler::InterfaceType {} state {} RouterPriority {}",
-                          ospfInterface.interfaceType(),
-                          ((OspfInterfaceImpl) ospfInterface).state(), ospfInterface.routerPriority());
-                ((OspfInterfaceImpl) ospfInterface).setState(OspfInterfaceState.WAITING);
-                //start wait timer - like inactivity timer with router deadInterval
-                startWaitTimer();
+    public void initializeInterfaceMap() throws Exception {
+        for (OspfProcess process : processes) {
+            for (OspfArea area : process.areas()) {
+                for (OspfInterface ospfInterface : area.ospfInterfaceList()) {
+                    OspfInterface anInterface = ospfInterfaceMap.get(ospfInterface.interfaceIndex());
+                    if (anInterface == null) {
+                        ospfInterface.setOspfArea(area);
+                        ((OspfInterfaceImpl) ospfInterface).setController(controller);
+                        ((OspfInterfaceImpl) ospfInterface).setState(OspfInterfaceState.DOWN);
+                        ospfInterface.setDr(Ip4Address.valueOf("0.0.0.0"));
+                        ospfInterface.setBdr(Ip4Address.valueOf("0.0.0.0"));
+                        ospfInterfaceMap.put(ospfInterface.interfaceIndex(), ospfInterface);
+                    }
+                    ((OspfInterfaceImpl) ospfInterface).setChannel(channel);
+                    ospfInterface.interfaceUp();
+                    ospfInterface.startDelayedAckTimer();
+                }
+                //Initialize the LSDB and aging process
+                area.initializeDb();
             }
-
         }
-        // Start hello timer with interval from config - convert seconds to milliseconds
-        startHelloTimer(ospfInterface.helloIntervalTime());
-        ospfArea.refreshArea(ospfInterface);
     }
 
-
     /**
-     * Gets called when a BDR was detected before the wait timer expired.
+     * Updates the interface map with interface details.
      *
-     * @param ch channel instance
+     * @param ospfProcesses updated process instances
      * @throws Exception might throws exception
      */
-    public void backupSeen(Channel ch) throws Exception {
-        log.debug("OSPFInterfaceChannelHandler::backupSeen ");
-        if (((OspfInterfaceImpl) ospfInterface).state() == OspfInterfaceState.WAITING) {
-            electRouter(ch);
+    public void updateInterfaceMap(List<OspfProcess> ospfProcesses) throws Exception {
+        for (OspfProcess ospfUpdatedProcess : ospfProcesses) {
+            for (OspfArea updatedArea : ospfUpdatedProcess.areas()) {
+                for (OspfInterface ospfUpdatedInterface : updatedArea.ospfInterfaceList()) {
+                    OspfInterface ospfInterface = ospfInterfaceMap.get(ospfUpdatedInterface.interfaceIndex());
+                    if (ospfInterface == null) {
+                        ospfUpdatedInterface.setOspfArea(updatedArea);
+                        ((OspfInterfaceImpl) ospfUpdatedInterface).setController(controller);
+                        ((OspfInterfaceImpl) ospfUpdatedInterface).setState(OspfInterfaceState.DOWN);
+                        ospfUpdatedInterface.setDr(Ip4Address.valueOf("0.0.0.0"));
+                        ospfUpdatedInterface.setBdr(Ip4Address.valueOf("0.0.0.0"));
+                        ospfInterfaceMap.put(ospfUpdatedInterface.interfaceIndex(), ospfUpdatedInterface);
+                        ((OspfInterfaceImpl) ospfUpdatedInterface).setChannel(channel);
+                        ospfUpdatedInterface.interfaceUp();
+                        ospfUpdatedInterface.startDelayedAckTimer();
+                    } else {
+                        ospfInterface.setOspfArea(updatedArea);
+
+                        if (ospfInterface.routerDeadIntervalTime() != ospfUpdatedInterface.routerDeadIntervalTime()) {
+                            ospfInterface.setRouterDeadIntervalTime(ospfUpdatedInterface.routerDeadIntervalTime());
+                            Map<String, OspfNbr> neighbors = ospfInterface.listOfNeighbors();
+                            for (String key : neighbors.keySet()) {
+                                OspfNbr ospfNbr = ospfInterface.neighbouringRouter(key);
+                                ospfNbr.setRouterDeadInterval(ospfInterface.routerDeadIntervalTime());
+                                ospfNbr.stopInactivityTimeCheck();
+                                ospfNbr.startInactivityTimeCheck();
+                            }
+                        }
+                        if (ospfInterface.interfaceType() != ospfUpdatedInterface.interfaceType()) {
+                            ospfInterface.setInterfaceType(ospfUpdatedInterface.interfaceType());
+                            if (ospfInterface.interfaceType() == OspfInterfaceType.POINT_TO_POINT.value()) {
+                                ospfInterface.setDr(Ip4Address.valueOf("0.0.0.0"));
+                                ospfInterface.setBdr(Ip4Address.valueOf("0.0.0.0"));
+                            }
+                            ospfInterface.removeNeighbors();
+                        }
+                        if (ospfInterface.helloIntervalTime() != ospfUpdatedInterface.helloIntervalTime()) {
+                            ospfInterface.setHelloIntervalTime(ospfUpdatedInterface.helloIntervalTime());
+                            ospfInterface.stopHelloTimer();
+                            ospfInterface.startHelloTimer();
+                        }
+                        ospfInterfaceMap.put(ospfInterface.interfaceIndex(), ospfInterface);
+                    }
+                }
+            }
         }
     }
 
     /**
-     * Gets called when no hello message received for particular period.
-     *
-     * @param ch channel instance
-     * @throws Exception might throws exception
+     * Initialize channel, start hello sender and initialize LSDB.
      */
-    public void waitTimer(Channel ch) throws Exception {
-        log.debug("OSPFInterfaceChannelHandler::waitTimer ");
-        //section 9.4
-        if (((OspfInterfaceImpl) ospfInterface).state() == OspfInterfaceState.WAITING) {
-            electRouter(ch);
+    private void initialize() throws Exception {
+        log.debug("OspfChannelHandler initialize..!!!");
+        if (configPacket != null) {
+            log.debug("OspfChannelHandler initialize -> sentConfig packet of length ::"
+                              + configPacket.length);
+            sentConfigPacket(configPacket);
         }
-    }
-
-    /**
-     * Neighbor change event is triggered when the router priority gets changed.
-     *
-     * @throws Exception might throws exception
-     */
-    public void neighborChange() throws Exception {
-        log.debug("OSPFInterfaceChannelHandler::neighborChange ");
-        if (((OspfInterfaceImpl) ospfInterface).state() == OspfInterfaceState.DR ||
-                ((OspfInterfaceImpl) ospfInterface).state() == OspfInterfaceState.BDR ||
-                ((OspfInterfaceImpl) ospfInterface).state() == OspfInterfaceState.DROTHER) {
-            electRouter(channel);
-        }
-    }
-
-    /**
-     * Gets called when an interface is down.
-     * All interface variables are reset, and interface timers disabled.
-     * Also all neighbor connections associated with the interface are destroyed.
-     */
-    public void interfaceDown() {
-        log.debug("OSPFInterfaceChannelHandler::interfaceDown ");
-        stopHelloTimer();
-        ospfInterface.listOfNeighbors().clear();
-        ((OspfInterfaceImpl) ospfInterface).setState(OspfInterfaceState.DOWN);
+        initializeInterfaceMap();
     }
 
     @Override
     public void channelConnected(ChannelHandlerContext ctx, ChannelStateEvent evt) throws Exception {
         log.info("OSPF channelConnected from {}", evt.getChannel().getRemoteAddress());
-        channel = evt.getChannel();
-        interfaceUp();
-        startDelayedAckTimer();
+        this.channel = evt.getChannel();
+        initialize();
     }
 
     @Override
     public void channelDisconnected(ChannelHandlerContext ctx, ChannelStateEvent evt) {
-        interfaceDown();
-        stopDelayedAckTimer();
         log.debug("OspfChannelHandler::channelDisconnected...!!!");
-    }
 
-    @Override
-    public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) throws Exception {
-        log.info("[exceptionCaught]: " + e.toString());
-        if (e.getCause() instanceof ReadTimeoutException) {
-            // device timeout
-            log.error("Disconnecting device {} due to read timeout", e.getChannel().getRemoteAddress());
-            return;
-        } else if (e.getCause() instanceof ClosedChannelException) {
-            log.debug("Channel for OSPF {} already closed", e.getChannel().getRemoteAddress());
-        } else if (e.getCause() instanceof IOException) {
-            log.error("Disconnecting OSPF {} due to IO Error: {}", e.getChannel().getRemoteAddress(),
-                      e.getCause().getMessage());
-            if (log.isDebugEnabled()) {
-                log.debug("StackTrace for previous Exception: {}", e.getCause());
+        for (Integer interfaceIndex : ospfInterfaceMap.keySet()) {
+            OspfInterface anInterface = ospfInterfaceMap.get(interfaceIndex);
+            if (anInterface != null) {
+                anInterface.interfaceDown();
+                anInterface.stopDelayedAckTimer();
             }
-        } else if (e.getCause() instanceof OspfParseException) {
-            OspfParseException errMsg = (OspfParseException) e.getCause();
-            byte errorCode = errMsg.errorCode();
-            byte errorSubCode = errMsg.errorSubCode();
-            log.error("Error while parsing message from OSPF {}, ErrorCode {}",
-                      e.getChannel().getRemoteAddress(), errorCode);
-        } else if (e.getCause() instanceof RejectedExecutionException) {
-            log.warn("Could not process message: queue full");
-        } else {
-            log.error("Error while processing message from OSPF {}, state {}",
-                      e.getChannel().getRemoteAddress(), ((OspfInterfaceImpl) ospfInterface).state());
+        }
+
+        if (controller != null) {
+            controller.connectPeer();
         }
     }
 
     @Override
-    public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception {
+    public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent
+            e) throws Exception {
+        log.debug("[exceptionCaught]: " + e.toString());
+        if (e.getCause() instanceof ReadTimeoutException) {
+            log.debug("Disconnecting device {} due to read timeout", e.getChannel().getRemoteAddress());
+            return;
+        } else if (e.getCause() instanceof ClosedChannelException) {
+            log.debug("Channel for OSPF {} already closed", e.getChannel().getRemoteAddress());
+        } else if (e.getCause() instanceof IOException) {
+            log.debug("Disconnecting OSPF {} due to IO Error: {}", e.getChannel().getRemoteAddress(),
+                      e.getCause().getMessage());
+        } else if (e.getCause() instanceof OspfParseException) {
+            OspfParseException errMsg = (OspfParseException) e.getCause();
+            byte errorCode = errMsg.errorCode();
+            byte errorSubCode = errMsg.errorSubCode();
+            log.debug("Error while parsing message from OSPF {}, ErrorCode {}",
+                      e.getChannel().getRemoteAddress(), errorCode);
+        } else if (e.getCause() instanceof RejectedExecutionException) {
+            log.debug("Could not process message: queue full");
+        } else {
+            log.debug("Error while processing message from OSPF {}, {}",
+                      e.getChannel().getRemoteAddress(), e.getCause().getMessage());
+        }
+    }
+
+    @Override
+    public void messageReceived(ChannelHandlerContext ctx, MessageEvent
+            e) throws Exception {
         log.debug("OspfChannelHandler::messageReceived...!!!");
         Object message = e.getMessage();
         if (message instanceof List) {
             List<OspfMessage> ospfMessageList = (List<OspfMessage>) message;
-            log.debug("OspfChannelHandler::List of OspfMessages Size {}", ospfMessageList.size());
+            log.debug("OspfChannelHandler::List of IsisMessages Size {}", ospfMessageList.size());
             if (ospfMessageList != null) {
                 for (OspfMessage ospfMessage : ospfMessageList) {
                     processOspfMessage(ospfMessage, ctx);
@@ -280,1121 +244,28 @@
      * @param ctx         channel handler context instance.
      * @throws Exception might throws exception
      */
-    public void processOspfMessage(OspfMessage ospfMessage, ChannelHandlerContext ctx) throws Exception {
+    public void processOspfMessage(OspfMessage
+                                           ospfMessage, ChannelHandlerContext ctx) throws Exception {
         log.debug("OspfChannelHandler::processOspfMessage...!!!");
-
-        if (!validateMessage(ospfMessage)) {
-            return;
-        }
-
-        switch (ospfMessage.ospfMessageType().value()) {
-            case OspfParameters.HELLO:
-                processHelloMessage(ospfMessage, ctx);
-                break;
-            case OspfParameters.DD:
-                processDdMessage(ospfMessage, ctx);
-                break;
-            case OspfParameters.LSREQUEST:
-                processLsRequestMessage(ospfMessage, ctx);
-                break;
-            case OspfParameters.LSUPDATE:
-                processLsUpdateMessage(ospfMessage, ctx);
-                break;
-            case OspfParameters.LSACK:
-                processLsAckMessage(ospfMessage, ctx);
-                break;
-            default:
-                log.debug("Unknown packet to process...!!!");
-                break;
+        int interfaceIndex = ospfMessage.interfaceIndex();
+        OspfInterface ospfInterface = ospfInterfaceMap.get(interfaceIndex);
+        if (ospfInterface != null) {
+            ospfInterface.processOspfMessage(ospfMessage, ctx);
         }
     }
 
     /**
-     * Validates the OSPF message received.
+     * Sends the interface configuration packet to server.
      *
-     * @param ospfMessage OSPF message.
-     * @return true if it is a valid else false.
-     * @throws Exception might throws exception
+     * @param configPacket interface configuration
      */
-    private boolean validateMessage(OspfMessage ospfMessage) throws Exception {
-        boolean isValid = true;
-        OspfPacketHeader header = (OspfPacketHeader) ospfMessage;
-
-        //added the check to eliminate self origin packets also two interfaces on same router.
-        if (!header.sourceIp().equals(ospfInterface.ipAddress()) && !header.routerId().equals(
-                ospfArea.routerId())) {
-            //Verify the checksum
-            ChecksumCalculator checksum = new ChecksumCalculator();
-            if (!checksum.isValidOspfCheckSum(ospfMessage, OspfUtil.OSPFPACKET_CHECKSUM_POS1,
-                                              OspfUtil.OSPFPACKET_CHECKSUM_POS2)) {
-                log.debug("Checksum mismatch. Received packet type {} ", ospfMessage.ospfMessageType());
-                return false;
-            }
-            if (((OspfPacketHeader) ospfMessage).ospfVersion() != OspfUtil.OSPF_VERSION_2) {
-                log.debug("Received osfpMessage Version should match with Interface Version ");
-                return false;
-            }
-            if (!((OspfPacketHeader) ospfMessage).areaId().equals(ospfArea.areaId())) {
-                log.debug("Received ospf packets are from different area than our Area ID. " +
-                                  "Received Area ID {}, Our AreaId {} ",
-                          ((OspfPacketHeader) ospfMessage).areaId(), ospfArea.areaId());
-                return false;
-            }
-
-            //According to RFC-2328 (8.2)
-            /**
-             * ABR should receive packets from backbone 0.0.0.0 as we are not acting as ABR
-             * we are rejecting the packet.
-             */
-            if (((OspfPacketHeader) ospfMessage).areaId().equals(Ip4Address.valueOf("0.0.0.0"))) {
-                log.debug("ABR should receive packets from backbone 0.0.0.0 as we are not acting as " +
-                                  "ABR we are rejecting the ospf packet");
-                return false;
-            }
-            if (ospfInterface.interfaceType() == OspfInterfaceType.BROADCAST.value() &&
-                    !OspfUtil.sameNetwork(((OspfPacketHeader) ospfMessage).sourceIp(),
-                                          ospfInterface.ipAddress(), ospfInterface.ipNetworkMask())) {
-                log.debug("Received packets from different subnets. Discarding...!!!");
-                return false;
-            }
+    public void sentConfigPacket(byte[] configPacket) {
+        if (channel != null) {
+            channel.write(configPacket);
+            log.debug("OspfChannelHandler sentConfigPacket packet sent..!!!");
         } else {
-            isValid = false;
-        }
-
-        return isValid;
-    }
-
-    /**
-     * Processes Hello message.
-     *
-     * @param ospfMessage OSPF message instance.
-     * @param ctx         context instance.
-     * @throws Exception might throws exception
-     */
-    void processHelloMessage(OspfMessage ospfMessage, ChannelHandlerContext ctx) throws Exception {
-        log.debug("OspfChannelHandler::processHelloMessage...!!!");
-        HelloPacket helloPacket = (HelloPacket) ospfMessage;
-
-        // processing of hello packet as per RFC 2328 section 10.5
-        log.debug("OspfChannelHandler::processHelloMessage::Interface Type {} OSPFInterfaceState {} ",
-                  ospfInterface.interfaceType(), ((OspfInterfaceImpl) ospfInterface).state());
-
-        if (ospfInterface.interfaceType() != OspfInterfaceType.POINT_TO_POINT.value()) {
-            if (!helloPacket.networkMask().equals(ospfInterface.ipNetworkMask())) {
-                log.debug("OspfChannelHandler::processHelloMessage::Hello Packet Received does not " +
-                                  "match the same network mask as the configure Interface");
-                return;
-            }
-        }
-        if (helloPacket.helloInterval() != ospfInterface.helloIntervalTime()) {
-            log.debug("OspfChannelHandler::processHelloMessage::Hello Packet Received have the same " +
-                              "hello interval as configured Interface");
-            return;
-        }
-        if (helloPacket.routerDeadInterval() != ospfInterface.routerDeadIntervalTime()) {
-            log.debug("OspfChannelHandler::processHelloMessage::Hello Packet Received have the same " +
-                              "Router Dead interval as configured Interface");
-            return;
-        }
-
-        if (ospfInterface.interfaceType() == OspfInterfaceType.POINT_TO_POINT.value()) {
-            // to verify if the neighbor which sent the hello is present in the OSPF Interface neighboring list .
-            OspfNbr nbr;
-            if (!ospfInterface.isNeighborInList(helloPacket.routerId().toString())) {
-                nbr = new OspfNbrImpl(ospfArea, ospfInterface, helloPacket.sourceIp(),
-                                      helloPacket.routerId(), helloPacket.options(), this, topologyForDeviceAndLink);
-                ospfInterface.addNeighbouringRouter(nbr);
-            } else {
-                nbr = ospfInterface.neighbouringRouter(helloPacket.routerId().toString());
-                nbr.setRouterPriority(helloPacket.routerPriority());
-            }
-            if (!helloPacket.containsNeighbour(ospfArea.routerId())) {
-                ((OspfNbrImpl) nbr).oneWayReceived(helloPacket, channel);
-            } else {
-                ((OspfNbrImpl) nbr).twoWayReceived(helloPacket, ctx.getChannel());
-            }
-        } else if (ospfInterface.interfaceType() == OspfInterfaceType.BROADCAST.value()) {
-
-            if (((OspfInterfaceImpl) ospfInterface).state() == OspfInterfaceState.WAITING) {
-                if ((!helloPacket.dr().equals(Ip4Address.valueOf("0.0.0.0"))) &&
-                        (!helloPacket.bdr().equals(Ip4Address.valueOf("0.0.0.0")))) {
-                    stopWaitTimer();
-                    ospfInterface.setDr(helloPacket.dr());
-                    ospfInterface.setBdr(helloPacket.bdr());
-                    if (helloPacket.dr().equals(ospfInterface.ipAddress())) {
-                        ((OspfInterfaceImpl) ospfInterface).setState(OspfInterfaceState.DR);
-                        //refresh router Lsa
-                        ospfArea.refreshArea(ospfInterface);
-                    } else if (helloPacket.bdr().equals(ospfInterface.ipAddress())) {
-                        ((OspfInterfaceImpl) ospfInterface).setState(OspfInterfaceState.BDR);
-                        //refresh router Lsa
-                        ospfArea.refreshArea(ospfInterface);
-                    } else {
-                        ((OspfInterfaceImpl) ospfInterface).setState(OspfInterfaceState.DROTHER);
-                        ospfArea.refreshArea(ospfInterface);
-                    }
-
-                } else if (!helloPacket.dr().equals(Ip4Address.valueOf("0.0.0.0")) ||
-                        !helloPacket.bdr().equals(Ip4Address.valueOf("0.0.0.0"))) {
-                    ospfInterface.setDr(helloPacket.dr());
-                    ospfInterface.setBdr(helloPacket.bdr());
-                }
-                Ip4Address sourceIp = helloPacket.sourceIp();
-                OspfNbr nbr;
-                if (!ospfInterface.isNeighborInList(helloPacket.routerId().toString())) {
-                    nbr = new OspfNbrImpl(ospfArea, ospfInterface, sourceIp, helloPacket.routerId(),
-                                          helloPacket.options(), this, topologyForDeviceAndLink);
-                    nbr.setNeighborId(helloPacket.routerId());
-                    nbr.setNeighborBdr(helloPacket.bdr());
-                    nbr.setNeighborDr(helloPacket.dr());
-                    nbr.setRouterPriority(helloPacket.routerPriority());
-                    ospfInterface.addNeighbouringRouter(nbr);
-                } else {
-                    nbr = ospfInterface.neighbouringRouter(helloPacket.routerId().toString());
-                    nbr.setRouterPriority(helloPacket.routerPriority());
-                }
-                if (!helloPacket.containsNeighbour(ospfArea.routerId())) {
-                    ((OspfNbrImpl) nbr).oneWayReceived(helloPacket, channel);
-                } else {
-                    ((OspfNbrImpl) nbr).twoWayReceived(helloPacket, ctx.getChannel());
-                }
-
-                if (helloPacket.dr().equals(sourceIp)) {
-                    if (helloPacket.bdr().equals(Ip4Address.valueOf("0.0.0.0"))) {
-                        // call backup seen
-                        stopWaitTimer();
-                        backupSeen(ctx.getChannel());
-                    }
-                }
-
-                if (helloPacket.bdr().equals(sourceIp)) {
-                    // call backup seen
-                    stopWaitTimer();
-                    backupSeen(ctx.getChannel());
-                }
-            } else {
-
-                if ((!helloPacket.dr().equals(Ip4Address.valueOf("0.0.0.0")) ||
-                        !helloPacket.bdr().equals(Ip4Address.valueOf("0.0.0.0")))
-                        && ospfInterface.routerPriority() == 0) {
-                    ospfInterface.setDr(helloPacket.dr());
-                    ospfInterface.setBdr(helloPacket.bdr());
-                }
-                //To verify if the neighbor which sent the hello is present in the OSPF Interface neighboring list .
-                Ip4Address sourceIp = helloPacket.sourceIp();
-                OspfNbr nbr;
-                if (!ospfInterface.isNeighborInList(helloPacket.routerId().toString())) {
-                    nbr = new OspfNbrImpl(ospfArea, ospfInterface, sourceIp, helloPacket.routerId(),
-                                          helloPacket.options(), this, topologyForDeviceAndLink);
-                    nbr.setNeighborId(helloPacket.routerId());
-                    nbr.setNeighborBdr(helloPacket.bdr());
-                    nbr.setNeighborDr(helloPacket.dr());
-                    nbr.setRouterPriority(helloPacket.routerPriority());
-                    ospfInterface.addNeighbouringRouter(nbr);
-                    ((OspfNbrImpl) nbr).oneWayReceived(helloPacket, channel);
-                } else {
-                    log.debug("OspfChannelHandler::NeighborInList::helloPacket.bdr(): {}, " +
-                                      "helloPacket.dr(): {}", helloPacket.bdr(), helloPacket.dr());
-                    nbr = ospfInterface.neighbouringRouter(helloPacket.routerId().toString());
-                    nbr.setRouterPriority(helloPacket.routerPriority());
-                    if (!helloPacket.containsNeighbour(ospfArea.routerId())) {
-                        ((OspfNbrImpl) nbr).oneWayReceived(helloPacket, channel);
-                    } else {
-                        ((OspfNbrImpl) nbr).twoWayReceived(helloPacket, ctx.getChannel());
-                    }
-                    if (nbr.routerPriority() != helloPacket.routerPriority()) {
-                        nbr.setNeighborBdr(helloPacket.bdr());
-                        nbr.setNeighborDr(helloPacket.dr());
-                        neighborChange();
-                    }
-
-
-                    if (nbr.neighborIpAddr().equals(helloPacket.dr()) &&
-                            !(nbr.neighborIpAddr().equals(nbr.neighborDr()))) {
-                        nbr.setNeighborBdr(helloPacket.bdr());
-                        nbr.setNeighborDr(helloPacket.dr());
-                        neighborChange();
-                    }
-
-                    if (!(nbr.neighborIpAddr().equals(helloPacket.dr())) &&
-                            (nbr.neighborIpAddr().equals(nbr.neighborDr()))) {
-                        nbr.setNeighborBdr(helloPacket.bdr());
-                        nbr.setNeighborDr(helloPacket.dr());
-                        neighborChange();
-                    }
-
-                    if (nbr.neighborIpAddr().equals(helloPacket.bdr()) &&
-                            !(nbr.neighborIpAddr().equals(nbr.neighborBdr()))) {
-                        nbr.setNeighborBdr(helloPacket.bdr());
-                        nbr.setNeighborDr(helloPacket.dr());
-                        neighborChange();
-                    }
-
-                    if (!(nbr.neighborIpAddr().equals(helloPacket.bdr())) &&
-                            (nbr.neighborIpAddr().equals(nbr.neighborBdr()))) {
-                        nbr.setNeighborBdr(helloPacket.bdr());
-                        nbr.setNeighborDr(helloPacket.dr());
-                        neighborChange();
-                    }
-
-                    nbr.setNeighborBdr(helloPacket.bdr());
-                    nbr.setNeighborDr(helloPacket.dr());
-                }
-
-            }
-        }
-    }
-
-    /**
-     * process the DD message which received.
-     *
-     * @param ospfMessage OSPF message instance.
-     * @param ctx         channel handler context instance
-     * @throws Exception might throws exception
-     */
-    void processDdMessage(OspfMessage ospfMessage, ChannelHandlerContext ctx) throws Exception {
-        log.debug("OspfChannelHandler::processDdMessage...!!!");
-
-        DdPacket ddPacket = (DdPacket) ospfMessage;
-        log.debug("Got DD packet from {}", ddPacket.sourceIp());
-        //check it is present in listOfNeighbors
-        Ip4Address neighbourId = ddPacket.routerId();
-        OspfNbr nbr = ospfInterface.neighbouringRouter(neighbourId.toString());
-
-        if (nbr != null) {
-            log.debug("OspfChannelHandler::processDdMessage:: OSPFNeighborState {}", nbr.getState());
-            // set options for the NBR
-            nbr.setIsOpaqueCapable(ddPacket.isOpaqueCapable());
-            if (ddPacket.imtu() > ospfInterface.mtu()) {
-                log.debug("the MTU size is greater than the interface MTU");
-                return;
-            }
-            if (nbr.getState() == OspfNeighborState.DOWN) {
-                return;
-            }
-            if (nbr.getState() == OspfNeighborState.ATTEMPT) {
-                return;
-            }
-            if (nbr.getState() == OspfNeighborState.TWOWAY) {
-                nbr.adjOk(channel);
-                return;
-            }
-            //if init is the state call twoWayReceived
-            if (nbr.getState() == OspfNeighborState.INIT) {
-                ((OspfNbrImpl) nbr).twoWayReceived(ddPacket, ctx.getChannel());
-            } else if (nbr.getState() == OspfNeighborState.EXSTART) {
-                //get I,M,MS Bits
-                int initialize = ddPacket.isInitialize();
-                int more = ddPacket.isMore();
-                int masterOrSlave = ddPacket.isMaster();
-                int options = ddPacket.options();
-                nbr.setOptions(options);
-
-                if (initialize == OspfUtil.INITIALIZE_SET && more == OspfUtil.MORE_SET &&
-                        masterOrSlave == OspfUtil.IS_MASTER) {
-                    if (ddPacket.getLsaHeaderList().isEmpty()) {
-                        if (OspfUtil.ipAddressToLong(ddPacket.routerId().toString()) >
-                                OspfUtil.ipAddressToLong(ospfArea.routerId().toString())) {
-                            nbr.setIsMaster(OspfUtil.IS_MASTER);
-                            ((OspfNbrImpl) nbr).setLastDdPacket(ddPacket);
-                            nbr.setDdSeqNum(ddPacket.sequenceNo());
-                            nbr.setOptions(ddPacket.options());
-                            ((OspfNbrImpl) nbr).negotiationDone(ddPacket, true, ddPacket.getLsaHeaderList(),
-                                                                ctx.getChannel());
-                        }
-                    }
-                }
-                if (initialize == OspfUtil.INITIALIZE_NOTSET && masterOrSlave == OspfUtil.NOT_MASTER) {
-                    if (nbr.ddSeqNum() == ddPacket.sequenceNo()) {
-                        if (OspfUtil.ipAddressToLong(ddPacket.routerId().toString()) <
-                                OspfUtil.ipAddressToLong(ospfArea.routerId().toString())) {
-                            ((OspfNbrImpl) nbr).setLastDdPacket(ddPacket);
-                            nbr.setOptions(ddPacket.options());
-                            nbr.setDdSeqNum(nbr.ddSeqNum() + 1);
-                            ((OspfNbrImpl) nbr).negotiationDone(ddPacket, false, ddPacket.getLsaHeaderList(),
-                                                                ctx.getChannel());
-                        }
-                    }
-                }
-
-            } else if (nbr.getState() == OspfNeighborState.EXCHANGE) {
-                //get I,M,MS Bits
-                log.debug("Neighbor state:: EXCHANGE");
-                boolean isDuplicateDDPacket = compareDdPackets(ddPacket, ((OspfNbrImpl) nbr).lastDdPacket());
-                int initialize = ddPacket.isInitialize();
-                int more = ddPacket.isMore();
-                int masterOrSlave = ddPacket.isMaster();
-                int options = ddPacket.options();
-
-                if (!isDuplicateDDPacket) {
-                    //if dd packet is not duplicate  then continue
-                    if (nbr.isMaster() != masterOrSlave) {
-                        DdPacket newResPacket =
-                                (DdPacket) ((OspfNbrImpl) nbr).seqNumMismatch("Master/Slave Inconsistency");
-                        newResPacket.setDestinationIp(ddPacket.sourceIp());
-                        log.debug("Sending back DDPacket to {}", ddPacket.sourceIp());
-                        ctx.getChannel().write(newResPacket);
-                    } else if (initialize == 1) {
-                        DdPacket newResPacket =
-                                (DdPacket) ((OspfNbrImpl) nbr).seqNumMismatch("Initialize bit inconsistency");
-                        newResPacket.setDestinationIp(ddPacket.sourceIp());
-                        log.debug("Sending back DDPacket to {}", ddPacket.sourceIp());
-                        ctx.getChannel().write(newResPacket);
-                    } else {
-
-                        if (masterOrSlave == OspfUtil.NOT_MASTER) {
-                            if (ddPacket.sequenceNo() == nbr.ddSeqNum()) {
-                                //Process the DD Packet
-                                ((OspfNbrImpl) nbr).processDdPacket(false, ddPacket, ctx.getChannel());
-                                log.debug("Received DD Packet");
-                            } else {
-                                DdPacket newResPacket =
-                                        (DdPacket) ((OspfNbrImpl) nbr).seqNumMismatch("Sequence Number Mismatch");
-                                newResPacket.setDestinationIp(ddPacket.sourceIp());
-                                log.debug("Sending back DDPacket to {}", ddPacket.sourceIp());
-                                ctx.getChannel().write(newResPacket);
-                            }
-                        } else {
-                            //we are the slave
-                            if (ddPacket.sequenceNo() == (nbr.ddSeqNum() + 1)) {
-                                ((OspfNbrImpl) nbr).setLastDdPacket(ddPacket);
-                                ((OspfNbrImpl) nbr).processDdPacket(true, ddPacket, ctx.getChannel());
-                                log.debug("Process DD Packet");
-                            } else {
-                                DdPacket newResPacket =
-                                        (DdPacket) ((OspfNbrImpl) nbr).seqNumMismatch("options inconsistency");
-                                newResPacket.setDestinationIp(ddPacket.sourceIp());
-                                log.debug("Sending back DDPacket to {}", ddPacket.sourceIp());
-                                ctx.getChannel().write(newResPacket);
-                            }
-                        }
-                    }
-                } else {
-                    if (masterOrSlave == OspfUtil.NOT_MASTER) {
-                        return;
-                    } else {
-                        DdPacket newResPacket = ((OspfNbrImpl) nbr).lastSentDdPacket();
-                        log.debug("Sending back DDPacket to {}", ddPacket.sourceIp());
-                        ctx.getChannel().write(newResPacket);
-                    }
-                }
-            } else if (nbr.getState() == OspfNeighborState.LOADING || nbr.getState() == OspfNeighborState.FULL) {
-                //In case if we are slave then we have to send the last received DD Packet
-                int options = ddPacket.options();
-                if (nbr.options() != options) {
-                    OspfMessage newResPacket = ((OspfNbrImpl) nbr).seqNumMismatch("Initialize bit inconsistency");
-                    newResPacket.setDestinationIp(ddPacket.sourceIp());
-                    ctx.getChannel().write(newResPacket);
-                } else if (ddPacket.isInitialize() == OspfUtil.INITIALIZE_SET) {
-                    OspfMessage newResPacket = ((OspfNbrImpl) nbr).seqNumMismatch("Initialize bit inconsistency");
-                    newResPacket.setDestinationIp(ddPacket.sourceIp());
-                    ctx.getChannel().write(newResPacket);
-                }
-                boolean isDuplicate = compareDdPackets(ddPacket, ((OspfNbrImpl) nbr).lastDdPacket());
-                //we are master
-                if (nbr.isMaster() != OspfUtil.IS_MASTER) {
-                    // check if the packet is duplicate, duplicates should be discarded by the master
-                    if (isDuplicate) {
-                        log.debug("received a duplicate DD packet");
-                    }
-                } else {
-                    //The slave must respond to duplicates by repeating the last Database Description packet
-                    //that it had sent.
-                    if (isDuplicate) {
-                        ddPacket.setDestinationIp(ddPacket.sourceIp());
-                        ctx.getChannel().write(((OspfNbrImpl) nbr).lastSentDdPacket());
-                        log.debug("Sending back the duplicate packet ");
-                    }
-                }
-            }
-        }
-    }
-
-    /**
-     * Process the Ls Request message.
-     *
-     * @param ospfMessage OSPF message instance.
-     * @param ctx         channel handler context instance.
-     * @throws Exception might throws exception
-     */
-    void processLsRequestMessage(OspfMessage ospfMessage, ChannelHandlerContext ctx) throws Exception {
-        log.debug("OspfChannelHandler::processLsRequestMessage...!!!");
-        LsRequest lsrPacket = (LsRequest) ospfMessage;
-        OspfNbr nbr = ospfInterface.neighbouringRouter(lsrPacket.routerId().toString());
-
-        if (nbr.getState() == OspfNeighborState.EXCHANGE || nbr.getState() == OspfNeighborState.LOADING ||
-                nbr.getState() == OspfNeighborState.FULL) {
-
-            LsRequest reqMsg = (LsRequest) ospfMessage;
-            if (reqMsg.getLinkStateRequests().isEmpty()) {
-                log.debug("Received Link State Request Vector is Empty ");
-                return;
-            } else {
-                //Send the LsUpdate back
-                ListIterator<LsRequestPacket> listItr = reqMsg.getLinkStateRequests().listIterator();
-                while (listItr.hasNext()) {
-                    LsUpdate lsupdate = new LsUpdate();
-                    lsupdate.setOspfVer(OspfUtil.OSPF_VERSION);
-                    lsupdate.setOspftype(OspfPacketType.LSUPDATE.value());
-                    lsupdate.setRouterId(ospfArea.routerId());
-                    lsupdate.setAreaId(ospfArea.areaId());
-                    lsupdate.setAuthType(OspfUtil.NOT_ASSIGNED);
-                    lsupdate.setAuthentication(OspfUtil.NOT_ASSIGNED);
-                    lsupdate.setOspfPacLength(OspfUtil.NOT_ASSIGNED); // to calculate packet length
-                    lsupdate.setChecksum(OspfUtil.NOT_ASSIGNED);
-
-                    //limit to mtu
-                    int currentLength = OspfUtil.OSPF_HEADER_LENGTH + OspfUtil.FOUR_BYTES;
-                    int maxSize = ospfInterface.mtu() -
-                            OspfUtil.LSA_HEADER_LENGTH; // subtract a normal IP header.
-                    int noLsa = 0;
-                    while (listItr.hasNext()) {
-                        LsRequestPacket lsRequest = (LsRequestPacket) listItr.next();
-                        // to verify length of the LSA
-                        LsaWrapper wrapper = ospfArea.getLsa(lsRequest.lsType(), lsRequest.linkStateId(),
-                                                             lsRequest.ownRouterId());
-                        OspfLsa ospflsa = wrapper.ospfLsa();
-                        if ((currentLength + ((LsaWrapperImpl) wrapper).lsaHeader().lsPacketLen()) >= maxSize) {
-                            listItr.previous();
-                            break;
-                        }
-                        if (ospflsa != null) {
-                            lsupdate.addLsa(ospflsa);
-                            noLsa++;
-
-                            currentLength = currentLength + ((LsaWrapperImpl) wrapper).lsaHeader().lsPacketLen();
-                        } else {
-                            nbr.badLSReq(channel);
-                        }
-                    }
-                    lsupdate.setNumberOfLsa(noLsa);
-                    //set the destination
-                    if (((OspfInterfaceImpl) ospfInterface).state() == OspfInterfaceState.DR ||
-                            ((OspfInterfaceImpl) ospfInterface).state() == OspfInterfaceState.BDR ||
-                            ((OspfInterfaceImpl) ospfInterface).state() == OspfInterfaceState.POINT2POINT) {
-                        lsupdate.setDestinationIp(OspfUtil.ALL_SPF_ROUTERS);
-                    } else if (((OspfInterfaceImpl) ospfInterface).state() == OspfInterfaceState.DROTHER) {
-                        lsupdate.setDestinationIp(OspfUtil.ALL_DROUTERS);
-                    }
-                    ctx.getChannel().write(lsupdate);
-                }
-            }
-        }
-    }
-
-    /**
-     * Process the ls update message.
-     *
-     * @param ospfMessage OSPF message instance.
-     * @param ctx         channel handler context instance.
-     * @throws Exception might throws exception
-     */
-    void processLsUpdateMessage(OspfMessage ospfMessage, ChannelHandlerContext ctx) throws Exception {
-        log.debug("OspfChannelHandler::processLsUpdateMessage");
-        LsUpdate lsUpdate = (LsUpdate) ospfMessage;
-        String neighbourId = lsUpdate.routerId().toString();
-        //LSUpdate packet has been associated with a particular neighbor.
-        //Neighbor should not be in lesser state than Exchange.
-        if (ospfInterface.isNeighborInList(neighbourId)) {
-            OspfNbrImpl nbr = (OspfNbrImpl) ospfInterface.neighbouringRouter(neighbourId);
-            if (nbr.getState() == OspfNeighborState.EXCHANGE ||
-                    nbr.getState() == OspfNeighborState.LOADING) {
-                nbr.processLsUpdate(lsUpdate, ctx.getChannel());
-            } else if (nbr.getState() == OspfNeighborState.FULL) {
-                if (lsUpdate.noLsa() != 0) {
-                    List<OspfLsa> list = lsUpdate.getLsaList();
-                    Iterator itr = list.iterator();
-                    while (itr.hasNext()) {
-                        LsaHeader lsa = (LsaHeader) itr.next();
-                        nbr.processReceivedLsa(lsa, true, ctx.getChannel(), lsUpdate.sourceIp());
-                    }
-                } else {
-                    return;
-                }
-            }
-        }
-    }
-
-    /**
-     * Process the ls acknowledge message.
-     *
-     * @param ospfMessage OSPF message instance.
-     * @param ctx         channel handler context instance.
-     * @throws Exception might throws exception
-     */
-    void processLsAckMessage(OspfMessage ospfMessage, ChannelHandlerContext ctx) throws Exception {
-        log.debug("OspfChannelHandler::processLsAckMessage");
-        LsAcknowledge lsAckPacket = (LsAcknowledge) ospfMessage;
-        //check it is present in listOfNeighbors
-        OspfNbrImpl nbr = (OspfNbrImpl) ospfInterface.neighbouringRouter(lsAckPacket.routerId().toString());
-        if (nbr != null) {
-            if (nbr.getState().getValue() < OspfNeighborState.EXCHANGE.getValue()) {
-                // discard the packet.
-                return;
-            } else {
-                // process ls acknowledgements
-                Iterator itr = lsAckPacket.getLinkStateHeaders().iterator();
-                while (itr.hasNext()) {
-                    LsaHeader lsRequest = (LsaHeader) itr.next();
-
-                    OspfLsa ospfLsa =
-                            (OspfLsa) nbr.getPendingReTxList().get(((OspfAreaImpl) ospfArea).getLsaKey(lsRequest));
-                    if (lsRequest != null && ospfLsa != null) {
-                        String isSame = ((OspfLsdbImpl) ospfArea.database()).isNewerOrSameLsa(
-                                lsRequest, (LsaHeader) ospfLsa);
-                        if (isSame.equals("same")) {
-                            nbr.getPendingReTxList().remove(((OspfAreaImpl) ospfArea).getLsaKey(lsRequest));
-                        }
-                    }
-                }
-            }
-        }
-    }
-
-    /**
-     * Compares two Dd Packets to check whether its duplicate or not.
-     *
-     * @param receivedDPacket received DD packet from network.
-     * @param lastDdPacket    Last DdPacket which we sent.
-     * @return true if it is a duplicate packet else false.
-     */
-    public boolean compareDdPackets(DdPacket receivedDPacket, DdPacket lastDdPacket) {
-        if (receivedDPacket.isInitialize() == lastDdPacket.isInitialize()) {
-            if (receivedDPacket.isMaster() == lastDdPacket.isMaster()) {
-                if (receivedDPacket.isMore() == lastDdPacket.isMore()) {
-                    if (receivedDPacket.options() == lastDdPacket.options()) {
-                        if (receivedDPacket.sequenceNo() == lastDdPacket.sequenceNo()) {
-                            return true;
-                        }
-                    }
-                }
-            }
-        }
-        return false;
-    }
-
-    /**
-     * Closes the Netty channel.
-     *
-     * @param ctx the Channel Handler Context
-     */
-    void closeChannel(ChannelHandlerContext ctx) {
-        log.debug("OspfChannelHandler::closeChannel");
-        isClosed = true;
-        ctx.getChannel().close();
-    }
-
-    /**
-     * Starts the hello timer which sends hello packet every configured seconds.
-     *
-     * @param period the interval to run task
-     */
-    private void startHelloTimer(long period) {
-        log.debug("OSPFInterfaceChannelHandler::startHelloTimer");
-        exServiceHello = Executors.newSingleThreadScheduledExecutor();
-        helloTimerTask = new InternalHelloTimer();
-        final ScheduledFuture<?> helloHandle =
-                exServiceHello.scheduleAtFixedRate(helloTimerTask, delay, period, TimeUnit.SECONDS);
-    }
-
-    /**
-     * Stops the hello timer.
-     */
-    private void stopHelloTimer() {
-        log.debug("OSPFInterfaceChannelHandler::stopHelloTimer ");
-        exServiceHello.shutdown();
-    }
-
-    /**
-     * Starts the wait timer.
-     */
-    private void startWaitTimer() {
-        log.debug("OSPFNbr::startWaitTimer");
-        exServiceWait = Executors.newSingleThreadScheduledExecutor();
-        waitTimerTask = new InternalWaitTimer();
-        final ScheduledFuture<?> waitTimerHandle =
-                exServiceWait.schedule(waitTimerTask, ospfInterface.routerDeadIntervalTime(),
-                                       TimeUnit.SECONDS);
-    }
-
-    /**
-     * Stops the wait timer.
-     */
-    private void stopWaitTimer() {
-        log.debug("OSPFNbr::stopWaitTimer ");
-        exServiceWait.shutdown();
-    }
-
-    /**
-     * Starts the timer which waits for configured seconds and sends Delayed Ack Packet.
-     */
-    private void startDelayedAckTimer() {
-        if (!isDelayedAckTimerScheduled) {
-            log.debug("Started DelayedAckTimer...!!!");
-            exServiceDelayedAck = Executors.newSingleThreadScheduledExecutor();
-            delayedAckTimerTask = new InternalDelayedAckTimer();
-            final ScheduledFuture<?> delayAckHandle =
-                    exServiceDelayedAck.scheduleAtFixedRate(delayedAckTimerTask, delayedAckTimerInterval,
-                                                            delayedAckTimerInterval, TimeUnit.MILLISECONDS);
-            isDelayedAckTimerScheduled = true;
-        }
-    }
-
-    /**
-     * Stops the delayed acknowledge timer.
-     */
-    private void stopDelayedAckTimer() {
-        if (isDelayedAckTimerScheduled) {
-            log.debug("Stopped DelayedAckTimer...!!!");
-            isDelayedAckTimerScheduled = false;
-            exServiceDelayedAck.shutdown();
-        }
-    }
-
-    /**
-     * Performs DR election.
-     *
-     * @param ch Netty Channel instance.
-     * @throws Exception might throws exception
-     */
-    public void electRouter(Channel ch) throws Exception {
-
-        Ip4Address currentDr = ospfInterface.dr();
-        Ip4Address currentBdr = ospfInterface.bdr();
-        OspfInterfaceState oldState = ((OspfInterfaceImpl) ospfInterface).state();
-        OspfInterfaceState newState;
-
-        log.debug("OSPFInterfaceChannelHandler::electRouter -> currentDr: {}, currentBdr: {}",
-                  currentDr, currentBdr);
-        List<OspfEligibleRouter> eligibleRouters = calculateListOfEligibleRouters(new OspfEligibleRouter());
-
-        log.debug("OSPFInterfaceChannelHandler::electRouter -> eligibleRouters: {}", eligibleRouters);
-        OspfEligibleRouter electedBdr = electBdr(eligibleRouters);
-        OspfEligibleRouter electedDr = electDr(eligibleRouters, electedBdr);
-
-        ospfInterface.setBdr(electedBdr.getIpAddress());
-        ospfInterface.setDr(electedDr.getIpAddress());
-
-        if (electedBdr.getIpAddress().equals(ospfInterface.ipAddress()) &&
-                !electedBdr.getIpAddress().equals(currentBdr)) {
-            ((OspfInterfaceImpl) ospfInterface).setState(OspfInterfaceState.BDR);
-        }
-
-        if (electedDr.getIpAddress().equals(ospfInterface.ipAddress()) &&
-                !electedDr.getIpAddress().equals(currentDr)) {
-            ((OspfInterfaceImpl) ospfInterface).setState(OspfInterfaceState.DR);
-        }
-
-        if (((OspfInterfaceImpl) ospfInterface).state() != oldState &&
-                !(((OspfInterfaceImpl) ospfInterface).state() == OspfInterfaceState.DROTHER &&
-                        oldState.value() < OspfInterfaceState.DROTHER.value())) {
-            log.debug("Recalculating as the State is changed ");
-            log.debug("OSPFInterfaceChannelHandler::electRouter -> currentDr: {}, currentBdr: {}",
-                      currentDr, currentBdr);
-            eligibleRouters = calculateListOfEligibleRouters(new OspfEligibleRouter());
-
-            log.debug("OSPFInterfaceChannelHandler::electRouter -> eligibleRouters: {}", eligibleRouters);
-            electedBdr = electBdr(eligibleRouters);
-            electedDr = electDr(eligibleRouters, electedBdr);
-
-            ospfInterface.setBdr(electedBdr.getIpAddress());
-            ospfInterface.setDr(electedDr.getIpAddress());
-        }
-
-        if (electedBdr.getIpAddress().equals(ospfInterface.ipAddress()) &&
-                !electedBdr.getIpAddress().equals(currentBdr)) {
-            ((OspfInterfaceImpl) ospfInterface).setState(OspfInterfaceState.BDR);
-            ospfArea.refreshArea(ospfInterface);
-        }
-
-        if (electedDr.getIpAddress().equals(ospfInterface.ipAddress()) &&
-                !electedDr.getIpAddress().equals(currentDr)) {
-            ((OspfInterfaceImpl) ospfInterface).setState(OspfInterfaceState.DR);
-            //Refresh Router Lsa & Network Lsa
-            ospfArea.refreshArea(ospfInterface);
-        }
-
-        if (currentDr != electedDr.getIpAddress() || currentBdr != electedBdr.getIpAddress()) {
-            Set<String> negibhorIdList;
-            negibhorIdList = ospfInterface.listOfNeighbors().keySet();
-            for (String routerid : negibhorIdList) {
-                OspfNbrImpl nbr = (OspfNbrImpl) ospfInterface.neighbouringRouter(routerid);
-                if (nbr.getState().getValue() >= OspfNeighborState.TWOWAY.getValue()) {
-                    nbr.adjOk(ch);
-                }
-            }
-        }
-
-        log.debug("OSPFInterfaceChannelHandler::electRouter -> ElectedDR: {}, ElectedBDR: {}",
-                  electedDr.getIpAddress(), electedBdr.getIpAddress());
-    }
-
-
-    /**
-     * BDR Election process. Find the list of eligible router to participate in the process.
-     *
-     * @param electedDr router elected as DR.
-     * @return list of eligible routers
-     */
-    public List<OspfEligibleRouter> calculateListOfEligibleRouters(OspfEligibleRouter electedDr) {
-        log.debug("OSPFNbr::calculateListOfEligibleRouters ");
-        Set<String> neighborIdList;
-        List<OspfEligibleRouter> eligibleRouters = new ArrayList<>();
-
-        neighborIdList = ospfInterface.listOfNeighbors().keySet();
-        for (String routerId : neighborIdList) {
-            OspfNbrImpl nbr = (OspfNbrImpl) ospfInterface.neighbouringRouter(routerId);
-            if (nbr.getState().getValue() >= OspfNeighborState.TWOWAY.getValue() &&
-                    nbr.routerPriority() > 0) {
-                OspfEligibleRouter router = new OspfEligibleRouter();
-                router.setIpAddress(nbr.neighborIpAddr());
-                router.setRouterId(nbr.neighborId());
-                router.setRouterPriority(nbr.routerPriority());
-                if (nbr.neighborDr().equals(nbr.neighborIpAddr()) ||
-                        electedDr.getIpAddress().equals(nbr.neighborIpAddr())) {
-                    router.setIsDr(true);
-                } else if (nbr.neighborBdr().equals(nbr.neighborIpAddr())) {
-                    router.setIsBdr(true);
-                }
-                eligibleRouters.add(router);
-            }
-        }
-        // interface does not have states like two and all
-        if (ospfInterface.routerPriority() > 0) {
-            OspfEligibleRouter router = new OspfEligibleRouter();
-            router.setIpAddress(ospfInterface.ipAddress());
-            router.setRouterId(ospfArea.routerId());
-            router.setRouterPriority(ospfInterface.routerPriority());
-            if (ospfInterface.dr().equals(ospfInterface.ipAddress()) ||
-                    electedDr.getIpAddress().equals(ospfInterface.ipAddress())) {
-                router.setIsDr(true);
-            } else if (ospfInterface.bdr().equals(ospfInterface.ipAddress()) &&
-                    !ospfInterface.dr().equals(ospfInterface.ipAddress())) {
-                router.setIsBdr(true);
-            }
-
-            eligibleRouters.add(router);
-        }
-
-        return eligibleRouters;
-    }
-
-    /**
-     * Based on router priority assigns BDR.
-     *
-     * @param eligibleRouters list of routers to participate in bdr election.
-     * @return OSPF Eligible router instance.
-     */
-    public OspfEligibleRouter electBdr(List<OspfEligibleRouter> eligibleRouters) {
-        log.debug("OSPFInterfaceChannelHandler::electBdr -> eligibleRouters: {}", eligibleRouters);
-        List<OspfEligibleRouter> declaredAsBdr = new ArrayList<>();
-        List<OspfEligibleRouter> notDrAndBdr = new ArrayList<>();
-        for (OspfEligibleRouter router : eligibleRouters) {
-            if (router.isBdr()) {
-                declaredAsBdr.add(router);
-            }
-            if (!router.isBdr() && !router.isDr()) {
-                notDrAndBdr.add(router);
-            }
-        }
-
-        OspfEligibleRouter electedBdr = new OspfEligibleRouter();
-        if (!declaredAsBdr.isEmpty()) {
-            if (declaredAsBdr.size() == 1) {
-                electedBdr = declaredAsBdr.get(0);
-            } else if (declaredAsBdr.size() > 1) {
-                electedBdr = selectRouterBasedOnPriority(declaredAsBdr);
-            }
-        } else {
-            if (notDrAndBdr.size() == 1) {
-                electedBdr = notDrAndBdr.get(0);
-            } else if (notDrAndBdr.size() > 1) {
-                electedBdr = selectRouterBasedOnPriority(notDrAndBdr);
-            }
-        }
-
-        electedBdr.setIsBdr(true);
-        electedBdr.setIsDr(false);
-
-        return electedBdr;
-    }
-
-    /**
-     * DR Election process.
-     *
-     * @param eligibleRouters list of eligible routers.
-     * @param electedBdr      Elected Bdr, OSPF eligible router instance.
-     * @return OSPF eligible router instance.
-     */
-    public OspfEligibleRouter electDr(List<OspfEligibleRouter> eligibleRouters,
-                                      OspfEligibleRouter electedBdr) {
-
-        List<OspfEligibleRouter> declaredAsDr = new ArrayList<>();
-        for (OspfEligibleRouter router : eligibleRouters) {
-            if (router.isDr()) {
-                declaredAsDr.add(router);
-            }
-        }
-
-        OspfEligibleRouter electedDr = new OspfEligibleRouter();
-        if (!declaredAsDr.isEmpty()) {
-            if (declaredAsDr.size() == 1) {
-                electedDr = declaredAsDr.get(0);
-            } else if (eligibleRouters.size() > 1) {
-                electedDr = selectRouterBasedOnPriority(declaredAsDr);
-            }
-        } else {
-            electedDr = electedBdr;
-            electedDr.setIsDr(true);
-            electedDr.setIsBdr(false);
-        }
-
-        return electedDr;
-    }
-
-    /**
-     * DR election process.
-     *
-     * @param routersList list of eligible routers.
-     * @return OSPF eligible router instance.
-     */
-    public OspfEligibleRouter selectRouterBasedOnPriority(List<OspfEligibleRouter> routersList) {
-
-        OspfEligibleRouter initialRouter = routersList.get(0);
-
-        for (int i = 1; i < routersList.size(); i++) {
-            OspfEligibleRouter router = routersList.get(i);
-            if (router.getRouterPriority() > initialRouter.getRouterPriority()) {
-                initialRouter = router;
-            } else if (router.getRouterPriority() == initialRouter.getRouterPriority()) {
-                try {
-                    //if (router.getIpAddress().toInt() > initialRouter.getIpAddress().toInt()) {
-                    if (OspfUtil.ipAddressToLong(router.getIpAddress().toString()) >
-                            OspfUtil.ipAddressToLong(initialRouter.getIpAddress().toString())) {
-                        initialRouter = router;
-                    }
-                } catch (Exception e) {
-                    log.debug("OSPFInterfaceChannelHandler::selectRouterBasedOnPriority ->" +
-                                      " eligibleRouters: {}", initialRouter);
-                }
-            }
-        }
-
-        return initialRouter;
-    }
-
-    /**
-     * Adds device information.
-     *
-     * @param ospfRouter OSPF router instance
-     */
-    public void addDeviceInformation(OspfRouter ospfRouter) {
-        controller.addDeviceDetails(ospfRouter);
-    }
-
-    /**
-     * removes device information.
-     *
-     * @param ospfRouter OSPF neighbor instance
-     */
-    public void removeDeviceInformation(OspfRouter ospfRouter) {
-        controller.removeDeviceDetails(ospfRouter);
-    }
-
-    /**
-     * Adds link information.
-     *
-     * @param ospfRouter  OSPF router instance
-     * @param ospfLinkTed list link ted instances
-     */
-    public void addLinkInformation(OspfRouter ospfRouter, OspfLinkTed ospfLinkTed) {
-        controller.addLinkDetails(ospfRouter, ospfLinkTed);
-    }
-
-    /**
-     * Removes link information.
-     *
-     * @param ospfNbr OSPF neighbor instance
-     */
-    public void removeLinkInformation(OspfNbr ospfNbr) {
-        controller.removeLinkDetails(buildOspfRouterDetails(ospfNbr));
-    }
-
-    /**
-     * Builds router details.
-     *
-     * @param ospfNbr OSPF neighbor instance
-     * @return OSPF router instance
-     */
-    private OspfRouter buildOspfRouterDetails(OspfNbr ospfNbr) {
-        OspfRouter ospfRouter = new OspfRouterImpl();
-        ospfRouter.setRouterIp(ospfNbr.neighborId());
-        ospfRouter.setInterfaceId(ospfInterface.ipAddress());
-        ospfRouter.setAreaIdOfInterface(ospfArea.areaId());
-
-        ospfRouter.setDeviceTed(new OspfDeviceTedImpl());
-
-        return ospfRouter;
-    }
-
-    /**
-     * Represents a Hello task which sent a hello message every configured time interval.
-     */
-    private class InternalHelloTimer implements Runnable {
-
-        /**
-         * Creates an instance of Hello Timer.
-         */
-        InternalHelloTimer() {
-        }
-
-        @Override
-        public void run() {
-            if (!isClosed && channel != null && channel.isOpen() && channel.isConnected()) {
-
-                HelloPacket hellopacket = new HelloPacket();
-                //Headers
-                hellopacket.setOspfVer(OspfUtil.OSPF_VERSION);
-                hellopacket.setOspftype(OspfPacketType.HELLO.value());
-                hellopacket.setOspfPacLength(0); //will be modified while encoding
-                hellopacket.setRouterId(ospfArea.routerId());
-                hellopacket.setAreaId(ospfArea.areaId());
-                hellopacket.setChecksum(0); //will be modified while encoding
-                hellopacket.setAuthType(Integer.parseInt(ospfInterface.authType()));
-                hellopacket.setAuthentication(Integer.parseInt(ospfInterface.authKey()));
-                //Body
-                hellopacket.setNetworkMask(ospfInterface.ipNetworkMask());
-                hellopacket.setOptions(ospfArea.options());
-                hellopacket.setHelloInterval(ospfInterface.helloIntervalTime());
-                hellopacket.setRouterPriority(ospfInterface.routerPriority());
-                hellopacket.setRouterDeadInterval(ospfInterface.routerDeadIntervalTime());
-                hellopacket.setDr(ospfInterface.dr());
-                hellopacket.setBdr(ospfInterface.bdr());
-
-                HashMap<String, OspfNbr> listOfNeighbors = ospfInterface.listOfNeighbors();
-                Set<String> keys = listOfNeighbors.keySet();
-                Iterator itr = keys.iterator();
-                while (itr.hasNext()) {
-                    String nbrKey = (String) itr.next();
-                    OspfNbrImpl nbr = (OspfNbrImpl) listOfNeighbors.get(nbrKey);
-                    if (nbr.getState() != OspfNeighborState.DOWN) {
-                        hellopacket.addNeighbor(Ip4Address.valueOf(nbrKey));
-                    }
-                }
-                // build a hello Packet
-                if (channel == null || !channel.isOpen() || !channel.isConnected()) {
-                    log.debug("Hello Packet not sent !!.. Channel Issue...");
-                    return;
-                }
-
-                hellopacket.setDestinationIp(OspfUtil.ALL_SPF_ROUTERS);
-                ChannelFuture future = channel.write(hellopacket);
-                if (future.isSuccess()) {
-                    log.debug("Hello Packet successfully sent !!");
-                } else {
-                    future.awaitUninterruptibly();
-                }
-
-            }
-        }
-    }
-
-    /**
-     * Represents a Wait Timer task which waits the interface state to become WAITING.
-     * It initiates DR election process.
-     */
-    private class InternalWaitTimer implements Runnable {
-        Channel ch;
-
-        /**
-         * Creates an instance of Wait Timer.
-         */
-        InternalWaitTimer() {
-            this.ch = channel;
-        }
-
-        @Override
-        public void run() {
-            log.debug("Wait timer expires...");
-            if (ch != null && ch.isConnected()) {
-                try {
-                    waitTimer(ch);
-                } catch (Exception e) {
-                    log.debug("Exception at wait timer ...!!!");
-                }
-
-            }
-        }
-    }
-
-    /**
-     * Represents a task which sent a LS Acknowledge from the link state headers list.
-     */
-    private class InternalDelayedAckTimer implements Runnable {
-        Channel ch;
-
-        /**
-         * Creates an instance of Delayed acknowledge timer.
-         */
-        InternalDelayedAckTimer() {
-            this.ch = channel;
-        }
-
-        @Override
-        public void run() {
-            if (!((OspfInterfaceImpl) ospfInterface).linkStateHeaders().isEmpty()) {
-                isDelayedAckTimerScheduled = true;
-                if (ch != null && ch.isConnected()) {
-
-                    List<LsaHeader> listOfLsaHeadersAcknowledged = new ArrayList<>();
-                    List<LsaHeader> listOfLsaHeaders = ((OspfInterfaceImpl) ospfInterface).linkStateHeaders();
-                    log.debug("Delayed Ack, Number of Lsa's to Ack {}", listOfLsaHeaders.size());
-                    Iterator itr = listOfLsaHeaders.iterator();
-                    while (itr.hasNext()) {
-                        LsAcknowledge ackContent = new LsAcknowledge();
-                        //Setting OSPF Header
-                        ackContent.setOspfVer(OspfUtil.OSPF_VERSION);
-                        ackContent.setOspftype(OspfPacketType.LSAACK.value());
-                        ackContent.setRouterId(ospfArea.routerId());
-                        ackContent.setAreaId(ospfArea.areaId());
-                        ackContent.setAuthType(OspfUtil.NOT_ASSIGNED);
-                        ackContent.setAuthentication(OspfUtil.NOT_ASSIGNED);
-                        ackContent.setOspfPacLength(OspfUtil.NOT_ASSIGNED);
-                        ackContent.setChecksum(OspfUtil.NOT_ASSIGNED);
-                        //limit to mtu
-                        int currentLength = OspfUtil.OSPF_HEADER_LENGTH;
-                        int maxSize = ospfInterface.mtu() -
-                                OspfUtil.LSA_HEADER_LENGTH; // subtract a normal IP header.
-                        while (itr.hasNext()) {
-                            if ((currentLength + OspfUtil.LSA_HEADER_LENGTH) >= maxSize) {
-                                break;
-                            }
-                            LsaHeader lsaHeader = (LsaHeader) itr.next();
-                            ackContent.addLinkStateHeader(lsaHeader);
-                            currentLength = currentLength + OspfUtil.LSA_HEADER_LENGTH;
-                            listOfLsaHeadersAcknowledged.add(lsaHeader);
-                            log.debug("Delayed Ack, Added Lsa's to Ack {}", lsaHeader);
-                        }
-
-                        log.debug("Delayed Ack, Number of Lsa's in LsAck packet {}",
-                                  ackContent.getLinkStateHeaders().size());
-
-                        //set the destination
-                        if (((OspfInterfaceImpl) ospfInterface).state() == OspfInterfaceState.DR ||
-                                ((OspfInterfaceImpl) ospfInterface).state() == OspfInterfaceState.BDR
-                                || ((OspfInterfaceImpl) ospfInterface).state() == OspfInterfaceState.POINT2POINT) {
-                            ackContent.setDestinationIp(OspfUtil.ALL_SPF_ROUTERS);
-                        } else if (((OspfInterfaceImpl) ospfInterface).state() == OspfInterfaceState.DROTHER) {
-                            ackContent.setDestinationIp(OspfUtil.ALL_DROUTERS);
-                        }
-                        ch.write(ackContent);
-                        for (LsaHeader lsa : listOfLsaHeadersAcknowledged) {
-                            ((OspfInterfaceImpl) ospfInterface).linkStateHeaders().remove(lsa);
-                            ospfInterface.removeLsaFromNeighborMap(((OspfAreaImpl) ospfArea).getLsaKey(lsa));
-                        }
-                    }
-                }
-            }
+            log.debug("OspfChannelHandler sentConfigPacket channel not connected - re try..!!!");
+            this.configPacket = configPacket;
         }
     }
 }
\ No newline at end of file
diff --git a/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/impl/OspfMessageDecoder.java b/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/impl/OspfMessageDecoder.java
index baeae99..1d6ae23 100755
--- a/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/impl/OspfMessageDecoder.java
+++ b/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/impl/OspfMessageDecoder.java
@@ -19,8 +19,10 @@
 import org.jboss.netty.channel.Channel;
 import org.jboss.netty.channel.ChannelHandlerContext;
 import org.jboss.netty.handler.codec.frame.FrameDecoder;
-import org.onosproject.ospf.protocol.ospfpacket.OspfMessage;
+import org.onlab.packet.Ip4Address;
+import org.onosproject.ospf.controller.OspfMessage;
 import org.onosproject.ospf.protocol.ospfpacket.OspfMessageReader;
+import org.onosproject.ospf.protocol.util.OspfUtil;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -35,24 +37,35 @@
     private static final Logger log = LoggerFactory.getLogger(OspfMessageDecoder.class);
 
     @Override
-    protected Object decode(ChannelHandlerContext ctx, Channel channel, ChannelBuffer channelBuffer) throws Exception {
-        log.debug("OspfMessageDecoder::Message received <:> length {}", channelBuffer.readableBytes());
-        log.debug("channelBuffer.readableBytes - decode {}", channelBuffer.readableBytes());
+    protected Object decode(ChannelHandlerContext ctx, Channel channel, ChannelBuffer buffer) throws Exception {
+        log.debug("OspfMessageDecoder::Message received <:> length {}", buffer.readableBytes());
         if (!channel.isConnected()) {
             log.info("Channel is not connected.");
             return null;
         }
-
         OspfMessageReader messageReader = new OspfMessageReader();
         List<OspfMessage> ospfMessageList = new LinkedList<>();
-
-        while (channelBuffer.readableBytes() > 0) {
-            OspfMessage message = messageReader.readFromBuffer(channelBuffer);
+        while (buffer.readableBytes() >= OspfUtil.MINIMUM_FRAME_LEN) {
+            ChannelBuffer ospfDataBuffer = buffer.readBytes(OspfUtil.MINIMUM_FRAME_LEN);
+            int readableBytes = ospfDataBuffer.readableBytes();
+            OspfMessage message = messageReader.readFromBuffer(ospfDataBuffer);
             if (message != null) {
+                if (ospfDataBuffer.readableBytes() >= OspfUtil.METADATA_LEN) {
+                    ospfDataBuffer.readerIndex(readableBytes - OspfUtil.METADATA_LEN);
+                    log.debug("IsisMessageDecoder::Reading metadata <:> length {}", ospfDataBuffer.readableBytes());
+
+
+                    int interfaceIndex = ospfDataBuffer.readByte();
+                    byte[] sourceIpBytes = new byte[OspfUtil.FOUR_BYTES];
+                    ospfDataBuffer.readBytes(sourceIpBytes, 0, OspfUtil.FOUR_BYTES);
+                    Ip4Address sourceIP = Ip4Address.valueOf(sourceIpBytes);
+
+                    message.setSourceIp(sourceIP);
+                    message.setInterfaceIndex(interfaceIndex);
+                }
                 ospfMessageList.add(message);
             }
         }
-
-        return ospfMessageList;
+        return (ospfMessageList.size() > 0) ? ospfMessageList : null;
     }
 }
\ No newline at end of file
diff --git a/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/impl/OspfMessageEncoder.java b/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/impl/OspfMessageEncoder.java
old mode 100755
new mode 100644
index 95bdcdc..8ac971c
--- a/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/impl/OspfMessageEncoder.java
+++ b/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/impl/OspfMessageEncoder.java
@@ -17,15 +17,10 @@
 package org.onosproject.ospf.controller.impl;
 
 import org.jboss.netty.buffer.ChannelBuffer;
+import org.jboss.netty.buffer.ChannelBuffers;
 import org.jboss.netty.channel.Channel;
 import org.jboss.netty.channel.ChannelHandlerContext;
 import org.jboss.netty.handler.codec.oneone.OneToOneEncoder;
-import org.onosproject.ospf.controller.OspfInterface;
-import org.onosproject.ospf.controller.area.OspfInterfaceImpl;
-import org.onosproject.ospf.protocol.ospfpacket.OspfMessage;
-import org.onosproject.ospf.protocol.ospfpacket.OspfMessageWriter;
-import org.onosproject.ospf.protocol.util.OspfInterfaceState;
-import org.onosproject.ospf.protocol.util.OspfUtil;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -35,46 +30,15 @@
 public class OspfMessageEncoder extends OneToOneEncoder {
 
     private static final Logger log = LoggerFactory.getLogger(OspfMessageEncoder.class);
-    private OspfInterface ospfInterface;
-
-
-    /**
-     * Creates an instance of OSPF message encoder.
-     */
-    OspfMessageEncoder() {
-    }
-
-    /**
-     * Creates an instance of OSPF message encoder.
-     *
-     * @param ospfInterface OSPF interface instance
-     */
-    OspfMessageEncoder(OspfInterface ospfInterface) {
-        this.ospfInterface = ospfInterface;
-    }
 
     @Override
     protected Object encode(ChannelHandlerContext ctx, Channel channel, Object msg) throws Exception {
 
-        log.debug("Encoding ospfMessage...!!!");
-        if (!(msg instanceof OspfMessage)) {
-            log.debug("Invalid msg.");
-            return msg;
-        }
+        byte[] byteMsg = (byte[]) msg;
+        log.debug("Encoding ospfMessage of length {}", byteMsg.length);
+        ChannelBuffer channelBuffer = ChannelBuffers.buffer(byteMsg.length);
+        channelBuffer.writeBytes(byteMsg);
 
-        OspfMessage ospfMessage = (OspfMessage) msg;
-        OspfMessageWriter messageWriter = new OspfMessageWriter();
-        if (((OspfInterfaceImpl) ospfInterface).state().equals(OspfInterfaceState.POINT2POINT)) {
-            ospfMessage.setDestinationIp(OspfUtil.ALL_SPF_ROUTERS);
-        }
-        ChannelBuffer buf = messageWriter.writeToBuffer(ospfMessage,
-                                                        ((OspfInterfaceImpl) ospfInterface).state().value(),
-                                                        ospfInterface.interfaceType());
-        log.info("OspfMessageEncoder sending packet of lenght {}", buf.readableBytes());
-        log.debug("OspfMessageEncoder sending packet of lenght {}", buf.readableBytes());
-        log.debug("Sending {} Message to {}, Length :: {}, <=> {}", ospfMessage.ospfMessageType(),
-                  ospfMessage.destinationIp(), buf.readableBytes(), buf.array());
-
-        return buf;
+        return channelBuffer;
     }
 }
diff --git a/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/impl/OspfNbrImpl.java b/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/impl/OspfNbrImpl.java
index 1233c28..800d571 100755
--- a/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/impl/OspfNbrImpl.java
+++ b/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/impl/OspfNbrImpl.java
@@ -28,8 +28,10 @@
 import org.onosproject.ospf.controller.OspfLsa;
 import org.onosproject.ospf.controller.OspfLsaType;
 import org.onosproject.ospf.controller.OspfLsdb;
+import org.onosproject.ospf.controller.OspfMessage;
 import org.onosproject.ospf.controller.OspfNbr;
 import org.onosproject.ospf.controller.OspfNeighborState;
+import org.onosproject.ospf.controller.OspfPacketType;
 import org.onosproject.ospf.controller.OspfRouter;
 import org.onosproject.ospf.controller.TopologyForDeviceAndLink;
 import org.onosproject.ospf.controller.area.OspfAreaImpl;
@@ -40,7 +42,7 @@
 import org.onosproject.ospf.protocol.lsa.OpaqueLsaHeader;
 import org.onosproject.ospf.protocol.lsa.types.OpaqueLsa10;
 import org.onosproject.ospf.protocol.lsa.types.TopLevelTlv;
-import org.onosproject.ospf.protocol.ospfpacket.OspfMessage;
+import org.onosproject.ospf.protocol.ospfpacket.OspfMessageWriter;
 import org.onosproject.ospf.protocol.ospfpacket.OspfPacketHeader;
 import org.onosproject.ospf.protocol.ospfpacket.subtype.LsRequestPacket;
 import org.onosproject.ospf.protocol.ospfpacket.types.DdPacket;
@@ -49,7 +51,6 @@
 import org.onosproject.ospf.protocol.ospfpacket.types.LsUpdate;
 import org.onosproject.ospf.protocol.util.ChecksumCalculator;
 import org.onosproject.ospf.protocol.util.OspfInterfaceState;
-import org.onosproject.ospf.protocol.util.OspfPacketType;
 import org.onosproject.ospf.protocol.util.OspfParameters;
 import org.onosproject.ospf.protocol.util.OspfUtil;
 import org.slf4j.Logger;
@@ -181,7 +182,6 @@
      * A link to the OSPF-Area this Neighbor Data Structure belongs to.
      */
     private OspfArea ospfArea;
-    private OspfInterfaceChannelHandler handler;
     private List<TopLevelTlv> topLevelTlvs = new ArrayList<>();
     private List<DeviceInformation> deviceInformationList = new ArrayList<>();
 
@@ -195,12 +195,11 @@
      * @param ipAddr                         IP address
      * @param routerId                       router id
      * @param options                        options
-     * @param handler                        channel handler instance
      * @param topologyForDeviceAndLinkCommon topology for device and link instance
      */
     public OspfNbrImpl(OspfArea paramOspfArea, OspfInterface paramOspfInterface,
                        Ip4Address ipAddr, Ip4Address routerId, int options,
-                       OspfInterfaceChannelHandler handler, TopologyForDeviceAndLink topologyForDeviceAndLinkCommon) {
+                       TopologyForDeviceAndLink topologyForDeviceAndLinkCommon) {
         this.ospfArea = paramOspfArea;
         this.ospfInterface = paramOspfInterface;
         state = OspfNeighborState.DOWN;
@@ -211,7 +210,6 @@
         this.options = options;
         lastDdPacket = new DdPacket();
         routerDeadInterval = paramOspfInterface.routerDeadIntervalTime();
-        this.handler = handler;
         this.topologyForDeviceAndLink = topologyForDeviceAndLinkCommon;
     }
 
@@ -243,6 +241,15 @@
     }
 
     /**
+     * Sets router dead interval.
+     *
+     * @param routerDeadInterval router dead interval
+     */
+    public void setRouterDeadInterval(int routerDeadInterval) {
+        this.routerDeadInterval = routerDeadInterval;
+    }
+
+    /**
      * Have seen a Neighbor, but the Neighbor doesn't know about me.
      *
      * @param ospfHello Hello Packet instance
@@ -313,7 +320,8 @@
                 startRxMtDdTimer(channel);
                 //setting destination ip
                 ddPacket.setDestinationIp(packet.sourceIp());
-                channel.write(ddPacket);
+                byte[] messageToWrite = getMessage(ddPacket);
+                channel.write(messageToWrite);
             } else {
                 state = OspfNeighborState.TWOWAY;
             }
@@ -409,7 +417,8 @@
                 setLastSentDdPacket(ddPacket);
                 getIsMoreBit();
 
-                ch.write(lastSentDdPacket());
+                byte[] messageToWrite = getMessage(lastSentDdPacket);
+                ch.write(messageToWrite);
             } else {
                 // process LSA Vector's List, Add it to LSRequestList.
                 processLsas(payload);
@@ -437,7 +446,8 @@
                 setLastSentDdPacket(ddPacket);
                 getIsMoreBit();
                 ddPacket.setDestinationIp(packet.sourceIp());
-                ch.write(lastSentDdPacket());
+                byte[] messageToWrite = getMessage(lastSentDdPacket);
+                ch.write(messageToWrite);
                 startRxMtDdTimer(ch);
             }
         }
@@ -594,7 +604,8 @@
             //setting destination ip
             ddPacket.setDestinationIp(neighborIpAddr());
             setLastSentDdPacket(ddPacket);
-            ch.write(ddPacket);
+            byte[] messageToWrite = getMessage(ddPacket);
+            ch.write(messageToWrite);
         }
     }
 
@@ -651,7 +662,8 @@
                 getIsMoreBit();
                 //Set the destination IP Address
                 ddPacket.setDestinationIp(dataDescPkt.sourceIp());
-                ch.write(lastSentDdPacket());
+                byte[] messageToWrite = getMessage(lastSentDdPacket());
+                ch.write(messageToWrite);
 
                 startRxMtDdTimer(ch);
             }
@@ -692,7 +704,8 @@
             }
 
             ddPacket.setDestinationIp(dataDescPkt.sourceIp());
-            ch.write(ddPacket);
+            byte[] messageToWrite = getMessage(ddPacket);
+            ch.write(messageToWrite);
         }
     }
 
@@ -753,7 +766,8 @@
                 LsRequest lsRequest = buildLsRequest();
                 //Setting the destination address
                 lsRequest.setDestinationIp(header.sourceIp());
-                ch.write(lsRequest);
+                byte[] messageToWrite = getMessage(lsRequest);
+                ch.write(messageToWrite);
 
                 setLastSentLsrPacket(lsRequest);
                 startRxMtLsrTimer(ch);
@@ -859,7 +873,8 @@
                     //setting destination ip
                     ddPacket.setDestinationIp(neighborIpAddr());
                     setLastSentDdPacket(ddPacket);
-                    ch.write(ddPacket);
+                    byte[] messageToWrite = getMessage(ddPacket);
+                    ch.write(messageToWrite);
                 }
             } else if (state.getValue() >= OspfNeighborState.EXSTART.getValue()) {
                 if (!formAdjacencyOrNot()) {
@@ -942,39 +957,55 @@
      */
     private void callDeviceAndLinkAdding(TopologyForDeviceAndLink topologyForDeviceAndLink) {
         Map<String, DeviceInformation> deviceInformationMap = topologyForDeviceAndLink.deviceInformationMap();
+        Map<String, DeviceInformation> deviceInformationMapForPointToPoint =
+                topologyForDeviceAndLink.deviceInformationMapForPointToPoint();
+        Map<String, DeviceInformation> deviceInformationMapToDelete =
+                topologyForDeviceAndLink.deviceInformationMapToDelete();
         Map<String, LinkInformation> linkInformationMap = topologyForDeviceAndLink.linkInformationMap();
+        Map<String, LinkInformation> linkInformationMapForPointToPoint =
+                topologyForDeviceAndLink.linkInformationMapForPointToPoint();
         OspfRouter ospfRouter = new OspfRouterImpl();
-        log.debug("Device Information in list format along with size {}", deviceInformationMap.size());
-        for (String key : deviceInformationMap.keySet()) {
-            DeviceInformation value = deviceInformationMap.get(key);
-            ospfRouter.setRouterIp(value.routerId());
-            ospfRouter.setAreaIdOfInterface(ospfArea.areaId());
-            ospfRouter.setNeighborRouterId(value.deviceId());
-            OspfDeviceTed ospfDeviceTed = new OspfDeviceTedImpl();
-            List<Ip4Address> ip4Addresses = value.interfaceId();
-            ospfDeviceTed.setIpv4RouterIds(ip4Addresses);
-            ospfRouter.setDeviceTed(ospfDeviceTed);
-            ospfRouter.setOpaque(ospfArea.isOpaqueEnabled());
-            if (value.isDr()) {
-                ospfRouter.setDr(value.isDr());
-            } else {
-                ospfRouter.setDr(false);
+
+        if (deviceInformationMap.size() != 0) {
+            for (String key : deviceInformationMap.keySet()) {
+                DeviceInformation value = deviceInformationMap.get(key);
+                ospfRouter.setRouterIp(value.routerId());
+                ospfRouter.setAreaIdOfInterface(ospfArea.areaId());
+                ospfRouter.setNeighborRouterId(value.deviceId());
+                OspfDeviceTed ospfDeviceTed = new OspfDeviceTedImpl();
+                List<Ip4Address> ip4Addresses = value.interfaceId();
+                ospfDeviceTed.setIpv4RouterIds(ip4Addresses);
+                ospfRouter.setDeviceTed(ospfDeviceTed);
+                ospfRouter.setOpaque(ospfArea.isOpaqueEnabled());
+                if (value.isDr()) {
+                    ospfRouter.setDr(value.isDr());
+                } else {
+                    ospfRouter.setDr(false);
+                }
+                int size = value.interfaceId().size();
+                for (int i = 0; i < size; i++) {
+                    ospfRouter.setInterfaceId(value.interfaceId().get(i));
+                }
+                ((OspfInterfaceImpl) ospfInterface).addDeviceInformation(ospfRouter);
             }
-            int size = value.interfaceId().size();
-            for (int i = 0; i < size; i++) {
-                ospfRouter.setInterfaceId(value.interfaceId().get(i));
+        }
+        if (deviceInformationMapForPointToPoint.size() != 0) {
+            for (String key : deviceInformationMapForPointToPoint.keySet()) {
+                DeviceInformation value = deviceInformationMapForPointToPoint.get(key);
+                ospfRouter.setRouterIp(value.routerId());
+                ospfRouter.setAreaIdOfInterface(ospfArea.areaId());
+                ospfRouter.setNeighborRouterId(value.deviceId());
+                OspfDeviceTed ospfDeviceTed = new OspfDeviceTedImpl();
+                List<Ip4Address> ip4Addresses = value.interfaceId();
+                ospfDeviceTed.setIpv4RouterIds(ip4Addresses);
+                ospfRouter.setDeviceTed(ospfDeviceTed);
+                ospfRouter.setOpaque(value.isDr());
+                int size = value.interfaceId().size();
+                for (int i = 0; i < size; i++) {
+                    ospfRouter.setInterfaceId(value.interfaceId().get(i));
+                }
+                ((OspfInterfaceImpl) ospfInterface).addDeviceInformation(ospfRouter);
             }
-            if (value.isAlreadyCreated()) {
-                removeDeviceDetails(value.routerId());
-                OspfRouter ospfRouter1 = new OspfRouterImpl();
-                ospfRouter1.setRouterIp(value.routerId());
-                ospfRouter1.setInterfaceId(ospfInterface.ipAddress());
-                ospfRouter1.setAreaIdOfInterface(ospfArea.areaId());
-                ospfRouter1.setDeviceTed(new OspfDeviceTedImpl());
-                topologyForDeviceAndLink.removeLinks(value.routerId());
-                handler.removeDeviceInformation(ospfRouter1);
-            }
-            handler.addDeviceInformation(ospfRouter);
         }
         for (Map.Entry<String, LinkInformation> entry : linkInformationMap.entrySet()) {
             String key = entry.getKey();
@@ -983,8 +1014,8 @@
             ospfRouterForLink.setInterfaceId(value.interfaceIp());
             ospfRouterForLink.setAreaIdOfInterface(ospfArea.areaId());
             ospfRouterForLink.setOpaque(ospfArea.isOpaqueEnabled());
-            OspfLinkTed ospfLinkTed =
-                    topologyForDeviceAndLink.getOspfLinkTedHashMap(value.linkDestinationId().toString());
+            OspfLinkTed ospfLinkTed = topologyForDeviceAndLink.getOspfLinkTedHashMap(
+                    value.linkDestinationId().toString());
             if (ospfLinkTed == null) {
                 ospfLinkTed = new OspfLinkTedImpl();
                 ospfLinkTed.setMaximumLink(Bandwidth.bps(0));
@@ -996,13 +1027,9 @@
                 ospfRouterForLink.setRouterIp(value.linkSourceId());
                 ospfRouterForLink.setNeighborRouterId(value.linkDestinationId());
                 try {
-                    handler.addLinkInformation(ospfRouterForLink, ospfLinkTed);
-                    log.debug("LinkId, LinkSrc , LinkDest , LinkInterface values are : "
-                                      + value.linkId() + " , " + value.linkSourceId() + "  , "
-                                      + value.linkDestinationId() + " , "
-                                      + value.interfaceIp());
+                    ((OspfInterfaceImpl) ospfInterface).addLinkInformation(ospfRouterForLink, ospfLinkTed);
                 } catch (Exception e) {
-                    log.debug("Got Exception : {}", e.getMessage());
+                    log.debug("Exception addLinkInformation: " + e.getMessage());
                 }
             }
         }
@@ -1178,11 +1205,31 @@
                 }
             }
         }
+
+        constructDeviceInformationFromDb();
         callDeviceAndLinkAdding(topologyForDeviceAndLink);
+
         return true;
     }
 
     /**
+     * Constructs device and link information from link state database.
+     */
+    private void constructDeviceInformationFromDb() {
+        OspfLsdb database = ospfArea.database();
+        List lsas = database.getAllLsaHeaders(true, true);
+        Iterator iterator = lsas.iterator();
+        while (iterator.hasNext()) {
+            OspfLsa ospfLsa = (OspfLsa) iterator.next();
+            if (ospfLsa.getOspfLsaType().value() == OspfLsaType.ROUTER.value()) {
+                topologyForDeviceAndLink.addLocalDevice(ospfLsa, ospfInterface, ospfArea);
+            } else if (ospfLsa.getOspfLsaType().value() == OspfLsaType.NETWORK.value()) {
+                topologyForDeviceAndLink.addLocalDevice(ospfLsa, ospfInterface, ospfArea);
+            }
+        }
+    }
+
+    /**
      * Checks Link State ID is equal to one of the router's own IP interface addresses.
      *
      * @param linkStateId link state id
@@ -1190,7 +1237,7 @@
      */
     private boolean isLinkStateMatchesOwnRouterId(String linkStateId) {
         boolean isLinkStateMatches = false;
-        List<OspfInterface> interfaceLst = ospfArea.getInterfacesLst();
+        List<OspfInterface> interfaceLst = ospfArea.ospfInterfaceList();
         for (OspfInterface ospfInterface : interfaceLst) {
             if (ospfInterface.ipAddress().toString().equals(linkStateId)) {
                 isLinkStateMatches = true;
@@ -1262,7 +1309,8 @@
 
         //setting the destination.
         responseLsUpdate.setDestinationIp(destination);
-        ch.write(responseLsUpdate);
+        byte[] messageToWrite = getMessage(responseLsUpdate);
+        ch.write(messageToWrite);
     }
 
     /**
@@ -1288,7 +1336,8 @@
         ackContent.addLinkStateHeader(ackLsa);
         //setting the destination IP
         ackContent.setDestinationIp(sourceIp);
-        ch.write(ackContent);
+        byte[] messageToWrite = getMessage(ackContent);
+        ch.write(messageToWrite);
     }
 
     /**
@@ -1314,7 +1363,7 @@
         ddSummaryList.clear();
         if (neighborIpAddr.equals(neighborBdr) ||
                 neighborIpAddr.equals(neighborDr)) {
-            handler.neighborChange();
+            ((OspfInterfaceImpl) ospfInterface).neighborChange();
         }
         log.debug("Neighbor Went Down : "
                           + this.neighborIpAddr + " , " + this.neighborId);
@@ -1324,16 +1373,14 @@
         ospfRouter.setInterfaceId(ospfInterface.ipAddress());
         ospfRouter.setAreaIdOfInterface(ospfArea.areaId());
         ospfRouter.setDeviceTed(new OspfDeviceTedImpl());
-        handler.removeDeviceInformation(ospfRouter);
+        ((OspfInterfaceImpl) ospfInterface).removeDeviceInformation(ospfRouter);
         removeDeviceDetails(this.neighborIpAddr);
         OspfRouter ospfRouter1 = new OspfRouterImpl();
         ospfRouter1.setRouterIp(this.neighborIpAddr);
         ospfRouter1.setInterfaceId(ospfInterface.ipAddress());
         ospfRouter1.setAreaIdOfInterface(ospfArea.areaId());
         ospfRouter1.setDeviceTed(new OspfDeviceTedImpl());
-        handler.removeDeviceInformation(ospfRouter1);
-        handler.removeLinkInformation(this);
-        callDeviceAndLinkAdding(topologyForDeviceAndLink);
+        ((OspfInterfaceImpl) ospfInterface).removeDeviceInformation(ospfRouter1);
     }
 
     /**
@@ -1344,13 +1391,12 @@
     private void removeDeviceDetails(Ip4Address routerId) {
         String key = "device:" + routerId;
         topologyForDeviceAndLink.removeDeviceInformationMap(key);
-        topologyForDeviceAndLink.removeLinks(routerId);
     }
 
     /**
      * Starts the inactivity timer.
      */
-    private void startInactivityTimeCheck() {
+    public void startInactivityTimeCheck() {
         if (!inActivityTimerScheduled) {
             log.debug("OSPFNbr::startInactivityTimeCheck");
             inActivityTimeCheckTask = new InternalInactivityTimeCheck();
@@ -1364,7 +1410,7 @@
     /**
      * Stops the inactivity timer.
      */
-    private void stopInactivityTimeCheck() {
+    public void stopInactivityTimeCheck() {
         if (inActivityTimerScheduled) {
             log.debug("OSPFNbr::stopInactivityTimeCheck ");
             exServiceInActivity.shutdown();
@@ -1393,7 +1439,7 @@
     /**
      * Stops the flooding timer.
      */
-    private void stopFloodingTimer() {
+    public void stopFloodingTimer() {
         if (floodingTimerScheduled) {
             log.debug("OSPFNbr::stopFloodingTimer ");
             exServiceFlooding.shutdown();
@@ -1420,7 +1466,7 @@
     /**
      * Stops the Dd Retransmission executor task.
      */
-    private void stopRxMtDdTimer() {
+    public void stopRxMtDdTimer() {
         if (rxmtDdPacketTimerScheduled) {
             exServiceRxmtDDPacket.shutdown();
             rxmtDdPacketTimerScheduled = false;
@@ -1447,7 +1493,7 @@
     /**
      * Stops Ls request retransmission executor task.
      */
-    private void stopRxMtLsrTimer() {
+    public void stopRxMtLsrTimer() {
         if (rxmtLsrTimerScheduled) {
             exServiceRxmtLsr.shutdown();
             rxmtLsrTimerScheduled = false;
@@ -1679,6 +1725,21 @@
         return pendingReTxList;
     }
 
+    /**
+     * Gets message as bytes.
+     *
+     * @param ospfMessage OSPF message
+     * @return OSPF message
+     */
+    private byte[] getMessage(OspfMessage ospfMessage) {
+        OspfMessageWriter messageWriter = new OspfMessageWriter();
+        if (((OspfInterfaceImpl) ospfInterface).state().equals(OspfInterfaceState.POINT2POINT)) {
+            ospfMessage.setDestinationIp(OspfUtil.ALL_SPF_ROUTERS);
+        }
+        return (messageWriter.getMessage(ospfMessage, ospfInterface.interfaceIndex(),
+                                         ((OspfInterfaceImpl) ospfInterface).state().value()));
+    }
+
 
     /**
      * Represents a Task which will do an inactivity time check.
@@ -1720,7 +1781,8 @@
         public void run() {
             if ((ch != null) && ch.isConnected()) {
                 DdPacket ddPacket = lastSentDdPacket();
-                ch.write(ddPacket);
+                byte[] messageToWrite = getMessage(ddPacket);
+                ch.write(messageToWrite);
                 log.debug("Re-Transmit DD Packet .");
             } else {
                 log.debug(
@@ -1748,7 +1810,8 @@
         public void run() {
             if ((ch != null) && ch.isConnected()) {
                 LsRequest lsrPacket = getLastSentLsrPacket();
-                ch.write(lsrPacket);
+                byte[] messageToWrite = getMessage(lsrPacket);
+                ch.write(messageToWrite);
                 log.debug("Re-Transmit LSRequest Packet .");
             } else {
                 log.debug(
@@ -1783,7 +1846,8 @@
                     for (LsUpdate lsupdate : lsUpdateList) {
                         //Pending for acknowledge directly sent it to neighbor
                         lsupdate.setDestinationIp(neighborIpAddr);
-                        channel.write(lsupdate);
+                        byte[] messageToWrite = getMessage(lsupdate);
+                        channel.write(messageToWrite);
                     }
                 }
 
@@ -1799,7 +1863,8 @@
                                 (((OspfInterfaceImpl) ospfInterface).state() == OspfInterfaceState.BDR)) {
                             lsupdate.setDestinationIp(neighborDr);
                         }
-                        channel.write(lsupdate);
+                        byte[] messageToWrite = getMessage(lsupdate);
+                        channel.write(messageToWrite);
                     }
                 }
             }
diff --git a/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/impl/OspfPipelineFactory.java b/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/impl/OspfPipelineFactory.java
index 394f783..1b1a108 100755
--- a/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/impl/OspfPipelineFactory.java
+++ b/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/impl/OspfPipelineFactory.java
@@ -18,57 +18,29 @@
 import org.jboss.netty.channel.ChannelPipeline;
 import org.jboss.netty.channel.ChannelPipelineFactory;
 import org.jboss.netty.channel.Channels;
-import org.jboss.netty.handler.timeout.ReadTimeoutHandler;
-import org.jboss.netty.util.ExternalResourceReleasable;
-import org.jboss.netty.util.HashedWheelTimer;
-import org.jboss.netty.util.Timer;
-import org.onosproject.ospf.controller.OspfArea;
-import org.onosproject.ospf.controller.OspfInterface;
 
 /**
- * Creates a ChannelPipeline for a server-side OSPF channel.
+ * Creates a ChannelPipeline for a client-side OSPF channel.
  */
-public class OspfPipelineFactory implements ChannelPipelineFactory, ExternalResourceReleasable {
-
-    private static final Timer TIMER = new HashedWheelTimer();
-    private Controller controller;
-    private ReadTimeoutHandler readTimeoutHandler;
-    private OspfArea ospfArea;
-    private OspfInterface ospfInterface;
-    private int holdTime = 120 * 1000;
+public class OspfPipelineFactory implements ChannelPipelineFactory {
+    private OspfInterfaceChannelHandler ospfChannelHandler;
 
     /**
-     * Creates an instance of OSPF pipeline factory.
+     * Creates an instance of OSPF channel pipeline factory.
      *
-     * @param controller    controller instance.
-     * @param ospfArea      OSPF area instance.
-     * @param ospfInterface OSPF interface instance.
+     * @param ospfChannelHandler OSPF channel handler instance
      */
-    public OspfPipelineFactory(Controller controller, OspfArea ospfArea, OspfInterface ospfInterface) {
-        super();
-        this.controller = controller;
-        this.ospfArea = ospfArea;
-        this.ospfInterface = ospfInterface;
-        readTimeoutHandler = new ReadTimeoutHandler(TIMER, holdTime);
+    public OspfPipelineFactory(OspfInterfaceChannelHandler ospfChannelHandler) {
+        this.ospfChannelHandler = ospfChannelHandler;
     }
 
     @Override
     public ChannelPipeline getPipeline() throws Exception {
-        OspfInterfaceChannelHandler interfaceHandler = new OspfInterfaceChannelHandler(
-                controller, ospfArea, ospfInterface);
-
         ChannelPipeline pipeline = Channels.pipeline();
-        pipeline.addLast("encoder", new OspfMessageEncoder(ospfInterface));
-        pipeline.addLast("decoder", new OspfMessageDecoder());
-        pipeline.addLast("holdTime", readTimeoutHandler);
-        pipeline.addLast("interfacehandler", interfaceHandler);
+        pipeline.addLast("encoder", new OspfMessageDecoder());
+        pipeline.addLast("decoder", new OspfMessageEncoder());
+        pipeline.addLast("handler", ospfChannelHandler);
 
         return pipeline;
     }
-
-    @Override
-    public void releaseExternalResources() {
-        TIMER.stop();
-    }
-
 }
\ No newline at end of file
diff --git a/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/impl/TopologyForDeviceAndLinkImpl.java b/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/impl/TopologyForDeviceAndLinkImpl.java
index e488e31..86dd2cf 100755
--- a/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/impl/TopologyForDeviceAndLinkImpl.java
+++ b/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/impl/TopologyForDeviceAndLinkImpl.java
@@ -38,6 +38,7 @@
 import org.onosproject.ospf.protocol.lsa.types.OpaqueLsa10;
 import org.onosproject.ospf.protocol.lsa.types.RouterLsa;
 import org.onosproject.ospf.protocol.lsa.types.TopLevelTlv;
+import org.onosproject.ospf.protocol.util.OspfUtil;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -49,6 +50,7 @@
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
+import java.util.TreeSet;
 
 /**
  * Represents device and link topology information.
@@ -56,7 +58,11 @@
 public class TopologyForDeviceAndLinkImpl implements TopologyForDeviceAndLink {
 
     private static final Logger log = LoggerFactory.getLogger(TopologyForDeviceAndLinkImpl.class);
+    Set<Ip4Address> routerSet = new TreeSet<Ip4Address>();
+    Ip4Address firstValue = Ip4Address.valueOf("0.0.0.0");
     private Map<String, DeviceInformation> deviceInformationMap = new LinkedHashMap();
+    private Map<Ip4Address, List<Ip4Address>> networkLsaMap = new LinkedHashMap();
+    private Map<String, DeviceInformation> deviceInformationMapForPointToPoint = new LinkedHashMap();
     private Map<String, DeviceInformation> deviceInformationMapToDelete = new LinkedHashMap();
     private HashMap<String, Set<OspfLsaLink>> deviceAndLinkInformation = new HashMap();
     private HashMap<String, OspfLinkTed> ospfLinkTedHashMap = new LinkedHashMap();
@@ -64,6 +70,7 @@
     private Ip4Address drRouterOld = Ip4Address.valueOf("0.0.0.0");
     private Ip4Address adRouterId = Ip4Address.valueOf("0.0.0.0");
     private Map<String, LinkInformation> linkInformationMap = new LinkedHashMap();
+    private Map<String, LinkInformation> linkInformationMapForPointToPoint = new LinkedHashMap();
     private List<String> toRemove = new ArrayList<>();
 
     /**
@@ -89,9 +96,31 @@
     }
 
     /**
-     * Gets device information.
+     * Gets deviceInformation as map for Point-To-Point.
      *
-     * @return device information to delete from core
+     * @return deviceInformationMap
+     */
+    public Map<String, DeviceInformation> deviceInformationMapForPointToPoint() {
+        return deviceInformationMapForPointToPoint;
+    }
+
+    /**
+     * Sets deviceInformation as map for Point-To-Point..
+     *
+     * @param key                  key to store device information
+     * @param deviceInformationMap device information instance
+     */
+    public void setDeviceInformationMapForPointToPoint(String key, DeviceInformation deviceInformationMap) {
+        if (deviceInformationMap != null) {
+            this.deviceInformationMapForPointToPoint.put(key, deviceInformationMap);
+        }
+
+    }
+
+    /**
+     * Gets deviceInformation as map.
+     *
+     * @return deviceInformationMap to delete from core
      */
     public Map<String, DeviceInformation> deviceInformationMapToDelete() {
         return deviceInformationMapToDelete;
@@ -103,8 +132,7 @@
      * @param key                          ket used to add in map
      * @param deviceInformationMapToDelete map from device information to remove
      */
-    public void setDeviceInformationMapToDelete(String key,
-                                                DeviceInformation deviceInformationMapToDelete) {
+    public void setDeviceInformationMapToDelete(String key, DeviceInformation deviceInformationMapToDelete) {
         if (deviceInformationMapToDelete != null) {
             this.deviceInformationMapToDelete.put(key, deviceInformationMapToDelete);
         }
@@ -153,6 +181,11 @@
         return linkInformationMap;
     }
 
+    private LinkInformation getLinkInformation(String key) {
+        LinkInformation linkInformation = this.linkInformationMap.get(key);
+        return linkInformation;
+    }
+
     /**
      * Sets link information in map.
      *
@@ -166,9 +199,30 @@
     }
 
     /**
-     * Removes Link Information from map.
+     * Gets linkInformation as map for PointToPoint.
      *
-     * @param key key used to remove from map
+     * @return linkInformationMap
+     */
+    public Map<String, LinkInformation> linkInformationMapForPointToPoint() {
+        return linkInformationMap;
+    }
+
+    /**
+     * Sets linkInformation as map for PointToPoint.
+     *
+     * @param key                key to store link information
+     * @param linkInformationMap link information instance
+     */
+    public void setLinkInformationMapForPointToPoint(String key, LinkInformation linkInformationMap) {
+        if (!this.linkInformationMap.containsKey(key)) {
+            this.linkInformationMap.put(key, linkInformationMap);
+        }
+    }
+
+    /**
+     * Removes Link Information from linkInformationMap.
+     *
+     * @param key key to remove link information
      */
     public void removeLinkInformationMap(String key) {
         if (this.linkInformationMap.containsKey(key)) {
@@ -242,108 +296,136 @@
         List<OspfLsaLink> ospfLsaLinkList = routerLsa.routerLink();
         Iterator iterator = ospfLsaLinkList.iterator();
         Ip4Address advertisingRouterId = routerLsa.advertisingRouter();
-        adRouterId = advertisingRouterId;
         while (iterator.hasNext()) {
             OspfLsaLink ospfLsaLink = (OspfLsaLink) iterator.next();
             Ip4Address linkId = Ip4Address.valueOf(ospfLsaLink.linkId());
             Ip4Address linkData = Ip4Address.valueOf(ospfLsaLink.linkData());
             if (ospfLsaLink.linkType() == 1) {
                 if ((advertisingRouterId.equals(ospfArea.routerId())) || (linkId.equals(ospfArea.routerId()))) {
-                    System.out.println("OspfInterface information will not display in web ");
-                } else {
-                    removeDevice(advertisingRouterId);
-                    removeLinks(advertisingRouterId);
-                    DeviceInformation deviceInformationPointToPoint =
-                            createDeviceInformation(false, linkId, linkId, advertisingRouterId, linkData,
-                                                    ospfArea.areaId(), false);
-                    String key = "device:" + advertisingRouterId;
-                    setDeviceInformationMap(key, deviceInformationPointToPoint);
-                    String linkIdKey = "linkId:" + advertisingRouterId + "-" + linkId;
-                    addLocalLink(linkIdKey, linkData, advertisingRouterId, linkId, true, false);
-                }
-            } else if (ospfLsaLink.linkType() == 2) {
-
-                if ((advertisingRouterId.equals(ospfArea.routerId())) || (linkId.equals(ospfArea.routerId()))) {
-                    log.debug("OspfInterface information will not display in web ");
-                } else {
-                    if (linkId.equals(linkData)) {
-                        if (drRouter.equals(Ip4Address.valueOf("0.0.0.0"))) {
-                            log.debug("drRouter not elected {} ", drRouter.toString());
-                        } else {
-                            if (drRouterOld.equals(linkId)) {
-                                log.debug("drRouterOld same as link id {} ", drRouterOld.toString());
-                            } else {
-                                String key = "device:" + drRouterOld;
-                                DeviceInformation deviceInformation1 = deviceInformation(key);
-                                if (deviceInformation1 != null) {
-                                    deviceInformation1.setAlreadyCreated(true);
-                                    setDeviceInformationMapToDelete(key, deviceInformation1);
-                                    String linkIdKey = "linkId:" + linkId + "-" + deviceInformation1.neighborId();
-                                    addLocalLink(linkIdKey, linkData, linkId, deviceInformation1.neighborId(),
-                                                 true, false);
-                                    String linkIdKey1 = "linkId:" + linkId + "-" + advertisingRouterId;
-                                    addLocalLink(linkIdKey1, linkData, linkId, advertisingRouterId, true, false);
-                                } else {
-                                    DeviceInformation deviceInformationToDelete =
-                                            createDeviceInformation(true, drRouterOld, drRouterOld,
-                                                                    drRouterOld, drRouterOld,
-                                                                    drRouterOld, true);
-                                    setDeviceInformationMapToDelete(key, deviceInformationToDelete);
-                                    String linkIdKey1 = "linkId:" + linkId + "-" + advertisingRouterId;
-                                    addLocalLink(linkIdKey1, linkData, linkId, advertisingRouterId, true, false);
-                                }
-                            }
-                        }
-                        drRouter = linkId;
-                        drRouterOld = linkId;
-                        DeviceInformation deviceInformationForDr =
-                                createDeviceInformation(false, linkId, advertisingRouterId, linkId, linkData,
-                                                        ospfArea.areaId(), true);
-                        String key = "device:" + linkId;
-                        setDeviceInformationMap(key, deviceInformationForDr);
-                        DeviceInformation deviceInformationForAdvertisingRouter =
-                                createDeviceInformation(false, linkId, advertisingRouterId, advertisingRouterId,
-                                                        linkData, ospfArea.areaId(), false);
-                        String key1 = "device:" + advertisingRouterId;
-                        setDeviceInformationMap(key1, deviceInformationForAdvertisingRouter);
-                        if (drRouter.equals(Ip4Address.valueOf("0.0.0.0"))) {
-                            System.out.println("Link will not get create since dr is not valid");
-                            //Need to analysis since this place will not get Dr information
-                            String linkIdKey = "linkId:" + linkId + "-" + advertisingRouterId;
-                            addLocalLink(linkIdKey, linkData, linkId, advertisingRouterId, true, false);
-                        } else {
-                            String linkIdKey = "linkId:" + drRouter + "-" + advertisingRouterId;
-                            addLocalLink(linkIdKey, linkData, drRouter, advertisingRouterId, true, false);
-                        }
-                    } else {
-                        DeviceInformation deviceInformationDrOther =
-                                createDeviceInformation(false, linkId, linkId, advertisingRouterId,
-                                                        linkData, ospfArea.areaId(), false);
+                    if (!advertisingRouterId.equals(ospfArea.routerId())) {
+                        DeviceInformation deviceInformationPointToPoint =
+                                createDeviceInformation(false, linkId, linkId, advertisingRouterId, linkData,
+                                                        ospfArea.areaId(), false);
                         String key = "device:" + advertisingRouterId;
-                        setDeviceInformationMap(key, deviceInformationDrOther);
-                        if (drRouter.equals(Ip4Address.valueOf("0.0.0.0"))) {
-                            String linkIdKey = "linkId:" + linkId + "-" + advertisingRouterId;
-                            addLocalLink(linkIdKey, linkData, linkId, advertisingRouterId, true, false);
-                        } else {
-                            String linkIdKey = "linkId:" + drRouter + "-" + advertisingRouterId;
-                            addLocalLink(linkIdKey, linkData, drRouter, advertisingRouterId, true, false);
-                        }
+                        setDeviceInformationMapForPointToPoint(key, deviceInformationPointToPoint);
                     }
+                } else {
+                    DeviceInformation deviceInformationPointToPoint =
+                            createDeviceInformation(false, linkId, linkId, advertisingRouterId,
+                                                    linkData, ospfArea.areaId(), false);
+                    String key = "device:" + advertisingRouterId;
+                    setDeviceInformationMapForPointToPoint(key, deviceInformationPointToPoint);
+                    String linkIdKey = "linkId:" + advertisingRouterId + "-" + linkId;
+                    addLocalLinkForPointToPoint(linkIdKey, linkData, advertisingRouterId, linkId, true, false);
                 }
             }
         }
     }
 
     /**
-     * Creates Device and Link instance from the NetworkLsa parameters.
+     * Creates device and link instance from the network LSA parameters.
      *
      * @param ospfLsa  OSPF LSA instance
      * @param ospfArea OSPF area instance
      */
     private void createDeviceAndLinkFromNetworkLsa(OspfLsa ospfLsa, OspfArea ospfArea) {
         NetworkLsa networkLsa = (NetworkLsa) ospfLsa;
-        Ip4Address advertisingRouterId = networkLsa.networkMask();
-        System.out.println("AdvertisingRouterId is : " + advertisingRouterId);
+        Ip4Address linkStateId = Ip4Address.valueOf(networkLsa.linkStateId());
+        Set<Ip4Address> drList = networkLsaMap.keySet();
+        try {
+            Ip4Address drToReplace = null;
+            for (Ip4Address drIp : drList) {
+                if (!drIp.equals(linkStateId)) {
+                    if (OspfUtil.sameNetwork(drIp, linkStateId, networkLsa.networkMask())) {
+                        drToReplace = drIp;
+                        String key = "device:" + drToReplace;
+                        DeviceInformation deleteDr = deviceInformation(key);
+                        if (deleteDr != null) {
+                            deleteDr.setAlreadyCreated(true);
+                            setDeviceInformationMapToDelete(key, deleteDr);
+                        }
+
+                        networkLsaMap.remove(drToReplace);
+                        break;
+                    }
+                }
+            }
+            networkLsaMap.put(linkStateId, networkLsa.attachedRouters());
+
+        } catch (Exception e) {
+            log.debug("Error::TopologyForDeviceAndLinkImpl:: {}", e.getMessage());
+        }
+        constructDeviceForBroadCastTopology(ospfArea);
+        disp();
+
+    }
+
+    private void constructDeviceForBroadCastTopology(OspfArea ospfArea) {
+
+        for (Map.Entry<Ip4Address, List<Ip4Address>> entry : networkLsaMap.entrySet()) {
+            Ip4Address key = entry.getKey();
+            DeviceInformation deviceInformationForDr = createDeviceInformation(false, key, key, key,
+                                                                               key, ospfArea.areaId(), true);
+            String dr = "device:" + key;
+            setDeviceInformationMap(dr, deviceInformationForDr);
+            List<Ip4Address> value = entry.getValue();
+            for (Ip4Address connectedRouter : value) {
+                if (!connectedRouter.equals(ospfArea.routerId())) {
+                    DeviceInformation deviceInformationAttachedRouters =
+                            createDeviceInformation(false, connectedRouter, key, connectedRouter,
+                                                    key, ospfArea.areaId(), false);
+                    String attachedRouters = "device:" + connectedRouter;
+                    setDeviceInformationMap(attachedRouters, deviceInformationAttachedRouters);
+                    String linkIdKey = "linkId:" + key + "-" + connectedRouter;
+                    addLocalLink(linkIdKey, key, key, connectedRouter, true, false);
+                }
+            }
+        }
+
+    }
+
+    private void disp() {
+        for (String key : deviceInformationMap.keySet()) {
+            DeviceInformation deviceInformation = deviceInformationMap.get(key);
+            log.debug("************************************************************************");
+            log.debug("DeviceInfoList RouterId is : {} and neighbour is  {} and linkdata {}",
+                      deviceInformation.routerId(), deviceInformation.neighborId(), deviceInformation.interfaceId());
+        }
+
+        for (Map.Entry<String, LinkInformation> entry : linkInformationMap.entrySet()) {
+            String linkDetail = entry.getKey();
+            log.debug("Link From and to is  " + linkDetail);
+        }
+        log.debug("Devices Needs to delete from Core are  : " + deviceInformationMapToDelete.size());
+        for (String key : deviceInformationMapToDelete.keySet()) {
+            DeviceInformation value = deviceInformationMapToDelete.get(key);
+            if (value.isAlreadyCreated()) {
+                log.debug("Device is deleted from list " + value.routerId());
+            }
+        }
+    }
+
+    private void getLinksToDelete(Set<Ip4Address> list, Ip4Address value, OspfArea ospfArea) {
+
+        Iterator iterator = list.iterator();
+
+        while (iterator.hasNext()) {
+            Ip4Address secondValue = (Ip4Address) iterator.next();
+            if (!value.equals("0.0.0.0")) {
+                if ((!value.equals(secondValue))) {
+                    if ((!secondValue.equals(ospfArea.routerId()))) {
+                        String key = "link:" + value.toString() + "-" + secondValue.toString();
+                        String key1 = "link:" + secondValue.toString() + "-" + value.toString();
+                        LinkInformation linkDetails = getLinkInformation(key);
+                        LinkInformation linkDetailsOther = getLinkInformation(key1);
+                        linkInformationMapForPointToPoint.put(key, linkDetails);
+                        linkInformationMapForPointToPoint.put(key1, linkDetailsOther);
+                    }
+                }
+            }
+
+        }
+
     }
 
     /**
@@ -444,13 +526,40 @@
     }
 
     /**
+     * Adds link information to LinkInformationMap for PointToPoint.
+     *
+     * @param advertisingRouter    advertising router
+     * @param linkData             link data
+     * @param linkSrc              link source
+     * @param linkDest             link destination
+     * @param opaqueEnabled        whether opaque is enabled or not
+     * @param linkSrcIdNotRouterId whether link is source id or router id
+     */
+    public void addLocalLinkForPointToPoint(String advertisingRouter, Ip4Address linkData, Ip4Address linkSrc,
+                                            Ip4Address linkDest, boolean opaqueEnabled, boolean linkSrcIdNotRouterId) {
+        String linkKey = "link:";
+        LinkInformation linkInformation = new LinkInformationImpl();
+        linkInformation.setLinkId(advertisingRouter);
+        linkInformation.setLinkSourceId(linkSrc);
+        linkInformation.setLinkDestinationId(linkDest);
+        linkInformation.setAlreadyCreated(false);
+        linkInformation.setLinkSrcIdNotRouterId(linkSrcIdNotRouterId);
+        linkInformation.setInterfaceIp(linkData);
+        if (linkDest != null) {
+            linkInformation.setLinkSrcIdNotRouterId(false);
+        }
+        linkKey = linkKey + "-" + linkSrc + "-" + linkDest;
+        setLinkInformationMapForPointToPoint(linkKey, linkInformation);
+    }
+
+    /**
      * Removes links from LinkInformationMap.
      *
      * @param routerId router id
      */
     public void removeLinks(Ip4Address routerId) {
-        Map<String, LinkInformation> linkInformationMaplocal = linkInformationMap;
-        if (linkInformationMaplocal != null) {
+        Map<String, LinkInformation> linkInformationMapLocal = linkInformationMap;
+        if (linkInformationMapLocal != null) {
             for (Map.Entry<String, LinkInformation> entry : linkInformationMap.entrySet()) {
                 String key = entry.getKey();
                 boolean check = key.contains(routerId.toString());
diff --git a/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/lsdb/LsaWrapperImpl.java b/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/lsdb/LsaWrapperImpl.java
index 42f05cd..a883f72 100755
--- a/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/lsdb/LsaWrapperImpl.java
+++ b/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/lsdb/LsaWrapperImpl.java
@@ -49,6 +49,15 @@
     private int binNumber = -1;
     private OspfInterface ospfInterface;
     private LsdbAge lsdbAge;
+    private int ageCounterRollOverWhenAdded;
+
+    public int getAgeCounterRollOverWhenAdded() {
+        return ageCounterRollOverWhenAdded;
+    }
+
+    public void setAgeCounterRollOverWhenAdded(int ageCounterRollOverWhenAdded) {
+        this.ageCounterRollOverWhenAdded = ageCounterRollOverWhenAdded;
+    }
 
     /**
      * Gets the LSA type.
@@ -318,6 +327,8 @@
 
         if (currentAge >= OspfParameters.MAXAGE) {
             return OspfParameters.MAXAGE;
+        } else if ((currentAge == lsaAgeReceived) && ageCounterRollOverWhenAdded != lsdbAge.getAgeCounterRollOver()) {
+            return OspfParameters.MAXAGE;
         }
 
         return currentAge;
diff --git a/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/lsdb/LsdbAgeImpl.java b/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/lsdb/LsdbAgeImpl.java
index 24bb717..348de07 100755
--- a/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/lsdb/LsdbAgeImpl.java
+++ b/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/lsdb/LsdbAgeImpl.java
@@ -41,7 +41,7 @@
 
     private static final Logger log =
             LoggerFactory.getLogger(LsdbAgeImpl.class);
-    protected int ageCounter = 0;
+    protected static int ageCounter = 0;
     private InternalAgeTimer dbAgeTimer;
     private ScheduledExecutorService exServiceage;
     // creating age bins of MAXAGE
diff --git a/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/lsdb/OspfLsdbImpl.java b/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/lsdb/OspfLsdbImpl.java
index 3df627d..f76a4db 100755
--- a/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/lsdb/OspfLsdbImpl.java
+++ b/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/lsdb/OspfLsdbImpl.java
@@ -267,6 +267,7 @@
         lsaWrapper.setLsaHeader(newLsa);
         lsaWrapper.setLsaAgeReceived(newLsa.age());
         lsaWrapper.setAgeCounterWhenReceived(lsdbAge.getAgeCounter());
+        lsaWrapper.setAgeCounterRollOverWhenAdded(lsdbAge.getAgeCounterRollOver());
         lsaWrapper.setIsSelfOriginated(isSelfOriginated);
         lsaWrapper.setIsSelfOriginated(isSelfOriginated);
         lsaWrapper.setOspfInterface(ospfInterface);
diff --git a/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/area/OspfAreaImplTest.java b/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/area/OspfAreaImplTest.java
index 011397c..98baa0f 100755
--- a/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/area/OspfAreaImplTest.java
+++ b/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/area/OspfAreaImplTest.java
@@ -15,29 +15,25 @@
  */
 package org.onosproject.ospf.controller.area;
 
-import org.easymock.EasyMock;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 import org.onlab.packet.Ip4Address;
-import org.onosproject.ospf.controller.OspfArea;
-import org.onosproject.ospf.controller.OspfAreaAddressRange;
 import org.onosproject.ospf.controller.OspfInterface;
-import org.onosproject.ospf.controller.OspfNbr;
 import org.onosproject.ospf.controller.OspfNeighborState;
 import org.onosproject.ospf.controller.TopologyForDeviceAndLink;
-import org.onosproject.ospf.controller.impl.Controller;
-import org.onosproject.ospf.controller.impl.OspfInterfaceChannelHandler;
 import org.onosproject.ospf.controller.impl.OspfNbrImpl;
 import org.onosproject.ospf.controller.impl.TopologyForDeviceAndLinkImpl;
 import org.onosproject.ospf.controller.lsdb.LsaWrapperImpl;
 import org.onosproject.ospf.protocol.lsa.LsaHeader;
+import org.onosproject.ospf.protocol.lsa.OpaqueLsaHeader;
 import org.onosproject.ospf.protocol.lsa.types.NetworkLsa;
+import org.onosproject.ospf.protocol.lsa.types.OpaqueLsa10;
 import org.onosproject.ospf.protocol.lsa.types.RouterLsa;
 import org.onosproject.ospf.protocol.util.OspfInterfaceState;
+import org.onosproject.ospf.protocol.util.OspfParameters;
 
 import java.util.ArrayList;
-import java.util.HashMap;
 import java.util.List;
 
 import static org.hamcrest.MatcherAssert.assertThat;
@@ -50,66 +46,66 @@
 
     private OspfAreaImpl ospfArea;
     private int result;
-    private OspfInterfaceImpl ospfInterface;
-    private HashMap<String, OspfNbr> ospfNbrList;
-    private List<OspfInterface> ospfInterfaces;
+    private List<OspfInterface> ospfInterfaces = new ArrayList<>();
     private OspfInterfaceImpl ospfInterface1;
     private OspfInterfaceImpl ospfInterface2;
     private OspfInterfaceImpl ospfInterface3;
-    private OspfInterfaceImpl ospfInterface4;
-    private OspfInterfaceImpl ospfInterface5;
-    private OspfInterfaceImpl ospfInterface6;
-    private NetworkLsa networkLsa;
     private OspfNbrImpl ospfNbr;
-    private RouterLsa routerLsa;
-    private List<OspfAreaAddressRange> ospfAreaAddressRanges;
+    private OspfNbrImpl ospfNbr1;
+    private NetworkLsa networkLsa;
     private LsaHeader lsaHeader;
+    private Ip4Address ip4Address = Ip4Address.valueOf("10.10.10.10");
+    private Ip4Address ip4Address1 = Ip4Address.valueOf("11.11.11.11");
+    private Ip4Address networkAddress = Ip4Address.valueOf("255.255.255.255");
     private TopologyForDeviceAndLink topologyForDeviceAndLink;
+    private RouterLsa routerLsa;
+    private OpaqueLsaHeader opaqueLsaHeader;
+    private OpaqueLsa10 opaqueLsa10;
 
     @Before
     public void setUp() throws Exception {
+        lsaHeader = new LsaHeader();
+        opaqueLsaHeader = new OpaqueLsaHeader();
+        opaqueLsaHeader.setAdvertisingRouter(ip4Address);
+        lsaHeader.setAdvertisingRouter(ip4Address);
+        routerLsa = new RouterLsa(lsaHeader);
+        routerLsa.setAdvertisingRouter(ip4Address);
+        opaqueLsa10 = new OpaqueLsa10(opaqueLsaHeader);
         ospfArea = new OspfAreaImpl();
+        ospfInterface1 = new OspfInterfaceImpl();
         topologyForDeviceAndLink = new TopologyForDeviceAndLinkImpl();
+        ospfNbr = new OspfNbrImpl(ospfArea, ospfInterface1, ip4Address, ip4Address1,
+                                  2, topologyForDeviceAndLink);
+        ospfNbr.setState(OspfNeighborState.EXCHANGE);
+        ospfNbr1 = new OspfNbrImpl(ospfArea, ospfInterface1, ip4Address, ip4Address1,
+                                   2, topologyForDeviceAndLink);
+        ospfNbr1.setState(OspfNeighborState.FULL);
+        ospfNbr1.setNeighborId(ip4Address);
+        ospfNbr.setNeighborId(ip4Address);
+        ospfNbr.setIsOpaqueCapable(true);
+        ospfInterface1.addNeighbouringRouter(ospfNbr);
+        ospfInterface1.addNeighbouringRouter(ospfNbr1);
+        ospfInterface2 = new OspfInterfaceImpl();
+        ospfInterface2.setIpAddress(ip4Address);
+        ospfInterface2.setIpNetworkMask(networkAddress);
+        ospfInterface2.setState(OspfInterfaceState.LOOPBACK);
+        ospfInterface2.addNeighbouringRouter(ospfNbr);
+        ospfInterface2.addNeighbouringRouter(ospfNbr1);
+        ospfInterfaces.add(ospfInterface2);
     }
 
     @After
     public void tearDown() throws Exception {
         ospfArea = null;
-        ospfInterface = null;
-        ospfNbrList = null;
         ospfInterfaces = null;
-        ospfAreaAddressRanges = null;
         lsaHeader = null;
-        routerLsa = null;
-        ospfNbr = null;
         networkLsa = null;
         ospfInterface1 = null;
         ospfInterface2 = null;
         ospfInterface3 = null;
-        ospfInterface4 = null;
-        ospfInterface5 = null;
-        ospfInterface6 = null;
 
     }
 
-    /**
-     * Tests equals() method.
-     */
-    @Test
-    public void testEquals() throws Exception {
-        ospfArea = new OspfAreaImpl();
-        ospfInterface = new OspfInterfaceImpl();
-        ospfArea.setTransitCapability(true);
-        ospfArea.setExternalRoutingCapability(true);
-        ospfArea.setStubCost(100);
-        ospfArea.initializeDb();
-        ospfArea.setAddressRanges(ospfAreaAddressRanges);
-        assertThat(ospfArea.equals(ospfArea), is(true));
-        ospfArea = EasyMock.createMock(OspfAreaImpl.class);
-        assertThat(ospfArea.equals(ospfArea), is(true));
-        OspfArea ospfArea = new OspfAreaImpl();
-        assertThat(ospfArea.equals(ospfArea), is(true));
-    }
 
     /**
      * Tests hashCode() method.
@@ -165,66 +161,6 @@
         assertThat(ospfArea, is(notNullValue()));
     }
 
-    /**
-     * Tests refreshArea() method.
-     */
-    @Test
-    public void testRefreshArea() throws Exception {
-
-        ospfInterface = new OspfInterfaceImpl();
-        ospfInterface.setState(OspfInterfaceState.DR);
-        ospfNbrList = new HashMap();
-        ospfNbrList.put("1.1.1.1", new OspfNbrImpl(new OspfAreaImpl(), new OspfInterfaceImpl(),
-                                                   Ip4Address.valueOf("1.1.1.1"),
-                                                   Ip4Address.valueOf("2.2.2.2"), 2,
-                                                   new OspfInterfaceChannelHandler(new Controller(),
-                                                                                   new OspfAreaImpl(),
-                                                                                   new OspfInterfaceImpl()),
-                                                   topologyForDeviceAndLink));
-        ospfNbrList.put("2.2.2.2", new OspfNbrImpl(new OspfAreaImpl(), new OspfInterfaceImpl(),
-                                                   Ip4Address.valueOf("1.1.1.1"),
-                                                   Ip4Address.valueOf("2.2.2.2"), 2,
-                                                   new OspfInterfaceChannelHandler(new Controller(),
-                                                                                   new OspfAreaImpl(),
-                                                                                   new OspfInterfaceImpl()),
-                                                   topologyForDeviceAndLink));
-        ospfNbrList.put("3.3.3.3", new OspfNbrImpl(new OspfAreaImpl(), new OspfInterfaceImpl(),
-                                                   Ip4Address.valueOf("1.1.1.1"),
-                                                   Ip4Address.valueOf("2.2.2.2"), 2,
-                                                   new OspfInterfaceChannelHandler(new Controller(),
-                                                                                   new OspfAreaImpl(),
-                                                                                   new OspfInterfaceImpl()),
-                                                   topologyForDeviceAndLink));
-        ospfNbrList.put("4.4.4.4", new OspfNbrImpl(new OspfAreaImpl(), new OspfInterfaceImpl(),
-                                                   Ip4Address.valueOf("1.1.1.1"),
-                                                   Ip4Address.valueOf("2.2.2.2"), 2,
-                                                   new OspfInterfaceChannelHandler(new Controller(),
-                                                                                   new OspfAreaImpl(),
-                                                                                   new OspfInterfaceImpl()),
-                                                   topologyForDeviceAndLink));
-
-        ospfInterface.setListOfNeighbors(ospfNbrList);
-        ospfInterface.setIpAddress(Ip4Address.valueOf("10.10.10.10"));
-        ospfInterface.setIpNetworkMask(Ip4Address.valueOf("255.255.255.255"));
-        ospfInterfaces = new ArrayList();
-        ospfInterface1 = new OspfInterfaceImpl();
-        ospfInterface1.setIpAddress(Ip4Address.valueOf("1.1.1.1"));
-        ospfInterfaces.add(ospfInterface1);
-        ospfInterface2 = new OspfInterfaceImpl();
-        ospfInterface2.setIpAddress(Ip4Address.valueOf("2.2.2.2"));
-        ospfInterfaces.add(ospfInterface2);
-        ospfInterface3 = new OspfInterfaceImpl();
-        ospfInterface3.setIpAddress(Ip4Address.valueOf("3.3.3.3"));
-        ospfInterfaces.add(ospfInterface3);
-        ospfArea.setInterfacesLst(ospfInterfaces);
-        ospfArea.setRouterId(Ip4Address.valueOf("111.111.111.111"));
-        networkLsa = ospfArea.buildNetworkLsa(Ip4Address.valueOf("1.1.1.1"),
-                                              Ip4Address.valueOf("255.255.255.255"));
-        ospfArea.refreshArea(ospfInterface);
-        assertThat(ospfNbrList.size(), is(4));
-        assertThat(networkLsa, is(notNullValue()));
-        assertThat(ospfArea, is(notNullValue()));
-    }
 
     /**
      * Tests buildNetworkLsa() method.
@@ -241,7 +177,7 @@
         ospfInterface3 = new OspfInterfaceImpl();
         ospfInterface3.setIpAddress(Ip4Address.valueOf("3.3.3.3"));
         ospfInterfaces.add(ospfInterface3);
-        ospfArea.setInterfacesLst(ospfInterfaces);
+        ospfArea.setOspfInterfaceList(ospfInterfaces);
         ospfArea.setRouterId(Ip4Address.valueOf("111.111.111.111"));
         networkLsa = ospfArea.buildNetworkLsa(Ip4Address.valueOf("1.1.1.1"),
                                               Ip4Address.valueOf("255.255.255.255"));
@@ -250,118 +186,6 @@
         assertThat(ospfArea, is(notNullValue()));
     }
 
-    /**
-     * Tests buildNetworkLsa() method.
-     */
-    @Test
-    public void testBuildNetworkLsa1() throws Exception {
-        ospfInterfaces = new ArrayList();
-        ospfInterface1 = new OspfInterfaceImpl();
-        ospfInterface1.setIpAddress(Ip4Address.valueOf("1.1.1.1"));
-        ospfInterface1.setIpNetworkMask(Ip4Address.valueOf("255.255.255.255"));
-        ospfInterface1.setState(OspfInterfaceState.POINT2POINT);
-        ospfNbr = new OspfNbrImpl(new OspfAreaImpl(), new OspfInterfaceImpl(),
-                                  Ip4Address.valueOf("1.1.1.1"),
-                                  Ip4Address.valueOf("2.2.2.2"), 2,
-                                  new OspfInterfaceChannelHandler(new Controller(),
-                                                                  new OspfAreaImpl(),
-                                                                  new OspfInterfaceImpl()),
-                                  topologyForDeviceAndLink);
-        ospfNbr.setState(OspfNeighborState.FULL);
-        ospfInterface1.addNeighbouringRouter(ospfNbr);
-        ospfInterfaces.add(ospfInterface1);
-        ospfArea.setInterfacesLst(ospfInterfaces);
-        ospfArea.setRouterId(Ip4Address.valueOf("111.111.111.111"));
-        networkLsa = ospfArea.buildNetworkLsa(Ip4Address.valueOf("1.1.1.1"),
-                                              Ip4Address.valueOf("255.255.255.255"));
-        assertThat(ospfInterfaces.size(), is(1));
-        assertThat(networkLsa, is(notNullValue()));
-        assertThat(ospfArea, is(notNullValue()));
-    }
-
-    /**
-     * Tests buildRouterLsa() method.
-     */
-    @Test
-    public void testBuildRouterLsa() throws Exception {
-        ospfNbrList = new HashMap();
-        ospfNbr = new OspfNbrImpl(new OspfAreaImpl(), new OspfInterfaceImpl(),
-                                  Ip4Address.valueOf("1.1.1.1"),
-                                  Ip4Address.valueOf("2.2.2.2"), 2,
-                                  new OspfInterfaceChannelHandler(new Controller(),
-                                                                  new OspfAreaImpl(),
-                                                                  new OspfInterfaceImpl()),
-                                  topologyForDeviceAndLink);
-        ospfNbr.setState(OspfNeighborState.FULL);
-        ospfInterfaces = new ArrayList();
-        ospfInterface1 = new OspfInterfaceImpl();
-        ospfInterface1.setIpAddress(Ip4Address.valueOf("1.1.1.1"));
-        ospfInterface1.setState(OspfInterfaceState.DOWN);
-        ospfInterface1.addNeighbouringRouter(ospfNbr);
-        ospfInterfaces.add(ospfInterface1);
-        ospfInterface2 = new OspfInterfaceImpl();
-        ospfInterface2.setState(OspfInterfaceState.LOOPBACK);
-        ospfInterface2.setIpAddress(Ip4Address.valueOf("2.2.2.2"));
-        ospfInterface2.addNeighbouringRouter(ospfNbr);
-        ospfInterfaces.add(ospfInterface2);
-        ospfInterface3 = new OspfInterfaceImpl();
-        ospfInterface3.setIpAddress(Ip4Address.valueOf("3.3.3.3"));
-        ospfInterface3.setState(OspfInterfaceState.POINT2POINT);
-        ospfInterface3.setIpNetworkMask(Ip4Address.valueOf("255.255.255.255"));
-        ospfInterface3.addNeighbouringRouter(ospfNbr);
-        ospfInterface3.setListOfNeighbors(ospfNbrList);
-        ospfInterfaces.add(ospfInterface3);
-        ospfInterface4 = new OspfInterfaceImpl();
-        ospfInterface4.setState(OspfInterfaceState.WAITING);
-        ospfInterface4.setIpAddress(Ip4Address.valueOf("3.3.3.3"));
-        ospfInterface4.setIpNetworkMask(Ip4Address.valueOf("255.255.255.255"));
-        ospfInterfaces.add(ospfInterface4);
-        ospfInterface5 = new OspfInterfaceImpl();
-        ospfInterface5.setState(OspfInterfaceState.DR);
-        ospfInterface5.setIpAddress(Ip4Address.valueOf("3.3.3.3"));
-        ospfInterfaces.add(ospfInterface5);
-        ospfInterface6 = new OspfInterfaceImpl();
-        ospfInterface6.setState(OspfInterfaceState.BDR);
-        ospfInterface6.setIpAddress(Ip4Address.valueOf("3.3.3.3"));
-        ospfInterface6.setDr(Ip4Address.valueOf("3.3.3.3"));
-        ospfInterfaces.add(ospfInterface6);
-        ospfArea.setInterfacesLst(ospfInterfaces);
-        ospfArea.setRouterId(Ip4Address.valueOf("111.111.111.111"));
-        assertThat(ospfInterfaces.size(), is(6));
-        routerLsa = ospfArea.buildRouterLsa(ospfInterface1);
-        assertThat(routerLsa, is(notNullValue()));
-        routerLsa = ospfArea.buildRouterLsa(ospfInterface2);
-        assertThat(routerLsa, is(notNullValue()));
-        routerLsa = ospfArea.buildRouterLsa(ospfInterface3);
-        assertThat(routerLsa, is(notNullValue()));
-        assertThat(ospfArea, is(notNullValue()));
-    }
-
-    /**
-     * Tests buildRouterLsa() method.
-     */
-    @Test
-    public void testBuildRouterLsa1() throws Exception {
-        ospfInterfaces = new ArrayList();
-        ospfInterface1 = new OspfInterfaceImpl();
-        ospfInterface1.setIpAddress(Ip4Address.valueOf("1.1.1.1"));
-        ospfInterface1.setIpNetworkMask(Ip4Address.valueOf("255.255.255.255"));
-        ospfInterface1.setState(OspfInterfaceState.POINT2POINT);
-        ospfNbr = new OspfNbrImpl(new OspfAreaImpl(), new OspfInterfaceImpl(),
-                                  Ip4Address.valueOf("1.1.1.1"),
-                                  Ip4Address.valueOf("2.2.2.2"), 2,
-                                  new OspfInterfaceChannelHandler(new Controller(),
-                                                                  new OspfAreaImpl(),
-                                                                  new OspfInterfaceImpl()),
-                                  topologyForDeviceAndLink);
-        ospfNbr.setState(OspfNeighborState.FULL);
-        ospfInterface1.addNeighbouringRouter(ospfNbr);
-        ospfInterfaces.add(ospfInterface1);
-        ospfArea.setInterfacesLst(ospfInterfaces);
-        ospfArea.setRouterId(Ip4Address.valueOf("111.111.111.111"));
-        routerLsa = ospfArea.buildRouterLsa(ospfInterface1);
-        assertThat(routerLsa, is(notNullValue()));
-    }
 
     /**
      * Tests areaId() getter method.
@@ -381,51 +205,6 @@
         assertThat(ospfArea.areaId(), is(Ip4Address.valueOf("1.1.1.1")));
     }
 
-    /**
-     * Tests addressRanges() getter method.
-     */
-    @Test
-    public void testGetAddressRanges() throws Exception {
-        ospfAreaAddressRanges = new ArrayList();
-        ospfAreaAddressRanges.add(new OspfAreaAddressRangeImpl());
-        ospfAreaAddressRanges.add(new OspfAreaAddressRangeImpl());
-        ospfAreaAddressRanges.add(new OspfAreaAddressRangeImpl());
-        ospfAreaAddressRanges.add(new OspfAreaAddressRangeImpl());
-        ospfArea.setAddressRanges(ospfAreaAddressRanges);
-        assertThat(ospfArea.addressRanges().size(), is(4));
-    }
-
-    /**
-     * Tests addressRanges() setter method.
-     */
-    @Test
-    public void testSetAddressRanges() throws Exception {
-        ospfAreaAddressRanges = new ArrayList();
-        ospfAreaAddressRanges.add(new OspfAreaAddressRangeImpl());
-        ospfAreaAddressRanges.add(new OspfAreaAddressRangeImpl());
-        ospfAreaAddressRanges.add(new OspfAreaAddressRangeImpl());
-        ospfAreaAddressRanges.add(new OspfAreaAddressRangeImpl());
-        ospfArea.setAddressRanges(ospfAreaAddressRanges);
-        assertThat(ospfArea.addressRanges().size(), is(4));
-    }
-
-    /**
-     * Tests isTransitCapability() getter method.
-     */
-    @Test
-    public void testIsTransitCapability() throws Exception {
-        ospfArea.setTransitCapability(true);
-        assertThat(ospfArea.isTransitCapability(), is(true));
-    }
-
-    /**
-     * Tests isTransitCapability() setter method.
-     */
-    @Test
-    public void testSetTransitCapability() throws Exception {
-        ospfArea.setTransitCapability(true);
-        assertThat(ospfArea.isTransitCapability(), is(true));
-    }
 
     /**
      * Tests isExternalRoutingCapability() getter method.
@@ -445,26 +224,9 @@
         assertThat(ospfArea.isExternalRoutingCapability(), is(true));
     }
 
-    /**
-     * Tests stubCost() getter method.
-     */
-    @Test
-    public void testGetStubCost() throws Exception {
-        ospfArea.setStubCost(100);
-        assertThat(ospfArea.stubCost(), is(100));
-    }
 
     /**
-     * Tests stubCost() setter method.
-     */
-    @Test
-    public void testSetStubCost() throws Exception {
-        ospfArea.setStubCost(100);
-        assertThat(ospfArea.stubCost(), is(100));
-    }
-
-    /**
-     * Tests getInterfacesLst() getter method.
+     * Tests ospfInterfaceList() getter method.
      */
     @Test
     public void testGetInterfacesLst() throws Exception {
@@ -478,9 +240,9 @@
         ospfInterface3 = new OspfInterfaceImpl();
         ospfInterface3.setIpAddress(Ip4Address.valueOf("3.3.3.3"));
         ospfInterfaces.add(ospfInterface3);
-        ospfArea.setInterfacesLst(ospfInterfaces);
+        ospfArea.setOspfInterfaceList(ospfInterfaces);
         assertThat(ospfInterfaces.size(), is(3));
-        assertThat(ospfArea.getInterfacesLst(), is(notNullValue()));
+        assertThat(ospfArea.ospfInterfaceList(), is(notNullValue()));
     }
 
     /**
@@ -498,32 +260,11 @@
         ospfInterface3 = new OspfInterfaceImpl();
         ospfInterface3.setIpAddress(Ip4Address.valueOf("3.3.3.3"));
         ospfInterfaces.add(ospfInterface3);
-        ospfArea.setInterfacesLst(ospfInterfaces);
+        ospfArea.setOspfInterfaceList(ospfInterfaces);
         assertThat(ospfInterfaces.size(), is(3));
-        assertThat(ospfArea.getInterfacesLst(), is(notNullValue()));
+        assertThat(ospfArea.ospfInterfaceList(), is(notNullValue()));
     }
 
-    /**
-     * Tests noNeighborInLsaExchangeProcess() method.
-     */
-    @Test
-    public void testNoNeighborInLsaExchangeProcess() throws Exception {
-        ospfInterfaces = new ArrayList();
-        ospfInterface1 = new OspfInterfaceImpl();
-        ospfInterface1.setIpAddress(Ip4Address.valueOf("1.1.1.1"));
-        ospfNbr = new OspfNbrImpl(new OspfAreaImpl(), new OspfInterfaceImpl(),
-                                  Ip4Address.valueOf("1.1.1.1"),
-                                  Ip4Address.valueOf("2.2.2.2"), 2,
-                                  new OspfInterfaceChannelHandler(new Controller(),
-                                                                  new OspfAreaImpl(),
-                                                                  new OspfInterfaceImpl()),
-                                  topologyForDeviceAndLink);
-        ospfNbr.setState(OspfNeighborState.EXCHANGE.EXCHANGE);
-        ospfInterface1.addNeighbouringRouter(ospfNbr);
-        ospfInterfaces.add(ospfInterface1);
-        ospfArea.setInterfacesLst(ospfInterfaces);
-        assertThat(ospfArea.noNeighborInLsaExchangeProcess(), is(false));
-    }
 
     /**
      * Tests getLsaHeaders() method.
@@ -620,27 +361,6 @@
         assertThat(ospfArea.toString(), is(notNullValue()));
     }
 
-    /**
-     * Tests getNeighborsInFullState() method.
-     */
-    @Test
-    public void testGetNeighborsinFullState() throws Exception {
-        ospfInterfaces = new ArrayList();
-        ospfInterface1 = new OspfInterfaceImpl();
-        ospfInterface1.setIpAddress(Ip4Address.valueOf("1.1.1.1"));
-        ospfNbr = new OspfNbrImpl(new OspfAreaImpl(), new OspfInterfaceImpl(),
-                                  Ip4Address.valueOf("1.1.1.1"),
-                                  Ip4Address.valueOf("2.2.2.2"), 2,
-                                  new OspfInterfaceChannelHandler(new Controller(),
-                                                                  new OspfAreaImpl(),
-                                                                  new OspfInterfaceImpl()),
-                                  topologyForDeviceAndLink);
-        ospfNbr.setState(OspfNeighborState.FULL);
-        ospfInterface1.addNeighbouringRouter(ospfNbr);
-        ospfInterfaces.add(ospfInterface1);
-        ospfArea.setInterfacesLst(ospfInterfaces);
-        assertThat(ospfArea.getNeighborsInFullState(ospfInterface1).size(), is(1));
-    }
 
     /**
      * Tests getLsaKey() method.
@@ -652,30 +372,6 @@
         assertThat(ospfArea.getLsaKey(lsaHeader), is(notNullValue()));
     }
 
-    /**
-     * Tests addToOtherNeighborLsaTxList() method.
-     */
-    @Test
-    public void testAddToOtherNeighborLsaTxList() throws Exception {
-        ospfInterfaces = new ArrayList();
-        ospfInterface1 = new OspfInterfaceImpl();
-        ospfInterface1.setIpAddress(Ip4Address.valueOf("1.1.1.1"));
-        ospfNbr = new OspfNbrImpl(new OspfAreaImpl(), new OspfInterfaceImpl(),
-                                  Ip4Address.valueOf("1.1.1.1"),
-                                  Ip4Address.valueOf("2.2.2.2"), 2,
-                                  new OspfInterfaceChannelHandler(new Controller(),
-                                                                  new OspfAreaImpl(),
-                                                                  new OspfInterfaceImpl()),
-                                  topologyForDeviceAndLink);
-        ospfNbr.setState(OspfNeighborState.FULL);
-        ospfInterface1.addNeighbouringRouter(ospfNbr);
-        ospfInterfaces.add(ospfInterface1);
-        ospfArea.setInterfacesLst(ospfInterfaces);
-        lsaHeader = new LsaHeader();
-        lsaHeader.setAdvertisingRouter(Ip4Address.valueOf("1.1.1.1"));
-        ospfArea.addToOtherNeighborLsaTxList(lsaHeader);
-        assertThat(ospfArea, is(notNullValue()));
-    }
 
     /**
      * Tests options() getter method.
@@ -719,4 +415,54 @@
     public void testOpaqueEnabledOptionsa() throws Exception {
         assertThat(ospfArea.opaqueEnabledOptions(), is(66));
     }
+
+    /**
+     * Tests noNeighborInLsaExchangeProcess()  method.
+     */
+    @Test
+    public void testNoNeighborInLsaExchangeProcess() throws Exception {
+        ospfArea.setOspfInterfaceList(ospfInterfaces);
+        ospfArea.noNeighborInLsaExchangeProcess();
+        assertThat(ospfArea, is(notNullValue()));
+    }
+
+    /**
+     * Tests getNeighborsInFullState()  method.
+     */
+    @Test
+    public void testGetNeighborsInFullState() throws Exception {
+        ospfArea.getNeighborsInFullState(ospfInterface1);
+        assertThat(ospfArea, is(notNullValue()));
+    }
+
+    /**
+     * Tests addToOtherNeighborLsaTxList()  method.
+     */
+    @Test
+    public void testAddToOtherNeighborLsaTxList() throws Exception {
+        ospfArea.setOspfInterfaceList(ospfInterfaces);
+        ospfArea.addToOtherNeighborLsaTxList(routerLsa);
+        assertThat(ospfArea, is(notNullValue()));
+
+        opaqueLsa10.setLsType(OspfParameters.LINK_LOCAL_OPAQUE_LSA);
+        ospfArea.addToOtherNeighborLsaTxList(opaqueLsa10);
+        assertThat(ospfArea, is(notNullValue()));
+    }
+
+    /**
+     * Tests buildRouterLsa()  method.
+     */
+    @Test
+    public void testBuildRouterLsa() throws Exception {
+        ospfArea.setRouterId(ip4Address);
+        ospfArea.setOspfInterfaceList(ospfInterfaces);
+        ospfInterface1.setState(OspfInterfaceState.POINT2POINT);
+        ospfInterface1.setIpAddress(ip4Address);
+        ospfInterface1.setIpNetworkMask(networkAddress);
+        ospfInterfaces.add(ospfInterface1);
+        ospfArea.buildRouterLsa(ospfInterface1);
+        ospfArea.setOspfInterfaceList(ospfInterfaces);
+        assertThat(ospfArea, is(notNullValue()));
+
+    }
 }
\ No newline at end of file
diff --git a/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/area/OspfInterfaceImplTest.java b/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/area/OspfInterfaceImplTest.java
index 640aee0..438357b 100755
--- a/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/area/OspfInterfaceImplTest.java
+++ b/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/area/OspfInterfaceImplTest.java
@@ -15,21 +15,55 @@
  */
 package org.onosproject.ospf.controller.area;
 
+import org.easymock.EasyMock;
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.jboss.netty.buffer.ChannelBuffers;
+import org.jboss.netty.buffer.HeapChannelBufferFactory;
+import org.jboss.netty.channel.Channel;
+import org.jboss.netty.channel.ChannelConfig;
+import org.jboss.netty.channel.ChannelHandlerContext;
+import org.jboss.netty.channel.ChannelStateEvent;
 import org.junit.After;
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
 import org.onlab.packet.Ip4Address;
+import org.onosproject.ospf.controller.OspfAreaAddressRange;
+import org.onosproject.ospf.controller.OspfInterface;
+import org.onosproject.ospf.controller.OspfLsaType;
+import org.onosproject.ospf.controller.OspfMessage;
 import org.onosproject.ospf.controller.OspfNbr;
+import org.onosproject.ospf.controller.OspfNeighborState;
+import org.onosproject.ospf.controller.OspfProcess;
 import org.onosproject.ospf.controller.TopologyForDeviceAndLink;
 import org.onosproject.ospf.controller.impl.Controller;
 import org.onosproject.ospf.controller.impl.OspfInterfaceChannelHandler;
+import org.onosproject.ospf.controller.impl.OspfLinkTedImpl;
 import org.onosproject.ospf.controller.impl.OspfNbrImpl;
+import org.onosproject.ospf.controller.impl.OspfRouterImpl;
 import org.onosproject.ospf.controller.impl.TopologyForDeviceAndLinkImpl;
+import org.onosproject.ospf.controller.util.OspfEligibleRouter;
+import org.onosproject.ospf.controller.util.OspfInterfaceType;
+import org.onosproject.ospf.exceptions.OspfParseException;
+import org.onosproject.ospf.protocol.lsa.LsaHeader;
 import org.onosproject.ospf.protocol.lsa.OpaqueLsaHeader;
+import org.onosproject.ospf.protocol.lsa.TlvHeader;
+import org.onosproject.ospf.protocol.lsa.tlvtypes.RouterTlv;
+import org.onosproject.ospf.protocol.lsa.types.OpaqueLsa10;
+import org.onosproject.ospf.protocol.lsa.types.RouterLsa;
+import org.onosproject.ospf.protocol.ospfpacket.subtype.LsRequestPacket;
+import org.onosproject.ospf.protocol.ospfpacket.types.DdPacket;
+import org.onosproject.ospf.protocol.ospfpacket.types.HelloPacket;
+import org.onosproject.ospf.protocol.ospfpacket.types.LsAcknowledge;
+import org.onosproject.ospf.protocol.ospfpacket.types.LsRequest;
+import org.onosproject.ospf.protocol.ospfpacket.types.LsUpdate;
+import org.onosproject.ospf.protocol.util.ChecksumCalculator;
 import org.onosproject.ospf.protocol.util.OspfInterfaceState;
 
+import java.net.UnknownHostException;
+import java.util.ArrayList;
 import java.util.HashMap;
+import java.util.List;
 
 import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.Matchers.is;
@@ -39,18 +73,54 @@
  * Unit test class for OspfInterfaceImpl.
  */
 public class OspfInterfaceImplTest {
-
+    private List<OspfAreaAddressRange> addressRanges = new ArrayList();
+    private List<OspfInterface> ospfInterfaces = new ArrayList();
     private OspfInterfaceImpl ospfInterface;
     private OspfNbrImpl ospfNbr;
     private OpaqueLsaHeader opaqueLsaHeader;
     private int result;
+    private OspfAreaImpl ospfArea;
     private HashMap<String, OspfNbr> ospfNbrHashMap;
     private TopologyForDeviceAndLink topologyForDeviceAndLink;
+    private Channel channel;
+    private ChannelHandlerContext channelHandlerContext;
+    private ChannelStateEvent channelStateEvent;
+    private HelloPacket helloPacket;
+    private DdPacket ddPacket;
+    private ChecksumCalculator checksumCalculator;
+    private byte[] byteArray;
+    private byte[] checkArray;
+    private OspfInterfaceChannelHandler ospfInterfaceChannelHandler;
+    private LsRequest lsRequest;
+    private ChannelBuffer buf;
+    private LsUpdate lsUpdate;
+    private LsAcknowledge lsAck;
+    private Controller controller;
+    private List<OspfProcess> ospfProcesses = new ArrayList();
+    private OspfProcess ospfProcess;
+    private OspfEligibleRouter ospfEligibleRouter;
 
     @Before
     public void setUp() throws Exception {
+        ospfProcess = new OspfProcessImpl();
+        ospfProcesses.add(ospfProcess);
         ospfInterface = new OspfInterfaceImpl();
         topologyForDeviceAndLink = new TopologyForDeviceAndLinkImpl();
+        channel = EasyMock.createMock(Channel.class);
+        ospfArea = createOspfArea();
+        ospfInterface = createOspfInterface();
+        ospfNbrHashMap = new HashMap();
+        topologyForDeviceAndLink = new TopologyForDeviceAndLinkImpl();
+        ospfNbr = new OspfNbrImpl(ospfArea, ospfInterface, Ip4Address.valueOf("10.10.10.10"),
+                                  Ip4Address.valueOf("2.2.2.2"), 2,
+                                  topologyForDeviceAndLink);
+        ospfNbr.setNeighborId(Ip4Address.valueOf("10.10.10.10"));
+        ospfNbr.setRouterPriority(0);
+        ospfNbr.setNeighborDr(Ip4Address.valueOf("13.13.13.13"));
+        ospfInterface.addNeighbouringRouter(ospfNbr);
+        controller = new Controller();
+        ospfInterfaceChannelHandler = new OspfInterfaceChannelHandler(controller, ospfProcesses);
+
     }
 
     @After
@@ -113,9 +183,7 @@
     public void testAddNeighbouringRouter() throws Exception {
         ospfNbr = new OspfNbrImpl(new OspfAreaImpl(), new OspfInterfaceImpl(),
                                   Ip4Address.valueOf("1.1.1.1"), Ip4Address.valueOf("2.2.2.2"), 2,
-                                  new OspfInterfaceChannelHandler(new Controller(), new OspfAreaImpl(),
-                                                                  new OspfInterfaceImpl()),
-                                                                    topologyForDeviceAndLink);
+                                  topologyForDeviceAndLink);
         ospfNbr.setNeighborId(Ip4Address.valueOf("111.111.111.111"));
         ospfInterface.addNeighbouringRouter(ospfNbr);
         assertThat(ospfInterface, is(notNullValue()));
@@ -129,9 +197,7 @@
     public void testGetNeighbouringRouter() throws Exception {
         ospfNbr = new OspfNbrImpl(new OspfAreaImpl(), new OspfInterfaceImpl(),
                                   Ip4Address.valueOf("1.1.1.1"), Ip4Address.valueOf("2.2.2.2"), 2,
-                                  new OspfInterfaceChannelHandler(new Controller(), new OspfAreaImpl(),
-                                                                  new OspfInterfaceImpl()),
-                                                                    topologyForDeviceAndLink);
+                                  topologyForDeviceAndLink);
         ospfNbr.setNeighborId(Ip4Address.valueOf("111.111.111.111"));
         ospfInterface.addNeighbouringRouter(ospfNbr);
         assertThat(ospfInterface.neighbouringRouter("111.111.111.111"), is(notNullValue()));
@@ -164,9 +230,7 @@
     public void testIsNeighborinList() throws Exception {
         ospfNbr = new OspfNbrImpl(new OspfAreaImpl(), new OspfInterfaceImpl(),
                                   Ip4Address.valueOf("1.1.1.1"), Ip4Address.valueOf("2.2.2.2"), 2,
-                                  new OspfInterfaceChannelHandler(new Controller(), new OspfAreaImpl(),
-                                                                  new OspfInterfaceImpl()),
-                                                                    topologyForDeviceAndLink);
+                                  topologyForDeviceAndLink);
         ospfNbr.setNeighborId(Ip4Address.valueOf("111.111.111.111"));
         ospfInterface.addNeighbouringRouter(ospfNbr);
         assertThat(ospfInterface.isNeighborInList("111.111.111.111"), is(notNullValue()));
@@ -180,10 +244,7 @@
         ospfNbrHashMap = new HashMap();
         ospfNbr = new OspfNbrImpl(new OspfAreaImpl(), new OspfInterfaceImpl(),
                                   Ip4Address.valueOf("1.1.1.1"), Ip4Address.valueOf("2.2.2.2"), 2,
-                                  new OspfInterfaceChannelHandler(new Controller(),
-                                                                  new OspfAreaImpl(),
-                                                                  new OspfInterfaceImpl()),
-                                                                    topologyForDeviceAndLink);
+                                  topologyForDeviceAndLink);
         ospfNbr.setNeighborId(Ip4Address.valueOf("111.111.111.111"));
         ospfNbrHashMap.put("111.111.111.111", ospfNbr);
         ospfInterface.setListOfNeighbors(ospfNbrHashMap);
@@ -198,9 +259,7 @@
         ospfNbrHashMap = new HashMap();
         ospfNbr = new OspfNbrImpl(new OspfAreaImpl(), new OspfInterfaceImpl(),
                                   Ip4Address.valueOf("1.1.1.1"), Ip4Address.valueOf("2.2.2.2"), 2,
-                                  new OspfInterfaceChannelHandler(new Controller(), new OspfAreaImpl(),
-                                                                  new OspfInterfaceImpl()),
-                                                                    topologyForDeviceAndLink);
+                                  topologyForDeviceAndLink);
         ospfNbr.setNeighborId(Ip4Address.valueOf("111.111.111.111"));
         ospfNbrHashMap.put("111.111.111.111", ospfNbr);
         ospfInterface.setListOfNeighbors(ospfNbrHashMap);
@@ -244,24 +303,6 @@
     }
 
     /**
-     * Tests areaId() getter method.
-     */
-    @Test
-    public void testGetAreaId() throws Exception {
-        ospfInterface.setAreaId(1);
-        assertThat(ospfInterface.areaId(), is(1));
-    }
-
-    /**
-     * Tests areaId() setter method.
-     */
-    @Test
-    public void testSetAreaId() throws Exception {
-        ospfInterface.setAreaId(1);
-        assertThat(ospfInterface.areaId(), is(1));
-    }
-
-    /**
      * Tests helloIntervalTime() getter method.
      */
     @Test
@@ -316,78 +357,6 @@
     }
 
     /**
-     * Tests interfaceCost() getter method.
-     */
-    @Test
-    public void testGetInterfaceCost() throws Exception {
-        ospfInterface.setInterfaceCost(100);
-        assertThat(ospfInterface.interfaceCost(), is(100));
-    }
-
-    /**
-     * Tests interfaceCost() setter method.
-     */
-    @Test
-    public void testSetInterfaceCost() throws Exception {
-        ospfInterface.setInterfaceCost(100);
-        assertThat(ospfInterface.interfaceCost(), is(100));
-    }
-
-    /**
-     * Tests authType() getter method.
-     */
-    @Test
-    public void testGetAuthType() throws Exception {
-        ospfInterface.setAuthType("00");
-        assertThat(ospfInterface.authType(), is("00"));
-    }
-
-    /**
-     * Tests authType() setter method.
-     */
-    @Test
-    public void testSetAuthType() throws Exception {
-        ospfInterface.setAuthType("00");
-        assertThat(ospfInterface.authType(), is("00"));
-    }
-
-    /**
-     * Tests authKey() getter method.
-     */
-    @Test
-    public void testGetAuthKey() throws Exception {
-        ospfInterface.setAuthKey("00");
-        assertThat(ospfInterface.authKey(), is("00"));
-    }
-
-    /**
-     * Tests authKey() setter method.
-     */
-    @Test
-    public void testSetAuthKey() throws Exception {
-        ospfInterface.setAuthKey("00");
-        assertThat(ospfInterface.authKey(), is("00"));
-    }
-
-    /**
-     * Tests pollInterval() getter method.
-     */
-    @Test
-    public void testGetPollInterval() throws Exception {
-        ospfInterface.setPollInterval(100);
-        assertThat(ospfInterface.pollInterval(), is(100));
-    }
-
-    /**
-     * Tests pollInterval() setter method.
-     */
-    @Test
-    public void testSetPollInterval() throws Exception {
-        ospfInterface.setPollInterval(100);
-        assertThat(ospfInterface.pollInterval(), is(100));
-    }
-
-    /**
      * Tests mtu() getter method.
      */
     @Test
@@ -460,29 +429,11 @@
     }
 
     /**
-     * Tests transmitDelay() getter method.
-     */
-    @Test
-    public void testGetTransmitDelay() throws Exception {
-        ospfInterface.setTransmitDelay(100);
-        assertThat(ospfInterface.transmitDelay(), is(100));
-    }
-
-    /**
-     * Tests transmitDelay() setter method.
-     */
-    @Test
-    public void testSetTransmitDelay() throws Exception {
-        ospfInterface.setTransmitDelay(100);
-        assertThat(ospfInterface.transmitDelay(), is(100));
-    }
-
-    /**
      * Tests equals() method.
      */
     @Test
     public void testEquals() throws Exception {
-        assertThat(ospfInterface.equals(new OspfInterfaceImpl()), is(true));
+        assertThat(ospfInterface.equals(new OspfInterfaceImpl()), is(false));
     }
 
     /**
@@ -501,4 +452,1021 @@
     public void testToString() throws Exception {
         assertThat(ospfInterface.toString(), is(notNullValue()));
     }
+
+    /**
+     * Tests to interfaceUp() method.
+     */
+    @Test(expected = Exception.class)
+    public void testInterfaceUp() throws Exception {
+        ospfInterface.setInterfaceType(OspfInterfaceType.POINT_TO_POINT.value());
+        ospfInterface.interfaceUp();
+        assertThat(ospfInterface, is(notNullValue()));
+    }
+
+    /**
+     * Tests to interfaceUp() method.
+     */
+    @Test(expected = Exception.class)
+    public void testInterfaceUp1() throws Exception {
+
+        ospfInterface.setInterfaceType(OspfInterfaceType.BROADCAST.value());
+        ospfInterface.interfaceUp();
+        assertThat(ospfInterface, is(notNullValue()));
+    }
+
+    /**
+     * Tests to interfaceUp() method.
+     */
+    @Test(expected = Exception.class)
+    public void testInterfaceUp2() throws Exception {
+
+        ospfInterface.setRouterPriority(1);
+        ospfInterface.setInterfaceType(OspfInterfaceType.BROADCAST.value());
+        ospfInterface.interfaceUp();
+        assertThat(ospfInterface, is(notNullValue()));
+    }
+
+    /**
+     * Tests to backupSeen() method.
+     */
+    @Test
+    public void testBackupSeen() throws Exception {
+        ospfInterface.setOspfArea(ospfArea);
+        ospfInterface.setState(OspfInterfaceState.WAITING);
+        ospfInterface.backupSeen(channel);
+        assertThat(ospfInterface, is(notNullValue()));
+    }
+
+    /**
+     * Tests to waitTimer() method.
+     */
+    @Test
+    public void testWaitTimer() throws Exception {
+        ospfInterface.setOspfArea(ospfArea);
+        ospfInterface.setState(OspfInterfaceState.WAITING);
+        ospfInterface.waitTimer(channel);
+        assertThat(ospfInterface, is(notNullValue()));
+    }
+
+    /**
+     * Tests to callDrElection() method.
+     */
+    @Test
+    public void testCallDrElection() throws Exception {
+        ospfInterface.setOspfArea(ospfArea);
+        ospfInterface.setState(OspfInterfaceState.WAITING);
+        ospfInterface.callDrElection(channel);
+        assertThat(ospfInterface, is(notNullValue()));
+    }
+
+    /**
+     * Tests to neighborChange() method.
+     */
+    @Test
+    public void testNeighborChange() throws Exception {
+        ospfInterface.setOspfArea(ospfArea);
+        ospfInterface.setState(OspfInterfaceState.DR);
+        ospfInterface.neighborChange();
+        assertThat(ospfInterface, is(notNullValue()));
+    }
+
+    /**
+     * Tests to interfaceDown() method.
+     */
+    @Test(expected = Exception.class)
+    public void testInterfaceDown() throws Exception {
+        ospfInterface.interfaceDown();
+        assertThat(ospfInterface, is(notNullValue()));
+    }
+
+    /**
+     * Tests processOspfMessage() method.
+     */
+    @Test
+    public void testProcessOspfMessage() throws Exception {
+        ospfInterface.setOspfArea(ospfArea);
+        ospfInterface.setInterfaceType(OspfInterfaceType.POINT_TO_POINT.value());
+        ospfInterface.setIpNetworkMask(Ip4Address.valueOf("0.0.0.0"));
+        ospfInterface.setIpAddress(Ip4Address.valueOf("11.11.11.11"));
+        ospfInterface.setInterfaceType(2);
+        ospfArea.setAreaId(Ip4Address.valueOf("12.12.12.12"));
+        channelHandlerContext = EasyMock.createMock(ChannelHandlerContext.class);
+        OspfMessage message;
+        helloPacket = new HelloPacket();
+        helloPacket.setSourceIp(Ip4Address.valueOf("1.1.0.1"));
+        helloPacket.setRouterId(Ip4Address.valueOf("10.10.10.10"));
+        helloPacket.setOspfVer(2);
+        helloPacket.setAreaId(Ip4Address.valueOf("12.12.12.12"));
+        helloPacket.setOptions(2);
+        helloPacket.setNetworkMask(Ip4Address.valueOf("3.3.3.3"));
+        helloPacket.setOspftype(1);
+        helloPacket.setAuthType(0);
+        helloPacket.setHelloInterval(60);
+        helloPacket.setRouterDeadInterval(60);
+        helloPacket.setAuthentication(0);
+        helloPacket.setNetworkMask(Ip4Address.valueOf("1.1.1.1"));
+        checksumCalculator = new ChecksumCalculator();
+        byteArray = helloPacket.asBytes();
+        helloPacket.setOspfPacLength(byteArray.length);
+        checkArray = checksumCalculator.calculateOspfCheckSum(byteArray, 12, 13);
+        checkArray[0] = -51;
+        checkArray[1] = 52;
+        buf = ChannelBuffers.copiedBuffer(checkArray);
+        helloPacket.setChecksum(buf.readUnsignedShort());
+        message = helloPacket;
+        ospfInterface.processOspfMessage(message, channelHandlerContext);
+        ddPacket = new DdPacket();
+        ddPacket.setSourceIp(Ip4Address.valueOf("1.1.1.1"));
+        ddPacket.setRouterId(Ip4Address.valueOf("10.10.10.10"));
+        ddPacket.setOspfVer(2);
+        ddPacket.setAreaId(Ip4Address.valueOf("12.12.12.12"));
+        ddPacket.setOptions(2);
+        ddPacket.setOspftype(2);
+        ddPacket.setAuthType(0);
+        ddPacket.setAuthentication(0);
+        checksumCalculator = new ChecksumCalculator();
+        byteArray = ddPacket.asBytes();
+        ddPacket.setOspfPacLength(byteArray.length);
+        checkArray = checksumCalculator.calculateOspfCheckSum(byteArray, 12, 13);
+        checkArray[0] = -49;
+        checkArray[1] = -79;
+        buf = ChannelBuffers.copiedBuffer(checkArray);
+        ddPacket.setChecksum(buf.readUnsignedShort());
+        channelHandlerContext = null;
+        channelHandlerContext = EasyMock.createMock(ChannelHandlerContext.class);
+        message = ddPacket;
+        ospfInterface.processOspfMessage(message, channelHandlerContext);
+        lsRequest = new LsRequest();
+        lsRequest.setSourceIp(Ip4Address.valueOf("1.1.1.1"));
+        lsRequest.setRouterId(Ip4Address.valueOf("10.10.10.10"));
+        lsRequest.setOspfVer(2);
+        lsRequest.setAreaId(Ip4Address.valueOf("12.12.12.12"));
+        lsRequest.setOspftype(3);
+        lsRequest.setAuthType(0);
+        lsRequest.setAuthentication(0);
+        checksumCalculator = new ChecksumCalculator();
+        byteArray = lsRequest.asBytes();
+        lsRequest.setOspfPacLength(byteArray.length);
+        checkArray = checksumCalculator.calculateOspfCheckSum(byteArray, 12, 13);
+        checkArray[0] = -47;
+        checkArray[1] = -72;
+        buf = ChannelBuffers.copiedBuffer(checkArray);
+        lsRequest.setChecksum(buf.readUnsignedShort());
+        message = lsRequest;
+        channelHandlerContext = null;
+        channelHandlerContext = EasyMock.createMock(ChannelHandlerContext.class);
+        ospfInterface.processOspfMessage(message, channelHandlerContext);
+        lsUpdate = new LsUpdate();
+        lsUpdate.setSourceIp(Ip4Address.valueOf("1.1.1.1"));
+        lsUpdate.setRouterId(Ip4Address.valueOf("10.10.10.10"));
+        lsUpdate.setOspfVer(2);
+        lsUpdate.setAreaId(Ip4Address.valueOf("12.12.12.12"));
+        lsUpdate.setOspftype(4);
+        lsUpdate.setAuthType(0);
+        lsUpdate.setAuthentication(0);
+        checksumCalculator = new ChecksumCalculator();
+        byteArray = lsUpdate.asBytes();
+        lsUpdate.setOspfPacLength(byteArray.length);
+        checkArray = checksumCalculator.calculateOspfCheckSum(byteArray, 12, 13);
+        checkArray[0] = -47;
+        checkArray[1] = -77;
+        buf = ChannelBuffers.copiedBuffer(checkArray);
+        lsUpdate.setChecksum(buf.readUnsignedShort());
+        message = lsUpdate;
+        ospfInterface.processOspfMessage(message, channelHandlerContext);
+        lsAck = new LsAcknowledge();
+        lsAck.setSourceIp(Ip4Address.valueOf("1.1.1.1"));
+        lsAck.setRouterId(Ip4Address.valueOf("10.10.10.10"));
+        lsAck.setOspfVer(2);
+        lsAck.setAreaId(Ip4Address.valueOf("12.12.12.12"));
+        lsAck.setOspftype(5);
+        lsAck.setAuthType(0);
+        lsAck.setAuthentication(0);
+        checksumCalculator = new ChecksumCalculator();
+        byteArray = lsAck.asBytes();
+        lsAck.setOspfPacLength(byteArray.length);
+        checkArray = checksumCalculator.calculateOspfCheckSum(byteArray, 12, 13);
+        checkArray[0] = -47;
+        checkArray[1] = -74;
+        buf = ChannelBuffers.copiedBuffer(checkArray);
+        lsAck.setChecksum(buf.readUnsignedShort());
+        message = lsAck;
+        channelHandlerContext = null;
+        channelHandlerContext = EasyMock.createMock(ChannelHandlerContext.class);
+        ospfInterface.processOspfMessage(message, channelHandlerContext);
+        assertThat(ospfInterface, is(notNullValue()));
+    }
+
+    /**
+     * Tests processHelloMessage() method.
+     */
+    @Test
+    public void testProcessHelloMessage() throws Exception {
+        ospfInterface.setIpAddress(Ip4Address.valueOf("11.11.11.11"));
+        ospfInterface.setInterfaceType(1);
+        ospfInterface.setIpNetworkMask(Ip4Address.valueOf("244.244.244.244"));
+        ospfInterface.setHelloIntervalTime(10);
+        ospfInterface.setRouterDeadIntervalTime(10);
+        ospfArea.setAreaId(Ip4Address.valueOf("12.12.12.12"));
+        channelHandlerContext = EasyMock.createMock(ChannelHandlerContext.class);
+        OspfMessage message;
+        helloPacket = new HelloPacket();
+        helloPacket.setSourceIp(Ip4Address.valueOf("1.1.1.1"));
+        helloPacket.setOspfVer(2);
+        helloPacket.setAreaId(Ip4Address.valueOf("12.12.12.12"));
+        helloPacket.setNetworkMask(Ip4Address.valueOf("244.244.244.244"));
+        helloPacket.setHelloInterval(10);
+        helloPacket.setRouterDeadInterval(10);
+        helloPacket.setDr(Ip4Address.valueOf("10.10.10.10"));
+        helloPacket.setBdr(Ip4Address.valueOf("11.11.11.11"));
+        helloPacket.setRouterId(Ip4Address.valueOf("111.111.111.111"));
+        message = helloPacket;
+        ospfInterface.processHelloMessage(message, channelHandlerContext);
+        assertThat(ospfInterfaceChannelHandler, is(notNullValue()));
+    }
+
+    /**
+     * Tests processHelloMessage() method.
+     */
+    @Test
+    public void testProcessHelloMessage1() throws Exception {
+        ospfInterface.setOspfArea(ospfArea);
+        ospfInterface.setInterfaceType(2);
+        ospfInterface.setRouterPriority(1);
+        ospfInterface.interfaceUp();
+        ospfInterface.setIpAddress(Ip4Address.valueOf("11.11.11.11"));
+        ospfInterface.setState(OspfInterfaceState.WAITING);
+        ospfInterface.setInterfaceType(2);
+        ospfInterface.setIpNetworkMask(Ip4Address.valueOf("244.244.244.244"));
+        ospfInterface.setHelloIntervalTime(10);
+        ospfInterface.setRouterDeadIntervalTime(10);
+        ospfArea.setAreaId(Ip4Address.valueOf("12.12.12.12"));
+        channelHandlerContext = EasyMock.createMock(ChannelHandlerContext.class);
+        OspfMessage message;
+        helloPacket = new HelloPacket();
+        helloPacket.setSourceIp(Ip4Address.valueOf("1.1.1.1"));
+        helloPacket.setOspfVer(2);
+        helloPacket.setAreaId(Ip4Address.valueOf("12.12.12.12"));
+        helloPacket.setNetworkMask(Ip4Address.valueOf("244.244.244.244"));
+        helloPacket.setHelloInterval(10);
+        helloPacket.setRouterDeadInterval(10);
+        helloPacket.setDr(Ip4Address.valueOf("10.10.10.10"));
+        helloPacket.setBdr(Ip4Address.valueOf("11.11.11.11"));
+        helloPacket.setRouterId(Ip4Address.valueOf("2.2.2.2"));
+        message = helloPacket;
+        channelHandlerContext = null;
+        channelHandlerContext = EasyMock.createMock(ChannelHandlerContext.class);
+        ospfInterface.processHelloMessage(message, channelHandlerContext);
+        assertThat(ospfInterfaceChannelHandler, is(notNullValue()));
+        ospfNbrHashMap = new HashMap();
+        ospfNbr = new OspfNbrImpl(ospfArea, ospfInterface, Ip4Address.valueOf("10.10.10.10"),
+                                  Ip4Address.valueOf("2.2.2.2"), 2,
+                                  topologyForDeviceAndLink);
+        ospfNbr.setNeighborId(Ip4Address.valueOf("2.2.2.2"));
+        ospfNbr.setRouterPriority(0);
+        ospfNbr.setNeighborDr(Ip4Address.valueOf("13.13.13.13"));
+        ospfInterface.addNeighbouringRouter(ospfNbr);
+        channelHandlerContext = null;
+        channelHandlerContext = EasyMock.createMock(ChannelHandlerContext.class);
+        ospfInterface.processHelloMessage(message, channelHandlerContext);
+        assertThat(ospfInterfaceChannelHandler, is(notNullValue()));
+    }
+
+    /**
+     * Tests processDdMessage() method.
+     */
+    @Test
+    public void testProcessDdMessage() throws Exception {
+        ospfInterface.setOspfArea(ospfArea);
+        ospfInterface.setIpAddress(Ip4Address.valueOf("11.11.11.11"));
+        ospfInterface.setInterfaceType(2);
+        ospfInterface.setIpNetworkMask(Ip4Address.valueOf("255.255.255.255"));
+        ospfInterface.setHelloIntervalTime(10);
+        ospfInterface.setRouterDeadIntervalTime(10);
+        ospfArea.setAreaId(Ip4Address.valueOf("12.12.12.12"));
+        channelHandlerContext = EasyMock.createMock(ChannelHandlerContext.class);
+        OspfMessage message;
+        ddPacket = new DdPacket();
+        ddPacket.setSourceIp(Ip4Address.valueOf("1.1.1.1"));
+        ddPacket.setOspfVer(2);
+        ddPacket.setAreaId(Ip4Address.valueOf("12.12.12.12"));
+        ddPacket.setRouterId(Ip4Address.valueOf("2.2.2.2"));
+        ddPacket.setIsOpaqueCapable(true);
+        ddPacket.setIsMore(1);
+        ddPacket.setIsInitialize(1);
+        ddPacket.setIsMaster(1);
+        ddPacket.setSequenceNo(123);
+        message = ddPacket;
+        ospfNbrHashMap = new HashMap();
+        ospfNbr = new OspfNbrImpl(ospfArea, ospfInterface, Ip4Address.valueOf("10.10.10.10"),
+                                  Ip4Address.valueOf("2.2.2.2"), 2,
+                                  topologyForDeviceAndLink);
+        ospfNbr.setLastDdPacket(createDdPacket());
+        ospfNbr.setNeighborId(Ip4Address.valueOf("2.2.2.2"));
+        ospfNbr.setState(OspfNeighborState.EXSTART);
+        ospfNbr.setRouterPriority(0);
+        ospfNbr.setNeighborDr(Ip4Address.valueOf("13.13.13.13"));
+        ospfNbr.setDdSeqNum(123);
+        ospfInterface.addNeighbouringRouter(ospfNbr);
+        channelHandlerContext = null;
+        channelHandlerContext = EasyMock.createMock(ChannelHandlerContext.class);
+        ospfInterface.processDdMessage(message, channelHandlerContext);
+        assertThat(ospfInterfaceChannelHandler, is(notNullValue()));
+    }
+
+    /**
+     * Tests processDdMessage() method.
+     */
+    @Test(expected = Exception.class)
+    public void testProcessDdMessage3() throws Exception {
+        ospfInterface.setIpAddress(Ip4Address.valueOf("11.11.11.11"));
+        ospfInterface.setInterfaceType(2);
+        ospfInterface.setIpNetworkMask(Ip4Address.valueOf("255.255.255.255"));
+        ospfInterface.setHelloIntervalTime(10);
+        ospfInterface.setRouterDeadIntervalTime(10);
+        ospfArea.setAreaId(Ip4Address.valueOf("12.12.12.12"));
+        channelHandlerContext = EasyMock.createMock(ChannelHandlerContext.class);
+        OspfMessage message;
+        ddPacket = new DdPacket();
+        ddPacket.setSourceIp(Ip4Address.valueOf("1.1.1.1"));
+        ddPacket.setOspfVer(2);
+        ddPacket.setAreaId(Ip4Address.valueOf("12.12.12.12"));
+        ddPacket.setRouterId(Ip4Address.valueOf("2.2.2.2"));
+        ddPacket.setIsOpaqueCapable(true);
+        ddPacket.setIsMore(1);
+        ddPacket.setIsInitialize(1);
+        ddPacket.setIsMaster(1);
+        ddPacket.setSequenceNo(123);
+        message = ddPacket;
+        ospfNbrHashMap = new HashMap();
+        ospfNbr = new OspfNbrImpl(ospfArea, ospfInterface, Ip4Address.valueOf("10.10.10.10"),
+                                  Ip4Address.valueOf("2.2.2.2"), 2,
+                                  topologyForDeviceAndLink);
+        ospfNbr.setLastDdPacket(createDdPacket());
+        ospfNbr.setNeighborId(Ip4Address.valueOf("2.2.2.2"));
+        ospfNbr.setState(OspfNeighborState.EXSTART);
+        ospfNbr.setRouterPriority(0);
+        ospfNbr.setNeighborDr(Ip4Address.valueOf("13.13.13.13"));
+        ospfNbr.setDdSeqNum(123);
+        ospfInterface.addNeighbouringRouter(ospfNbr);
+        ddPacket.setIsMore(1);
+        ddPacket.setIsInitialize(0);
+        ddPacket.setIsMaster(0);
+        ddPacket.setSequenceNo(123);
+        ospfInterface.addNeighbouringRouter(ospfNbr);
+        channelHandlerContext = null;
+        channelHandlerContext = EasyMock.createMock(ChannelHandlerContext.class);
+        ospfInterface.processDdMessage(message, channelHandlerContext);
+        assertThat(ospfInterfaceChannelHandler, is(notNullValue()));
+    }
+
+    /**
+     * Tests processDdMessage() method.
+     */
+    @Test(expected = Exception.class)
+    public void testProcessDdMessage1() throws Exception {
+        ospfInterface.setIpAddress(Ip4Address.valueOf("11.11.11.11"));
+        ospfInterface.setInterfaceType(2);
+        ospfInterface.setIpNetworkMask(Ip4Address.valueOf("255.255.255.255"));
+        ospfInterface.setHelloIntervalTime(10);
+        ospfInterface.setRouterDeadIntervalTime(10);
+        ospfArea.setAreaId(Ip4Address.valueOf("12.12.12.12"));
+        channelHandlerContext = EasyMock.createMock(ChannelHandlerContext.class);
+        OspfMessage message;
+        ddPacket = new DdPacket();
+        ddPacket.setSourceIp(Ip4Address.valueOf("1.1.1.1"));
+        ddPacket.setOspfVer(2);
+        ddPacket.setAreaId(Ip4Address.valueOf("12.12.12.12"));
+        ddPacket.setRouterId(Ip4Address.valueOf("2.2.2.2"));
+        ddPacket.setIsOpaqueCapable(true);
+        ddPacket.setIsMore(1);
+        ddPacket.setIsInitialize(1);
+        ddPacket.setIsMaster(1);
+        ddPacket.setSequenceNo(123);
+        message = ddPacket;
+        ospfNbrHashMap = new HashMap();
+        ospfNbr = new OspfNbrImpl(ospfArea, ospfInterface, Ip4Address.valueOf("10.10.10.10"),
+                                  Ip4Address.valueOf("2.2.2.2"), 2,
+                                  topologyForDeviceAndLink);
+        ospfNbr.setLastDdPacket(createDdPacket());
+        ospfNbr.setNeighborId(Ip4Address.valueOf("2.2.2.2"));
+        ospfNbr.setState(OspfNeighborState.EXCHANGE);
+        ospfNbr.setRouterPriority(0);
+        ospfNbr.setNeighborDr(Ip4Address.valueOf("13.13.13.13"));
+        ospfNbr.setDdSeqNum(123);
+        ospfInterface.addNeighbouringRouter(ospfNbr);
+        ddPacket.setIsMore(1);
+        ddPacket.setIsInitialize(0);
+        ddPacket.setIsMaster(0);
+        ddPacket.setSequenceNo(123);
+        ospfInterface.addNeighbouringRouter(ospfNbr);
+        channelHandlerContext = null;
+        channelHandlerContext = EasyMock.createMock(ChannelHandlerContext.class);
+        ospfInterface.processDdMessage(message, channelHandlerContext);
+        assertThat(ospfInterfaceChannelHandler, is(notNullValue()));
+
+    }
+
+    /**
+     * Tests processDdMessage() method.
+     */
+    @Test(expected = Exception.class)
+    public void testProcessDdMessage2() throws Exception {
+        ospfInterface.setIpAddress(Ip4Address.valueOf("11.11.11.11"));
+        ospfInterface.setInterfaceType(2);
+        ospfInterface.setIpNetworkMask(Ip4Address.valueOf("255.255.255.255"));
+        ospfInterface.setHelloIntervalTime(10);
+        ospfInterface.setRouterDeadIntervalTime(10);
+        ospfArea.setAreaId(Ip4Address.valueOf("12.12.12.12"));
+        channelHandlerContext = EasyMock.createMock(ChannelHandlerContext.class);
+        OspfMessage message;
+        ddPacket = new DdPacket();
+        ddPacket.setSourceIp(Ip4Address.valueOf("1.1.1.1"));
+        ddPacket.setOspfVer(2);
+        ddPacket.setAreaId(Ip4Address.valueOf("12.12.12.12"));
+        ddPacket.setRouterId(Ip4Address.valueOf("2.2.2.2"));
+        ddPacket.setIsOpaqueCapable(true);
+        ddPacket.setIsMore(1);
+        ddPacket.setIsInitialize(1);
+        ddPacket.setIsMaster(1);
+        ddPacket.setSequenceNo(123);
+        message = ddPacket;
+        ospfNbrHashMap = new HashMap();
+        ospfNbr = new OspfNbrImpl(ospfArea, ospfInterface, Ip4Address.valueOf("10.10.10.10"),
+                                  Ip4Address.valueOf("2.2.2.2"), 2,
+                                  topologyForDeviceAndLink);
+        ospfNbr.setLastDdPacket(createDdPacket());
+        ospfNbr.setNeighborId(Ip4Address.valueOf("2.2.2.2"));
+        ospfNbr.setState(OspfNeighborState.LOADING);
+        ospfNbr.setRouterPriority(0);
+        ospfNbr.setNeighborDr(Ip4Address.valueOf("13.13.13.13"));
+        ospfNbr.setDdSeqNum(123);
+        ospfInterface.addNeighbouringRouter(ospfNbr);
+        ospfInterface.setState(OspfInterfaceState.POINT2POINT);
+        channelHandlerContext = null;
+        channelHandlerContext = EasyMock.createMock(ChannelHandlerContext.class);
+        ospfInterface.processDdMessage(message, channelHandlerContext);
+        assertThat(ospfInterfaceChannelHandler, is(notNullValue()));
+
+    }
+
+    /**
+     * Tests processDdMessage() method.
+     */
+    @Test(expected = Exception.class)
+    public void testProcessDdMessage4() throws Exception {
+        ospfInterface.setIpAddress(Ip4Address.valueOf("11.11.11.11"));
+        ospfInterface.setInterfaceType(2);
+        ospfInterface.setIpNetworkMask(Ip4Address.valueOf("255.255.255.255"));
+        ospfInterface.setHelloIntervalTime(10);
+        ospfInterface.setRouterDeadIntervalTime(10);
+        ospfArea.setAreaId(Ip4Address.valueOf("12.12.12.12"));
+        channelHandlerContext = EasyMock.createMock(ChannelHandlerContext.class);
+        OspfMessage message;
+        ddPacket = new DdPacket();
+        ddPacket.setSourceIp(Ip4Address.valueOf("1.1.1.1"));
+        ddPacket.setOspfVer(2);
+        ddPacket.setAreaId(Ip4Address.valueOf("12.12.12.12"));
+        ddPacket.setRouterId(Ip4Address.valueOf("2.2.2.2"));
+        ddPacket.setIsOpaqueCapable(true);
+        ddPacket.setIsMore(1);
+        ddPacket.setIsInitialize(1);
+        ddPacket.setIsMaster(1);
+        ddPacket.setSequenceNo(123);
+        message = ddPacket;
+        ospfNbrHashMap = new HashMap();
+        ospfNbr = new OspfNbrImpl(ospfArea, ospfInterface, Ip4Address.valueOf("10.10.10.10"),
+                                  Ip4Address.valueOf("2.2.2.2"), 2,
+                                  topologyForDeviceAndLink);
+        ospfNbr.setLastDdPacket(createDdPacket());
+        ospfNbr.setNeighborId(Ip4Address.valueOf("2.2.2.2"));
+        ospfNbr.setState(OspfNeighborState.EXCHANGE);
+        ospfNbr.setRouterPriority(0);
+        ospfNbr.setNeighborDr(Ip4Address.valueOf("13.13.13.13"));
+        ospfNbr.setDdSeqNum(123);
+        ospfInterface.addNeighbouringRouter(ospfNbr);
+        ospfInterface.setState(OspfInterfaceState.POINT2POINT);
+        channelHandlerContext = null;
+        channelHandlerContext = EasyMock.createMock(ChannelHandlerContext.class);
+        ddPacket.setIsMore(1);
+        ddPacket.setIsInitialize(0);
+        ddPacket.setIsMaster(1);
+        ddPacket.setSequenceNo(123);
+        ospfInterface.addNeighbouringRouter(ospfNbr);
+        ospfNbr.setState(OspfNeighborState.EXCHANGE);
+        ospfInterface.addNeighbouringRouter(ospfNbr);
+        channelHandlerContext = null;
+        channelHandlerContext = EasyMock.createMock(ChannelHandlerContext.class);
+        ospfInterface.processDdMessage(message, channelHandlerContext);
+        assertThat(ospfInterfaceChannelHandler, is(notNullValue()));
+
+    }
+
+    /**
+     * Tests processDdMessage() method.
+     */
+    @Test(expected = Exception.class)
+    public void testProcessDdMessage5() throws Exception {
+        ospfInterface.setIpAddress(Ip4Address.valueOf("11.11.11.11"));
+        ospfInterface.setInterfaceType(2);
+        ospfInterface.setIpNetworkMask(Ip4Address.valueOf("255.255.255.255"));
+        ospfInterface.setHelloIntervalTime(10);
+        ospfInterface.setRouterDeadIntervalTime(10);
+        ospfArea.setAreaId(Ip4Address.valueOf("12.12.12.12"));
+        channelHandlerContext = EasyMock.createMock(ChannelHandlerContext.class);
+        OspfMessage message;
+        ddPacket = new DdPacket();
+        ddPacket.setSourceIp(Ip4Address.valueOf("1.1.1.1"));
+        ddPacket.setOspfVer(2);
+        ddPacket.setAreaId(Ip4Address.valueOf("12.12.12.12"));
+        ddPacket.setRouterId(Ip4Address.valueOf("2.2.2.2"));
+        ddPacket.setIsOpaqueCapable(true);
+        ddPacket.setIsMore(1);
+        ddPacket.setIsInitialize(1);
+        ddPacket.setIsMaster(1);
+        ddPacket.setSequenceNo(123);
+        message = ddPacket;
+        ospfNbrHashMap = new HashMap();
+        ospfNbr = new OspfNbrImpl(ospfArea, ospfInterface, Ip4Address.valueOf("10.10.10.10"),
+                                  Ip4Address.valueOf("2.2.2.2"), 2,
+                                  topologyForDeviceAndLink);
+        ospfNbr.setLastDdPacket(createDdPacket());
+        ospfNbr.setNeighborId(Ip4Address.valueOf("2.2.2.2"));
+        ospfNbr.setState(OspfNeighborState.EXCHANGE);
+        ospfNbr.setRouterPriority(0);
+        ospfNbr.setNeighborDr(Ip4Address.valueOf("13.13.13.13"));
+        ospfNbr.setDdSeqNum(123);
+        ospfInterface.addNeighbouringRouter(ospfNbr);
+        ospfInterface.setState(OspfInterfaceState.POINT2POINT);
+        channelHandlerContext = null;
+        channelHandlerContext = EasyMock.createMock(ChannelHandlerContext.class);
+        ddPacket.setIsMore(1);
+        ddPacket.setIsInitialize(1);
+        ddPacket.setIsMaster(0);
+        ddPacket.setSequenceNo(123);
+        ospfInterface.addNeighbouringRouter(ospfNbr);
+        ospfNbr.setState(OspfNeighborState.EXCHANGE);
+        ospfInterface.addNeighbouringRouter(ospfNbr);
+        channelHandlerContext = null;
+        channelHandlerContext = EasyMock.createMock(ChannelHandlerContext.class);
+        ospfInterface.processDdMessage(message, channelHandlerContext);
+        assertThat(ospfInterfaceChannelHandler, is(notNullValue()));
+
+    }
+
+    /**
+     * Tests processDdMessage() method.
+     */
+    @Test(expected = Exception.class)
+    public void testProcessDdMessage6() throws Exception {
+        ospfInterface.setIpAddress(Ip4Address.valueOf("11.11.11.11"));
+        ospfInterface.setInterfaceType(2);
+        ospfInterface.setIpNetworkMask(Ip4Address.valueOf("255.255.255.255"));
+        ospfInterface.setHelloIntervalTime(10);
+        ospfInterface.setRouterDeadIntervalTime(10);
+        ospfArea.setAreaId(Ip4Address.valueOf("12.12.12.12"));
+        channelHandlerContext = EasyMock.createMock(ChannelHandlerContext.class);
+        OspfMessage message;
+        ddPacket = new DdPacket();
+        ddPacket.setSourceIp(Ip4Address.valueOf("1.1.1.1"));
+        ddPacket.setOspfVer(2);
+        ddPacket.setAreaId(Ip4Address.valueOf("12.12.12.12"));
+        ddPacket.setRouterId(Ip4Address.valueOf("2.2.2.2"));
+        ddPacket.setIsOpaqueCapable(true);
+        ddPacket.setIsMore(1);
+        ddPacket.setIsInitialize(1);
+        ddPacket.setIsMaster(1);
+        ddPacket.setSequenceNo(123);
+        message = ddPacket;
+        ospfNbrHashMap = new HashMap();
+        ospfNbr = new OspfNbrImpl(ospfArea, ospfInterface, Ip4Address.valueOf("10.10.10.10"),
+                                  Ip4Address.valueOf("2.2.2.2"), 2,
+                                  topologyForDeviceAndLink);
+        ospfNbr.setLastDdPacket(createDdPacket());
+        ospfNbr.setNeighborId(Ip4Address.valueOf("2.2.2.2"));
+        ospfNbr.setState(OspfNeighborState.FULL);
+        ospfNbr.setRouterPriority(0);
+        ospfNbr.setNeighborDr(Ip4Address.valueOf("13.13.13.13"));
+        ospfNbr.setDdSeqNum(123);
+        ospfInterface.addNeighbouringRouter(ospfNbr);
+        ospfInterface.setState(OspfInterfaceState.POINT2POINT);
+        channelHandlerContext = null;
+        channelHandlerContext = EasyMock.createMock(ChannelHandlerContext.class);
+        ddPacket.setIsMore(1);
+        ddPacket.setIsInitialize(1);
+        ddPacket.setIsMaster(0);
+        ddPacket.setSequenceNo(123);
+        ospfInterface.addNeighbouringRouter(ospfNbr);
+        ospfNbr.setState(OspfNeighborState.FULL);
+        ospfInterface.addNeighbouringRouter(ospfNbr);
+        channelHandlerContext = null;
+        channelHandlerContext = EasyMock.createMock(ChannelHandlerContext.class);
+        ospfInterface.processDdMessage(message, channelHandlerContext);
+        assertThat(ospfInterfaceChannelHandler, is(notNullValue()));
+
+    }
+
+    /**
+     * Tests processLsRequestMessage() method.
+     */
+    @Test(expected = Exception.class)
+    public void testProcessLSRequestMessage() throws Exception {
+        ospfArea.setRouterId(Ip4Address.valueOf("11.11.11.11"));
+        ospfArea.setAreaId(Ip4Address.valueOf("12.12.12.12"));
+        ospfInterface.setOspfArea(ospfArea);
+        ospfInterface.setIpAddress(Ip4Address.valueOf("11.11.11.11"));
+        ospfInterface.setInterfaceType(2);
+        ospfInterface.setIpNetworkMask(Ip4Address.valueOf("255.255.255.255"));
+        ospfInterface.setHelloIntervalTime(10);
+        ospfInterface.setRouterDeadIntervalTime(10);
+        channelHandlerContext = EasyMock.createMock(ChannelHandlerContext.class);
+        OspfMessage message;
+        lsRequest = new LsRequest();
+        lsRequest.setSourceIp(Ip4Address.valueOf("1.1.1.1"));
+        lsRequest.setOspfVer(2);
+        lsRequest.setAreaId(Ip4Address.valueOf("12.12.12.12"));
+        lsRequest.setRouterId(Ip4Address.valueOf("10.226.165.100"));
+        List<LsRequestPacket> lsRequests = new ArrayList();
+        LsRequestPacket lsRequestPacket = new LsRequestPacket();
+        lsRequestPacket.setLsType(OspfLsaType.AREA_LOCAL_OPAQUE_LSA.value());
+        lsRequestPacket.setLinkStateId("2.2.2.2");
+        lsRequestPacket.setOwnRouterId("10.226.165.100");
+        lsRequests.add(lsRequestPacket);
+        lsRequests.add(lsRequestPacket);
+        lsRequest.addLinkStateRequests(lsRequestPacket);
+        message = lsRequest;
+        ospfNbrHashMap = new HashMap();
+        ospfNbr.setState(OspfNeighborState.EXCHANGE);
+        ospfNbr = new OspfNbrImpl(ospfArea, createOspfInterface(), Ip4Address.valueOf("10.10.10.10"),
+                                  Ip4Address.valueOf("10.226.165.100"), 2,
+                                  topologyForDeviceAndLink);
+        ospfNbr.setLastDdPacket(createDdPacket());
+        ospfNbr.setNeighborId(Ip4Address.valueOf("10.226.165.100"));
+        ospfNbr.setState(OspfNeighborState.FULL);
+        ospfNbr.setRouterPriority(0);
+        ospfNbr.setNeighborDr(Ip4Address.valueOf("13.13.13.13"));
+        ospfNbr.setDdSeqNum(123);
+        ospfInterface.addNeighbouringRouter(ospfNbr);
+        OpaqueLsaHeader lsaHeader = new OpaqueLsaHeader();
+        lsaHeader.setLsType(OspfLsaType.AREA_LOCAL_OPAQUE_LSA.value());
+        lsaHeader.setLinkStateId("2.2.2.2");
+        lsaHeader.setAdvertisingRouter(Ip4Address.valueOf("10.226.165.100"));
+        OpaqueLsa10 opaqueLsa10 = new OpaqueLsa10(lsaHeader);
+        ospfArea.addLsa(opaqueLsa10, false, ospfInterface);
+        ospfInterface.setOspfArea(ospfArea);
+        ospfInterface.processLsRequestMessage(message, channelHandlerContext);
+        assertThat(ospfInterface, is(notNullValue()));
+    }
+
+    /**
+     * Tests processLsUpdateMessage() method.
+     */
+    @Test
+    public void testProcessLSUpdateMessage() throws Exception {
+        ospfInterface.setIpAddress(Ip4Address.valueOf("11.11.11.11"));
+        ospfInterface.setInterfaceType(2);
+        ospfInterface.setIpNetworkMask(Ip4Address.valueOf("255.255.255.255"));
+        ospfInterface.setHelloIntervalTime(10);
+        ospfInterface.setRouterDeadIntervalTime(10);
+        ospfArea.setAreaId(Ip4Address.valueOf("12.12.12.12"));
+        channelHandlerContext = EasyMock.createMock(ChannelHandlerContext.class);
+        OspfMessage message;
+        lsUpdate = new LsUpdate();
+        lsUpdate.setSourceIp(Ip4Address.valueOf("1.1.1.1"));
+        lsUpdate.setOspfVer(2);
+        lsUpdate.setAreaId(Ip4Address.valueOf("12.12.12.12"));
+        lsUpdate.setRouterId(Ip4Address.valueOf("10.226.165.100"));
+        RouterLsa routerLsa = new RouterLsa();
+        lsUpdate.addLsa(routerLsa);
+        lsUpdate.setNumberOfLsa(1);
+        message = lsUpdate;
+        ospfNbrHashMap = new HashMap();
+        ospfNbr.setState(OspfNeighborState.FULL);
+        ospfNbr = new OspfNbrImpl(ospfArea, createOspfInterface(), Ip4Address.valueOf("10.10.10.10"),
+                                  Ip4Address.valueOf("10.226.165.100"), 2,
+                                  topologyForDeviceAndLink);
+        ospfNbr.setLastDdPacket(createDdPacket());
+        ospfNbr.setNeighborId(Ip4Address.valueOf("2.2.2.2"));
+        ospfNbr.setState(OspfNeighborState.FULL);
+        ospfNbr.setRouterPriority(0);
+        ospfNbr.setNeighborDr(Ip4Address.valueOf("13.13.13.13"));
+        ospfNbr.setDdSeqNum(123);
+        ospfInterface.addNeighbouringRouter(ospfNbr);
+        channelHandlerContext = null;
+        channelHandlerContext = EasyMock.createMock(ChannelHandlerContext.class);
+        ospfInterface.processLsUpdateMessage(message, channelHandlerContext);
+        assertThat(ospfInterfaceChannelHandler, is(notNullValue()));
+
+    }
+
+    @Test(expected = Exception.class)
+    public void testProcessLSAckMessage() throws Exception {
+        ospfInterface.setIpAddress(Ip4Address.valueOf("11.11.11.11"));
+        ospfInterface.setInterfaceType(2);
+        ospfInterface.setIpNetworkMask(Ip4Address.valueOf("255.255.255.255"));
+        ospfInterface.setHelloIntervalTime(10);
+        ospfInterface.setRouterDeadIntervalTime(10);
+        ospfArea.setAreaId(Ip4Address.valueOf("12.12.12.12"));
+        channelHandlerContext = EasyMock.createMock(ChannelHandlerContext.class);
+        OspfMessage message;
+        lsAck = new LsAcknowledge();
+        lsAck.setSourceIp(Ip4Address.valueOf("1.1.1.1"));
+        lsAck.setOspfVer(2);
+        lsAck.setAreaId(Ip4Address.valueOf("12.12.12.12"));
+        LsaHeader lsaHeader = new LsaHeader();
+        lsAck.addLinkStateHeader(lsaHeader);
+        message = lsAck;
+        ospfNbr = new OspfNbrImpl(ospfArea, createOspfInterface(), Ip4Address.valueOf("10.10.10.10"),
+                                  Ip4Address.valueOf("10.226.165.100"), 2,
+                                  topologyForDeviceAndLink);
+        ospfNbr.setLastDdPacket(createDdPacket());
+        ospfNbr.setNeighborId(Ip4Address.valueOf("2.2.2.2"));
+        ospfNbr.setState(OspfNeighborState.FULL);
+        ospfNbr.setRouterPriority(0);
+        ospfNbr.setNeighborDr(Ip4Address.valueOf("13.13.13.13"));
+        ospfNbr.setDdSeqNum(123);
+        channelHandlerContext = null;
+        channelHandlerContext = EasyMock.createMock(ChannelHandlerContext.class);
+        ospfInterface.processLsAckMessage(message, channelHandlerContext);
+        assertThat(ospfInterfaceChannelHandler, is(notNullValue()));
+
+    }
+
+    /**
+     * Tests electRouter() method.
+     */
+    @Test
+    public void testElectRouter() throws Exception {
+        ospfInterface.setOspfArea(ospfArea);
+        ospfInterface.setDr(Ip4Address.valueOf("3.3.3.3"));
+        ospfInterface.setBdr(Ip4Address.valueOf("3.3.3.3"));
+        ospfInterface.setIpNetworkMask(Ip4Address.valueOf("255.255.255.255"));
+        ChannelConfig channelConfig = EasyMock.createMock(ChannelConfig.class);
+        EasyMock.expect(channelConfig.getBufferFactory()).andReturn(new HeapChannelBufferFactory());
+        Channel channel = EasyMock.createMock(Channel.class);
+        ospfInterface.electRouter(channel);
+        assertThat(ospfInterface.dr(), is(notNullValue()));
+    }
+
+    /**
+     * Tests electBdr() method.
+     */
+    @Test
+    public void testElectBdr() throws Exception {
+        ospfEligibleRouter = new OspfEligibleRouter();
+        ospfEligibleRouter.setIpAddress(Ip4Address.valueOf("1.1.1.1"));
+        ospfEligibleRouter.setIsDr(true);
+        ospfEligibleRouter.setRouterPriority(10);
+        ospfEligibleRouter.setRouterId(Ip4Address.valueOf("1.1.1.1"));
+        ospfEligibleRouter.setIsBdr(false);
+        OspfEligibleRouter ospfEligibleRouter1 = new OspfEligibleRouter();
+        ospfEligibleRouter.setIpAddress(Ip4Address.valueOf("1.1.1.1"));
+        ospfEligibleRouter.setIsDr(true);
+        ospfEligibleRouter.setRouterPriority(10);
+        ospfEligibleRouter.setRouterId(Ip4Address.valueOf("1.1.1.1"));
+        ospfEligibleRouter.setIsBdr(false);
+        OspfEligibleRouter ospfEligibleRouter2 = new OspfEligibleRouter();
+        ospfEligibleRouter.setIpAddress(Ip4Address.valueOf("1.1.1.1"));
+        ospfEligibleRouter.setIsDr(true);
+        ospfEligibleRouter.setRouterPriority(10);
+        ospfEligibleRouter.setRouterId(Ip4Address.valueOf("1.1.1.1"));
+        ospfEligibleRouter.setIsBdr(false);
+        List<OspfEligibleRouter> ospfEligibleRouters = new ArrayList<>();
+
+        ospfEligibleRouters.add(ospfEligibleRouter);
+        ospfEligibleRouters.add(ospfEligibleRouter1);
+        ospfEligibleRouters.add(ospfEligibleRouter2);
+        OspfEligibleRouter eligibleRouter = ospfInterface.electBdr(ospfEligibleRouters);
+        assertThat(ospfEligibleRouters.size(), is(3));
+        assertThat(eligibleRouter, is(notNullValue()));
+    }
+
+    /**
+     * Tests electDr() method.
+     */
+    @Test
+    public void testElectDR() throws Exception {
+        ospfEligibleRouter = new OspfEligibleRouter();
+        ospfEligibleRouter.setIpAddress(Ip4Address.valueOf("1.1.1.1"));
+        ospfEligibleRouter.setIsDr(true);
+        ospfEligibleRouter.setRouterPriority(10);
+        ospfEligibleRouter.setRouterId(Ip4Address.valueOf("1.1.1.1"));
+        ospfEligibleRouter.setIsBdr(false);
+        OspfEligibleRouter ospfEligibleRouter1 = new OspfEligibleRouter();
+        ospfEligibleRouter.setIpAddress(Ip4Address.valueOf("1.1.1.1"));
+        ospfEligibleRouter.setIsDr(true);
+        ospfEligibleRouter.setRouterPriority(10);
+        ospfEligibleRouter.setRouterId(Ip4Address.valueOf("1.1.1.1"));
+        ospfEligibleRouter.setIsBdr(false);
+        OspfEligibleRouter ospfEligibleRouter2 = new OspfEligibleRouter();
+        ospfEligibleRouter.setIpAddress(Ip4Address.valueOf("1.1.1.1"));
+        ospfEligibleRouter.setIsDr(true);
+        ospfEligibleRouter.setRouterPriority(10);
+        ospfEligibleRouter.setRouterId(Ip4Address.valueOf("1.1.1.1"));
+        ospfEligibleRouter.setIsBdr(false);
+        List<OspfEligibleRouter> ospfEligibleRouters = new ArrayList<>();
+        ospfEligibleRouters.add(ospfEligibleRouter);
+        ospfEligibleRouters.add(ospfEligibleRouter1);
+        ospfEligibleRouters.add(ospfEligibleRouter2);
+        OspfEligibleRouter eligibleRouter = ospfInterface.electDr(ospfEligibleRouters,
+                                                                  ospfEligibleRouter);
+        assertThat(ospfEligibleRouters.size(), is(3));
+        assertThat(eligibleRouter, is(notNullValue()));
+    }
+
+    /**
+     * Tests selectRouterBasedOnPriority() method.
+     */
+    @Test
+    public void testSelectRouterBasedOnPriority() throws Exception {
+        ospfEligibleRouter = new OspfEligibleRouter();
+        ospfEligibleRouter.setIpAddress(Ip4Address.valueOf("1.1.1.1"));
+        ospfEligibleRouter.setIsDr(true);
+        ospfEligibleRouter.setRouterPriority(10);
+        ospfEligibleRouter.setRouterId(Ip4Address.valueOf("1.1.1.1"));
+        ospfEligibleRouter.setIsBdr(false);
+        OspfEligibleRouter ospfEligibleRouter1 = new OspfEligibleRouter();
+        ospfEligibleRouter.setIpAddress(Ip4Address.valueOf("1.1.1.1"));
+        ospfEligibleRouter.setIsDr(true);
+        ospfEligibleRouter.setRouterPriority(11);
+        ospfEligibleRouter.setRouterId(Ip4Address.valueOf("1.1.1.1"));
+        ospfEligibleRouter.setIsBdr(false);
+        OspfEligibleRouter ospfEligibleRouter2 = new OspfEligibleRouter();
+        ospfEligibleRouter.setIpAddress(Ip4Address.valueOf("1.1.1.1"));
+        ospfEligibleRouter.setIsDr(true);
+        ospfEligibleRouter.setRouterPriority(12);
+        ospfEligibleRouter.setRouterId(Ip4Address.valueOf("1.1.1.1"));
+        ospfEligibleRouter.setIsBdr(false);
+        List<OspfEligibleRouter> ospfEligibleRouters = new ArrayList<>();
+        ospfEligibleRouters.add(ospfEligibleRouter);
+        ospfEligibleRouters.add(ospfEligibleRouter1);
+        ospfEligibleRouters.add(ospfEligibleRouter2);
+        OspfEligibleRouter eligibleRouter = ospfInterface.selectRouterBasedOnPriority(
+                ospfEligibleRouters);
+        assertThat(eligibleRouter, is(notNullValue()));
+    }
+
+    /**
+     * Tests addDeviceInformation() method.
+     */
+    @Test(expected = Exception.class)
+    public void testAddDeviceInformation() throws Exception {
+        ospfNbr = new OspfNbrImpl(ospfArea, createOspfInterface(), Ip4Address.valueOf("10.10.10.10"),
+                                  Ip4Address.valueOf("10.226.165.100"), 2,
+                                  topologyForDeviceAndLink);
+
+        ospfInterface.addDeviceInformation(new OspfRouterImpl());
+        assertThat(ospfInterfaceChannelHandler, is(notNullValue()));
+    }
+
+    /**
+     * Tests removeDeviceInformation() method.
+     */
+    @Test(expected = Exception.class)
+    public void testRemoveDeviceInformation() throws Exception {
+        ospfNbr = new OspfNbrImpl(ospfArea, createOspfInterface(), Ip4Address.valueOf("10.10.10.10"),
+                                  Ip4Address.valueOf("10.226.165.100"), 2,
+                                  topologyForDeviceAndLink);
+
+        ospfInterface.removeDeviceInformation(new OspfRouterImpl());
+        assertThat(ospfInterfaceChannelHandler, is(notNullValue()));
+    }
+
+    /**
+     * Tests addLinkInformation() method.
+     */
+    @Test(expected = Exception.class)
+    public void testaddLinkInformation() throws Exception {
+        ospfNbr = new OspfNbrImpl(ospfArea, createOspfInterface(), Ip4Address.valueOf("10.10.10.10"),
+                                  Ip4Address.valueOf("10.226.165.100"), 2,
+                                  topologyForDeviceAndLink);
+
+        List topTlv = new ArrayList();
+        topTlv.add(new RouterTlv(new TlvHeader()));
+        ospfInterface.addLinkInformation(new OspfRouterImpl(), new OspfLinkTedImpl());
+        assertThat(ospfInterfaceChannelHandler, is(notNullValue()));
+    }
+
+    /**
+     * Tests removeLinkInformation() method.
+     */
+    @Test(expected = Exception.class)
+    public void testRemoveLinkInformation() throws Exception {
+        ospfNbr = new OspfNbrImpl(ospfArea, createOspfInterface(), Ip4Address.valueOf("10.10.10.10"),
+                                  Ip4Address.valueOf("10.226.165.100"), 2,
+                                  topologyForDeviceAndLink);
+
+        ospfInterface.removeLinkInformation(new OspfRouterImpl(), new OspfLinkTedImpl());
+        assertThat(ospfInterfaceChannelHandler, is(notNullValue()));
+    }
+
+    /**
+     * Utility for test method.
+     */
+    private DdPacket createDdPacket() throws OspfParseException {
+        byte[] ddPacket = {2, 2, 0, 32, -64, -88, -86, 8, 0, 0, 0, 1, -96, 82,
+                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, -36, 2, 7, 65, 119, -87, 126};
+        DdPacket ddPacket1 = new DdPacket();
+        ChannelBuffer buf = ChannelBuffers.buffer(ddPacket.length);
+        buf.writeBytes(ddPacket);
+        ddPacket1.readFrom(buf);
+        return ddPacket1;
+    }
+
+    /**
+     * Utility for test method.
+     */
+    private OspfInterfaceImpl createOspfInterface() throws UnknownHostException {
+        ospfInterface = new OspfInterfaceImpl();
+        OspfAreaImpl ospfArea = new OspfAreaImpl();
+        OspfInterfaceChannelHandler ospfInterfaceChannelHandler = EasyMock.createMock(
+                OspfInterfaceChannelHandler.class);
+        ospfNbr = new OspfNbrImpl(ospfArea, ospfInterface, Ip4Address.valueOf("10.226.165.164"),
+                                  Ip4Address.valueOf("1.1.1.1"), 2,
+                                  topologyForDeviceAndLink);
+        ospfNbr.setState(OspfNeighborState.EXSTART);
+        ospfNbr.setNeighborId(Ip4Address.valueOf("10.226.165.100"));
+        this.ospfInterface = new OspfInterfaceImpl();
+        this.ospfInterface.setIpAddress(Ip4Address.valueOf("10.226.165.164"));
+        this.ospfInterface.setIpNetworkMask(Ip4Address.valueOf("255.255.255.255"));
+        this.ospfInterface.setBdr(Ip4Address.valueOf("111.111.111.111"));
+        this.ospfInterface.setDr(Ip4Address.valueOf("111.111.111.111"));
+        this.ospfInterface.setHelloIntervalTime(20);
+        this.ospfInterface.setInterfaceType(2);
+        this.ospfInterface.setReTransmitInterval(2000);
+        this.ospfInterface.setMtu(6500);
+        this.ospfInterface.setRouterDeadIntervalTime(1000);
+        this.ospfInterface.setRouterPriority(1);
+        this.ospfInterface.setInterfaceType(1);
+        this.ospfInterface.addNeighbouringRouter(ospfNbr);
+        return this.ospfInterface;
+    }
+
+    /**
+     * Utility for test method.
+     */
+    private OspfInterfaceImpl createOspfInterface1() throws UnknownHostException {
+        ospfInterface = new OspfInterfaceImpl();
+        OspfAreaImpl ospfArea = new OspfAreaImpl();
+        OspfInterfaceChannelHandler ospfInterfaceChannelHandler = EasyMock.createMock(
+                OspfInterfaceChannelHandler.class);
+        ospfNbr = new OspfNbrImpl(ospfArea, ospfInterface, Ip4Address.valueOf("10.226.165.164"),
+                                  Ip4Address.valueOf("1.1.1.1"), 2,
+                                  topologyForDeviceAndLink);
+        ospfNbr.setState(OspfNeighborState.FULL);
+        ospfNbr.setNeighborId(Ip4Address.valueOf("10.226.165.100"));
+        ospfInterface = new OspfInterfaceImpl();
+        ospfInterface.setIpAddress(Ip4Address.valueOf("10.226.165.164"));
+        ospfInterface.setIpNetworkMask(Ip4Address.valueOf("255.255.255.255"));
+        ospfInterface.setBdr(Ip4Address.valueOf("111.111.111.111"));
+        ospfInterface.setDr(Ip4Address.valueOf("111.111.111.111"));
+        ospfInterface.setHelloIntervalTime(20);
+        ospfInterface.setInterfaceType(2);
+        ospfInterface.setReTransmitInterval(2000);
+        ospfInterface.setMtu(6500);
+        ospfInterface.setRouterDeadIntervalTime(1000);
+        ospfInterface.setRouterPriority(1);
+        ospfInterface.setInterfaceType(1);
+        ospfInterface.addNeighbouringRouter(ospfNbr);
+        return ospfInterface;
+    }
+
+    /**
+     * Utility for test method.
+     */
+    private OspfAreaImpl createOspfArea() throws UnknownHostException {
+        OspfAreaAddressRangeImpl ospfAreaAddressRange;
+        ospfAreaAddressRange = createOspfAreaAddressRange();
+        addressRanges.add(ospfAreaAddressRange);
+        OspfAreaImpl ospfArea = new OspfAreaImpl();
+        ospfArea.setAreaId(Ip4Address.valueOf("10.226.165.164"));
+        ospfArea.setExternalRoutingCapability(true);
+        OspfInterfaceImpl ospfInterface = createOspfInterface();
+        ospfInterfaces.add(ospfInterface);
+        ospfArea.setOspfInterfaceList(ospfInterfaces);
+        RouterLsa routerLsa = new RouterLsa();
+        routerLsa.setLsType(1);
+        routerLsa.setLinkStateId("2.2.2.2");
+        routerLsa.setAdvertisingRouter(Ip4Address.valueOf("2.2.2.2"));
+        try {
+            ospfArea.addLsa(routerLsa, false, ospfInterface);
+        } catch (Exception e) {
+            System.out.println("ospfAreaImpl createOspfArea");
+        }
+        ospfArea.setRouterId(Ip4Address.valueOf("111.111.111.111"));
+
+        return ospfArea;
+    }
+
+    /**
+     * Utility for test method.
+     */
+    private OspfAreaAddressRangeImpl createOspfAreaAddressRange() {
+        OspfAreaAddressRangeImpl ospfAreaAddressRange = new OspfAreaAddressRangeImpl();
+        ospfAreaAddressRange.setIpAddress(Ip4Address.valueOf("10.226.165.164"));
+        ospfAreaAddressRange.setAdvertise(true);
+        ospfAreaAddressRange.setMask("mask");
+        return ospfAreaAddressRange;
+    }
+
 }
\ No newline at end of file
diff --git a/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/impl/ControllerTest.java b/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/impl/ControllerTest.java
index 8c700d0..f51b014 100755
--- a/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/impl/ControllerTest.java
+++ b/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/impl/ControllerTest.java
@@ -71,7 +71,7 @@
         ospfInterface.setIpAddress(Ip4Address.valueOf("1.1.1.1"));
         ospfInterfaces.add(ospfInterface);
         ospfArea.setAreaId(Ip4Address.valueOf("2.2.2.2"));
-        ospfArea.setInterfacesLst(ospfInterfaces);
+        ospfArea.setOspfInterfaceList(ospfInterfaces);
         ospfProcess.setProcessId("10.10.10.10");
         ospfAreas = new ArrayList();
         ospfAreas.add(ospfArea);
@@ -82,7 +82,7 @@
         ospfProcess1.setProcessId("11.11.11.11");
         ospfArea1 = new OspfAreaImpl();
         ospfArea1.setAreaId(Ip4Address.valueOf("2.2.2.2"));
-        ospfArea1.setInterfacesLst(ospfInterfaces);
+        ospfArea1.setOspfInterfaceList(ospfInterfaces);
         ospfAreas.add(ospfArea1);
         ospfProcess1.setAreas(ospfAreas);
         ospfProcesses.add(ospfProcess1);
@@ -167,83 +167,6 @@
         assertThat(controller, is(notNullValue()));
     }
 
-    /**
-     * Tests deleteInterfaceFromArea() method.
-     */
-    @Test
-    public void testDeleteInterfaceFromArea() throws Exception {
-        controller.updateConfig(ospfProcesses);
-        assertThat(controller.deleteInterfaceFromArea("10.10.10.10", "2.2.2.2", "1.1.1.1"), is(true));
-        assertThat(controller.deleteInterfaceFromArea("10.10.10.10", "2.2.2.2", "5.5.5.5"), is(false));
-    }
-
-    /**
-     * Tests checkArea() method.
-     */
-    @Test
-    public void testCheckArea() throws Exception {
-        controller.updateConfig(ospfProcesses);
-        assertThat(controller.checkArea("10.10.10.10", "2.2.2.2"), is(true));
-    }
-
-    /**
-     * Tests checkArea() method.
-     */
-    @Test
-    public void testCheckArea1() throws Exception {
-        controller.updateConfig(ospfProcesses);
-        assertThat(controller.checkArea("10.10.10.10", "111.111.111.111"), is(false));
-    }
-
-    /**
-     * Tests checkProcess() method.
-     */
-    @Test
-    public void testCheckProcess() throws Exception {
-        controller.updateConfig(ospfProcesses);
-        assertThat(controller.checkProcess("3.3.3.3"), is(false));
-        assertThat(controller.checkProcess("1.1.1.1"), is(false));
-    }
-
-    /**
-     * Tests checkInterface() method.
-     */
-    @Test
-    public void testCheckInterface() throws Exception {
-        controller.updateConfig(ospfProcesses);
-        assertThat(controller.checkInterface("10.10.10.10", "2.2.2.2", "1.1.1.1"), is(true));
-    }
-
-    /**
-     * Tests updateAreaInProcess() method.
-     */
-    @Test
-    public void testUpdateAreaInProcess() throws Exception {
-        controller.updateConfig(ospfProcesses);
-        controller.updateAreaInProcess("10.10.10.10", "2.2.2.2", ospfArea);
-        assertThat(controller, is(notNullValue()));
-    }
-
-    /**
-     * Tests updateConfig() method.
-     */
-    @Test
-    public void testUpdateConfig() throws Exception {
-        controller.updateConfig(ospfProcesses);
-        controller.updateConfig(ospfProcesses);
-        controller.updateConfig(ospfProcesses);
-        assertThat(controller, is(notNullValue()));
-    }
-
-    /**
-     * Tests updateConfig() method.
-     */
-    @Test
-    public void testUpdateConfig2() throws Exception {
-        controller.updateConfig(ospfProcesses);
-        controller.updateConfig(ospfProcesses);
-        assertThat(controller, is(notNullValue()));
-    }
 
     /**
      * Tests updateConfig() method.
@@ -257,7 +180,7 @@
         ospfInterface.setIpAddress(Ip4Address.valueOf("10.10.10.5"));
         ospfInterfaces.add(ospfInterface);
         ospfArea.setAreaId(Ip4Address.valueOf("2.2.2.2"));
-        ospfArea.setInterfacesLst(ospfInterfaces);
+        ospfArea.setOspfInterfaceList(ospfInterfaces);
         ospfProcess.setProcessId("10.10.10.10");
         ospfAreas = new ArrayList();
         ospfAreas.add(ospfArea);
@@ -269,67 +192,6 @@
     }
 
     /**
-     * Tests deleteConfig() method.
-     */
-    @Test(expected = Exception.class)
-    public void testDeleteConfig() throws Exception {
-        controller.updateConfig(ospfProcesses);
-        controller.deleteConfig(ospfProcesses, "INTERFACE");
-        assertThat(controller, is(notNullValue()));
-    }
-
-    /**
-     * Tests deleteConfig() method.
-     */
-    @Test(expected = Exception.class)
-    public void testDeleteConfig1() throws Exception {
-        controller.updateConfig(ospfProcesses);
-        controller.deleteConfig(ospfProcesses, "AREA");
-        assertThat(controller, is(notNullValue()));
-    }
-
-    /**
-     * Tests deleteConfig() method.
-     */
-
-    @Test
-    public void testDeleteConfig2() throws Exception {
-        controller.updateConfig(ospfProcesses);
-        controller.deleteConfig(ospfProcesses, "PROCESS");
-        assertThat(controller, is(notNullValue()));
-    }
-
-    /**
-     * Tests deleteConfig() method.
-     */
-    @Test
-    public void testDeleteConfig3() throws Exception {
-        ospfProcesses = new ArrayList();
-        controller.deleteConfig(ospfProcesses, "PROCESS");
-        assertThat(controller, is(notNullValue()));
-    }
-
-    /**
-     * Tests deleteConfig() method.
-     */
-    @Test
-    public void testDeleteConfig4() throws Exception {
-        controller.updateConfig(ospfProcesses);
-        controller.deleteConfig(ospfProcesses, "PROCESS");
-        controller.updateConfig(ospfProcesses);
-        assertThat(controller, is(notNullValue()));
-    }
-
-    /**
-     * Tests deleteProcessWhenExists() method.
-     */
-    @Test
-    public void testDeleteProcessWhenExists() throws Exception {
-        controller.updateConfig(ospfProcesses);
-        controller.deleteProcessWhenExists(ospfProcesses, "PROCESS");
-    }
-
-    /**
      * Tests addLinkDetails() method.
      */
     @Test
@@ -350,7 +212,7 @@
         controller.start(ospfAgent, driverService);
         ospfRouter = new OspfRouterImpl();
         controller.addLinkDetails(ospfRouter, new OspfLinkTedImpl());
-        controller.removeLinkDetails(ospfRouter);
+        controller.removeLinkDetails(ospfRouter, new OspfLinkTedImpl());
         assertThat(controller, is(notNullValue()));
     }
 }
\ No newline at end of file
diff --git a/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/impl/OspfConfigUtilTest.java b/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/impl/OspfConfigUtilTest.java
new file mode 100755
index 0000000..fd1c075
--- /dev/null
+++ b/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/impl/OspfConfigUtilTest.java
@@ -0,0 +1,82 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.ospf.controller.impl;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.onosproject.ospf.controller.OspfProcess;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.notNullValue;
+import static org.hamcrest.MatcherAssert.assertThat;
+
+/**
+ * Unit test class for OspfJsonParsingUtilTest.
+ */
+public class OspfConfigUtilTest {
+    private ObjectMapper mapper;
+    private JsonNode jsonNode;
+    private List<OspfProcess> ospfProcessList = new ArrayList<>();
+    private String jsonString = "{\n" +
+            "\t\"processes\": {\n" +
+            "\t\t\"areas\": [{\n" +
+            "\t\t\t\"interface\": [{\n" +
+            "\t\t\t\t\"interfaceIndex\": \"2\",\n" +
+            "\n" +
+            "\t\t\t\t\"helloIntervalTime\": \"10\",\n" +
+            "\n" +
+            "\t\t\t\t\"routerDeadIntervalTime\": \"40\",\n" +
+            "\n" +
+            "\t\t\t\t\"interfaceType\": \"2\",\n" +
+            "\n" +
+            "\t\t\t\t\"reTransmitInterval\": \"5\"\n" +
+            "\t\t\t}],\n" +
+            "\t\t\t\"areaId\": \"5.5.5.5\",\n" +
+            "\n" +
+            "\t\t\t\"routerId\": \"7.7.7.7\",\n" +
+            "\n" +
+            "\t\t\t\"isOpaqueEnable\": \"false\",\n" +
+            "\n" +
+            "\t\t\t\"externalRoutingCapability\": \"true\"\n" +
+            "\t\t}]\n" +
+            "\t}\n" +
+            "}";
+
+    @Before
+    public void setUp() throws Exception {
+        mapper = new ObjectMapper();
+        jsonNode = mapper.readTree(jsonString);
+        mapper = new ObjectMapper();
+    }
+
+    @After
+    public void tearDown() throws Exception {
+
+    }
+
+    @Test
+    public void testProcesses() throws Exception {
+        jsonNode.path("areas");
+        ospfProcessList = OspfConfigUtil.processes(jsonNode);
+        assertThat(ospfProcessList, is(notNullValue()));
+    }
+}
\ No newline at end of file
diff --git a/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/impl/OspfControllerImplTest.java b/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/impl/OspfControllerImplTest.java
index 7c9816b..7c7f265 100755
--- a/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/impl/OspfControllerImplTest.java
+++ b/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/impl/OspfControllerImplTest.java
@@ -46,10 +46,8 @@
     private OspfControllerImpl ospfController;
     private OspfRouterListener ospfRouterListener;
     private OspfLinkListener ospfLinkListener;
-    private Controller controller;
     private List<OspfProcess> ospfProcesses;
     private OspfProcess process1;
-    private OspfProcess process2;
     private List<OspfArea> areas;
     private OspfAreaImpl ospfArea;
     private List<OspfInterface> ospfInterfaces;
@@ -61,7 +59,6 @@
     @Before
     public void setUp() throws Exception {
         ospfController = new OspfControllerImpl();
-        controller = new Controller();
     }
 
     @After
@@ -69,7 +66,6 @@
         ospfController = null;
         ospfRouterListener = null;
         ospfLinkListener = null;
-        controller = null;
         ospfProcesses = null;
         areas = null;
         ospfArea = null;
@@ -140,38 +136,6 @@
     }
 
     /**
-     * Tests updateConfig() method.
-     */
-    @Test
-    public void testUpdateConfig() throws Exception {
-        ospfProcess = new OspfProcessImpl();
-        ospfArea = new OspfAreaImpl();
-        ospfInterface = new OspfInterfaceImpl();
-        ospfInterfaces = new ArrayList();
-        ospfInterface.setIpAddress(Ip4Address.valueOf("11.11.11.11"));
-        ospfInterfaces.add(ospfInterface);
-        ospfArea.setAreaId(Ip4Address.valueOf("2.2.2.2"));
-        ospfArea.setInterfacesLst(ospfInterfaces);
-        ospfProcess.setProcessId("10.10.10.10");
-        areas = new ArrayList();
-        areas.add(ospfArea);
-        ospfProcess.setAreas(areas);
-        ospfProcesses = new ArrayList();
-        ospfProcesses.add(ospfProcess);
-        process1 = new OspfProcessImpl();
-        process1.setProcessId("11.11.11.11");
-        ospfArea1 = new OspfAreaImpl();
-        ospfArea1.setAreaId(Ip4Address.valueOf("2.2.2.2"));
-        ospfArea1.setInterfacesLst(ospfInterfaces);
-        areas.add(ospfArea1);
-        process1.setAreas(areas);
-        ospfProcesses.add(process1);
-        ospfController.updateConfig(ospfProcesses);
-        assertThat(ospfController, is(notNullValue()));
-
-    }
-
-    /**
      * Tests deleteConfig() method.
      */
     @Test
@@ -183,7 +147,7 @@
         ospfInterface.setIpAddress(Ip4Address.valueOf("10.10.10.5"));
         ospfInterfaces.add(ospfInterface);
         ospfArea.setAreaId(Ip4Address.valueOf("2.2.2.2"));
-        ospfArea.setInterfacesLst(ospfInterfaces);
+        ospfArea.setOspfInterfaceList(ospfInterfaces);
         ospfProcess.setProcessId("10.10.10.10");
         areas = new ArrayList();
         areas.add(ospfArea);
@@ -194,7 +158,7 @@
         process1.setProcessId("11.11.11.11");
         ospfArea1 = new OspfAreaImpl();
         ospfArea1.setAreaId(Ip4Address.valueOf("2.2.2.2"));
-        ospfArea1.setInterfacesLst(ospfInterfaces);
+        ospfArea1.setOspfInterfaceList(ospfInterfaces);
         areas.add(ospfArea1);
         process1.setAreas(areas);
         ospfProcesses.add(process1);
@@ -221,7 +185,7 @@
         ospfRouter = new OspfRouterImpl();
 
         ospfController.agent.addLink(ospfRouter, new OspfLinkTedImpl());
-        ospfController.agent.deleteLink(ospfRouter);
+        ospfController.agent.deleteLink(ospfRouter, new OspfLinkTedImpl());
         assertThat(ospfController, is(notNullValue()));
     }
 
diff --git a/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/impl/OspfDeviceTedImplTest.java b/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/impl/OspfDeviceTedImplTest.java
index e65ca9d..b11f537 100755
--- a/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/impl/OspfDeviceTedImplTest.java
+++ b/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/impl/OspfDeviceTedImplTest.java
@@ -21,6 +21,7 @@
 import org.onlab.packet.Ip4Address;
 import org.onlab.packet.Ip6Address;
 
+import java.net.InetAddress;
 import java.util.ArrayList;
 import java.util.List;
 
@@ -31,8 +32,6 @@
  * Unit test class for OspfDeviceTedImpl.
  */
 public class OspfDeviceTedImplTest {
-    private static final Ip6Address LOCAL_ADDRESS = Ip6Address.valueOf("::1");
-
     private OspfDeviceTedImpl ospfDeviceTed;
 
     @Before
@@ -128,10 +127,10 @@
     /**
      * Tests ipv6RouterIds() getter method.
      */
-    @Test
+    @Test(expected = Exception.class)
     public void testIpv6RouterIds() throws Exception {
         List list = new ArrayList();
-        list.add(LOCAL_ADDRESS);
+        list.add(Ip6Address.valueOf(InetAddress.getLocalHost()));
         ospfDeviceTed.setIpv6RouterIds(list);
         assertThat(ospfDeviceTed.ipv6RouterIds().size(), is(1));
     }
@@ -139,11 +138,11 @@
     /**
      * Tests ipv6RouterIds() setter method.
      */
-    @Test
+    @Test(expected = Exception.class)
     public void testSetIpv6RouterIds() throws Exception {
         List list = new ArrayList();
-        list.add(LOCAL_ADDRESS);
+        list.add(Ip6Address.valueOf(InetAddress.getLocalHost()));
         ospfDeviceTed.setIpv6RouterIds(list);
         assertThat(ospfDeviceTed.ipv6RouterIds().size(), is(1));
     }
-}
+}
\ No newline at end of file
diff --git a/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/impl/OspfInterfaceChannelHandlerTest.java b/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/impl/OspfInterfaceChannelHandlerTest.java
index 51a949e..2ad4bd2 100755
--- a/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/impl/OspfInterfaceChannelHandlerTest.java
+++ b/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/impl/OspfInterfaceChannelHandlerTest.java
@@ -18,9 +18,7 @@
 import org.easymock.EasyMock;
 import org.jboss.netty.buffer.ChannelBuffer;
 import org.jboss.netty.buffer.ChannelBuffers;
-import org.jboss.netty.buffer.HeapChannelBufferFactory;
 import org.jboss.netty.channel.Channel;
-import org.jboss.netty.channel.ChannelConfig;
 import org.jboss.netty.channel.ChannelFuture;
 import org.jboss.netty.channel.ChannelHandlerContext;
 import org.jboss.netty.channel.ChannelStateEvent;
@@ -30,34 +28,27 @@
 import org.junit.Before;
 import org.junit.Test;
 import org.onlab.packet.Ip4Address;
+import org.onosproject.ospf.controller.OspfArea;
 import org.onosproject.ospf.controller.OspfAreaAddressRange;
 import org.onosproject.ospf.controller.OspfInterface;
-import org.onosproject.ospf.controller.OspfNbr;
+import org.onosproject.ospf.controller.OspfLsaType;
 import org.onosproject.ospf.controller.OspfNeighborState;
+import org.onosproject.ospf.controller.OspfProcess;
 import org.onosproject.ospf.controller.TopologyForDeviceAndLink;
 import org.onosproject.ospf.controller.area.OspfAreaAddressRangeImpl;
 import org.onosproject.ospf.controller.area.OspfAreaImpl;
 import org.onosproject.ospf.controller.area.OspfInterfaceImpl;
-import org.onosproject.ospf.controller.util.OspfEligibleRouter;
+import org.onosproject.ospf.controller.area.OspfProcessImpl;
 import org.onosproject.ospf.exceptions.OspfParseException;
 import org.onosproject.ospf.protocol.lsa.LsaHeader;
-import org.onosproject.ospf.protocol.lsa.TlvHeader;
-import org.onosproject.ospf.protocol.lsa.tlvtypes.RouterTlv;
 import org.onosproject.ospf.protocol.lsa.types.RouterLsa;
-import org.onosproject.ospf.protocol.ospfpacket.OspfMessage;
-import org.onosproject.ospf.protocol.ospfpacket.subtype.LsRequestPacket;
 import org.onosproject.ospf.protocol.ospfpacket.types.DdPacket;
 import org.onosproject.ospf.protocol.ospfpacket.types.HelloPacket;
-import org.onosproject.ospf.protocol.ospfpacket.types.LsAcknowledge;
-import org.onosproject.ospf.protocol.ospfpacket.types.LsRequest;
-import org.onosproject.ospf.protocol.ospfpacket.types.LsUpdate;
 import org.onosproject.ospf.protocol.util.ChecksumCalculator;
-import org.onosproject.ospf.protocol.util.OspfInterfaceState;
 
 import java.net.SocketAddress;
 import java.net.UnknownHostException;
 import java.util.ArrayList;
-import java.util.HashMap;
 import java.util.List;
 
 import static org.hamcrest.CoreMatchers.is;
@@ -69,179 +60,59 @@
  * Unit test class for OspfInterfaceChannelHandler.
  */
 public class OspfInterfaceChannelHandlerTest {
-
-    private List<OspfAreaAddressRange> addressRanges;
-    private List<OspfInterface> ospfInterfaces;
+    private final String string1 = "2.2.2.2";
+    private List<OspfAreaAddressRange> addressRanges = new ArrayList();
+    private List<OspfInterface> ospfInterfaces = new ArrayList<>();
     private Controller controller;
     private OspfAreaImpl ospfArea;
     private OspfInterfaceImpl ospfInterface;
     private OspfInterfaceChannelHandler ospfInterfaceChannelHandler;
-    private HashMap<String, OspfNbr> ospfNbrHashMap;
     private OspfNbrImpl ospfNbr;
-    private Channel channel;
     private ChannelHandlerContext channelHandlerContext;
     private ChannelStateEvent channelStateEvent;
-    private HelloPacket helloPacket;
-    private DdPacket ddPacket;
-    private ChecksumCalculator checksumCalculator;
+    private TopologyForDeviceAndLink topologyForDeviceAndLink;
+    private List<OspfProcess> ospfProcesses = new ArrayList<>();
+    private OspfProcess ospfProcess;
+    private Ip4Address ip4Address1 = Ip4Address.valueOf("10.10.10.10");
+    private Ip4Address ip4Address2 = Ip4Address.valueOf("2.2.2.2");
+    private Ip4Address ip4Address3 = Ip4Address.valueOf("13.13.13.13");
+    private Ip4Address ip4Address4 = Ip4Address.valueOf("111.111.111.111");
+    private Ip4Address ip4Address5 = Ip4Address.valueOf("10.226.165.164");
+    private Ip4Address ip4Address6 = Ip4Address.valueOf("1.1.1.1");
+    private Ip4Address ip4Address7 = Ip4Address.valueOf("10.226.165.100");
+    private Ip4Address subnetAddress = Ip4Address.valueOf("255.255.255.255");
     private byte[] byteArray;
     private byte[] checkArray;
+    private HelloPacket helloPacket;
+    private ChecksumCalculator checksumCalculator;
     private ChannelBuffer buf;
-    private OspfEligibleRouter ospfEligibleRouter;
-    private LsUpdate lsUpdate;
-    private LsAcknowledge lsAck;
-    private LsRequest lsRequest;
-    private TopologyForDeviceAndLink topologyForDeviceAndLink;
+    private List<OspfArea> ospfAreas = new ArrayList<>();
 
     @Before
     public void setUp() throws Exception {
-        addressRanges = new ArrayList();
-        ospfInterfaces = new ArrayList<>();
+        ospfProcess = new OspfProcessImpl();
         ospfArea = createOspfArea();
-        ospfInterface = createOspfInterface();
-        ospfNbrHashMap = new HashMap();
-        topologyForDeviceAndLink = new TopologyForDeviceAndLinkImpl();
-        ospfNbr = new OspfNbrImpl(ospfArea, ospfInterface, Ip4Address.valueOf("10.10.10.10"),
-                                  Ip4Address.valueOf("2.2.2.2"), 2,
-                                  new OspfInterfaceChannelHandler(new Controller(), ospfArea,
-                                                                  ospfInterface),
-                                  topologyForDeviceAndLink);
-        ospfNbr.setNeighborId(Ip4Address.valueOf("10.10.10.10"));
-        ospfNbr.setRouterPriority(0);
-        ospfNbr.setNeighborDr(Ip4Address.valueOf("13.13.13.13"));
-        ospfInterface.addNeighbouringRouter(ospfNbr);
+        ospfAreas.add(ospfArea);
+        ospfProcess.setAreas(ospfAreas);
+        ospfProcesses.add(ospfProcess);
         controller = new Controller();
-        ospfInterfaceChannelHandler = new OspfInterfaceChannelHandler();
-        ospfInterfaceChannelHandler = new OspfInterfaceChannelHandler(controller, ospfArea,
-                                                                      ospfInterface);
+        topologyForDeviceAndLink = new TopologyForDeviceAndLinkImpl();
+        ospfNbr = new OspfNbrImpl(ospfArea, ospfInterface, ip4Address1,
+                                  ip4Address2, 2, topologyForDeviceAndLink);
+        ospfNbr.setNeighborId(ip4Address1);
+        ospfNbr.setRouterPriority(0);
+        ospfNbr.setNeighborDr(ip4Address3);
+        ospfInterface.addNeighbouringRouter(ospfNbr);
+        ospfInterfaceChannelHandler = new OspfInterfaceChannelHandler(controller, ospfProcesses);
     }
 
     @After
     public void tearDown() throws Exception {
         ospfInterfaceChannelHandler = null;
-        addressRanges = null;
-        ospfInterfaces = null;
-        controller = null;
-        ospfArea = null;
         ospfInterfaceChannelHandler = null;
         ospfInterface = null;
-        ospfNbrHashMap = null;
-        channel = null;
         channelHandlerContext = null;
         channelStateEvent = null;
-        helloPacket = null;
-        ddPacket = null;
-        checksumCalculator = null;
-        byteArray = null;
-        checkArray = null;
-        ospfEligibleRouter = null;
-        lsUpdate = null;
-        lsAck = null;
-        lsRequest = null;
-    }
-
-    /**
-     * Tests interfaceUp() method.
-     */
-    @Test
-    public void testInterfaceUp() throws Exception {
-        ospfInterface.setInterfaceType(2);
-        ospfInterface.setRouterPriority(0);
-        ospfInterfaceChannelHandler.interfaceUp();
-        assertThat(ospfInterfaceChannelHandler, is(notNullValue()));
-    }
-
-    /**
-     * Tests interfaceUp() method.
-     */
-    @Test
-    public void testInterfaceUp1() throws Exception {
-
-        ospfInterface.setInterfaceType(2);
-        ospfInterface.setRouterPriority(0);
-        ospfInterfaceChannelHandler.interfaceUp();
-        assertThat(ospfInterfaceChannelHandler, is(notNullValue()));
-    }
-
-    /**
-     * Tests interfaceUp() method.
-     */
-    @Test
-    public void testInterfaceUp2() throws Exception {
-        ospfInterface.setInterfaceType(1);
-        ospfInterface.setRouterPriority(1);
-        ospfInterfaceChannelHandler.interfaceUp();
-        assertThat(ospfInterfaceChannelHandler, is(notNullValue()));
-    }
-
-    /**
-     * Tests interfaceUp() method.
-     */
-    @Test
-    public void testInterfaceUp3() throws Exception {
-        ospfInterface.setInterfaceType(2);
-        ospfInterface.setRouterPriority(1);
-        ospfInterfaceChannelHandler.interfaceUp();
-        assertThat(ospfInterfaceChannelHandler, is(notNullValue()));
-    }
-
-    /**
-     * Tests backupSeen() method.
-     */
-    @Test
-    public void testBackupSeen() throws Exception {
-        channel = EasyMock.createMock(Channel.class);
-        ospfInterface.setState(OspfInterfaceState.WAITING);
-        ospfInterfaceChannelHandler.backupSeen(channel);
-        assertThat(ospfInterface.dr(), is(notNullValue()));
-    }
-
-    /**
-     * Tests waitTimer() method.
-     */
-    @Test
-    public void testWaitTimer() throws Exception {
-        channel = EasyMock.createMock(Channel.class);
-        ospfInterface.setState(OspfInterfaceState.WAITING);
-        ospfInterface.setIpAddress(Ip4Address.valueOf("10.10.10.10"));
-        ospfInterface.setIpNetworkMask(Ip4Address.valueOf("255.255.255.255"));
-        ospfInterfaceChannelHandler.waitTimer(channel);
-        assertThat(ospfInterface.dr(), is(notNullValue()));
-    }
-
-    /**
-     * Tests neighborChange() method.
-     */
-    @Test
-    public void testNeighborChange() throws Exception {
-        ospfNbrHashMap = new HashMap();
-        ospfNbr = new OspfNbrImpl(new OspfAreaImpl(), new OspfInterfaceImpl(),
-                                  Ip4Address.valueOf("1.1.1.1"), Ip4Address.valueOf("2.2.2.2"), 2,
-                                  new OspfInterfaceChannelHandler(new Controller(),
-                                                                  new OspfAreaImpl(),
-                                                                  new OspfInterfaceImpl()),
-                                  topologyForDeviceAndLink);
-        ospfNbr.setNeighborId(Ip4Address.valueOf("111.111.111.111"));
-        ospfNbrHashMap.put("111.111.111.111", ospfNbr);
-        ospfNbr.setState(OspfNeighborState.EXCHANGE);
-        ospfInterface.setListOfNeighbors(ospfNbrHashMap);
-        ospfInterface.setIpAddress(Ip4Address.valueOf("10.10.10.10"));
-        ospfInterface.setIpNetworkMask(Ip4Address.valueOf("255.255.255.255"));
-        ospfInterface.setIpAddress(Ip4Address.valueOf("10.10.10.10"));
-        ospfInterface.setIpNetworkMask(Ip4Address.valueOf("255.255.255.255"));
-        channel = EasyMock.createMock(Channel.class);
-        ospfInterface.setState(OspfInterfaceState.DR);
-        ospfInterfaceChannelHandler.waitTimer(channel);
-        assertThat(ospfInterface.dr(), is(Ip4Address.valueOf("0.0.0.0")));
-    }
-
-    /**
-     * Tests interfaceDown() method.
-     */
-    @Test(expected = Exception.class)
-    public void testInterfaceDown() throws Exception {
-        ospfInterfaceChannelHandler.interfaceDown();
-        assertThat(ospfInterface.state(), is(OspfInterfaceState.DOWN));
     }
 
     /**
@@ -252,7 +123,6 @@
         channelHandlerContext = EasyMock.createMock(ChannelHandlerContext.class);
         channelStateEvent = EasyMock.createMock(ChannelStateEvent.class);
         ospfInterfaceChannelHandler.channelConnected(channelHandlerContext, channelStateEvent);
-        assertThat(ospfInterface.state(), is(notNullValue()));
     }
 
     /**
@@ -269,14 +139,64 @@
     /**
      * Tests channelDisconnected() method.
      */
-    @Test(expected = Exception.class)
+    @Test
     public void testChannelDisconnected() throws Exception {
         channelHandlerContext = EasyMock.createMock(ChannelHandlerContext.class);
         channelStateEvent = EasyMock.createMock(ChannelStateEvent.class);
-
         ospfInterfaceChannelHandler.channelDisconnected(channelHandlerContext, channelStateEvent);
+        assertThat(ospfInterfaceChannelHandler, is(notNullValue()));
+    }
 
-        assertThat(ospfInterface.state(), is(notNullValue()));
+    /**
+     * Tests initializeInterfaceMap() method.
+     */
+    @Test
+    public void testInitializeInterfaceMap() throws Exception {
+        ospfInterfaceChannelHandler.initializeInterfaceMap();
+        assertThat(ospfInterfaceChannelHandler, is(notNullValue()));
+    }
+
+    /**
+     * Tests updateInterfaceMap() method.
+     */
+    @Test
+    public void testUpdateInterfaceMap() throws Exception {
+        ospfInterfaceChannelHandler.updateInterfaceMap(ospfProcesses);
+        assertThat(ospfInterfaceChannelHandler, is(notNullValue()));
+    }
+
+    /**
+     * Utility for test method.
+     */
+    private OspfAreaImpl createOspfArea() throws Exception {
+        OspfAreaAddressRangeImpl ospfAreaAddressRange;
+        ospfAreaAddressRange = createOspfAreaAddressRange();
+        addressRanges.add(ospfAreaAddressRange);
+        OspfAreaImpl ospfArea = new OspfAreaImpl();
+        ospfArea.setAreaId(ip4Address5);
+        ospfArea.setExternalRoutingCapability(true);
+        OspfInterfaceImpl ospfInterface = createOspfInterface();
+        ospfInterfaces.add(ospfInterface);
+        ospfArea.setOspfInterfaceList(ospfInterfaces);
+        RouterLsa routerLsa = new RouterLsa();
+        routerLsa.setLsType(1);
+        routerLsa.setLinkStateId(string1);
+        routerLsa.setAdvertisingRouter(ip4Address2);
+        ospfArea.addLsa(routerLsa, false, ospfInterface);
+        ospfArea.setRouterId(ip4Address4);
+
+        return ospfArea;
+    }
+
+    /**
+     * Utility for test method.
+     */
+    private OspfAreaAddressRangeImpl createOspfAreaAddressRange() {
+        OspfAreaAddressRangeImpl ospfAreaAddressRange = new OspfAreaAddressRangeImpl();
+        ospfAreaAddressRange.setIpAddress(ip4Address5);
+        ospfAreaAddressRange.setAdvertise(true);
+        ospfAreaAddressRange.setMask("mask");
+        return ospfAreaAddressRange;
     }
 
     /**
@@ -333,701 +253,63 @@
     }
 
     /**
-     * Tests processOspfMessage() method.
+     * Utility for test method.
      */
-    @Test
-    public void testProcessOspfMessage() throws Exception {
-        ospfInterface.setIpAddress(Ip4Address.valueOf("11.11.11.11"));
-        ospfInterface.setIpNetworkMask(Ip4Address.valueOf("225.225.225.225"));
+    private OspfInterfaceImpl createOspfInterface1() throws UnknownHostException {
+        ospfInterface = new OspfInterfaceImpl();
+        OspfAreaImpl ospfArea = new OspfAreaImpl();
+        OspfInterfaceChannelHandler ospfInterfaceChannelHandler = EasyMock.createMock(
+                OspfInterfaceChannelHandler.class);
+        ospfNbr = new OspfNbrImpl(ospfArea, ospfInterface, ip4Address5,
+                                  ip4Address6, 2, topologyForDeviceAndLink);
+        ospfNbr.setState(OspfNeighborState.FULL);
+        ospfNbr.setNeighborId(ip4Address7);
+        ospfInterface = new OspfInterfaceImpl();
+        ospfInterface.setIpAddress(ip4Address5);
+        ospfInterface.setIpNetworkMask(subnetAddress);
+        ospfInterface.setBdr(ip4Address4);
+        ospfInterface.setDr(ip4Address4);
+        ospfInterface.setHelloIntervalTime(20);
         ospfInterface.setInterfaceType(2);
-        ospfArea.setAreaId(Ip4Address.valueOf("12.12.12.12"));
-        channelHandlerContext = EasyMock.createMock(ChannelHandlerContext.class);
-        OspfMessage message;
-        helloPacket = new HelloPacket();
-        helloPacket.setSourceIp(Ip4Address.valueOf("1.1.1.1"));
-        helloPacket.setRouterId(Ip4Address.valueOf("10.10.10.10"));
-        helloPacket.setOspfVer(2);
-        helloPacket.setAreaId(Ip4Address.valueOf("12.12.12.12"));
-        helloPacket.setOptions(2);
-        helloPacket.setNetworkMask(Ip4Address.valueOf("3.3.3.3"));
-        helloPacket.setOspftype(1);
-        helloPacket.setAuthType(0);
-        helloPacket.setHelloInterval(60);
-        helloPacket.setRouterDeadInterval(60);
-        helloPacket.setAuthentication(0);
-        checksumCalculator = new ChecksumCalculator();
-        byteArray = helloPacket.asBytes();
-        helloPacket.setOspfPacLength(byteArray.length);
-        checkArray = checksumCalculator.calculateOspfCheckSum(byteArray, 12, 13);
-        checkArray[0] = -53;
-        checkArray[1] = 37;
-        buf = ChannelBuffers.copiedBuffer(checkArray);
-        helloPacket.setChecksum(buf.readUnsignedShort());
-        message = helloPacket;
-        ospfInterfaceChannelHandler.processOspfMessage(message, channelHandlerContext);
-        ddPacket = new DdPacket();
-        ddPacket.setSourceIp(Ip4Address.valueOf("1.1.1.1"));
-        ddPacket.setRouterId(Ip4Address.valueOf("10.10.10.10"));
-        ddPacket.setOspfVer(2);
-        ddPacket.setAreaId(Ip4Address.valueOf("12.12.12.12"));
-        ddPacket.setOptions(2);
-        ddPacket.setOspftype(2);
-        ddPacket.setAuthType(0);
-        ddPacket.setAuthentication(0);
-        checksumCalculator = new ChecksumCalculator();
-        byteArray = ddPacket.asBytes();
-        ddPacket.setOspfPacLength(byteArray.length);
-        checkArray = checksumCalculator.calculateOspfCheckSum(byteArray, 12, 13);
-        checkArray[0] = -49;
-        checkArray[1] = -79;
-        buf = ChannelBuffers.copiedBuffer(checkArray);
-        ddPacket.setChecksum(buf.readUnsignedShort());
-        message = ddPacket;
-        ospfInterfaceChannelHandler.processOspfMessage(message, channelHandlerContext);
-        lsRequest = new LsRequest();
-        lsRequest.setSourceIp(Ip4Address.valueOf("1.1.1.1"));
-        lsRequest.setRouterId(Ip4Address.valueOf("10.10.10.10"));
-        lsRequest.setOspfVer(2);
-        lsRequest.setAreaId(Ip4Address.valueOf("12.12.12.12"));
-        lsRequest.setOspftype(3);
-        lsRequest.setAuthType(0);
-        lsRequest.setAuthentication(0);
-        checksumCalculator = new ChecksumCalculator();
-        byteArray = lsRequest.asBytes();
-        lsRequest.setOspfPacLength(byteArray.length);
-        checkArray = checksumCalculator.calculateOspfCheckSum(byteArray, 12, 13);
-        checkArray[0] = -33;
-        checkArray[1] = -58;
-        buf = ChannelBuffers.copiedBuffer(checkArray);
-        lsRequest.setChecksum(buf.readUnsignedShort());
-        message = lsRequest;
-        ospfInterfaceChannelHandler.processOspfMessage(message, channelHandlerContext);
-        lsUpdate = new LsUpdate();
-        lsUpdate.setSourceIp(Ip4Address.valueOf("1.1.1.1"));
-        lsUpdate.setRouterId(Ip4Address.valueOf("10.10.10.10"));
-        lsUpdate.setOspfVer(2);
-        lsUpdate.setAreaId(Ip4Address.valueOf("12.12.12.12"));
-        lsUpdate.setOspftype(4);
-        lsUpdate.setAuthType(0);
-        lsUpdate.setAuthentication(0);
-        checksumCalculator = new ChecksumCalculator();
-        byteArray = lsUpdate.asBytes();
-        lsUpdate.setOspfPacLength(byteArray.length);
-        checkArray = checksumCalculator.calculateOspfCheckSum(byteArray, 12, 13);
-        checkArray[0] = -47;
-        checkArray[1] = -77;
-        buf = ChannelBuffers.copiedBuffer(checkArray);
-        lsUpdate.setChecksum(buf.readUnsignedShort());
-        message = lsUpdate;
-        ospfInterfaceChannelHandler.processOspfMessage(message, channelHandlerContext);
-        lsAck = new LsAcknowledge();
-        lsAck.setSourceIp(Ip4Address.valueOf("1.1.1.1"));
-        lsAck.setRouterId(Ip4Address.valueOf("10.10.10.10"));
-        lsAck.setOspfVer(2);
-        lsAck.setAreaId(Ip4Address.valueOf("12.12.12.12"));
-        lsAck.setOspftype(5);
-        lsAck.setAuthType(0);
-        lsAck.setAuthentication(0);
-        checksumCalculator = new ChecksumCalculator();
-        byteArray = lsAck.asBytes();
-        lsAck.setOspfPacLength(byteArray.length);
-        checkArray = checksumCalculator.calculateOspfCheckSum(byteArray, 12, 13);
-        checkArray[0] = -47;
-        checkArray[1] = -74;
-        buf = ChannelBuffers.copiedBuffer(checkArray);
-        lsAck.setChecksum(buf.readUnsignedShort());
-        message = lsAck;
-        ospfInterfaceChannelHandler.processOspfMessage(message, channelHandlerContext);
-        assertThat(ospfInterfaceChannelHandler, is(notNullValue()));
-
-    }
-
-    /**
-     * Tests processHelloMessage() method.
-     */
-    @Test
-    public void testProcessHelloMessage() throws Exception {
-        ospfInterface.setIpAddress(Ip4Address.valueOf("11.11.11.11"));
-        ospfInterface.setInterfaceType(1);
-        ospfInterface.setIpNetworkMask(Ip4Address.valueOf("244.244.244.244"));
-        ospfInterface.setHelloIntervalTime(10);
-        ospfInterface.setRouterDeadIntervalTime(10);
-        ospfArea.setAreaId(Ip4Address.valueOf("12.12.12.12"));
-        channelHandlerContext = EasyMock.createMock(ChannelHandlerContext.class);
-        OspfMessage message;
-        helloPacket = new HelloPacket();
-        helloPacket.setSourceIp(Ip4Address.valueOf("1.1.1.1"));
-        helloPacket.setOspfVer(2);
-        helloPacket.setAreaId(Ip4Address.valueOf("12.12.12.12"));
-        helloPacket.setNetworkMask(Ip4Address.valueOf("244.244.244.244"));
-        helloPacket.setHelloInterval(10);
-        helloPacket.setRouterDeadInterval(10);
-        helloPacket.setDr(Ip4Address.valueOf("10.10.10.10"));
-        helloPacket.setBdr(Ip4Address.valueOf("11.11.11.11"));
-        helloPacket.setRouterId(Ip4Address.valueOf("111.111.111.111"));
-        message = helloPacket;
-        ospfInterfaceChannelHandler.processHelloMessage(message, channelHandlerContext);
-        assertThat(ospfInterfaceChannelHandler, is(notNullValue()));
-    }
-
-    /**
-     * Tests processHelloMessage() method.
-     */
-    @Test
-    public void testProcessHelloMessage1() throws Exception {
-        ospfInterface.setInterfaceType(2);
+        ospfInterface.setReTransmitInterval(2000);
+        ospfInterface.setMtu(6500);
+        ospfInterface.setRouterDeadIntervalTime(1000);
         ospfInterface.setRouterPriority(1);
-        ospfInterfaceChannelHandler.interfaceUp();
-        ospfInterface.setIpAddress(Ip4Address.valueOf("11.11.11.11"));
-        ospfInterface.setState(OspfInterfaceState.WAITING);
-        ospfInterface.setInterfaceType(2);
-        ospfInterface.setIpNetworkMask(Ip4Address.valueOf("244.244.244.244"));
-        ospfInterface.setHelloIntervalTime(10);
-        ospfInterface.setRouterDeadIntervalTime(10);
-        ospfArea.setAreaId(Ip4Address.valueOf("12.12.12.12"));
-        channelHandlerContext = EasyMock.createMock(ChannelHandlerContext.class);
-        OspfMessage message;
-        helloPacket = new HelloPacket();
-        helloPacket.setSourceIp(Ip4Address.valueOf("1.1.1.1"));
-        helloPacket.setOspfVer(2);
-        helloPacket.setAreaId(Ip4Address.valueOf("12.12.12.12"));
-        helloPacket.setNetworkMask(Ip4Address.valueOf("244.244.244.244"));
-        helloPacket.setHelloInterval(10);
-        helloPacket.setRouterDeadInterval(10);
-        helloPacket.setDr(Ip4Address.valueOf("10.10.10.10"));
-        helloPacket.setBdr(Ip4Address.valueOf("11.11.11.11"));
-        helloPacket.setRouterId(Ip4Address.valueOf("2.2.2.2"));
-        message = helloPacket;
-        ospfInterfaceChannelHandler.processHelloMessage(message, channelHandlerContext);
-        assertThat(ospfInterfaceChannelHandler, is(notNullValue()));
-        ospfNbrHashMap = new HashMap();
-        ospfNbr = new OspfNbrImpl(ospfArea, ospfInterface, Ip4Address.valueOf("10.10.10.10"),
-                                  Ip4Address.valueOf("2.2.2.2"), 2,
-                                  new OspfInterfaceChannelHandler(new Controller(), ospfArea,
-                                                                  ospfInterface),
-                                  topologyForDeviceAndLink);
-        ospfNbr.setNeighborId(Ip4Address.valueOf("2.2.2.2"));
-        ospfNbr.setRouterPriority(0);
-        ospfNbr.setNeighborDr(Ip4Address.valueOf("13.13.13.13"));
+        ospfInterface.setInterfaceType(1);
         ospfInterface.addNeighbouringRouter(ospfNbr);
-        ospfInterfaceChannelHandler.processHelloMessage(message, channelHandlerContext);
-        assertThat(ospfInterfaceChannelHandler, is(notNullValue()));
+        return ospfInterface;
     }
 
     /**
-     * Tests processDdMessage() method.
+     * Utility for test method.
      */
-    @Test
-    public void testProcessDdMessage() throws Exception {
-        ospfInterface.setIpAddress(Ip4Address.valueOf("11.11.11.11"));
-        ospfInterface.setInterfaceType(2);
-        ospfInterface.setIpNetworkMask(Ip4Address.valueOf("255.255.255.255"));
-        ospfInterface.setHelloIntervalTime(10);
-        ospfInterface.setRouterDeadIntervalTime(10);
-        ospfArea.setAreaId(Ip4Address.valueOf("12.12.12.12"));
-        channelHandlerContext = EasyMock.createMock(ChannelHandlerContext.class);
-        OspfMessage message;
-        ddPacket = new DdPacket();
-        ddPacket.setSourceIp(Ip4Address.valueOf("1.1.1.1"));
-        ddPacket.setOspfVer(2);
-        ddPacket.setAreaId(Ip4Address.valueOf("12.12.12.12"));
-        ddPacket.setRouterId(Ip4Address.valueOf("2.2.2.2"));
-        ddPacket.setIsOpaqueCapable(true);
-        ddPacket.setIsMore(1);
-        ddPacket.setIsInitialize(1);
-        ddPacket.setIsMaster(1);
-        ddPacket.setSequenceNo(123);
-        message = ddPacket;
-        ospfNbrHashMap = new HashMap();
-        ospfNbr = new OspfNbrImpl(ospfArea, ospfInterface, Ip4Address.valueOf("10.10.10.10"),
-                                  Ip4Address.valueOf("2.2.2.2"), 2,
-                                  new OspfInterfaceChannelHandler(new Controller(), ospfArea,
-                                                                  ospfInterface),
-                                  topologyForDeviceAndLink);
-        ospfNbr.setLastDdPacket(createDdPacket());
-        ospfNbr.setNeighborId(Ip4Address.valueOf("2.2.2.2"));
-        ospfNbr.setState(OspfNeighborState.EXSTART);
-        ospfNbr.setRouterPriority(0);
-        ospfNbr.setNeighborDr(Ip4Address.valueOf("13.13.13.13"));
-        ospfNbr.setDdSeqNum(123);
-        ospfInterface.addNeighbouringRouter(ospfNbr);
-        ospfInterfaceChannelHandler.processDdMessage(message, channelHandlerContext);
-        assertThat(ospfInterfaceChannelHandler, is(notNullValue()));
-    }
-
-    /**
-     * Tests processDdMessage() method.
-     */
-    @Test(expected = Exception.class)
-    public void testProcessDdMessage3() throws Exception {
-        ospfInterface.setIpAddress(Ip4Address.valueOf("11.11.11.11"));
-        ospfInterface.setInterfaceType(2);
-        ospfInterface.setIpNetworkMask(Ip4Address.valueOf("255.255.255.255"));
-        ospfInterface.setHelloIntervalTime(10);
-        ospfInterface.setRouterDeadIntervalTime(10);
-        ospfArea.setAreaId(Ip4Address.valueOf("12.12.12.12"));
-        channelHandlerContext = EasyMock.createMock(ChannelHandlerContext.class);
-        OspfMessage message;
-        ddPacket = new DdPacket();
-        ddPacket.setSourceIp(Ip4Address.valueOf("1.1.1.1"));
-        ddPacket.setOspfVer(2);
-        ddPacket.setAreaId(Ip4Address.valueOf("12.12.12.12"));
-        ddPacket.setRouterId(Ip4Address.valueOf("2.2.2.2"));
-        ddPacket.setIsOpaqueCapable(true);
-        ddPacket.setIsMore(1);
-        ddPacket.setIsInitialize(1);
-        ddPacket.setIsMaster(1);
-        ddPacket.setSequenceNo(123);
-        message = ddPacket;
-        ospfNbrHashMap = new HashMap();
-        ospfNbr = new OspfNbrImpl(ospfArea, ospfInterface, Ip4Address.valueOf("10.10.10.10"),
-                                  Ip4Address.valueOf("2.2.2.2"), 2,
-                                  new OspfInterfaceChannelHandler(new Controller(), ospfArea,
-                                                                  ospfInterface),
-                                  topologyForDeviceAndLink);
-        ospfNbr.setLastDdPacket(createDdPacket());
-        ospfNbr.setNeighborId(Ip4Address.valueOf("2.2.2.2"));
-        ospfNbr.setState(OspfNeighborState.EXSTART);
-        ospfNbr.setRouterPriority(0);
-        ospfNbr.setNeighborDr(Ip4Address.valueOf("13.13.13.13"));
-        ospfNbr.setDdSeqNum(123);
-        ospfInterface.addNeighbouringRouter(ospfNbr);
-        ddPacket.setIsMore(1);
-        ddPacket.setIsInitialize(0);
-        ddPacket.setIsMaster(0);
-        ddPacket.setSequenceNo(123);
-        ospfInterface.addNeighbouringRouter(ospfNbr);
-        ospfInterfaceChannelHandler.processDdMessage(message, channelHandlerContext);
-        assertThat(ospfInterfaceChannelHandler, is(notNullValue()));
-    }
-
-    /**
-     * Tests processDdMessage() method.
-     */
-    @Test(expected = Exception.class)
-    public void testProcessDdMessage1() throws Exception {
-        ospfInterface.setIpAddress(Ip4Address.valueOf("11.11.11.11"));
-        ospfInterface.setInterfaceType(2);
-        ospfInterface.setIpNetworkMask(Ip4Address.valueOf("255.255.255.255"));
-        ospfInterface.setHelloIntervalTime(10);
-        ospfInterface.setRouterDeadIntervalTime(10);
-        ospfArea.setAreaId(Ip4Address.valueOf("12.12.12.12"));
-        channelHandlerContext = EasyMock.createMock(ChannelHandlerContext.class);
-        OspfMessage message;
-        ddPacket = new DdPacket();
-        ddPacket.setSourceIp(Ip4Address.valueOf("1.1.1.1"));
-        ddPacket.setOspfVer(2);
-        ddPacket.setAreaId(Ip4Address.valueOf("12.12.12.12"));
-        ddPacket.setRouterId(Ip4Address.valueOf("2.2.2.2"));
-        ddPacket.setIsOpaqueCapable(true);
-        ddPacket.setIsMore(1);
-        ddPacket.setIsInitialize(1);
-        ddPacket.setIsMaster(1);
-        ddPacket.setSequenceNo(123);
-        message = ddPacket;
-        ospfNbrHashMap = new HashMap();
-        ospfNbr = new OspfNbrImpl(ospfArea, ospfInterface, Ip4Address.valueOf("10.10.10.10"),
-                                  Ip4Address.valueOf("2.2.2.2"), 2,
-                                  new OspfInterfaceChannelHandler(new Controller(), ospfArea,
-                                                                  ospfInterface),
-                                  topologyForDeviceAndLink);
-        ospfNbr.setLastDdPacket(createDdPacket());
-        ospfNbr.setNeighborId(Ip4Address.valueOf("2.2.2.2"));
-        ospfNbr.setState(OspfNeighborState.EXCHANGE);
-        ospfNbr.setRouterPriority(0);
-        ospfNbr.setNeighborDr(Ip4Address.valueOf("13.13.13.13"));
-        ospfNbr.setDdSeqNum(123);
-        ospfInterface.addNeighbouringRouter(ospfNbr);
-        ddPacket.setIsMore(1);
-        ddPacket.setIsInitialize(0);
-        ddPacket.setIsMaster(0);
-        ddPacket.setSequenceNo(123);
-        ospfInterface.addNeighbouringRouter(ospfNbr);
-        ospfInterfaceChannelHandler.processDdMessage(message, channelHandlerContext);
-        assertThat(ospfInterfaceChannelHandler, is(notNullValue()));
-
-    }
-
-    /**
-     * Tests processDdMessage() method.
-     */
-    @Test(expected = Exception.class)
-    public void testProcessDdMessage2() throws Exception {
-        ospfInterface.setIpAddress(Ip4Address.valueOf("11.11.11.11"));
-        ospfInterface.setInterfaceType(2);
-        ospfInterface.setIpNetworkMask(Ip4Address.valueOf("255.255.255.255"));
-        ospfInterface.setHelloIntervalTime(10);
-        ospfInterface.setRouterDeadIntervalTime(10);
-        ospfArea.setAreaId(Ip4Address.valueOf("12.12.12.12"));
-        channelHandlerContext = EasyMock.createMock(ChannelHandlerContext.class);
-        OspfMessage message;
-        ddPacket = new DdPacket();
-        ddPacket.setSourceIp(Ip4Address.valueOf("1.1.1.1"));
-        ddPacket.setOspfVer(2);
-        ddPacket.setAreaId(Ip4Address.valueOf("12.12.12.12"));
-        ddPacket.setRouterId(Ip4Address.valueOf("2.2.2.2"));
-        ddPacket.setIsOpaqueCapable(true);
-        ddPacket.setIsMore(1);
-        ddPacket.setIsInitialize(1);
-        ddPacket.setIsMaster(1);
-        ddPacket.setSequenceNo(123);
-        message = ddPacket;
-        ospfNbrHashMap = new HashMap();
-        ospfNbr = new OspfNbrImpl(ospfArea, ospfInterface, Ip4Address.valueOf("10.10.10.10"),
-                                  Ip4Address.valueOf("2.2.2.2"), 2,
-                                  new OspfInterfaceChannelHandler(new Controller(), ospfArea,
-                                                                  ospfInterface),
-                                  topologyForDeviceAndLink);
-        ospfNbr.setLastDdPacket(createDdPacket());
-        ospfNbr.setNeighborId(Ip4Address.valueOf("2.2.2.2"));
-        ospfNbr.setState(OspfNeighborState.LOADING);
-        ospfNbr.setRouterPriority(0);
-        ospfNbr.setNeighborDr(Ip4Address.valueOf("13.13.13.13"));
-        ospfNbr.setDdSeqNum(123);
-        ospfInterface.addNeighbouringRouter(ospfNbr);
-        ospfInterfaceChannelHandler.processDdMessage(message, channelHandlerContext);
-        ddPacket.setIsMore(1);
-        ddPacket.setIsInitialize(0);
-        ddPacket.setIsMaster(0);
-        ddPacket.setSequenceNo(123);
-        ospfInterface.addNeighbouringRouter(ospfNbr);
-        ospfNbr.setState(OspfNeighborState.LOADING);
-        ospfInterface.addNeighbouringRouter(ospfNbr);
-
-        ospfInterfaceChannelHandler.processDdMessage(message, channelHandlerContext);
-
-        assertThat(ospfInterfaceChannelHandler, is(notNullValue()));
-
-    }
-
-    /**
-     * Tests processLsRequestMessage() method.
-     */
-    @Test
-    public void testProcessLSRequestMessage() throws Exception {
-        ospfInterface.setIpAddress(Ip4Address.valueOf("11.11.11.11"));
-        ospfInterface.setInterfaceType(2);
-        ospfInterface.setIpNetworkMask(Ip4Address.valueOf("255.255.255.255"));
-        ospfInterface.setHelloIntervalTime(10);
-        ospfInterface.setRouterDeadIntervalTime(10);
-        ospfArea.setAreaId(Ip4Address.valueOf("12.12.12.12"));
-        channelHandlerContext = EasyMock.createMock(ChannelHandlerContext.class);
-        OspfMessage message;
-        lsRequest = new LsRequest();
-        lsRequest.setSourceIp(Ip4Address.valueOf("1.1.1.1"));
-        lsRequest.setOspfVer(2);
-        lsRequest.setAreaId(Ip4Address.valueOf("12.12.12.12"));
-        lsRequest.setRouterId(Ip4Address.valueOf("10.226.165.100"));
-        List<LsRequestPacket> lsRequests = new ArrayList();
-        LsRequestPacket lsRequestPacket = new LsRequestPacket();
-        lsRequestPacket.setLsType(3);
-        lsRequestPacket.setLinkStateId("2.2.2.2");
-        lsRequestPacket.setOwnRouterId("2.2.2.2");
-        lsRequests.add(lsRequestPacket);
-        lsRequests.add(lsRequestPacket);
-        lsRequest.addLinkStateRequests(new LsRequestPacket());
-        lsRequest.addLinkStateRequests(new LsRequestPacket());
-        message = lsRequest;
-        ospfNbrHashMap = new HashMap();
-        ospfNbr.setState(OspfNeighborState.EXCHANGE);
-        ospfNbr = new OspfNbrImpl(ospfArea, createOspfInterface(), Ip4Address.valueOf("10.10.10.10"),
-                                  Ip4Address.valueOf("10.226.165.100"), 2,
-                                  new OspfInterfaceChannelHandler(new Controller(), ospfArea,
-                                                                  createOspfInterface1()),
-                                  topologyForDeviceAndLink);
-        ospfNbr.setLastDdPacket(createDdPacket());
-        ospfNbr.setNeighborId(Ip4Address.valueOf("2.2.2.2"));
-        ospfNbr.setState(OspfNeighborState.FULL);
-        ospfNbr.setRouterPriority(0);
-        ospfNbr.setNeighborDr(Ip4Address.valueOf("13.13.13.13"));
-        ospfNbr.setDdSeqNum(123);
-        ospfInterface.addNeighbouringRouter(ospfNbr);
-        ospfInterface.setListOfNeighbors(ospfNbrHashMap);
-        ospfInterfaceChannelHandler.processLsRequestMessage(message, channelHandlerContext);
-        assertThat(ospfInterfaceChannelHandler, is(notNullValue()));
-
-    }
-
-    /**
-     * Tests processLsUpdateMessage() method.
-     */
-    @Test
-    public void testProcessLSUpdateMessage() throws Exception {
-        ospfInterface.setIpAddress(Ip4Address.valueOf("11.11.11.11"));
-        ospfInterface.setInterfaceType(2);
-        ospfInterface.setIpNetworkMask(Ip4Address.valueOf("255.255.255.255"));
-        ospfInterface.setHelloIntervalTime(10);
-        ospfInterface.setRouterDeadIntervalTime(10);
-        ospfArea.setAreaId(Ip4Address.valueOf("12.12.12.12"));
-        channelHandlerContext = EasyMock.createMock(ChannelHandlerContext.class);
-        OspfMessage message;
-        lsUpdate = new LsUpdate();
-        lsUpdate.setSourceIp(Ip4Address.valueOf("1.1.1.1"));
-        lsUpdate.setOspfVer(2);
-        lsUpdate.setAreaId(Ip4Address.valueOf("12.12.12.12"));
-        lsUpdate.setRouterId(Ip4Address.valueOf("10.226.165.100"));
-        RouterLsa routerLsa = new RouterLsa();
-        lsUpdate.addLsa(routerLsa);
-        lsUpdate.setNumberOfLsa(1);
-        message = lsUpdate;
-        ospfNbrHashMap = new HashMap();
-        ospfNbr.setState(OspfNeighborState.FULL);
-        ospfNbr = new OspfNbrImpl(ospfArea, createOspfInterface(), Ip4Address.valueOf("10.10.10.10"),
-                                  Ip4Address.valueOf("10.226.165.100"), 2,
-                                  new OspfInterfaceChannelHandler(new Controller(), ospfArea,
-                                                                  createOspfInterface1()),
-                                  topologyForDeviceAndLink);
-        ospfNbr.setLastDdPacket(createDdPacket());
-        ospfNbr.setNeighborId(Ip4Address.valueOf("2.2.2.2"));
-        ospfNbr.setState(OspfNeighborState.FULL);
-        ospfNbr.setRouterPriority(0);
-        ospfNbr.setNeighborDr(Ip4Address.valueOf("13.13.13.13"));
-        ospfNbr.setDdSeqNum(123);
-        ospfInterface.addNeighbouringRouter(ospfNbr);
-        ospfInterfaceChannelHandler.processLsUpdateMessage(message, channelHandlerContext);
-        assertThat(ospfInterfaceChannelHandler, is(notNullValue()));
-
-    }
-
-    @Test(expected = Exception.class)
-    public void testProcessLSAckMessage() throws Exception {
-        ospfInterface.setIpAddress(Ip4Address.valueOf("11.11.11.11"));
-        ospfInterface.setInterfaceType(2);
-        ospfInterface.setIpNetworkMask(Ip4Address.valueOf("255.255.255.255"));
-        ospfInterface.setHelloIntervalTime(10);
-        ospfInterface.setRouterDeadIntervalTime(10);
-        ospfArea.setAreaId(Ip4Address.valueOf("12.12.12.12"));
-        channelHandlerContext = EasyMock.createMock(ChannelHandlerContext.class);
-        OspfMessage message;
-        lsAck = new LsAcknowledge();
-        lsAck.setSourceIp(Ip4Address.valueOf("1.1.1.1"));
-        lsAck.setOspfVer(2);
-        lsAck.setAreaId(Ip4Address.valueOf("12.12.12.12"));
+    private OspfInterfaceImpl createOspfInterface() throws Exception {
+        ospfInterface = new OspfInterfaceImpl();
         LsaHeader lsaHeader = new LsaHeader();
-        lsAck.addLinkStateHeader(lsaHeader);
-        message = lsAck;
-        ospfNbr = new OspfNbrImpl(ospfArea, createOspfInterface(), Ip4Address.valueOf("10.10.10.10"),
-                                  Ip4Address.valueOf("10.226.165.100"), 2,
-                                  new OspfInterfaceChannelHandler(new Controller(), ospfArea,
-                                                                  createOspfInterface()),
-                                  topologyForDeviceAndLink);
-        ospfNbr.setLastDdPacket(createDdPacket());
-        ospfNbr.setNeighborId(Ip4Address.valueOf("2.2.2.2"));
-        ospfNbr.setState(OspfNeighborState.FULL);
-        ospfNbr.setRouterPriority(0);
-        ospfNbr.setNeighborDr(Ip4Address.valueOf("13.13.13.13"));
-        ospfNbr.setDdSeqNum(123);
-        ospfInterfaceChannelHandler.processLsAckMessage(message, channelHandlerContext);
-        assertThat(ospfInterfaceChannelHandler, is(notNullValue()));
-
-    }
-
-    /**
-     * Tests compareDdPackets() method.
-     */
-    @Test
-    public void testCompareDDPackets() throws Exception {
-        ospfInterface.setIpAddress(Ip4Address.valueOf("11.11.11.11"));
-        ospfInterface.setInterfaceType(2);
-        ospfInterface.setIpNetworkMask(Ip4Address.valueOf("255.255.255.255"));
-        ospfInterface.setHelloIntervalTime(10);
-        ospfInterface.setRouterDeadIntervalTime(10);
-        ospfArea.setAreaId(Ip4Address.valueOf("12.12.12.12"));
-        channelHandlerContext = EasyMock.createMock(ChannelHandlerContext.class);
-        OspfMessage message;
-        ddPacket = new DdPacket();
-        ddPacket.setSourceIp(Ip4Address.valueOf("1.1.1.1"));
-        ddPacket.setOspfVer(2);
-        ddPacket.setIsInitialize(1);
-        ddPacket.setIsMaster(1);
-        ddPacket.setIsMore(1);
-        ddPacket.setOptions(2);
-        ddPacket.setAreaId(Ip4Address.valueOf("12.12.12.12"));
-        assertThat(ospfInterfaceChannelHandler.compareDdPackets(ddPacket, ddPacket), is(true));
-    }
-
-    @Test(expected = Exception.class)
-    public void testCloseChannel() throws Exception {
-        channelHandlerContext = EasyMock.createMock(ChannelHandlerContext.class);
-
-        ospfInterfaceChannelHandler.closeChannel(channelHandlerContext);
-
-        assertThat(ospfInterface.dr(), is(notNullValue()));
-    }
-
-    /**
-     * Tests electRouter() method.
-     */
-    @Test
-    public void testElectRouter() throws Exception {
-        ospfInterface.setDr(Ip4Address.valueOf("3.3.3.3"));
-        ospfInterface.setBdr(Ip4Address.valueOf("3.3.3.3"));
-        ospfInterface.setIpNetworkMask(Ip4Address.valueOf("255.255.255.255"));
-        ChannelConfig channelConfig = EasyMock.createMock(ChannelConfig.class);
-        EasyMock.expect(channelConfig.getBufferFactory()).andReturn(new HeapChannelBufferFactory());
-        Channel channel = EasyMock.createMock(Channel.class);
-        ospfInterfaceChannelHandler.electRouter(channel);
-        assertThat(ospfInterface.dr(), is(notNullValue()));
-    }
-
-    /**
-     * Tests electBdr() method.
-     */
-    @Test
-    public void testElectBdr() throws Exception {
-        ospfEligibleRouter = new OspfEligibleRouter();
-        ospfEligibleRouter.setIpAddress(Ip4Address.valueOf("1.1.1.1"));
-        ospfEligibleRouter.setIsDr(true);
-        ospfEligibleRouter.setRouterPriority(10);
-        ospfEligibleRouter.setRouterId(Ip4Address.valueOf("1.1.1.1"));
-        ospfEligibleRouter.setIsBdr(false);
-        OspfEligibleRouter ospfEligibleRouter1 = new OspfEligibleRouter();
-        ospfEligibleRouter.setIpAddress(Ip4Address.valueOf("1.1.1.1"));
-        ospfEligibleRouter.setIsDr(true);
-        ospfEligibleRouter.setRouterPriority(10);
-        ospfEligibleRouter.setRouterId(Ip4Address.valueOf("1.1.1.1"));
-        ospfEligibleRouter.setIsBdr(false);
-        OspfEligibleRouter ospfEligibleRouter2 = new OspfEligibleRouter();
-        ospfEligibleRouter.setIpAddress(Ip4Address.valueOf("1.1.1.1"));
-        ospfEligibleRouter.setIsDr(true);
-        ospfEligibleRouter.setRouterPriority(10);
-        ospfEligibleRouter.setRouterId(Ip4Address.valueOf("1.1.1.1"));
-        ospfEligibleRouter.setIsBdr(false);
-        List<OspfEligibleRouter> ospfEligibleRouters = new ArrayList<>();
-
-        ospfEligibleRouters.add(ospfEligibleRouter);
-        ospfEligibleRouters.add(ospfEligibleRouter1);
-        ospfEligibleRouters.add(ospfEligibleRouter2);
-        OspfEligibleRouter eligibleRouter = ospfInterfaceChannelHandler.electBdr(ospfEligibleRouters);
-        assertThat(ospfEligibleRouters.size(), is(3));
-        assertThat(eligibleRouter, is(notNullValue()));
-    }
-
-    /**
-     * Tests electDr() method.
-     */
-    @Test
-    public void testElectDR() throws Exception {
-        ospfEligibleRouter = new OspfEligibleRouter();
-        ospfEligibleRouter.setIpAddress(Ip4Address.valueOf("1.1.1.1"));
-        ospfEligibleRouter.setIsDr(true);
-        ospfEligibleRouter.setRouterPriority(10);
-        ospfEligibleRouter.setRouterId(Ip4Address.valueOf("1.1.1.1"));
-        ospfEligibleRouter.setIsBdr(false);
-        OspfEligibleRouter ospfEligibleRouter1 = new OspfEligibleRouter();
-        ospfEligibleRouter.setIpAddress(Ip4Address.valueOf("1.1.1.1"));
-        ospfEligibleRouter.setIsDr(true);
-        ospfEligibleRouter.setRouterPriority(10);
-        ospfEligibleRouter.setRouterId(Ip4Address.valueOf("1.1.1.1"));
-        ospfEligibleRouter.setIsBdr(false);
-        OspfEligibleRouter ospfEligibleRouter2 = new OspfEligibleRouter();
-        ospfEligibleRouter.setIpAddress(Ip4Address.valueOf("1.1.1.1"));
-        ospfEligibleRouter.setIsDr(true);
-        ospfEligibleRouter.setRouterPriority(10);
-        ospfEligibleRouter.setRouterId(Ip4Address.valueOf("1.1.1.1"));
-        ospfEligibleRouter.setIsBdr(false);
-        List<OspfEligibleRouter> ospfEligibleRouters = new ArrayList<>();
-        ospfEligibleRouters.add(ospfEligibleRouter);
-        ospfEligibleRouters.add(ospfEligibleRouter1);
-        ospfEligibleRouters.add(ospfEligibleRouter2);
-        OspfEligibleRouter eligibleRouter = ospfInterfaceChannelHandler.electDr(ospfEligibleRouters,
-                                                                                ospfEligibleRouter);
-        assertThat(ospfEligibleRouters.size(), is(3));
-        assertThat(eligibleRouter, is(notNullValue()));
-    }
-
-    /**
-     * Tests selectRouterBasedOnPriority() method.
-     */
-    @Test
-    public void testSelectRouterBasedOnPriority() throws Exception {
-        ospfEligibleRouter = new OspfEligibleRouter();
-        ospfEligibleRouter.setIpAddress(Ip4Address.valueOf("1.1.1.1"));
-        ospfEligibleRouter.setIsDr(true);
-        ospfEligibleRouter.setRouterPriority(10);
-        ospfEligibleRouter.setRouterId(Ip4Address.valueOf("1.1.1.1"));
-        ospfEligibleRouter.setIsBdr(false);
-        OspfEligibleRouter ospfEligibleRouter1 = new OspfEligibleRouter();
-        ospfEligibleRouter.setIpAddress(Ip4Address.valueOf("1.1.1.1"));
-        ospfEligibleRouter.setIsDr(true);
-        ospfEligibleRouter.setRouterPriority(11);
-        ospfEligibleRouter.setRouterId(Ip4Address.valueOf("1.1.1.1"));
-        ospfEligibleRouter.setIsBdr(false);
-        OspfEligibleRouter ospfEligibleRouter2 = new OspfEligibleRouter();
-        ospfEligibleRouter.setIpAddress(Ip4Address.valueOf("1.1.1.1"));
-        ospfEligibleRouter.setIsDr(true);
-        ospfEligibleRouter.setRouterPriority(12);
-        ospfEligibleRouter.setRouterId(Ip4Address.valueOf("1.1.1.1"));
-        ospfEligibleRouter.setIsBdr(false);
-        List<OspfEligibleRouter> ospfEligibleRouters = new ArrayList<>();
-        ospfEligibleRouters.add(ospfEligibleRouter);
-        ospfEligibleRouters.add(ospfEligibleRouter1);
-        ospfEligibleRouters.add(ospfEligibleRouter2);
-        OspfEligibleRouter eligibleRouter = ospfInterfaceChannelHandler.selectRouterBasedOnPriority(
-                ospfEligibleRouters);
-        assertThat(eligibleRouter, is(notNullValue()));
-    }
-
-    /**
-     * Tests addDeviceInformation() method.
-     */
-    @Test(expected = Exception.class)
-    public void testAddDeviceInformation() throws Exception {
-        ospfNbr = new OspfNbrImpl(ospfArea, createOspfInterface(), Ip4Address.valueOf("10.10.10.10"),
-                                  Ip4Address.valueOf("10.226.165.100"), 2,
-                                  new OspfInterfaceChannelHandler(new Controller(), ospfArea,
-                                                                  createOspfInterface()),
-                                  topologyForDeviceAndLink);
-
-        ospfInterfaceChannelHandler.addDeviceInformation(new OspfRouterImpl());
-        assertThat(ospfInterfaceChannelHandler, is(notNullValue()));
-    }
-
-    /**
-     * Tests removeDeviceInformation() method.
-     */
-    @Test(expected = Exception.class)
-    public void testRemoveDeviceInformation() throws Exception {
-        ospfNbr = new OspfNbrImpl(ospfArea, createOspfInterface(), Ip4Address.valueOf("10.10.10.10"),
-                                  Ip4Address.valueOf("10.226.165.100"), 2,
-                                  new OspfInterfaceChannelHandler(new Controller(), ospfArea,
-                                                                  createOspfInterface()),
-                                  topologyForDeviceAndLink);
-
-        ospfInterfaceChannelHandler.removeDeviceInformation(new OspfRouterImpl());
-        assertThat(ospfInterfaceChannelHandler, is(notNullValue()));
-    }
-
-    /**
-     * Tests addLinkInformation() method.
-     */
-    @Test(expected = Exception.class)
-    public void testaddLinkInformation() throws Exception {
-        ospfNbr = new OspfNbrImpl(ospfArea, createOspfInterface(), Ip4Address.valueOf("10.10.10.10"),
-                                  Ip4Address.valueOf("10.226.165.100"), 2,
-                                  new OspfInterfaceChannelHandler(new Controller(), ospfArea,
-                                                                  createOspfInterface()),
-                                  topologyForDeviceAndLink);
-
-        List topTlv = new ArrayList();
-        topTlv.add(new RouterTlv(new TlvHeader()));
-        ospfInterfaceChannelHandler.addLinkInformation(new OspfRouterImpl(), new OspfLinkTedImpl());
-        assertThat(ospfInterfaceChannelHandler, is(notNullValue()));
-    }
-
-    /**
-     * Tests removeLinkInformation() method.
-     */
-    @Test(expected = Exception.class)
-    public void testRemoveLinkInformation() throws Exception {
-        ospfNbr = new OspfNbrImpl(ospfArea, createOspfInterface(), Ip4Address.valueOf("10.10.10.10"),
-                                  Ip4Address.valueOf("10.226.165.100"), 2,
-                                  new OspfInterfaceChannelHandler(new Controller(), ospfArea,
-                                                                  createOspfInterface()),
-                                  topologyForDeviceAndLink);
-
-        ospfInterfaceChannelHandler.removeLinkInformation(ospfNbr);
-        assertThat(ospfInterfaceChannelHandler, is(notNullValue()));
+        lsaHeader.setLsType(OspfLsaType.ROUTER.value());
+        RouterLsa routerLsa = new RouterLsa();
+        OspfAreaImpl ospfArea = new OspfAreaImpl();
+        ospfArea.addLsa(routerLsa, true, ospfInterface);
+        ospfNbr = new OspfNbrImpl(ospfArea, ospfInterface, ip4Address5,
+                                  ip4Address6, 2, topologyForDeviceAndLink);
+        ospfNbr.setState(OspfNeighborState.EXSTART);
+        ospfNbr.setNeighborId(ip4Address7);
+        this.ospfInterface = new OspfInterfaceImpl();
+        this.ospfInterface.setIpAddress(ip4Address5);
+        this.ospfInterface.setIpNetworkMask(subnetAddress);
+        this.ospfInterface.setBdr(ip4Address4);
+        this.ospfInterface.setDr(ip4Address4);
+        this.ospfInterface.setHelloIntervalTime(20);
+        this.ospfInterface.setInterfaceType(2);
+        this.ospfInterface.setReTransmitInterval(2000);
+        this.ospfInterface.setMtu(6500);
+        this.ospfInterface.setRouterDeadIntervalTime(1000);
+        this.ospfInterface.setRouterPriority(1);
+        this.ospfInterface.setInterfaceType(1);
+        this.ospfInterface.setInterfaceIndex(1);
+        this.ospfInterface.addNeighbouringRouter(ospfNbr);
+        this.ospfInterface.setOspfArea(ospfArea);
+        return this.ospfInterface;
     }
 
     /**
@@ -1042,115 +324,4 @@
         ddPacket1.readFrom(buf);
         return ddPacket1;
     }
-
-    /**
-     * Utility for test method.
-     */
-    private OspfInterfaceImpl createOspfInterface() throws UnknownHostException {
-        ospfInterface = new OspfInterfaceImpl();
-        OspfAreaImpl ospfArea = new OspfAreaImpl();
-        OspfInterfaceChannelHandler ospfInterfaceChannelHandler = EasyMock.createMock(
-                OspfInterfaceChannelHandler.class);
-        ospfNbr = new OspfNbrImpl(ospfArea, ospfInterface, Ip4Address.valueOf("10.226.165.164"),
-                                  Ip4Address.valueOf("1.1.1.1"), 2, ospfInterfaceChannelHandler,
-                                  topologyForDeviceAndLink);
-        ospfNbr.setState(OspfNeighborState.EXSTART);
-        ospfNbr.setNeighborId(Ip4Address.valueOf("10.226.165.100"));
-        this.ospfInterface = new OspfInterfaceImpl();
-        this.ospfInterface.setIpAddress(Ip4Address.valueOf("10.226.165.164"));
-        this.ospfInterface.setIpNetworkMask(Ip4Address.valueOf("255.255.255.255"));
-        this.ospfInterface.setAreaId(2);
-        this.ospfInterface.setAuthKey("authKey");
-        this.ospfInterface.setAuthType("AuthReq");
-        this.ospfInterface.setBdr(Ip4Address.valueOf("111.111.111.111"));
-        this.ospfInterface.setDr(Ip4Address.valueOf("111.111.111.111"));
-        this.ospfInterface.setHelloIntervalTime(20);
-        this.ospfInterface.setInterfaceCost(10);
-        this.ospfInterface.setInterfaceType(2);
-        this.ospfInterface.setReTransmitInterval(2000);
-        this.ospfInterface.setMtu(6500);
-        this.ospfInterface.setPollInterval(1000);
-        this.ospfInterface.setRouterDeadIntervalTime(1000);
-        this.ospfInterface.setRouterPriority(1);
-        this.ospfInterface.setTransmitDelay(500);
-        this.ospfInterface.setInterfaceType(1);
-        this.ospfInterface.addNeighbouringRouter(ospfNbr);
-        return this.ospfInterface;
-    }
-
-    /**
-     * Utility for test method.
-     */
-    private OspfInterfaceImpl createOspfInterface1() throws UnknownHostException {
-        ospfInterface = new OspfInterfaceImpl();
-        OspfAreaImpl ospfArea = new OspfAreaImpl();
-        OspfInterfaceChannelHandler ospfInterfaceChannelHandler = EasyMock.createMock(
-                OspfInterfaceChannelHandler.class);
-        ospfNbr = new OspfNbrImpl(ospfArea, ospfInterface, Ip4Address.valueOf("10.226.165.164"),
-                                  Ip4Address.valueOf("1.1.1.1"), 2, ospfInterfaceChannelHandler,
-                                  topologyForDeviceAndLink);
-        ospfNbr.setState(OspfNeighborState.FULL);
-        ospfNbr.setNeighborId(Ip4Address.valueOf("10.226.165.100"));
-        ospfInterface = new OspfInterfaceImpl();
-        ospfInterface.setIpAddress(Ip4Address.valueOf("10.226.165.164"));
-        ospfInterface.setIpNetworkMask(Ip4Address.valueOf("255.255.255.255"));
-        ospfInterface.setAreaId(2);
-        ospfInterface.setAuthKey("authKey");
-        ospfInterface.setAuthType("AuthReq");
-        ospfInterface.setBdr(Ip4Address.valueOf("111.111.111.111"));
-        ospfInterface.setDr(Ip4Address.valueOf("111.111.111.111"));
-        ospfInterface.setHelloIntervalTime(20);
-        ospfInterface.setInterfaceCost(10);
-        ospfInterface.setInterfaceType(2);
-        ospfInterface.setReTransmitInterval(2000);
-        ospfInterface.setMtu(6500);
-        ospfInterface.setPollInterval(1000);
-        ospfInterface.setRouterDeadIntervalTime(1000);
-        ospfInterface.setRouterPriority(1);
-        ospfInterface.setTransmitDelay(500);
-        ospfInterface.setInterfaceType(1);
-        ospfInterface.addNeighbouringRouter(ospfNbr);
-        return ospfInterface;
-    }
-
-    /**
-     * Utility for test method.
-     */
-    private OspfAreaImpl createOspfArea() throws UnknownHostException {
-        OspfAreaAddressRangeImpl ospfAreaAddressRange;
-        ospfAreaAddressRange = createOspfAreaAddressRange();
-        addressRanges.add(ospfAreaAddressRange);
-        OspfAreaImpl ospfArea = new OspfAreaImpl();
-        ospfArea.setStubCost(10);
-        ospfArea.setAreaId(Ip4Address.valueOf("10.226.165.164"));
-        ospfArea.setExternalRoutingCapability(true);
-        ospfArea.setTransitCapability(true);
-        ospfArea.setAddressRanges(addressRanges);
-        OspfInterfaceImpl ospfInterface = createOspfInterface();
-        ospfInterfaces.add(ospfInterface);
-        ospfArea.setInterfacesLst(ospfInterfaces);
-        RouterLsa routerLsa = new RouterLsa();
-        routerLsa.setLsType(1);
-        routerLsa.setLinkStateId("2.2.2.2");
-        routerLsa.setAdvertisingRouter(Ip4Address.valueOf("2.2.2.2"));
-        try {
-            ospfArea.addLsa(routerLsa, false, ospfInterface);
-        } catch (Exception e) {
-            System.out.println("ospfAreaImpl createOspfArea");
-        }
-        ospfArea.setRouterId(Ip4Address.valueOf("111.111.111.111"));
-
-        return ospfArea;
-    }
-
-    /**
-     * Utility for test method.
-     */
-    private OspfAreaAddressRangeImpl createOspfAreaAddressRange() {
-        OspfAreaAddressRangeImpl ospfAreaAddressRange = new OspfAreaAddressRangeImpl();
-        ospfAreaAddressRange.setIpAddress(Ip4Address.valueOf("10.226.165.164"));
-        ospfAreaAddressRange.setAdvertise(true);
-        ospfAreaAddressRange.setMask("mask");
-        return ospfAreaAddressRange;
-    }
 }
\ No newline at end of file
diff --git a/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/impl/OspfLinkTedImplTest.java b/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/impl/OspfLinkTedImplTest.java
index 7415ed0..d4f0e2e 100755
--- a/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/impl/OspfLinkTedImplTest.java
+++ b/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/impl/OspfLinkTedImplTest.java
@@ -21,6 +21,7 @@
 import org.onlab.packet.Ip4Address;
 import org.onlab.util.Bandwidth;
 
+import java.net.InetAddress;
 import java.util.ArrayList;
 import java.util.List;
 
@@ -32,8 +33,6 @@
  * Unit test class for OspfDeviceTedImpl.
  */
 public class OspfLinkTedImplTest {
-    private static final Ip4Address LOCAL_ADDRESS = Ip4Address.valueOf("127.0.0.1");
-
     private OspfLinkTedImpl ospfLinkTed;
 
     @Before
@@ -91,7 +90,7 @@
     @Test
     public void testIpv4RemRouterId() throws Exception {
         List list = new ArrayList();
-        list.add(LOCAL_ADDRESS);
+        list.add(Ip4Address.valueOf(InetAddress.getLocalHost()));
         ospfLinkTed.setIpv4RemRouterId(list);
         assertThat(ospfLinkTed.ipv4RemRouterId().size(), is(1));
     }
@@ -102,7 +101,7 @@
     @Test
     public void testSetIpv4RemRouterId() throws Exception {
         List list = new ArrayList();
-        list.add(LOCAL_ADDRESS);
+        list.add(Ip4Address.valueOf(InetAddress.getLocalHost()));
         ospfLinkTed.setIpv4RemRouterId(list);
         assertThat(ospfLinkTed.ipv4RemRouterId().size(), is(1));
     }
@@ -133,7 +132,7 @@
     @Test
     public void testIpv4LocRouterId() throws Exception {
         List list = new ArrayList();
-        list.add(LOCAL_ADDRESS);
+        list.add(Ip4Address.valueOf(InetAddress.getLocalHost()));
         ospfLinkTed.setIpv4LocRouterId(list);
         assertThat(ospfLinkTed.ipv4LocRouterId().size(), is(1));
     }
@@ -144,7 +143,7 @@
     @Test
     public void testSetIpv4LocRouterId() throws Exception {
         List list = new ArrayList();
-        list.add(LOCAL_ADDRESS);
+        list.add(Ip4Address.valueOf(InetAddress.getLocalHost()));
         ospfLinkTed.setIpv4LocRouterId(list);
         assertThat(ospfLinkTed.ipv4LocRouterId().size(), is(1));
     }
@@ -202,4 +201,4 @@
         ospfLinkTed.setMaxUnResBandwidth(Bandwidth.bps(1234.0));
         assertThat(ospfLinkTed.maxUnResBandwidth(), is(notNullValue()));
     }
-}
+}
\ No newline at end of file
diff --git a/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/impl/OspfMessageDecoderTest.java b/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/impl/OspfMessageDecoderTest.java
index 696469c..8bb8a2c 100755
--- a/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/impl/OspfMessageDecoderTest.java
+++ b/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/impl/OspfMessageDecoderTest.java
@@ -28,7 +28,7 @@
 import java.net.SocketAddress;
 
 import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.CoreMatchers.nullValue;
+import static org.hamcrest.CoreMatchers.notNullValue;
 import static org.hamcrest.MatcherAssert.assertThat;
 
 /**
@@ -36,7 +36,7 @@
  */
 public class OspfMessageDecoderTest {
 
-    private final byte[] hellopacket = {0, 0, 0, 0, 2, 1, 0, 44, -64, -88, -86, 8, 0, 0, 0, 1, 39, 59,
+    private final byte[] hellopacket = {0, 0, 0, 0, 0, 2, 1, 0, 44, -64, -88, -86, 8, 0, 0, 0, 1, 39, 59,
             0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1, -1, 0, 0, 10, 2, 1, 0, 0, 0,
             40, -64, -88, -86, 8, 0, 0, 0, 0};
     private final byte[] ddpacket = {0, 0, 0, 0, 2, 2, 0, 32, -64, -88, -86, 8, 0, 0, 0, 1, -96, 82,
@@ -75,10 +75,10 @@
      */
     @Test
     public void testDecode() throws Exception {
-
         channel = EasyMock.createMock(Channel.class);
         socketAddress = InetSocketAddress.createUnresolved("127.0.0.1", 7000);
         channelBuffer = ChannelBuffers.copiedBuffer(hellopacket);
-        assertThat(ospfMessageDecoder.decode(ctx, channel, channelBuffer), is(nullValue()));
+        ospfMessageDecoder.decode(ctx, channel, channelBuffer);
+        assertThat(ospfMessageDecoder, is(notNullValue()));
     }
 }
\ No newline at end of file
diff --git a/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/impl/OspfMessageEncoderTest.java b/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/impl/OspfMessageEncoderTest.java
index 0e40cb7..5bb7dec 100755
--- a/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/impl/OspfMessageEncoderTest.java
+++ b/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/impl/OspfMessageEncoderTest.java
@@ -17,24 +17,11 @@
 
 
 import org.easymock.EasyMock;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
 import org.jboss.netty.channel.Channel;
 import org.jboss.netty.channel.ChannelHandlerContext;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
-import org.onlab.packet.Ip4Address;
-import org.onosproject.ospf.controller.area.OspfInterfaceImpl;
-import org.onosproject.ospf.protocol.ospfpacket.types.DdPacket;
-import org.onosproject.ospf.protocol.ospfpacket.types.HelloPacket;
-import org.onosproject.ospf.protocol.ospfpacket.types.LsAcknowledge;
-import org.onosproject.ospf.protocol.ospfpacket.types.LsRequest;
-import org.onosproject.ospf.protocol.ospfpacket.types.LsUpdate;
-import org.onosproject.ospf.protocol.util.OspfInterfaceState;
-
-import java.net.InetSocketAddress;
-import java.net.SocketAddress;
 
 import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.CoreMatchers.notNullValue;
@@ -44,55 +31,24 @@
  * Created by sdn on 13/1/16.
  */
 public class OspfMessageEncoderTest {
-    private final byte[] hpacket = {2, 1, 0, 44, -64, -88, -86, 8, 0, 0, 0, 1, 39, 59,
-            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1, -1, 0, 0, 10, 2, 1, 0, 0, 0,
-            40, -64, -88, -86, 8, 0, 0, 0, 0};
-    private final byte[] dpacket = {2, 2, 0, 32, -64, -88, -86, 8, 0, 0, 0, 1, -96, 82,
-            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, -36, 2, 7, 65, 119, -87, 126};
-    private final byte[] lrpacket = {2, 3, 0, 36, -64, -88, -86, 3, 0, 0, 0, 1, -67, -57,
-            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, -64, -88, -86, 8, -64, -88, -86, 8};
-    private byte[] lAckpacket = {2, 5, 0, 44, -64, -88, -86, 8, 0, 0, 0, 1, -30, -12,
-            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 14, 16, 2, 1, -64, -88, -86, 2, -64,
-            -88, -86, 2, -128, 0, 0, 1, 74, -114, 0, 48};
-    private HelloPacket helloPacket;
-    private DdPacket ddPacket;
-    private LsAcknowledge lsAcknowledge;
-    private LsRequest lsRequest;
-    private LsUpdate lsUpdate;
-    private ChannelHandlerContext ctx;
+
+    private final byte[] object = {2, 1, 0, 44, -64, -88, -86, 8, 0, 0, 0, 1, 39,
+            59, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1, -1, 0, 0, 10, 2, 1, 0, 0,
+            0, 40, -64, -88, -86, 8, 0, 0, 0, 0};
     private OspfMessageEncoder ospfMessageEncoder;
-    private ChannelBuffer buf;
-    private SocketAddress socketAddress;
+    private ChannelHandlerContext channelHandlerContext;
     private Channel channel;
 
     @Before
     public void setUp() throws Exception {
         ospfMessageEncoder = new OspfMessageEncoder();
-        helloPacket = new HelloPacket();
-        ddPacket = new DdPacket();
-        lsAcknowledge = new LsAcknowledge();
-        lsRequest = new LsRequest();
-        lsUpdate = new LsUpdate();
-        helloPacket.setOspftype(1);
-        ddPacket.setOspftype(2);
-        lsAcknowledge.setOspftype(5);
-        lsRequest.setOspftype(3);
-        lsUpdate.setOspftype(4);
-        OspfInterfaceImpl ospfInterface = new OspfInterfaceImpl();
-        ospfInterface.setState(OspfInterfaceState.DROTHER);
-        ospfMessageEncoder = new OspfMessageEncoder(ospfInterface);
-
+        channelHandlerContext = EasyMock.createMock(ChannelHandlerContext.class);
+        channel = EasyMock.createMock(Channel.class);
     }
 
     @After
     public void tearDown() throws Exception {
-        helloPacket = null;
-        ddPacket = null;
-        lsAcknowledge = null;
-        lsRequest = null;
-        lsUpdate = null;
         ospfMessageEncoder = null;
-        buf = null;
     }
 
     /**
@@ -100,33 +56,6 @@
      */
     @Test
     public void testEncode() throws Exception {
-        socketAddress = InetSocketAddress.createUnresolved("127.0.0.1", 8600);
-        channel = EasyMock.createMock(Channel.class);
-        helloPacket = new HelloPacket();
-        helloPacket.setDestinationIp(Ip4Address.valueOf("15.15.15.15"));
-        buf = ChannelBuffers.buffer(hpacket.length);
-        buf.writeBytes(hpacket);
-        helloPacket.readFrom(buf);
-        ospfMessageEncoder.encode(ctx, channel, helloPacket);
-        ddPacket = new DdPacket();
-        ddPacket.setDestinationIp(Ip4Address.valueOf("15.15.15.15"));
-        buf = ChannelBuffers.buffer(dpacket.length);
-        buf.writeBytes(dpacket);
-        ddPacket.readFrom(buf);
-        ospfMessageEncoder.encode(ctx, channel, ddPacket);
-        lsRequest = new LsRequest();
-        lsRequest.setDestinationIp(Ip4Address.valueOf("15.15.15.15"));
-        buf = ChannelBuffers.buffer(lrpacket.length);
-        buf.writeBytes(lrpacket);
-        lsRequest.readFrom(buf);
-        ospfMessageEncoder.encode(ctx, channel, lsRequest);
-
-        lsAcknowledge = new LsAcknowledge();
-        lsAcknowledge.setDestinationIp(Ip4Address.valueOf("15.15.15.15"));
-        buf = ChannelBuffers.buffer(lAckpacket.length);
-        buf.writeBytes(lAckpacket);
-        lsAcknowledge.readFrom(buf);
-        ospfMessageEncoder.encode(ctx, channel, lsAcknowledge);
-        assertThat(ospfMessageEncoder, is(notNullValue()));
+        assertThat(ospfMessageEncoder.encode(channelHandlerContext, channel, object), is(notNullValue()));
     }
 }
\ No newline at end of file
diff --git a/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/impl/OspfNbrImplTest.java b/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/impl/OspfNbrImplTest.java
index 5c7c27a..295f0ab 100755
--- a/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/impl/OspfNbrImplTest.java
+++ b/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/impl/OspfNbrImplTest.java
@@ -19,31 +19,37 @@
 import org.easymock.EasyMock;
 import org.jboss.netty.channel.Channel;
 import org.junit.After;
-import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
 import org.onlab.packet.Ip4Address;
+import org.onosproject.ospf.controller.OspfAreaAddressRange;
 import org.onosproject.ospf.controller.OspfInterface;
 import org.onosproject.ospf.controller.OspfLsa;
 import org.onosproject.ospf.controller.OspfLsaType;
+import org.onosproject.ospf.controller.OspfMessage;
 import org.onosproject.ospf.controller.OspfNeighborState;
 import org.onosproject.ospf.controller.TopologyForDeviceAndLink;
+import org.onosproject.ospf.controller.area.OspfAreaAddressRangeImpl;
 import org.onosproject.ospf.controller.area.OspfAreaImpl;
 import org.onosproject.ospf.controller.area.OspfInterfaceImpl;
 import org.onosproject.ospf.controller.lsdb.LsaWrapperImpl;
 import org.onosproject.ospf.controller.lsdb.LsdbAgeImpl;
+import org.onosproject.ospf.controller.util.OspfInterfaceType;
 import org.onosproject.ospf.protocol.lsa.LsaHeader;
+import org.onosproject.ospf.protocol.lsa.OpaqueLsaHeader;
 import org.onosproject.ospf.protocol.lsa.types.NetworkLsa;
+import org.onosproject.ospf.protocol.lsa.types.OpaqueLsa10;
 import org.onosproject.ospf.protocol.lsa.types.RouterLsa;
-import org.onosproject.ospf.protocol.ospfpacket.OspfMessage;
 import org.onosproject.ospf.protocol.ospfpacket.types.DdPacket;
 import org.onosproject.ospf.protocol.ospfpacket.types.HelloPacket;
 import org.onosproject.ospf.protocol.ospfpacket.types.LsRequest;
 import org.onosproject.ospf.protocol.ospfpacket.types.LsUpdate;
 import org.onosproject.ospf.protocol.util.ChecksumCalculator;
+import org.onosproject.ospf.protocol.util.OspfInterfaceState;
 import org.onosproject.ospf.protocol.util.OspfUtil;
 
 import java.net.SocketAddress;
+import java.net.UnknownHostException;
 import java.util.ArrayList;
 import java.util.List;
 
@@ -55,54 +61,68 @@
  * Unit test class for OspfNbrImpl.
  */
 public class OspfNbrImplTest {
-
+    private List<OspfAreaAddressRange> addressRanges = new ArrayList();
     private OspfNbrImpl ospfNbr;
+    private OspfNbrImpl ospfNbr1;
     private OspfInterfaceImpl ospfInterface;
     private OspfAreaImpl ospfArea;
     private OspfInterfaceImpl ospfInterface1;
     private OspfInterfaceImpl ospfInterface2;
-    private List<OspfInterface> ospfInterfaces;
+    private List<OspfInterface> ospfInterfaces = new ArrayList();
     private List<OspfLsa> ospfLsaList;
     private Channel channel;
     private Channel channel1;
     private Channel channel2;
     private OspfMessage ospfMessage;
     private TopologyForDeviceAndLink topologyForDeviceAndLink;
+    private LsaHeader lsaHeader;
 
     @Before
     public void setUp() throws Exception {
+        lsaHeader = new LsaHeader();
+        lsaHeader.setLsType(OspfLsaType.ROUTER.value());
+        RouterLsa routerLsa = new RouterLsa(lsaHeader);
+        routerLsa.setLsType(OspfLsaType.ROUTER.value());
         ospfInterface = new OspfInterfaceImpl();
         ospfInterface.setInterfaceType(2);
+        ospfInterface.setInterfaceIndex(1);
         ospfInterface.setRouterDeadIntervalTime(30);
         ospfInterface.setReTransmitInterval(30);
         ospfInterface.setDr(Ip4Address.valueOf("1.1.1.1"));
         ospfInterface.setIpAddress(Ip4Address.valueOf("1.1.1.1"));
-        ospfArea = new OspfAreaImpl();
+        ospfInterface.setState(OspfInterfaceState.POINT2POINT);
+        ospfArea = createOspfArea();
+        ospfArea.addLsa(routerLsa, true, ospfInterface);
+        ospfInterface.setOspfArea(ospfArea);
         ospfInterface1 = new OspfInterfaceImpl();
         ospfInterface1.setInterfaceType(2);
+        ospfInterface1.setInterfaceIndex(1);
         ospfInterface1.setRouterDeadIntervalTime(30);
         ospfInterface1.setReTransmitInterval(30);
         ospfInterface1.setDr(Ip4Address.valueOf("7.7.7.7"));
         ospfInterface1.setIpAddress(Ip4Address.valueOf("7.7.7.7"));
+        ospfInterface1.setState(OspfInterfaceState.DOWN);
+        ospfInterface1.setOspfArea(ospfArea);
         ospfInterface2 = new OspfInterfaceImpl();
         ospfInterface2.setInterfaceType(2);
+        ospfInterface2.setInterfaceIndex(1);
         ospfInterface2.setRouterDeadIntervalTime(30);
         ospfInterface2.setReTransmitInterval(30);
         ospfInterface2.setDr(Ip4Address.valueOf("6.6.6.6"));
         ospfInterface2.setIpAddress(Ip4Address.valueOf("6.6.6.6"));
+        ospfInterface2.setOspfArea(ospfArea);
+        ospfInterface1.setState(OspfInterfaceState.DR);
         ospfInterfaces = new ArrayList();
         ospfInterfaces.add(ospfInterface);
         ospfInterfaces.add(ospfInterface1);
         ospfInterfaces.add(ospfInterface2);
-        ospfArea.setInterfacesLst(ospfInterfaces);
+        ospfArea.setOspfInterfaceList(ospfInterfaces);
+        ospfInterface.setState(OspfInterfaceState.POINT2POINT);
         ospfArea.setRouterId(Ip4Address.valueOf("111.111.111.111"));
         topologyForDeviceAndLink = new TopologyForDeviceAndLinkImpl();
         ospfNbr = new OspfNbrImpl(ospfArea, ospfInterface, Ip4Address.valueOf("1.1.1.1"),
                                   Ip4Address.valueOf("2.2.2.2"), 2,
-                                  new OspfInterfaceChannelHandler(new Controller(),
-                                                                  ospfArea, ospfInterface),
                                   topologyForDeviceAndLink);
-
     }
 
     @After
@@ -184,12 +204,19 @@
     /**
      * Tests negotiationDone() method.
      */
-    @Test(expected = Exception.class)
+    @Test
     public void testNegotiationDone() throws Exception {
+
         ospfLsaList = new ArrayList();
-        ospfLsaList.add(new RouterLsa());
-        ospfMessage = new HelloPacket();
+        RouterLsa routerLsa = new RouterLsa();
+        routerLsa.setLsType(OspfLsaType.ROUTER.value());
+        ospfLsaList.add(routerLsa);
+        DdPacket ddPacket = new DdPacket();
+        ddPacket.setIsOpaqueCapable(true);
+        ospfMessage = ddPacket;
         ospfNbr.setState(OspfNeighborState.EXSTART);
+        ospfNbr.setIsOpaqueCapable(true);
+        channel = null;
         channel = EasyMock.createMock(Channel.class);
         ospfNbr.negotiationDone(ospfMessage, true, ospfLsaList, channel);
         channel1 = EasyMock.createMock(Channel.class);
@@ -230,7 +257,7 @@
     @Test
     public void testBadLSReq() throws Exception {
         channel = EasyMock.createMock(Channel.class);
-        ospfNbr.setState(OspfNeighborState.FULL);
+        ospfNbr.setState(OspfNeighborState.EXCHANGE);
         ospfNbr.badLSReq(channel);
         assertThat(ospfNbr, is(notNullValue()));
     }
@@ -294,11 +321,24 @@
     @Test
     public void testAdjOk() throws Exception {
         channel = EasyMock.createMock(Channel.class);
+        ospfInterface.setInterfaceType(OspfInterfaceType.BROADCAST.value());
         ospfInterface.setIpAddress(Ip4Address.valueOf("2.2.2.2"));
-        ospfNbr.setState(OspfNeighborState.TWOWAY);
-        ospfNbr.setNeighborDr(Ip4Address.valueOf("2.2.2.2"));
-        ospfNbr.adjOk(channel);
-        Assert.assertNotNull(ospfNbr);
+        ospfNbr1 = new OspfNbrImpl(ospfArea, ospfInterface, Ip4Address.valueOf("1.1.1.1"),
+                                   Ip4Address.valueOf("2.2.2.2"), 2,
+                                   topologyForDeviceAndLink);
+        ospfNbr1.setState(OspfNeighborState.TWOWAY);
+        ospfNbr1.setNeighborDr(Ip4Address.valueOf("2.2.2.2"));
+        ospfNbr1.adjOk(channel);
+        assertThat(ospfNbr1, is(notNullValue()));
+
+        ospfInterface.setInterfaceType(OspfInterfaceType.POINT_TO_POINT.value());
+        ospfNbr1 = new OspfNbrImpl(ospfArea, ospfInterface, Ip4Address.valueOf("1.1.1.1"),
+                                   Ip4Address.valueOf("2.2.2.2"), 2,
+                                   topologyForDeviceAndLink);
+        channel = null;
+        channel = EasyMock.createMock(Channel.class);
+        ospfNbr1.adjOk(channel);
+        assertThat(ospfNbr1, is(notNullValue()));
     }
 
     /**
@@ -321,8 +361,11 @@
      */
     @Test
     public void testLoadingDone() throws Exception {
-        ospfArea.addLsa(new RouterLsa(), false, ospfInterface);
-        ospfArea.addLsa(new RouterLsa(), ospfInterface);
+        LsaHeader lsaHeader = new LsaHeader();
+        lsaHeader.setLsType(OspfLsaType.ROUTER.value());
+        RouterLsa routerLsa = new RouterLsa(lsaHeader);
+        ospfArea.addLsa(routerLsa, false, ospfInterface);
+        ospfArea.addLsa(routerLsa, ospfInterface);
         ospfArea.addLsaToMaxAgeBin("lsa", new LsaWrapperImpl());
         ospfNbr.loadingDone();
         assertThat(ospfNbr, is(notNullValue()));
@@ -362,6 +405,7 @@
         channel1 = EasyMock.createMock(Channel.class);
         assertThat(ospfNbr.processReceivedLsa(routerlsa, true, channel1,
                                               Ip4Address.valueOf("10.10.10.10")), is(true));
+
     }
 
     /**
@@ -394,7 +438,7 @@
     @Test
     public void testSendLsa() throws Exception {
         channel = EasyMock.createMock(Channel.class);
-        ospfNbr.sendLsa(new LsaHeader(), Ip4Address.valueOf("1.1.1.1"), channel);
+        ospfNbr.sendLsa(lsaHeader, Ip4Address.valueOf("1.1.1.1"), channel);
         assertThat(ospfNbr, is(notNullValue()));
     }
 
@@ -648,4 +692,77 @@
     public void testGetPendingReTxList() throws Exception {
         assertThat(ospfNbr.getPendingReTxList(), is(notNullValue()));
     }
+
+    /**
+     * Utility for test method.
+     */
+    private OspfAreaImpl createOspfArea() throws UnknownHostException {
+        OspfAreaAddressRangeImpl ospfAreaAddressRange;
+        ospfAreaAddressRange = createOspfAreaAddressRange();
+        addressRanges.add(ospfAreaAddressRange);
+        OspfAreaImpl ospfArea = new OspfAreaImpl();
+        ospfArea.setAreaId(Ip4Address.valueOf("10.226.165.164"));
+        ospfArea.setExternalRoutingCapability(true);
+        OspfInterfaceImpl ospfInterface = createOspfInterface();
+        ospfInterfaces.add(ospfInterface);
+        ospfArea.setOspfInterfaceList(ospfInterfaces);
+        RouterLsa routerLsa = new RouterLsa();
+        routerLsa.setLsType(1);
+        routerLsa.setLinkStateId("2.2.2.2");
+        routerLsa.setAdvertisingRouter(Ip4Address.valueOf("2.2.2.2"));
+        OpaqueLsaHeader opaqueLsaHeader = new OpaqueLsaHeader();
+        OpaqueLsa10 opaqueLsa10 = new OpaqueLsa10(opaqueLsaHeader);
+        opaqueLsa10.setLsType(OspfLsaType.AREA_LOCAL_OPAQUE_LSA.value());
+        opaqueLsa10.setLinkStateId("2.2.2.2");
+        opaqueLsa10.setAdvertisingRouter(Ip4Address.valueOf("2.2.2.2"));
+        try {
+            ospfArea.addLsa(routerLsa, false, ospfInterface);
+            ospfArea.addLsa(opaqueLsa10, false, ospfInterface);
+        } catch (Exception e) {
+            System.out.println("ospfAreaImpl createOspfArea");
+        }
+        ospfArea.setRouterId(Ip4Address.valueOf("111.111.111.111"));
+
+        return ospfArea;
+    }
+
+    /**
+     * Utility for test method.
+     */
+    private OspfAreaAddressRangeImpl createOspfAreaAddressRange() {
+        OspfAreaAddressRangeImpl ospfAreaAddressRange = new OspfAreaAddressRangeImpl();
+        ospfAreaAddressRange.setIpAddress(Ip4Address.valueOf("10.226.165.164"));
+        ospfAreaAddressRange.setAdvertise(true);
+        ospfAreaAddressRange.setMask("mask");
+        return ospfAreaAddressRange;
+    }
+
+    /**
+     * Utility for test method.
+     */
+    private OspfInterfaceImpl createOspfInterface() throws UnknownHostException {
+        ospfInterface = new OspfInterfaceImpl();
+        OspfAreaImpl ospfArea = new OspfAreaImpl();
+        OspfInterfaceChannelHandler ospfInterfaceChannelHandler = EasyMock.createMock(
+                OspfInterfaceChannelHandler.class);
+        ospfNbr = new OspfNbrImpl(ospfArea, ospfInterface, Ip4Address.valueOf("10.226.165.164"),
+                                  Ip4Address.valueOf("1.1.1.1"), 2,
+                                  topologyForDeviceAndLink);
+        ospfNbr.setState(OspfNeighborState.EXSTART);
+        ospfNbr.setNeighborId(Ip4Address.valueOf("10.226.165.100"));
+        this.ospfInterface = new OspfInterfaceImpl();
+        this.ospfInterface.setIpAddress(Ip4Address.valueOf("10.226.165.164"));
+        this.ospfInterface.setIpNetworkMask(Ip4Address.valueOf("255.255.255.255"));
+        this.ospfInterface.setBdr(Ip4Address.valueOf("111.111.111.111"));
+        this.ospfInterface.setDr(Ip4Address.valueOf("111.111.111.111"));
+        this.ospfInterface.setHelloIntervalTime(20);
+        this.ospfInterface.setInterfaceType(2);
+        this.ospfInterface.setReTransmitInterval(2000);
+        this.ospfInterface.setMtu(6500);
+        this.ospfInterface.setRouterDeadIntervalTime(1000);
+        this.ospfInterface.setRouterPriority(1);
+        this.ospfInterface.setInterfaceType(1);
+        this.ospfInterface.addNeighbouringRouter(ospfNbr);
+        return this.ospfInterface;
+    }
 }
\ No newline at end of file
diff --git a/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/impl/OspfPipelineFactoryTest.java b/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/impl/OspfPipelineFactoryTest.java
index b4678a8..3357dc9 100755
--- a/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/impl/OspfPipelineFactoryTest.java
+++ b/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/impl/OspfPipelineFactoryTest.java
@@ -18,12 +18,6 @@
 import org.jboss.netty.channel.ChannelPipeline;
 import org.junit.After;
 import org.junit.Before;
-import org.junit.Test;
-import org.onosproject.ospf.controller.area.OspfAreaImpl;
-import org.onosproject.ospf.controller.area.OspfInterfaceImpl;
-
-import static org.hamcrest.CoreMatchers.*;
-import static org.hamcrest.MatcherAssert.assertThat;
 
 /**
  * Unit test class for OspfPipelineFactory.
@@ -35,8 +29,6 @@
 
     @Before
     public void setUp() throws Exception {
-        ospfPipelineFactory = new OspfPipelineFactory(new Controller(), new OspfAreaImpl(), new OspfInterfaceImpl());
-
     }
 
     @After
@@ -44,22 +36,4 @@
         ospfPipelineFactory = null;
         channelPipeline = null;
     }
-
-    /**
-     * Tests getPipeline() method.
-     */
-    @Test
-    public void testGetPipeline() throws Exception {
-        channelPipeline = ospfPipelineFactory.getPipeline();
-        assertThat(channelPipeline, is(notNullValue()));
-    }
-
-    /**
-     * Tests releaseExternalResources() method.
-     */
-    @Test
-    public void testReleaseExternalResources() throws Exception {
-        ospfPipelineFactory.releaseExternalResources();
-        assertThat(channelPipeline, is(nullValue()));
-    }
 }
\ No newline at end of file
diff --git a/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/lsdb/LsaQueueConsumerTest.java b/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/lsdb/LsaQueueConsumerTest.java
index 679e6cc..0145b01 100755
--- a/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/lsdb/LsaQueueConsumerTest.java
+++ b/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/lsdb/LsaQueueConsumerTest.java
@@ -74,8 +74,9 @@
     @Test
     public void testRun() throws Exception {
         blockingQueue = new ArrayBlockingQueue(5);
-        channel = EasyMock.createMock(Channel.class);
         ospfArea = new OspfAreaImpl();
+        lsdbAge = new LsdbAgeImpl(ospfArea);
+        channel = EasyMock.createMock(Channel.class);
         lsaWrapper = new LsaWrapperImpl();
         lsaWrapper.setLsaProcessing("verifyChecksum");
         blockingQueue.add(lsaWrapper);
@@ -104,7 +105,7 @@
         lsaHeader.setLsType(1);
         lsaWrapper.setLsaHeader(lsaHeader);
         lsaWrapper.setLsaProcessing("refreshLsa");
-        lsaWrapper.setLsdbAge(new LsdbAgeImpl(new OspfAreaImpl()));
+        lsaWrapper.setLsdbAge(new LsdbAgeImpl(ospfArea));
         blockingQueue.add(lsaWrapper);
         lsaQueueConsumer = new LsaQueueConsumer(blockingQueue, channel, ospfArea);
         lsaQueueConsumer.run();
@@ -128,7 +129,7 @@
         lsaHeader.setLsType(2);
         lsaWrapper.setLsaHeader(lsaHeader);
         lsaWrapper.setLsaProcessing("refreshLsa");
-        lsaWrapper.setLsdbAge(new LsdbAgeImpl(new OspfAreaImpl()));
+        lsaWrapper.setLsdbAge(new LsdbAgeImpl(ospfArea));
         blockingQueue.add(lsaWrapper);
         lsaQueueConsumer = new LsaQueueConsumer(blockingQueue, channel, ospfArea);
         lsaQueueConsumer.run();
@@ -155,7 +156,7 @@
         lsaHeader.setLsType(2);
         lsaWrapper.setLsaHeader(lsaHeader);
         lsaWrapper.setLsaProcessing("maxAgeLsa");
-        lsaWrapper.setLsdbAge(new LsdbAgeImpl(new OspfAreaImpl()));
+        lsaWrapper.setLsdbAge(new LsdbAgeImpl(ospfArea));
         blockingQueue.add(lsaWrapper);
         lsaQueueConsumer = new LsaQueueConsumer(blockingQueue, channel, ospfArea);
         lsaQueueConsumer.run();
@@ -168,7 +169,7 @@
     @Test
     public void testSetChannel() throws Exception {
         channel = EasyMock.createMock(Channel.class);
-        lsdbAge = new LsdbAgeImpl(new OspfAreaImpl());
+        lsdbAge = new LsdbAgeImpl(ospfArea);
         lsdbAge.startDbAging();
         lsdbAge.setChannel(channel);
         assertThat(lsaQueueConsumer, is(notNullValue()));
diff --git a/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/lsdb/LsdbAgeImplTest.java b/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/lsdb/LsdbAgeImplTest.java
index 65a79aa..fdde205 100755
--- a/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/lsdb/LsdbAgeImplTest.java
+++ b/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/lsdb/LsdbAgeImplTest.java
@@ -23,6 +23,7 @@
 import org.junit.Test;
 import org.onosproject.ospf.controller.LsaBin;
 import org.onosproject.ospf.controller.OspfArea;
+import org.onosproject.ospf.controller.OspfLsaType;
 import org.onosproject.ospf.controller.area.OspfAreaImpl;
 
 import static org.hamcrest.CoreMatchers.*;
@@ -181,14 +182,10 @@
     public void testRefereshLsa() throws Exception {
         lsaWrapper = EasyMock.createMock(LsaWrapperImpl.class);
         lsaWrapper.setBinNumber(0);
+        lsaWrapper.setLsaType(OspfLsaType.NETWORK);
         lsdbAge.addLsaToMaxAgeBin("lsa1", lsaWrapper);
         lsdbAge.ageLsaAndFlood();
-        lsaWrapper.setBinNumber(0);
-        lsaWrapper = EasyMock.createMock(LsaWrapperImpl.class);
-        lsdbAge.addLsaToMaxAgeBin("lsa2", lsaWrapper);
-        lsdbAge.ageLsaAndFlood();
         lsdbAge.startDbAging();
-        lsaBin = new LsaBinImpl(1809);
         lsdbAge.refreshLsa();
         assertThat(lsdbAge, is(notNullValue()));
     }
diff --git a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/exceptions/OspfErrorType.java b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/exceptions/OspfErrorType.java
old mode 100644
new mode 100755
diff --git a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/exceptions/OspfParseException.java b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/exceptions/OspfParseException.java
old mode 100644
new mode 100755
diff --git a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/exceptions/package-info.java b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/exceptions/package-info.java
old mode 100644
new mode 100755
diff --git a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/package-info.java b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/package-info.java
old mode 100644
new mode 100755
diff --git a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/LsaHeader.java b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/LsaHeader.java
old mode 100644
new mode 100755
diff --git a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/OpaqueLsaHeader.java b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/OpaqueLsaHeader.java
old mode 100644
new mode 100755
index da37bb1..ac27445
--- a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/OpaqueLsaHeader.java
+++ b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/OpaqueLsaHeader.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2016-present Open Networking Laboratory
+ * Copyright 2016 Open Networking Laboratory
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/TlvHeader.java b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/TlvHeader.java
old mode 100644
new mode 100755
diff --git a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/linksubtype/AdministrativeGroup.java b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/linksubtype/AdministrativeGroup.java
old mode 100644
new mode 100755
diff --git a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/linksubtype/LinkId.java b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/linksubtype/LinkId.java
old mode 100644
new mode 100755
diff --git a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/linksubtype/LinkSubType.java b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/linksubtype/LinkSubType.java
old mode 100644
new mode 100755
diff --git a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/linksubtype/LinkSubTypes.java b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/linksubtype/LinkSubTypes.java
old mode 100644
new mode 100755
diff --git a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/linksubtype/LinkType.java b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/linksubtype/LinkType.java
old mode 100644
new mode 100755
diff --git a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/linksubtype/LocalInterfaceIpAddress.java b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/linksubtype/LocalInterfaceIpAddress.java
old mode 100644
new mode 100755
diff --git a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/linksubtype/MaximumBandwidth.java b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/linksubtype/MaximumBandwidth.java
old mode 100644
new mode 100755
diff --git a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/linksubtype/MaximumReservableBandwidth.java b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/linksubtype/MaximumReservableBandwidth.java
old mode 100644
new mode 100755
diff --git a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/linksubtype/RemoteInterfaceIpAddress.java b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/linksubtype/RemoteInterfaceIpAddress.java
old mode 100644
new mode 100755
diff --git a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/linksubtype/TrafficEngineeringMetric.java b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/linksubtype/TrafficEngineeringMetric.java
old mode 100644
new mode 100755
diff --git a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/linksubtype/UnknownLinkSubType.java b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/linksubtype/UnknownLinkSubType.java
old mode 100644
new mode 100755
diff --git a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/linksubtype/UnreservedBandwidth.java b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/linksubtype/UnreservedBandwidth.java
old mode 100644
new mode 100755
diff --git a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/linksubtype/package-info.java b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/linksubtype/package-info.java
old mode 100644
new mode 100755
diff --git a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/package-info.java b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/package-info.java
old mode 100644
new mode 100755
diff --git a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/subtypes/OspfExternalDestination.java b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/subtypes/OspfExternalDestination.java
old mode 100644
new mode 100755
diff --git a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/subtypes/OspfLsaLink.java b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/subtypes/OspfLsaLink.java
old mode 100644
new mode 100755
diff --git a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/subtypes/package-info.java b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/subtypes/package-info.java
old mode 100644
new mode 100755
diff --git a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/tlvtypes/LinkTlv.java b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/tlvtypes/LinkTlv.java
old mode 100644
new mode 100755
diff --git a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/tlvtypes/OpaqueTopLevelTlvTypes.java b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/tlvtypes/OpaqueTopLevelTlvTypes.java
old mode 100644
new mode 100755
diff --git a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/tlvtypes/RouterTlv.java b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/tlvtypes/RouterTlv.java
old mode 100644
new mode 100755
diff --git a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/tlvtypes/package-info.java b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/tlvtypes/package-info.java
old mode 100644
new mode 100755
diff --git a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/types/AsbrSummaryLsa.java b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/types/AsbrSummaryLsa.java
old mode 100644
new mode 100755
diff --git a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/types/ExternalLsa.java b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/types/ExternalLsa.java
old mode 100644
new mode 100755
diff --git a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/types/NetworkLsa.java b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/types/NetworkLsa.java
old mode 100644
new mode 100755
index 596c593..f389170
--- a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/types/NetworkLsa.java
+++ b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/types/NetworkLsa.java
@@ -103,6 +103,16 @@
     }
 
     /**
+     * Gets the list of attached routers.
+     *
+     * @return list of attached routers
+     */
+    public List<Ip4Address> attachedRouters() {
+
+        return attachedRouters;
+    }
+
+    /**
      * Reads from channel buffer and populate instance.
      *
      * @param channelBuffer channel buffer instance
diff --git a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/types/OpaqueLsa10.java b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/types/OpaqueLsa10.java
old mode 100644
new mode 100755
index 7cdce93..df9c8f5
--- a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/types/OpaqueLsa10.java
+++ b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/types/OpaqueLsa10.java
@@ -29,7 +29,6 @@
 import org.onosproject.ospf.protocol.lsa.tlvtypes.RouterTlv;
 import org.onosproject.ospf.protocol.util.OspfParameters;
 
-import java.util.Arrays;
 import java.util.ArrayList;
 import java.util.List;
 
@@ -193,11 +192,11 @@
         }
         OpaqueLsa10 that = (OpaqueLsa10) o;
         return Objects.equal(topLevelValues, that.topLevelValues) &&
-                            Arrays.equals(opaqueInfo, that.opaqueInfo);
+                Objects.equal(opaqueInfo, that.opaqueInfo);
     }
 
     @Override
     public int hashCode() {
-        return Objects.hashCode(Arrays.hashCode(opaqueInfo), topLevelValues);
+        return Objects.hashCode(opaqueInfo, topLevelValues);
     }
 }
\ No newline at end of file
diff --git a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/types/OpaqueLsa11.java b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/types/OpaqueLsa11.java
old mode 100644
new mode 100755
index fb982fa..3f5d56a
--- a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/types/OpaqueLsa11.java
+++ b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/types/OpaqueLsa11.java
@@ -16,13 +16,12 @@
 package org.onosproject.ospf.protocol.lsa.types;
 
 import com.google.common.base.MoreObjects;
+import com.google.common.base.Objects;
 import com.google.common.primitives.Bytes;
 import org.jboss.netty.buffer.ChannelBuffer;
 import org.onosproject.ospf.controller.OspfLsaType;
 import org.onosproject.ospf.protocol.lsa.OpaqueLsaHeader;
 
-import java.util.Arrays;
-
 /**
  * Representation of an Opaque LSA of type AS (11).
  */
@@ -107,12 +106,12 @@
             return false;
         }
         OpaqueLsa11 that = (OpaqueLsa11) o;
-        return Arrays.equals(opaqueInfo, that.opaqueInfo);
+        return Objects.equal(opaqueInfo, that.opaqueInfo);
     }
 
     @Override
     public int hashCode() {
-        return Arrays.hashCode(opaqueInfo);
+        return Objects.hashCode(opaqueInfo);
     }
 
     @Override
diff --git a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/types/OpaqueLsa9.java b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/types/OpaqueLsa9.java
old mode 100644
new mode 100755
index 1bff5e0..5b60684
--- a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/types/OpaqueLsa9.java
+++ b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/types/OpaqueLsa9.java
@@ -16,13 +16,12 @@
 package org.onosproject.ospf.protocol.lsa.types;
 
 import com.google.common.base.MoreObjects;
+import com.google.common.base.Objects;
 import com.google.common.primitives.Bytes;
 import org.jboss.netty.buffer.ChannelBuffer;
 import org.onosproject.ospf.controller.OspfLsaType;
 import org.onosproject.ospf.protocol.lsa.OpaqueLsaHeader;
 
-import java.util.Arrays;
-
 /**
  * Representation of an Opaque LSA of type link local (9).
  */
@@ -109,12 +108,12 @@
             return false;
         }
         OpaqueLsa9 that = (OpaqueLsa9) o;
-        return Arrays.equals(opaqueInfo, that.opaqueInfo);
+        return Objects.equal(opaqueInfo, that.opaqueInfo);
     }
 
     @Override
     public int hashCode() {
-        return Arrays.hashCode(opaqueInfo);
+        return Objects.hashCode(opaqueInfo);
     }
 
     @Override
diff --git a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/types/RouterLsa.java b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/types/RouterLsa.java
old mode 100644
new mode 100755
diff --git a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/types/SummaryLsa.java b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/types/SummaryLsa.java
old mode 100644
new mode 100755
diff --git a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/types/TopLevelTlv.java b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/types/TopLevelTlv.java
old mode 100644
new mode 100755
diff --git a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/types/package-info.java b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/types/package-info.java
old mode 100644
new mode 100755
diff --git a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/ospfpacket/OspfMessageReader.java b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/ospfpacket/OspfMessageReader.java
old mode 100644
new mode 100755
index c07e2ab..cd62374
--- a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/ospfpacket/OspfMessageReader.java
+++ b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/ospfpacket/OspfMessageReader.java
@@ -18,6 +18,7 @@
 
 import org.jboss.netty.buffer.ChannelBuffer;
 import org.onlab.packet.Ip4Address;
+import org.onosproject.ospf.controller.OspfMessage;
 import org.onosproject.ospf.exceptions.OspfErrorType;
 import org.onosproject.ospf.exceptions.OspfParseException;
 import org.onosproject.ospf.protocol.ospfpacket.types.DdPacket;
@@ -46,15 +47,8 @@
     public OspfMessage readFromBuffer(ChannelBuffer channelBuffer)
             throws Exception {
 
-        if (channelBuffer.readableBytes() < OspfUtil.PACKET_MINIMUM_LENGTH) {
-            log.error("Packet should have minimum length...");
-            throw new OspfParseException(OspfErrorType.MESSAGE_HEADER_ERROR, OspfErrorType.BAD_MESSAGE_LENGTH);
-        }
-
         try {
             OspfPacketHeader ospfHeader = getOspfHeader(channelBuffer);
-            int len = ospfHeader.ospfPacLength() - OspfUtil.OSPF_HEADER_LENGTH;
-
             OspfMessage ospfMessage = null;
             switch (ospfHeader.ospfType()) {
                 case OspfParameters.HELLO:
@@ -81,7 +75,8 @@
                 try {
                     log.debug("{} Received::Message Length :: {} ", ospfMessage.ospfMessageType(),
                               ospfHeader.ospfPacLength());
-                    ospfMessage.readFrom(channelBuffer.readBytes(len));
+                    ospfMessage.readFrom(channelBuffer.readBytes(ospfHeader.ospfPacLength() -
+                                                                         OspfUtil.OSPF_HEADER_LENGTH));
                 } catch (Exception e) {
                     throw new OspfParseException(OspfErrorType.OSPF_MESSAGE_ERROR,
                                                  OspfErrorType.BAD_MESSAGE);
@@ -105,22 +100,13 @@
     private OspfPacketHeader getOspfHeader(ChannelBuffer channelBuffer) throws Exception {
         OspfPacketHeader ospfPacketHeader = new OspfPacketHeader();
 
-        byte[] sourceIpBytes = new byte[OspfUtil.FOUR_BYTES];
-        channelBuffer.readBytes(sourceIpBytes, 0, OspfUtil.FOUR_BYTES);
-        Ip4Address sourceIP = Ip4Address.valueOf(sourceIpBytes);
-
-        // Determine ospf version & Packet Type
+        // Determine OSPF version & Packet Type
         int version = channelBuffer.readByte(); //byte 1 is ospf version
         int packetType = channelBuffer.readByte(); //byte 2 is ospf packet type
 
         // byte 3 & 4 combine is packet length.
         int packetLength = channelBuffer.readShort();
 
-        if (packetLength > channelBuffer.readableBytes() + OspfUtil.FOUR_BYTES) {
-            log.error("Packet should have minimum length...");
-            throw new OspfParseException(OspfErrorType.MESSAGE_HEADER_ERROR, OspfErrorType.BAD_MESSAGE_LENGTH);
-        }
-
         byte[] tempByteArray = new byte[OspfUtil.FOUR_BYTES];
         channelBuffer.readBytes(tempByteArray, 0, OspfUtil.FOUR_BYTES);
         Ip4Address routerId = Ip4Address.valueOf(tempByteArray);
@@ -133,7 +119,6 @@
         int auType = channelBuffer.readUnsignedShort();
         int authentication = (int) channelBuffer.readLong();
 
-        ospfPacketHeader.setSourceIp(sourceIP);
         ospfPacketHeader.setOspfVer(version);
         ospfPacketHeader.setOspftype(packetType);
         ospfPacketHeader.setOspfPacLength(packetLength);
diff --git a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/ospfpacket/OspfMessageWriter.java b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/ospfpacket/OspfMessageWriter.java
old mode 100644
new mode 100755
index 6e0f502..b89d860
--- a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/ospfpacket/OspfMessageWriter.java
+++ b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/ospfpacket/OspfMessageWriter.java
@@ -1,5 +1,5 @@
 /*
-* Copyright 2016-present Open Networking Laboratory
+* Copyright 2016 Open Networking Laboratory
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
@@ -15,41 +15,36 @@
 */
 package org.onosproject.ospf.protocol.ospfpacket;
 
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
+import org.onosproject.ospf.controller.OspfMessage;
 import org.onosproject.ospf.protocol.util.OspfParameters;
 import org.onosproject.ospf.protocol.util.OspfUtil;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 /**
- * A message writer which writes an OspfMessage to ChannelBuffer.
+ * A message writer which writes an OSPF message to byte array.
  */
 public class OspfMessageWriter {
     private static final Logger log = LoggerFactory.getLogger(OspfMessageWriter.class);
 
     /**
-     * Writes OSPF message to ChannelBuffer.
+     * Writes OSPF message to byte array.
      *
      * @param ospfMessage    OSPF message
+     * @param interfaceIndex interface index
      * @param interfaceState interface state
-     * @param interfaceType  interface type
-     * @return channelBuffer channel buffer instance
-     * @throws Exception might throws exception while parsing message
+     * @return message as byte array
      */
-    public ChannelBuffer writeToBuffer(OspfMessage ospfMessage, int interfaceState,
-                                       int interfaceType) throws Exception {
+    public byte[] getMessage(OspfMessage ospfMessage, int interfaceIndex, int interfaceState) {
 
-        ChannelBuffer buf = null;
+        byte[] buf = null;
         switch (ospfMessage.ospfMessageType().value()) {
             case OspfParameters.HELLO:
             case OspfParameters.LSACK:
-                buf = writeMessageToBuffer(ospfMessage, interfaceState);
-                break;
             case OspfParameters.DD:
             case OspfParameters.LSREQUEST:
             case OspfParameters.LSUPDATE:
-                buf = writeMessageToBuffer(ospfMessage, interfaceState);
+                buf = writeMessageToBytes(ospfMessage, interfaceIndex, interfaceState);
                 break;
             default:
                 log.debug("Message Writer[Encoder] - Unknown Message to encode..!!!");
@@ -60,14 +55,13 @@
     }
 
     /**
-     * Writes an OSPF Message to channel buffer.
+     * Writes an OSPF Message to byte array.
      *
      * @param ospfMessage    OSPF Message instance
      * @param interfaceState interface state
-     * @return channelBuffer instance
+     * @return message as byte array
      */
-    private ChannelBuffer writeMessageToBuffer(OspfMessage ospfMessage, int interfaceState) throws Exception {
-        ChannelBuffer channelBuffer = null;
+    private byte[] writeMessageToBytes(OspfMessage ospfMessage, int interfaceIndex, int interfaceState) {
         byte[] ospfMessageAsByte = ospfMessage.asBytes();
         //Add the length and checksum in byte array at length position 2 & 3 and Checksum position
         ospfMessageAsByte = OspfUtil.addLengthAndCheckSum(ospfMessageAsByte, OspfUtil.OSPFPACKET_LENGTH_POS1,
@@ -76,16 +70,13 @@
                                                           OspfUtil.OSPFPACKET_CHECKSUM_POS2);
         //Add Interface State Info and destination IP as metadata
         if (interfaceState == OspfParameters.DR || interfaceState == OspfParameters.BDR) {
-            ospfMessageAsByte = OspfUtil.addMetadata(ospfMessageAsByte, OspfUtil.JOIN_ALL_DROUTERS,
+            ospfMessageAsByte = OspfUtil.addMetadata(interfaceIndex, ospfMessageAsByte, OspfUtil.JOIN_ALL_DROUTERS,
                                                      ospfMessage.destinationIp());
         } else {
-            ospfMessageAsByte = OspfUtil.addMetadata(ospfMessageAsByte, OspfUtil.ONLY_ALL_SPF_ROUTERS,
+            ospfMessageAsByte = OspfUtil.addMetadata(interfaceIndex, ospfMessageAsByte, OspfUtil.ONLY_ALL_SPF_ROUTERS,
                                                      ospfMessage.destinationIp());
         }
 
-        channelBuffer = ChannelBuffers.buffer(ospfMessageAsByte.length);
-        channelBuffer.writeBytes(ospfMessageAsByte);
-
-        return channelBuffer;
+        return ospfMessageAsByte;
     }
 }
\ No newline at end of file
diff --git a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/ospfpacket/OspfPacketHeader.java b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/ospfpacket/OspfPacketHeader.java
old mode 100644
new mode 100755
index a57e444..556ce5c
--- a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/ospfpacket/OspfPacketHeader.java
+++ b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/ospfpacket/OspfPacketHeader.java
@@ -18,8 +18,9 @@
 import com.google.common.base.MoreObjects;
 import org.jboss.netty.buffer.ChannelBuffer;
 import org.onlab.packet.Ip4Address;
+import org.onosproject.ospf.controller.OspfMessage;
+import org.onosproject.ospf.controller.OspfPacketType;
 import org.onosproject.ospf.exceptions.OspfParseException;
-import org.onosproject.ospf.protocol.util.OspfPacketType;
 
 /**
  * Defines the OSPF Packet Header, fields and access methods.
@@ -57,6 +58,7 @@
     private int authentication;
     private Ip4Address destinationIp;
     private Ip4Address sourceIp;
+    private int interfaceIndex;
 
     /**
      * Gets the source IP.
@@ -256,11 +258,30 @@
     }
 
     /**
+     * Returns the interface index on which the message received.
+     *
+     * @return interface index on which the message received
+     */
+    public int interfaceIndex() {
+        return interfaceIndex;
+    }
+
+    /**
+     * Sets the interface index on which the message received.
+     *
+     * @param interfaceIndex interface index on which the message received
+     */
+    public void setInterfaceIndex(int interfaceIndex) {
+        this.interfaceIndex = interfaceIndex;
+    }
+
+    /**
      * Populates the header from the packetHeader instance.
      *
      * @param ospfPacketHeader packet header instance.
      */
     public void populateHeader(OspfPacketHeader ospfPacketHeader) {
+        this.setInterfaceIndex(ospfPacketHeader.interfaceIndex());
         this.setSourceIp(ospfPacketHeader.sourceIp());
         this.setOspfVer(ospfPacketHeader.ospfVersion());
         this.setOspftype(ospfPacketHeader.ospfType());
diff --git a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/ospfpacket/package-info.java b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/ospfpacket/package-info.java
old mode 100644
new mode 100755
diff --git a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/ospfpacket/subtype/LsRequestPacket.java b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/ospfpacket/subtype/LsRequestPacket.java
old mode 100644
new mode 100755
diff --git a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/ospfpacket/subtype/package-info.java b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/ospfpacket/subtype/package-info.java
old mode 100644
new mode 100755
diff --git a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/ospfpacket/types/DdPacket.java b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/ospfpacket/types/DdPacket.java
old mode 100644
new mode 100755
index dbadad7..2a78df7
--- a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/ospfpacket/types/DdPacket.java
+++ b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/ospfpacket/types/DdPacket.java
@@ -23,7 +23,7 @@
 import org.onosproject.ospf.protocol.lsa.LsaHeader;
 import org.onosproject.ospf.protocol.lsa.OpaqueLsaHeader;
 import org.onosproject.ospf.protocol.ospfpacket.OspfPacketHeader;
-import org.onosproject.ospf.protocol.util.OspfPacketType;
+import org.onosproject.ospf.controller.OspfPacketType;
 import org.onosproject.ospf.protocol.util.OspfParameters;
 import org.onosproject.ospf.protocol.util.OspfUtil;
 import org.slf4j.Logger;
diff --git a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/ospfpacket/types/HelloPacket.java b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/ospfpacket/types/HelloPacket.java
old mode 100644
new mode 100755
index 1c0ae16..a21ff6c
--- a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/ospfpacket/types/HelloPacket.java
+++ b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/ospfpacket/types/HelloPacket.java
@@ -22,7 +22,7 @@
 import org.onosproject.ospf.exceptions.OspfErrorType;
 import org.onosproject.ospf.exceptions.OspfParseException;
 import org.onosproject.ospf.protocol.ospfpacket.OspfPacketHeader;
-import org.onosproject.ospf.protocol.util.OspfPacketType;
+import org.onosproject.ospf.controller.OspfPacketType;
 import org.onosproject.ospf.protocol.util.OspfUtil;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
diff --git a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/ospfpacket/types/LsAcknowledge.java b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/ospfpacket/types/LsAcknowledge.java
old mode 100644
new mode 100755
index 4c6f993..0f2edff
--- a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/ospfpacket/types/LsAcknowledge.java
+++ b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/ospfpacket/types/LsAcknowledge.java
@@ -23,7 +23,7 @@
 import org.onosproject.ospf.protocol.lsa.LsaHeader;
 import org.onosproject.ospf.protocol.lsa.OpaqueLsaHeader;
 import org.onosproject.ospf.protocol.ospfpacket.OspfPacketHeader;
-import org.onosproject.ospf.protocol.util.OspfPacketType;
+import org.onosproject.ospf.controller.OspfPacketType;
 import org.onosproject.ospf.protocol.util.OspfParameters;
 import org.onosproject.ospf.protocol.util.OspfUtil;
 import org.slf4j.Logger;
diff --git a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/ospfpacket/types/LsRequest.java b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/ospfpacket/types/LsRequest.java
old mode 100644
new mode 100755
index 630edac..efa329a
--- a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/ospfpacket/types/LsRequest.java
+++ b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/ospfpacket/types/LsRequest.java
@@ -22,7 +22,7 @@
 import org.onosproject.ospf.exceptions.OspfParseException;
 import org.onosproject.ospf.protocol.ospfpacket.OspfPacketHeader;
 import org.onosproject.ospf.protocol.ospfpacket.subtype.LsRequestPacket;
-import org.onosproject.ospf.protocol.util.OspfPacketType;
+import org.onosproject.ospf.controller.OspfPacketType;
 import org.onosproject.ospf.protocol.util.OspfUtil;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
diff --git a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/ospfpacket/types/LsUpdate.java b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/ospfpacket/types/LsUpdate.java
old mode 100644
new mode 100755
index bb7858e..706e9d2
--- a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/ospfpacket/types/LsUpdate.java
+++ b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/ospfpacket/types/LsUpdate.java
@@ -32,7 +32,7 @@
 import org.onosproject.ospf.protocol.lsa.types.RouterLsa;
 import org.onosproject.ospf.protocol.lsa.types.SummaryLsa;
 import org.onosproject.ospf.protocol.ospfpacket.OspfPacketHeader;
-import org.onosproject.ospf.protocol.util.OspfPacketType;
+import org.onosproject.ospf.controller.OspfPacketType;
 import org.onosproject.ospf.protocol.util.OspfParameters;
 import org.onosproject.ospf.protocol.util.OspfUtil;
 import org.slf4j.Logger;
diff --git a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/ospfpacket/types/package-info.java b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/ospfpacket/types/package-info.java
old mode 100644
new mode 100755
diff --git a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/package-info.java b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/package-info.java
old mode 100644
new mode 100755
diff --git a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/util/ChecksumCalculator.java b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/util/ChecksumCalculator.java
old mode 100644
new mode 100755
index 7b0140a..7ba504f
--- a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/util/ChecksumCalculator.java
+++ b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/util/ChecksumCalculator.java
@@ -25,7 +25,7 @@
 import org.onosproject.ospf.protocol.lsa.types.OpaqueLsa9;
 import org.onosproject.ospf.protocol.lsa.types.RouterLsa;
 import org.onosproject.ospf.protocol.lsa.types.SummaryLsa;
-import org.onosproject.ospf.protocol.ospfpacket.OspfMessage;
+import org.onosproject.ospf.controller.OspfMessage;
 import org.onosproject.ospf.protocol.ospfpacket.types.DdPacket;
 import org.onosproject.ospf.protocol.ospfpacket.types.HelloPacket;
 import org.onosproject.ospf.protocol.ospfpacket.types.LsAcknowledge;
diff --git a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/util/OspfInterfaceState.java b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/util/OspfInterfaceState.java
old mode 100644
new mode 100755
index 82a00f0..a8036b5
--- a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/util/OspfInterfaceState.java
+++ b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/util/OspfInterfaceState.java
@@ -31,20 +31,55 @@
     private int value;
 
     /**
-     * Creates an instance of Interface State.
+     * Creates an instance of interface state.
      *
-     * @param value Interface State value
+     * @param value Interface state value
      */
     OspfInterfaceState(int value) {
         this.value = value;
     }
 
     /**
-     * Gets value for Interface State.
+     * Gets value for Interface state.
      *
-     * @return value Interface State
+     * @return value Interface state
      */
     public int value() {
         return value;
     }
+
+    /**
+     * Gets interface state.
+     *
+     * @return interface state
+     */
+    public String interfaceState() {
+        String state = null;
+        switch (value) {
+            case 1:
+                state = "DOWN";
+                break;
+            case 2:
+                state = "LOOPBACK";
+                break;
+            case 3:
+                state = "WAITING";
+                break;
+            case 4:
+                state = "POINT2POINT";
+                break;
+            case 5:
+                state = "DROTHER";
+                break;
+            case 6:
+                state = "BDR";
+                break;
+            case 7:
+                state = "DR";
+                break;
+            default:
+                break;
+        }
+        return state;
+    }
 }
\ No newline at end of file
diff --git a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/util/OspfParameters.java b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/util/OspfParameters.java
old mode 100644
new mode 100755
diff --git a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/util/OspfUtil.java b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/util/OspfUtil.java
old mode 100644
new mode 100755
index 5372804..4509d32
--- a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/util/OspfUtil.java
+++ b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/util/OspfUtil.java
@@ -36,10 +36,11 @@
  * Representation of an OSPF constants and utility methods.
  */
 public final class OspfUtil {
-
     public static final int OSPF_VERSION_2 = 2;
     public static final int OSPF_VERSION = OSPF_VERSION_2;
     public static final int PACKET_MINIMUM_LENGTH = 24;
+    public static final int METADATA_LEN = 5;
+    public static final int MINIMUM_FRAME_LEN = 1487;
     public static final int OSPF_HEADER_LENGTH = 24;
     public static final int LSA_HEADER_LENGTH = 20;
     public static final int DD_HEADER_LENGTH = OSPF_HEADER_LENGTH + 8;
@@ -52,6 +53,8 @@
     public static final int LSAPACKET_CHECKSUM_POS2 = 17;
     public static final Ip4Address ALL_SPF_ROUTERS = Ip4Address.valueOf("224.0.0.5");
     public static final Ip4Address ALL_DROUTERS = Ip4Address.valueOf("224.0.0.6");
+    public static final Ip4Address DEFAULTIP = Ip4Address.valueOf("0.0.0.0");
+    public static final int RETRANSMITINTERVAL = 5;
     public static final int ONLY_ALL_SPF_ROUTERS = 1;
     public static final int JOIN_ALL_DROUTERS = 2;
     public static final int INITIALIZE_SET = 1;
@@ -62,9 +65,16 @@
     public static final int NOT_MASTER = 0;
     public static final int NOT_ASSIGNED = 0;
     public static final int FOUR_BYTES = 4;
+    public static final int FIVE_BYTES = 5;
     public static final int EIGHT_BYTES = 8;
     public static final int TWELVE_BYTES = 12;
     public static final int EXTERNAL_DESTINATION_LENGTH = 12;
+    public static final String SHOST = "127.0.0.1";
+    public static final int SPORT = 7000;
+    public static final int MTU = 1500;
+    public static final char CONFIG_LENGTH = 1498;
+    public static final char ROUTER_PRIORITY = 0;
+    public static final int HELLO_PACKET_OPTIONS = 2;
     private static final Logger log =
             LoggerFactory.getLogger(OspfUtil.class);
 
@@ -398,18 +408,21 @@
     /**
      * Adds metadata to ospf packet like whether to join multi cast group and destination IP.
      *
+     * @param interfaceIndex   interface index
      * @param ospfPacket       OSPF packet
      * @param allDroutersValue whether to join multi cast or not
      * @param destinationIp    destination ip address
      * @return byte array
      */
-    public static byte[] addMetadata(byte[] ospfPacket, int allDroutersValue, Ip4Address destinationIp) {
+    public static byte[] addMetadata(int interfaceIndex, byte[] ospfPacket, int allDroutersValue,
+                                     Ip4Address destinationIp) {
         byte[] packet;
+        byte[] interfaceIndexByteVal = {(byte) interfaceIndex};
         byte[] allDroutersByteVal = {(byte) allDroutersValue};
         byte[] destIpAsBytes = destinationIp.toOctets();
-        byte[] metadata = Bytes.concat(allDroutersByteVal, destIpAsBytes);
-
-        packet = Bytes.concat(metadata, ospfPacket);
+        byte[] metadata = Bytes.concat(interfaceIndexByteVal, allDroutersByteVal);
+        metadata = Bytes.concat(metadata, destIpAsBytes);
+        packet = Bytes.concat(ospfPacket, metadata);
 
         return packet;
     }
diff --git a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/util/package-info.java b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/util/package-info.java
old mode 100644
new mode 100755
diff --git a/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/ospfpacket/OspfMessageReaderTest.java b/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/ospfpacket/OspfMessageReaderTest.java
index a2d5ca1..d390af2 100644
--- a/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/ospfpacket/OspfMessageReaderTest.java
+++ b/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/ospfpacket/OspfMessageReaderTest.java
@@ -20,6 +20,7 @@
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
+import org.onosproject.ospf.protocol.util.OspfUtil;
 
 import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.CoreMatchers.notNullValue;
@@ -31,17 +32,17 @@
 
 public class OspfMessageReaderTest {
 
-    private final byte[] packet1 = {1, 1, 1, 1, 2, 1, 0, 44, -64, -88, -86, 8,
+    private final byte[] packet1 = {2, 1, 0, 44, -64, -88, -86, 8,
             0, 0, 0, 1, 39, 59, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1, -1, 0, 0,
             10, 2, 1, 0, 0, 0, 40, -64, -88, -86, 8, 0, 0, 0, 0};
-    private final byte[] packet2 = {1, 1, 1, 1, 2, 2, 0, 52, -64, -88, -86, 8, 0,
+    private final byte[] packet2 = {2, 2, 0, 52, -64, -88, -86, 8, 0,
             0, 0, 1, -96, 82, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, -36, 2, 7, 65, 119,
             -87, 126, 0, 23, 2, 1, 10, 10, 10, 10, 10, 10, 10, 10, -128, 0, 0, 6,
             -69, 26, 0, 36};
-    private final byte[] packet3 = {1, 1, 1, 1, 2, 3, 0, 36, -64, -88, -86, 3, 0,
+    private final byte[] packet3 = {2, 3, 0, 36, -64, -88, -86, 3, 0,
             0, 0, 1, -67, -57, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, -64, -88,
             -86, 8, -64, -88, -86, 8};
-    private final byte[] packet4 = {1, 1, 1, 1, 2, 4, 1, 36, -64, -88, -86, 3, 0,
+    private final byte[] packet4 = {2, 4, 1, 36, -64, -88, -86, 3, 0,
             0, 0, 1, 54, 107, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 0,
             2, 2, 1, -64, -88, -86, 3, -64, -88, -86, 3, -128, 0,
             0, 1, 58, -100, 0, 48, 2, 0, 0, 2, -64, -88, -86,
@@ -62,7 +63,7 @@
             0, 0, 0, 0, 0, 0, 0, 3, 2, 5, -64, -88, -84, 0, -64,
             -88, -86, 2, -128, 0, 0, 1, 51, 65, 0, 36, -1, -1, -1, 0,
             -128, 0, 0, 20, -64, -88, -86, 10, 0, 0, 0, 0};
-    private final byte[] packet5 = {1, 1, 1, 1, 2, 5, 0, 44, -64, -88, -86, 8, 0, 0,
+    private final byte[] packet5 = {2, 5, 0, 44, -64, -88, -86, 8, 0, 0,
             0, 1, -30, -12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 14, 16, 2, 1, -64, -88, -86,
             2, -64, -88, -86, 2, -128, 0, 0, 1, 74, -114, 0, 48};
     private OspfMessageReader ospfMessageReader;
@@ -84,21 +85,39 @@
      */
     @Test
     public void testReadFromBuffer() throws Exception {
-        channelBuffer = ChannelBuffers.copiedBuffer(packet1);
+        channelBuffer = ChannelBuffers.copiedBuffer(framePacket(packet1));
         ospfMessageReader.readFromBuffer(channelBuffer);
 
-        channelBuffer = ChannelBuffers.copiedBuffer(packet2);
+        channelBuffer = ChannelBuffers.copiedBuffer(framePacket(packet2));
         ospfMessageReader.readFromBuffer(channelBuffer);
 
-        channelBuffer = ChannelBuffers.copiedBuffer(packet3);
+        channelBuffer = ChannelBuffers.copiedBuffer(framePacket(packet3));
         ospfMessageReader.readFromBuffer(channelBuffer);
 
-        channelBuffer = ChannelBuffers.copiedBuffer(packet4);
+        channelBuffer = ChannelBuffers.copiedBuffer(framePacket(packet4));
         ospfMessageReader.readFromBuffer(channelBuffer);
 
-        channelBuffer = ChannelBuffers.copiedBuffer(packet5);
+        channelBuffer = ChannelBuffers.copiedBuffer(framePacket(packet5));
         ospfMessageReader.readFromBuffer(channelBuffer);
         assertThat(ospfMessageReader, is(notNullValue()));
+    }
 
+    /**
+     * Frames the packet to min frame length.
+     *
+     * @param ospfPacket OSPF packet
+     * @return OSPF packet as byte array
+     */
+    private byte[] framePacket(byte[] ospfPacket) {
+        //Set the length of the packet
+        //Get the total length of the packet
+        int length = ospfPacket.length;
+        //PDU_LENGTH + 1 byte for interface index
+        if (length < OspfUtil.MINIMUM_FRAME_LEN) {
+            byte[] bytes = new byte[OspfUtil.MINIMUM_FRAME_LEN + 5];
+            System.arraycopy(ospfPacket, 0, bytes, 0, length);
+            return bytes;
+        }
+        return ospfPacket;
     }
 }
\ No newline at end of file
diff --git a/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/ospfpacket/OspfMessageWriterTest.java b/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/ospfpacket/OspfMessageWriterTest.java
index 4208a06..bc0563d 100644
--- a/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/ospfpacket/OspfMessageWriterTest.java
+++ b/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/ospfpacket/OspfMessageWriterTest.java
@@ -57,10 +57,10 @@
     }
 
     /**
-     * Tests writeToBuffer() method.
+     * Tests getMessage() method.
      */
     @Test
-    public void testWriteToBuffer() throws Exception {
+    public void testGetMessage() throws Exception {
         helloPacket = new HelloPacket();
         helloPacket.setAuthType(1);
         helloPacket.setOspftype(1);
@@ -79,12 +79,12 @@
         helloPacket.setBdr(Ip4Address.valueOf("2.2.2.2"));
         helloPacket.addNeighbor(Ip4Address.valueOf("8.8.8.8"));
         helloPacket.setDestinationIp(Ip4Address.valueOf("5.5.5.5"));
-        ospfMessageWriter.writeToBuffer(helloPacket, 7, 1);
+        ospfMessageWriter.getMessage(helloPacket, 7, 1);
         assertThat(ospfMessageWriter, is(notNullValue()));
     }
 
     @Test(expected = Exception.class)
-    public void testWriteToBuffer1() throws Exception {
+    public void testGetMessage1() throws Exception {
 
         ddPacket = new DdPacket();
         ddPacket.setAuthType(1);
@@ -95,12 +95,12 @@
         ddPacket.setAuthentication(2);
         ddPacket.setOspfPacLength(48);
         ddPacket.setOspfVer(2);
-        ospfMessageWriter.writeToBuffer(ddPacket, 1, 1);
+        ospfMessageWriter.getMessage(ddPacket, 1, 1);
         assertThat(ospfMessageWriter, is(notNullValue()));
     }
 
     @Test(expected = Exception.class)
-    public void testWriteToBuffer2() throws Exception {
+    public void testGetMessage2() throws Exception {
 
         lsAck = new LsAcknowledge();
         lsAck.setAuthType(1);
@@ -111,12 +111,12 @@
         lsAck.setAuthentication(2);
         lsAck.setOspfPacLength(48);
         lsAck.setOspfVer(2);
-        ospfMessageWriter.writeToBuffer(lsAck, 1, 1);
+        ospfMessageWriter.getMessage(lsAck, 1, 1);
         assertThat(ospfMessageWriter, is(notNullValue()));
     }
 
     @Test(expected = Exception.class)
-    public void testWriteToBuffer3() throws Exception {
+    public void testGetMessage3() throws Exception {
         lsReq = new LsRequest();
         lsReq.setAuthType(1);
         lsReq.setOspftype(3);
@@ -126,12 +126,15 @@
         lsReq.setAuthentication(2);
         lsReq.setOspfPacLength(48);
         lsReq.setOspfVer(2);
-        ospfMessageWriter.writeToBuffer(lsReq, 1, 1);
+        ospfMessageWriter.getMessage(lsReq, 1, 1);
         assertThat(ospfMessageWriter, is(notNullValue()));
     }
 
+    /**
+     * Tests getMessage() method.
+     */
     @Test(expected = Exception.class)
-    public void testWriteToBuffer4() throws Exception {
+    public void testGetMessage4() throws Exception {
         lsUpdate = new LsUpdate();
         lsUpdate.setAuthType(1);
         lsUpdate.setOspftype(3);
@@ -141,15 +144,15 @@
         lsUpdate.setAuthentication(2);
         lsUpdate.setOspfPacLength(48);
         lsUpdate.setOspfVer(2);
-        ospfMessageWriter.writeToBuffer(lsUpdate, 1, 1);
+        ospfMessageWriter.getMessage(lsUpdate, 1, 1);
         assertThat(ospfMessageWriter, is(notNullValue()));
     }
 
     /**
-     * Tests writeToBuffer() method.
+     * Tests getMessage() method.
      */
     @Test(expected = Exception.class)
-    public void testWriteToBuffer5() throws Exception {
+    public void testGetMessage5() throws Exception {
         lsAck = new LsAcknowledge();
         lsAck.setAuthType(1);
         lsAck.setOspftype(5);
@@ -159,6 +162,6 @@
         lsAck.setAuthentication(2);
         lsAck.setOspfPacLength(48);
         lsAck.setOspfVer(2);
-        ospfMessageWriter.writeToBuffer(lsAck, 1, 1);
+        ospfMessageWriter.getMessage(lsAck, 1, 1);
     }
 }
\ No newline at end of file
diff --git a/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/ospfpacket/types/DdPacketTest.java b/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/ospfpacket/types/DdPacketTest.java
index 47b72e5..91404d1 100644
--- a/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/ospfpacket/types/DdPacketTest.java
+++ b/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/ospfpacket/types/DdPacketTest.java
@@ -22,10 +22,10 @@
 import org.junit.Before;
 import org.junit.Test;
 import org.onlab.packet.Ip4Address;
+import org.onosproject.ospf.controller.OspfPacketType;
 import org.onosproject.ospf.protocol.lsa.LsaHeader;
 import org.onosproject.ospf.protocol.lsa.OpaqueLsaHeader;
 import org.onosproject.ospf.protocol.ospfpacket.OspfPacketHeader;
-import org.onosproject.ospf.protocol.util.OspfPacketType;
 
 import java.util.List;
 import java.util.Vector;
diff --git a/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/ospfpacket/types/HelloPacketTest.java b/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/ospfpacket/types/HelloPacketTest.java
index 6ed9d0c..acdbd3a 100644
--- a/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/ospfpacket/types/HelloPacketTest.java
+++ b/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/ospfpacket/types/HelloPacketTest.java
@@ -21,8 +21,8 @@
 import org.junit.Before;
 import org.junit.Test;
 import org.onlab.packet.Ip4Address;
+import org.onosproject.ospf.controller.OspfPacketType;
 import org.onosproject.ospf.protocol.ospfpacket.OspfPacketHeader;
-import org.onosproject.ospf.protocol.util.OspfPacketType;
 
 import java.util.Vector;
 
diff --git a/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/ospfpacket/types/LsAcknowledgeTest.java b/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/ospfpacket/types/LsAcknowledgeTest.java
index aea5723..1d8b3e0 100644
--- a/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/ospfpacket/types/LsAcknowledgeTest.java
+++ b/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/ospfpacket/types/LsAcknowledgeTest.java
@@ -22,10 +22,10 @@
 import org.junit.Before;
 import org.junit.Test;
 import org.onlab.packet.Ip4Address;
+import org.onosproject.ospf.controller.OspfPacketType;
 import org.onosproject.ospf.protocol.lsa.LsaHeader;
 import org.onosproject.ospf.protocol.lsa.OpaqueLsaHeader;
 import org.onosproject.ospf.protocol.ospfpacket.OspfPacketHeader;
-import org.onosproject.ospf.protocol.util.OspfPacketType;
 
 import java.util.List;
 
diff --git a/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/ospfpacket/types/LsRequestTest.java b/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/ospfpacket/types/LsRequestTest.java
index 6238b88..ece1fbe 100644
--- a/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/ospfpacket/types/LsRequestTest.java
+++ b/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/ospfpacket/types/LsRequestTest.java
@@ -21,9 +21,9 @@
 import org.junit.Before;
 import org.junit.Test;
 import org.onlab.packet.Ip4Address;
+import org.onosproject.ospf.controller.OspfPacketType;
 import org.onosproject.ospf.protocol.ospfpacket.OspfPacketHeader;
 import org.onosproject.ospf.protocol.ospfpacket.subtype.LsRequestPacket;
-import org.onosproject.ospf.protocol.util.OspfPacketType;
 
 import java.net.UnknownHostException;
 import java.util.List;
diff --git a/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/ospfpacket/types/LsUpdateTest.java b/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/ospfpacket/types/LsUpdateTest.java
index 75611f6..fac03eb 100644
--- a/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/ospfpacket/types/LsUpdateTest.java
+++ b/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/ospfpacket/types/LsUpdateTest.java
@@ -22,6 +22,7 @@
 import org.junit.Test;
 import org.onlab.packet.Ip4Address;
 import org.onosproject.ospf.controller.OspfLsa;
+import org.onosproject.ospf.controller.OspfPacketType;
 import org.onosproject.ospf.protocol.lsa.LsaHeader;
 import org.onosproject.ospf.protocol.lsa.OpaqueLsaHeader;
 import org.onosproject.ospf.protocol.lsa.types.AsbrSummaryLsa;
@@ -33,7 +34,6 @@
 import org.onosproject.ospf.protocol.lsa.types.RouterLsa;
 import org.onosproject.ospf.protocol.lsa.types.SummaryLsa;
 import org.onosproject.ospf.protocol.ospfpacket.OspfPacketHeader;
-import org.onosproject.ospf.protocol.util.OspfPacketType;
 
 import java.util.List;
 import java.util.Vector;
diff --git a/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/util/OspfUtilTest.java b/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/util/OspfUtilTest.java
index 747df02..faf1bce 100644
--- a/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/util/OspfUtilTest.java
+++ b/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/util/OspfUtilTest.java
@@ -229,7 +229,7 @@
      */
     @Test
     public void testAddMetadata() throws Exception {
-        result1 = OspfUtil.addMetadata(packet, 123, Ip4Address.valueOf("1.1.1.1"));
+        result1 = OspfUtil.addMetadata(2, packet, 1, Ip4Address.valueOf("1.1.1.1"));
         assertThat(result1, is(notNullValue()));
     }
 
@@ -251,7 +251,7 @@
      */
     @Test
     public void testAddMetaData() throws Exception {
-        result1 = OspfUtil.addMetadata(packet, 1, Ip4Address.valueOf("2.2.2.2"));
+        result1 = OspfUtil.addMetadata(2, packet, 1, Ip4Address.valueOf("2.2.2.2"));
         assertThat(result1, is(notNullValue()));
     }