Search in sources :

Example 46 with OchSignal

use of org.onosproject.net.OchSignal in project onos by opennetworkinglab.

the class OpenFlowLambdaQuery method signals.

private Set<OchSignal> signals(long min, long max, long grid) {
    if (Spectrum.O_BAND_MIN.asMHz() > min) {
        log.warn("Out of range frequency (below the O-band minimum)");
    }
    if (Spectrum.U_BAND_MAX.asMHz() < max) {
        log.warn("Out of range frequency (above the U-band maximum)");
    }
    double centerFrequencyMHz = Spectrum.CENTER_FREQUENCY.asMHz();
    long startSpacingMultiplier = (long) (min - centerFrequencyMHz) / grid;
    long stopSpacingMultiplier = (long) (max - centerFrequencyMHz) / grid;
    Set<OchSignal> signals = new LinkedHashSet<>();
    if (grid == ChannelSpacing.CHL_100GHZ.frequency().asMHz()) {
        signals = IntStream.rangeClosed((int) startSpacingMultiplier, (int) stopSpacingMultiplier).mapToObj(i -> new OchSignal(GridType.DWDM, ChannelSpacing.CHL_100GHZ, i, 8)).collect(GuavaCollectors.toImmutableSet());
    } else if (grid == ChannelSpacing.CHL_50GHZ.frequency().asMHz()) {
        signals = IntStream.rangeClosed((int) startSpacingMultiplier, (int) stopSpacingMultiplier).mapToObj(i -> new OchSignal(GridType.DWDM, ChannelSpacing.CHL_50GHZ, i, 4)).collect(GuavaCollectors.toImmutableSet());
    } else if (grid == ChannelSpacing.CHL_25GHZ.frequency().asMHz()) {
        signals = IntStream.rangeClosed((int) startSpacingMultiplier, (int) stopSpacingMultiplier).mapToObj(i -> new OchSignal(GridType.DWDM, ChannelSpacing.CHL_25GHZ, i, 2)).collect(GuavaCollectors.toImmutableSet());
    } else if (grid == ChannelSpacing.CHL_12P5GHZ.frequency().asMHz()) {
        signals = IntStream.rangeClosed((int) startSpacingMultiplier, (int) stopSpacingMultiplier).mapToObj(i -> new OchSignal(GridType.DWDM, ChannelSpacing.CHL_6P25GHZ, i, 1)).collect(GuavaCollectors.toImmutableSet());
    } else if (grid == ChannelSpacing.CHL_6P25GHZ.frequency().asMHz()) {
        // Only consider odd values for the multiplier (for easy mapping to fixed grid)
        signals = IntStream.rangeClosed((int) startSpacingMultiplier, (int) stopSpacingMultiplier).filter(i -> i % 2 == 1).mapToObj(i -> new OchSignal(GridType.FLEX, ChannelSpacing.CHL_6P25GHZ, i, 1)).collect(GuavaCollectors.toImmutableSet());
    } else {
        log.warn("Unsupported channel spacing");
    }
    return signals;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) Dpid(org.onosproject.openflow.controller.Dpid) IntStream(java.util.stream.IntStream) GridType(org.onosproject.net.GridType) LambdaQuery(org.onosproject.net.behaviour.LambdaQuery) Logger(org.slf4j.Logger) PortNumber(org.onosproject.net.PortNumber) OFPortDesc(org.projectfloodlight.openflow.protocol.OFPortDesc) Set(java.util.Set) Spectrum(org.onlab.util.Spectrum) GuavaCollectors(org.onlab.util.GuavaCollectors) OpenFlowController(org.onosproject.openflow.controller.OpenFlowController) OpenFlowSwitch(org.onosproject.openflow.controller.OpenFlowSwitch) AbstractHandlerBehaviour(org.onosproject.net.driver.AbstractHandlerBehaviour) Dpid.dpid(org.onosproject.openflow.controller.Dpid.dpid) OchSignal(org.onosproject.net.OchSignal) OFPortDescProp(org.projectfloodlight.openflow.protocol.OFPortDescProp) List(java.util.List) OFPortDescPropOptical(org.projectfloodlight.openflow.protocol.OFPortDescPropOptical) LoggerFactory.getLogger(org.slf4j.LoggerFactory.getLogger) ChannelSpacing(org.onosproject.net.ChannelSpacing) LinkedHashSet(java.util.LinkedHashSet) OchSignal(org.onosproject.net.OchSignal)

Example 47 with OchSignal

use of org.onosproject.net.OchSignal in project onos by opennetworkinglab.

the class ZteDeviceDiscoveryImpl method toPortDescriptionInternal.

private PortDescription toPortDescriptionInternal(HierarchicalConfiguration component) {
    Map<String, String> annotations = new HashMap<>();
    String name = component.getString("name");
    String type = component.getString("state/type");
    annotations.put(OdtnDeviceDescriptionDiscovery.OC_NAME, name);
    annotations.put(OdtnDeviceDescriptionDiscovery.OC_TYPE, type);
    annotations.putIfAbsent(AnnotationKeys.PORT_NAME, name);
    // PORT-1-4-C1
    String[] textStr = name.split("-");
    // use different value of portNumber on the same equipment
    String portComponentIndex = textStr[textStr.length - 1];
    int slotIndex = Integer.parseInt(textStr[2]);
    int slotPortIndex = Integer.parseInt(portComponentIndex.substring(1));
    int portNumber = slotIndex * 10 + slotPortIndex;
    annotations.putIfAbsent(ONOS_PORT_INDEX, portComponentIndex);
    annotations.putIfAbsent(CONNECTION_ID, "connection:" + Integer.parseInt(portComponentIndex.substring(1)));
    if (portComponentIndex.charAt(0) == 'L') {
        // line
        annotations.putIfAbsent(PORT_TYPE, OdtnPortType.LINE.value());
        OchSignal signalId = OchSignal.newDwdmSlot(ChannelSpacing.CHL_50GHZ, 1);
        return OchPortHelper.ochPortDescription(PortNumber.portNumber(portNumber + 100L), true, OduSignalType.ODUC2, true, signalId, DefaultAnnotations.builder().putAll(annotations).build());
    } else if (portComponentIndex.charAt(0) == 'C') {
        // client
        annotations.putIfAbsent(PORT_TYPE, OdtnPortType.CLIENT.value());
        Builder builder = DefaultPortDescription.builder();
        builder.withPortNumber(PortNumber.portNumber(portNumber)).isEnabled(true).portSpeed(100000L).type(Type.PACKET).annotations(DefaultAnnotations.builder().putAll(annotations).build());
        return builder.build();
    }
    return null;
}
Also used : HashMap(java.util.HashMap) Builder(org.onosproject.net.device.DefaultPortDescription.Builder) OchSignal(org.onosproject.net.OchSignal)

Example 48 with OchSignal

use of org.onosproject.net.OchSignal in project onos by opennetworkinglab.

the class PolatisPowerConfig method acquireTargetPower.

private Long acquireTargetPower(PortNumber port, T component) {
    if (component instanceof OchSignal) {
        log.warn("Channel power is not applicable.");
        return null;
    }
    log.debug("Get port{} target power...", port);
    DeviceId deviceId = handler().data().deviceId();
    Long targetPower = 0L;
    try {
        targetPower = Long.valueOf(get(handler(), VOA_LEVEL_OID + "." + port.toLong()).toInt());
    } catch (IOException e) {
        log.error("Error reading target power for device {} exception {}", deviceId, e);
    }
    return targetPower;
}
Also used : DeviceId(org.onosproject.net.DeviceId) OchSignal(org.onosproject.net.OchSignal) IOException(java.io.IOException)

Example 49 with OchSignal

use of org.onosproject.net.OchSignal in project onos by opennetworkinglab.

the class CzechLightLambdaQuery method queryLambdas.

@Override
public Set<OchSignal> queryLambdas(PortNumber portNumber) {
    DeviceService deviceService = this.handler().get(DeviceService.class);
    Port port = deviceService.getPort(data().deviceId(), portNumber);
    if ((port.type() == Port.Type.FIBER) || (port.type() == Port.Type.OMS)) {
        final int startMultiplier50 = (int) (START_CENTER_FREQ_50.subtract(Spectrum.CENTER_FREQUENCY).asHz() / Frequency.ofGHz(50).asHz());
        final int endMultiplier50 = (int) (END_CENTER_FREQ_50.subtract(Spectrum.CENTER_FREQUENCY).asHz() / Frequency.ofGHz(50).asHz());
        return IntStream.range(startMultiplier50, endMultiplier50 + 1).mapToObj(x -> OchSignal.newDwdmSlot(ChannelSpacing.CHL_50GHZ, x)).collect(Collectors.toSet());
    } else {
        return Collections.emptySet();
    }
}
Also used : IntStream(java.util.stream.IntStream) LambdaQuery(org.onosproject.net.behaviour.LambdaQuery) PortNumber(org.onosproject.net.PortNumber) DeviceService(org.onosproject.net.device.DeviceService) Set(java.util.Set) Spectrum(org.onlab.util.Spectrum) Collectors(java.util.stream.Collectors) AbstractHandlerBehaviour(org.onosproject.net.driver.AbstractHandlerBehaviour) OchSignal(org.onosproject.net.OchSignal) Frequency(org.onlab.util.Frequency) Port(org.onosproject.net.Port) ChannelSpacing(org.onosproject.net.ChannelSpacing) Collections(java.util.Collections) Port(org.onosproject.net.Port) DeviceService(org.onosproject.net.device.DeviceService)

Example 50 with OchSignal

use of org.onosproject.net.OchSignal in project onos by opennetworkinglab.

the class CienaWaveserverDeviceDescription method parseWaveServerCienaOchPorts.

public static PortDescription parseWaveServerCienaOchPorts(long portNumber, HierarchicalConfiguration config, SparseAnnotations annotations) {
    final List<String> tunableType = Lists.newArrayList("performance-optimized", "accelerated");
    final String flexGrid = "flex-grid";
    final String state = "properties.transmitter.state";
    final String tunable = "properties.modem.tx-tuning-mode";
    final String spacing = "properties.line-system.wavelength-spacing";
    final String frequency = "properties.transmitter.frequency.value";
    boolean isEnabled = config.getString(state).equals(ENABLED);
    boolean isTunable = tunableType.contains(config.getString(tunable));
    GridType gridType = config.getString(spacing).equals(flexGrid) ? GridType.FLEX : null;
    ChannelSpacing chSpacing = gridType == GridType.FLEX ? ChannelSpacing.CHL_6P25GHZ : null;
    // Working in Ghz //(Nominal central frequency - 193.1)/channelSpacing = spacingMultiplier
    final int baseFrequency = 193100;
    long spacingFrequency = chSpacing == null ? baseFrequency : chSpacing.frequency().asHz();
    int spacingMult = ((int) (toGbps(((int) config.getDouble(frequency) - baseFrequency)) / // FIXME is there a better way ?
    toGbpsFromHz(spacingFrequency)));
    return ochPortDescription(PortNumber.portNumber(portNumber), isEnabled, OduSignalType.ODU4, isTunable, new OchSignal(gridType, chSpacing, spacingMult, 1), annotations);
}
Also used : ChannelSpacing(org.onosproject.net.ChannelSpacing) OchSignal(org.onosproject.net.OchSignal) GridType(org.onosproject.net.GridType)

Aggregations

OchSignal (org.onosproject.net.OchSignal)63 PortNumber (org.onosproject.net.PortNumber)17 ChannelSpacing (org.onosproject.net.ChannelSpacing)16 GridType (org.onosproject.net.GridType)14 DeviceId (org.onosproject.net.DeviceId)12 ConnectPoint (org.onosproject.net.ConnectPoint)11 DeviceService (org.onosproject.net.device.DeviceService)10 HashMap (java.util.HashMap)9 Set (java.util.Set)9 IntStream (java.util.stream.IntStream)9 JsonNode (com.fasterxml.jackson.databind.JsonNode)8 Logger (org.slf4j.Logger)8 ArrayList (java.util.ArrayList)7 Port (org.onosproject.net.Port)7 Collectors (java.util.stream.Collectors)6 HierarchicalConfiguration (org.apache.commons.configuration.HierarchicalConfiguration)6 AbstractHandlerBehaviour (org.onosproject.net.driver.AbstractHandlerBehaviour)6 Collections (java.util.Collections)5 List (java.util.List)5 Frequency (org.onlab.util.Frequency)5