diff --git a/apps/pce/app/src/main/java/org/onosproject/pce/pceservice/PceManager.java b/apps/pce/app/src/main/java/org/onosproject/pce/pceservice/PceManager.java
index d4d4808..c0326b6 100644
--- a/apps/pce/app/src/main/java/org/onosproject/pce/pceservice/PceManager.java
+++ b/apps/pce/app/src/main/java/org/onosproject/pce/pceservice/PceManager.java
@@ -254,6 +254,7 @@
 
         tunnelConsumerIdGen = coreService.getIdGenerator(TUNNEL_CONSUMER_ID_GEN_TOPIC);
         localLspIdIdGen = coreService.getIdGenerator(LOCAL_LSP_ID_GEN_TOPIC);
+        localLspIdIdGen.getNewId(); // To prevent 0, the 1st value generated from being used in protocol.
         localLspIdFreeList = storageService.<Short>setBuilder()
                 .withName("pcepLocalLspIdDeletedList")
                 .withSerializer(Serializer.using(KryoNamespaces.API))
diff --git a/apps/pce/app/src/main/java/org/onosproject/pce/pceservice/PceccSrTeBeHandler.java b/apps/pce/app/src/main/java/org/onosproject/pce/pceservice/PceccSrTeBeHandler.java
index 63eed1b..0a79716 100644
--- a/apps/pce/app/src/main/java/org/onosproject/pce/pceservice/PceccSrTeBeHandler.java
+++ b/apps/pce/app/src/main/java/org/onosproject/pce/pceservice/PceccSrTeBeHandler.java
@@ -406,15 +406,6 @@
             DeviceId deviceId = null;
             for (Iterator<Link> iterator = linkList.iterator(); iterator.hasNext();) {
                 link = iterator.next();
-                // Add source device label now
-                deviceId = link.src().deviceId();
-                nodeLabelId = pceStore.getGlobalNodeLabel(deviceId);
-                if (nodeLabelId == null) {
-                    log.error("Unable to find node label for a device id {} in store.", deviceId.toString());
-                    return null;
-                }
-                labelStack.add(nodeLabelId);
-
                 // Add adjacency label for this link
                 adjLabelId = pceStore.getAdjLabel(link);
                 if (adjLabelId == null) {
@@ -422,11 +413,7 @@
                     return null;
                 }
                 labelStack.add(adjLabelId);
-            }
 
-            // This is the last link in path
-            // Add destination device label now.
-            if (link != null) {
                 deviceId = link.dst().deviceId();
                 nodeLabelId = pceStore.getGlobalNodeLabel(deviceId);
                 if (nodeLabelId == null) {
diff --git a/apps/pce/app/src/test/java/org/onosproject/pce/pceservice/PceccSrTeBeHandlerTest.java b/apps/pce/app/src/test/java/org/onosproject/pce/pceservice/PceccSrTeBeHandlerTest.java
index 70f7376..be5cd2e 100644
--- a/apps/pce/app/src/test/java/org/onosproject/pce/pceservice/PceccSrTeBeHandlerTest.java
+++ b/apps/pce/app/src/test/java/org/onosproject/pce/pceservice/PceccSrTeBeHandlerTest.java
@@ -417,11 +417,8 @@
         // Compute label stack
         LabelStack labelStack = srTeHandler.computeLabelStack(path1);
 
-        // check node-label of D1.deviceId()
         List<LabelResourceId> labelList = labelStack.labelResources();
         Iterator<LabelResourceId> iterator = labelList.iterator();
-        labelId = iterator.next();
-        assertThat(labelId, is(LabelResourceId.labelResourceId(4097)));
 
         // check adjacency label of D1.deviceId()
         labelId = iterator.next();
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 00a7a20..46768a7 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
@@ -438,6 +438,7 @@
                 // When there are no LSPs to sync, directly end-of-sync PCRpt will come and the
                 // list will be null.
                 syncStateRptList = Collections.EMPTY_LIST;
+                log.debug("No LSPs reported from PCC during sync.");
             }
 
             Iterator<PcepStateReport> stateRptListIterator = syncStateRptList.iterator();
@@ -502,8 +503,8 @@
                         } catch (PcepParseException e) {
                             log.error("Exception occured while sending initiate delete message {}", e.getMessage());
                         }
+                        continue;
                     }
-                    continue;
                 }
 
                 if (!lspObj.getCFlag()) {
diff --git a/protocols/pcep/ctl/src/main/java/org/onosproject/pcep/controller/impl/PcepClientImpl.java b/protocols/pcep/ctl/src/main/java/org/onosproject/pcep/controller/impl/PcepClientImpl.java
index 42d4b07..927b4c7 100644
--- a/protocols/pcep/ctl/src/main/java/org/onosproject/pcep/controller/impl/PcepClientImpl.java
+++ b/protocols/pcep/ctl/src/main/java/org/onosproject/pcep/controller/impl/PcepClientImpl.java
@@ -186,6 +186,7 @@
 
     @Override
     public void setLspDbSyncStatus(PcepSyncStatus syncStatus) {
+        log.debug("LSP DB sync status set from {} to {}", this.lspDbSyncStatus, syncStatus);
         this.lspDbSyncStatus = syncStatus;
     }
 
@@ -199,7 +200,7 @@
 
         PcepSyncStatus syncOldStatus = labelDbSyncStatus();
         this.labelDbSyncStatus = syncStatus;
-
+        log.debug("Label DB sync status set from {} to {}", syncOldStatus, syncStatus);
         if ((syncOldStatus == PcepSyncStatus.IN_SYNC) && (syncStatus == PcepSyncStatus.SYNCED)) {
             // Perform end of LSP DB sync actions.
             this.agent.analyzeSyncMsgList(pccId);
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepNaiIpv4Adjacency.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepNaiIpv4Adjacency.java
index 7716873..5d01912 100644
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepNaiIpv4Adjacency.java
+++ b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepNaiIpv4Adjacency.java
@@ -59,6 +59,14 @@
         return ST_TYPE;
     }
 
+    public int getLocalIpv4Addr() {
+        return localIpv4Addr;
+    }
+
+    public int getRemoteIpv4Addr() {
+        return remoteIpv4Addr;
+    }
+
     @Override
     public int write(ChannelBuffer bb) {
         int iLenStartIndex = bb.writerIndex();
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/SrEroSubObject.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/SrEroSubObject.java
index 57b719e..947ba28 100644
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/SrEroSubObject.java
+++ b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/SrEroSubObject.java
@@ -84,7 +84,7 @@
      */
     protected static final Logger log = LoggerFactory.getLogger(SrEroSubObject.class);
 
-    public static final short TYPE = 0x60; //TODO : type to be defined
+    public static final short TYPE = 0x24; //TODO : type to be defined
     public static final short LENGTH = 12;
     public static final short VALUE_LENGTH = 10;
     public static final int SET = 1;
@@ -243,9 +243,10 @@
     @Override
     public int write(ChannelBuffer c) {
         int iLenStartIndex = c.writerIndex();
-
-        c.writeShort(TYPE);
-        c.writeShort(LENGTH);
+        c.writeByte(TYPE);
+        // Store the position of object length
+        int objectLenIndex = c.writerIndex();
+        c.writeByte(0);
 
         short temp = 0;
         if (bMFlag) {
@@ -264,13 +265,14 @@
         temp = (short) (temp | tempST);
         c.writeShort(temp);
         if (bMFlag) {
-            int tempSid = (int) sid << 12;
+            int tempSid = sid << 12;
             c.writeInt(tempSid);
         } else {
             c.writeInt(sid);
         }
         nai.write(c);
 
+        c.setByte(objectLenIndex, (c.writerIndex() - iLenStartIndex));
         return c.writerIndex() - iLenStartIndex;
     }
 
diff --git a/providers/pcep/packet/src/main/java/org/onosproject/provider/pcep/packet/impl/PcepPacketProvider.java b/providers/pcep/packet/src/main/java/org/onosproject/provider/pcep/packet/impl/PcepPacketProvider.java
index 13a2f99..41cf375 100644
--- a/providers/pcep/packet/src/main/java/org/onosproject/provider/pcep/packet/impl/PcepPacketProvider.java
+++ b/providers/pcep/packet/src/main/java/org/onosproject/provider/pcep/packet/impl/PcepPacketProvider.java
@@ -10,6 +10,7 @@
 import org.apache.felix.scr.annotations.Service;
 import org.onlab.packet.Ethernet;
 import org.onlab.packet.IPv4;
+import org.onlab.packet.MacAddress;
 import org.onlab.packet.TCP;
 import org.onosproject.net.AnnotationKeys;
 import org.onosproject.net.ConnectPoint;
@@ -90,6 +91,7 @@
 
             Ethernet eth = new Ethernet();
             eth.setEtherType(Ethernet.TYPE_IPV4);
+            eth.setDestinationMACAddress(MacAddress.NONE);
             eth.setPayload(ipv4);
 
             // Get lsrId of the PCEP client from the PCC ID. Session info is based on lsrID.
diff --git a/providers/pcep/tunnel/src/main/java/org/onosproject/provider/pcep/tunnel/impl/PcepTunnelProvider.java b/providers/pcep/tunnel/src/main/java/org/onosproject/provider/pcep/tunnel/impl/PcepTunnelProvider.java
index 7af0040..d9eedb4 100644
--- a/providers/pcep/tunnel/src/main/java/org/onosproject/provider/pcep/tunnel/impl/PcepTunnelProvider.java
+++ b/providers/pcep/tunnel/src/main/java/org/onosproject/provider/pcep/tunnel/impl/PcepTunnelProvider.java
@@ -28,6 +28,8 @@
 import org.onlab.packet.IpAddress;
 import org.onosproject.cfg.ComponentConfigService;
 import org.onosproject.core.DefaultGroupId;
+import org.onosproject.incubator.net.resource.label.LabelResourceId;
+import org.onosproject.incubator.net.tunnel.DefaultLabelStack;
 import org.onosproject.incubator.net.tunnel.DefaultOpticalTunnelEndPoint;
 import org.onosproject.incubator.net.tunnel.DefaultTunnel;
 import org.onosproject.incubator.net.tunnel.DefaultTunnelDescription;
@@ -59,6 +61,7 @@
 import org.onosproject.net.ElementId;
 import org.onosproject.net.IpElementId;
 import org.onosproject.net.Link;
+import org.onosproject.net.NetworkResource;
 import org.onosproject.net.Path;
 import org.onosproject.net.PortNumber;
 import org.onosproject.net.SparseAnnotations;
@@ -95,6 +98,7 @@
 import org.onosproject.pcepio.protocol.PcepMessage;
 import org.onosproject.pcepio.protocol.PcepMetricObject;
 import org.onosproject.pcepio.protocol.PcepMsgPath;
+import org.onosproject.pcepio.protocol.PcepNai;
 import org.onosproject.pcepio.protocol.PcepReportMsg;
 import org.onosproject.pcepio.protocol.PcepSrpObject;
 import org.onosproject.pcepio.protocol.PcepStateReport;
@@ -102,7 +106,10 @@
 import org.onosproject.pcepio.protocol.PcepUpdateRequest;
 import org.onosproject.pcepio.types.IPv4SubObject;
 import org.onosproject.pcepio.types.PathSetupTypeTlv;
+import org.onosproject.pcepio.types.PcepNaiIpv4Adjacency;
+import org.onosproject.pcepio.types.PcepNaiIpv4NodeId;
 import org.onosproject.pcepio.types.PcepValueType;
+import org.onosproject.pcepio.types.SrEroSubObject;
 import org.onosproject.pcepio.types.StatefulIPv4LspIdentifiersTlv;
 import org.onosproject.pcepio.types.SymbolicPathNameTlv;
 import org.osgi.service.component.ComponentContext;
@@ -115,6 +122,7 @@
 import java.util.Collections;
 import java.util.Dictionary;
 import java.util.HashMap;
+import java.util.Iterator;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.ListIterator;
@@ -845,7 +853,7 @@
      * Creates list of hops for ERO object from Path.
      *
      * @param path network path
-     * @return list of ipv4 subobjects
+     * @return list of ERO subobjects
      */
     private LinkedList<PcepValueType> createPcepPath(Path path) {
         LinkedList<PcepValueType> llSubObjects = new LinkedList<PcepValueType>();
@@ -880,6 +888,55 @@
     }
 
     /**
+     * Creates label stack for ERO object from network resource.
+     *
+     * @param labelStack
+     * @param path (hop list)
+     * @return list of ERO subobjects
+     */
+    private LinkedList<PcepValueType> createPcepLabelStack(DefaultLabelStack labelStack, Path path) {
+        checkNotNull(labelStack);
+
+        LinkedList<PcepValueType> llSubObjects = new LinkedList<PcepValueType>();
+        Iterator<Link> links = path.links().iterator();
+        LabelResourceId label = null;
+        Link link = null;
+        PcepValueType subObj = null;
+        PcepNai nai = null;
+        Device dstNode = null;
+        long srcPortNo, dstPortNo;
+
+        ListIterator<LabelResourceId> labelListIterator = labelStack.labelResources().listIterator();
+        while (labelListIterator.hasNext()) {
+            label = labelListIterator.next();
+            link = links.next();
+
+            srcPortNo = link.src().port().toLong();
+            srcPortNo = ((srcPortNo & IDENTIFIER_SET) == IDENTIFIER_SET) ? srcPortNo & SET : srcPortNo;
+
+            dstPortNo = link.dst().port().toLong();
+            dstPortNo = ((dstPortNo & IDENTIFIER_SET) == IDENTIFIER_SET) ? dstPortNo & SET : dstPortNo;
+
+            nai = new PcepNaiIpv4Adjacency((int) srcPortNo, (int) dstPortNo);
+            subObj = new SrEroSubObject(PcepNaiIpv4Adjacency.ST_TYPE, false, false, false, true, (int) label.labelId(),
+                                        nai);
+            llSubObjects.add(subObj);
+
+            dstNode = deviceService.getDevice(link.dst().deviceId());
+            nai = new PcepNaiIpv4NodeId(Ip4Address.valueOf(dstNode.annotations().value(LSRID)).toInt());
+
+            if (!labelListIterator.hasNext()) {
+                log.error("Malformed label stack.");
+            }
+            label = labelListIterator.next();
+            subObj = new SrEroSubObject(PcepNaiIpv4NodeId.ST_TYPE, false, false, false, true, (int) label.labelId(),
+                                        nai);
+            llSubObjects.add(subObj);
+        }
+        return llSubObjects;
+    }
+
+    /**
      * Creates PcInitiated lsp request list for setup tunnel.
      *
      * @param tunnel mpls tunnel
@@ -893,7 +950,14 @@
                                                                   PcepClient pc, int srpId)
                                                                           throws PcepParseException {
         PcepValueType tlv;
-        LinkedList<PcepValueType> llSubObjects = createPcepPath(path);
+        LinkedList<PcepValueType> llSubObjects = null;
+
+        NetworkResource labelStack = tunnel.resource();
+        if (labelStack != null && labelStack instanceof DefaultLabelStack) {
+            llSubObjects = createPcepLabelStack((DefaultLabelStack) labelStack, path);
+        } else {
+            llSubObjects = createPcepPath(path);
+        }
 
         if (llSubObjects == null || llSubObjects.size() == 0) {
             log.error("There is no link information to create tunnel");
@@ -932,8 +996,8 @@
         llOptionalTlv.add(tlv);
 
         //build LSP object
-        PcepLspObject lspobj = pc.factory().buildLspObject().setAFlag(true).setOFlag((byte) 0).setPlspId(0)
-                .setOptionalTlv(llOptionalTlv).build();
+        PcepLspObject lspobj = pc.factory().buildLspObject().setAFlag(true).setDFlag(true).setOFlag((byte) 0)
+                .setPlspId(0).setOptionalTlv(llOptionalTlv).build();
 
         //build ENDPOINTS object
         PcepEndPointsObject endpointsobj = pc.factory().buildEndPointsObject()
@@ -1036,15 +1100,6 @@
             pcepTunnelApiMapper.addToCoreTunnelRequestQueue(pcepTunnelData);
             int srpId = SrpIdGenerators.create();
             TunnelId tunnelId = tunnel.tunnelId();
-            int plspId = 0;
-
-            if (!(pcepTunnelApiMapper.checkFromTunnelDBQueue(tunnelId))) {
-                log.error("Tunnel doesnot exists. Tunnel id {}" + tunnelId.toString());
-                return;
-            } else {
-                PcepTunnelData pcepTunnelDbData = pcepTunnelApiMapper.getDataFromTunnelDBQueue(tunnelId);
-                plspId = pcepTunnelDbData.plspId();
-            }
 
             PcepValueType tlv;
             LinkedList<PcepValueType> llOptionalTlv = new LinkedList<PcepValueType>();
@@ -1066,8 +1121,11 @@
 
             String localLspIdString = tunnel.annotations().value(LOCAL_LSP_ID);
             String pccTunnelIdString = tunnel.annotations().value(PCC_TUNNEL_ID);
+            String pLspIdString = tunnel.annotations().value(PLSP_ID);
+
             short localLspId = 0;
             short pccTunnelId = 0;
+            int plspId = 0;
 
             if (localLspIdString != null) {
                 localLspId = Short.valueOf(localLspIdString);
@@ -1077,6 +1135,10 @@
                 pccTunnelId = Short.valueOf(pccTunnelIdString);
             }
 
+            if (pLspIdString != null) {
+                plspId = Integer.valueOf(pLspIdString);
+            }
+
             tlv = new StatefulIPv4LspIdentifiersTlv((((IpTunnelEndPoint) tunnel.src())
                     .ip().getIp4Address().toInt()),
                     localLspId, pccTunnelId, 0, (((IpTunnelEndPoint) tunnel.dst()).ip()
@@ -1119,7 +1181,14 @@
             PcepValueType tlv;
             int plspId = 0;
 
-            LinkedList<PcepValueType> llSubObjects = createPcepPath(path);
+            LinkedList<PcepValueType> llSubObjects = null;
+            NetworkResource labelStack = tunnel.resource();
+            if (labelStack != null && labelStack instanceof DefaultLabelStack) {
+                llSubObjects = createPcepLabelStack((DefaultLabelStack) labelStack, path);
+            } else {
+                llSubObjects = createPcepPath(path);
+            }
+
             LinkedList<PcepValueType> llOptionalTlv = new LinkedList<PcepValueType>();
             LinkedList<PcepUpdateRequest> llUpdateRequestList = new LinkedList<PcepUpdateRequest>();
 
@@ -1329,7 +1398,7 @@
             DefaultTunnelDescription td = new DefaultTunnelDescription(tunnel.tunnelId(), tunnel.src(),
                                                                        tunnel.dst(), tunnel.type(), tunnel.groupId(),
                                                                        providerId, tunnel.tunnelName(), path,
-                                                                       annotations);
+                                                                       tunnel.resource(), annotations);
 
             if (CREATE == pcepTunnelData.requestType()) {
                 pcepTunnelApiMapper.addToTunnelIdMap(pcepTunnelData);
@@ -1355,7 +1424,8 @@
             // though there are no labels to download for SR-TE.
             if ((pcepLspStatus == PcepLspStatus.GOING_UP)
                     && (LspType.valueOf(tunnel.annotations().value(LSP_SIG_TYPE)) == SR_WITHOUT_SIGNALLING)) {
-                updateTunnel(tunnel, tunnel.path());
+                // Query again to get latest tunnel updated with protocol values from PCRpt msg.
+                updateTunnel(service.tunnelQueryById(tunnel.tunnelId()), tunnel.path());
             }
         }
 
@@ -1391,12 +1461,10 @@
 
                 while (listIterator.hasNext()) {
                     PcepValueType tlv = listIterator.next();
-
                     switch (tlv.getType()) {
                     case PathSetupTypeTlv.TYPE:
                         lspType = LspType.values()[Integer.valueOf(((PathSetupTypeTlv) tlv).getPst())];
                         break;
-
                     default:
                         break;
                     }
@@ -1417,38 +1485,48 @@
             }
 
             PcepAttribute attributes = msgPath.getPcepAttribute();
+            float bandwidth = 0;
             int cost = 0;
-            if (attributes != null && attributes.getMetricObjectList() != null) {
-                ListIterator<PcepMetricObject> iterator = attributes.getMetricObjectList().listIterator();
-                PcepMetricObject metricObj = iterator.next();
+            if (attributes != null) {
+                if (attributes.getMetricObjectList() != null) {
+                    ListIterator<PcepMetricObject> iterator = attributes.getMetricObjectList().listIterator();
+                    PcepMetricObject metricObj = iterator.next();
 
-                while (metricObj != null) {
-                    if (metricObj.getBType() == IGP_METRIC) {
-                        costType = "COST";
-                    } else if (metricObj.getBType() == TE_METRIC) {
-                        costType = "TE_COST";
+                    while (metricObj != null) {
+                        if (metricObj.getBType() == IGP_METRIC) {
+                            costType = "COST";
+                        } else if (metricObj.getBType() == TE_METRIC) {
+                            costType = "TE_COST";
+                        }
+                        if (costType != null) {
+                            cost = metricObj.getMetricVal();
+                            log.debug("Path cost {}", cost);
+                            break;
+                        }
+                        metricObj = iterator.next();
                     }
-
-                    if (costType != null) {
-                        cost = metricObj.getMetricVal();
-                        log.debug("Path cost {}", cost);
-                        break;
-                    }
-                    metricObj = iterator.next();
+                }
+                if (attributes.getBandwidthObject() != null) {
+                    bandwidth = attributes.getBandwidthObject().getBandwidth();
                 }
             }
 
-            Path path = buildPathFromEroObj(eroObj, providerId, cost);
-
-            float bandwidth = 0;
-            if (msgPath.getBandwidthObject() != null) {
-                bandwidth = msgPath.getBandwidthObject().getBandwidth();
+            List<Object> eroSubObjList = buildPathFromEroObj(eroObj, providerId);
+            List<Link> links = new ArrayList<>();
+            List<LabelResourceId> labels = new ArrayList<>();
+            for (Object linkOrLabel : eroSubObjList) {
+                if (linkOrLabel instanceof Link) {
+                    links.add((Link) linkOrLabel);
+                } else if (linkOrLabel instanceof Integer) {
+                    labels.add(LabelResourceId.labelResourceId(((Integer) linkOrLabel).longValue()));
+                }
             }
 
-            /*
-             * To carry PST TLV, SRP object can be present with value 0 even when PCRpt is not in response to any action
-             * from PCE.
-             */
+            Path path = new DefaultPath(providerId, links, cost, EMPTY);
+            NetworkResource labelStack = new DefaultLabelStack(labels);
+
+            // To carry PST TLV, SRP object can be present with value 0 even when PCRpt is not in response to any action
+            // from PCE.
             PcepSrpObject srpObj = stateRpt.getSrpObject();
             LspType lspType = getLspType(srpObj);
 
@@ -1463,11 +1541,9 @@
                 case StatefulIPv4LspIdentifiersTlv.TYPE:
                     ipv4LspIdenTlv = (StatefulIPv4LspIdentifiersTlv) tlv;
                     break;
-
                 case SymbolicPathNameTlv.TYPE:
                     pathNameTlv = (SymbolicPathNameTlv) tlv;
                     break;
-
                 default:
                     break;
                 }
@@ -1540,7 +1616,7 @@
                 annotations = getAnnotations(lspObj, ipv4LspIdenTlv, bandwidth, lspType, costType);
 
                 td = new DefaultTunnelDescription(null, tunnelEndPointSrc, tunnelEndPointDst, MPLS, new DefaultGroupId(
-                        0), providerId, TunnelName.tunnelName(new String(pathNameTlv.getValue())), path,
+                        0), providerId, TunnelName.tunnelName(new String(pathNameTlv.getValue())), path, labelStack,
                         annotations);
 
                 // Do not support PCC initiated LSP after LSP DB sync is completed.
@@ -1573,7 +1649,7 @@
                     TunnelId tId = tunnelAdded(td, tunnelState);
                     Tunnel tunnelInserted = new DefaultTunnel(providerId, tunnelEndPointSrc, tunnelEndPointDst, MPLS,
                             tunnelState, new DefaultGroupId(0), tId, TunnelName.tunnelName(String.valueOf(pathNameTlv
-                                    .getValue())), path, annotations);
+                                    .getValue())), path, labelStack, annotations);
 
                     PcepTunnelData pcepTunnelData = new PcepTunnelData(tunnelInserted, path, LSP_STATE_RPT);
                     pcepTunnelData.setStatefulIpv4IndentifierTlv(ipv4LspIdenTlv);
@@ -1589,7 +1665,7 @@
             if (lspObj.getDFlag()) {
                 annotations = getAnnotations(lspObj, ipv4LspIdenTlv, bandwidth, lspType, costType);
                 td = new DefaultTunnelDescription(null, tunnelEndPointSrc, tunnelEndPointDst, MPLS, new DefaultGroupId(
-                        0), providerId, TunnelName.tunnelName(new String(pathNameTlv.getValue())), path,
+                        0), providerId, TunnelName.tunnelName(new String(pathNameTlv.getValue())), path, labelStack,
                         annotations);
                 tunnelUpdateInDelegatedCase(pccId, annotations, td, providerId);
             }
@@ -1629,15 +1705,14 @@
          *
          * @param eroObj ERO object
          * @param providerId provider id
-         * @param cost cost of path
-         * @return path object
+         * @return list of links and labels
          */
-        private Path buildPathFromEroObj(PcepEroObject eroObj, ProviderId providerId, int cost) {
+        private List<Object> buildPathFromEroObj(PcepEroObject eroObj, ProviderId providerId) {
             checkNotNull(eroObj);
-            List<Link> links = new ArrayList<Link>();
+            List<Object> subObjList = new ArrayList<>();
             LinkedList<PcepValueType> llSubObj = eroObj.getSubObjects();
             if (0 == llSubObj.size()) {
-                log.debug("ERO in report message does not have hop information");
+                log.error("ERO in report message does not have hop information");
                 return null;
             }
             ListIterator<PcepValueType> tlvIterator = llSubObj.listIterator();
@@ -1665,16 +1740,34 @@
                                 .dst(dst)
                                 .type(Link.Type.DIRECT)
                                 .build();
-                        links.add(link);
+                        subObjList.add(link);
                         src = dst;
                     }
                     break;
+                case SrEroSubObject.TYPE:
+                    SrEroSubObject srEroSubObj = (SrEroSubObject) subObj;
+                    subObjList.add(srEroSubObj.getSid());
+
+                    if (srEroSubObj.getSt() == PcepNaiIpv4Adjacency.ST_TYPE) {
+                        PcepNaiIpv4Adjacency nai = (PcepNaiIpv4Adjacency) (srEroSubObj.getNai());
+                        IpAddress srcIp = IpAddress.valueOf(nai.getLocalIpv4Addr());
+                        src = new ConnectPoint(IpElementId.ipElement(srcIp), PortNumber.portNumber(0));
+                        IpAddress dstIp = IpAddress.valueOf(nai.getRemoteIpv4Addr());
+                        dst = new ConnectPoint(IpElementId.ipElement(dstIp), PortNumber.portNumber(0));
+                        Link link = DefaultLink.builder()
+                                .providerId(providerId)
+                                .src(src)
+                                .dst(dst)
+                                .type(Link.Type.DIRECT)
+                                .build();
+                        subObjList.add(link);
+                    }
                 default:
                     // the other sub objects are not required
                 }
             }
 
-            return new DefaultPath(providerId, links, cost, EMPTY);
+            return subObjList;
         }
 
         @Override
