- //Compute the link latency : if the latency is not defined, the latency is computed from the length
- private Long calcLatency(Link link) {
- var augLinkLatency = link.augmentation(Link1.class).getLinkLatency();
- if (augLinkLatency != null) {
- return augLinkLatency.toJava();
- }
- Double linkLength = calcLength(link);
- if (linkLength == null) {
- LOG.debug("In PceLink: cannot compute the latency for the link {}", link.getLinkId().getValue());
- return 1L;
- }
- LOG.debug("In PceLink: The latency of link {} is extrapolated from link length and == {}",
- link.getLinkId(), linkLength / GLASSCELERITY);
- return (long) Math.ceil(linkLength / GLASSCELERITY);
- }
-
- private Double calcLength(Link link) {
- var augLinkLength = link.augmentation(Link1.class).getLinkLength();
- if (augLinkLength != null) {
- return augLinkLength.doubleValue();
- }
- if (this.omsAttributesSpan == null) {
- LOG.debug("In PceLink: cannot compute the length for the link {}", link.getLinkId().getValue());
- return null;
- }
- double linkLength = 0;
- Map<LinkConcatenationKey, LinkConcatenation> linkConcatenationMap =
- this.omsAttributesSpan.nonnullLinkConcatenation();
- for (Map.Entry<LinkConcatenationKey, LinkConcatenation> entry : linkConcatenationMap.entrySet()) {
- // Length is expressed in meter according to OpenROADM MSA
- if (entry == null || entry.getValue() == null || entry.getValue().getSRLGLength() == null) {
- LOG.debug("In PceLink: cannot compute the length for the link {}", link.getLinkId().getValue());
- return null;
- }
- linkLength += entry.getValue().getSRLGLength().doubleValue();
- LOG.debug("In PceLink: The length of the link {} == {}", link.getLinkId(), linkLength / 1000.0);
- }
- return linkLength / 1000.0;
- }
-
- //Calculate CD and PMD of the link from link length
- private Map<String, Double> calcCDandPMDfromLength() {
- return this.length == null
- ? new HashMap<>()
- : new HashMap<>(
- Map.of(
- "CD", 16.5 * this.length,
- "PMD2", Math.pow(this.length * PMD_CONSTANT, 2)));
- }
-
- //Calculate CD and PMD of the link
- private Map<String, Double> calcCDandPMD(Link link) {
- double linkCd = 0.0;
- double linkPmd2 = 0.0;
- if (this.omsAttributesSpan == null) {
- LOG.debug("In PceLink {} no OMS present, assume G.652 fiber, calculation based on fiber length of {} km",
- link.getLinkId(), this.length);
- return calcCDandPMDfromLength();
- }
- Map<LinkConcatenationKey, LinkConcatenation> linkConcatenationMap =
- this.omsAttributesSpan.nonnullLinkConcatenation();
- for (Map.Entry<LinkConcatenationKey, LinkConcatenation> entry : linkConcatenationMap.entrySet()) {
- // If the link-concatenation list is not populated or partially populated CD &
- // PMD shall be derived from link-length (expressed in km in OR topology)
- if (entry == null || entry.getValue() == null || entry.getValue().getSRLGLength() == null
- || entry.getValue().augmentation(LinkConcatenation1.class).getFiberType() == null) {
- if (this.length > 0.0) {
- LOG.debug("In PceLink: no OMS present; cd and PMD for the link {} extrapolated from link length {}"
- + "assuming SMF fiber type", link.getLinkId().getValue(), this.length);
- return calcCDandPMDfromLength();
- }
- // If Link-length upper attributes not present or incorrectly populated, no way
- // to calculate CD & PMD
- LOG.error("In PceLink: no Link length declared and no OMS present for the link {}."
- + " No Way to compute CD and PMD", link.getLinkId().getValue());
- return Map.of();
- }
- // SRLG length is expressed in OR topology in meter
- var entryAug = entry.getValue().augmentation(LinkConcatenation1.class);
- linkCd += entry.getValue().getSRLGLength().doubleValue() / 1000.0
- * retrieveCdFromFiberType(entryAug.getFiberType());
- if (entryAug.getPmd() == null
- || entryAug.getPmd().getValue().doubleValue() == 0.0
- || entryAug.getPmd().getValue().toString().isEmpty()) {
- linkPmd2 += Math.pow(
- entry.getValue().getSRLGLength().doubleValue() / 1000.0
- * retrievePmdFromFiberType(entryAug.getFiberType()),
- 2);
- } else {
- linkPmd2 += Math.pow(entryAug.getPmd().getValue().doubleValue(), 2);
- }
- }
- LOG.debug("In PceLink: The CD and PMD2 of link {} are respectively {} ps and {} ps",
- link.getLinkId(), linkCd, linkPmd2);
- return Map.of("CD", linkCd, "PMD2", linkPmd2);
- }
-
- // compute default spanLoss and power correction from fiber length
- // when no OMS attribute defined
- private Map<String, Double> calcDefaultSpanLoss(Link link) {
- var augLinkLength = link.augmentation(Link1.class).getLinkLength();
- if (augLinkLength == null || augLinkLength.doubleValue() == 0) {
- LOG.error("In PceLink, no link length present or length declared = 0,"
- + " unable to calculate default span Loss ");
- return new HashMap<>();
- }
- long linkLength = augLinkLength.longValue();
- LOG.warn("In PceLink {}, assume G.652 fiber, calculation "
- + "based on fiber length of {} km and typical loss of 0.25dB per Km ",
- link.getLinkId(), linkLength);
- return new HashMap<>(
- Map.of(
- "SpanLoss", linkLength * 0.25,
- "PoutCorrection", retrievePower(FiberType.Smf)
- ));
- }
-
- // Compute the attenuation of a span from OMS attribute
- private Map<String, Double> calcSpanLoss(Link link) {
- if (this.omsAttributesSpan == null) {
- return calcDefaultSpanLoss(link);
- }
- Collection<LinkConcatenation> linkConcatenationList =
- this.omsAttributesSpan.nonnullLinkConcatenation().values();
- if (linkConcatenationList == null) {
- LOG.error("in PceLink : Null field in the OmsAttrubtesSpan");
- return calcDefaultSpanLoss(link);
- }
- Iterator<LinkConcatenation> linkConcatenationiterator = linkConcatenationList.iterator();
- if (!linkConcatenationiterator.hasNext()) {
- return calcDefaultSpanLoss(link);
- }
- // Reference of power to be launched at input of ROADM (dBm)
- return new HashMap<>(Map.of(
- "PoutCorrection", retrievePower(
- linkConcatenationiterator.next().augmentation(LinkConcatenation1.class).getFiberType()) - 2.0,
- "SpanLoss", this.omsAttributesSpan.getSpanlossCurrent().getValue().doubleValue()));
- }
-
- private double retrievePower(FiberType fiberType) {
- switch (fiberType) {
- case Smf:
- return 2;
- case Eleaf:
- return 1;
- case Truewavec:
- return -1;
- case Oleaf:
- case Dsf:
- case Truewave:
- case NzDsf:
- case Ull:
- default:
- return 0;
- }
- }
-
- private double retrievePmdFromFiberType(FiberType fiberType) {
- return fiberType.toString().equalsIgnoreCase("Dsf")
- ? 0.2
- : PMD_CONSTANT;
- }
-
- private double retrieveCdFromFiberType(FiberType fiberType) {
- switch (fiberType) {
- case Dsf:
- return 0.0;
- case Truewavec:
- return 3.0;
- case Eleaf:
- case Oleaf:
- case NzDsf:
- return 4.3;
- case Truewave:
- return 4.4;
- case Smf:
- case Ull:
- default:
- return 16.5;
- }
- }
-