Search in sources :

Example 11 with Frequency

use of org.onlab.util.Frequency in project onos by opennetworkinglab.

the class CienaRestDevice method fetchRule.

private FlowRule fetchRule(PortNumber port) {
    Frequency frequency = getFrequency(port);
    if (frequency == null) {
        return null;
    }
    int channel = getChannelFromFrequency(frequency);
    /*
         * both inPort and outPort will be same as WaveServer only deal with same port ptp-indexes
         * channel and spaceMultiplier are same.
         * TODO: find a way to get both inPort and outPort for future when inPort may not be equal to outPort
         */
    TrafficSelector selector = DefaultTrafficSelector.builder().matchInPort(port).add(Criteria.matchOchSignalType(OchSignalType.FIXED_GRID)).add(Criteria.matchLambda(OchSignal.newDwdmSlot(CHANNEL_SPACING, channel))).build();
    TrafficTreatment treatment = DefaultTrafficTreatment.builder().setOutput(port).build();
    int hash = Objects.hash(deviceId, selector, treatment);
    Pair<FlowId, Integer> lookup = crossConnectCache.get(hash);
    if (lookup == null) {
        return null;
    }
    return DefaultFlowRule.builder().forDevice(deviceId).makePermanent().withSelector(selector).withTreatment(treatment).withPriority(lookup.getRight()).withCookie(lookup.getLeft().value()).build();
}
Also used : FlowId(org.onosproject.net.flow.FlowId) Frequency(org.onlab.util.Frequency) TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment)

Example 12 with Frequency

use of org.onlab.util.Frequency in project onos by opennetworkinglab.

the class CzechLightDiscovery method discoverPortDetails.

@Override
public List<PortDescription> discoverPortDetails() {
    DeviceId deviceId = handler().data().deviceId();
    DeviceService deviceService = checkNotNull(handler().get(DeviceService.class));
    Device device = deviceService.getDevice(deviceId);
    var deviceType = DeviceType.valueOf(device.annotations().value(DEVICE_TYPE_ANNOTATION));
    List<PortDescription> portDescriptions = Lists.newArrayList();
    if (deviceType == DeviceType.INLINE_AMP) {
        DefaultAnnotations.Builder annotations = DefaultAnnotations.builder();
        annotations.set(AnnotationKeys.PORT_NAME, DESC_PORT_LINE_WEST);
        annotations.set(OdtnDeviceDescriptionDiscovery.PORT_TYPE, OdtnDeviceDescriptionDiscovery.OdtnPortType.LINE.toString());
        portDescriptions.add(omsPortDescription(PortNumber.portNumber(PORT_INLINE_WEST), true, START_CENTER_FREQ_50, END_CENTER_FREQ_50, CHANNEL_SPACING_50.frequency(), annotations.build()));
        annotations = DefaultAnnotations.builder();
        annotations.set(AnnotationKeys.PORT_NAME, DESC_PORT_LINE_EAST);
        annotations.set(OdtnDeviceDescriptionDiscovery.PORT_TYPE, OdtnDeviceDescriptionDiscovery.OdtnPortType.LINE.toString());
        portDescriptions.add(omsPortDescription(PortNumber.portNumber(PORT_INLINE_EAST), true, START_CENTER_FREQ_50, END_CENTER_FREQ_50, CHANNEL_SPACING_50.frequency(), annotations.build()));
        return portDescriptions;
    }
    DefaultAnnotations.Builder annotationsForCommon = DefaultAnnotations.builder();
    switch(deviceType) {
        case LINE_DEGREE:
            annotationsForCommon.set(AnnotationKeys.PORT_NAME, DESC_PORT_LINE);
            annotationsForCommon.set(OdtnDeviceDescriptionDiscovery.PORT_TYPE, OdtnDeviceDescriptionDiscovery.OdtnPortType.LINE.toString());
            break;
        case ADD_DROP_FLEX:
        case COHERENT_ADD_DROP:
            annotationsForCommon.set(AnnotationKeys.PORT_NAME, DESC_PORT_EXPRESS);
            break;
        case INLINE_AMP:
            assert false : "this cannot happen because it's handled above, but I have to type this here anyway";
        default:
            assert false : "unhandled device type";
    }
    portDescriptions.add(omsPortDescription(PortNumber.portNumber(PORT_COMMON), true, START_CENTER_FREQ_50, END_CENTER_FREQ_50, CHANNEL_SPACING_50.frequency(), annotationsForCommon.build()));
    final int leafPortCount;
    switch(deviceType) {
        case LINE_DEGREE:
            leafPortCount = 9;
            break;
        case ADD_DROP_FLEX:
            leafPortCount = 20;
            break;
        case COHERENT_ADD_DROP:
            leafPortCount = 8;
            break;
        default:
            log.error("Unsupported CzechLight device type");
            return null;
    }
    for (var i = 1; i <= leafPortCount; ++i) {
        DefaultAnnotations.Builder annotations = DefaultAnnotations.builder();
        final Frequency channelSpacing;
        annotations.set(AnnotationKeys.PORT_NAME, leafPortName(deviceType, i));
        switch(deviceType) {
            case LINE_DEGREE:
                channelSpacing = CHANNEL_SPACING_50.frequency();
                break;
            case ADD_DROP_FLEX:
                annotations.set(OdtnDeviceDescriptionDiscovery.PORT_TYPE, OdtnDeviceDescriptionDiscovery.OdtnPortType.CLIENT.toString());
                channelSpacing = CHANNEL_SPACING_50.frequency();
                break;
            case COHERENT_ADD_DROP:
                annotations.set(OdtnDeviceDescriptionDiscovery.PORT_TYPE, OdtnDeviceDescriptionDiscovery.OdtnPortType.CLIENT.toString());
                channelSpacing = CHANNEL_SPACING_NONE.frequency();
                break;
            default:
                log.error("Unsupported CzechLight device type");
                return null;
        }
        portDescriptions.add(omsPortDescription(PortNumber.portNumber(i), true, START_CENTER_FREQ_50, END_CENTER_FREQ_50, channelSpacing, annotations.build()));
    }
    return portDescriptions;
}
Also used : DefaultAnnotations(org.onosproject.net.DefaultAnnotations) DeviceId(org.onosproject.net.DeviceId) Device(org.onosproject.net.Device) DeviceService(org.onosproject.net.device.DeviceService) OmsPortHelper.omsPortDescription(org.onosproject.net.optical.device.OmsPortHelper.omsPortDescription) PortDescription(org.onosproject.net.device.PortDescription) Frequency(org.onlab.util.Frequency)

Example 13 with Frequency

use of org.onlab.util.Frequency in project onos by opennetworkinglab.

the class OmsPortHelper method asOmsPort.

public static Optional<OmsPort> asOmsPort(Port port) {
    if (port instanceof OmsPort) {
        return Optional.of((OmsPort) port);
    }
    try {
        Annotations an = port.annotations();
        Frequency minFrequency = Frequency.ofHz(Long.parseLong(an.value(OpticalAnnotations.MIN_FREQ_HZ)));
        Frequency maxFrequency = Frequency.ofHz(Long.parseLong(an.value(OpticalAnnotations.MAX_FREQ_HZ)));
        Frequency grid = Frequency.ofHz(Long.parseLong(an.value(OpticalAnnotations.GRID_HZ)));
        return Optional.of(new DefaultOmsPort(port, minFrequency, maxFrequency, grid));
    } catch (NumberFormatException e) {
        log.warn("{} was not well-formed OMS port.", port, e);
        return Optional.empty();
    }
}
Also used : DefaultOmsPort(org.onosproject.net.optical.impl.DefaultOmsPort) OmsPort(org.onosproject.net.optical.OmsPort) OpticalAnnotations(org.onosproject.net.optical.OpticalAnnotations) DefaultAnnotations(org.onosproject.net.DefaultAnnotations) Annotations(org.onosproject.net.Annotations) SparseAnnotations(org.onosproject.net.SparseAnnotations) Frequency(org.onlab.util.Frequency) DefaultOmsPort(org.onosproject.net.optical.impl.DefaultOmsPort)

Example 14 with Frequency

use of org.onlab.util.Frequency in project onos by opennetworkinglab.

the class OpticalChannelUtility method extractOch.

/**
 * This method extracts Central Frequency and Slot Width from OchSignal instance.
 * @param signal - OchSignal instance.
 * @param channelSpacing - channel spacing.
 * @return - HashMap with upper and lower bounds of frequency.
 */
public static final Map<String, Frequency> extractOch(OchSignal signal, ChannelSpacing channelSpacing) {
    // Initializing variables
    int spacingMultiplier = signal.spacingMultiplier();
    int slotGranularity = signal.slotGranularity();
    // Computing central frequency
    Frequency central = computeCentralFrequency(spacingMultiplier, channelSpacing);
    // Computing slot width
    Frequency sw = computeSlotWidth(slotGranularity);
    Map<String, Frequency> freqs = new HashMap<String, Frequency>();
    freqs.put("centralFrequency", central);
    freqs.put("slotWidth", sw);
    return freqs;
}
Also used : HashMap(java.util.HashMap) Frequency(org.onlab.util.Frequency)

Example 15 with Frequency

use of org.onlab.util.Frequency in project onos by opennetworkinglab.

the class OpticalChannelUtility method createOchSignalFromBounds.

/**
 * This method creates OchSignal instance from frequency bounds.
 * @param lowerBound - lower bound of the frequency.
 * @param upperBound - upper bound of the frequency.
 * @param gridType - type of the frequency grid.
 * @param channelSpacing - channel spacing.
 * @return - returns created instance of OchSignal.
 */
public static final OchSignal createOchSignalFromBounds(Frequency lowerBound, Frequency upperBound, GridType gridType, ChannelSpacing channelSpacing) {
    // Transferring everything to the frequencies
    Frequency slotWidth = upperBound.subtract(lowerBound);
    Frequency halfBw = slotWidth.floorDivision(2);
    Frequency centralFrequency = lowerBound.add(halfBw);
    int spacingMultiplier = computeSpacingMultiplier(centralFrequency, channelSpacing);
    int slotGranularity = computeSlotGranularity(slotWidth);
    return (new OchSignal(gridType, channelSpacing, spacingMultiplier, slotGranularity));
}
Also used : Frequency(org.onlab.util.Frequency) OchSignal(org.onosproject.net.OchSignal)

Aggregations

Frequency (org.onlab.util.Frequency)17 PortNumber (org.onosproject.net.PortNumber)6 DefaultAnnotations (org.onosproject.net.DefaultAnnotations)5 DeviceId (org.onosproject.net.DeviceId)4 OchSignal (org.onosproject.net.OchSignal)4 Port (org.onosproject.net.Port)4 DeviceService (org.onosproject.net.device.DeviceService)4 Test (org.junit.Test)3 FlowRuleParser (org.onosproject.drivers.odtn.impl.FlowRuleParser)3 Annotations (org.onosproject.net.Annotations)3 ChannelSpacing (org.onosproject.net.ChannelSpacing)3 DefaultPort (org.onosproject.net.DefaultPort)3 GridType (org.onosproject.net.GridType)3 DefaultTrafficSelector (org.onosproject.net.flow.DefaultTrafficSelector)3 DefaultTrafficTreatment (org.onosproject.net.flow.DefaultTrafficTreatment)3 OmsPort (org.onosproject.net.optical.OmsPort)3 Preconditions.checkNotNull (com.google.common.base.Preconditions.checkNotNull)2 ImmutableList (com.google.common.collect.ImmutableList)2 ByteArrayInputStream (java.io.ByteArrayInputStream)2 StringReader (java.io.StringReader)2