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();
}
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;
}
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();
}
}
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;
}
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));
}
Aggregations