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.yang.gen.v1.http.org.openroadm.common.network.rev181130.Link1;
14 import org.opendaylight.yang.gen.v1.http.org.openroadm.link.rev181130.span.attributes.LinkConcatenation.FiberType;
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);
27 ///////////////////////// LINKS ////////////////////
29 * extension of Link to include constraints and Graph weight
32 private boolean isValid = true;
33 // this member is for XPONDER INPUT/OUTPUT links.
34 // it keeps name of client corresponding to NETWORK TP
35 private String client = "";
36 private final LinkId linkId;
37 private final OpenroadmLinkType linkType;
38 private final NodeId sourceId;
39 private final NodeId destId;
40 private final Object sourceTP;
41 private final Object destTP;
42 private final String sourceSupNodeId;
43 private final String destSupNodeId;
44 private final String sourceCLLI;
45 private final String destCLLI;
46 private final LinkId oppositeLink;
47 private final Long latency;
48 private final List<Long> srlgList;
49 private final double osnr;
50 private final Span omsAttributesSpan;
51 private static final double CELERITY = 2.99792458 * 1e5; //meter per ms
52 private static final double NOISE_MASK_A = 0.571429;
53 private static final double NOISE_MASK_B = 39.285714;
54 private static final double UPPER_BOUND_OSNR = 33;
55 private static final double LOWER_BOUND_OSNR = 0.1;
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);
78 if (this.linkType == OpenroadmLinkType.ROADMTOROADM) {
79 this.omsAttributesSpan = MapUtils.getOmsAttributesSpan(link);
80 this.srlgList = MapUtils.getSRLG(link);
81 this.latency = calcLatency(link);
82 this.osnr = calcSpanOSNR();
84 this.omsAttributesSpan = null;
87 this.osnr = 100L; //infinite OSNR in DB
90 LOG.debug("PceLink: created PceLink {}", toString());
93 //Retrieve the opposite link
94 private LinkId calcOpposite(Link link) {
95 LinkId tmpoppositeLink = MapUtils.extractOppositeLink(link);
96 if (tmpoppositeLink == null) {
97 LOG.error("PceLink: Error calcOpposite. Link is ignored {}", link.getLinkId().getValue());
100 return tmpoppositeLink;
103 //Compute the link latency : if the latency is not defined, the latency it is computed from the omsAttributesSpan
104 private Long calcLatency(Link link) {
106 link1 = link.augmentation(Link1.class);
107 Long tmplatency = link1.getLinkLatency();
108 if (tmplatency != null) {
114 for (int i = 0; i < this.omsAttributesSpan.getLinkConcatenation().size(); i++) {
115 //Length is expressed in meter and latency is expressed in ms according to OpenROADM MSA
116 tmp += this.omsAttributesSpan.getLinkConcatenation().get(i).getSRLGLength() / CELERITY;
117 LOG.info("In PceLink: The latency of link {} == {}",link.getLinkId(),tmplatency);
119 tmplatency = (long) Math.ceil(tmp);
120 } catch (NullPointerException e) {
121 LOG.debug("In PceLink: cannot compute the latency for the link {}",link.getLinkId().getValue());
127 //Compute the OSNR of a span
128 public double calcSpanOSNR() {
130 double pout; //power on the output of the previous ROADM (dBm)
131 pout = retrievePower(this.omsAttributesSpan.getLinkConcatenation().get(0).getFiberType());
132 double spanLoss = this.omsAttributesSpan.getSpanlossCurrent().getValue().doubleValue(); // span loss (dB)
133 double pin = pout - spanLoss; //power on the input of the current ROADM (dBm)
135 spanOsnrDb = NOISE_MASK_A * pin + NOISE_MASK_B;
136 if (spanOsnrDb > UPPER_BOUND_OSNR) {
137 spanOsnrDb = UPPER_BOUND_OSNR;
138 } else if (spanOsnrDb < LOWER_BOUND_OSNR) {
139 spanOsnrDb = LOWER_BOUND_OSNR;
142 } catch (NullPointerException e) {
143 LOG.error("in PceLink : Null field in the OmsAttrubtesSpan");
148 private double retrievePower(FiberType fiberType) {
172 public LinkId getOppositeLink() {
176 public Object getSourceTP() {
180 public Object getDestTP() {
184 public OpenroadmLinkType getlinkType() {
188 public LinkId getLinkId() {
192 public NodeId getSourceId() {
196 public NodeId getDestId() {
200 public String getClient() {
204 public void setClient(String client) {
205 this.client = client;
208 // Double for transformer of JUNG graph
209 public Double getLatency() {
210 return latency.doubleValue();
213 public String getsourceSupNodeId() {
214 return sourceSupNodeId;
217 public String getdestSupNodeId() {
218 return destSupNodeId;
221 public List<Long> getsrlgList() {
225 public double getosnr() {
229 public String getsourceCLLI() {
233 public String getdestCLLI() {
237 public boolean isValid() {
238 if ((this.linkId == null) || (this.linkType == null)
239 || (this.oppositeLink == null)) {
241 LOG.error("PceLink: No Link type or opposite link is available. Link is ignored {}", linkId);
243 if ((this.sourceId == null) || (this.destId == null)
244 || (this.sourceTP == null) || (this.destTP == null)) {
246 LOG.error("PceLink: No Link source or destination is available. Link is ignored {}", linkId);
248 if ((this.sourceSupNodeId.equals("")) || (this.destSupNodeId.equals(""))) {
250 LOG.error("PceLink: No Link source SuppNodeID or destination SuppNodeID is available. Link is ignored {}",
253 if ((this.sourceCLLI.equals("")) || (this.destCLLI.equals(""))) {
255 LOG.error("PceLink: No Link source CLLI or destination CLLI is available. Link is ignored {}", linkId);
257 if ((this.omsAttributesSpan == null) && (this.linkType == OpenroadmLinkType.ROADMTOROADM)) {
259 LOG.error("PceLink: Error reading Span for OMS link. Link is ignored {}", linkId);
261 if ((this.srlgList != null) && (this.srlgList.isEmpty())) {
263 LOG.error("PceLink: Empty srlgList for OMS link. Link is ignored {}", linkId);
268 public String toString() {
269 return "PceLink type=" + linkType + " ID=" + linkId.getValue() + " latency=" + latency;