2 * Copyright © 2017 AT&T, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.transportpce.pce.networkanalyzer;
11 import java.util.List;
13 import org.opendaylight.transportpce.pce.constraints.PceConstraints;
14 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev181130.Link1;
15 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.rev181130.networks.network.link.oms.attributes.Span;
16 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev181130.OpenroadmLinkType;
17 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.NodeId;
18 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.LinkId;
19 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.networks.network.Link;
20 import org.slf4j.Logger;
21 import org.slf4j.LoggerFactory;
23 public class PceLink {
26 private static final Logger LOG = LoggerFactory.getLogger(PceLink.class);
28 ///////////////////////// LINKS ////////////////////
30 * extension of Link to include constraints and Graph weight
35 private boolean isValid = true;
37 // this member is for XPONDER INPUT/OUTPUT links.
38 // it keeps name of client correcponding to NETWORK TP
39 private String client = "";
41 private final LinkId linkId;
42 private final OpenroadmLinkType linkType;
43 private final NodeId sourceId;
44 private final NodeId destId;
45 private final Object sourceTP;
46 private final Object destTP;
47 private final String sourceSupNodeId;
48 private final String destSupNodeId;
49 private final String sourceCLLI;
50 private final String destCLLI;
51 private final LinkId oppositeLink;
52 private final Long latency;
53 private final List<Long> srlgList;
54 private final double osnr;
55 private final Span omsAttributesSpan;
57 public PceLink(Link link, PceNode source, PceNode dest) {
58 LOG.debug("PceLink: : PceLink start ");
60 this.linkId = link.getLinkId();
62 this.sourceId = link.getSource().getSourceNode();
63 this.destId = link.getDestination().getDestNode();
65 this.sourceTP = link.getSource().getSourceTp();
66 this.destTP = link.getDestination().getDestTp();
68 this.sourceSupNodeId = source.getSupNodeIdPceNode();
69 this.destSupNodeId = dest.getSupNodeIdPceNode();
71 this.sourceCLLI = source.getCLLI();
72 this.destCLLI = dest.getCLLI();
74 this.linkType = MapUtils.calcType(link);
76 this.oppositeLink = calcOpposite(link);
77 this.latency = calcLatency(link);
79 if (this.linkType == OpenroadmLinkType.ROADMTOROADM) {
80 this.omsAttributesSpan = MapUtils.getOmsAttributesSpan(link);
81 this.srlgList = MapUtils.getSRLG(link);
82 this.osnr = retrieveOSNR();
84 this.omsAttributesSpan = null;
90 LOG.debug("PceLink: created PceLink {}", toString());
93 /*private OpenroadmLinkType calcType(Link link) {
94 org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.rev181130.@Nullable Link1 link1 = null;
95 OpenroadmLinkType tmplinkType = null;
98 link1 = link.augmentation(org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.rev181130
101 this.isValid = false;
102 LOG.error("PceLink: No Link augmentation available. Link is ignored {}", this.linkId);
106 tmplinkType = link1.getLinkType();
107 if (tmplinkType == null) {
108 this.isValid = false;
109 LOG.error("PceLink: No Link type available. Link is ignored {}", this.linkId);
115 private LinkId calcOpposite(Link link) {
118 LinkId tmpoppositeLink = MapUtils.extractOppositeLink(link);
119 if (tmpoppositeLink == null) {
120 LOG.error("PceLink: Error calcOpposite. Link is ignored {}", link.getLinkId().getValue());
123 return tmpoppositeLink;
126 private Long calcLatency(Link link) {
127 Long tmplatency = 1L;
130 link1 = link.augmentation(Link1.class);
132 tmplatency = link1.getLinkLatency();
133 } catch (NullPointerException e) {
134 LOG.debug("the latency does not exist for this link");
139 @SuppressWarnings("checkstyle:VariableDeclarationUsageDistance")
140 public double retrieveOSNR() {
141 // sum of 1 over the span OSNRs (linear units)
149 // span OSNR, in linear units
151 // default amplifier noise value, in dB
152 //double ampNoise = 5.5;
153 // fiber span measured loss, in dB
155 // launch power, in dB
157 double constantA = 38.97293;
158 double constantB = 0.72782;
159 double constantC = -0.532331;
160 double constactD = -0.019549;
161 double upperBoundosnr = 33;
162 double lowerBoundosnr = 0.1;
164 if (omsAttributesSpan == null) {
165 // indicates no data or N/A
168 loss = omsAttributesSpan.getSpanlossCurrent().getValue().doubleValue();
169 switch (omsAttributesSpan.getLinkConcatenation().get(0).getFiberType()) {
206 spanOsnrDb = constantA + constantB * power + constantC * loss + constactD * power * loss;
207 if (spanOsnrDb > upperBoundosnr) {
208 spanOsnrDb = upperBoundosnr;
209 } else if (spanOsnrDb < lowerBoundosnr) {
210 spanOsnrDb = lowerBoundosnr;
212 spanOsnrLu = Math.pow(10, (spanOsnrDb / 10.0));
213 sum = PceConstraints.CONST_OSNR / spanOsnrLu;
215 LOG.debug("In retrieveosnr: link osnr is {} dB", linkOsnrLu);
219 public LinkId getOppositeLink() {
223 public Object getSourceTP() {
227 public Object getDestTP() {
231 public OpenroadmLinkType getlinkType() {
235 public LinkId getLinkId() {
239 public NodeId getSourceId() {
243 public NodeId getDestId() {
247 public String getClient() {
251 public void setClient(String client) {
252 this.client = client;
255 // Double for transformer of JUNG graph
256 public Double getLatency() {
257 return latency.doubleValue();
260 public String getsourceSupNodeId() {
261 return sourceSupNodeId;
264 public String getdestSupNodeId() {
265 return destSupNodeId;
268 public List<Long> getsrlgList() {
272 public double getosnr() {
276 public String getsourceCLLI() {
280 public String getdestCLLI() {
284 public boolean isValid() {
285 if ((this.linkId == null) || (this.linkType == null)
286 || (this.oppositeLink == null)) {
288 LOG.error("PceLink: No Link type or opposite link is available. Link is ignored {}", linkId);
290 if ((this.sourceId == null) || (this.destId == null)
291 || (this.sourceTP == null) || (this.destTP == null)) {
293 LOG.error("PceLink: No Link source or destination is available. Link is ignored {}", linkId);
295 if ((this.sourceSupNodeId.equals("")) || (this.destSupNodeId.equals(""))) {
297 LOG.error("PceLink: No Link source SuppNodeID or destination SuppNodeID is available. Link is ignored {}",
300 if ((this.sourceCLLI.equals("")) || (this.destCLLI.equals(""))) {
302 LOG.error("PceLink: No Link source CLLI or destination CLLI is available. Link is ignored {}", linkId);
304 if ((this.omsAttributesSpan == null) && (this.linkType == OpenroadmLinkType.ROADMTOROADM)) {
306 LOG.error("PceLink: Error reading Span for OMS link. Link is ignored {}", linkId);
308 if ((this.srlgList != null) && (this.srlgList.isEmpty())) {
310 LOG.error("PceLink: Empty srlgList for OMS link. Link is ignored {}", linkId);
315 public String toString() {
316 return "PceLink type=" + linkType + " ID=" + linkId.getValue() + " latecy=" + latency;