ONOS-4505: Bug Fixes

Change-Id: Ia030aa3aff9e2ad34a5e27fbe4ba088dda65bfa7
diff --git a/protocols/isis/api/src/main/java/org/onosproject/isis/controller/IsisInterface.java b/protocols/isis/api/src/main/java/org/onosproject/isis/controller/IsisInterface.java
index 3ac7122..3f775cc 100644
--- a/protocols/isis/api/src/main/java/org/onosproject/isis/controller/IsisInterface.java
+++ b/protocols/isis/api/src/main/java/org/onosproject/isis/controller/IsisInterface.java
@@ -195,13 +195,6 @@
     void setAreaLength(int areaLength);
 
     /**
-     * Sets link state packet ID.
-     *
-     * @param lspId link state packet ID
-     */
-    void setLspId(String lspId);
-
-    /**
      * Returns holding time.
      *
      * @return holding time
@@ -251,6 +244,11 @@
     void startHelloSender(Channel channel);
 
     /**
+     * Stops the hello timer which sends hello packet every configured seconds.
+     */
+    void stopHelloSender();
+
+    /**
      * Processes an ISIS message which is received on this interface.
      *
      * @param isisMessage ISIS message instance
@@ -315,4 +313,9 @@
      * @param isisNeighbor ISIS neighbor instance
      */
     void removeNeighbor(IsisNeighbor isisNeighbor);
+
+    /**
+     * Removes all the neighbors.
+     */
+    void removeNeighbors();
 }
diff --git a/protocols/isis/api/src/main/java/org/onosproject/isis/controller/IsisLsdb.java b/protocols/isis/api/src/main/java/org/onosproject/isis/controller/IsisLsdb.java
index 06e34fd..c9e1586 100644
--- a/protocols/isis/api/src/main/java/org/onosproject/isis/controller/IsisLsdb.java
+++ b/protocols/isis/api/src/main/java/org/onosproject/isis/controller/IsisLsdb.java
@@ -108,4 +108,18 @@
      * @return neighbor database information
      */
     Map<String, LspWrapper> getL2Db();
+
+    /**
+     * Sets the level 1 link state sequence number.
+     *
+     * @param l1LspSeqNo link state sequence number
+     */
+     void setL1LspSeqNo(int l1LspSeqNo);
+
+    /**
+     * Sets the level 2 link state sequence number.
+     *
+     * @param l2LspSeqNo link state sequence number
+     */
+    void setL2LspSeqNo(int l2LspSeqNo);
 }
\ No newline at end of file
diff --git a/protocols/isis/api/src/main/java/org/onosproject/isis/controller/IsisNeighbor.java b/protocols/isis/api/src/main/java/org/onosproject/isis/controller/IsisNeighbor.java
index eedf11c..76e8b18 100644
--- a/protocols/isis/api/src/main/java/org/onosproject/isis/controller/IsisNeighbor.java
+++ b/protocols/isis/api/src/main/java/org/onosproject/isis/controller/IsisNeighbor.java
@@ -108,4 +108,16 @@
      * Stops the inactivity timer.
      */
     void stopInactivityTimeCheck();
-}
+
+    /**
+     * Stops the holding time check timer.
+     */
+    void stopHoldingTimeCheck();
+
+    /**
+     * Returns router type.
+     *
+     * @return router type
+     */
+    IsisRouterType routerType();
+}
\ No newline at end of file
diff --git a/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/Controller.java b/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/Controller.java
old mode 100755
new mode 100644
index c12c520..f16aeb4
--- a/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/Controller.java
+++ b/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/Controller.java
@@ -19,6 +19,7 @@
 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.socket.nio.NioClientSocketChannelFactory;
@@ -35,10 +36,14 @@
 
 import java.net.InetAddress;
 import java.net.InetSocketAddress;
+import java.net.NetworkInterface;
 import java.net.UnknownHostException;
 import java.util.ArrayList;
+import java.util.Enumeration;
 import java.util.List;
 import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.TimeUnit;
 
 import static org.onlab.util.Tools.groupedThreads;
 
@@ -48,12 +53,17 @@
 public class Controller {
     protected static final int BUFFER_SIZE = 4 * 1024 * 1024;
     private static final Logger log = LoggerFactory.getLogger(Controller.class);
+    private static final int RETRY_INTERVAL = 4;
     private final int peerWorkerThreads = 16;
+    byte[] configPacket = null;
     private List<IsisProcess> processes = null;
     private IsisChannelHandler isisChannelHandler;
     private NioClientSocketChannelFactory peerExecFactory;
     private ClientBootstrap peerBootstrap = null;
     private TpPort isisPort = TpPort.tpPort(IsisConstants.SPORT);
+    private ScheduledExecutorService connectExecutor = null;
+    private int connectRetryCounter = 0;
+    private int connectRetryTime;
 
     /**
      * Deactivates ISIS controller.
@@ -70,12 +80,11 @@
      */
     public void updateConfig(JsonNode jsonNode) throws Exception {
         log.debug("Controller::UpdateConfig called");
-        byte[] configPacket = new byte[IsisConstants.CONFIG_LENGTH];
+        configPacket = new byte[IsisConstants.CONFIG_LENGTH];
         byte numberOfInterface = 0; // number of interfaces to configure
 
         configPacket[0] = (byte) 0xFF; // its a conf packet - identifier
         List<IsisProcess> isisProcesses = getConfig(jsonNode);
-
         for (IsisProcess isisProcess : isisProcesses) {
             log.debug("IsisProcessDetails : " + isisProcess);
             for (IsisInterface isisInterface : isisProcess.isisInterfaceList()) {
@@ -100,16 +109,19 @@
         configPacket[1] = numberOfInterface;
         //First time configuration
         if (processes == null) {
-            processes = isisProcesses;
-            //Initialize connection by creating a channel handler instance and sent the config packet);
-            initConnection();
-            //Initializing the interface map in channel handler
-            isisChannelHandler.initializeInterfaceMap();
+            if (isisProcesses.size() > 0) {
+                processes = isisProcesses;
+                connectPeer();
+                //Initializing the interface map in channel handler
+                if (isisChannelHandler != null) {
+                    isisChannelHandler.initializeInterfaceMap();
+                }
+            }
         } else {
             isisChannelHandler.updateInterfaceMap(isisProcesses);
+            //Send the config packet
+            isisChannelHandler.sentConfigPacket(configPacket);
         }
-        //Send the config packet
-        isisChannelHandler.sentConfigPacket(configPacket);
     }
 
     /**
@@ -182,10 +194,8 @@
      * @return list of processes configured
      */
     private List<IsisProcess> getConfig(JsonNode json) throws Exception {
-
         List<IsisProcess> isisProcessesList = new ArrayList<>();
         JsonNode jsonNodes = json;
-
         if (jsonNodes == null) {
             return isisProcessesList;
         }
@@ -193,49 +203,335 @@
             List<IsisInterface> interfaceList = new ArrayList<>();
             for (JsonNode jsonNode1 : jsonNode.path(IsisConstants.INTERFACE)) {
                 IsisInterface isisInterface = new DefaultIsisInterface();
-                isisInterface.setInterfaceIndex(jsonNode1.path(IsisConstants.INTERFACEINDEX).asInt());
-                isisInterface.setInterfaceIpAddress(Ip4Address.valueOf(jsonNode1
-                                                                               .path(IsisConstants.INTERFACEIP)
-                                                                               .asText()));
-                try {
-                    isisInterface.setNetworkMask(InetAddress.getByName((jsonNode1
-                            .path(IsisConstants.NETWORKMASK).asText())).getAddress());
-                } catch (UnknownHostException e) {
-                    log.debug("Error:: Parsing network mask");
+                String index = jsonNode1.path(IsisConstants.INTERFACEINDEX).asText();
+                if (isPrimitive(index)) {
+                    int input = Integer.parseInt(index);
+                    if (input < 1 || input > 255) {
+                        log.debug("Wrong interface index: {}", index);
+                        continue;
+                    }
+                    isisInterface.setInterfaceIndex(Integer.parseInt(index));
+                } else {
+                    log.debug("Wrong interface index {}", index);
+                    continue;
                 }
-                isisInterface.setInterfaceMacAddress(MacAddress.valueOf(jsonNode1
-                                                                                .path(IsisConstants.MACADDRESS)
-                                                                                .asText()));
+                Ip4Address ipAddress = getInterfaceIp(isisInterface.interfaceIndex());
+                if (ipAddress != null && !ipAddress.equals(IsisConstants.DEFAULTIP)) {
+                    isisInterface.setInterfaceIpAddress(ipAddress);
+                } else {
+                    log.debug("Wrong interface index {}. No matching interface in system.", index);
+                    continue;
+                }
+                MacAddress macAddress = getInterfaceMac(isisInterface.interfaceIndex());
+                if (macAddress != null) {
+                    isisInterface.setInterfaceMacAddress(macAddress);
+                } else {
+                    log.debug("Wrong interface index {}. No matching interface in system.", index);
+                    continue;
+                }
+                String mask = getInterfaceMask(isisInterface.interfaceIndex());
+                if (mask != null) {
+                    try {
+                        isisInterface.setNetworkMask(InetAddress.getByName(mask).getAddress());
+                    } catch (UnknownHostException e) {
+                        log.debug("Wrong interface index {}. Error while getting network mask.", index);
+                    }
+                } else {
+                    log.debug("Wrong interface index {}. Error while getting network mask.", index);
+                    continue;
+                }
                 isisInterface.setIntermediateSystemName(jsonNode1
                                                                 .path(IsisConstants.INTERMEDIATESYSTEMNAME)
                                                                 .asText());
-                isisInterface.setSystemId(jsonNode1.path(IsisConstants.SYSTEMID).asText());
-                isisInterface.setReservedPacketCircuitType(jsonNode1
-                                                                   .path(IsisConstants.RESERVEDPACKETCIRCUITTYPE)
-                                                                   .asInt());
-                if (isisInterface.reservedPacketCircuitType() == IsisRouterType.L1.value()) {
-                    isisInterface.setL1LanId(jsonNode1.path(IsisConstants.LANID).asText());
+                String systemId = jsonNode1.path(IsisConstants.SYSTEMID).asText();
+                if (isValidSystemId(systemId)) {
+                    isisInterface.setSystemId(systemId);
+                } else {
+                    log.debug("Wrong systemId: {} for interface index {}.", systemId, index);
+                    continue;
                 }
-                isisInterface.setIdLength(jsonNode1.path(IsisConstants.IDLENGTH).asInt());
-                isisInterface.setMaxAreaAddresses(jsonNode1.path(IsisConstants.MAXAREAADDRESSES).asInt());
-                isisInterface.setNetworkType(IsisNetworkType.get(jsonNode1
-                                                                         .path(IsisConstants.NETWORKTYPE)
-                                                                         .asInt()));
-                isisInterface.setAreaAddress(jsonNode1.path(IsisConstants.AREAADDRESS).asText());
-                isisInterface.setAreaLength(jsonNode1.path(IsisConstants.AREALENGTH).asInt());
-                isisInterface.setLspId(jsonNode1.path(IsisConstants.LSPID).asText());
-                isisInterface.setCircuitId(jsonNode1.path(IsisConstants.CIRCUITID).asText());
-                isisInterface.setHoldingTime(jsonNode1.path(IsisConstants.HOLDINGTIME).asInt());
-                isisInterface.setPriority(jsonNode1.path(IsisConstants.PRIORITY).asInt());
-                isisInterface.setHelloInterval(jsonNode1.path(IsisConstants.HELLOINTERVAL).asInt());
+                String circuitType = jsonNode1.path(IsisConstants.RESERVEDPACKETCIRCUITTYPE).asText();
+                if (isPrimitive(circuitType)) {
+                    int input = Integer.parseInt(circuitType);
+                    if (input < 1 || input > 3) {
+                        log.debug("Wrong ReservedPacketCircuitType: {} for interface index {}.", circuitType, index);
+                        continue;
+                    }
+                    isisInterface.setReservedPacketCircuitType(input);
+                } else {
+                    log.debug("Wrong ReservedPacketCircuitType: {} for interface index {}.", circuitType, index);
+                    continue;
+                }
+                String networkType = jsonNode1.path(IsisConstants.NETWORKTYPE).asText();
+                if (isPrimitive(networkType)) {
+                    int input = Integer.parseInt(networkType);
+                    if (input < 1 || input > 2) {
+                        log.debug("Wrong networkType: {} for interface index {}.", networkType, index);
+                        continue;
+                    }
+                    isisInterface.setNetworkType(IsisNetworkType.get(input));
+                } else {
+                    log.debug("Wrong networkType: {} for interface index {}.", networkType, index);
+                    continue;
+                }
+                String areaAddress = jsonNode1.path(IsisConstants.AREAADDRESS).asText();
+                if (isPrimitive(areaAddress)) {
+                    if (areaAddress.length() > 7) {
+                        log.debug("Wrong areaAddress: {} for interface index {}.", areaAddress, index);
+                        continue;
+                    }
+                    isisInterface.setAreaAddress(areaAddress);
+                } else {
+                    log.debug("Wrong areaAddress: {} for interface index {}.", areaAddress, index);
+                    continue;
+                }
+                String circuitId = jsonNode1.path(IsisConstants.CIRCUITID).asText();
+                if (isPrimitive(circuitId)) {
+                    int input = Integer.parseInt(circuitId);
+                    if (input < 1) {
+                        log.debug("Wrong circuitId: {} for interface index {}.", circuitId, index);
+                        continue;
+                    }
+                    isisInterface.setCircuitId(circuitId);
+                } else {
+                    log.debug("Wrong circuitId: {} for interface index {}.", circuitId, index);
+                    continue;
+                }
+                String holdingTime = jsonNode1.path(IsisConstants.HOLDINGTIME).asText();
+                if (isPrimitive(holdingTime)) {
+                    int input = Integer.parseInt(holdingTime);
+                    if (input < 1 || input > 255) {
+                        log.debug("Wrong holdingTime: {} for interface index {}.", holdingTime, index);
+                        continue;
+                    }
+                    isisInterface.setHoldingTime(input);
+                } else {
+                    log.debug("Wrong holdingTime: {} for interface index {}.", holdingTime, index);
+                    continue;
+                }
+                String helloInterval = jsonNode1.path(IsisConstants.HELLOINTERVAL).asText();
+                if (isPrimitive(helloInterval)) {
+                    int interval = Integer.parseInt(helloInterval);
+                    if (interval > 0 && interval <= 255) {
+                        isisInterface.setHelloInterval(interval);
+                    } else {
+                        log.debug("Wrong hello interval: {} for interface index {}.", helloInterval, index);
+                        continue;
+                    }
+                } else {
+                    log.debug("Wrong hello interval: {} for interface index {}.", helloInterval, index);
+                    continue;
+                }
                 interfaceList.add(isisInterface);
             }
-            IsisProcess process = new DefaultIsisProcess();
-            process.setProcessId(jsonNode.path(IsisConstants.PROCESSESID).asText());
-            process.setIsisInterfaceList(interfaceList);
-            isisProcessesList.add(process);
+            if (interfaceList.size() > 0) {
+                IsisProcess process = new DefaultIsisProcess();
+                process.setProcessId(jsonNode.path(IsisConstants.PROCESSESID).asText());
+                process.setIsisInterfaceList(interfaceList);
+                isisProcessesList.add(process);
+            }
         });
 
         return isisProcessesList;
     }
+
+    /**
+     * Returns interface MAC by index.
+     *
+     * @param interfaceIndex interface index
+     * @return interface IP by index
+     */
+    private MacAddress getInterfaceMac(int interfaceIndex) {
+        MacAddress macAddress = null;
+        try {
+            NetworkInterface networkInterface = NetworkInterface.getByIndex(interfaceIndex);
+            macAddress = MacAddress.valueOf(networkInterface.getHardwareAddress());
+        } catch (Exception e) {
+            log.debug("Error while getting Interface IP by index");
+            return macAddress;
+        }
+
+        return macAddress;
+    }
+
+    /**
+     * Returns interface IP by index.
+     *
+     * @param interfaceIndex interface index
+     * @return interface IP by index
+     */
+    private 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 IsisConstants.DEFAULTIP;
+        }
+        return ipAddress;
+    }
+
+    /**
+     * Returns interface MAC 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;
+        }
+        return subnetMask;
+    }
+
+    /**
+     * Checks if primitive or not.
+     *
+     * @param value input value
+     * @return true if number else false
+     */
+    private 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 system id is valid or not.
+     *
+     * @param value input value
+     * @return true if valid else false
+     */
+    private boolean isValidSystemId(String value) {
+        value = value.trim();
+        boolean status = true;
+        if (value.length() != 14) {
+            return false;
+        }
+        for (int i = 0; i < value.length(); i++) {
+            char c = value.charAt(i);
+            if (!Character.isDigit(c)) {
+                if (!((i == 4 || i == 9) && c == '.')) {
+                    status = false;
+                    break;
+                }
+            }
+        }
+
+        return status;
+    }
+
+    /**
+     * Disconnects the executor.
+     */
+    public void disconnectExecutor() {
+        if (connectExecutor != null) {
+            connectExecutor.shutdown();
+            connectExecutor = null;
+        }
+    }
+
+    /**
+     * Connects to peer.
+     */
+    public void connectPeer() {
+        scheduleConnectionRetry(this.connectRetryTime);
+    }
+
+    /**
+     * 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);
+    }
+
+    /**
+     * 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 {}", IsisConstants.SHOST);
+            initConnection();
+            InetSocketAddress connectToSocket = new InetSocketAddress(IsisConstants.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,
+                                      IsisConstants.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 {
+                            connectRetryCounter++;
+                            log.info("Connected to remote host {}, Connect Counter {}", IsisConstants.SHOST,
+                                     connectRetryCounter);
+                            disconnectExecutor();
+                            isisChannelHandler.initializeInterfaceMap();
+                            //Send the config packet
+                            isisChannelHandler.sentConfigPacket(configPacket);
+                            return;
+                        }
+                    }
+                });
+            } catch (Exception e) {
+                log.info("Connect peer exception : " + e.toString());
+                disconnectExecutor();
+            }
+        }
+    }
 }
\ No newline at end of file
diff --git a/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/DefaultIsisController.java b/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/DefaultIsisController.java
old mode 100755
new mode 100644
diff --git a/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/DefaultIsisInterface.java b/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/DefaultIsisInterface.java
old mode 100755
new mode 100644
index bbeb4dd..134a48b
--- a/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/DefaultIsisInterface.java
+++ b/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/DefaultIsisInterface.java
@@ -69,15 +69,14 @@
     private MacAddress interfaceMacAddress;
     private String intermediateSystemName;
     private String systemId;
-    private String l1LanId;
-    private String l2LanId;
+    private String l1LanId = IsisConstants.DEFAULTLANID;
+    private String l2LanId = IsisConstants.DEFAULTLANID;
     private int idLength;
     private int maxAreaAddresses;
     private int reservedPacketCircuitType;
     private IsisNetworkType networkType;
     private String areaAddress;
     private int areaLength;
-    private String lspId;
     private int holdingTime;
     private int priority;
     private String circuitId;
@@ -114,10 +113,25 @@
      * @param isisNeighbor ISIS neighbor instance
      */
     public void removeNeighbor(IsisNeighbor isisNeighbor) {
+        log.debug("Neighbor removed - {}", isisNeighbor.neighborMacAddress());
+        isisNeighbor.stopHoldingTimeCheck();
+        isisNeighbor.stopInactivityTimeCheck();
         neighborList.remove(isisNeighbor.neighborMacAddress());
     }
 
     /**
+     * Removes all the neighbors.
+     */
+    public void removeNeighbors() {
+        Set<MacAddress> neighbors = neighbors();
+        for (MacAddress mac : neighbors) {
+            removeNeighbor(lookup(mac));
+            log.debug("Neighbor removed - {}", mac);
+        }
+        neighborList.clear();
+    }
+
+    /**
      * Returns the ISIS neighbor instance if exists.
      *
      * @param isisNeighborMac mac address of the neighbor router
@@ -400,24 +414,6 @@
     }
 
     /**
-     * Returns LSP ID.
-     *
-     * @return LSP ID
-     */
-    public String getLspId() {
-        return lspId;
-    }
-
-    /**
-     * Sets LSP ID.
-     *
-     * @param lspId link state packet ID
-     */
-    public void setLspId(String lspId) {
-        this.lspId = lspId;
-    }
-
-    /**
      * Returns holding time.
      *
      * @return holding time
@@ -518,9 +514,21 @@
      */
     public void processIsisMessage(IsisMessage isisMessage, IsisLsdb isisLsdb, Channel channel) {
         log.debug("IsisInterfaceImpl::processIsisMessage...!!!");
-        if (channel == null) {
-            this.channel = channel;
+        this.channel = channel;
+
+        if (isisMessage.sourceMac().equals(interfaceMacAddress)) {
+            log.debug("Received our own message {}...!!!", isisMessage.isisPduType());
+            return;
         }
+
+        if (isisMessage.isisPduType() == IsisPduType.P2PHELLOPDU && networkType.equals(IsisNetworkType.BROADCAST)) {
+            return;
+        } else if ((isisMessage.isisPduType() == IsisPduType.L1HELLOPDU ||
+                isisMessage.isisPduType() == IsisPduType.L2HELLOPDU)
+                && networkType.equals(IsisNetworkType.P2P)) {
+            return;
+        }
+
         if (this.isisLsdb == null) {
             this.isisLsdb = isisLsdb;
         }
@@ -543,7 +551,7 @@
                 break;
             case L1PSNP:
             case L2PSNP:
-                log.debug("Received a PSNP packet...!!!");
+                processPsnPduMessage(isisMessage, channel);
                 break;
             default:
                 log.debug("Unknown packet to process...!!!");
@@ -560,6 +568,13 @@
     public boolean validateHelloMessage(HelloPdu helloPdu) {
         boolean isValid = false;
 
+        if ((helloPdu.circuitType() == IsisRouterType.L1.value() &&
+                reservedPacketCircuitType == IsisRouterType.L2.value()) ||
+                (helloPdu.circuitType() == IsisRouterType.L2.value() &&
+                        reservedPacketCircuitType == IsisRouterType.L1.value())) {
+            return false;
+        }
+
         //Local InterfaceAddress TLV and compare with the IP Interface address and check if they are in same subnet
         List<Ip4Address> interfaceIpAddresses = helloPdu.interfaceIpAddresses();
         Ip4Address neighborIp = (helloPdu.interfaceIpAddresses() != null) ?
@@ -569,11 +584,16 @@
         }
 
         //Verify if it's in same area, Areas which the router belongs to
-        List<String> areas = helloPdu.areaAddress();
-        for (String area : areas) {
-            if (areaAddress.equals(area)) {
-                isValid = true;
+        if (helloPdu.circuitType() == IsisRouterType.L1.value()) {
+            List<String> areas = helloPdu.areaAddress();
+            for (String area : areas) {
+                if (areaAddress.equals(area)) {
+                    isValid = true;
+                }
             }
+        } else if (helloPdu.circuitType() == IsisRouterType.L2.value() ||
+                helloPdu.circuitType() == IsisRouterType.L1L2.value()) {
+            isValid = true;
         }
 
         return isValid;
@@ -585,6 +605,7 @@
      * @param neighborMac neighbor MAc address
      * @return true if neighbor exist else false
      */
+
     private boolean isNeighborInList(MacAddress neighborMac) {
         return neighborList.containsKey(neighborMac);
     }
@@ -623,9 +644,8 @@
         log.debug("IsisInterfaceImpl::processHelloMessage::Interface Type {} ISISInterfaceState {} ",
                   networkType, interfaceState);
 
-        //If L1 Hello, validate the area, network and max address
-        if (IsisPduType.get(helloPacket.pduType()) == IsisPduType.L1HELLOPDU &&
-                !validateHelloMessage(helloPacket)) {
+        //If validate the area, network and max address
+        if (!validateHelloMessage(helloPacket)) {
             return;
         }
 
@@ -637,6 +657,7 @@
             addNeighbouringRouter(neighbor);
         }
 
+        neighbor.setHoldingTime(helloPacket.holdingTime());
         neighbor.stopInactivityTimeCheck();
         neighbor.startInactivityTimeCheck();
 
@@ -644,24 +665,29 @@
         String lanId = helloPacket.lanId();
 
         if (IsisPduType.L1HELLOPDU == helloPacket.isisPduType()) {
-            buildUpdateAndSendSelfGeneratedLspIfDisChange(l1LanId, lanId, channel);
+            buildUpdateAndSendSelfGeneratedLspIfDisChange(l1LanId, lanId, channel,
+                                                          IsisRouterType.get(helloPacket.circuitType()));
             l1LanId = lanId;
             neighbor.setL1LanId(lanId);
             //if a change in lanid
         } else if (IsisPduType.L2HELLOPDU == helloPacket.isisPduType()) {
-            buildUpdateAndSendSelfGeneratedLspIfDisChange(l1LanId, lanId, channel);
+            buildUpdateAndSendSelfGeneratedLspIfDisChange(l2LanId, lanId, channel,
+                                                          IsisRouterType.get(helloPacket.circuitType()));
             l2LanId = lanId;
             neighbor.setL2LanId(lanId);
         }
 
         //Check in neighbors list our MAC address present
         List<MacAddress> neighbors = helloPacket.neighborList();
-        for (MacAddress macAddress : neighbors) {
-            if (interfaceMacAddress.equals(macAddress)) {
-                neighbor.setNeighborState(IsisInterfaceState.UP);
-                //Build Self LSP add in LSDB and sent it.
-                buildStoreAndSendSelfGeneratedLspIfNotExistInDb(channel);
-                break;
+        if (neighbors != null) {
+            for (MacAddress macAddress : neighbors) {
+                if (interfaceMacAddress.equals(macAddress)) {
+                    neighbor.setNeighborState(IsisInterfaceState.UP);
+                    //Build Self LSP add in LSDB and sent it.
+                    buildStoreAndSendSelfGeneratedLspIfNotExistInDb(channel,
+                                                                    IsisRouterType.get(helloPacket.circuitType()));
+                    break;
+                }
             }
         }
     }
@@ -671,7 +697,8 @@
      *
      * @param channel netty channel instance
      */
-    private void buildStoreAndSendSelfGeneratedLspIfNotExistInDb(Channel channel) {
+    private void buildStoreAndSendSelfGeneratedLspIfNotExistInDb(Channel channel, IsisRouterType neighborRouterType) {
+        this.channel = channel;
         //Check our LSP is present in DB. else create a self LSP and store it and sent it
         String lspKey = isisLsdb.lspKey(systemId);
         LspWrapper wrapper = null;
@@ -690,18 +717,25 @@
                 sendLsp(lsp, channel);
             }
         } else if (reservedPacketCircuitType == IsisRouterType.L1L2.value()) {
-            wrapper = isisLsdb.findLsp(IsisPduType.L1LSPDU, lspKey);
-            if (wrapper == null) {
-                LsPdu lsp = new LspGenerator().getLsp(this, lspKey, IsisPduType.L1LSPDU, allConfiguredInterfaceIps);
-                isisLsdb.addLsp(lsp, true, this);
-                sendLsp(lsp, channel);
+            if ((neighborRouterType == IsisRouterType.L1 || neighborRouterType == IsisRouterType.L1L2)) {
+
+                wrapper = isisLsdb.findLsp(IsisPduType.L1LSPDU, lspKey);
+                if (wrapper == null) {
+                    LsPdu lsp = new LspGenerator().getLsp(this, lspKey, IsisPduType.L1LSPDU,
+                                                          allConfiguredInterfaceIps);
+                    isisLsdb.addLsp(lsp, true, this);
+                    sendLsp(lsp, channel);
+                }
             }
 
-            wrapper = isisLsdb.findLsp(IsisPduType.L2LSPDU, lspKey);
-            if (wrapper == null) {
-                LsPdu lsp = new LspGenerator().getLsp(this, lspKey, IsisPduType.L2LSPDU, allConfiguredInterfaceIps);
-                isisLsdb.addLsp(lsp, true, this);
-                sendLsp(lsp, channel);
+            if ((neighborRouterType == IsisRouterType.L2 || neighborRouterType == IsisRouterType.L1L2)) {
+                wrapper = isisLsdb.findLsp(IsisPduType.L2LSPDU, lspKey);
+                if (wrapper == null) {
+                    LsPdu lsp = new LspGenerator().getLsp(this, lspKey, IsisPduType.L2LSPDU,
+                                                          allConfiguredInterfaceIps);
+                    isisLsdb.addLsp(lsp, true, this);
+                    sendLsp(lsp, channel);
+                }
             }
         }
     }
@@ -714,29 +748,35 @@
      * @param channel       netty channel instance
      */
     private void buildUpdateAndSendSelfGeneratedLspIfDisChange(String previousLanId,
-                                                               String latestLanId, Channel channel) {
+                                                               String latestLanId, Channel channel,
+                                                               IsisRouterType neighborRouterType) {
+        this.channel = channel;
         //If DIS change then build and sent LSP
-        if (previousLanId != null && !previousLanId.equals(IsisConstants.DEFAULTLANID) &&
-                !previousLanId.equals(latestLanId)) {
+        if (!previousLanId.equals(latestLanId)) {
             //Create a self LSP and Update it in DB and sent it
             String lspKey = isisLsdb.lspKey(systemId);
             if (reservedPacketCircuitType == IsisRouterType.L1.value()) {
                 LsPdu lsp = new LspGenerator().getLsp(this, lspKey, IsisPduType.L1LSPDU, allConfiguredInterfaceIps);
                 isisLsdb.addLsp(lsp, true, this);
                 sendLsp(lsp, channel);
-            } else if (reservedPacketCircuitType == IsisRouterType.L2.value()) {
+            } else if (reservedPacketCircuitType == IsisRouterType.L2.value() &&
+                    (neighborRouterType == IsisRouterType.L2 || neighborRouterType == IsisRouterType.L1L2)) {
                 LsPdu lsp = new LspGenerator().getLsp(this, lspKey, IsisPduType.L2LSPDU, allConfiguredInterfaceIps);
                 isisLsdb.addLsp(lsp, true, this);
                 sendLsp(lsp, channel);
             } else if (reservedPacketCircuitType == IsisRouterType.L1L2.value()) {
                 //L1 LSPDU
-                LsPdu lsp = new LspGenerator().getLsp(this, lspKey, IsisPduType.L1LSPDU, allConfiguredInterfaceIps);
-                isisLsdb.addLsp(lsp, true, this);
-                sendLsp(lsp, channel);
+                if (neighborRouterType == IsisRouterType.L1 || neighborRouterType == IsisRouterType.L1L2) {
+                    LsPdu lsp = new LspGenerator().getLsp(this, lspKey, IsisPduType.L1LSPDU, allConfiguredInterfaceIps);
+                    isisLsdb.addLsp(lsp, true, this);
+                    sendLsp(lsp, channel);
+                }
                 //L1 LSPDU
-                lsp = new LspGenerator().getLsp(this, lspKey, IsisPduType.L2LSPDU, allConfiguredInterfaceIps);
-                isisLsdb.addLsp(lsp, true, this);
-                sendLsp(lsp, channel);
+                if (neighborRouterType == IsisRouterType.L2 || neighborRouterType == IsisRouterType.L1L2) {
+                    LsPdu lsp = new LspGenerator().getLsp(this, lspKey, IsisPduType.L2LSPDU, allConfiguredInterfaceIps);
+                    isisLsdb.addLsp(lsp, true, this);
+                    sendLsp(lsp, channel);
+                }
             }
         }
 
@@ -756,7 +796,9 @@
         lspBytes = IsisUtil.addChecksum(lspBytes, IsisConstants.CHECKSUMPOSITION,
                                         IsisConstants.CHECKSUMPOSITION + 1);
         //write to the channel
-        channel.write(IsisUtil.framePacket(lspBytes, interfaceIndex));
+        if (channel != null && channel.isConnected() && channel.isOpen()) {
+            channel.write(IsisUtil.framePacket(lspBytes, interfaceIndex));
+        }
     }
 
     /**
@@ -794,7 +836,7 @@
                 addNeighbouringRouter(neighbor);
             }
             neighbor.setNeighborState(IsisInterfaceState.DOWN);
-            buildStoreAndSendSelfGeneratedLspIfNotExistInDb(channel);
+            buildStoreAndSendSelfGeneratedLspIfNotExistInDb(channel, IsisRouterType.get(helloPacket.circuitType()));
         } else if (stateTlv.adjacencyType() == IsisInterfaceState.DOWN.value()) {
             neighbor = neighbouringRouter(isisMessage.sourceMac());
             if (neighbor == null) {
@@ -805,6 +847,10 @@
         } else if (stateTlv.adjacencyType() == IsisInterfaceState.INITIAL.value()) {
             //Neighbor already present in the list
             neighbor = neighbouringRouter(isisMessage.sourceMac());
+            if (neighbor == null) {
+                neighbor = new DefaultIsisNeighbor(helloPacket, this);
+                addNeighbouringRouter(neighbor);
+            }
             neighbor.setNeighborState(IsisInterfaceState.INITIAL);
             neighbor.setLocalExtendedCircuitId(stateTlv.localCircuitId());
             //interfaceState = IsisInterfaceState.UP;
@@ -813,9 +859,10 @@
             neighbor = neighbouringRouter(isisMessage.sourceMac());
             neighbor.setNeighborState(IsisInterfaceState.UP);
             neighbor.setLocalExtendedCircuitId(stateTlv.localCircuitId());
-            buildStoreAndSendSelfGeneratedLspIfNotExistInDb(channel);
+            buildStoreAndSendSelfGeneratedLspIfNotExistInDb(channel, IsisRouterType.get(helloPacket.circuitType()));
         }
 
+        neighbor.setHoldingTime(helloPacket.holdingTime());
         neighbor.stopInactivityTimeCheck();
         neighbor.startInactivityTimeCheck();
     }
@@ -828,11 +875,36 @@
      */
     public void processLsPduMessage(IsisMessage isisMessage, Channel channel) {
         log.debug("Enters processLsPduMessage ...!!!");
+        IsisNeighbor neighbor = neighbouringRouter(isisMessage.sourceMac());
+        if (networkType == IsisNetworkType.BROADCAST && neighbor == null) {
+            return;
+        }
+
         LsPdu lsPdu = (LsPdu) isisMessage;
         LspWrapper wrapper = isisLsdb.findLsp(lsPdu.isisPduType(), lsPdu.lspId());
         if (wrapper == null || isisLsdb.isNewerOrSameLsp(lsPdu, wrapper.lsPdu()).equalsIgnoreCase("latest")) {
-            //not exist in the database or latest, then add it in database
-            isisLsdb.addLsp(lsPdu, false, this);
+            if (wrapper != null) {               // verify if the LSA - is your own LSA - get system ID and compare LSP
+                String lspKey = isisLsdb.lspKey(systemId);
+                if (lsPdu.lspId().equals(lspKey)) {
+                    lsPdu.setSequenceNumber(lsPdu.sequenceNumber() + 1);
+                    if (lsPdu.pduType() == IsisPduType.L1LSPDU.value()) {
+                        // setting the ls sequence number
+                        isisLsdb.setL1LspSeqNo(lsPdu.sequenceNumber());
+                    } else if (lsPdu.pduType() == IsisPduType.L2LSPDU.value()) {
+                        // setting the ls sequence number
+                        isisLsdb.setL2LspSeqNo(lsPdu.sequenceNumber());
+                    }
+                    isisLsdb.addLsp(lsPdu, true, this);
+                    sendLsp(lsPdu, channel);
+                } else {
+                    isisLsdb.addLsp(lsPdu, false, this);
+                }
+
+
+            } else {
+                //not exist in the database or latest, then add it in database
+                isisLsdb.addLsp(lsPdu, false, this);
+            }
         }
 
         //If network type is P2P, acknowledge with a PSNP
@@ -865,7 +937,48 @@
                                                               IsisConstants.RESERVEDPOSITION);
             flagValue = false;
             //write to the channel
-            channel.write(IsisUtil.framePacket(psnpBytes, interfaceIndex));
+            if (channel != null && channel.isConnected() && channel.isOpen()) {
+                channel.write(IsisUtil.framePacket(psnpBytes, interfaceIndex));
+            }
+        }
+    }
+
+    /**
+     * Processes PSN PDU message.
+     * Checks for self originated LSP entries in PSNP message and sends the missing LSP.
+     *
+     * @param isisMessage PSN PDU message instance
+     * @param channel     channel instance
+     */
+    public void processPsnPduMessage(IsisMessage isisMessage, Channel channel) {
+        log.debug("Enters processPsnPduMessage ...!!!");
+        //If adjacency not formed don't process.
+        IsisNeighbor neighbor = neighbouringRouter(isisMessage.sourceMac());
+        if (networkType == IsisNetworkType.BROADCAST && neighbor == null) {
+            return;
+        }
+
+        Psnp psnPacket = (Psnp) isisMessage;
+        List<IsisTlv> isisTlvs = psnPacket.getAllTlv();
+        Iterator iterator = isisTlvs.iterator();
+        while (iterator.hasNext()) {
+            IsisTlv isisTlv = (IsisTlv) iterator.next();
+            if (isisTlv instanceof LspEntriesTlv) {
+                LspEntriesTlv lspEntriesTlv = (LspEntriesTlv) isisTlv;
+                List<LspEntry> lspEntryList = lspEntriesTlv.lspEntry();
+                Iterator lspEntryListIterator = lspEntryList.iterator();
+                while (lspEntryListIterator.hasNext()) {
+                    LspEntry lspEntry = (LspEntry) lspEntryListIterator.next();
+                    String lspKey = lspEntry.lspId();
+                    LspWrapper lspWrapper = isisLsdb.findLsp(psnPacket.isisPduType(), lspKey);
+                    if (lspWrapper != null) {
+                        if (lspWrapper.isSelfOriginated()) {
+                            //Sent the LSP
+                            sendLsp((LsPdu) lspWrapper.lsPdu(), channel);
+                        }
+                    }
+                }
+            }
         }
     }
 
@@ -877,123 +990,60 @@
      */
     public void processCsnPduMessage(IsisMessage isisMessage, Channel channel) {
         log.debug("Enters processCsnPduMessage ...!!!");
-        if (reservedPacketCircuitType == IsisRouterType.L1.value()) {
-            processOnL1CsnPdu(isisMessage, channel);
-        } else if (reservedPacketCircuitType == IsisRouterType.L2.value()) {
-            processOnL2CsnPdu(isisMessage, channel);
+        IsisNeighbor neighbor = neighbouringRouter(isisMessage.sourceMac());
+        if (networkType == IsisNetworkType.BROADCAST && neighbor == null) {
+            return;
         }
-    }
 
-    /**
-     * Process the isisMessage which belongs to L1 CSN PDU.
-     * checks the database for this LsPdu if it exists further check for sequence number
-     * sequence number is greater will send PsnPdu.
-     *
-     * @param isisMessage CSN PDU message instance
-     * @param channel     netty channel instance
-     */
-    private void processOnL1CsnPdu(IsisMessage isisMessage, Channel channel) {
         Csnp csnPacket = (Csnp) isisMessage;
+        IsisPduType psnPduType = (IsisPduType.L2CSNP.equals(csnPacket.isisPduType())) ?
+                IsisPduType.L2PSNP : IsisPduType.L1PSNP;
+        IsisPduType lsPduType = (IsisPduType.L2CSNP.equals(csnPacket.isisPduType())) ?
+                IsisPduType.L2LSPDU : IsisPduType.L1LSPDU;
+
         List<LspEntry> lspEntryRequestList = new ArrayList<>();
         boolean selfOriginatedFound = false;
-        if (IsisPduType.L1CSNP.equals(csnPacket.isisPduType())) {
-            List<IsisTlv> isisTlvs = csnPacket.getAllTlv();
-            Iterator iterator = isisTlvs.iterator();
-            while (iterator.hasNext()) {
-                IsisTlv isisTlv = (IsisTlv) iterator.next();
-                if (isisTlv instanceof LspEntriesTlv) {
-                    LspEntriesTlv lspEntriesTlv = (LspEntriesTlv) isisTlv;
-                    List<LspEntry> lspEntryList = lspEntriesTlv.lspEntry();
-                    Iterator lspEntryListIterator = lspEntryList.iterator();
-                    while (lspEntryListIterator.hasNext()) {
-                        LspEntry lspEntry = (LspEntry) lspEntryListIterator.next();
-                        String lspKey = lspEntry.lspId();
-                        LspWrapper lspWrapper = isisLsdb.findLsp(IsisPduType.L1LSPDU, lspKey);
-                        if (lspWrapper != null) {
-                            LsPdu lsPdu = (LsPdu) lspWrapper.lsPdu();
-                            if (lspWrapper.isSelfOriginated()) {
-                                selfOriginatedFound = true;
-                                if (lspEntry.lspSequenceNumber() > lsPdu.sequenceNumber()) {
-                                    sendLsPduMessage(lspEntry.lspSequenceNumber(), csnPacket.isisPduType(), channel);
-                                }
-                            } else {
-                                if (lsPdu.sequenceNumber() < lspEntry.lspSequenceNumber()) {
-                                    lspEntryRequestList.add(lspEntry);
-                                    flagValue = true;
-                                }
+        List<IsisTlv> isisTlvs = csnPacket.getAllTlv();
+        Iterator iterator = isisTlvs.iterator();
+        while (iterator.hasNext()) {
+            IsisTlv isisTlv = (IsisTlv) iterator.next();
+            if (isisTlv instanceof LspEntriesTlv) {
+                LspEntriesTlv lspEntriesTlv = (LspEntriesTlv) isisTlv;
+                List<LspEntry> lspEntryList = lspEntriesTlv.lspEntry();
+                Iterator lspEntryListIterator = lspEntryList.iterator();
+                while (lspEntryListIterator.hasNext()) {
+                    LspEntry lspEntry = (LspEntry) lspEntryListIterator.next();
+                    String lspKey = lspEntry.lspId();
+                    LspWrapper lspWrapper = isisLsdb.findLsp(lsPduType, lspKey);
+                    if (lspWrapper != null) {
+                        LsPdu lsPdu = (LsPdu) lspWrapper.lsPdu();
+                        if (lspWrapper.isSelfOriginated()) {
+                            selfOriginatedFound = true;
+                            if (lspEntry.lspSequenceNumber() < lsPdu.sequenceNumber()) {
+                                sendLsp(lsPdu, channel);
                             }
                         } else {
-                            lspEntryRequestList.add(lspEntry);
-                            flagValue = true;
+                            if (lsPdu.sequenceNumber() < lspEntry.lspSequenceNumber()) {
+                                lspEntryRequestList.add(lspEntry);
+                                flagValue = true;
+                            }
                         }
+                    } else {
+                        lspEntryRequestList.add(lspEntry);
+                        flagValue = true;
                     }
                 }
             }
-            if (flagValue) {
-                sendPsnPduMessage(lspEntryRequestList, csnPacket.isisPduType(), channel);
-            }
-
-            if (!selfOriginatedFound) {
-                String lspKey = isisLsdb.lspKey(systemId);
-                LspWrapper wrapper = isisLsdb.findLsp(IsisPduType.L1LSPDU, lspKey);
-                sendLsp((LsPdu) wrapper.lsPdu(), channel);
-            }
         }
-    }
+        if (flagValue) {
+            sendPsnPduMessage(lspEntryRequestList, psnPduType, channel);
+            lspEntryRequestList.clear();
+        }
 
-    /**
-     * Process the isisMessage which belongs to L2 CSNP.
-     * checks the database for this LsPdu if it exists further check for sequence number
-     * sequence number is greater will send PsnPdu.
-     *
-     * @param isisMessage received CSNP message
-     * @param channel     netty channel instance
-     */
-    private void processOnL2CsnPdu(IsisMessage isisMessage, Channel channel) {
-        Csnp csnPacket = (Csnp) isisMessage;
-        List<LspEntry> lspEntryRequestList = new ArrayList<>();
-        boolean selfOriginatedFound = false;
-        if (IsisPduType.L2CSNP.equals(csnPacket.isisPduType())) {
-            List<IsisTlv> isisTlvs = csnPacket.getAllTlv();
-            Iterator iterator = isisTlvs.iterator();
-            while (iterator.hasNext()) {
-                IsisTlv isisTlv = (IsisTlv) iterator.next();
-                if (isisTlv instanceof LspEntriesTlv) {
-                    LspEntriesTlv lspEntriesTlv = (LspEntriesTlv) isisTlv;
-                    List<LspEntry> lspEntryList = lspEntriesTlv.lspEntry();
-                    Iterator lspEntryListIterator = lspEntryList.iterator();
-                    while (lspEntryListIterator.hasNext()) {
-                        LspEntry lspEntry = (LspEntry) lspEntryListIterator.next();
-                        String lspKey = lspEntry.lspId();
-                        LspWrapper lspWrapper = isisLsdb.findLsp(IsisPduType.L2LSPDU, lspKey);
-                        if (lspWrapper != null) {
-                            LsPdu lsPdu = (LsPdu) lspWrapper.lsPdu();
-                            if (lspWrapper.isSelfOriginated()) {
-                                selfOriginatedFound = true;
-                                if (lspEntry.lspSequenceNumber() > lsPdu.sequenceNumber()) {
-                                    sendLsPduMessage(lspEntry.lspSequenceNumber(), csnPacket.isisPduType(), channel);
-                                }
-                            } else {
-                                if (lsPdu.sequenceNumber() < lspEntry.lspSequenceNumber()) {
-                                    lspEntryRequestList.add(lspEntry);
-                                    flagValue = true;
-                                }
-                            }
-                        } else {
-                            lspEntryRequestList.add(lspEntry);
-                            flagValue = true;
-                        }
-                    }
-                }
-            }
-            if (flagValue) {
-                sendPsnPduMessage(lspEntryRequestList, csnPacket.isisPduType(), channel);
-                lspEntryRequestList.clear();
-            }
-
-            if (!selfOriginatedFound) {
-                String lspKey = isisLsdb.lspKey(systemId);
-                LspWrapper wrapper = isisLsdb.findLsp(IsisPduType.L2LSPDU, lspKey);
+        if (!selfOriginatedFound) {
+            String lspKey = isisLsdb.lspKey(systemId);
+            LspWrapper wrapper = isisLsdb.findLsp(lsPduType, lspKey);
+            if (wrapper != null) {
                 sendLsp((LsPdu) wrapper.lsPdu(), channel);
             }
         }
@@ -1007,13 +1057,7 @@
      * @param channel             netty channel instance
      */
     private void sendPsnPduMessage(List<LspEntry> lspEntryRequestList, IsisPduType isisPduType, Channel channel) {
-        IsisPduType psnpType = null;
-        if (isisPduType == IsisPduType.L1CSNP) {
-            psnpType = IsisPduType.L1PSNP;
-        } else if (reservedPacketCircuitType == IsisRouterType.L2.value()) {
-            psnpType = IsisPduType.L2PSNP;
-        }
-        IsisHeader isisHeader = new LspGenerator().getHeader(psnpType);
+        IsisHeader isisHeader = new LspGenerator().getHeader(isisPduType);
         Psnp psnp = new Psnp(isisHeader);
         psnp.setSourceId(lspKeyP2P(this.systemId));
         TlvHeader tlvHeader = new TlvHeader();
@@ -1021,6 +1065,9 @@
         tlvHeader.setTlvLength(0);
         LspEntriesTlv lspEntriesTlv = new LspEntriesTlv(tlvHeader);
         for (LspEntry lspEntry : lspEntryRequestList) {
+            lspEntry.setLspChecksum(0);
+            lspEntry.setLspSequenceNumber(0);
+            lspEntry.setRemainingTime(0);
             lspEntriesTlv.addLspEntry(lspEntry);
         }
         psnp.addTlv(lspEntriesTlv);
@@ -1031,7 +1078,9 @@
                                                           IsisConstants.RESERVEDPOSITION);
         flagValue = false;
         //write to the channel
-        channel.write(IsisUtil.framePacket(psnpBytes, interfaceIndex));
+        if (channel != null && channel.isConnected() && channel.isOpen()) {
+            channel.write(IsisUtil.framePacket(psnpBytes, interfaceIndex));
+        }
     }
 
     /**
@@ -1048,28 +1097,6 @@
     }
 
     /**
-     * Sends the link state PDU with latest self generated lsp entry.
-     *
-     * @param sequenceNumber sequence number of the self generated lsp
-     * @param isisPduType    intermediate system type
-     * @param channel        netty channel instance
-     */
-    private void sendLsPduMessage(int sequenceNumber, IsisPduType isisPduType, Channel channel) {
-        String lspKey = isisLsdb.lspKey(systemId);
-        LsPdu lsp = new LspGenerator().getLsp(this, lspKey, isisPduType, allConfiguredInterfaceIps);
-        lsp.setSequenceNumber(sequenceNumber);
-        byte[] lspBytes = lsp.asBytes();
-        lspBytes = IsisUtil.addLengthAndMarkItInReserved(lspBytes, IsisConstants.LENGTHPOSITION,
-                                                         IsisConstants.LENGTHPOSITION + 1,
-                                                         IsisConstants.RESERVEDPOSITION);
-        lspBytes = IsisUtil.addChecksum(lspBytes, IsisConstants.CHECKSUMPOSITION,
-                                        IsisConstants.CHECKSUMPOSITION + 1);
-        //write to the channel
-        channel.write(IsisUtil.framePacket(lspBytes, interfaceIndex));
-    }
-
-
-    /**
      * Starts the hello timer which sends hello packet every configured seconds.
      *
      * @param channel netty channel instance
@@ -1083,4 +1110,12 @@
                 exServiceHello.scheduleAtFixedRate(isisHelloPduSender, 0,
                                                    helloInterval, TimeUnit.SECONDS);
     }
+
+    /**
+     * Stops the hello timer which sends hello packet every configured seconds.
+     */
+    public void stopHelloSender() {
+        log.debug("IsisInterfaceImpl::stopHelloSender");
+        exServiceHello.shutdown();
+    }
 }
\ No newline at end of file
diff --git a/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/DefaultIsisNeighbor.java b/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/DefaultIsisNeighbor.java
old mode 100755
new mode 100644
index 7fac0cb..3e05a37
--- a/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/DefaultIsisNeighbor.java
+++ b/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/DefaultIsisNeighbor.java
@@ -88,6 +88,7 @@
         }
         this.isisInterface = isisInterface;
         startHoldingTimeCheck();
+        log.debug("Neighbor added - {}", neighborMacAddress);
     }
 
     /**
@@ -387,6 +388,10 @@
         @Override
         public void run() {
             holdingTime--;
+            if (holdingTime <= 0) {
+                log.debug("Calling neighbor down. Holding time is 0.");
+                neighborDown();
+            }
         }
     }
 }
\ No newline at end of file
diff --git a/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/DefaultIsisProcess.java b/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/DefaultIsisProcess.java
old mode 100755
new mode 100644
diff --git a/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/IsisChannelHandler.java b/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/IsisChannelHandler.java
old mode 100755
new mode 100644
index 064176d..86c6853
--- a/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/IsisChannelHandler.java
+++ b/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/IsisChannelHandler.java
@@ -94,13 +94,35 @@
             for (IsisInterface isisUpdatedInterface : isisUpdatedProcess.isisInterfaceList()) {
                 IsisInterface isisInterface = isisInterfaceMap.get(isisUpdatedInterface.interfaceIndex());
                 if (isisInterface == null) {
-                    isisInterfaceMap.put(isisInterface.interfaceIndex(), isisInterface);
-                    interfaceIps.add(isisInterface.interfaceIpAddress());
+                    isisInterfaceMap.put(isisUpdatedInterface.interfaceIndex(), isisUpdatedInterface);
+                    interfaceIps.add(isisUpdatedInterface.interfaceIpAddress());
                 } else {
-                    isisInterface.setReservedPacketCircuitType(isisUpdatedInterface.reservedPacketCircuitType());
-                    isisInterface.setNetworkType(isisUpdatedInterface.networkType());
-                    isisInterface.setHoldingTime(isisUpdatedInterface.holdingTime());
-                    isisInterface.setHelloInterval(isisUpdatedInterface.helloInterval());
+                    if (isisInterface.intermediateSystemName() != isisUpdatedInterface.intermediateSystemName()) {
+                        isisInterface.setIntermediateSystemName(isisUpdatedInterface.intermediateSystemName());
+                    }
+                    if (isisInterface.reservedPacketCircuitType() != isisUpdatedInterface.reservedPacketCircuitType()) {
+                        isisInterface.setReservedPacketCircuitType(isisUpdatedInterface.reservedPacketCircuitType());
+                        isisInterface.removeNeighbors();
+                    }
+                    if (isisInterface.circuitId() != isisUpdatedInterface.circuitId()) {
+                        isisInterface.setCircuitId(isisUpdatedInterface.circuitId());
+                    }
+                    if (isisInterface.networkType() != isisUpdatedInterface.networkType()) {
+                        isisInterface.setNetworkType(isisUpdatedInterface.networkType());
+                        isisInterface.removeNeighbors();
+                    }
+                    if (isisInterface.areaAddress() != isisUpdatedInterface.areaAddress()) {
+                        isisInterface.setAreaAddress(isisUpdatedInterface.areaAddress());
+                    }
+                    if (isisInterface.holdingTime() != isisUpdatedInterface.holdingTime()) {
+                        isisInterface.setHoldingTime(isisUpdatedInterface.holdingTime());
+                    }
+                    if (isisInterface.helloInterval() != isisUpdatedInterface.helloInterval()) {
+                        isisInterface.setHelloInterval(isisUpdatedInterface.helloInterval());
+                        isisInterface.stopHelloSender();
+                        isisInterface.startHelloSender(channel);
+                    }
+
                     isisInterfaceMap.put(isisInterface.interfaceIndex(), isisInterface);
                 }
             }
@@ -144,6 +166,9 @@
     @Override
     public void channelDisconnected(ChannelHandlerContext ctx, ChannelStateEvent evt) {
         log.debug("IsisChannelHandler::channelDisconnected...!!!");
+        if (controller != null) {
+            controller.connectPeer();
+        }
     }
 
     @Override
@@ -169,8 +194,9 @@
         } else if (e.getCause() instanceof RejectedExecutionException) {
             log.warn("Could not process message: queue full");
         } else {
-            log.error("Error while processing message from ISIS {}",
-                      e.getChannel().getRemoteAddress());
+            log.error("Error while processing message from ISIS {}, {}",
+                      e.getChannel().getRemoteAddress(), e.getCause().getMessage());
+            e.getCause().printStackTrace();
         }
     }
 
diff --git a/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/IsisHelloPduSender.java b/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/IsisHelloPduSender.java
old mode 100755
new mode 100644
index 87338f5..e798b3e
--- a/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/IsisHelloPduSender.java
+++ b/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/IsisHelloPduSender.java
@@ -45,7 +45,7 @@
 
     @Override
     public void run() {
-        if (channel != null) {
+        if (channel != null && channel.isConnected() && channel.isOpen()) {
             try {
                 byte[] helloPdu = null;
                 byte[] interfaceIndex = {(byte) isisInterface.interfaceIndex()};
diff --git a/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/IsisMessageDecoder.java b/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/IsisMessageDecoder.java
old mode 100755
new mode 100644
index f2cbf19..b75bc3f
--- a/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/IsisMessageDecoder.java
+++ b/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/IsisMessageDecoder.java
@@ -44,7 +44,6 @@
             log.info("Channel is not connected.");
             return null;
         }
-
         IsisMessageReader messageReader = new IsisMessageReader();
         List<IsisMessage> isisMessageList = new LinkedList<>();
         int dataLength = buffer.readableBytes();
@@ -74,8 +73,7 @@
                 isisMessageList.add(message);
             }
         }
-
-        return isisMessageList;
+        return (isisMessageList.size() > 0) ? isisMessageList : null;
     }
 
     /**
diff --git a/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/IsisMessageEncoder.java b/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/IsisMessageEncoder.java
old mode 100755
new mode 100644
diff --git a/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/IsisPipelineFactory.java b/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/IsisPipelineFactory.java
old mode 100755
new mode 100644
diff --git a/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/lsdb/DefaultIsisLsdb.java b/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/lsdb/DefaultIsisLsdb.java
old mode 100755
new mode 100644
index 8a58269..3c66bf8
--- a/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/lsdb/DefaultIsisLsdb.java
+++ b/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/lsdb/DefaultIsisLsdb.java
@@ -45,7 +45,6 @@
     private IsisLsdbAge lsdbAge = null;
 
 
-
     private int l1LspSeqNo = IsisConstants.STARTLSSEQUENCENUM;
     private int l2LspSeqNo = IsisConstants.STARTLSSEQUENCENUM;
 
@@ -80,6 +79,7 @@
     public void setL2LspSeqNo(int l2LspSeqNo) {
         this.l2LspSeqNo = l2LspSeqNo;
     }
+
     /**
      * Returns the LSDB LSP key.
      *
@@ -96,6 +96,7 @@
         return lspKey.toString();
     }
 
+
     /**
      * Returns the neighbor L1 database information.
      *
@@ -218,7 +219,12 @@
             byte[] checkSum = {lspBytes[IsisConstants.CHECKSUMPOSITION], lspBytes[IsisConstants.CHECKSUMPOSITION + 1]};
             lspdu.setCheckSum(ChannelBuffers.copiedBuffer(checkSum).readUnsignedShort());
         }
-        DefaultLspWrapper lspWrapper = new DefaultLspWrapper();
+
+        DefaultLspWrapper lspWrapper = (DefaultLspWrapper) findLsp(lspdu.isisPduType(), lspdu.lspId());
+        if (lspWrapper == null) {
+            lspWrapper = new DefaultLspWrapper();
+        }
+
         lspWrapper.setLspAgeReceived(IsisConstants.LSPMAXAGE - lspdu.remainingLifeTime());
         lspWrapper.setLspType(IsisPduType.get(lspdu.pduType()));
         lspWrapper.setLsPdu(lspdu);
@@ -228,8 +234,8 @@
         lspWrapper.setIsisInterface(isisInterface);
         lspWrapper.setLsdbAge(lsdbAge);
         addLsp(lspWrapper, lspdu.lspId());
-        log.debug("Added LSp In LSDB: {}", lspWrapper);
 
+        log.debug("Added LSp In LSDB: {}", lspWrapper);
         return true;
     }
 
@@ -270,7 +276,6 @@
                       lspWrapper.lsPdu().isisPduType(),
                       binNumber, lspWrapper.remainingLifetime());
         }
-
         return false;
     }
 
@@ -344,4 +349,4 @@
                 break;
         }
     }
-}
+}
\ No newline at end of file
diff --git a/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/lsdb/DefaultIsisLsdbAge.java b/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/lsdb/DefaultIsisLsdbAge.java
old mode 100755
new mode 100644
index 2cf07ba..5a48798
--- a/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/lsdb/DefaultIsisLsdbAge.java
+++ b/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/lsdb/DefaultIsisLsdbAge.java
@@ -36,10 +36,10 @@
  */
 public class DefaultIsisLsdbAge implements IsisLsdbAge {
     private static final Logger log = LoggerFactory.getLogger(DefaultIsisLsdbAge.class);
-    protected static int ageCounter = 0;
+    protected int ageCounter = 0;
     private InternalAgeTimer dbAgeTimer;
     private ScheduledExecutorService exServiceage;
-    private Integer maxBins = 1200;
+    private Integer maxBins = IsisConstants.LSPMAXAGE;
     private Map<Integer, IsisLspBin> ageBins = new ConcurrentHashMap<>(maxBins);
     private int ageCounterRollOver = 0;
     private IsisLspQueueConsumer queueConsumer = null;
@@ -202,7 +202,7 @@
         } else {
             binNumber = ageCounter - IsisConstants.LSPREFRESH;
         }
-        if (binNumber > IsisConstants.LSPMAXAGE) {
+        if (binNumber >= IsisConstants.LSPMAXAGE) {
             binNumber = binNumber - IsisConstants.LSPMAXAGE;
         }
         IsisLspBin lspBin = ageBins.get(binNumber);
diff --git a/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/lsdb/DefaultIsisLspBin.java b/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/lsdb/DefaultIsisLspBin.java
old mode 100755
new mode 100644
diff --git a/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/lsdb/DefaultLspWrapper.java b/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/lsdb/DefaultLspWrapper.java
old mode 100755
new mode 100644
index b89e88f..b9b3306
--- a/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/lsdb/DefaultLspWrapper.java
+++ b/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/lsdb/DefaultLspWrapper.java
@@ -21,11 +21,14 @@
 import org.onosproject.isis.controller.LspWrapper;
 import org.onosproject.isis.io.isispacket.pdu.LsPdu;
 import org.onosproject.isis.io.util.IsisConstants;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * Representation of LSP wrapper where the LSPs are stored with metadata.
  */
 public class DefaultLspWrapper implements LspWrapper {
+    private static final Logger log = LoggerFactory.getLogger(DefaultLspWrapper.class);
     private int binNumber = -1;
     private boolean selfOriginated = false;
     private IsisPduType lspType;
@@ -229,7 +232,15 @@
         int currentAge = 0;
         //ls age received
         if (lsdbAge.ageCounter() >= ageCounterWhenReceived) {
+            if (!selfOriginated) {
+                if (ageCounterRollOverWhenAdded == lsdbAge.ageCounterRollOver()) {
             currentAge = lspAgeReceived + (lsdbAge.ageCounter() - ageCounterWhenReceived);
+                } else {
+                    return IsisConstants.LSPMAXAGE;
+                }
+            } else {
+                currentAge = lspAgeReceived + (lsdbAge.ageCounter() - ageCounterWhenReceived);
+            }
         } else {
             currentAge = lspAgeReceived + ((IsisConstants.LSPMAXAGE + lsdbAge.ageCounter())
                     - ageCounterWhenReceived);
@@ -245,6 +256,8 @@
         return currentAge;
     }
 
+
+
     /**
      * Returns remaining time.
      *
@@ -252,7 +265,7 @@
      */
     public int remainingLifetime() {
         //Calculate the remaining lifetime
-        remainingLifetime = IsisConstants.LSPMAXAGE - lsdbAge.ageCounter();
+        remainingLifetime = IsisConstants.LSPMAXAGE - currentAge();
         return remainingLifetime;
     }
 
diff --git a/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/lsdb/IsisLspQueueConsumer.java b/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/lsdb/IsisLspQueueConsumer.java
old mode 100755
new mode 100644
index 9007093..b5eca27
--- a/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/lsdb/IsisLspQueueConsumer.java
+++ b/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/lsdb/IsisLspQueueConsumer.java
@@ -100,7 +100,9 @@
                                                 IsisConstants.CHECKSUMPOSITION + 1);
                 //write to the channel
                 channel.write(IsisUtil.framePacket(lspBytes, isisInterface.interfaceIndex()));
-
+                // Updating the database with resetting remaining life time to default.
+                IsisLsdb isisDb = isisInterface.isisLsdb();
+                isisDb.addLsp(lsPdu, true, isisInterface);
                 log.debug("LSPQueueConsumer: processRefreshLsp - Flooded SelfOriginated LSP {}",
                           wrapper.lsPdu());
             }
diff --git a/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/lsdb/package-info.java b/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/lsdb/package-info.java
old mode 100755
new mode 100644
diff --git a/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/package-info.java b/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/package-info.java
old mode 100755
new mode 100644
diff --git a/protocols/isis/ctl/src/test/java/org/onosproject/isis/controller/impl/ControllerTest.java b/protocols/isis/ctl/src/test/java/org/onosproject/isis/controller/impl/ControllerTest.java
index 9a41bd3..13ec2cc 100644
--- a/protocols/isis/ctl/src/test/java/org/onosproject/isis/controller/impl/ControllerTest.java
+++ b/protocols/isis/ctl/src/test/java/org/onosproject/isis/controller/impl/ControllerTest.java
@@ -16,6 +16,8 @@
 
 package org.onosproject.isis.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;
@@ -30,10 +32,65 @@
 public class ControllerTest {
 
     private Controller controller;
+    private ObjectMapper mapper;
+    private JsonNode jsonNode;
+    private JsonNode jsonNode1;
+    private String jsonString = "{" +
+            "                \"processes\": [{" +
+            "                                \"processId\": \"4.4.4.4\"," +
+            "                                \"interface\": [{" +
+            "                                                \"interfaceIndex\": \"2\"," +
+            "                                                \"macAddress\": \"08:00:27:b7:ab:bf\"," +
+            "                                                \"interfaceIp\": \"192.168.56.101\"," +
+            "                                                \"networkMask\": \"255.255.255.224\"," +
+            "                                                \"intermediateSystemName\": \"ROUTERONE\"," +
+            "                                                \"systemId\": \"2929.2929.2929\"," +
+            "                                                \"lanId\": \"0000.0000.0000.00\"," +
+            "                                                \"idLength\": \"0\"," +
+            "                                                \"maxAreaAddresses\": \"3\"," +
+            "                                                \"reservedPacketCircuitType\": \"1\"," +
+            "                                                \"circuitId\": \"10\"," +
+            "                                                \"networkType\": \"2\"," +
+            "                                                \"areaAddress\": \"490000\"," +
+            "                                                \"areaLength\": \"3\"," +
+            "                                                \"lspId\": \"1313131313130000\"," +
+            "                                                \"holdingTime\": \"50\"," +
+            "                                                \"helloInterval\": \"10\"," +
+            "                                                \"priority\": \"0\"" +
+            "                                }]" +
+            "                }]" +
+            "}";
+    private String jsonString1 = "{" +
+            "                \"processes\": {" +
+            "                                \"interface\": [{" +
+            "                                                \"interfaceIndex\": \"2\"," +
+            "                                                \"interfaceIp\": \"100.100.100.100\"," +
+            "                                                \"macAddress\": \"08:00:27:b7:ab:bf\"," +
+            "                                                \"networkMask\": \"255.255.255.224\"," +
+            "                                                \"intermediateSystemName\": \"ROUTERONE\"," +
+            "                                                \"systemId\": \"2929.2929.2929\"," +
+            "                                                \"lanId\": \"0000.0000.0000.00\"," +
+            "                                                \"idLength\": \"0\"," +
+            "                                                \"maxAreaAddresses\": \"3\"," +
+            "                                                \"reservedPacketCircuitType\": \"1\"," +
+            "                                                \"circuitId\": \"10\"," +
+            "                                                \"networkType\": \"2\"," +
+            "                                                \"areaAddress\": \"490000\"," +
+            "                                                \"areaLength\": \"3\"," +
+            "                                                \"lspId\": \"1313131313130000\"," +
+            "                                                \"holdingTime\": \"50\"," +
+            "                                                \"helloInterval\": \"10\"," +
+            "                                                \"priority\": \"0\"" +
+            "                                }]" +
+            "                }" +
+            "}";
 
     @Before
     public void setUp() throws Exception {
         controller = new Controller();
+        mapper = new ObjectMapper();
+        jsonNode = mapper.readTree(jsonString);
+        jsonNode1 = mapper.readTree(jsonString1);
     }
 
     @After
@@ -58,4 +115,18 @@
         controller.getAllConfiguredProcesses();
         assertThat(controller, is(notNullValue()));
     }
+
+    /**
+     * Tests updateConfig() method.
+     */
+    @Test
+    public void testUpdateConfig() throws Exception {
+        jsonNode.path("interface");
+        controller.updateConfig(jsonNode);
+        assertThat(controller, is(notNullValue()));
+
+        controller.updateConfig(jsonNode1);
+        assertThat(controller, is(notNullValue()));
+    }
+
 }
\ No newline at end of file
diff --git a/protocols/isis/ctl/src/test/java/org/onosproject/isis/controller/impl/DefaultIsisControllerTest.java b/protocols/isis/ctl/src/test/java/org/onosproject/isis/controller/impl/DefaultIsisControllerTest.java
index 915727d..61af4d7 100644
--- a/protocols/isis/ctl/src/test/java/org/onosproject/isis/controller/impl/DefaultIsisControllerTest.java
+++ b/protocols/isis/ctl/src/test/java/org/onosproject/isis/controller/impl/DefaultIsisControllerTest.java
@@ -15,9 +15,13 @@
  */
 package org.onosproject.isis.controller.impl;
 
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.easymock.EasyMock;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
+import org.onosproject.isis.controller.topology.IsisRouterListener;
 
 import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.CoreMatchers.notNullValue;
@@ -27,11 +31,43 @@
  * Unit test case for DefaultIsisController.
  */
 public class DefaultIsisControllerTest {
+    private ObjectMapper mapper;
+    private JsonNode jsonNode;
     private DefaultIsisController defaultIsisController;
+    private String jsonString = "{" +
+            "                \"processes\": [{" +
+            "                                \"processId\": \"4.4.4.4\"," +
+            "                                \"interface\": [{" +
+            "                                                \"interfaceIndex\": \"2\"," +
+            "                                                \"macAddress\": \"08:00:27:b7:ab:bf\"," +
+            "                                                \"interfaceIp\": \"192.168.56.101\"," +
+            "                                                \"networkMask\": \"255.255.255.224\"," +
+            "                                                \"intermediateSystemName\": \"ROUTERONE\"," +
+            "                                                \"systemId\": \"2929.2929.2929\"," +
+            "                                                \"lanId\": \"0000.0000.0000.00\"," +
+            "                                                \"idLength\": \"0\"," +
+            "                                                \"maxAreaAddresses\": \"3\"," +
+            "                                                \"reservedPacketCircuitType\": \"1\"," +
+            "                                                \"circuitId\": \"10\"," +
+            "                                                \"networkType\": \"2\"," +
+            "                                                \"areaAddress\": \"490000\"," +
+            "                                                \"areaLength\": \"3\"," +
+            "                                                \"lspId\": \"1313131313130000\"," +
+            "                                                \"holdingTime\": \"50\"," +
+            "                                                \"helloInterval\": \"10\"," +
+            "                                                \"priority\": \"0\"" +
+            "                                }]" +
+            "                }]" +
+            "}";
+
+    private IsisRouterListener isisRouterListener;
 
     @Before
     public void setUp() throws Exception {
         defaultIsisController = new DefaultIsisController();
+        mapper = new ObjectMapper();
+        jsonNode = mapper.readTree(jsonString);
+        isisRouterListener = EasyMock.createNiceMock(IsisRouterListener.class);
     }
 
     @After
@@ -66,4 +102,31 @@
         defaultIsisController.allConfiguredProcesses();
         assertThat(defaultIsisController, is(notNullValue()));
     }
+
+    /**
+     * Tests updateConfig() method.
+     */
+    @Test
+    public void testUpdateConfig() throws Exception {
+        defaultIsisController.updateConfig(jsonNode);
+        assertThat(defaultIsisController, is(notNullValue()));
+    }
+
+    /**
+     * Tests addRouterListener() method.
+     */
+    @Test
+    public void testaddRouterListener() throws Exception {
+        defaultIsisController.addRouterListener(isisRouterListener);
+        assertThat(defaultIsisController, is(notNullValue()));
+    }
+
+    /**
+     * Tests removeRouterListener() method.
+     */
+    @Test
+    public void testremoveRouterListener() throws Exception {
+        defaultIsisController.removeRouterListener(isisRouterListener);
+        assertThat(defaultIsisController, is(notNullValue()));
+    }
 }
diff --git a/protocols/isis/ctl/src/test/java/org/onosproject/isis/controller/impl/DefaultIsisInterfaceTest.java b/protocols/isis/ctl/src/test/java/org/onosproject/isis/controller/impl/DefaultIsisInterfaceTest.java
index 7e7749f..fe8a57a 100644
--- a/protocols/isis/ctl/src/test/java/org/onosproject/isis/controller/impl/DefaultIsisInterfaceTest.java
+++ b/protocols/isis/ctl/src/test/java/org/onosproject/isis/controller/impl/DefaultIsisInterfaceTest.java
@@ -15,6 +15,10 @@
  */
 package org.onosproject.isis.controller.impl;
 
+import org.easymock.EasyMock;
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.jboss.netty.buffer.ChannelBuffers;
+import org.jboss.netty.channel.Channel;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
@@ -23,15 +27,30 @@
 import org.onosproject.isis.controller.IsisInterface;
 import org.onosproject.isis.controller.IsisInterfaceState;
 import org.onosproject.isis.controller.IsisLsdb;
+import org.onosproject.isis.controller.IsisMessage;
 import org.onosproject.isis.controller.IsisNeighbor;
 import org.onosproject.isis.controller.IsisNetworkType;
+import org.onosproject.isis.controller.IsisPduType;
+import org.onosproject.isis.controller.IsisRouterType;
+import org.onosproject.isis.controller.impl.lsdb.DefaultIsisLsdb;
 import org.onosproject.isis.io.isispacket.IsisHeader;
-import org.onosproject.isis.io.isispacket.pdu.HelloPdu;
+import org.onosproject.isis.io.isispacket.pdu.Csnp;
 import org.onosproject.isis.io.isispacket.pdu.L1L2HelloPdu;
+import org.onosproject.isis.io.isispacket.pdu.LsPdu;
+import org.onosproject.isis.io.isispacket.pdu.P2PHelloPdu;
+import org.onosproject.isis.io.isispacket.pdu.Psnp;
+import org.onosproject.isis.io.isispacket.tlv.AdjacencyStateTlv;
+import org.onosproject.isis.io.isispacket.tlv.AreaAddressTlv;
+import org.onosproject.isis.io.isispacket.tlv.LspEntriesTlv;
+import org.onosproject.isis.io.isispacket.tlv.LspEntry;
+import org.onosproject.isis.io.isispacket.tlv.TlvHeader;
+import org.onosproject.isis.io.isispacket.tlv.TlvType;
 
+import java.util.ArrayList;
+import java.util.List;
 import java.util.Set;
 
-import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.*;
 import static org.junit.Assert.assertThat;
 
 /**
@@ -39,16 +58,26 @@
  */
 public class DefaultIsisInterfaceTest {
     private final MacAddress macAddress = MacAddress.valueOf("AA:BB:CC:DD:EE:FF");
-    private final Ip4Address ip4Address = Ip4Address.valueOf("10.10.10.10");
+    private final MacAddress macAddress1 = MacAddress.valueOf("AA:CC:CC:DD:EE:FF");
+    private final Ip4Address ip4Address = Ip4Address.valueOf("10.10.0.0");
     private final byte[] mask = {
             (byte) 255, (byte) 255, (byte) 255, (byte) 224
     };
+    private final byte[] mask1 = {
+            (byte) 0, (byte) 0, (byte) 0, (byte) 0
+    };
     private final String intSysName = "ROUTER";
     private final String sysId = "1111.1111.1111";
     private final String areaAddr = "49.002";
+    private final byte[] csnpBytes = {
+            0, 67, 18, 52, 18, 52, 0,
+            18, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1, -1, -1, -1, -1,
+            -1, -1, 9, 32, 4, -81, 18, 52, 18, 52, 0, 18, 0, 0, 0,
+            0, 0, 41, -92, -30, 4, -81, 41, 41, 41, 41, 41, 41, 0,
+            0, 0, 0, 0, 1, 91, 126
+    };
     private IsisInterfaceState resultIfState;
     private DefaultIsisInterface defaultIsisInterface;
-    private HelloPdu helloPdu;
     private IsisHeader isisHeader;
     private IsisInterface isisInterface;
     private Set<MacAddress> resultSet;
@@ -60,18 +89,35 @@
     private byte[] resultByteArr;
     private String resultStr;
     private IsisNetworkType resultNwType;
-
+    private List<Ip4Address> ip4Addresses = new ArrayList<>();
+    private DefaultIsisNeighbor defaultIsisNeighbor;
+    private IsisNeighbor result;
+    private IsisLsdb result1;
+    private Set<MacAddress> result2;
+    private Channel result3;
+    private IsisMessage isisMessage;
+    private IsisLsdb isisLsdb;
+    private Channel channel;
+    private L1L2HelloPdu helloPdu;
+    private LsPdu lsPdu;
+    private Csnp csnp;
+    private Psnp psnp;
+    private P2PHelloPdu p2PHelloPdu;
+    private boolean result4;
+    private String result5;
 
     @Before
     public void setUp() throws Exception {
+        channel = EasyMock.createNiceMock(Channel.class);
         defaultIsisInterface = new DefaultIsisInterface();
+        defaultIsisInterface.setInterfaceMacAddress(macAddress);
         isisHeader = new IsisHeader();
         isisHeader.setIrpDiscriminator((byte) 1);
         helloPdu = new L1L2HelloPdu(isisHeader);
         isisInterface = new DefaultIsisInterface();
-        resultNeighborList = new DefaultIsisNeighbor(helloPdu, isisInterface);
-
-
+        defaultIsisNeighbor = new DefaultIsisNeighbor(helloPdu, isisInterface);
+        defaultIsisNeighbor.setNeighborMacAddress(macAddress);
+        isisLsdb = new DefaultIsisLsdb();
     }
 
     @After
@@ -365,26 +411,6 @@
     }
 
     /**
-     * Tests getLspId() getter method.
-     */
-    @Test
-    public void testGetLspId() throws Exception {
-        defaultIsisInterface.setLspId(sysId);
-        resultStr = defaultIsisInterface.getLspId();
-        assertThat(resultStr, is(sysId));
-    }
-
-    /**
-     * Tests getLspId() setter method.
-     */
-    @Test
-    public void testSetLspId() throws Exception {
-        defaultIsisInterface.setLspId(sysId);
-        resultStr = defaultIsisInterface.getLspId();
-        assertThat(resultStr, is(sysId));
-    }
-
-    /**
      * Tests holdingTime() getter method.
      */
     @Test
@@ -483,4 +509,369 @@
         resultStr = defaultIsisInterface.circuitId();
         assertThat(resultStr, is(sysId));
     }
+
+    /**
+     * Tests setAllConfiguredInterfaceIps() setter method.
+     */
+    @Test
+    public void testSetAllConfiguredInterfaceIps() throws Exception {
+        ip4Addresses.add(ip4Address);
+        defaultIsisInterface.setAllConfiguredInterfaceIps(ip4Addresses);
+        assertThat(defaultIsisInterface, is(notNullValue()));
+    }
+
+    /**
+     * Tests setAllConfiguredInterfaceIps() method.
+     */
+    @Test
+    public void testRemoveNeighbor() throws Exception {
+        defaultIsisInterface.removeNeighbor(defaultIsisNeighbor);
+        assertThat(defaultIsisInterface, is(notNullValue()));
+    }
+
+    /**
+     * Tests lookup() method.
+     */
+    @Test
+    public void testLookup() throws Exception {
+        result = defaultIsisInterface.lookup(defaultIsisNeighbor.neighborMacAddress());
+        assertThat(result, is(nullValue()));
+    }
+
+    /**
+     * Tests isisLsdb() method.
+     */
+    @Test
+    public void testIsisLsdb() throws Exception {
+        result1 = defaultIsisInterface.isisLsdb();
+        assertThat(result1, is(nullValue()));
+    }
+
+    /**
+     * Tests neighbors() method.
+     */
+    @Test
+    public void testNeighbors() throws Exception {
+        result2 = defaultIsisInterface.neighbors();
+        assertThat(result2, is(notNullValue()));
+    }
+
+    /**
+     * Tests channel() method.
+     */
+    @Test
+    public void testChannel() throws Exception {
+        result3 = defaultIsisInterface.channel();
+        assertThat(result3, is(nullValue()));
+    }
+
+    /**
+     * Tests processIsisMessage() method.
+     */
+    @Test
+    public void testProcessIsisMessage() throws Exception {
+        helloPdu = new L1L2HelloPdu(isisHeader);
+        helloPdu.setSourceMac(macAddress1);
+        helloPdu.setIsisPduType(IsisPduType.L2HELLOPDU.value());
+        defaultIsisInterface.setNetworkType(IsisNetworkType.BROADCAST);
+        isisMessage = helloPdu;
+        defaultIsisInterface.processIsisMessage(isisMessage, isisLsdb, channel);
+        assertThat(defaultIsisInterface, is(notNullValue()));
+    }
+
+    /**
+     * Tests processIsisMessage() method.
+     */
+    @Test(expected = Exception.class)
+    public void testProcessIsisMessage1() throws Exception {
+        lsPdu = new LsPdu(isisHeader);
+        lsPdu.setSourceMac(macAddress1);
+        lsPdu.setIsisPduType(IsisPduType.L2LSPDU.value());
+        isisMessage = lsPdu;
+        defaultIsisInterface.processIsisMessage(isisMessage, isisLsdb, channel);
+        assertThat(defaultIsisInterface, is(notNullValue()));
+    }
+
+    /**
+     * Tests processIsisMessage() method.
+     */
+    @Test
+    public void testProcessIsisMessage2() throws Exception {
+        csnp = new Csnp(isisHeader);
+        csnp.setSourceMac(macAddress1);
+        csnp.setIsisPduType(IsisPduType.L2CSNP.value());
+        isisMessage = csnp;
+        defaultIsisInterface.processIsisMessage(isisMessage, isisLsdb, channel);
+        assertThat(defaultIsisInterface, is(notNullValue()));
+    }
+
+    /**
+     * Tests processIsisMessage() method.
+     */
+    @Test
+    public void testProcessIsisMessage3() throws Exception {
+        psnp = new Psnp(isisHeader);
+        psnp.setSourceMac(macAddress1);
+        psnp.setIsisPduType(IsisPduType.L2PSNP.value());
+        isisMessage = psnp;
+        defaultIsisInterface.processIsisMessage(isisMessage, isisLsdb, channel);
+        assertThat(defaultIsisInterface, is(notNullValue()));
+    }
+
+    /**
+     * Tests processIsisMessage() method.
+     */
+    @Test
+    public void testProcessIsisMessage4() throws Exception {
+        p2PHelloPdu = new P2PHelloPdu(isisHeader);
+        p2PHelloPdu.setSourceMac(macAddress1);
+        p2PHelloPdu.setIsisPduType(IsisPduType.P2PHELLOPDU.value());
+        defaultIsisInterface.setNetworkType(IsisNetworkType.P2P);
+        isisMessage = p2PHelloPdu;
+        defaultIsisInterface.processIsisMessage(isisMessage, isisLsdb, channel);
+        assertThat(defaultIsisInterface, is(notNullValue()));
+    }
+
+    /**
+     * Tests validateHelloMessage() method.
+     */
+    @Test
+    public void testValidateHelloMessage() throws Exception {
+        helloPdu = new L1L2HelloPdu(isisHeader);
+        result4 = defaultIsisInterface.validateHelloMessage(helloPdu);
+        assertThat(result4, is(false));
+    }
+
+    /**
+     * Tests processL1L2HelloPduMessage() method.
+     */
+    @Test(expected = Exception.class)
+    public void testProcessL1L2HelloPduMessage() throws Exception {
+        helloPdu = new L1L2HelloPdu(isisHeader);
+        helloPdu.setSourceMac(macAddress1);
+        helloPdu.setCircuitType((byte) IsisRouterType.L2.value());
+        defaultIsisInterface.processL1L2HelloPduMessage(helloPdu, channel);
+        assertThat(defaultIsisInterface, is(notNullValue()));
+    }
+
+    /**
+     * Tests processP2pHelloPduMessage() method.
+     */
+    @Test(expected = Exception.class)
+    public void testProcessP2pHelloPduMessagee() throws Exception {
+        defaultIsisInterface.setSystemId(sysId);
+        p2PHelloPdu = new P2PHelloPdu(isisHeader);
+        p2PHelloPdu.setIsisPduType(IsisPduType.P2PHELLOPDU.value());
+        p2PHelloPdu.setSourceMac(macAddress1);
+        p2PHelloPdu.setCircuitType((byte) IsisRouterType.L2.value());
+        defaultIsisInterface.setNetworkType(IsisNetworkType.P2P);
+        defaultIsisInterface.processIsisMessage(p2PHelloPdu, isisLsdb, channel);
+        assertThat(defaultIsisInterface, is(notNullValue()));
+    }
+
+    /**
+     * Tests processP2pHelloPduMessage() method.
+     */
+    @Test(expected = Exception.class)
+    public void testProcessP2pHelloPduMessagee1() throws Exception {
+        defaultIsisInterface.setSystemId(sysId);
+        p2PHelloPdu = new P2PHelloPdu(isisHeader);
+        p2PHelloPdu.setIsisPduType(IsisPduType.P2PHELLOPDU.value());
+        p2PHelloPdu.setSourceMac(macAddress1);
+        p2PHelloPdu.setCircuitType((byte) IsisRouterType.L2.value());
+        defaultIsisInterface.setNetworkType(IsisNetworkType.P2P);
+        defaultIsisInterface.setReservedPacketCircuitType(IsisRouterType.L2.value());
+        defaultIsisInterface.setAllConfiguredInterfaceIps(ip4Addresses);
+        defaultIsisInterface.setInterfaceIpAddress(ip4Address);
+        defaultIsisInterface.setNetworkMask(mask1);
+        defaultIsisInterface.processIsisMessage(p2PHelloPdu, isisLsdb, channel);
+        assertThat(defaultIsisInterface, is(notNullValue()));
+    }
+
+    /**
+     * Tests processP2pHelloPduMessage() method.
+     */
+    @Test(expected = Exception.class)
+    public void testProcessP2pHelloPduMessagee2() throws Exception {
+        defaultIsisInterface.setSystemId(sysId);
+        p2PHelloPdu = new P2PHelloPdu(isisHeader);
+        TlvHeader tlvHeader = new TlvHeader();
+        tlvHeader.setTlvType(TlvType.AREAADDRESS.value());
+        AreaAddressTlv areaAddressTlv = new AreaAddressTlv(tlvHeader);
+        areaAddressTlv.addAddress(areaAddr);
+        p2PHelloPdu.addTlv(areaAddressTlv);
+        p2PHelloPdu.setIsisPduType(IsisPduType.P2PHELLOPDU.value());
+        p2PHelloPdu.setSourceMac(macAddress1);
+        p2PHelloPdu.setCircuitType((byte) IsisRouterType.L1.value());
+        defaultIsisInterface.setNetworkType(IsisNetworkType.P2P);
+        defaultIsisInterface.setReservedPacketCircuitType(IsisRouterType.L1.value());
+        defaultIsisInterface.setAreaAddress(areaAddr);
+        defaultIsisInterface.setAllConfiguredInterfaceIps(ip4Addresses);
+        defaultIsisInterface.setInterfaceIpAddress(ip4Address);
+        defaultIsisInterface.setNetworkMask(mask1);
+        defaultIsisInterface.processIsisMessage(p2PHelloPdu, isisLsdb, channel);
+        assertThat(defaultIsisInterface, is(notNullValue()));
+    }
+
+    /**
+     * Tests processP2pHelloPduMessage() method.
+     */
+    @Test(expected = Exception.class)
+    public void testProcessP2pHelloPduMessagee3() throws Exception {
+        defaultIsisInterface.setSystemId(sysId);
+        p2PHelloPdu = new P2PHelloPdu(isisHeader);
+        TlvHeader tlvHeader = new TlvHeader();
+        tlvHeader.setTlvType(TlvType.ADJACENCYSTATE.value());
+        AdjacencyStateTlv adjacencyStateTlv = new AdjacencyStateTlv(tlvHeader);
+        adjacencyStateTlv.setNeighborSystemId(sysId);
+        adjacencyStateTlv.setAdjacencyType((byte) IsisInterfaceState.DOWN.value());
+        p2PHelloPdu.addTlv(adjacencyStateTlv);
+        tlvHeader = new TlvHeader();
+        tlvHeader.setTlvType(TlvType.AREAADDRESS.value());
+        AreaAddressTlv areaAddressTlv = new AreaAddressTlv(tlvHeader);
+        areaAddressTlv.addAddress(areaAddr);
+        p2PHelloPdu.addTlv(areaAddressTlv);
+        p2PHelloPdu.setIsisPduType(IsisPduType.P2PHELLOPDU.value());
+        p2PHelloPdu.setSourceMac(macAddress1);
+        p2PHelloPdu.setCircuitType((byte) IsisRouterType.L1.value());
+        defaultIsisInterface.setNetworkType(IsisNetworkType.P2P);
+        defaultIsisInterface.setReservedPacketCircuitType(IsisRouterType.L1.value());
+        defaultIsisInterface.setAreaAddress(areaAddr);
+        defaultIsisInterface.setAllConfiguredInterfaceIps(ip4Addresses);
+        defaultIsisInterface.setInterfaceIpAddress(ip4Address);
+        defaultIsisInterface.setNetworkMask(mask1);
+        defaultIsisInterface.processIsisMessage(p2PHelloPdu, isisLsdb, channel);
+        assertThat(defaultIsisInterface, is(notNullValue()));
+    }
+
+    /**
+     * Tests processP2pHelloPduMessage() method.
+     */
+    @Test(expected = Exception.class)
+    public void testProcessP2pHelloPduMessagee4() throws Exception {
+        defaultIsisInterface.setSystemId(sysId);
+        p2PHelloPdu = new P2PHelloPdu(isisHeader);
+        TlvHeader tlvHeader = new TlvHeader();
+        tlvHeader.setTlvType(TlvType.ADJACENCYSTATE.value());
+        AdjacencyStateTlv adjacencyStateTlv = new AdjacencyStateTlv(tlvHeader);
+        adjacencyStateTlv.setNeighborSystemId(sysId);
+        adjacencyStateTlv.setAdjacencyType((byte) IsisInterfaceState.INITIAL.value());
+        p2PHelloPdu.addTlv(adjacencyStateTlv);
+        tlvHeader = new TlvHeader();
+        tlvHeader.setTlvType(TlvType.AREAADDRESS.value());
+        AreaAddressTlv areaAddressTlv = new AreaAddressTlv(tlvHeader);
+        areaAddressTlv.addAddress(areaAddr);
+        p2PHelloPdu.addTlv(areaAddressTlv);
+        p2PHelloPdu.setIsisPduType(IsisPduType.P2PHELLOPDU.value());
+        p2PHelloPdu.setSourceMac(macAddress1);
+        p2PHelloPdu.setCircuitType((byte) IsisRouterType.L1.value());
+        defaultIsisInterface.setNetworkType(IsisNetworkType.P2P);
+        defaultIsisInterface.setReservedPacketCircuitType(IsisRouterType.L1L2.value());
+        defaultIsisInterface.setAreaAddress(areaAddr);
+        defaultIsisInterface.setAllConfiguredInterfaceIps(ip4Addresses);
+        defaultIsisInterface.setInterfaceIpAddress(ip4Address);
+        defaultIsisInterface.setNetworkMask(mask1);
+        defaultIsisInterface.processIsisMessage(p2PHelloPdu, isisLsdb, channel);
+        assertThat(defaultIsisInterface, is(notNullValue()));
+    }
+
+    @Test(expected = Exception.class)
+    public void testProcessP2pHelloPduMessagee5() throws Exception {
+        defaultIsisInterface.setSystemId(sysId);
+        p2PHelloPdu = new P2PHelloPdu(isisHeader);
+        TlvHeader tlvHeader = new TlvHeader();
+        tlvHeader.setTlvType(TlvType.ADJACENCYSTATE.value());
+        AdjacencyStateTlv adjacencyStateTlv = new AdjacencyStateTlv(tlvHeader);
+        adjacencyStateTlv.setNeighborSystemId(sysId);
+        adjacencyStateTlv.setAdjacencyType((byte) IsisInterfaceState.UP.value());
+        p2PHelloPdu.addTlv(adjacencyStateTlv);
+        tlvHeader = new TlvHeader();
+        tlvHeader.setTlvType(TlvType.AREAADDRESS.value());
+        AreaAddressTlv areaAddressTlv = new AreaAddressTlv(tlvHeader);
+        areaAddressTlv.addAddress(areaAddr);
+        p2PHelloPdu.addTlv(areaAddressTlv);
+        p2PHelloPdu.setIsisPduType(IsisPduType.P2PHELLOPDU.value());
+        p2PHelloPdu.setSourceMac(macAddress1);
+        p2PHelloPdu.setCircuitType((byte) IsisRouterType.L2.value());
+        defaultIsisInterface.setNetworkType(IsisNetworkType.P2P);
+        defaultIsisInterface.setReservedPacketCircuitType(IsisRouterType.L1L2.value());
+        defaultIsisInterface.setAreaAddress(areaAddr);
+        defaultIsisInterface.setAllConfiguredInterfaceIps(ip4Addresses);
+        defaultIsisInterface.setInterfaceIpAddress(ip4Address);
+        defaultIsisInterface.setNetworkMask(mask1);
+        defaultIsisInterface.processIsisMessage(p2PHelloPdu, isisLsdb, channel);
+        assertThat(defaultIsisInterface, is(notNullValue()));
+    }
+
+    /**
+     * Tests startHelloSender() method.
+     */
+    @Test(expected = Exception.class)
+    public void testStartHelloSender() throws Exception {
+        defaultIsisInterface.startHelloSender(channel);
+        assertThat(defaultIsisInterface, is(notNullValue()));
+    }
+
+    /**
+     * Tests lspKeyP2P() method.
+     */
+    @Test
+    public void testLspKeyP2P() throws Exception {
+        result5 = defaultIsisInterface.lspKeyP2P(sysId);
+        assertThat(result5, is(notNullValue()));
+    }
+
+    /**
+     * Tests processLsPduMessage() method.
+     */
+    @Test
+    public void testProcessLsPduMessage() throws Exception {
+        lsPdu = new LsPdu(isisHeader);
+        lsPdu.setSourceMac(macAddress1);
+        lsPdu.setIsisPduType(IsisPduType.L2LSPDU.value());
+        lsPdu.setLspId(sysId);
+        isisMessage = lsPdu;
+        defaultIsisInterface.setNetworkType(IsisNetworkType.P2P);
+        defaultIsisInterface.setSystemId(sysId);
+        defaultIsisInterface.processIsisMessage(isisMessage, isisLsdb, channel);
+        assertThat(defaultIsisInterface, is(notNullValue()));
+    }
+
+    /**
+     * Tests processPsnPduMessage() method.
+     */
+    @Test
+    public void testProcessPsnPduMessage() throws Exception {
+        psnp = new Psnp(isisHeader);
+        psnp.setSourceMac(macAddress1);
+        psnp.setIsisPduType(IsisPduType.L2PSNP.value());
+        TlvHeader tlvHeader = new TlvHeader();
+        tlvHeader.setTlvType(TlvType.LSPENTRY.value());
+        tlvHeader.setTlvLength(0);
+        LspEntriesTlv lspEntriesTlv = new LspEntriesTlv(tlvHeader);
+        LspEntry lspEntry = new LspEntry();
+        lspEntry.setLspChecksum(0);
+        lspEntry.setLspSequenceNumber(0);
+        lspEntry.setRemainingTime(0);
+        lspEntriesTlv.addLspEntry(lspEntry);
+        psnp.addTlv(lspEntriesTlv);
+        isisMessage = psnp;
+        defaultIsisInterface.processIsisMessage(isisMessage, isisLsdb, channel);
+        assertThat(defaultIsisInterface, is(notNullValue()));
+    }
+
+    /**
+     * Tests processCsnPduMessage() method.
+     */
+    @Test(expected = Exception.class)
+    public void testProcessCsnPduMessage() throws Exception {
+        ChannelBuffer channelBuffer = ChannelBuffers.copiedBuffer(csnpBytes);
+        csnp = new Csnp(isisHeader);
+        csnp.readFrom(channelBuffer);
+        csnp.setSourceMac(macAddress1);
+        csnp.setIsisPduType(IsisPduType.L2CSNP.value());
+        isisMessage = csnp;
+        defaultIsisInterface.processIsisMessage(isisMessage, isisLsdb, channel);
+        assertThat(defaultIsisInterface, is(notNullValue()));
+    }
 }
diff --git a/protocols/isis/ctl/src/test/java/org/onosproject/isis/controller/impl/DefaultIsisProcessTest.java b/protocols/isis/ctl/src/test/java/org/onosproject/isis/controller/impl/DefaultIsisProcessTest.java
index 3c16a14..95717cd 100644
--- a/protocols/isis/ctl/src/test/java/org/onosproject/isis/controller/impl/DefaultIsisProcessTest.java
+++ b/protocols/isis/ctl/src/test/java/org/onosproject/isis/controller/impl/DefaultIsisProcessTest.java
@@ -36,6 +36,7 @@
     private final String processId = "1";
     private IsisProcess isisProcess;
     private String result;
+    private IsisProcess defaultIsisProcess;
     private IsisInterface isisInterface;
     private List<IsisInterface> isisInterfaceList;
     private List<IsisInterface> result1;
@@ -44,6 +45,7 @@
     public void setUp() throws Exception {
         isisProcess = new DefaultIsisProcess();
         isisInterface = EasyMock.createNiceMock(DefaultIsisInterface.class);
+        defaultIsisProcess = new DefaultIsisProcess();
     }
 
     @After
@@ -90,4 +92,4 @@
         result1 = isisProcess.isisInterfaceList();
         assertThat(result1, is(nullValue()));
     }
-}
+}
\ No newline at end of file
diff --git a/protocols/isis/ctl/src/test/java/org/onosproject/isis/controller/impl/IsisChannelHandlerTest.java b/protocols/isis/ctl/src/test/java/org/onosproject/isis/controller/impl/IsisChannelHandlerTest.java
index 1644b6e..9081cdf 100644
--- a/protocols/isis/ctl/src/test/java/org/onosproject/isis/controller/impl/IsisChannelHandlerTest.java
+++ b/protocols/isis/ctl/src/test/java/org/onosproject/isis/controller/impl/IsisChannelHandlerTest.java
@@ -23,10 +23,14 @@
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
+import org.onlab.packet.Ip4Address;
+import org.onosproject.isis.controller.IsisInterface;
 import org.onosproject.isis.controller.IsisMessage;
+import org.onosproject.isis.controller.IsisNetworkType;
 import org.onosproject.isis.controller.IsisProcess;
 import org.onosproject.isis.io.isispacket.pdu.L1L2HelloPdu;
 
+import java.util.ArrayList;
 import java.util.List;
 
 import static org.hamcrest.CoreMatchers.is;
@@ -43,12 +47,14 @@
     private IsisChannelHandler isisChannelHandler;
     private Controller controller;
     private IsisProcess isisProcess;
-    private List<IsisProcess> isisProcessList;
+    private List<IsisProcess> isisProcessList = new ArrayList();
     private ChannelHandlerContext channelHandlerContext;
     private ChannelStateEvent channelStateEvent;
     private ExceptionEvent exceptionEvent;
     private MessageEvent messageEvent;
     private IsisMessage isisMessage;
+    private List<IsisInterface> isisInterfaceList = new ArrayList<>();
+    private Ip4Address ip4Address = Ip4Address.valueOf("10.10.10.10");
 
     @Before
     public void setUp() throws Exception {
@@ -71,7 +77,7 @@
     /**
      * Tests initializeInterfaceMap() method.
      */
-    @Test(expected = Exception.class)
+    @Test
     public void testInitializeInterfaceMap() throws Exception {
         isisChannelHandler.initializeInterfaceMap();
         assertThat(isisChannelHandler, is(notNullValue()));
@@ -82,6 +88,32 @@
      */
     @Test(expected = Exception.class)
     public void testUpdateInterfaceMap() throws Exception {
+        IsisInterface isisInterface = new DefaultIsisInterface();
+        IsisInterface isisInterface1 = new DefaultIsisInterface();
+        isisInterface.setInterfaceIpAddress(ip4Address);
+        isisInterface.setInterfaceIndex(1);
+        isisInterfaceList.add(isisInterface);
+        IsisProcess isisProcess = new DefaultIsisProcess();
+        isisProcess.setIsisInterfaceList(isisInterfaceList);
+        isisProcessList.add(isisProcess);
+        isisChannelHandler.updateInterfaceMap(isisProcessList);
+        assertThat(isisChannelHandler, is(notNullValue()));
+        isisProcessList = new ArrayList<>();
+        isisInterface1.setInterfaceIpAddress(ip4Address);
+        isisInterface1.setInterfaceIndex(1);
+        isisInterface1.setInterfaceIpAddress(ip4Address);
+        isisInterface1.setInterfaceIndex(1);
+        isisInterface1.setSystemId("9999.9999.9999");
+        isisInterface1.setIntermediateSystemName("router");
+        isisInterface1.setReservedPacketCircuitType(3);
+        isisInterface1.setCircuitId("10");
+        isisInterface1.setNetworkType(IsisNetworkType.BROADCAST);
+        isisInterface1.setAreaAddress("490001");
+        isisInterface1.setHoldingTime(50);
+        isisInterface1.setHelloInterval(10);
+        isisInterfaceList.add(isisInterface1);
+        isisProcess.setIsisInterfaceList(isisInterfaceList);
+        isisProcessList.add(isisProcess);
         isisChannelHandler.updateInterfaceMap(isisProcessList);
         assertThat(isisChannelHandler, is(notNullValue()));
     }
@@ -89,7 +121,7 @@
     /**
      * Tests initializeInterfaceIpList() method.
      */
-    @Test(expected = Exception.class)
+    @Test
     public void testInitializeInterfaceIpList() throws Exception {
         isisChannelHandler.initializeInterfaceIpList();
         assertThat(isisChannelHandler, is(notNullValue()));
diff --git a/protocols/isis/ctl/src/test/java/org/onosproject/isis/controller/impl/IsisHelloPduSenderTest.java b/protocols/isis/ctl/src/test/java/org/onosproject/isis/controller/impl/IsisHelloPduSenderTest.java
index 85228b2..ef089a1 100644
--- a/protocols/isis/ctl/src/test/java/org/onosproject/isis/controller/impl/IsisHelloPduSenderTest.java
+++ b/protocols/isis/ctl/src/test/java/org/onosproject/isis/controller/impl/IsisHelloPduSenderTest.java
@@ -58,7 +58,7 @@
     /**
      * Tests run() method.
      */
-    @Test
+    @Test(expected = Exception.class)
     public void testRun() throws Exception {
         isisInterface.setNetworkType(IsisNetworkType.P2P);
         isisInterface.setCircuitId(circuitId);
diff --git a/protocols/isis/ctl/src/test/java/org/onosproject/isis/controller/impl/IsisMessageDecoderTest.java b/protocols/isis/ctl/src/test/java/org/onosproject/isis/controller/impl/IsisMessageDecoderTest.java
index a2c32b9..4948ec6 100644
--- a/protocols/isis/ctl/src/test/java/org/onosproject/isis/controller/impl/IsisMessageDecoderTest.java
+++ b/protocols/isis/ctl/src/test/java/org/onosproject/isis/controller/impl/IsisMessageDecoderTest.java
@@ -24,11 +24,14 @@
 public class IsisMessageDecoderTest {
 
     private final byte[] hello = {
+            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
             -125, 20, 1, 0, 17, 1, 0, 0,
             2, 51, 51, 51, 51, 51, 51, 0, 100, 5, -39, -126, 1, 4, 3,
             73, 0, 0, -127, 1, -52, -124, 4, -64, -88, 56, 102
     };
+    private final byte[] array2 = {0, 0, 0, 0, 0, 0, 0};
     private final String id = "127.0.0.1";
+    private byte[] array1;
     private IsisMessageDecoder isisMessageDecoder;
     private ChannelHandlerContext ctx;
     private Channel channel;
@@ -49,7 +52,8 @@
     public void testDecode() throws Exception {
         channel = EasyMock.createMock(Channel.class);
         socketAddress = InetSocketAddress.createUnresolved(id, 7000);
-        byte[] array = IsisUtil.getPaddingTlvs(hello.length);
+        byte[] array = IsisUtil.getPaddingTlvs(hello.length - 17);
+        array1 = Bytes.concat(hello, array);
         channelBuffer = ChannelBuffers.copiedBuffer(Bytes.concat(hello, array));
         assertThat(isisMessageDecoder.decode(ctx, channel, channelBuffer), is(nullValue()));
     }
diff --git a/protocols/isis/ctl/src/test/java/org/onosproject/isis/controller/impl/lsdb/DefaultIsisLsdbTest.java b/protocols/isis/ctl/src/test/java/org/onosproject/isis/controller/impl/lsdb/DefaultIsisLsdbTest.java
index d1c04fe..bc67ad3 100644
--- a/protocols/isis/ctl/src/test/java/org/onosproject/isis/controller/impl/lsdb/DefaultIsisLsdbTest.java
+++ b/protocols/isis/ctl/src/test/java/org/onosproject/isis/controller/impl/lsdb/DefaultIsisLsdbTest.java
@@ -22,8 +22,13 @@
 import org.onosproject.isis.controller.IsisLsdbAge;
 import org.onosproject.isis.controller.IsisPduType;
 import org.onosproject.isis.controller.LspWrapper;
+import org.onosproject.isis.controller.impl.DefaultIsisInterface;
+import org.onosproject.isis.io.isispacket.IsisHeader;
+import org.onosproject.isis.io.isispacket.pdu.AttachedToOtherAreas;
+import org.onosproject.isis.io.isispacket.pdu.LsPdu;
 import org.onosproject.isis.io.util.IsisConstants;
 
+import java.util.List;
 import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
 
@@ -37,19 +42,27 @@
     private final int l1LspSeqNo = IsisConstants.STARTLSSEQUENCENUM;
     private final int l2LspSeqNo = IsisConstants.STARTLSSEQUENCENUM;
     private final String srcId = "1111.1111.1111";
-
     private DefaultIsisLsdb defaultIsisLsdb;
     private IsisLsdbAge lsdbAge = null;
-
-
     private int resultInt;
     private Map<String, LspWrapper> resultMap = new ConcurrentHashMap<>();
     private IsisLsdb resultLsdb;
     private LspWrapper resultLspWrapper;
-
+    private List<LspWrapper> lspWrapperList;
+    private LsPdu lsPdu;
+    private IsisHeader isisHeader;
+    private DefaultIsisInterface defaultIsisInterface;
+    private String lspId = "1234.1234.1234.00-00";
+    private String result;
 
     @Before
     public void setUp() throws Exception {
+        defaultIsisInterface = new DefaultIsisInterface();
+        isisHeader = new IsisHeader();
+        lsPdu = new LsPdu(isisHeader);
+        lsPdu.setLspId(lspId);
+        lsPdu.setAttachedToOtherAreas(AttachedToOtherAreas.DEFAULTMETRIC);
+        lsPdu.setIsisPduType(IsisPduType.L1LSPDU.value());
         defaultIsisLsdb = new DefaultIsisLsdb();
     }
 
@@ -129,5 +142,60 @@
         resultLspWrapper = defaultIsisLsdb.findLsp(IsisPduType.L1HELLOPDU, srcId);
         assertThat(resultLspWrapper, is(nullValue()));
     }
+
+    /**
+     * Tests allLspHeaders() method.
+     */
+    @Test
+    public void testAllLspHeaders() throws Exception {
+        defaultIsisLsdb.addLsp(lsPdu, false, defaultIsisInterface);
+        lspWrapperList = defaultIsisLsdb.allLspHeaders(true);
+        assertThat(lspWrapperList, is(notNullValue()));
+
+        defaultIsisLsdb.addLsp(lsPdu, true, defaultIsisInterface);
+        lspWrapperList = defaultIsisLsdb.allLspHeaders(true);
+        assertThat(lspWrapperList, is(notNullValue()));
+    }
+
+    /**
+     * Tests isNewerOrSameLsp() method.
+     */
+    @Test
+    public void testIsNewerOrSameLsp() throws Exception {
+        result = defaultIsisLsdb.isNewerOrSameLsp(lsPdu, lsPdu);
+        assertThat(result, is("same"));
+    }
+
+    /**
+     * Tests lsSequenceNumber() method.
+     */
+    @Test
+    public void testLsSequenceNumber() throws Exception {
+        resultInt = defaultIsisLsdb.lsSequenceNumber(IsisPduType.L1LSPDU);
+        assertThat(resultInt, is(1));
+
+        resultInt = defaultIsisLsdb.lsSequenceNumber(IsisPduType.L2LSPDU);
+        assertThat(resultInt, is(1));
+
+        resultInt = defaultIsisLsdb.lsSequenceNumber(IsisPduType.L1CSNP);
+        assertThat(resultInt, is(1));
+    }
+
+    /**
+     * Tests deleteLsp() method.
+     */
+    @Test
+    public void testdeleteLsp() throws Exception {
+        defaultIsisLsdb.deleteLsp(lsPdu);
+        assertThat(defaultIsisLsdb, is(notNullValue()));
+
+        lsPdu.setIsisPduType(IsisPduType.L2LSPDU.value());
+        defaultIsisLsdb.deleteLsp(lsPdu);
+        assertThat(defaultIsisLsdb, is(notNullValue()));
+
+        lsPdu.setIsisPduType(IsisPduType.L1CSNP.value());
+        defaultIsisLsdb.deleteLsp(lsPdu);
+        assertThat(defaultIsisLsdb, is(notNullValue()));
+    }
 }
 
diff --git a/protocols/isis/ctl/src/test/java/org/onosproject/isis/controller/impl/lsdb/DefaultLspWrapperTest.java b/protocols/isis/ctl/src/test/java/org/onosproject/isis/controller/impl/lsdb/DefaultLspWrapperTest.java
index 617dece..02eed12 100644
--- a/protocols/isis/ctl/src/test/java/org/onosproject/isis/controller/impl/lsdb/DefaultLspWrapperTest.java
+++ b/protocols/isis/ctl/src/test/java/org/onosproject/isis/controller/impl/lsdb/DefaultLspWrapperTest.java
@@ -19,7 +19,11 @@
 import org.junit.Before;
 import org.junit.Test;
 import org.onosproject.isis.controller.IsisInterface;
+import org.onosproject.isis.controller.IsisLsdbAge;
+import org.onosproject.isis.controller.IsisPduType;
 import org.onosproject.isis.controller.impl.DefaultIsisInterface;
+import org.onosproject.isis.io.isispacket.IsisHeader;
+import org.onosproject.isis.io.isispacket.pdu.LsPdu;
 
 import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.CoreMatchers.notNullValue;
@@ -36,11 +40,20 @@
     private int result1;
     private IsisInterface isisInterface;
     private IsisInterface result2;
+    private IsisPduType isisPduType;
+    private boolean result3;
+    private LsPdu lsPdu;
+    private LsPdu pdu;
+    private DefaultIsisLsdbAge defaultIsisLsdbAge;
+    private IsisLsdbAge lsdbAge;
 
     @Before
     public void setUp() throws Exception {
         defaultLspWrapper = new DefaultLspWrapper();
         isisInterface = new DefaultIsisInterface();
+        pdu = new LsPdu(new IsisHeader());
+        defaultIsisLsdbAge = new DefaultIsisLsdbAge();
+        defaultIsisLsdbAge.startDbAging();
     }
 
     @After
@@ -108,4 +121,169 @@
         assertThat(result2, is(notNullValue()));
     }
 
+    /**
+     * Tests ageCounterWhenReceived() getter method.
+     */
+    @Test
+    public void testAgeCounterWhenReceived() throws Exception {
+        defaultLspWrapper.setAgeCounterWhenReceived(1);
+        result1 = defaultLspWrapper.ageCounterWhenReceived();
+        assertThat(result1, is(notNullValue()));
+    }
+
+    /**
+     * Tests ageCounterWhenReceived() setter method.
+     */
+    @Test
+    public void testSetAgeCounterWhenReceived() throws Exception {
+        defaultLspWrapper.setAgeCounterWhenReceived(1);
+        result1 = defaultLspWrapper.ageCounterWhenReceived();
+        assertThat(result1, is(notNullValue()));
+    }
+
+    /**
+     * Tests ageCounterRollOverWhenAdded() getter method.
+     */
+    @Test
+    public void testAgeCounterRollOverWhenAdded() throws Exception {
+        defaultLspWrapper.setAgeCounterRollOverWhenAdded(1);
+        result1 = defaultLspWrapper.ageCounterRollOverWhenAdded();
+        assertThat(result1, is(notNullValue()));
+    }
+
+    /**
+     * Tests ageCounterRollOverWhenAdded() setter method.
+     */
+    @Test
+    public void testSetAgeCounterRollOverWhenAdded() throws Exception {
+        defaultLspWrapper.setAgeCounterRollOverWhenAdded(1);
+        result1 = defaultLspWrapper.ageCounterRollOverWhenAdded();
+        assertThat(result1, is(notNullValue()));
+    }
+
+    /**
+     * Tests lspType() getter method.
+     */
+    @Test
+    public void testLspType() throws Exception {
+        defaultLspWrapper.setLspType(IsisPduType.L1LSPDU);
+        isisPduType = defaultLspWrapper.lspType();
+        assertThat(isisPduType, is(IsisPduType.L1LSPDU));
+    }
+
+    /**
+     * Tests lspType() setter method.
+     */
+    @Test
+    public void testSetLspType() throws Exception {
+        defaultLspWrapper.setLspType(IsisPduType.L1LSPDU);
+        isisPduType = defaultLspWrapper.lspType();
+        assertThat(isisPduType, is(IsisPduType.L1LSPDU));
+    }
+
+    /**
+     * Tests isSelfOriginated() getter method.
+     */
+    @Test
+    public void testIsSelfOriginated() throws Exception {
+        defaultLspWrapper.setSelfOriginated(true);
+        result3 = defaultLspWrapper.isSelfOriginated();
+        assertThat(result3, is(true));
+    }
+
+    /**
+     * Tests isSelfOriginated() setter method.
+     */
+    @Test
+    public void testSetSelfOriginated() throws Exception {
+        defaultLspWrapper.setSelfOriginated(true);
+        result3 = defaultLspWrapper.isSelfOriginated();
+        assertThat(result3, is(true));
+    }
+
+    /**
+     * Tests binNumber() getter method.
+     */
+    @Test
+    public void testBinNumber() throws Exception {
+        defaultLspWrapper.setBinNumber(1);
+        result1 = defaultLspWrapper.binNumber();
+        assertThat(result1, is(1));
+    }
+
+    /**
+     * Tests binNumber() setter method.
+     */
+    @Test
+    public void testSetBinNumber() throws Exception {
+        defaultLspWrapper.setBinNumber(1);
+        result1 = defaultLspWrapper.binNumber();
+        assertThat(result1, is(1));
+    }
+
+    /**
+     * Tests lsPdu() getter method.
+     */
+    @Test
+    public void testLsPdu() throws Exception {
+        defaultLspWrapper.setLsPdu(pdu);
+        lsPdu = defaultLspWrapper.lsPdu();
+        assertThat(lsPdu, is(pdu));
+    }
+
+    /**
+     * Tests lsPdu() setter method.
+     */
+    @Test
+    public void testSetLsPdu() throws Exception {
+        defaultLspWrapper.setLsPdu(pdu);
+        lsPdu = defaultLspWrapper.lsPdu();
+        assertThat(lsPdu, is(pdu));
+    }
+
+    /**
+     * Tests lsdbAge() getter method.
+     */
+    @Test
+    public void testlsdbAge() throws Exception {
+        defaultLspWrapper.setLsdbAge(defaultIsisLsdbAge);
+        lsdbAge = defaultLspWrapper.lsdbAge();
+        assertThat(lsdbAge, is(defaultIsisLsdbAge));
+    }
+
+    /**
+     * Tests lsdbAge() setter method.
+     */
+    @Test
+    public void testSetLsdbAge() throws Exception {
+        defaultLspWrapper.setLsdbAge(defaultIsisLsdbAge);
+        lsdbAge = defaultLspWrapper.lsdbAge();
+        assertThat(lsdbAge, is(defaultIsisLsdbAge));
+    }
+
+    /**
+     * Tests remainingLifetime() getter method.
+     */
+    @Test
+    public void testRemainingLifetime() throws Exception {
+        defaultLspWrapper.setLsdbAge(defaultIsisLsdbAge);
+        defaultLspWrapper.setAgeCounterWhenReceived(1);
+        defaultLspWrapper.currentAge();
+        defaultLspWrapper.setRemainingLifetime(1);
+        result1 = defaultLspWrapper.remainingLifetime();
+        assertThat(result1, is(1));
+    }
+
+    /**
+     * Tests remainingLifetime() setter method.
+     */
+    @Test
+    public void testSetRemainingLifetime() throws Exception {
+        defaultLspWrapper.setLsdbAge(defaultIsisLsdbAge);
+        defaultLspWrapper.setAgeCounterWhenReceived(1);
+        defaultLspWrapper.currentAge();
+        defaultLspWrapper.setRemainingLifetime(1);
+        result1 = defaultLspWrapper.remainingLifetime();
+        assertThat(result1, is(1));
+    }
 }
\ No newline at end of file
diff --git a/protocols/isis/ctl/src/test/java/org/onosproject/isis/controller/impl/lsdb/IsisLspQueueConsumerTest.java b/protocols/isis/ctl/src/test/java/org/onosproject/isis/controller/impl/lsdb/IsisLspQueueConsumerTest.java
index 2e592af..b47bd3b 100644
--- a/protocols/isis/ctl/src/test/java/org/onosproject/isis/controller/impl/lsdb/IsisLspQueueConsumerTest.java
+++ b/protocols/isis/ctl/src/test/java/org/onosproject/isis/controller/impl/lsdb/IsisLspQueueConsumerTest.java
@@ -18,7 +18,11 @@
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
+import org.onosproject.isis.controller.impl.DefaultIsisInterface;
 
+import java.net.InetSocketAddress;
+import java.net.SocketAddress;
+import java.util.concurrent.ArrayBlockingQueue;
 import java.util.concurrent.BlockingQueue;
 
 import static org.hamcrest.CoreMatchers.is;
@@ -31,10 +35,22 @@
 public class IsisLspQueueConsumerTest {
 
     private IsisLspQueueConsumer isisLspQueueConsumer;
-    private BlockingQueue blockingQueue;
+    private BlockingQueue blockingQueue = new ArrayBlockingQueue(1024);
+    private DefaultLspWrapper lspWrapper;
+    private DefaultLspWrapper lspWrapper1;
+    private SocketAddress socketAddress = InetSocketAddress.createUnresolved("127.0.0.1", 7000);
 
     @Before
     public void setUp() throws Exception {
+        lspWrapper = new DefaultLspWrapper();
+        lspWrapper.setLspProcessing("refreshLsp");
+        lspWrapper.setSelfOriginated(true);
+        lspWrapper.setIsisInterface(new DefaultIsisInterface());
+        lspWrapper1 = new DefaultLspWrapper();
+        lspWrapper1.setLspProcessing("maxAgeLsp");
+        lspWrapper1.setIsisInterface(new DefaultIsisInterface());
+        blockingQueue.add(lspWrapper);
+        blockingQueue.add(lspWrapper1);
         isisLspQueueConsumer = new IsisLspQueueConsumer(blockingQueue);
     }
 
diff --git a/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/pdu/Psnp.java b/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/pdu/Psnp.java
old mode 100755
new mode 100644
diff --git a/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/util/IsisConstants.java b/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/util/IsisConstants.java
index cf5871a..9156eb4 100644
--- a/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/util/IsisConstants.java
+++ b/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/util/IsisConstants.java
@@ -33,6 +33,7 @@
     public static final int IRPDISCRIMINATOR = 131;
     public static final int ISISVERSION = 1;
     public static final int RESERVED = 0;
+    public static final int PRIORITY = 0;
     public static final int MAXAREAADDRESS = 0;
     public static final int SYSTEMIDLENGTH = 0;
     public static final int PROTOCOLSUPPORTED = 204;
@@ -55,24 +56,15 @@
     public static final String DEFAULTLANID = "0000.0000.0000.00";
     public static final String PROCESSESID = "processId";
     public static final String INTERFACE = "interface";
-    public static final String INTERFACEIP = "interfaceIp";
-    public static final String NETWORKMASK = "networkMask";
     public static final String INTERFACEINDEX = "interfaceIndex";
     public static final String INTERMEDIATESYSTEMNAME = "intermediateSystemName";
     public static final String SYSTEMID = "systemId";
-    public static final String LANID = "lanId";
-    public static final String IDLENGTH = "idLength";
-    public static final String MAXAREAADDRESSES = "maxAreaAddresses";
     public static final String RESERVEDPACKETCIRCUITTYPE = "reservedPacketCircuitType";
     public static final String CIRCUITID = "circuitId";
     public static final String NETWORKTYPE = "networkType";
     public static final String AREAADDRESS = "areaAddress";
-    public static final String AREALENGTH = "areaLength";
-    public static final String LSPID = "lspId";
     public static final String HOLDINGTIME = "holdingTime";
     public static final String HELLOINTERVAL = "helloInterval";
-    public static final String PRIORITY = "priority";
-    public static final String MACADDRESS = "macAddress";
 
     /**
      * Non parameterized constructor.
diff --git a/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/util/IsisUtil.java b/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/util/IsisUtil.java
old mode 100755
new mode 100644
index 6b665ac..cfd941e
--- a/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/util/IsisUtil.java
+++ b/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/util/IsisUtil.java
@@ -22,6 +22,7 @@
 import org.onosproject.isis.controller.IsisInterfaceState;
 import org.onosproject.isis.controller.IsisNeighbor;
 import org.onosproject.isis.controller.IsisPduType;
+import org.onosproject.isis.controller.IsisRouterType;
 import org.onosproject.isis.io.isispacket.IsisHeader;
 import org.onosproject.isis.io.isispacket.pdu.L1L2HelloPdu;
 import org.onosproject.isis.io.isispacket.pdu.P2PHelloPdu;
@@ -394,7 +395,6 @@
         isisHeader.setIdLength((byte) IsisConstants.SYSTEMIDLENGTH);
         isisHeader.setIsisPduType(IsisPduType.P2PHELLOPDU.value());
         isisHeader.setVersion2((byte) IsisConstants.ISISVERSION);
-        //isisHeader.setReserved((byte) IsisConstants.RESERVED);
         isisHeader.setReserved((byte) IsisConstants.PDULENGTHPOSITION);
         isisHeader.setMaximumAreaAddresses((byte) IsisConstants.MAXAREAADDRESS);
         P2PHelloPdu p2pHelloPdu = new P2PHelloPdu(isisHeader);
@@ -510,14 +510,32 @@
         l1L2HelloPdu.addTlv(areaAddressTlv);
         Set<MacAddress> neighbors = isisInterface.neighbors();
         if (neighbors.size() > 0) {
+            List<MacAddress> neighborMacs = new ArrayList<>();
+            for (MacAddress neighbor : neighbors) {
+                IsisNeighbor isisNeighbor = isisInterface.lookup(neighbor);
+                if (isisPduType == IsisPduType.L1HELLOPDU) {
+                    if (isisNeighbor.routerType() == IsisRouterType.L1 ||
+                            isisNeighbor.routerType() == IsisRouterType.L1L2) {
+                        neighborMacs.add(neighbor);
+                    }
+                } else if (isisPduType == IsisPduType.L2HELLOPDU) {
+                    if (isisNeighbor.routerType() == IsisRouterType.L2 ||
+                            isisNeighbor.routerType() == IsisRouterType.L1L2) {
+                        neighborMacs.add(neighbor);
+                    }
+                }
+            }
+
             tlvHeader.setTlvType(TlvType.ISNEIGHBORS.value());
             tlvHeader.setTlvLength(0);
+
             IsisNeighborTlv isisNeighborTlv = new IsisNeighborTlv(tlvHeader);
-            for (MacAddress neighbor : neighbors) {
+            for (MacAddress neighbor : neighborMacs) {
                 isisNeighborTlv.addNeighbor(neighbor);
             }
             l1L2HelloPdu.addTlv(isisNeighborTlv);
         }
+
         tlvHeader.setTlvType(TlvType.PROTOCOLSUPPORTED.value());
         tlvHeader.setTlvLength(0);
         ProtocolSupportedTlv protocolSupportedTlv = new ProtocolSupportedTlv(tlvHeader);
@@ -708,4 +726,4 @@
         }
         return Bytes.toArray(byteList);
     }
-}
+}
\ No newline at end of file
diff --git a/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/util/LspGenerator.java b/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/util/LspGenerator.java
index c6ae962..b72c2ab 100644
--- a/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/util/LspGenerator.java
+++ b/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/util/LspGenerator.java
@@ -140,8 +140,15 @@
         metricOfIntRea.setExpenseIsInternal(true);
         Ip4Address ip4Address = isisInterface.interfaceIpAddress();
         byte[] ipAddress = ip4Address.toOctets();
-        ipAddress[ipAddress.length - 1] = 0;
-        metricOfIntRea.setIpAddress(Ip4Address.valueOf(ipAddress));
+       // ipAddress[ipAddress.length - 1] = 0;
+        byte[] networkmass = isisInterface.networkMask();
+        // metric calculation part
+        byte[] result = new byte[ipAddress.length];
+        result[0] = (byte) (ipAddress[0] & networkmass[0]);
+        result[1] = (byte) (ipAddress[1] & networkmass[1]);
+        result[2] = (byte) (ipAddress[2] & networkmass[2]);
+        result[3] = (byte) (ipAddress[3] & networkmass[3]);
+        metricOfIntRea.setIpAddress(Ip4Address.valueOf(result));
         metricOfIntRea.setSubnetAddres(Ip4Address.valueOf(isisInterface.networkMask()));
         ipInterReacTlv.addInternalReachabilityMetric(metricOfIntRea);
         lsp.addTlv(ipInterReacTlv);