Bgp and Pcep maintaiability

Change-Id: I2c14cc29d4900ef2f0fbffd4761b0d78e282910f
diff --git a/protocols/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpConnectPeer.java b/protocols/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpConnectPeer.java
index 03310a6..d42d32c 100644
--- a/protocols/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpConnectPeer.java
+++ b/protocols/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpConnectPeer.java
@@ -17,12 +17,28 @@
  */
 public interface BgpConnectPeer {
     /**
-    * Initiate bgp peer connection.
-    */
+     * Initiate bgp peer connection.
+     */
     void connectPeer();
 
     /**
-    * End bgp peer connection.
-    */
+     * End bgp peer connection.
+     */
     void disconnectPeer();
+
+    /**
+     * Returns the peer port.
+     *
+     * @return PeerPort
+     */
+    int getPeerPort();
+
+    /**
+     * Returns the connect retry counter.
+     *
+     * @return connectRetryCounter
+     */
+    int getConnectRetryCounter();
+
+
 }
diff --git a/protocols/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpController.java b/protocols/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpController.java
index 90a8eed..e562b94 100644
--- a/protocols/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpController.java
+++ b/protocols/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpController.java
@@ -19,6 +19,7 @@
 import org.onosproject.bgpio.exceptions.BgpParseException;
 import org.onosproject.bgpio.protocol.BgpMessage;
 
+import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
@@ -61,7 +62,7 @@
      * Send a message to a particular bgp peer.
      *
      * @param bgpId the id of the peer to send message.
-     * @param msg the message to send
+     * @param msg   the message to send
      */
     void writeMsg(BgpId bgpId, BgpMessage msg);
 
@@ -69,14 +70,13 @@
      * Process a message and notify the appropriate listeners.
      *
      * @param bgpId id of the peer the message arrived on
-     * @param msg the message to process.
+     * @param msg   the message to process.
      * @throws BgpParseException on data processing error
      */
     void processBgpPacket(BgpId bgpId, BgpMessage msg) throws BgpParseException;
 
     /**
      * Close all connected BGP peers.
-     *
      */
     void closeConnectedPeers();
 
@@ -149,4 +149,35 @@
      * @return link listener
      */
     Set<BgpLinkListener> linkListener();
+
+    /**
+     * Stores the exceptions occured during an active session.
+     *
+     * @param peerId BGP peer id
+     * @param exception exceptions based on the peer id.
+     */
+    void activeSessionExceptionAdd(String peerId, String exception);
+
+    /**
+     * Stores the exceptions occured during an closed session.
+     *
+     * @param peerId BGP peer id
+     * @param exception exceptions based on the peer id
+     */
+    void closedSessionExceptionAdd(String peerId, String exception);
+
+    /**
+     * Return active session exceptions.
+     *
+     * @return activeSessionMap
+     */
+    Map<String, List<String>> activeSessionMap();
+
+    /**
+     * Return closed session exceptions.
+     *
+     * @return closedSessionMap
+     */
+    Map<String, List<String>> closedSessionMap();
+
 }
diff --git a/protocols/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpDpid.java b/protocols/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpDpid.java
index a0f5952..fb9ca1d 100644
--- a/protocols/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpDpid.java
+++ b/protocols/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpDpid.java
@@ -61,8 +61,10 @@
         this.stringBuilder.append(":ROUTINGUNIVERSE=").append(((BgpLinkLsNlriVer4) linkNlri).getIdentifier());
 
         if (nodeDescriptorType == NODE_DESCRIPTOR_LOCAL) {
+            log.debug("Local node descriptor added");
             add(linkNlri.localNodeDescriptors());
         } else if (nodeDescriptorType == NODE_DESCRIPTOR_REMOTE) {
+            log.debug("Remote node descriptor added");
             add(linkNlri.remoteNodeDescriptors());
         }
     }
@@ -93,7 +95,7 @@
 
         this.stringBuilder.append(":ROUTINGUNIVERSE=").append(((BgpNodeLSNlriVer4) nlri).getIdentifier());
         add(((BgpNodeLSNlriVer4) nlri).getLocalNodeDescriptors().getNodedescriptors());
-        log.info("BgpDpid :: add");
+        log.debug("BgpDpid :: add");
     }
 
     /**
@@ -103,7 +105,7 @@
      * @return instance of this class
      */
     public BgpDpid add(final NodeDescriptors value) {
-        log.info("BgpDpid :: add function");
+        log.debug("BgpDpid :: add function");
         if (value != null) {
             List<BgpValueType> subTlvs = value.getSubTlvs();
             ListIterator<BgpValueType> listIterator = subTlvs.listIterator();
@@ -148,7 +150,7 @@
         try {
             return new URI(SCHEME, value, null);
         } catch (URISyntaxException e) {
-            log.info("Exception BgpId URI: " + e.toString());
+            log.debug("Exception BgpId URI: " + e.toString());
         }
         return null;
     }
diff --git a/protocols/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpLocalRib.java b/protocols/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpLocalRib.java
index 456ecd2..a10fafc 100644
--- a/protocols/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpLocalRib.java
+++ b/protocols/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpLocalRib.java
@@ -16,8 +16,14 @@
 import org.onosproject.bgpio.exceptions.BgpParseException;
 import org.onosproject.bgpio.protocol.BgpLSNlri;
 import org.onosproject.bgpio.protocol.linkstate.PathAttrNlriDetails;
+import org.onosproject.bgpio.protocol.linkstate.PathAttrNlriDetailsLocalRib;
+import org.onosproject.bgpio.protocol.linkstate.BgpNodeLSIdentifier;
+import org.onosproject.bgpio.protocol.linkstate.BgpLinkLSIdentifier;
+import org.onosproject.bgpio.protocol.linkstate.BgpPrefixLSIdentifier;
 import org.onosproject.bgpio.types.RouteDistinguisher;
 
+import java.util.Map;
+
 /**
  * Abstraction of BGP local RIB.
  */
@@ -62,4 +68,46 @@
      * @throws BgpParseException while deleting NLRI from local rib
      */
     void delete(BgpLSNlri nlri, RouteDistinguisher routeDistinguisher) throws BgpParseException;
+
+    /**
+     * Returns node NLRI tree.
+     *
+     * @return node tree
+     */
+    Map<BgpNodeLSIdentifier, PathAttrNlriDetailsLocalRib> nodeTree();
+
+    /**
+     * Returns link NLRI tree.
+     *
+     * @return link tree
+     */
+    Map<BgpLinkLSIdentifier, PathAttrNlriDetailsLocalRib> linkTree();
+
+    /**
+     * Returns prefix NLRI tree.
+     *
+     * @return prefix tree
+     */
+    Map<BgpPrefixLSIdentifier, PathAttrNlriDetailsLocalRib> prefixTree();
+
+    /**
+     * Returns VPN node NLRI tree.
+     *
+     * @return vpn node NLRI tree
+     */
+    Map<RouteDistinguisher, Map<BgpNodeLSIdentifier, PathAttrNlriDetailsLocalRib>> vpnNodeTree();
+
+    /**
+     * Returns VPN link NLRI tree.
+     *
+     * @return vpn link NLRI Tree
+     */
+    Map<RouteDistinguisher, Map<BgpLinkLSIdentifier, PathAttrNlriDetailsLocalRib>> vpnLinkTree();
+
+    /**
+     * Returns VPN prefix NLRI tree.
+     *
+     * @return vpn prefix NLRI Tree
+     */
+    Map<RouteDistinguisher, Map<BgpPrefixLSIdentifier, PathAttrNlriDetailsLocalRib>> vpnPrefixTree();
 }
diff --git a/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/linkstate/BgpLinkLSIdentifier.java b/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/linkstate/BgpLinkLSIdentifier.java
index 0294c9c..e80fd13 100644
--- a/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/linkstate/BgpLinkLSIdentifier.java
+++ b/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/linkstate/BgpLinkLSIdentifier.java
@@ -83,15 +83,15 @@
      * @throws BgpParseException while parsing link identifier
      */
     public static BgpLinkLSIdentifier parseLinkIdendifier(ChannelBuffer cb, byte protocolId) throws BgpParseException {
-        //Parse local node descriptor
+        log.debug("Parse local node descriptor");
         NodeDescriptors localNodeDescriptors = new NodeDescriptors();
         localNodeDescriptors = parseNodeDescriptors(cb, NodeDescriptors.LOCAL_NODE_DES_TYPE, protocolId);
 
-        //Parse remote node descriptor
+        log.debug("Parse remote node descriptor");
         NodeDescriptors remoteNodeDescriptors = new NodeDescriptors();
         remoteNodeDescriptors = parseNodeDescriptors(cb, NodeDescriptors.REMOTE_NODE_DES_TYPE, protocolId);
 
-        //Parse link descriptor
+        log.debug("Parse link descriptor");
         LinkedList<BgpValueType> linkDescriptor = new LinkedList<>();
         linkDescriptor = parseLinkDescriptors(cb);
         return new BgpLinkLSIdentifier(localNodeDescriptors, remoteNodeDescriptors, linkDescriptor);
@@ -108,7 +108,7 @@
      */
     public static NodeDescriptors parseNodeDescriptors(ChannelBuffer cb, short desType, byte protocolId)
             throws BgpParseException {
-        log.debug("parse Node descriptors");
+        log.debug("Parse node descriptors");
         ChannelBuffer tempBuf = cb.copy();
         short type = cb.readShort();
         short length = cb.readShort();
@@ -166,8 +166,8 @@
                 break;
             case BgpAttrNodeMultiTopologyId.ATTRNODE_MULTITOPOLOGY:
                 tlv = BgpAttrNodeMultiTopologyId.read(tempCb);
-                count++;
-                //MultiTopologyId TLV cannot repeat more than once
+                count = count++;
+                log.debug("MultiTopologyId TLV cannot repeat more than once");
                 if (count > 1) {
                     //length + 4 implies data contains type, length and value
                     throw new BgpParseException(BgpErrorType.UPDATE_MESSAGE_ERROR,
diff --git a/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/linkstate/BgpNodeLSNlriVer4.java b/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/linkstate/BgpNodeLSNlriVer4.java
index 2cecf0c..a1035e2 100644
--- a/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/linkstate/BgpNodeLSNlriVer4.java
+++ b/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/linkstate/BgpNodeLSNlriVer4.java
@@ -135,7 +135,7 @@
         byte protocolId = cb.readByte();
         long identifier = cb.readLong();
 
-        // Parse Local Node Descriptors
+        log.debug("Parse local node descriptors");
         BgpNodeLSIdentifier localNodeDescriptors = new BgpNodeLSIdentifier();
         localNodeDescriptors = BgpNodeLSIdentifier.parseLocalNodeDescriptors(cb, protocolId);
         return new BgpNodeLSNlriVer4(identifier, protocolId, localNodeDescriptors, isVpn, routeDistinguisher);
diff --git a/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/linkstate/BgpPrefixLSIdentifier.java b/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/linkstate/BgpPrefixLSIdentifier.java
index fbfc781..eb795b4 100644
--- a/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/linkstate/BgpPrefixLSIdentifier.java
+++ b/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/linkstate/BgpPrefixLSIdentifier.java
@@ -51,6 +51,7 @@
     public BgpPrefixLSIdentifier() {
         this.localNodeDescriptors = null;
         this.prefixDescriptor = null;
+        log.debug("Parameters are reset");
     }
 
     /**
@@ -74,11 +75,11 @@
      */
     public static BgpPrefixLSIdentifier parsePrefixIdendifier(ChannelBuffer cb, byte protocolId)
             throws BgpParseException {
-        //Parse Local Node descriptor
+        log.debug("Parse local node descriptor");
         NodeDescriptors localNodeDescriptors = new NodeDescriptors();
         localNodeDescriptors = parseLocalNodeDescriptors(cb, protocolId);
 
-        //Parse Prefix descriptor
+        log.debug("MultiTopologyId TLV cannot repeat more than once");
         List<BgpValueType> prefixDescriptor = new LinkedList<>();
         prefixDescriptor = parsePrefixDescriptors(cb);
         return new BgpPrefixLSIdentifier(localNodeDescriptors, prefixDescriptor);
diff --git a/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4/BgpKeepaliveMsgVer4.java b/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4/BgpKeepaliveMsgVer4.java
index ac44c54..7cb13aa 100644
--- a/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4/BgpKeepaliveMsgVer4.java
+++ b/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4/BgpKeepaliveMsgVer4.java
@@ -124,13 +124,13 @@
         @Override
         public void write(ChannelBuffer cb, BgpKeepaliveMsgVer4 message) {
 
-            // write marker
+            log.debug("Write marker");
             cb.writeBytes(marker, 0, MARKER_LENGTH);
 
-            // write length of header
+            log.debug("Write length of header");
             cb.writeShort(PACKET_MINIMUM_LENGTH);
 
-            // write the type of message
+            log.debug("Write the type of message");
             cb.writeByte(MSG_TYPE.getType());
         }
     }
diff --git a/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4/BgpNotificationMsgVer4.java b/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4/BgpNotificationMsgVer4.java
index b252de8..382f123 100644
--- a/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4/BgpNotificationMsgVer4.java
+++ b/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4/BgpNotificationMsgVer4.java
@@ -198,7 +198,7 @@
                 cb.writeBytes(message.data);
             }
 
-            //Update message length field in notification message
+            log.debug("Update message length field in notification message");
             int length = cb.writerIndex() - msgStartIndex;
             cb.setShort(headerLenIndex, (short) length);
             message.bgpHeader.setLength((short) length);
diff --git a/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4/BgpOpenMsgVer4.java b/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4/BgpOpenMsgVer4.java
index 5ab79fe..d8900ad 100644
--- a/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4/BgpOpenMsgVer4.java
+++ b/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4/BgpOpenMsgVer4.java
@@ -193,14 +193,19 @@
             // Read AS number
             asNumber = cb.getUnsignedShort(cb.readerIndex());
             cb.readShort();
+            log.debug("AS number read");
+
             // Read Hold timer
             holdTime = cb.readShort();
+            log.debug("Holding time read");
 
             // Read BGP Identifier
             bgpId = cb.readInt();
+            log.debug("BGP identifier read");
 
             // Read optional parameter length
             optParaLen = cb.readByte();
+            log.debug("OPtional parameter length read");
 
             // Read Capabilities if optional parameter length is greater than 0
             if (optParaLen != 0) {
@@ -263,7 +268,7 @@
                     throw new BgpParseException("Invalid length received for RpdCapability.");
                 }
                 if (length > cb.readableBytes()) {
-                    throw new BgpParseException("Four octet as num tlv length"
+                    throw new BgpParseException("Four octet as num TLV length"
                             + " is more than readableBytes.");
                 }
                 short rpdAfi = cb.readShort();
@@ -559,7 +564,7 @@
         while (listIterator.hasNext()) {
             BgpValueType tlv = listIterator.next();
             if (tlv == null) {
-                log.debug("Warning: tlv is null from CapabilityTlv list");
+                log.debug("Warning: TLV is null from CapabilityTlv list");
                 continue;
             }
             tlv.write(cb);
diff --git a/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4/BgpPathAttributes.java b/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4/BgpPathAttributes.java
index 9f8ec82..6847dd6 100644
--- a/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4/BgpPathAttributes.java
+++ b/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4/BgpPathAttributes.java
@@ -154,7 +154,7 @@
                 pathAttribute = WideCommunity.read(cb);
                 break;
             default:
-                //skip bytes for unsupported attribute types
+                log.debug("Skip bytes for unsupported attribute types");
                 UnSupportedAttribute.read(cb);
             }
             pathAttributeList.add(pathAttribute);
@@ -263,19 +263,19 @@
         }
 
         if (!isOrigin) {
-            log.debug("Mandatory Attributes not Present");
+            log.debug("Mandatory attributes not Present");
             Validation.validateType(BgpErrorType.UPDATE_MESSAGE_ERROR,
                     BgpErrorType.MISSING_WELLKNOWN_ATTRIBUTE,
                     Origin.ORIGIN_TYPE);
         }
         if (!isAsPath) {
-            log.debug("Mandatory Attributes not Present");
+            log.debug("Mandatory attributes not Present");
             Validation.validateType(BgpErrorType.UPDATE_MESSAGE_ERROR,
                     BgpErrorType.MISSING_WELLKNOWN_ATTRIBUTE,
                     AsPath.ASPATH_TYPE);
         }
         if (!isMpUnReach && !isMpReach && !isNextHop) {
-            log.debug("Mandatory Attributes not Present");
+            log.debug("Mandatory attributes not Present");
             Validation.validateType(BgpErrorType.UPDATE_MESSAGE_ERROR,
                     BgpErrorType.MISSING_WELLKNOWN_ATTRIBUTE,
                     NextHop.NEXTHOP_TYPE);
diff --git a/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4/BgpUpdateMsgVer4.java b/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4/BgpUpdateMsgVer4.java
index 7062a7d..b6576a3 100644
--- a/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4/BgpUpdateMsgVer4.java
+++ b/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4/BgpUpdateMsgVer4.java
@@ -130,7 +130,7 @@
             LinkedList<IpPrefix> withDrwRoutes = new LinkedList<>();
             LinkedList<IpPrefix> nlri = new LinkedList<>();
             BgpPathAttributes bgpPathAttributes = new BgpPathAttributes();
-            // Reading Withdrawn Routes Length
+
             Short withDrwLen = cb.readShort();
 
             if (cb.readableBytes() < withDrwLen) {
@@ -138,13 +138,15 @@
                         BgpErrorType.MALFORMED_ATTRIBUTE_LIST,
                         cb.readableBytes());
             }
+            log.debug("Reading withdrawn routes length");
             ChannelBuffer tempCb = cb.readBytes(withDrwLen);
             if (withDrwLen != 0) {
                 // Parsing WithdrawnRoutes
                 withDrwRoutes = parseWithdrawnRoutes(tempCb);
+                log.debug("Withdrawn routes parsed");
             }
             if (cb.readableBytes() < MIN_LEN_AFTER_WITHDRW_ROUTES) {
-                log.debug("Bgp Path Attribute len field not present");
+                log.debug("Bgp path attribute len field not present");
                 throw new BgpParseException(BgpErrorType.UPDATE_MESSAGE_ERROR,
                         BgpErrorType.MALFORMED_ATTRIBUTE_LIST, null);
             }
@@ -156,6 +158,7 @@
                 throw new BgpParseException(BgpErrorType.UPDATE_MESSAGE_ERROR,
                         BgpErrorType.MALFORMED_ATTRIBUTE_LIST, null);
             }
+            log.debug("Total path attribute length read");
             if (totPathAttrLen != 0) {
                 // Parsing BGPPathAttributes
                 if (cb.readableBytes() < totPathAttrLen) {
diff --git a/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/BgpFsSourcePrefix.java b/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/BgpFsSourcePrefix.java
index e205246..9587cc5 100644
--- a/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/BgpFsSourcePrefix.java
+++ b/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/BgpFsSourcePrefix.java
@@ -15,17 +15,16 @@
  */
 package org.onosproject.bgpio.types;
 
-import java.nio.ByteBuffer;
-import java.util.Objects;
-
+import com.google.common.base.MoreObjects;
+import com.google.common.base.Preconditions;
 import org.jboss.netty.buffer.ChannelBuffer;
 import org.onlab.packet.IpPrefix;
 import org.onosproject.bgpio.exceptions.BgpParseException;
 import org.onosproject.bgpio.util.Constants;
 import org.onosproject.bgpio.util.Validation;
 
-import com.google.common.base.MoreObjects;
-import com.google.common.base.Preconditions;
+import java.nio.ByteBuffer;
+import java.util.Objects;
 
 /**
  * Provides implementation of IPv4AddressTlv.
@@ -33,13 +32,14 @@
 public class BgpFsSourcePrefix implements BgpValueType {
 
     public static final byte FLOW_SPEC_TYPE = Constants.BGP_FLOWSPEC_SRC_PREFIX;
+    public static final int BYTE_IN_BITS = 8;
     private byte length;
     private IpPrefix ipPrefix;
-    public static final int BYTE_IN_BITS = 8;
+
     /**
      * Constructor to initialize parameters.
      *
-     * @param length length of the prefix
+     * @param length   length of the prefix
      * @param ipPrefix ip prefix
      */
     public BgpFsSourcePrefix(byte length, IpPrefix ipPrefix) {
@@ -48,6 +48,50 @@
     }
 
     /**
+     * Reads the channel buffer and returns object of IPv4AddressTlv.
+     *
+     * @param cb channelBuffer
+     * @return object of flow spec source prefix
+     * @throws BgpParseException while parsing BgpFsSourcePrefix
+     */
+    public static BgpFsSourcePrefix read(ChannelBuffer cb) throws BgpParseException {
+        IpPrefix ipPrefix;
+
+        int length = cb.readByte();
+        if (length == 0) {
+            byte[] prefix = new byte[]{0};
+            ipPrefix = Validation.bytesToPrefix(prefix, length);
+            return new BgpFsSourcePrefix((byte) ipPrefix.prefixLength(), ipPrefix);
+        }
+
+        int len = length / BYTE_IN_BITS;
+        int reminder = length % BYTE_IN_BITS;
+        if (reminder > 0) {
+            len = len + 1;
+        }
+        if (cb.readableBytes() < len) {
+            Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR,
+                    BgpErrorType.MALFORMED_ATTRIBUTE_LIST, cb.readableBytes());
+        }
+        byte[] prefix = new byte[len];
+        cb.readBytes(prefix, 0, len);
+        ipPrefix = Validation.bytesToPrefix(prefix, length);
+
+        return new BgpFsSourcePrefix((byte) ipPrefix.prefixLength(), ipPrefix);
+    }
+
+    /**
+     * Returns object of this class with specified values.
+     *
+     * @param ipPrefix ip prefix
+     * @param length   length of ip prefix
+     * @return object of this class
+     */
+    public static BgpFsSourcePrefix of(final IpPrefix ipPrefix, final byte length) {
+        return new BgpFsSourcePrefix(length, ipPrefix);
+    }
+
+    /**
      * Returns ip prefix.
      *
      * @return ipPrefix ip prefix
@@ -87,50 +131,6 @@
         return cb.writerIndex() - iLenStartIndex;
     }
 
-    /**
-     * Reads the channel buffer and returns object of IPv4AddressTlv.
-     *
-     * @param cb channelBuffer
-     * @return object of flow spec source prefix
-     * @throws BgpParseException while parsing BgpFsSourcePrefix
-     */
-    public static BgpFsSourcePrefix read(ChannelBuffer cb) throws BgpParseException {
-        IpPrefix ipPrefix;
-
-        int length = cb.readByte();
-        if (length == 0) {
-            byte[] prefix = new byte[] {0};
-            ipPrefix = Validation.bytesToPrefix(prefix, length);
-            return new BgpFsSourcePrefix((byte) ipPrefix.prefixLength(), ipPrefix);
-        }
-
-        int len = length / BYTE_IN_BITS;
-        int reminder = length % BYTE_IN_BITS;
-        if (reminder > 0) {
-            len = len + 1;
-        }
-        if (cb.readableBytes() < len) {
-            Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR,
-                    BgpErrorType.MALFORMED_ATTRIBUTE_LIST, cb.readableBytes());
-        }
-        byte[] prefix = new byte[len];
-        cb.readBytes(prefix, 0, len);
-        ipPrefix = Validation.bytesToPrefix(prefix, length);
-
-        return new BgpFsSourcePrefix((byte) ipPrefix.prefixLength(), ipPrefix);
-    }
-
-    /**
-     * Returns object of this class with specified values.
-     *
-     * @param ipPrefix ip prefix
-     * @param length length of ip prefix
-     * @return object of this class
-     */
-    public static BgpFsSourcePrefix of(final IpPrefix ipPrefix, final byte length) {
-        return new BgpFsSourcePrefix(length, ipPrefix);
-    }
-
     @Override
     public int compareTo(Object o) {
         if (this.equals(o)) {
diff --git a/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/BgpValueType.java b/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/BgpValueType.java
index 3fb8d3b..32aaa71 100644
--- a/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/BgpValueType.java
+++ b/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/BgpValueType.java
@@ -44,4 +44,4 @@
      * @return result after comparing two objects
      */
     int compareTo(Object o);
-}
\ No newline at end of file
+}
diff --git a/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpAttrNodeName.java b/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpAttrNodeName.java
index 605e7e3..f7f783e 100644
--- a/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpAttrNodeName.java
+++ b/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpAttrNodeName.java
@@ -80,6 +80,7 @@
 
         nodeName = new byte[lsAttrLength];
         cb.readBytes(nodeName);
+        log.debug("LS attribute node name read");
         return BgpAttrNodeName.of(nodeName);
     }
 
diff --git a/protocols/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/BgpChannelHandler.java b/protocols/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/BgpChannelHandler.java
index 92236a4..1f6e5bc 100644
--- a/protocols/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/BgpChannelHandler.java
+++ b/protocols/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/BgpChannelHandler.java
@@ -499,6 +499,7 @@
 
         if (e.getCause() instanceof ReadTimeoutException) {
             // device timeout
+            bgpController.closedSessionExceptionAdd(peerAddr, e.getCause().toString());
             log.error("Disconnecting device {} due to read timeout", getPeerInfoString());
             sendNotification(BgpErrorType.HOLD_TIMER_EXPIRED, (byte) 0, null);
             state = ChannelState.IDLE;
@@ -506,9 +507,11 @@
             ctx.getChannel().close();
             return;
         } else if (e.getCause() instanceof ClosedChannelException) {
+            bgpController.activeSessionExceptionAdd(peerAddr, e.getCause().toString());
             log.debug("Channel for bgp {} already closed", getPeerInfoString());
         } else if (e.getCause() instanceof IOException) {
             log.error("Disconnecting peer {} due to IO Error: {}", getPeerInfoString(), e.getCause().getMessage());
+            bgpController.closedSessionExceptionAdd(peerAddr, e.getCause().toString());
             if (log.isDebugEnabled()) {
                 // still print stack trace if debug is enabled
                 log.debug("StackTrace for previous Exception: ", e.getCause());
@@ -520,6 +523,7 @@
             BgpParseException errMsg = (BgpParseException) e.getCause();
             byte errorCode = errMsg.getErrorCode();
             byte errorSubCode = errMsg.getErrorSubCode();
+            bgpController.activeSessionExceptionAdd(peerAddr, e.getCause().toString());
             ChannelBuffer tempCb = errMsg.getData();
             if (tempCb != null) {
                 int dataLength = tempCb.readableBytes();
@@ -529,9 +533,11 @@
             sendNotification(errorCode, errorSubCode, data);
         } else if (e.getCause() instanceof RejectedExecutionException) {
             log.warn("Could not process message: queue full");
+            bgpController.activeSessionExceptionAdd(peerAddr, e.getCause().toString());
         } else {
             stopKeepAliveTimer();
             log.error("Error while processing message from peer " + getPeerInfoString() + "state " + this.state);
+            bgpController.closedSessionExceptionAdd(peerAddr, e.getCause().toString());
             ctx.getChannel().close();
         }
     }
@@ -733,7 +739,7 @@
      * @throws IOException while processing error message
      */
     public void processUnknownMsg(byte errorCode, byte errorSubCode, byte data) throws BgpParseException, IOException {
-        log.debug("UNKNOWN message received");
+        log.debug("Unknown message received");
         byte[] byteArray = new byte[1];
         byteArray[0] = data;
         sendNotification(errorCode, errorSubCode, byteArray);
@@ -782,7 +788,7 @@
      * @throws BgpParseException
      */
     private boolean capabilityValidation(BgpChannelHandler h, BgpOpenMsg openmsg) throws BgpParseException {
-        log.debug("capabilityValidation");
+        log.debug("capability validation");
 
         boolean isFourOctetCapabilityExits = false;
         boolean isRpdCapabilityExits = false;
@@ -916,7 +922,7 @@
      * @return true or false
      */
     private boolean asNumberValidation(BgpChannelHandler h, BgpOpenMsg openMsg) {
-        log.debug("AS Num validation");
+        log.debug("AS number validation");
 
         int capAsNum = 0;
         boolean isFourOctetCapabilityExits = false;
diff --git a/protocols/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/BgpConfig.java b/protocols/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/BgpConfig.java
index a0bac3e..867f6a6 100644
--- a/protocols/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/BgpConfig.java
+++ b/protocols/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/BgpConfig.java
@@ -19,6 +19,8 @@
 import java.util.Map.Entry;
 import java.util.Set;
 import java.util.TreeMap;
+import java.util.List;
+import java.util.ArrayList;
 
 import org.onlab.packet.Ip4Address;
 import org.onlab.packet.IpAddress;
@@ -42,7 +44,7 @@
     private static final short DEFAULT_HOLD_TIMER = 120;
     private static final short DEFAULT_CONN_RETRY_TIME = 120;
     private static final short DEFAULT_CONN_RETRY_COUNT = 5;
-
+    private List<BgpConnectPeerImpl> peerList = new ArrayList();
     private State state = State.INIT;
     private int localAs;
     private int maxSession;
@@ -189,10 +191,10 @@
             }
 
             this.bgpPeerTree.put(routerid, lspeer);
-            log.debug("added successfully");
+            log.debug("Added successfully");
             return true;
         } else {
-            log.debug("already exists");
+            log.debug("Already exists");
             return false;
         }
     }
@@ -208,6 +210,8 @@
                 connectPeer = new BgpConnectPeerImpl(bgpController, routerid, Controller.BGP_PORT_NUM);
                 lspeer.setConnectPeer(connectPeer);
                 connectPeer.connectPeer();
+                peerList.add((BgpConnectPeerImpl) connectPeer);
+
             }
             return true;
         }
diff --git a/protocols/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/BgpConnectPeerImpl.java b/protocols/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/BgpConnectPeerImpl.java
index 494718b..a53bf23 100644
--- a/protocols/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/BgpConnectPeerImpl.java
+++ b/protocols/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/BgpConnectPeerImpl.java
@@ -42,6 +42,38 @@
     private int connectRetryTime;
     private ChannelPipelineFactory pfact;
     private ClientBootstrap peerBootstrap;
+    public String getPeerHost() {
+        return peerHost;
+    }
+    public static int getRetryInterval() {
+        return RETRY_INTERVAL;
+    }
+
+    @Override
+    public int getPeerPort() {
+        return peerPort;
+    }
+    @Override
+    public int getConnectRetryCounter() {
+        return connectRetryCounter;
+    }
+
+    public void setConnectRetryCounter(int connectRetryCounter) {
+        this.connectRetryCounter = connectRetryCounter;
+    }
+
+    public void setConnectRetryTime(int connectRetryTime) {
+        this.connectRetryTime = connectRetryTime;
+    }
+
+    public BgpCfg getBgpconfig() {
+        return bgpconfig;
+    }
+
+    public void setBgpconfig(BgpCfg bgpconfig) {
+        this.bgpconfig = bgpconfig;
+    }
+
     private BgpCfg bgpconfig;
 
     /**
@@ -118,14 +150,14 @@
                         } else {
 
                             connectRetryCounter++;
-                            log.info("Connected to remote host {}, Connect Counter {}", peerHost, connectRetryCounter);
+                            log.debug("Connected to remote host {}, Connect Counter {}", peerHost, connectRetryCounter);
                             disconnectPeer();
                             return;
                         }
                     }
                 });
             } catch (Exception e) {
-                log.info("Connect peer exception : " + e.toString());
+                log.debug("Connect peer exception : " + e.toString());
                 disconnectPeer();
             }
         }
diff --git a/protocols/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/BgpControllerImpl.java b/protocols/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/BgpControllerImpl.java
index 83c0648..15a5b58 100644
--- a/protocols/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/BgpControllerImpl.java
+++ b/protocols/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/BgpControllerImpl.java
@@ -38,6 +38,9 @@
 import org.slf4j.LoggerFactory;
 
 import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.Map;
+import java.util.TreeMap;
 import java.util.List;
 import java.util.Set;
 import java.util.concurrent.ConcurrentHashMap;
@@ -50,7 +53,7 @@
 public class BgpControllerImpl implements BgpController {
 
     private static final Logger log = LoggerFactory.getLogger(BgpControllerImpl.class);
-
+    final Controller ctrl = new Controller(this);
     protected ConcurrentHashMap<BgpId, BgpPeer> connectedPeers = new ConcurrentHashMap<BgpId, BgpPeer>();
 
     protected BgpPeerManagerImpl peerManager = new BgpPeerManagerImpl();
@@ -60,10 +63,53 @@
 
     protected Set<BgpNodeListener> bgpNodeListener = new CopyOnWriteArraySet<>();
     protected Set<BgpLinkListener> bgpLinkListener = new CopyOnWriteArraySet<>();
-
-    final Controller ctrl = new Controller(this);
-
+    protected BgpController bgpController;
     private BgpConfig bgpconfig = new BgpConfig(this);
+    private List<String> activeExceptionList = new LinkedList();
+    private LinkedList<String> closedExceptionList = new LinkedList<String>();
+    private Map<String, List<String>> activeSessionExceptionMap = new TreeMap<>();
+    private Map<String, List<String>> closedSessionExceptionMap = new TreeMap<>();
+
+    @Override
+    public void activeSessionExceptionAdd(String peerId, String exception) {
+        if (peerId != null) {
+            activeExceptionList.add(exception);
+            activeSessionExceptionMap.put(peerId, activeExceptionList);
+        } else {
+            log.debug("Peer Id is null");
+        }
+        if (activeExceptionList.size() > 10) {
+            activeExceptionList.clear();
+            activeExceptionList.add(exception);
+            activeSessionExceptionMap.put(peerId, activeExceptionList);
+        }
+    }
+
+
+    @Override
+    public void closedSessionExceptionAdd(String peerId, String exception) {
+        if (peerId != null) {
+            closedExceptionList.add(exception);
+            closedSessionExceptionMap.put(peerId, closedExceptionList);
+         } else {
+            log.debug("Peer Id is null");
+        }
+        if (closedExceptionList.size() > 10) {
+            closedExceptionList.clear();
+            closedExceptionList.add(exception);
+            closedSessionExceptionMap.put(peerId, closedExceptionList);
+        }
+    }
+
+    @Override
+    public Map<String, List<String>> activeSessionMap() {
+        return activeSessionExceptionMap;
+    }
+
+    @Override
+    public Map<String, List<String>> closedSessionMap() {
+        return closedSessionExceptionMap;
+    }
 
     @Activate
     public void activate() {
@@ -73,6 +119,8 @@
 
     @Deactivate
     public void deactivate() {
+        activeSessionExceptionMap.clear();
+        closedSessionExceptionMap.clear();
         // Close all connected peers
         closeConnectedPeers();
         this.ctrl.stop();
diff --git a/protocols/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/BgpLocalRibImpl.java b/protocols/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/BgpLocalRibImpl.java
index aef8055..9bf2ee3 100644
--- a/protocols/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/BgpLocalRibImpl.java
+++ b/protocols/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/BgpLocalRibImpl.java
@@ -69,6 +69,7 @@
      *
      * @return node tree
      */
+    @Override
     public Map<BgpNodeLSIdentifier, PathAttrNlriDetailsLocalRib> nodeTree() {
         return nodeTree;
     }
@@ -78,6 +79,7 @@
      *
      * @return link tree
      */
+    @Override
     public Map<BgpLinkLSIdentifier, PathAttrNlriDetailsLocalRib> linkTree() {
         return linkTree;
     }
@@ -87,6 +89,7 @@
      *
      * @return prefix tree
      */
+    @Override
     public Map<BgpPrefixLSIdentifier, PathAttrNlriDetailsLocalRib> prefixTree() {
         return prefixTree;
     }
@@ -96,6 +99,7 @@
      *
      * @return vpn node NLRI tree
      */
+    @Override
     public Map<RouteDistinguisher, Map<BgpNodeLSIdentifier, PathAttrNlriDetailsLocalRib>> vpnNodeTree() {
         return vpnNodeTree;
     }
@@ -105,6 +109,7 @@
      *
      * @return vpn link NLRI Tree
      */
+    @Override
     public Map<RouteDistinguisher, Map<BgpLinkLSIdentifier, PathAttrNlriDetailsLocalRib>> vpnLinkTree() {
         return vpnLinkTree;
     }
@@ -114,6 +119,7 @@
      *
      * @return vpn prefix NLRI Tree
      */
+    @Override
     public Map<RouteDistinguisher, Map<BgpPrefixLSIdentifier, PathAttrNlriDetailsLocalRib>> vpnPrefixTree() {
         return vpnPrefixTree;
     }
@@ -421,7 +427,7 @@
                 decisionResult = selectionAlgo.compare(prefixTree.get(prefixIdentifier), detailsLocRib);
                 if (decisionResult < 0) {
                     prefixTree.replace(prefixIdentifier, detailsLocRib);
-                    log.debug("local RIB prefix updated: {}", detailsLocRib.toString());
+                    log.debug("Local RIB prefix updated: {}", detailsLocRib.toString());
                 }
             } else {
                     if (!isVpnRib) {
diff --git a/protocols/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/BgpPeerImpl.java b/protocols/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/BgpPeerImpl.java
index 02a4321..40048bc 100644
--- a/protocols/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/BgpPeerImpl.java
+++ b/protocols/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/BgpPeerImpl.java
@@ -142,16 +142,20 @@
                 if (tlv.getType() == MultiProtocolExtnCapabilityTlv.TYPE) {
                     MultiProtocolExtnCapabilityTlv temp = (MultiProtocolExtnCapabilityTlv) tlv;
                     if ((temp.getAfi() == afi) && (temp.getSafi() == sAfi)) {
+                        log.debug("Multi prorotcol extension capabality TLV is true");
                         return true;
+
                     }
                 } else if (tlv.getType() == RpdCapabilityTlv.TYPE) {
                     RpdCapabilityTlv temp = (RpdCapabilityTlv) tlv;
                     if ((temp.getAfi() == afi) && (temp.getSafi() == sAfi)) {
+                        log.debug("RPD capabality TLV is true");
                         return true;
                     }
                 }
             }
         }
+        log.debug("IS capabality is not supported ");
         return false;
     }
 
@@ -236,7 +240,7 @@
         BgpMessage msg = Controller.getBgpMessageFactory4().updateMessageBuilder()
                                                            .setBgpPathAttributes(attributesList).build();
 
-        log.debug("Sending Flow spec Update message to {}", channel.getRemoteAddress());
+        log.debug("Sending flow spec update message to {}", channel.getRemoteAddress());
         channel.write(Collections.singletonList(msg));
     }
 
diff --git a/protocols/pcep/api/src/main/java/org/onosproject/pcep/controller/PcepCfg.java b/protocols/pcep/api/src/main/java/org/onosproject/pcep/controller/PcepCfg.java
new file mode 100644
index 0000000..a6aa623
--- /dev/null
+++ b/protocols/pcep/api/src/main/java/org/onosproject/pcep/controller/PcepCfg.java
@@ -0,0 +1,56 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.pcep.controller;
+
+/**
+ * PCEP peer state information.
+ */
+
+public interface PcepCfg {
+
+    State getState();
+
+    void setState(State state);
+
+    enum State {
+        /**
+         * Signifies that its just created.
+         */
+        INIT,
+
+        /**
+         * Signifies that only IP Address is configured.
+         */
+        OPENWAIT,
+
+        /**
+         * Signifies that only Autonomous System is configured.
+         */
+        KEEPWAIT,
+
+        /**
+         * Signifies that both IP and Autonomous System is configured.
+         */
+        ESTABLISHED,
+
+        /**
+         * Signifies that both IP and Autonomous System is down.
+         */
+        DOWN
+    }
+
+}
diff --git a/protocols/pcep/api/src/main/java/org/onosproject/pcep/controller/PcepClientController.java b/protocols/pcep/api/src/main/java/org/onosproject/pcep/controller/PcepClientController.java
index 9f02b8b..7ced035 100644
--- a/protocols/pcep/api/src/main/java/org/onosproject/pcep/controller/PcepClientController.java
+++ b/protocols/pcep/api/src/main/java/org/onosproject/pcep/controller/PcepClientController.java
@@ -15,9 +15,6 @@
  */
 package org.onosproject.pcep.controller;
 
-import java.util.Collection;
-import java.util.LinkedList;
-
 import org.onosproject.incubator.net.tunnel.DefaultLabelStack;
 import org.onosproject.incubator.net.tunnel.LabelStack;
 import org.onosproject.incubator.net.tunnel.Tunnel;
@@ -25,6 +22,11 @@
 import org.onosproject.pcepio.protocol.PcepMessage;
 import org.onosproject.pcepio.types.PcepValueType;
 
+import java.util.Collection;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+
 /**
  * Abstraction of an Pcep client controller. Serves as a one stop
  * shop for obtaining Pcep devices and (un)register listeners
@@ -135,4 +137,41 @@
      * @return list of ERO sub-objects
      */
     public LinkedList<PcepValueType> createPcepLabelStack(DefaultLabelStack labelStack, Path path);
+
+    /**
+     * Returns list of PCEP exceptions.
+     *
+     * @return PcepExceptions
+     */
+    public Map<String, List<String>> getPcepExceptions();
+
+    /**
+     * Returns all the pcep error messages received .
+     *
+     * @return PcepErrorMsg
+     */
+    public Map<Integer, Integer> getPcepErrorMsg();
+
+    /**
+     * Returns the pcep session details.
+     *
+     * @return PcepSession
+     */
+    public Map<String, String> getPcepSessionMap();
+
+    /**
+     * Returns the pcep sessionid information.
+     *
+     * @return PcepSessionId
+     */
+    public Map<String, Byte> getPcepSessionIdMap();
+
+    /**
+     * Creates detailed information about pcep error value and type per peer.
+     *
+     * @param peerId id of the peer which sent the error message
+     * @param errorType the error type of the error message received
+     * @param errValue the error value of the error message received
+     */
+    void peerErrorMsg(String peerId, Integer errorType, Integer errValue);
 }
diff --git a/protocols/pcep/api/src/main/java/org/onosproject/pcep/controller/PcepErrorDetail.java b/protocols/pcep/api/src/main/java/org/onosproject/pcep/controller/PcepErrorDetail.java
new file mode 100644
index 0000000..febf74f
--- /dev/null
+++ b/protocols/pcep/api/src/main/java/org/onosproject/pcep/controller/PcepErrorDetail.java
@@ -0,0 +1,108 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.pcep.controller;
+
+import java.util.Map;
+import java.util.TreeMap;
+
+/**
+ * PCEP error message details.
+ */
+public class PcepErrorDetail {
+
+    private Map<Integer, String> sessionEstablishmentFailureMap = new TreeMap<>();
+    private Map<Integer, String> unknownObjectMap = new TreeMap<>();
+    private Map<Integer, String> notSupportedObjectMap = new TreeMap<>();
+    private Map<Integer, String> policyViolationMap = new TreeMap<>();
+    private Map<Integer, String> mandatoryObjectMissingMap = new TreeMap<>();
+    private Map<Integer, String> receptionOfInvalidObjectMap = new TreeMap<>();
+    private Map<Integer, String> invalidOperationMap = new TreeMap<>();
+
+
+    public Map sessionEstablishmentFailure() {
+        sessionEstablishmentFailureMap.put(1, "Reception of an invalid Open message or a non Open message.");
+        sessionEstablishmentFailureMap.put(2, "no Open message received before the expiration of the OpenWait timer");
+        sessionEstablishmentFailureMap.put(3, "unacceptable and non-negotiable session characteristics");
+        sessionEstablishmentFailureMap.put(4, "unacceptable but negotiable session characteristics");
+        sessionEstablishmentFailureMap.put(5, "reception of a second Open message with still " +
+                "unacceptable session characteristics");
+        sessionEstablishmentFailureMap.put(6, "reception of a PCErr message proposing unacceptable " +
+                "session characteristics");
+        sessionEstablishmentFailureMap.put(7, "No Keepalive or PCErr message received before the " +
+                "expiration of the KeepWait timer");
+        sessionEstablishmentFailureMap.put(8, "PCEP version not supported");
+        return sessionEstablishmentFailureMap;
+    }
+
+
+    public Map unknownObject() {
+        unknownObjectMap.put(1, "Unrecognized object class");
+        unknownObjectMap.put(2, "Unrecognized object type");
+        return unknownObjectMap;
+    }
+
+    public Map notSupportedObject() {
+        notSupportedObjectMap.put(1, "Not Supported object class");
+        notSupportedObjectMap.put(2, "Not Supported object type");
+        return notSupportedObjectMap;
+    }
+
+
+    public Map policyViolation() {
+        policyViolationMap.put(1, "C bit of the METRIC object set (request rejected)");
+        policyViolationMap.put(2, "O bit of the RP object cleared (request rejected)");
+        return policyViolationMap;
+    }
+
+
+
+    public Map mandatoryObjectMissing() {
+        mandatoryObjectMissingMap.put(1, "RP object missing");
+        mandatoryObjectMissingMap.put(2, "RRO missing for a re-optimization request (R bit of the RP object set)");
+        mandatoryObjectMissingMap.put(2, "END-POINTS object missing");
+        return mandatoryObjectMissingMap;
+
+    }
+
+
+    public Map receptionOfInvalidObject() {
+        receptionOfInvalidObjectMap.put(1, "reception of an object with P flag not set although the P flag must be" +
+                "set according to this specification.");
+        return receptionOfInvalidObjectMap;
+    }
+
+    public Map invalidOperation() {
+        invalidOperationMap.put(1, "Attempted LSP Update Request for a non-delegated LSP.  The PCEP-ERROR Object" +
+                " is followed by the LSP Object that identifies the LSP.");
+        invalidOperationMap.put(2, "Attempted LSP Update Request if the" +
+                " stateful PCE capability was not" +
+                " advertised.");
+        invalidOperationMap.put(3, "Attempted LSP Update Request for an LSP" +
+                "identified by an unknown PLSP-ID.");
+        invalidOperationMap.put(4, "A PCE indicates to a PCC that it has" +
+                " exceeded the resource limit allocated" +
+                " for its state, and thus it cannot" +
+                " accept and process its LSP State Report" +
+                " message.");
+        invalidOperationMap.put(5, "Attempted LSP State Report if active" +
+                " stateful PCE capability was not" +
+                " advertised.");
+        return invalidOperationMap;
+    }
+
+
+
+}
diff --git a/protocols/pcep/api/src/main/java/org/onosproject/pcep/controller/PcepErrorType.java b/protocols/pcep/api/src/main/java/org/onosproject/pcep/controller/PcepErrorType.java
new file mode 100644
index 0000000..de68061
--- /dev/null
+++ b/protocols/pcep/api/src/main/java/org/onosproject/pcep/controller/PcepErrorType.java
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.pcep.controller;
+
+/**
+ * PCEP error message type information.
+ */
+public enum  PcepErrorType {
+    SESSIONESTABLISHMENTFAILURE(1),
+    CAPABALITYNOTSUPPORTED(2),
+    UNKNOWNOBJECT(3),
+    NOTSUPPORTEDOBJECT(4),
+    POLICYVIOLATION(5),
+    MANDATORYOBJECTMISSING(6),
+    SYNCHRONIZEDPATHCOMPUTATIONREQUESTMISSING(7),
+    UNKNOWNREQUESTREFERENCE(8),
+    ESTABLISHINGSECONDPCEPSESSION(9),
+    RECEPTIONOFINVALIDOBJECT(10),
+    INVALIDOPERATION(19),
+    VIRTUALNETWORKTLVMISSING(255);
+
+    public  int value;
+
+    /**
+     * Creates an instance of Pcep Error Type.
+     *
+     * @param value represents Error type
+     */
+    PcepErrorType(int value) {
+        this.value = value;
+    }
+
+    /**
+     * Gets the value representing Pcep Error Type.
+     *
+     * @return value represents Error Type
+     */
+    public  int value() {
+        return value;
+    }
+}
\ No newline at end of file
diff --git a/protocols/pcep/ctl/src/main/java/org/onosproject/pcep/controller/impl/Controller.java b/protocols/pcep/ctl/src/main/java/org/onosproject/pcep/controller/impl/Controller.java
index b7d1d52..92ea93a 100644
--- a/protocols/pcep/ctl/src/main/java/org/onosproject/pcep/controller/impl/Controller.java
+++ b/protocols/pcep/ctl/src/main/java/org/onosproject/pcep/controller/impl/Controller.java
@@ -20,8 +20,11 @@
 import java.lang.management.ManagementFactory;
 import java.lang.management.RuntimeMXBean;
 import java.net.InetSocketAddress;
-import java.util.HashMap;
 import java.util.Map;
+import java.util.LinkedList;
+import java.util.TreeMap;
+import java.util.List;
+import java.util.HashMap;
 import java.util.concurrent.Executors;
 
 import org.jboss.netty.bootstrap.ServerBootstrap;
@@ -30,6 +33,7 @@
 import org.jboss.netty.channel.group.DefaultChannelGroup;
 import org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory;
 import org.onosproject.pcep.controller.PccId;
+import org.onosproject.pcep.controller.PcepCfg;
 import org.onosproject.pcep.controller.PcepPacketStats;
 import org.onosproject.pcep.controller.driver.PcepAgent;
 import org.onosproject.pcep.controller.driver.PcepClientDriver;
@@ -48,7 +52,7 @@
     private static final Logger log = LoggerFactory.getLogger(Controller.class);
 
     private static final PcepFactory FACTORY1 = PcepFactories.getFactory(PcepVersion.PCEP_1);
-
+    private PcepCfg pcepConfig = new PcepConfig();
     private ChannelGroup cg;
 
     // Configuration options
@@ -60,12 +64,83 @@
 
     private PcepAgent agent;
 
+    private Map<String, String> peerMap = new TreeMap<>();
+    private Map<String, List<String>> pcepExceptionMap = new TreeMap<>();
+    private Map<Integer, Integer> pcepErrorMsg = new TreeMap<>();
+    private Map<String, Byte> sessionMap = new TreeMap<>();
+    private LinkedList<String> pcepExceptionList = new LinkedList<String>();
+
     private NioServerSocketChannelFactory execFactory;
 
     // Perf. related configuration
     private static final int SEND_BUFFER_SIZE = 4 * 1024 * 1024;
 
     /**
+     * pcep session information.
+     *
+     * @param peerId id of the peer with which the session is being formed
+     * @param status pcep session status
+     * @param sessionId pcep session id
+     */
+    public void peerStatus(String peerId, String status, byte sessionId) {
+        if (peerId != null) {
+            peerMap.put(peerId, status);
+            sessionMap.put(peerId, sessionId);
+        } else {
+            log.debug("Peer Id is null");
+        }
+    }
+
+    /**
+     * Pcep session exceptions information.
+     *
+     * @param peerId id of the peer which has generated the exception
+     * @param exception pcep session exception
+     */
+    public void peerExceptions(String peerId, String exception) {
+        if (peerId != null) {
+            pcepExceptionList.add(exception);
+            pcepExceptionMap.put(peerId, pcepExceptionList);
+        } else {
+            log.debug("Peer Id is null");
+        }
+        if (pcepExceptionList.size() > 10) {
+            pcepExceptionList.clear();
+            pcepExceptionList.add(exception);
+            pcepExceptionMap.put(peerId, pcepExceptionList);
+        }
+    }
+
+    /**
+     * Create a map of pcep error messages received.
+     *
+     * @param peerId id of the peer which has sent the error message
+     * @param errorType error type of pcep error messgae
+     * @param errValue error value of pcep error messgae
+     */
+    public void peerErrorMsg(String peerId, Integer errorType, Integer errValue) {
+        if (peerId == null) {
+            pcepErrorMsg.put(errorType, errValue);
+        } else {
+            if (pcepErrorMsg.size() > 10) {
+                pcepErrorMsg.clear();
+            }
+            pcepErrorMsg.put(errorType, errValue);
+        }
+    }
+
+    /**
+     * Returns the pcep session details.
+     *
+     * @return pcep session details
+     */
+    public Map<String, Byte> mapSession() {
+        return this.sessionMap;
+    }
+
+
+
+    /**
      * Returns factory version for processing pcep messages.
      *
      * @return instance of factory version
@@ -84,6 +159,33 @@
     }
 
     /**
+     * Returns the list of pcep peers with session information.
+     *
+     * @return pcep peer information
+     */
+    public  Map<String, String> mapPeer() {
+        return this.peerMap;
+    }
+
+    /**
+     * Returns the list of pcep exceptions per peer.
+     *
+     * @return pcep exceptions
+     */
+    public  Map<String, List<String>> exceptionsMap() {
+        return this.pcepExceptionMap;
+    }
+
+    /**
+     * Returns the type and value of pcep error messages.
+     *
+     * @return pcep error message
+     */
+    public Map<Integer, Integer> mapErrorMsg() {
+        return this.pcepErrorMsg;
+    }
+
+    /**
      * Tell controller that we're ready to accept pcc connections.
      */
     public void run() {
@@ -101,7 +203,7 @@
             InetSocketAddress sa = new InetSocketAddress(pcepPort);
             cg = new DefaultChannelGroup();
             cg.add(bootstrap.bind(sa));
-            log.info("Listening for PCC connection on {}", sa);
+            log.debug("Listening for PCC connection on {}", sa);
         } catch (Exception e) {
             throw new RuntimeException(e);
         }
diff --git a/protocols/pcep/ctl/src/main/java/org/onosproject/pcep/controller/impl/PcepChannelHandler.java b/protocols/pcep/ctl/src/main/java/org/onosproject/pcep/controller/impl/PcepChannelHandler.java
index d2523f5..d557116 100644
--- a/protocols/pcep/ctl/src/main/java/org/onosproject/pcep/controller/impl/PcepChannelHandler.java
+++ b/protocols/pcep/ctl/src/main/java/org/onosproject/pcep/controller/impl/PcepChannelHandler.java
@@ -40,6 +40,7 @@
 import org.onlab.packet.IpAddress;
 import org.onosproject.pcep.controller.ClientCapability;
 import org.onosproject.pcep.controller.PccId;
+import org.onosproject.pcep.controller.PcepCfg;
 import org.onosproject.pcep.controller.driver.PcepClientDriver;
 import org.onosproject.pcepio.exceptions.PcepParseException;
 import org.onosproject.pcepio.protocol.PcepError;
@@ -87,7 +88,9 @@
     // State needs to be volatile because the HandshakeTimeoutHandler
     // needs to check if the handshake is complete
     private volatile ChannelState state;
-
+    private String peerAddr;
+    private SocketAddress address;
+    private InetSocketAddress inetAddress;
     // When a pcc client with a ip addresss is found (i.e we already have a
     // connected client with the same ip), the new client is immediately
     // disconnected. At that point netty callsback channelDisconnected() which
@@ -122,226 +125,38 @@
     //  Channel State Machine
     //*************************
 
-    /**
-     * The state machine for handling the client/channel state. All state
-     * transitions should happen from within the state machine (and not from other
-     * parts of the code)
-     */
-    enum ChannelState {
-        /**
-         * Initial state before channel is connected.
-         */
-        INIT(false) {
-
-        },
-        /**
-         * Once the session is established, wait for open message.
-         */
-        OPENWAIT(false) {
-            @Override
-            void processPcepMessage(PcepChannelHandler h, PcepMessage m) throws IOException, PcepParseException {
-
-                log.info("Message received in OPEN WAIT State");
-
-                //check for open message
-                if (m.getType() != PcepType.OPEN) {
-                    // When the message type is not open message increment the wrong packet statistics
-                    h.processUnknownMsg();
-                    log.debug("message is not OPEN message");
-                } else {
-
-                    h.pcepPacketStats.addInPacket();
-                    PcepOpenMsg pOpenmsg = (PcepOpenMsg) m;
-                        //Do Capability negotiation.
-                        h.capabilityNegotiation(pOpenmsg);
-                        log.debug("Sending handshake OPEN message");
-                        h.sessionId = pOpenmsg.getPcepOpenObject().getSessionId();
-                        h.pcepVersion = pOpenmsg.getPcepOpenObject().getVersion();
-
-                        //setting keepalive and deadTimer
-                        byte yKeepalive = pOpenmsg.getPcepOpenObject().getKeepAliveTime();
-                        byte yDeadTimer = pOpenmsg.getPcepOpenObject().getDeadTime();
-                        h.keepAliveTime = yKeepalive;
-                        if (yKeepalive < yDeadTimer) {
-                            h.deadTime = yDeadTimer;
-                        } else {
-                            if (DEADTIMER_MAXIMUM_VALUE > (yKeepalive * KEEPALIVE_MULTIPLE_FOR_DEADTIMER)) {
-                                h.deadTime = (byte) (yKeepalive * KEEPALIVE_MULTIPLE_FOR_DEADTIMER);
-                            } else {
-                                h.deadTime = DEADTIMER_MAXIMUM_VALUE;
-                            }
-                        }
-
-                        /*
-                         * If MPLS LSR id and PCEP session socket IP addresses are not same,
-                         * the MPLS LSR id will be encoded in separate TLV.
-                         * We always maintain session information based on LSR ids.
-                         * The socket IP is stored in channel.
-                         */
-                        LinkedList<PcepValueType> optionalTlvs = pOpenmsg.getPcepOpenObject().getOptionalTlv();
-                        if (optionalTlvs != null) {
-                            for (PcepValueType optionalTlv : optionalTlvs) {
-                                if (optionalTlv instanceof NodeAttributesTlv) {
-                                    List<PcepValueType> subTlvs = ((NodeAttributesTlv) optionalTlv)
-                                            .getllNodeAttributesSubTLVs();
-                                    if (subTlvs == null) {
-                                        break;
-                                    }
-                                    for (PcepValueType subTlv : subTlvs) {
-                                        if (subTlv instanceof IPv4RouterIdOfLocalNodeSubTlv) {
-                                            h.thispccId = PccId.pccId(IpAddress
-                                                    .valueOf(((IPv4RouterIdOfLocalNodeSubTlv) subTlv).getInt()));
-                                            break;
-                                        }
-                                    }
-                                    break;
-                                }
-                            }
-                        }
-
-                        if (h.thispccId == null) {
-                            final SocketAddress address = h.channel.getRemoteAddress();
-                            if (!(address instanceof InetSocketAddress)) {
-                                throw new IOException("Invalid client connection. Pcc is indentifed based on IP");
-                            }
-
-                            final InetSocketAddress inetAddress = (InetSocketAddress) address;
-                            h.thispccId = PccId.pccId(IpAddress.valueOf(inetAddress.getAddress()));
-                        }
-
-                        h.sendHandshakeOpenMessage();
-                        h.pcepPacketStats.addOutPacket();
-                        h.setState(KEEPWAIT);
-                }
-            }
-        },
-        /**
-         * Once the open messages are exchanged, wait for keep alive message.
-         */
-        KEEPWAIT(false) {
-            @Override
-            void processPcepMessage(PcepChannelHandler h, PcepMessage m) throws IOException, PcepParseException {
-                log.info("message received in KEEPWAIT state");
-                //check for keep alive message
-                if (m.getType() != PcepType.KEEP_ALIVE) {
-                    // When the message type is not keep alive message increment the wrong packet statistics
-                    h.processUnknownMsg();
-                    log.error("message is not KEEPALIVE message");
-                } else {
-                    // Set the client connected status
-                    h.pcepPacketStats.addInPacket();
-                    log.debug("sending keep alive message in KEEPWAIT state");
-                    h.pc = h.controller.getPcepClientInstance(h.thispccId, h.sessionId, h.pcepVersion,
-                            h.pcepPacketStats);
-                    //Get pc instance and set capabilities
-                    h.pc.setCapability(h.capability);
-
-                    // Initilialize DB sync status.
-                    h.pc.setLspDbSyncStatus(NOT_SYNCED);
-                    h.pc.setLabelDbSyncStatus(NOT_SYNCED);
-
-                    // set the status of pcc as connected
-                    h.pc.setConnected(true);
-                    h.pc.setChannel(h.channel);
-
-                    // set any other specific parameters to the pcc
-                    h.pc.setPcVersion(h.pcepVersion);
-                    h.pc.setPcSessionId(h.sessionId);
-                    h.pc.setPcKeepAliveTime(h.keepAliveTime);
-                    h.pc.setPcDeadTime(h.deadTime);
-                    int keepAliveTimer = h.keepAliveTime & BYTE_MASK;
-                    int deadTimer = h.deadTime & BYTE_MASK;
-                    if (0 == h.keepAliveTime) {
-                        h.deadTime = 0;
-                    }
-                    // handle keep alive and dead time
-                    if (keepAliveTimer != PcepPipelineFactory.DEFAULT_KEEP_ALIVE_TIME
-                            || deadTimer != PcepPipelineFactory.DEFAULT_DEAD_TIME) {
-
-                        h.channel.getPipeline().replace("idle", "idle",
-                                new IdleStateHandler(PcepPipelineFactory.TIMER, deadTimer, keepAliveTimer, 0));
-                    }
-                    log.debug("Dead timer : " + deadTimer);
-                    log.debug("Keep alive time : " + keepAliveTimer);
-
-                    //set the state handshake completion.
-
-                    h.sendKeepAliveMessage();
-                    h.pcepPacketStats.addOutPacket();
-                    h.setHandshakeComplete(true);
-
-                    if (!h.pc.connectClient()) {
-                        disconnectDuplicate(h);
-                    } else {
-                        h.setState(ESTABLISHED);
-                        //Session is established, add a network configuration with LSR id and device capabilities.
-                        h.addNode();
-                    }
-                }
-            }
-        },
-        /**
-         * Once the keep alive messages are exchanged, the state is established.
-         */
-        ESTABLISHED(true) {
-            @Override
-            void processPcepMessage(PcepChannelHandler h, PcepMessage m) throws IOException, PcepParseException {
-
-                //h.channel.getPipeline().remove("waittimeout");
-                log.debug("Message received in established state " + m.getType());
-                //dispatch the message
-                h.dispatchMessage(m);
-            }
-        };
-        private boolean handshakeComplete;
-
-        ChannelState(boolean handshakeComplete) {
-            this.handshakeComplete = handshakeComplete;
-        }
-
-        void processPcepMessage(PcepChannelHandler h, PcepMessage m) throws IOException, PcepParseException {
-            // do nothing
-        }
-
-        /**
-         * Is this a state in which the handshake has completed.
-         *
-         * @return true if the handshake is complete
-         */
-        public boolean isHandshakeComplete() {
-            return this.handshakeComplete;
-        }
-
-        protected void disconnectDuplicate(PcepChannelHandler h) {
-            log.error("Duplicated Pcc IP or incompleted cleanup - " + "disconnecting channel {}",
-                    h.getClientInfoString());
-            h.duplicatePccIdFound = Boolean.TRUE;
-            h.channel.disconnect();
-        }
-
-        /**
-         * Sets handshake complete status.
-         *
-         * @param handshakeComplete status of handshake
-         */
-        public void setHandshakeComplete(boolean handshakeComplete) {
-            this.handshakeComplete = handshakeComplete;
-        }
-
-    }
-
     @Override
     public void channelConnected(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception {
         channel = e.getChannel();
         log.info("PCC connected from {}", channel.getRemoteAddress());
 
+        address = channel.getRemoteAddress();
+        if (!(address instanceof InetSocketAddress)) {
+            throw new IOException("Invalid peer connection.");
+        }
+
+        inetAddress = (InetSocketAddress) address;
+        peerAddr = IpAddress.valueOf(inetAddress.getAddress()).toString();
+
         // Wait for open message from pcc client
         setState(ChannelState.OPENWAIT);
+        controller.peerStatus(peerAddr, PcepCfg.State.OPENWAIT.toString(), sessionId);
     }
 
     @Override
     public void channelDisconnected(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception {
         log.info("Pcc disconnected callback for pc:{}. Cleaning up ...", getClientInfoString());
+        controller.peerStatus(peerAddr, PcepCfg.State.DOWN.toString(), sessionId);
+
+        channel = e.getChannel();
+        address = channel.getRemoteAddress();
+        if (!(address instanceof InetSocketAddress)) {
+            throw new IOException("Invalid peer connection.");
+        }
+
+        inetAddress = (InetSocketAddress) address;
+        peerAddr = IpAddress.valueOf(inetAddress.getAddress()).toString();
+
         if (thispccId != null) {
             if (!duplicatePccIdFound) {
                 // if the disconnected client (on this ChannelHandler)
@@ -377,6 +192,7 @@
                 // OpenWait timer.
                 errMsg = getErrorMsg(PcepErrorDetailInfo.ERROR_TYPE_1, PcepErrorDetailInfo.ERROR_VALUE_2);
                 log.debug("Sending PCEP-ERROR message to PCC.");
+                controller.peerExceptions(peerAddr, e.getCause().toString());
                 channel.write(Collections.singletonList(errMsg));
                 channel.close();
                 state = ChannelState.INIT;
@@ -386,14 +202,17 @@
                 // KeepWait timer.
                 errMsg = getErrorMsg(PcepErrorDetailInfo.ERROR_TYPE_1, PcepErrorDetailInfo.ERROR_VALUE_7);
                 log.debug("Sending PCEP-ERROR message to PCC.");
+                controller.peerExceptions(peerAddr, e.getCause().toString());
                 channel.write(Collections.singletonList(errMsg));
                 channel.close();
                 state = ChannelState.INIT;
                 return;
             }
         } else if (e.getCause() instanceof ClosedChannelException) {
+            controller.peerExceptions(peerAddr, e.getCause().toString());
             log.debug("Channel for pc {} already closed", getClientInfoString());
         } else if (e.getCause() instanceof IOException) {
+            controller.peerExceptions(peerAddr, e.getCause().toString());
             log.error("Disconnecting client {} due to IO Error: {}", getClientInfoString(), e.getCause().getMessage());
             if (log.isDebugEnabled()) {
                 // still print stack trace if debug is enabled
@@ -401,6 +220,7 @@
             }
             channel.close();
         } else if (e.getCause() instanceof PcepParseException) {
+            controller.peerExceptions(peerAddr, e.getCause().toString());
             PcepParseException errMsgParse = (PcepParseException) e.getCause();
             byte errorType = errMsgParse.getErrorType();
             byte errorValue = errMsgParse.getErrorValue();
@@ -414,8 +234,10 @@
             }
         } else if (e.getCause() instanceof RejectedExecutionException) {
             log.warn("Could not process message: queue full");
+            controller.peerExceptions(peerAddr, e.getCause().toString());
         } else {
             log.error("Error while processing message from client " + getClientInfoString() + "state " + this.state);
+            controller.peerExceptions(peerAddr, e.getCause().toString());
             channel.close();
         }
     }
@@ -458,15 +280,6 @@
     }
 
     /**
-     * To set the handshake status.
-     *
-     * @param handshakeComplete value is handshake status
-     */
-    public void setHandshakeComplete(boolean handshakeComplete) {
-        this.state.setHandshakeComplete(handshakeComplete);
-    }
-
-    /**
      * Is this a state in which the handshake has completed.
      *
      * @return true if the handshake is complete
@@ -476,6 +289,15 @@
     }
 
     /**
+     * To set the handshake status.
+     *
+     * @param handshakeComplete value is handshake status
+     */
+    public void setHandshakeComplete(boolean handshakeComplete) {
+        this.state.setHandshakeComplete(handshakeComplete);
+    }
+
+    /**
      * To handle the pcep message.
      *
      * @param m pcep message
@@ -561,24 +383,24 @@
             PcepValueType tlv = listIterator.next();
 
             switch (tlv.getType()) {
-            case PceccCapabilityTlv.TYPE:
-                pceccCapability = true;
-                if (((PceccCapabilityTlv) tlv).sBit()) {
-                    labelStackCapability = true;
-                }
-                break;
-            case StatefulPceCapabilityTlv.TYPE:
-                statefulPceCapability = true;
-                StatefulPceCapabilityTlv stetefulPcCapTlv = (StatefulPceCapabilityTlv) tlv;
-                if (stetefulPcCapTlv.getIFlag()) {
-                    pcInstantiationCapability = true;
-                }
-                break;
-            case SrPceCapabilityTlv.TYPE:
-                srCapability = true;
-                break;
-            default:
-                continue;
+                case PceccCapabilityTlv.TYPE:
+                    pceccCapability = true;
+                    if (((PceccCapabilityTlv) tlv).sBit()) {
+                        labelStackCapability = true;
+                    }
+                    break;
+                case StatefulPceCapabilityTlv.TYPE:
+                    statefulPceCapability = true;
+                    StatefulPceCapabilityTlv stetefulPcCapTlv = (StatefulPceCapabilityTlv) tlv;
+                    if (stetefulPcCapTlv.getIFlag()) {
+                        pcInstantiationCapability = true;
+                    }
+                    break;
+                case SrPceCapabilityTlv.TYPE:
+                    srCapability = true;
+                    break;
+                default:
+                    continue;
             }
         }
         this.capability = new ClientCapability(pceccCapability, statefulPceCapability, pcInstantiationCapability,
@@ -588,7 +410,7 @@
     /**
      * Send keep alive message.
      *
-     * @throws IOException when channel is disconnected
+     * @throws IOException        when channel is disconnected
      * @throws PcepParseException while building keep alive message
      */
     private void sendKeepAliveMessage() throws IOException, PcepParseException {
@@ -638,22 +460,22 @@
 
         llerrObj.add(errObj);
 
-            //If Error caught in other than Openmessage
-            LinkedList<PcepError> llPcepErr = new LinkedList<>();
+        //If Error caught in other than Openmessage
+        LinkedList<PcepError> llPcepErr = new LinkedList<>();
 
-            PcepError pcepErr = factory1.buildPcepError()
-                    .setErrorObjList(llerrObj)
-                    .build();
+        PcepError pcepErr = factory1.buildPcepError()
+                .setErrorObjList(llerrObj)
+                .build();
 
-            llPcepErr.add(pcepErr);
+        llPcepErr.add(pcepErr);
 
-            PcepErrorInfo errInfo = factory1.buildPcepErrorInfo()
-                    .setPcepErrorList(llPcepErr)
-                    .build();
+        PcepErrorInfo errInfo = factory1.buildPcepErrorInfo()
+                .setPcepErrorList(llPcepErr)
+                .build();
 
-            errMsg = factory1.buildPcepErrorMsg()
-                    .setPcepErrorInfo(errInfo)
-                    .build();
+        errMsg = factory1.buildPcepErrorMsg()
+                .setPcepErrorInfo(errInfo)
+                .build();
         return errMsg;
     }
 
@@ -690,4 +512,214 @@
             }
         }
     }
+
+    /**
+     * The state machine for handling the client/channel state. All state
+     * transitions should happen from within the state machine (and not from other
+     * parts of the code)
+     */
+    enum ChannelState {
+        /**
+         * Initial state before channel is connected.
+         */
+        INIT(false) {
+
+        },
+        /**
+         * Once the session is established, wait for open message.
+         */
+        OPENWAIT(false) {
+            @Override
+            void processPcepMessage(PcepChannelHandler h, PcepMessage m) throws IOException, PcepParseException {
+
+                log.info("Message received in OPEN WAIT State");
+
+                //check for open message
+                if (m.getType() != PcepType.OPEN) {
+                    // When the message type is not open message increment the wrong packet statistics
+                    h.processUnknownMsg();
+                    log.debug("Message is not OPEN message");
+                } else {
+
+                    h.pcepPacketStats.addInPacket();
+                    PcepOpenMsg pOpenmsg = (PcepOpenMsg) m;
+                    //Do Capability negotiation.
+                    h.capabilityNegotiation(pOpenmsg);
+                    log.debug("Sending handshake OPEN message");
+                    h.sessionId = pOpenmsg.getPcepOpenObject().getSessionId();
+                    h.pcepVersion = pOpenmsg.getPcepOpenObject().getVersion();
+
+                    //setting keepalive and deadTimer
+                    byte yKeepalive = pOpenmsg.getPcepOpenObject().getKeepAliveTime();
+                    byte yDeadTimer = pOpenmsg.getPcepOpenObject().getDeadTime();
+                    h.keepAliveTime = yKeepalive;
+                    if (yKeepalive < yDeadTimer) {
+                        h.deadTime = yDeadTimer;
+                    } else {
+                        if (DEADTIMER_MAXIMUM_VALUE > (yKeepalive * KEEPALIVE_MULTIPLE_FOR_DEADTIMER)) {
+                            h.deadTime = (byte) (yKeepalive * KEEPALIVE_MULTIPLE_FOR_DEADTIMER);
+                        } else {
+                            h.deadTime = DEADTIMER_MAXIMUM_VALUE;
+                        }
+                    }
+
+                        /*
+                         * If MPLS LSR id and PCEP session socket IP addresses are not same,
+                         * the MPLS LSR id will be encoded in separate TLV.
+                         * We always maintain session information based on LSR ids.
+                         * The socket IP is stored in channel.
+                         */
+                    LinkedList<PcepValueType> optionalTlvs = pOpenmsg.getPcepOpenObject().getOptionalTlv();
+                    if (optionalTlvs != null) {
+                        for (PcepValueType optionalTlv : optionalTlvs) {
+                            if (optionalTlv instanceof NodeAttributesTlv) {
+                                List<PcepValueType> subTlvs = ((NodeAttributesTlv) optionalTlv)
+                                        .getllNodeAttributesSubTLVs();
+                                if (subTlvs == null) {
+                                    break;
+                                }
+                                for (PcepValueType subTlv : subTlvs) {
+                                    if (subTlv instanceof IPv4RouterIdOfLocalNodeSubTlv) {
+                                        h.thispccId = PccId.pccId(IpAddress
+                                                .valueOf(((IPv4RouterIdOfLocalNodeSubTlv) subTlv).getInt()));
+                                        break;
+                                    }
+                                }
+                                break;
+                            }
+                        }
+                    }
+
+                    if (h.thispccId == null) {
+                        final SocketAddress address = h.channel.getRemoteAddress();
+                        if (!(address instanceof InetSocketAddress)) {
+                            throw new IOException("Invalid client connection. Pcc is indentifed based on IP");
+                        }
+
+                        final InetSocketAddress inetAddress = (InetSocketAddress) address;
+                        h.thispccId = PccId.pccId(IpAddress.valueOf(inetAddress.getAddress()));
+                    }
+
+                    h.sendHandshakeOpenMessage();
+                    h.pcepPacketStats.addOutPacket();
+                    h.setState(KEEPWAIT);
+                    h.controller.peerStatus(h.peerAddr.toString(), PcepCfg.State.KEEPWAIT.toString(), h.sessionId);
+                }
+            }
+        },
+        /**
+         * Once the open messages are exchanged, wait for keep alive message.
+         */
+        KEEPWAIT(false) {
+            @Override
+            void processPcepMessage(PcepChannelHandler h, PcepMessage m) throws IOException, PcepParseException {
+                log.info("Message received in KEEPWAIT state");
+                //check for keep alive message
+                if (m.getType() != PcepType.KEEP_ALIVE) {
+                    // When the message type is not keep alive message increment the wrong packet statistics
+                    h.processUnknownMsg();
+                    log.error("Message is not KEEPALIVE message");
+                } else {
+                    // Set the client connected status
+                    h.pcepPacketStats.addInPacket();
+                    log.debug("sending keep alive message in KEEPWAIT state");
+                    h.pc = h.controller.getPcepClientInstance(h.thispccId, h.sessionId, h.pcepVersion,
+                            h.pcepPacketStats);
+                    //Get pc instance and set capabilities
+                    h.pc.setCapability(h.capability);
+
+                    // Initilialize DB sync status.
+                    h.pc.setLspDbSyncStatus(NOT_SYNCED);
+                    h.pc.setLabelDbSyncStatus(NOT_SYNCED);
+
+                    // set the status of pcc as connected
+                    h.pc.setConnected(true);
+                    h.pc.setChannel(h.channel);
+
+                    // set any other specific parameters to the pcc
+                    h.pc.setPcVersion(h.pcepVersion);
+                    h.pc.setPcSessionId(h.sessionId);
+                    h.pc.setPcKeepAliveTime(h.keepAliveTime);
+                    h.pc.setPcDeadTime(h.deadTime);
+                    int keepAliveTimer = h.keepAliveTime & BYTE_MASK;
+                    int deadTimer = h.deadTime & BYTE_MASK;
+                    if (0 == h.keepAliveTime) {
+                        h.deadTime = 0;
+                    }
+                    // handle keep alive and dead time
+                    if (keepAliveTimer != PcepPipelineFactory.DEFAULT_KEEP_ALIVE_TIME
+                            || deadTimer != PcepPipelineFactory.DEFAULT_DEAD_TIME) {
+
+                        h.channel.getPipeline().replace("idle", "idle",
+                                new IdleStateHandler(PcepPipelineFactory.TIMER, deadTimer, keepAliveTimer, 0));
+                    }
+                    log.debug("Dead timer : " + deadTimer);
+                    log.debug("Keep alive time : " + keepAliveTimer);
+
+                    //set the state handshake completion.
+
+                    h.sendKeepAliveMessage();
+                    h.pcepPacketStats.addOutPacket();
+                    h.setHandshakeComplete(true);
+
+                    if (!h.pc.connectClient()) {
+                        disconnectDuplicate(h);
+                    } else {
+                        h.setState(ESTABLISHED);
+                     h.controller.peerStatus(h.peerAddr.toString(), PcepCfg.State.ESTABLISHED.toString(), h.sessionId);
+                        //Session is established, add a network configuration with LSR id and device capabilities.
+                        h.addNode();
+                    }
+                }
+            }
+        },
+        /**
+         * Once the keep alive messages are exchanged, the state is established.
+         */
+        ESTABLISHED(true) {
+            @Override
+            void processPcepMessage(PcepChannelHandler h, PcepMessage m) throws IOException, PcepParseException {
+
+                //h.channel.getPipeline().remove("waittimeout");
+                log.debug("Message received in established state " + m.getType());
+                //dispatch the message
+                h.dispatchMessage(m);
+            }
+        };
+        private boolean handshakeComplete;
+
+        ChannelState(boolean handshakeComplete) {
+            this.handshakeComplete = handshakeComplete;
+        }
+
+        void processPcepMessage(PcepChannelHandler h, PcepMessage m) throws IOException, PcepParseException {
+            // do nothing
+        }
+
+        /**
+         * Is this a state in which the handshake has completed.
+         *
+         * @return true if the handshake is complete
+         */
+        public boolean isHandshakeComplete() {
+            return this.handshakeComplete;
+        }
+
+        /**
+         * Sets handshake complete status.
+         *
+         * @param handshakeComplete status of handshake
+         */
+        public void setHandshakeComplete(boolean handshakeComplete) {
+            this.handshakeComplete = handshakeComplete;
+        }
+
+        protected void disconnectDuplicate(PcepChannelHandler h) {
+            log.error("Duplicated Pcc IP or incompleted cleanup - " + "disconnecting channel {}",
+                    h.getClientInfoString());
+            h.duplicatePccIdFound = Boolean.TRUE;
+            h.channel.disconnect();
+        }
+
+    }
 }
diff --git a/protocols/pcep/ctl/src/main/java/org/onosproject/pcep/controller/impl/PcepClientControllerImpl.java b/protocols/pcep/ctl/src/main/java/org/onosproject/pcep/controller/impl/PcepClientControllerImpl.java
index 999dd40..8ffc707 100644
--- a/protocols/pcep/ctl/src/main/java/org/onosproject/pcep/controller/impl/PcepClientControllerImpl.java
+++ b/protocols/pcep/ctl/src/main/java/org/onosproject/pcep/controller/impl/PcepClientControllerImpl.java
@@ -15,17 +15,18 @@
  */
 package org.onosproject.pcep.controller.impl;
 
-import java.util.Arrays;
+import java.util.Map;
+import java.util.TreeMap;
+import java.util.List;
+import java.util.LinkedList;
+import java.util.Set;
+import java.util.HashSet;
+import java.util.HashMap;
 import java.util.Collection;
 import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
 import java.util.ListIterator;
-import java.util.Map;
-import java.util.Set;
+import java.util.Arrays;
+import java.util.Iterator;
 import java.util.Map.Entry;
 import java.util.concurrent.ConcurrentHashMap;
 
@@ -185,6 +186,7 @@
     private DeviceListener deviceListener = new InternalDeviceListener();
     private LinkListener linkListener = new InternalLinkListener();
     private InternalConfigListener cfgListener = new InternalConfigListener();
+    private Map<Integer, Integer> pcepErrorMsg = new TreeMap<>();
 
     @Activate
     public void activate() {
@@ -220,6 +222,39 @@
     }
 
     @Override
+    public void peerErrorMsg(String peerId, Integer errorType, Integer errValue) {
+        if (peerId == null) {
+            pcepErrorMsg.put(errorType, errValue);
+        } else {
+            if (pcepErrorMsg.size() > 10) {
+                pcepErrorMsg.clear();
+            }
+            pcepErrorMsg.put(errorType, errValue);
+        }
+    }
+
+    @Override
+    public Map<String, List<String>> getPcepExceptions() {
+        return this.ctrl.exceptionsMap();
+    }
+
+    @Override
+    public Map<Integer, Integer> getPcepErrorMsg() {
+        return pcepErrorMsg;
+    }
+
+
+    @Override
+    public Map<String, String> getPcepSessionMap() {
+        return this.ctrl.mapPeer();
+    }
+
+    @Override
+    public Map<String, Byte> getPcepSessionIdMap() {
+        return this.ctrl.mapSession();
+    }
+
+    @Override
     public Collection<PcepClient> getClients() {
         return connectedClients.values();
     }
@@ -879,7 +914,7 @@
 
             connectedClients.remove(pccId);
             for (PcepClientListener l : pcepClientListener) {
-                log.warn("removal for {}", pccId.toString());
+                log.warn("Removal for {}", pccId.toString());
                 l.clientDisconnected(pccId);
             }
         }
diff --git a/protocols/pcep/ctl/src/main/java/org/onosproject/pcep/controller/impl/PcepConfig.java b/protocols/pcep/ctl/src/main/java/org/onosproject/pcep/controller/impl/PcepConfig.java
new file mode 100644
index 0000000..2c8c162
--- /dev/null
+++ b/protocols/pcep/ctl/src/main/java/org/onosproject/pcep/controller/impl/PcepConfig.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.pcep.controller.impl;
+
+import org.onosproject.pcep.controller.PccId;
+import org.onosproject.pcep.controller.PcepCfg;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.TreeMap;
+
+
+public class PcepConfig implements PcepCfg {
+
+    protected static final Logger log = LoggerFactory.getLogger(PcepConfig.class);
+
+    private State state = State.INIT;
+    private PccId pccId;
+    private TreeMap<String, PcepCfg> bgpPeerTree = new TreeMap<>();
+
+    @Override
+    public State getState() {
+        return state;
+    }
+
+    @Override
+    public void setState(State state) {
+        this.state = state;
+    }
+
+}
diff --git a/protocols/pcep/ctl/src/test/java/org/onosproject/pcelabelstore/util/MockPcepClientController.java b/protocols/pcep/ctl/src/test/java/org/onosproject/pcelabelstore/util/MockPcepClientController.java
index 77bf8c5..da8356e 100644
--- a/protocols/pcep/ctl/src/test/java/org/onosproject/pcelabelstore/util/MockPcepClientController.java
+++ b/protocols/pcep/ctl/src/test/java/org/onosproject/pcelabelstore/util/MockPcepClientController.java
@@ -15,10 +15,7 @@
  */
 package org.onosproject.pcelabelstore.util;
 
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.Map;
+
 
 import org.onosproject.incubator.net.tunnel.DefaultLabelStack;
 import org.onosproject.incubator.net.tunnel.LabelStack;
@@ -33,6 +30,12 @@
 import org.onosproject.pcepio.protocol.PcepMessage;
 import org.onosproject.pcepio.types.PcepValueType;
 
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.Map;
+import java.util.List;
+
 public class MockPcepClientController implements PcepClientController {
 
     Map<PccId, PcepClient> clientMap = new HashMap<>();
@@ -120,6 +123,31 @@
     }
 
     @Override
+    public Map<String, List<String>> getPcepExceptions() {
+        return null;
+    }
+
+    @Override
+    public Map<Integer, Integer> getPcepErrorMsg() {
+        return null;
+    }
+
+    @Override
+    public Map<String, String> getPcepSessionMap() {
+        return null;
+    }
+
+    @Override
+    public Map<String, Byte> getPcepSessionIdMap() {
+        return null;
+    }
+
+    @Override
+    public void peerErrorMsg(String peerId, Integer errorType, Integer errValue) {
+
+    }
+
+    @Override
     public boolean allocateLocalLabel(Tunnel tunnel) {
         // TODO Auto-generated method stub
         return false;
diff --git a/providers/bgp/BUCK b/providers/bgp/BUCK
index 403bcbe..b5f516e 100644
--- a/providers/bgp/BUCK
+++ b/providers/bgp/BUCK
@@ -1,6 +1,7 @@
 BUNDLES = [
     '//providers/bgp/cfg:onos-providers-bgp-cfg',
     '//providers/bgp/topology:onos-providers-bgp-topology',
+    '//providers/bgp/cli:onos-providers-bgp-cli',
     '//protocols/bgp/api:onos-protocols-bgp-api',
     '//protocols/bgp/ctl:onos-protocols-bgp-ctl',
     '//protocols/bgp/bgpio:onos-protocols-bgp-bgpio',
diff --git a/providers/bgp/app/app.xml b/providers/bgp/app/app.xml
index ddf438a..e7b1ac1 100755
--- a/providers/bgp/app/app.xml
+++ b/providers/bgp/app/app.xml
@@ -25,6 +25,7 @@
     <artifact>mvn:${project.groupId}/onos-pcep-controller-api/${project.version}</artifact>
     <artifact>mvn:${project.groupId}/onos-bgp-provider-topology/${project.version}</artifact>
     <artifact>mvn:${project.groupId}/onos-bgp-provider-cfg/${project.version}</artifact>
+    <artifact>mvn:${project.groupId}/onos-bgp-provider-cli/${project.version}</artifact>
     <artifact>mvn:${project.groupId}/onos-pcepio/${project.version}</artifact>
     <artifact>mvn:${project.groupId}/onos-app-pcep-api/${project.version}</artifact>
     <artifact>mvn:${project.groupId}/onos-pcep-controller-impl/${project.version}</artifact>
diff --git a/providers/bgp/app/features.xml b/providers/bgp/app/features.xml
index 3bace0e..d50537a 100755
--- a/providers/bgp/app/features.xml
+++ b/providers/bgp/app/features.xml
@@ -23,6 +23,7 @@
         <bundle>mvn:${project.groupId}/onos-bgp-ctl/${project.version}</bundle>
         <bundle>mvn:${project.groupId}/onos-pcep-controller-api/${project.version}</bundle>
         <bundle>mvn:${project.groupId}/onos-bgp-provider-topology/${project.version}</bundle>
+        <bundle>mvn:${project.groupId}/onos-bgp-provider-cli/${project.version}</bundle>
         <bundle>mvn:${project.groupId}/onos-bgp-provider-cfg/${project.version}</bundle>
         <bundle>mvn:${project.groupId}/onos-pcepio/${project.version}</bundle>
         <bundle>mvn:${project.groupId}/onos-app-pcep-api/${project.version}</bundle>
diff --git a/providers/bgp/app/pom.xml b/providers/bgp/app/pom.xml
index 7e93df3..b9605e2 100755
--- a/providers/bgp/app/pom.xml
+++ b/providers/bgp/app/pom.xml
@@ -46,6 +46,11 @@
             <artifactId>onos-bgp-provider-topology</artifactId>
             <version>${project.version}</version>
         </dependency>
+	<dependency>
+            <groupId>org.onosproject</groupId>
+            <artifactId>onos-bgp-provider-cli</artifactId>
+            <version>${project.version}</version>
+        </dependency>
         <dependency>
             <groupId>org.onosproject</groupId>
             <artifactId>onos-app-pce</artifactId>
diff --git a/providers/bgp/cfg/src/main/java/org/onosproject/provider/bgp/cfg/impl/BgpAppConfig.java b/providers/bgp/cfg/src/main/java/org/onosproject/provider/bgp/cfg/impl/BgpAppConfig.java
index f185f65..504930d 100644
--- a/providers/bgp/cfg/src/main/java/org/onosproject/provider/bgp/cfg/impl/BgpAppConfig.java
+++ b/providers/bgp/cfg/src/main/java/org/onosproject/provider/bgp/cfg/impl/BgpAppConfig.java
@@ -24,6 +24,8 @@
 import org.onosproject.bgp.controller.BgpController;
 import org.onosproject.core.ApplicationId;
 import org.onosproject.net.config.Config;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import java.util.ArrayList;
 import java.util.List;
@@ -41,6 +43,7 @@
 
     BgpCfg bgpConfig = null;
 
+    protected final Logger log = LoggerFactory.getLogger(BgpAppConfig.class);
     public static final String ROUTER_ID = "routerId";
     public static final String LOCAL_AS = "localAs";
     public static final String MAX_SESSION = "maxSession";
@@ -170,10 +173,11 @@
         if (flowSpecCapability() != null) {
             String flowSpec = flowSpecCapability();
             if ((!flowSpec.equals("IPV4")) && (!flowSpec.equals("VPNV4")) && (!flowSpec.equals("IPV4_VPNV4"))) {
+                log.debug("Flow specification capabality is false");
                 return false;
             }
         }
-
+        log.debug("Flow specification capabality is true");
         return true;
     }
 
@@ -303,10 +307,11 @@
                     !validateRemoteAs(nodes.get(i).asNumber()) ||
                     !validatePeerHoldTime(nodes.get(i).holdTime()) ||
                     !(connectMode.equals(PEER_CONNECT_ACTIVE) || connectMode.equals(PEER_CONNECT_PASSIVE))) {
+                log.debug("BGP peer configration false");
                 return false;
             }
         }
-
+        log.debug("BGP peer configration true");
         return true;
     }
 
@@ -317,7 +322,6 @@
      */
     public List<BgpPeerConfig> bgpPeer() {
         List<BgpPeerConfig> nodes = new ArrayList<BgpPeerConfig>();
-
         JsonNode jsonNodes = object.get(BGP_PEER);
         if (jsonNodes == null) {
             return null;
diff --git a/providers/bgp/cli/BUCK b/providers/bgp/cli/BUCK
new file mode 100644
index 0000000..64ae7f9
--- /dev/null
+++ b/providers/bgp/cli/BUCK
@@ -0,0 +1,16 @@
+COMPILE_DEPS = [
+    '//lib:CORE_DEPS',
+    '//incubator/api:onos-incubator-api',
+    '//providers/bgp/cfg:onos-providers-bgp-cfg',
+    '//providers/bgp/topology:onos-providers-bgp-topology',
+    '//protocols/bgp/api:onos-protocols-bgp-api',
+    '//protocols/bgp/ctl:onos-protocols-bgp-ctl',
+    '//protocols/bgp/bgpio:onos-protocols-bgp-bgpio',
+    '//lib:org.apache.karaf.shell.console',
+    '//cli:onos-cli',
+]
+
+osgi_jar_with_tests (
+  deps = COMPILE_DEPS,
+)
+
diff --git a/providers/bgp/cli/pom.xml b/providers/bgp/cli/pom.xml
new file mode 100644
index 0000000..76b92b7
--- /dev/null
+++ b/providers/bgp/cli/pom.xml
@@ -0,0 +1,82 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ Copyright 2016-present Open Networking Laboratory
+  ~
+  ~ Licensed under the Apache License, Version 2.0 (the "License");
+  ~ you may not use this file except in compliance with the License.
+  ~ You may obtain a copy of the License at
+  ~
+  ~     http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  -->
+<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xmlns="http://maven.apache.org/POM/4.0.0"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.onosproject</groupId>
+        <artifactId>onos-bgp-providers</artifactId>
+        <version>1.9.0-SNAPSHOT</version>
+    </parent>
+
+    <artifactId>onos-bgp-provider-cli</artifactId>
+    <packaging>bundle</packaging>
+
+    <description>BGP cli implementation</description>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.onosproject</groupId>
+            <artifactId>onos-cli</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.onosproject</groupId>
+            <artifactId>onos-bgp-api</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.onosproject</groupId>
+            <artifactId>onos-bgp-provider-cfg</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>org.osgi.compendium</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.karaf.shell</groupId>
+            <artifactId>org.apache.karaf.shell.console</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.felix</groupId>
+            <artifactId>org.apache.felix.scr.annotations</artifactId>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.onosproject</groupId>
+            <artifactId>onos-bgp-ctl</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+    </dependencies>
+<build>
+    <plugins>
+    <plugin>
+        <groupId>org.apache.felix</groupId>
+        <artifactId>maven-bundle-plugin</artifactId>
+        <extensions>true</extensions>
+        <configuration>
+            <instructions>
+                <Export-Package>org.onosproject.bgp.*</Export-Package>
+            </instructions>
+        </configuration>
+    </plugin>
+</plugins>
+</build>
+</project>
diff --git a/providers/bgp/cli/src/main/java/org/onosproject/bgp/cli/BgpConfiguration.java b/providers/bgp/cli/src/main/java/org/onosproject/bgp/cli/BgpConfiguration.java
new file mode 100644
index 0000000..d34c80e
--- /dev/null
+++ b/providers/bgp/cli/src/main/java/org/onosproject/bgp/cli/BgpConfiguration.java
@@ -0,0 +1,123 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.bgp.cli;
+
+import org.apache.karaf.shell.commands.Argument;
+import org.apache.karaf.shell.commands.Command;
+import org.onosproject.bgp.controller.BgpCfg;
+import org.onosproject.bgp.controller.BgpConnectPeer;
+import org.onosproject.bgp.controller.BgpController;
+import org.onosproject.bgp.controller.BgpPeerCfg;
+import org.onosproject.cli.AbstractShellCommand;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.Set;
+import java.util.TreeMap;
+
+
+@Command(scope = "onos", name = "bgp", description = "lists configuration")
+public class BgpConfiguration extends AbstractShellCommand {
+    private static final Logger log = LoggerFactory.getLogger(BgpConfiguration.class);
+    private static final String CONFIGURATION = "configuration";
+    private static final String PEER = "peer";
+    protected BgpController bgpController;
+    protected BgpConnectPeer bgpConnectPeer;
+    protected BgpPeerCfg bgpPeerCfg;
+    protected BgpCfg bgpCfg;
+    @Argument(index = 0, name = "name",
+            description = "configuration" + "\n" + "peer",
+            required = true, multiValued = false)
+    String name = null;
+    @Argument(index = 1, name = "peer",
+            description = "peerIp",
+            required = false, multiValued = false)
+    String peer = null;
+
+    @Override
+    protected void execute() {
+        switch (name) {
+            case CONFIGURATION:
+                displayBgpConfiguration();
+                break;
+            case PEER:
+                displayBgpPeerConfiguration();
+                break;
+            default:
+                System.out.print("Unknown command...!!");
+                break;
+        }
+    }
+
+    private void displayBgpConfiguration() {
+        try {
+
+            this.bgpController = get(BgpController.class);
+            bgpCfg = bgpController.getConfig();
+            print("RouterID = %s, ASNumber = %s, MaxSession = %s, HoldingTime = %s, LsCapabality = %s," +
+                            " LargeAsCapabality = %s, FlowSpecCapabality = %s", bgpCfg.getRouterId(),
+                    bgpCfg.getAsNumber(), bgpCfg.getMaxSession(), bgpCfg.getHoldTime(),
+                    bgpCfg.getLsCapability(), bgpCfg.getLargeASCapability(), bgpCfg.flowSpecCapability());
+
+        } catch (Exception e) {
+            log.debug("Error occurred while displaying BGP configuration: {}", e.getMessage());
+        }
+    }
+
+    private void displayBgpPeerConfiguration() {
+        try {
+            this.bgpController = get(BgpController.class);
+            BgpCfg bgpCfg = bgpController.getConfig();
+            if (bgpCfg == null) {
+                return;
+            }
+            TreeMap<String, BgpPeerCfg> displayPeerTree = bgpCfg.getPeerTree();
+            Set<String> peerKey = displayPeerTree.keySet();
+            if (peer != null) {
+                if (peerKey.size() > 0) {
+                    for (String peerIdKey : peerKey) {
+                        bgpPeerCfg = displayPeerTree.get(peerIdKey);
+                        bgpConnectPeer = bgpPeerCfg.connectPeer();
+                        if (peerIdKey.equals(peer)) {
+                            print("PeerRouterID = %s, PeerHoldingTime = %s, ASNumber = %s, PeerState = %s," +
+                                            " PeerPort = %s, ConnectRetryCounter = %s",
+                                    peer, bgpPeerCfg.getHoldtime(), bgpPeerCfg.getAsNumber(),
+                                    bgpPeerCfg.getState(), bgpConnectPeer.getPeerPort(),
+                                    bgpConnectPeer.getConnectRetryCounter());
+                        }
+                    }
+                }
+            } else {
+                if (peerKey.size() > 0) {
+                    for (String peerIdKey : peerKey) {
+                        bgpPeerCfg = displayPeerTree.get(peerIdKey);
+                        bgpConnectPeer = bgpPeerCfg.connectPeer();
+                        print("PeerRouterID = %s, PeerHoldingTime = %s, ASNumber = %s, PeerState = %s, PeerPort = %s," +
+                                        " ConnectRetryCounter = %s",
+                                bgpPeerCfg.getPeerRouterId(), bgpPeerCfg.getHoldtime(), bgpPeerCfg.getAsNumber(),
+                                bgpPeerCfg.getState(), bgpConnectPeer.getPeerPort(),
+                                bgpConnectPeer.getConnectRetryCounter());
+                    }
+                }
+
+            }
+        } catch (Exception e) {
+            log.debug("Error occurred while displaying BGP peer configuration: {}", e.getMessage());
+        }
+    }
+
+
+}
\ No newline at end of file
diff --git a/providers/bgp/cli/src/main/java/org/onosproject/bgp/cli/BgpExceptions.java b/providers/bgp/cli/src/main/java/org/onosproject/bgp/cli/BgpExceptions.java
new file mode 100644
index 0000000..2f129ba
--- /dev/null
+++ b/providers/bgp/cli/src/main/java/org/onosproject/bgp/cli/BgpExceptions.java
@@ -0,0 +1,123 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.bgp.cli;
+
+import org.apache.karaf.shell.commands.Argument;
+import org.apache.karaf.shell.commands.Command;
+import org.onosproject.bgp.controller.BgpController;
+import org.onosproject.cli.AbstractShellCommand;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+
+@Command(scope = "onos", name = "bgp-exception", description = "Displays Exceptions")
+public class BgpExceptions extends AbstractShellCommand {
+    public static final String ACTIVESESSION = "activesession";
+    public static final String CLOSEDSESSION = "closedsession";
+    private static final Logger log = LoggerFactory.getLogger(BgpExceptions.class);
+    protected BgpController bgpController;
+    @Argument(index = 0, name = "name",
+            description = "activesession" + "\n" + "closedsession",
+            required = true, multiValued = false)
+    String name = null;
+    @Argument(index = 1, name = "peerIp",
+            description = "peerId",
+            required = false, multiValued = false)
+    String peerId = null;
+    private Set<String> activeSessionExceptionkeySet;
+    private Set<String> closedSessionExceptionKeySet;
+
+    @Override
+    protected void execute() {
+        switch (name) {
+            case ACTIVESESSION:
+                displayActiveSessionException();
+                break;
+            case CLOSEDSESSION:
+                displayClosedSessionException();
+                break;
+            default:
+                System.out.print("Unknown Command");
+                break;
+        }
+    }
+
+    private void displayActiveSessionException() {
+        try {
+            this.bgpController = get(BgpController.class);
+            Map<String, List<String>> activeSessionExceptionMap = bgpController.activeSessionMap();
+            activeSessionExceptionkeySet = activeSessionExceptionMap.keySet();
+            if (activeSessionExceptionkeySet.size() > 0) {
+                if (peerId != null) {
+                    if (activeSessionExceptionkeySet.contains(peerId)) {
+                        for (String peerIdKey : activeSessionExceptionkeySet) {
+                            List activeSessionExceptionlist = activeSessionExceptionMap.get(peerIdKey);
+                            System.out.println(activeSessionExceptionlist);
+                        }
+                    } else {
+                        System.out.print("Wrong argument");
+                    }
+                } else {
+                    activeSessionExceptionkeySet = activeSessionExceptionMap.keySet();
+                    if (activeSessionExceptionkeySet.size() > 0) {
+                        for (String peerId : activeSessionExceptionkeySet) {
+                            print("PeerId = %s, Exception = %s ", peerId, activeSessionExceptionMap.get(peerId));
+                        }
+                    }
+                }
+            }
+        } catch (Exception e) {
+            log.debug("Error occurred while displaying BGP exceptions: {}", e.getMessage());
+        }
+    }
+
+    private void displayClosedSessionException() {
+        try {
+            this.bgpController = get(BgpController.class);
+            Map<String, List<String>> closedSessionExceptionMap = bgpController.closedSessionMap();
+            closedSessionExceptionKeySet = closedSessionExceptionMap.keySet();
+            if (closedSessionExceptionKeySet.size() > 0) {
+                if (peerId != null) {
+                    if (closedSessionExceptionKeySet.contains(peerId)) {
+                        for (String peerIdKey : closedSessionExceptionKeySet) {
+                            List closedSessionExceptionlist = closedSessionExceptionMap.get(peerIdKey);
+                            print("Exceptions = %s", closedSessionExceptionlist);
+                        }
+                    } else {
+                        System.out.print("Wrong argument");
+                    }
+                } else {
+                    closedSessionExceptionKeySet = closedSessionExceptionMap.keySet();
+                    if (closedSessionExceptionKeySet.size() > 0) {
+                        for (String peerId : closedSessionExceptionKeySet) {
+                            print("PeerId = %s, Exception = %s", peerId, closedSessionExceptionMap.get(peerId));
+                        }
+                    }
+                }
+            }
+        } catch (Exception e) {
+            log.debug("Error occurred while displaying resons for session closure: {}", e.getMessage());
+        }
+    }
+
+
+}
+
+
diff --git a/providers/bgp/cli/src/main/java/org/onosproject/bgp/cli/BgpLocalRibDisplay.java b/providers/bgp/cli/src/main/java/org/onosproject/bgp/cli/BgpLocalRibDisplay.java
new file mode 100644
index 0000000..3e5fb68
--- /dev/null
+++ b/providers/bgp/cli/src/main/java/org/onosproject/bgp/cli/BgpLocalRibDisplay.java
@@ -0,0 +1,406 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.bgp.cli;
+
+import org.apache.karaf.shell.commands.Argument;
+import org.apache.karaf.shell.commands.Command;
+import org.onosproject.bgp.controller.BgpController;
+import org.onosproject.bgp.controller.BgpLocalRib;
+import org.onosproject.bgpio.protocol.BgpLSNlri;
+
+import org.onosproject.bgpio.protocol.linkstate.BgpNodeLSIdentifier;
+import org.onosproject.bgpio.protocol.linkstate.BgpNodeLSNlriVer4;
+import org.onosproject.bgpio.protocol.linkstate.PathAttrNlriDetails;
+import org.onosproject.bgpio.protocol.linkstate.PathAttrNlriDetailsLocalRib;
+import org.onosproject.bgpio.protocol.linkstate.BgpLinkLSIdentifier;
+import org.onosproject.bgpio.protocol.linkstate.BgpPrefixLSIdentifier;
+import org.onosproject.bgpio.protocol.linkstate.NodeDescriptors;
+import org.onosproject.bgpio.protocol.linkstate.BgpLinkLsNlriVer4;
+import org.onosproject.bgpio.types.IPv4AddressTlv;
+import org.onosproject.bgpio.types.RouteDistinguisher;
+import org.onosproject.bgpio.types.BgpValueType;
+import org.onosproject.bgpio.types.LinkStateAttributes;
+import org.onosproject.bgpio.types.MpReachNlri;
+import org.onosproject.bgpio.types.AutonomousSystemTlv;
+import org.onosproject.bgpio.types.IsIsNonPseudonode;
+import org.onosproject.bgpio.types.LocalPref;
+import org.onosproject.bgpio.types.Origin;
+import org.onosproject.bgpio.types.attr.BgpAttrRouterIdV4;
+import org.onosproject.bgpio.types.attr.BgpLinkAttrMaxLinkBandwidth;
+import org.onosproject.bgpio.types.attr.BgpLinkAttrUnRsrvdLinkBandwidth;
+import org.onosproject.bgpio.types.attr.BgpLinkAttrTeDefaultMetric;
+import org.onosproject.bgpio.types.attr.BgpLinkAttrIgpMetric;
+import org.onosproject.cli.AbstractShellCommand;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.Map;
+import java.util.Set;
+import java.util.List;
+import java.util.Iterator;
+import java.util.Arrays;
+
+
+
+@Command(scope = "onos", name = "bgp-rib", description = "lists RIB configuration")
+public class BgpLocalRibDisplay extends AbstractShellCommand {
+    private static final Logger log = LoggerFactory.getLogger(BgpLocalRibDisplay.class);
+    private static final String NODETREE = "nodes";
+    private static final String LINKTREE = "links";
+    private static final String PREFIXTREE = "prefix";
+    private static final String VPNNODETREE = "vpnnodes";
+    private static final String VPNLINKTREE = "vpnlinkS";
+    private static final String VPNPREFIXTREE = "vpnprefix";
+    protected Origin origin;
+    protected LocalPref localPref;
+    protected BgpAttrRouterIdV4 bgpAttrRouterIdV4;
+    protected IsIsNonPseudonode isIsNonPseudonode;
+    protected AutonomousSystemTlv autonomousSystemTlv;
+    protected IPv4AddressTlv iPv4AddressTlv;
+    protected BgpLinkAttrMaxLinkBandwidth bgpLinkAttrMaxLinkBandwidth;
+    protected BgpLinkAttrUnRsrvdLinkBandwidth bgpLinkAttrUnRsrvdLinkBandwidth;
+    protected BgpLinkAttrTeDefaultMetric bgpLinkAttrTeDefaultMetric;
+    protected BgpLinkAttrIgpMetric bgpLinkAttrIgpMetric;
+    protected PathAttrNlriDetailsLocalRib pathAttrNlriDetailsLocalRib;
+    protected MpReachNlri mpReachNlri;
+    protected PathAttrNlriDetails pathAttrNlriDetails;
+    protected BgpNodeLSNlriVer4.ProtocolType protocolType;
+    protected BgpController bgpController = get(BgpController.class);
+    protected BgpLocalRib bgpLocalRib = bgpController.bgpLocalRib();
+    Map<BgpNodeLSIdentifier, PathAttrNlriDetailsLocalRib> nodeTreeMap = bgpLocalRib.nodeTree();
+    Set<BgpNodeLSIdentifier> nodekeySet = nodeTreeMap.keySet();
+    Map<BgpLinkLSIdentifier, PathAttrNlriDetailsLocalRib> linkTreeMap = bgpLocalRib.linkTree();
+    Set<BgpLinkLSIdentifier> linkkeySet = linkTreeMap.keySet();
+    @Argument(index = 0, name = "name",
+            description = "nodetree" + "\n" + "linktree" + "\n" + "prefixtree" + "\n" + "vpnnodetree" + "\n" +
+                    "vpnlinktree" + "\n" + "vpnprefixtree", required = true, multiValued = false)
+    String name = null;
+    @Argument(index = 1, name = "numberofentries",
+            description = "numberofentries", required = false, multiValued = false)
+    int numberofentries;
+    @Argument(index = 2, name = "vpnId",
+            description = "vpnId", required = false, multiValued = false)
+    String vpnId = null;
+    private int count = 0;
+
+    @Override
+    protected void execute() {
+        switch (name) {
+            case NODETREE:
+                displayNodes();
+                break;
+            case LINKTREE:
+                displayLinks();
+                break;
+            case PREFIXTREE:
+                displayPrefix();
+                break;
+            case VPNNODETREE:
+                displayVpnNodes();
+                break;
+            case VPNLINKTREE:
+                displayVpnLinks();
+                break;
+            case VPNPREFIXTREE:
+                displayVpnPrefix();
+                break;
+            default:
+                System.out.print("Unknown Command");
+                break;
+        }
+
+    }
+
+    private void displayNodes() {
+        try {
+            int counter = 0;
+            print("Total number of entries = %s", nodeTreeMap.size());
+            for (BgpNodeLSIdentifier nodes : nodekeySet) {
+                if (numberofentries > nodeTreeMap.size() || numberofentries < 0) {
+                    System.out.print("Wrong Argument");
+                    break;
+                } else if (counter < numberofentries) {
+                    pathAttrNlriDetailsLocalRib = nodeTreeMap.get(nodes);
+                    displayNode();
+                    counter++;
+                } else if (counter == 0) {
+                    pathAttrNlriDetailsLocalRib = nodeTreeMap.get(nodes);
+                    displayNode();
+
+
+                }
+
+            }
+        } catch (Exception e) {
+            log.debug("Error occurred while displaying BGP nodes: {}", e.getMessage());
+        }
+
+    }
+
+
+    private void displayLinks() {
+        try {
+            int counter = 0;
+            print("Total Number of entries = %d", linkTreeMap.size());
+            for (BgpLinkLSIdentifier links : linkkeySet) {
+                if (numberofentries > linkTreeMap.size() || numberofentries < 0) {
+                    System.out.print("Wrong Argument");
+                    break;
+                } else if (counter < numberofentries) {
+                    pathAttrNlriDetailsLocalRib = linkTreeMap.get(links);
+                    print("Total number of entries = %d", linkTreeMap.size());
+                    displayLink();
+                    counter++;
+                } else if (counter == 0) {
+                    pathAttrNlriDetailsLocalRib = linkTreeMap.get(links);
+                    displayLink();
+                }
+
+            }
+        } catch (Exception e) {
+            log.debug("Error occurred while displaying BGP links: {}", e.getMessage());
+        }
+    }
+
+    private void displayPrefix() {
+        try {
+            this.bgpController = get(BgpController.class);
+            bgpLocalRib = bgpController.bgpLocalRib();
+            Map<BgpPrefixLSIdentifier, PathAttrNlriDetailsLocalRib> prefixmap = bgpLocalRib.prefixTree();
+            Set<BgpPrefixLSIdentifier> prefixkeySet = prefixmap.keySet();
+            for (BgpPrefixLSIdentifier prefix : prefixkeySet) {
+                pathAttrNlriDetailsLocalRib = prefixmap.get(prefix);
+                pathAttrNlriDetails = pathAttrNlriDetailsLocalRib.localRibNlridetails();
+                print("No of entries = %d", prefixmap.size());
+                System.out.print(pathAttrNlriDetailsLocalRib.toString());
+
+            }
+
+
+        } catch (Exception e) {
+            log.debug("Error occurred while displaying BGP prefixes: {}", e.getMessage());
+
+        }
+    }
+
+    private void displayVpnNodes() {
+        try {
+            this.bgpController = get(BgpController.class);
+            bgpLocalRib = bgpController.bgpLocalRib();
+            Map<RouteDistinguisher, Map<BgpNodeLSIdentifier, PathAttrNlriDetailsLocalRib>> vpnNode =
+                    bgpLocalRib.vpnNodeTree();
+            Set<RouteDistinguisher> vpnNodekeySet = vpnNode.keySet();
+            for (RouteDistinguisher vpnNodes : vpnNodekeySet) {
+                boolean invalidProcess = true;
+                if (vpnId != null && vpnId.trim().equals(vpnNodes.hashCode())) {
+                    invalidProcess = false;
+                    displayNodes();
+                }
+                if (invalidProcess) {
+                    print("%s\n", "Id " + vpnId + "does not exist...!!!");
+                }
+            }
+        } catch (Exception e) {
+            log.debug("Error occurred while displaying BGP nodes based on VPN : {}", e.getMessage());
+        }
+
+    }
+
+    private void displayVpnLinks() {
+        try {
+            this.bgpController = get(BgpController.class);
+            bgpLocalRib = bgpController.bgpLocalRib();
+            Map<RouteDistinguisher, Map<BgpLinkLSIdentifier, PathAttrNlriDetailsLocalRib>> vpnLink =
+                    bgpLocalRib.vpnLinkTree();
+            Set<RouteDistinguisher> vpnLinkkeySet = vpnLink.keySet();
+            for (RouteDistinguisher vpnLinks : vpnLinkkeySet) {
+                boolean invalidProcess = true;
+                if (vpnId != null && vpnId.trim().equals(vpnLinks.hashCode())) {
+                    invalidProcess = false;
+                    displayLinks();
+                }
+                if (invalidProcess) {
+                    print("%s\n", "Id " + vpnId + "does not exist...!!!");
+                }
+            }
+        } catch (Exception e) {
+            log.debug("Error occurred while displaying BGP links based on VPN : {}", e.getMessage());
+        }
+    }
+
+    private void displayVpnPrefix() {
+        try {
+            this.bgpController = get(BgpController.class);
+            bgpLocalRib = bgpController.bgpLocalRib();
+            Map<RouteDistinguisher, Map<BgpPrefixLSIdentifier, PathAttrNlriDetailsLocalRib>> vpnPrefix =
+                    bgpLocalRib.vpnPrefixTree();
+            Set<RouteDistinguisher> vpnPrefixkeySet = vpnPrefix.keySet();
+            for (RouteDistinguisher vpnprefixId : vpnPrefixkeySet) {
+                boolean invalidProcess = true;
+                if (vpnId != null && vpnId.trim().equals(vpnprefixId.hashCode())) {
+                    invalidProcess = false;
+                    displayPrefix();
+                }
+                if (invalidProcess) {
+                    print("%s\n", "Id " + vpnId + "does not exist...!!!");
+                }
+            }
+        } catch (Exception e) {
+            log.debug("Error occurred while displaying BGP prefixes based on VPN : {}", e.getMessage());
+        }
+    }
+
+    private void displayNode() {
+
+
+        pathAttrNlriDetails = pathAttrNlriDetailsLocalRib.localRibNlridetails();
+        List<BgpValueType> bgpValueTypeList = pathAttrNlriDetails.pathAttributes();
+        protocolType = pathAttrNlriDetails.protocolID();
+        Iterator<BgpValueType> itrBgpValueType = bgpValueTypeList.iterator();
+        while (itrBgpValueType.hasNext()) {
+            BgpValueType bgpValueType = itrBgpValueType.next();
+            if (bgpValueType instanceof Origin) {
+                origin = (Origin) bgpValueType;
+            } else if (bgpValueType instanceof LocalPref) {
+                localPref = (LocalPref) bgpValueType;
+            } else if (bgpValueType instanceof LinkStateAttributes) {
+                LinkStateAttributes linkStateAttributes = (LinkStateAttributes) bgpValueType;
+                List linkStateAttribiuteList = linkStateAttributes.linkStateAttributes();
+                Iterator<BgpValueType> linkStateAttribiteIterator = linkStateAttribiuteList.iterator();
+                while (linkStateAttribiteIterator.hasNext()) {
+                    BgpValueType bgpValueType1 = linkStateAttribiteIterator.next();
+                    if (bgpValueType1 instanceof BgpAttrRouterIdV4) {
+                        bgpAttrRouterIdV4 = (BgpAttrRouterIdV4) bgpValueType1;
+                    }
+                }
+            } else if (bgpValueType instanceof MpReachNlri) {
+                mpReachNlri = (MpReachNlri) bgpValueType;
+                List<BgpLSNlri> bgpLSNlris = mpReachNlri.mpReachNlri();
+                Iterator<BgpLSNlri> bgpLsnlrisIterator = bgpLSNlris.iterator();
+                while (bgpLsnlrisIterator.hasNext()) {
+                    BgpLSNlri bgpLSNlri = bgpLsnlrisIterator.next();
+                    if (bgpLSNlri instanceof BgpNodeLSNlriVer4) {
+                        BgpNodeLSNlriVer4 bgpNodeLSNlriVer4 = (BgpNodeLSNlriVer4) bgpLSNlri;
+                        BgpNodeLSIdentifier bgpNodeLSIdentifier = bgpNodeLSNlriVer4.getLocalNodeDescriptors();
+                        NodeDescriptors nodeDescriptors = bgpNodeLSIdentifier.getNodedescriptors();
+                        List<BgpValueType> bgpvalueTypesList = nodeDescriptors.getSubTlvs();
+                        Iterator<BgpValueType> bgpValueTypeIterator = bgpvalueTypesList.iterator();
+                        while (bgpValueTypeIterator.hasNext()) {
+                            BgpValueType valueType = bgpValueTypeIterator.next();
+                            if (valueType instanceof IsIsNonPseudonode) {
+                                isIsNonPseudonode = (IsIsNonPseudonode) valueType;
+
+                            }
+                        }
+                    }
+                }
+            }
+        }
+        print("RibAsNumber = %s,PeerIdentifier = %s,RibIpAddress = %s,ProtocolType = %s,Origin = %s,LocalPref = %s," +
+                        "RouterID = %s,IsoNodeID = %s,NextHop = %s", pathAttrNlriDetailsLocalRib.localRibAsNum(),
+                pathAttrNlriDetailsLocalRib.localRibIdentifier(), pathAttrNlriDetailsLocalRib.localRibIpAddress(),
+                protocolType.toString(), origin.origin(), localPref.localPref(), bgpAttrRouterIdV4.attrRouterId(),
+                Arrays.toString(isIsNonPseudonode.getIsoNodeId()), mpReachNlri.nexthop4());
+    }
+
+    private void displayLink() {
+
+        pathAttrNlriDetails = pathAttrNlriDetailsLocalRib.localRibNlridetails();
+        List<BgpValueType> valueTypes = pathAttrNlriDetails.pathAttributes();
+        Iterator<BgpValueType> itrBgpValueType = valueTypes.iterator();
+        while (itrBgpValueType.hasNext()) {
+            BgpValueType bgpValueType = itrBgpValueType.next();
+            if (bgpValueType instanceof Origin) {
+                origin = (Origin) bgpValueType;
+            } else if (bgpValueType instanceof LocalPref) {
+                localPref = (LocalPref) bgpValueType;
+            } else if (bgpValueType instanceof LinkStateAttributes) {
+                LinkStateAttributes linkStateAttributes = (LinkStateAttributes) bgpValueType;
+                List linkStateAttributelist = linkStateAttributes.linkStateAttributes();
+                Iterator<BgpValueType> linkStateAttributeIterator = linkStateAttributelist.iterator();
+                while (linkStateAttributeIterator.hasNext()) {
+                    BgpValueType bgpValueType1 = linkStateAttributeIterator.next();
+                    if (bgpValueType1 instanceof BgpAttrRouterIdV4) {
+                        bgpAttrRouterIdV4 = (BgpAttrRouterIdV4) bgpValueType1;
+                    } else if (bgpValueType1 instanceof BgpLinkAttrMaxLinkBandwidth) {
+                        bgpLinkAttrMaxLinkBandwidth = (BgpLinkAttrMaxLinkBandwidth) bgpValueType1;
+                    } else if (bgpValueType1 instanceof BgpLinkAttrUnRsrvdLinkBandwidth) {
+                        bgpLinkAttrUnRsrvdLinkBandwidth = (BgpLinkAttrUnRsrvdLinkBandwidth) bgpValueType1;
+                    } else if (bgpValueType1 instanceof BgpLinkAttrTeDefaultMetric) {
+                        bgpLinkAttrTeDefaultMetric = (BgpLinkAttrTeDefaultMetric) bgpValueType1;
+                    } else if (bgpValueType1 instanceof BgpLinkAttrIgpMetric) {
+                        bgpLinkAttrIgpMetric = (BgpLinkAttrIgpMetric) bgpValueType1;
+                    }
+
+                }
+            } else if (bgpValueType instanceof MpReachNlri) {
+                mpReachNlri = (MpReachNlri) bgpValueType;
+                List<BgpLSNlri> bgpLSNlris = mpReachNlri.mpReachNlri();
+                Iterator<BgpLSNlri> bgpLsnlrisIterator = bgpLSNlris.iterator();
+                while (bgpLsnlrisIterator.hasNext()) {
+                    BgpLSNlri bgpLSNlri = bgpLsnlrisIterator.next();
+                    if (bgpLSNlri instanceof BgpLinkLsNlriVer4) {
+                        BgpLinkLsNlriVer4 bgpLinkLsNlriVer4 = (BgpLinkLsNlriVer4) bgpLSNlri;
+                        BgpLinkLSIdentifier bgpLinkLSIdentifier = bgpLinkLsNlriVer4.getLinkIdentifier();
+                        NodeDescriptors localnodeDescriptors = bgpLinkLSIdentifier.localNodeDescriptors();
+                        NodeDescriptors remotenodeDescriptors = bgpLinkLSIdentifier.remoteNodeDescriptors();
+                        List<BgpValueType> linkDescriptors = bgpLinkLSIdentifier.linkDescriptors();
+                        List<BgpValueType> subTlvList = localnodeDescriptors.getSubTlvs();
+                        Iterator<BgpValueType> subTlvIterator = subTlvList.iterator();
+                        while (subTlvIterator.hasNext()) {
+                            BgpValueType valueType = subTlvIterator.next();
+                            if (valueType instanceof IsIsNonPseudonode) {
+                                isIsNonPseudonode = (IsIsNonPseudonode) valueType;
+                            } else if (valueType instanceof AutonomousSystemTlv) {
+                                autonomousSystemTlv = (AutonomousSystemTlv) valueType;
+                            }
+                        }
+                        List<BgpValueType> remotevalueTypes = remotenodeDescriptors.getSubTlvs();
+                        Iterator<BgpValueType> remoteValueTypesIterator = remotevalueTypes.iterator();
+                        while (remoteValueTypesIterator.hasNext()) {
+                            BgpValueType valueType = remoteValueTypesIterator.next();
+                            if (valueType instanceof IsIsNonPseudonode) {
+                                isIsNonPseudonode = (IsIsNonPseudonode) valueType;
+                            } else if (valueType instanceof AutonomousSystemTlv) {
+                                autonomousSystemTlv = (AutonomousSystemTlv) valueType;
+                            }
+                        }
+                        Iterator<BgpValueType> listIterator = linkDescriptors.iterator();
+                        while (listIterator.hasNext()) {
+                            BgpValueType valueType = listIterator.next();
+                            if (valueType instanceof IPv4AddressTlv) {
+                                iPv4AddressTlv = (IPv4AddressTlv) valueType;
+                            }
+
+                        }
+                    }
+                }
+            }
+        }
+        print("PeerIdentifier = %s,Origin = %s,LocalPref = %s,RouterID = %s,MaxBandwidth = %s," +
+                        "UnreservedBandwidth = %s,DefaultMetric = %s,IGPMetric = %s,IsoNodeID = %s,ASNum = %s," +
+                        "IPAddress = %s,NextHop = %s", pathAttrNlriDetailsLocalRib.localRibIdentifier(),
+                origin.origin(), localPref.localPref(), bgpAttrRouterIdV4.attrRouterId(),
+                bgpLinkAttrMaxLinkBandwidth.linkAttrMaxLinkBandwidth(),
+                bgpLinkAttrUnRsrvdLinkBandwidth.getLinkAttrUnRsrvdLinkBandwidth().toString(),
+                bgpLinkAttrTeDefaultMetric.attrLinkDefTeMetric(), bgpLinkAttrIgpMetric.attrLinkIgpMetric(),
+                Arrays.toString(isIsNonPseudonode.getIsoNodeId()), autonomousSystemTlv.getAsNum(),
+                iPv4AddressTlv.address(), mpReachNlri.nexthop4().toString(),
+                pathAttrNlriDetailsLocalRib.localRibIpAddress(), origin.origin(), localPref.localPref(),
+                bgpAttrRouterIdV4.attrRouterId());
+
+    }
+}
\ No newline at end of file
diff --git a/providers/bgp/cli/src/main/java/org/onosproject/bgp/cli/package-info.java b/providers/bgp/cli/src/main/java/org/onosproject/bgp/cli/package-info.java
new file mode 100644
index 0000000..10d3b8c
--- /dev/null
+++ b/providers/bgp/cli/src/main/java/org/onosproject/bgp/cli/package-info.java
@@ -0,0 +1,4 @@
+/**
+ * Created by root1 on 23/8/16.
+ */
+package org.onosproject.bgp.cli;
\ No newline at end of file
diff --git a/providers/bgp/cli/src/main/resources/OSGI-INF/blueprint/shell-config.xml b/providers/bgp/cli/src/main/resources/OSGI-INF/blueprint/shell-config.xml
new file mode 100644
index 0000000..6695a01
--- /dev/null
+++ b/providers/bgp/cli/src/main/resources/OSGI-INF/blueprint/shell-config.xml
@@ -0,0 +1,15 @@
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
+
+    <command-bundle xmlns="http://karaf.apache.org/xmlns/shell/v1.1.0">
+        <command>
+            <action class="org.onosproject.bgp.cli.BgpConfiguration"/>
+        </command>
+        <command>
+            <action class="org.onosproject.bgp.cli.BgpLocalRibDisplay"/>
+        </command>
+        <command>
+            <action class="org.onosproject.bgp.cli.BgpExceptions"/>
+        </command>
+    </command-bundle>
+
+</blueprint>
diff --git a/providers/bgp/pom.xml b/providers/bgp/pom.xml
index be59ed7..9f04125 100644
--- a/providers/bgp/pom.xml
+++ b/providers/bgp/pom.xml
@@ -27,6 +27,7 @@
         <module>topology</module>
         <module>cfg</module>
         <module>app</module>
+        <module>cli</module>
   </modules>
     <dependencies>
 
diff --git a/providers/bgp/topology/src/test/java/org/onosproject/provider/bgp/topology/impl/BgpControllerAdapter.java b/providers/bgp/topology/src/test/java/org/onosproject/provider/bgp/topology/impl/BgpControllerAdapter.java
index e8cd0fe..2619661 100644
--- a/providers/bgp/topology/src/test/java/org/onosproject/provider/bgp/topology/impl/BgpControllerAdapter.java
+++ b/providers/bgp/topology/src/test/java/org/onosproject/provider/bgp/topology/impl/BgpControllerAdapter.java
@@ -26,6 +26,7 @@
 import org.onosproject.bgpio.exceptions.BgpParseException;
 import org.onosproject.bgpio.protocol.BgpMessage;
 
+import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
@@ -109,6 +110,26 @@
     }
 
     @Override
+    public void activeSessionExceptionAdd(String peerId, String exception) {
+        return;
+    }
+
+    @Override
+    public void closedSessionExceptionAdd(String peerId, String exception) {
+        return;
+    }
+
+    @Override
+    public Map<String, List<String>> activeSessionMap() {
+        return null;
+    }
+
+    @Override
+    public Map<String, List<String>> closedSessionMap() {
+        return null;
+    }
+
+    @Override
     public void addListener(BgpNodeListener listener) {
         // TODO Auto-generated method stub
     }
diff --git a/providers/pcep/BUCK b/providers/pcep/BUCK
index c5b609d..ce77c96 100644
--- a/providers/pcep/BUCK
+++ b/providers/pcep/BUCK
@@ -1,6 +1,7 @@
 BUNDLES = [
     '//providers/pcep/topology:onos-providers-pcep-topology',
     '//providers/pcep/tunnel:onos-providers-pcep-tunnel',
+    '//providers/pcep/cli:onos-providers-pcep-cli',
     '//protocols/pcep/api:onos-protocols-pcep-api',
     '//protocols/pcep/pcepio:onos-protocols-pcep-pcepio',
     '//protocols/pcep/ctl:onos-protocols-pcep-ctl',
diff --git a/providers/pcep/app/app.xml b/providers/pcep/app/app.xml
index 1bdef05..1acc35d 100644
--- a/providers/pcep/app/app.xml
+++ b/providers/pcep/app/app.xml
@@ -25,4 +25,5 @@
     <artifact>mvn:${project.groupId}/onos-pcep-controller-impl/${project.version}</artifact>
     <artifact>mvn:${project.groupId}/onos-pcep-provider-topology/${project.version}</artifact>
     <artifact>mvn:${project.groupId}/onos-pcep-provider-tunnel/${project.version}</artifact>
+    <artifact>mvn:${project.groupId}/onos-pcep-provider-cli/${project.version}</artifact>
 </app>
diff --git a/providers/pcep/app/features.xml b/providers/pcep/app/features.xml
index 002f7f6..7f846be 100644
--- a/providers/pcep/app/features.xml
+++ b/providers/pcep/app/features.xml
@@ -24,5 +24,6 @@
         <bundle>mvn:${project.groupId}/onos-pcep-controller-impl/${project.version}</bundle>
         <bundle>mvn:${project.groupId}/onos-pcep-provider-topology/${project.version}</bundle>
         <bundle>mvn:${project.groupId}/onos-pcep-provider-tunnel/${project.version}</bundle>
+        <bundle>mvn:${project.groupId}/onos-pcep-provider-cli/${project.version}</bundle>
     </feature>
 </features>
diff --git a/providers/pcep/app/pom.xml b/providers/pcep/app/pom.xml
index f3b2d08..4d2439f 100644
--- a/providers/pcep/app/pom.xml
+++ b/providers/pcep/app/pom.xml
@@ -53,6 +53,11 @@
         </dependency>
         <dependency>
             <groupId>org.onosproject</groupId>
+            <artifactId>onos-pcep-provider-cli</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.onosproject</groupId>
             <artifactId>onos-pcep-provider-tunnel</artifactId>
             <version>${project.version}</version>
         </dependency>
diff --git a/providers/pcep/cli/BUCK b/providers/pcep/cli/BUCK
new file mode 100644
index 0000000..93199e4
--- /dev/null
+++ b/providers/pcep/cli/BUCK
@@ -0,0 +1,12 @@
+COMPILE_DEPS = [
+  '//lib:CORE_DEPS',
+  '//incubator/api:onos-incubator-api',
+  '//protocols/pcep/ctl:onos-protocols-pcep-ctl',
+  '//protocols/pcep/api:onos-protocols-pcep-api',
+  '//lib:org.apache.karaf.shell.console',
+  '//cli:onos-cli',
+]
+
+osgi_jar_with_tests (
+  deps = COMPILE_DEPS,
+)
diff --git a/providers/pcep/cli/pom.xml b/providers/pcep/cli/pom.xml
new file mode 100644
index 0000000..b9b04bc
--- /dev/null
+++ b/providers/pcep/cli/pom.xml
@@ -0,0 +1,58 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ Copyright 2016-present Open Networking Laboratory
+  ~
+  ~ Licensed under the Apache License, Version 2.0 (the "License");
+  ~ you may not use this file except in compliance with the License.
+  ~ You may obtain a copy of the License at
+  ~
+  ~     http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  -->
+<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xmlns="http://maven.apache.org/POM/4.0.0"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.onosproject</groupId>
+        <artifactId>onos-pcep-providers</artifactId>
+        <version>1.9.0-SNAPSHOT</version>
+    </parent>
+
+    <artifactId>onos-pcep-provider-cli</artifactId>
+    <packaging>bundle</packaging>
+
+    <description>PCEP cli implementation</description>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.onosproject</groupId>
+            <artifactId>onos-cli</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>org.osgi.compendium</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.karaf.shell</groupId>
+            <artifactId>org.apache.karaf.shell.console</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.felix</groupId>
+            <artifactId>org.apache.felix.scr.annotations</artifactId>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.onosproject</groupId>
+            <artifactId>onos-pcep-controller-impl</artifactId>
+            <version>1.9.0-SNAPSHOT</version>
+        </dependency>
+    </dependencies>
+</project>
\ No newline at end of file
diff --git a/providers/pcep/cli/src/main/java/org/onosproject/pcep/cli/PcepSessionCommand.java b/providers/pcep/cli/src/main/java/org/onosproject/pcep/cli/PcepSessionCommand.java
new file mode 100644
index 0000000..420dd0c
--- /dev/null
+++ b/providers/pcep/cli/src/main/java/org/onosproject/pcep/cli/PcepSessionCommand.java
@@ -0,0 +1,264 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.pcep.cli;
+
+
+import org.apache.karaf.shell.commands.Argument;
+import org.apache.karaf.shell.commands.Command;
+import org.onosproject.cli.AbstractShellCommand;
+import org.onosproject.pcep.controller.PcepClientController;
+import org.onosproject.pcep.controller.PcepErrorDetail;
+import org.onosproject.pcep.controller.PcepErrorType;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.Set;
+import java.util.Map;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.TreeMap;
+
+
+@Command(scope = "onos", name = "pcep", description = "Pcep Session Info")
+public class PcepSessionCommand extends AbstractShellCommand {
+    private static final Logger log = LoggerFactory.getLogger(PcepSessionCommand.class);
+    private static final String SESSION = "session";
+    private static final String EXCEPTION = "exception";
+    private static final String ERROR = "error";
+    private PcepClientController pcepClientController;
+    private byte sessionId;
+    private Set<String> pcepSessionKeySet;
+    private Set<String> pcepSessionIdKeySet;
+    private Integer sessionIdValue = 0;
+    private String sessionStatus;
+    private List pcepSessionExceptions = new ArrayList();
+    private Set<String> pcepSessionFailurekeySet;
+    private PcepErrorDetail pcepErrorDetail;
+    private PcepErrorType pcepErrorType;
+    private Map<Integer, String> sessionEstablishmentFailureMap = new TreeMap<>();
+    private Map<Integer, String> unknownObjectMap = new TreeMap<>();
+    private Map<Integer, String> notSupportedObjectMap = new TreeMap<>();
+    private Map<Integer, String> policyViolationMap = new TreeMap<>();
+    private Map<Integer, String> mandatoryObjectMissingMap = new TreeMap<>();
+    private Map<Integer, String> receptionOfInvalidObjectMap = new TreeMap<>();
+    private Map<Integer, String> invalidOperationMap = new TreeMap<>();
+    private Set<Integer> pcepErrorMsgKey;
+    private Integer pcepErrorValue = 0;
+
+    @Argument(index = 0, name = "name",
+            description = "session" + "\n" + "exception" + "\n" + "error",
+            required = true, multiValued = false)
+    String name = null;
+    @Argument(index = 1, name = "peer",
+            description = "peerIp",
+            required = false, multiValued = false)
+    String peer = null;
+
+    @Override
+    protected void execute() {
+        switch (name) {
+            case SESSION:
+                displayPcepSession();
+                break;
+            case EXCEPTION:
+                displayPcepSessionFailureReason();
+                break;
+            case ERROR:
+                displayPcepErrorMsgs();
+                break;
+            default:
+                System.out.print("Unknown Command");
+                break;
+        }
+    }
+
+    private void displayPcepSession() {
+        try {
+            this.pcepClientController = get(PcepClientController.class);
+            Map<String, String> pcepSessionMap = pcepClientController.getPcepSessionMap();
+            Map<String, Byte> pcepSessionIdMap = pcepClientController.getPcepSessionIdMap();
+            pcepSessionKeySet = pcepSessionMap.keySet();
+            pcepSessionIdKeySet = pcepSessionIdMap.keySet();
+            if (peer != null) {
+                if (pcepSessionKeySet.size() > 0) {
+                    if (pcepSessionKeySet.contains(peer)) {
+                        for (String pcepSessionPeer : pcepSessionKeySet) {
+                            if (pcepSessionPeer.equals(peer)) {
+                                for (String pcepSessionId : pcepSessionIdKeySet) {
+                                    if (pcepSessionId.equals(peer)) {
+                                        sessionId = pcepSessionIdMap.get(pcepSessionId);
+                                        sessionStatus = pcepSessionMap.get(pcepSessionPeer);
+                                        if (sessionId < 0) {
+                                            sessionIdValue = sessionId + 256;
+                                        } else {
+                                            sessionIdValue = (int) sessionId;
+                                        }
+                                    }
+                                }
+                  print("SessionIp = %s, Status = %s, sessionId = %s", pcepSessionPeer, sessionStatus, sessionIdValue);
+                            }
+                        }
+                    } else {
+                        System.out.print("Wrong Peer IP");
+                    }
+                }
+            } else {
+                if (pcepSessionKeySet.size() > 0) {
+                    for (String pcepSessionPeer : pcepSessionKeySet) {
+                        for (String pcepSessionId : pcepSessionIdKeySet) {
+                            if (pcepSessionId.equals(pcepSessionPeer)) {
+                                sessionId = pcepSessionIdMap.get(pcepSessionId);
+                                sessionStatus = pcepSessionMap.get(pcepSessionPeer);
+                                if (sessionId < 0) {
+                                    sessionIdValue = sessionId + 256;
+                                } else {
+                                    sessionIdValue = (int) sessionId;
+                                }
+                            }
+                        }
+                print("SessionIp = %s, Status = %s, sessionId = %s", pcepSessionPeer, sessionStatus, sessionIdValue);
+                    }
+                }
+            }
+        } catch (Exception e) {
+            log.debug("Error occurred while displaying PCEP session information: {}", e.getMessage());
+        }
+    }
+
+    private void displayPcepSessionFailureReason() {
+        try {
+            this.pcepClientController = get(PcepClientController.class);
+            Map<String, List<String>> pcepSessionFailureReasonMap = pcepClientController.getPcepExceptions();
+            pcepSessionFailurekeySet = pcepSessionFailureReasonMap.keySet();
+            if (pcepSessionFailurekeySet.size() > 0) {
+                if (peer != null) {
+                    if (pcepSessionFailurekeySet.contains(peer)) {
+                        for (String pcepSessionPeerId : pcepSessionFailurekeySet) {
+                            if (pcepSessionPeerId.equals(peer)) {
+                                pcepSessionExceptions = pcepSessionFailureReasonMap.get(pcepSessionPeerId);
+                                print("PeerId = %s, FailureReason = %s", pcepSessionPeerId, pcepSessionExceptions);
+                            }
+                        }
+                    } else {
+                        System.out.print("Wrong Peer IP");
+                    }
+
+                } else {
+                    pcepSessionFailurekeySet = pcepSessionFailureReasonMap.keySet();
+                    if (pcepSessionFailurekeySet.size() > 0) {
+                        for (String pcepSessionPeerId : pcepSessionFailurekeySet) {
+                            pcepSessionExceptions = pcepSessionFailureReasonMap.get(pcepSessionPeerId);
+                            print("PeerId = %s, FailureReason = %s", pcepSessionPeerId, pcepSessionExceptions);
+                        }
+                    }
+                }
+
+            }
+
+
+        } catch (Exception e) {
+            log.debug("Error occurred while displaying PCEP session failure reasons: {}", e.getMessage());
+        }
+
+    }
+
+
+    private void displayPcepErrorMsgs() {
+        try {
+            this.pcepClientController = get(PcepClientController.class);
+            Map<Integer, Integer> pcepErrorMsgMap = pcepClientController.getPcepErrorMsg();
+            pcepErrorMsgKey = pcepErrorMsgMap.keySet();
+            if (pcepErrorMsgKey.size() > 0) {
+                for (Integer errorType : pcepErrorMsgKey) {
+                    pcepErrorValue = pcepErrorMsgMap.get(errorType);
+                    pcepErrorType = PcepErrorType.values()[errorType];
+                    switch (pcepErrorType) {
+                        case SESSIONESTABLISHMENTFAILURE:
+                            sessionEstablishmentFailureMap =  pcepErrorDetail.sessionEstablishmentFailure();
+                            Set<Integer> sessionFailureKeySet = sessionEstablishmentFailureMap.keySet();
+                            for (Integer sessionFailureKey : sessionFailureKeySet) {
+                                if (sessionFailureKey == pcepErrorValue) {
+                                    System.out.print(sessionEstablishmentFailureMap.get(sessionFailureKey));
+                                }
+                            }
+                        case CAPABALITYNOTSUPPORTED:
+                            System.out.print("Capability not supported");
+                        case UNKNOWNOBJECT:
+                            unknownObjectMap =  pcepErrorDetail.unknownObject();
+                            Set<Integer> unknownObjectKeySet = unknownObjectMap.keySet();
+                            for (Integer unknownObjectKey : unknownObjectKeySet) {
+                                if (unknownObjectKey == pcepErrorValue) {
+                                    System.out.print(unknownObjectMap.get(unknownObjectKey));
+                                }
+                            }
+                        case NOTSUPPORTEDOBJECT:
+                            notSupportedObjectMap =  pcepErrorDetail.notSupportedObject();
+                            Set<Integer> notSupportedObjectKeySet = notSupportedObjectMap.keySet();
+                            for (Integer notSupportedObjectKey : notSupportedObjectKeySet) {
+                                if (notSupportedObjectKey == pcepErrorValue) {
+                                    System.out.print(notSupportedObjectMap.get(notSupportedObjectKey));
+                                }
+                            }
+                        case POLICYVIOLATION:
+                            policyViolationMap =  pcepErrorDetail.policyViolation();
+                            Set<Integer> policyViolationKeySet = policyViolationMap.keySet();
+                            for (Integer policyViolationKey : policyViolationKeySet) {
+                                if (policyViolationKey == pcepErrorValue) {
+                                    System.out.print(policyViolationMap.get(policyViolationKey));
+                                }
+                            }
+                        case MANDATORYOBJECTMISSING:
+                            mandatoryObjectMissingMap =  pcepErrorDetail.mandatoryObjectMissing();
+                            Set<Integer> mandatoryObjectMissingKeySet = mandatoryObjectMissingMap.keySet();
+                            for (Integer mandatoryObjectMissingKey : mandatoryObjectMissingKeySet) {
+                                if (mandatoryObjectMissingKey == pcepErrorValue) {
+                                    System.out.print(mandatoryObjectMissingMap.get(mandatoryObjectMissingKey));
+                                }
+                            }
+                        case SYNCHRONIZEDPATHCOMPUTATIONREQUESTMISSING:
+                            System.out.print("Synchronized path computation request missing");
+                        case UNKNOWNREQUESTREFERENCE:
+                            System.out.print("Unknown request reference");
+                        case ESTABLISHINGSECONDPCEPSESSION:
+                            System.out.print("Attempt to establish a second PCEP session");
+                        case RECEPTIONOFINVALIDOBJECT:
+                            receptionOfInvalidObjectMap =  pcepErrorDetail.receptionOfInvalidObject();
+                            Set<Integer> receptionOfInvalidObjectKeySet = receptionOfInvalidObjectMap.keySet();
+                            for (Integer receptionOfInvalidObjectKey : receptionOfInvalidObjectKeySet) {
+                                if (receptionOfInvalidObjectKey == pcepErrorValue) {
+                                    System.out.print(receptionOfInvalidObjectMap.get(receptionOfInvalidObjectKey));
+                                }
+                            }
+                        case INVALIDOPERATION:
+                            invalidOperationMap =  pcepErrorDetail.invalidOperation();
+                            Set<Integer> invalidOperationKeySet = invalidOperationMap.keySet();
+                            for (Integer invalidOperationKey : invalidOperationKeySet) {
+                                if (invalidOperationKey == pcepErrorValue) {
+                                    System.out.print(invalidOperationMap.get(invalidOperationKey));
+                                }
+                            }
+                        case VIRTUALNETWORKTLVMISSING:
+                            System.out.print("VIRTUAL-NETWORK TLV missing");
+                        default:
+                            System.out.print("Unknown error message");
+                    }
+                }
+            }
+        }  catch (Exception e) {
+            log.debug("Error occurred while displaying PCEP error messages received: {}", e.getMessage());
+        }
+    }
+}
diff --git a/providers/pcep/cli/src/main/java/org/onosproject/pcep/cli/package-info.java b/providers/pcep/cli/src/main/java/org/onosproject/pcep/cli/package-info.java
new file mode 100644
index 0000000..2dd3a6d
--- /dev/null
+++ b/providers/pcep/cli/src/main/java/org/onosproject/pcep/cli/package-info.java
@@ -0,0 +1,4 @@
+/**
+ * Created by root1 on 23/8/16.
+ */
+package org.onosproject.pcep.cli;
\ No newline at end of file
diff --git a/providers/pcep/cli/src/main/resources/OSGI-INF/blueprint/shell-config.xml b/providers/pcep/cli/src/main/resources/OSGI-INF/blueprint/shell-config.xml
new file mode 100644
index 0000000..aef97fd
--- /dev/null
+++ b/providers/pcep/cli/src/main/resources/OSGI-INF/blueprint/shell-config.xml
@@ -0,0 +1,10 @@
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
+
+    <command-bundle xmlns="http://karaf.apache.org/xmlns/shell/v1.1.0">
+
+        <command>
+            <action class="org.onosproject.pcep.cli.PcepSessionCommand"/>
+        </command>
+    </command-bundle>
+
+</blueprint>
diff --git a/providers/pcep/pom.xml b/providers/pcep/pom.xml
index a48bce5..491d5bb 100644
--- a/providers/pcep/pom.xml
+++ b/providers/pcep/pom.xml
@@ -27,5 +27,6 @@
         <module>topology</module>
         <module>tunnel</module>
         <module>app</module>
+        <module>cli</module>
   </modules>
 </project>
\ No newline at end of file
diff --git a/providers/pcep/topology/src/test/java/org/onosproject/provider/pcep/topology/impl/PcepClientControllerAdapter.java b/providers/pcep/topology/src/test/java/org/onosproject/provider/pcep/topology/impl/PcepClientControllerAdapter.java
index 459ebc9..86487d9 100644
--- a/providers/pcep/topology/src/test/java/org/onosproject/provider/pcep/topology/impl/PcepClientControllerAdapter.java
+++ b/providers/pcep/topology/src/test/java/org/onosproject/provider/pcep/topology/impl/PcepClientControllerAdapter.java
@@ -15,12 +15,7 @@
  */
 package org.onosproject.provider.pcep.topology.impl;
 
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.LinkedList;
-import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
+
 
 import org.apache.felix.scr.annotations.Activate;
 import org.apache.felix.scr.annotations.Deactivate;
@@ -48,6 +43,15 @@
 
 import com.google.common.collect.Sets;
 
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.List;
+import java.util.Map;
+
 import static org.onosproject.pcepio.types.PcepErrorDetailInfo.ERROR_TYPE_19;
 import static org.onosproject.pcepio.types.PcepErrorDetailInfo.ERROR_VALUE_5;
 
@@ -306,6 +310,32 @@
     }
 
     @Override
+    public Map<String, List<String>> getPcepExceptions() {
+        return null;
+    }
+
+    @Override
+    public Map<Integer, Integer> getPcepErrorMsg() {
+        return null;
+    }
+
+    @Override
+    public Map<String, String> getPcepSessionMap() {
+        return null;
+    }
+
+    @Override
+    public Map<String, Byte> getPcepSessionIdMap() {
+        return null;
+    }
+
+    @Override
+    public void peerErrorMsg(String peerId, Integer errorType, Integer errValue) {
+        return;
+    }
+
+
+    @Override
     public boolean allocateLocalLabel(Tunnel tunnel) {
         // TODO Auto-generated method stub
         return false;
diff --git a/providers/pcep/tunnel/src/test/java/org/onosproject/provider/pcep/tunnel/impl/PcepClientControllerAdapter.java b/providers/pcep/tunnel/src/test/java/org/onosproject/provider/pcep/tunnel/impl/PcepClientControllerAdapter.java
index a541734..4bcba82 100644
--- a/providers/pcep/tunnel/src/test/java/org/onosproject/provider/pcep/tunnel/impl/PcepClientControllerAdapter.java
+++ b/providers/pcep/tunnel/src/test/java/org/onosproject/provider/pcep/tunnel/impl/PcepClientControllerAdapter.java
@@ -21,6 +21,8 @@
 import java.util.LinkedList;
 import java.util.Set;
 import java.util.concurrent.ConcurrentHashMap;
+import java.util.List;
+import java.util.Map;
 
 import org.apache.felix.scr.annotations.Activate;
 import org.apache.felix.scr.annotations.Deactivate;
@@ -299,6 +301,31 @@
     }
 
     @Override
+    public Map<String, List<String>> getPcepExceptions() {
+        return null;
+    }
+
+    @Override
+    public Map<Integer, Integer> getPcepErrorMsg() {
+        return null;
+    }
+
+    @Override
+    public Map<String, String> getPcepSessionMap() {
+        return null;
+    }
+
+    @Override
+    public Map<String, Byte> getPcepSessionIdMap() {
+        return null;
+    }
+
+    @Override
+    public void peerErrorMsg(String peerId, Integer errorType, Integer errValue) {
+        return;
+    }
+
+    @Override
     public boolean allocateLocalLabel(Tunnel tunnel) {
         // TODO Auto-generated method stub
         return false;