Java 类org.projectfloodlight.openflow.protocol.OFPortOptical 实例源码

项目:athena    文件:OfOpticalSwitchImplLinc13.java   
/**
 * Creates an OpenFlow optical port based on the given port and transport type.
 *
 * @param port OpenFlow optical port
 * @param type transport type
 * @return OpenFlow optical port
 */
private OFPortOptical createOpticalPort(OFPortOptical port, short type) {
    List<OFPortDescPropOpticalTransport> descList = new ArrayList<>(port.getDesc().size());

    for (OFPortDescPropOpticalTransport desc : port.getDesc()) {
        OFPortDescPropOpticalTransport newDesc = desc.createBuilder()
                .setType(desc.getType())
                .setPortSignalType(type)
                .setPortType(desc.getPortType())
                .setReserved(desc.getReserved())
                .build();
        descList.add(newDesc);
    }

    OFPortOptical newPort = port.createBuilder()
            .setConfig(port.getConfig())
            .setDesc(descList)
            .setHwAddr(port.getHwAddr())
            .setName(port.getName())
            .setPortNo(port.getPortNo())
            .setState(port.getState())
            .build();

    return newPort;
}
项目:athena    文件:OfOpticalSwitchImplLinc13.java   
/**
 * Builds list of OFPortOptical ports based on the multi-part circuit ports reply.
 *
 * Ensure the optical transport port's signal type is configured correctly.
 *
 * @param wPorts OF reply with circuit ports
 */
private void createOpticalPortList(OFCircuitPortsReply wPorts) {
    opticalPorts = new ArrayList<>(wPorts.getEntries().size());

    for (OFPortOptical p : wPorts.getEntries()) {
        short signalType;

        // FIXME: use constants once loxi has full optical extensions
        if (isOChPort(p.getPortNo().getPortNumber())) {
            signalType = 5;      // OCH port
        } else {
            signalType = 2;      // OMS port
        }

        opticalPorts.add(createOpticalPort(p, signalType));
    }
}
项目:ravikumaran201504    文件:OFOpticalSwitchImplLINC13.java   
private void processHandshakeOFExperimenterPortDescRequest(
        OFCircuitPortsReply sr) {
    Collection<OFPortOptical> entries = sr.getEntries();
    List<OFPortDesc> ofPortDescList = new ArrayList<>(entries.size());
    for (OFPortOptical entry : entries) {
        log.warn("LINC:OE port message {}", entry.toString());
        ofPortDescList.add(factory().buildPortDesc().
                setPortNo(entry.getPortNo())
                                       .setConfig(entry.getConfig())
                                       .setState(entry.getState())
                                       .setHwAddr(entry.getHwAddr())
                                       .setName(entry.getName())
                                       .build());

    }
    setExperimenterPortDescReply(factory().buildPortDescStatsReply().
            setEntries(ofPortDescList).build());
}
项目:onos    文件:OfOpticalSwitchImplLinc13.java   
/**
 * Creates an OpenFlow optical port based on the given port and transport type.
 *
 * @param port OpenFlow optical port
 * @param type transport type
 * @return OpenFlow optical port
 */
private OFPortOptical createOpticalPort(OFPortOptical port, short type) {
    List<OFPortDescPropOpticalTransport> descList = new ArrayList<>(port.getDesc().size());

    for (OFPortDescPropOpticalTransport desc : port.getDesc()) {
        OFPortDescPropOpticalTransport newDesc = desc.createBuilder()
                .setType(desc.getType())
                .setPortSignalType(type)
                .setPortType(desc.getPortType())
                .setReserved(desc.getReserved())
                .build();
        descList.add(newDesc);
    }

    OFPortOptical newPort = port.createBuilder()
            .setConfig(port.getConfig())
            .setDesc(descList)
            .setHwAddr(port.getHwAddr())
            .setName(port.getName())
            .setPortNo(port.getPortNo())
            .setState(port.getState())
            .build();

    return newPort;
}
项目:onos    文件:OfOpticalSwitchImplLinc13.java   
/**
 * Builds list of OFPortOptical ports based on the multi-part circuit ports reply.
 *
 * Ensure the optical transport port's signal type is configured correctly.
 *
 * @param wPorts OF reply with circuit ports
 */
private void createOpticalPortList(OFCircuitPortsReply wPorts) {
    opticalPorts = new ArrayList<>(wPorts.getEntries().size());

    for (OFPortOptical p : wPorts.getEntries()) {
        short signalType;

        // FIXME: use constants once loxi has full optical extensions
        if (isOChPort(p.getPortNo())) {
            signalType = 5;      // OCH port
        } else {
            signalType = 2;      // OMS port
        }

        opticalPorts.add(createOpticalPort(p, signalType));
    }
}
项目:athena    文件:OpenFlowDeviceProvider.java   
/**
 * Build a portDescription from a given a port description describing some
 * Optical port.
 *
 * @param port description property type.
 * @param port the port to build from.
 * @return portDescription for the port.
 */
private PortDescription buildPortDescription(PortDescPropertyType ptype, OFPortOptical port) {
    checkArgument(port.getDesc().size() >= 1);

    // Minimally functional fixture. This needs to be fixed as we add better support.
    PortNumber portNo = PortNumber.portNumber(port.getPortNo().getPortNumber());

    boolean enabled = !port.getState().contains(OFPortState.LINK_DOWN)
            && !port.getConfig().contains(OFPortConfig.PORT_DOWN);
    SparseAnnotations annotations = makePortAnnotation(port.getName(), port.getHwAddr().toString());

    if (port.getVersion() == OFVersion.OF_13
            && ptype == PortDescPropertyType.OPTICAL_TRANSPORT) {
        // At this point, not much is carried in the optical port message.
        LOG.debug("Optical transport port message {}", port.toString());
    } else {
        // removable once 1.4+ support complete.
        LOG.debug("Unsupported optical port properties");
    }

    OFPortDescPropOpticalTransport desc = port.getDesc().get(0);
    switch (desc.getPortSignalType()) {
        // FIXME: use constants once loxi has full optical extensions
        case 2:     // OMS port
            // Assume complete optical spectrum and 50 GHz grid
            // LINC-OE is only supported optical OF device for now
            return omsPortDescription(portNo, enabled,
                    Spectrum.U_BAND_MIN, Spectrum.O_BAND_MAX, Frequency.ofGHz(50), annotations);
        case 5:     // OCH port
            OchSignal signal = new OchSignal(GridType.DWDM, ChannelSpacing.CHL_50GHZ, 0, 4);
            return ochPortDescription(portNo, enabled, OduSignalType.ODU4,
                    true, signal, annotations);
        default:
            break;
    }

    return new DefaultPortDescription(portNo, enabled, FIBER, 0, annotations);
}
项目:onos    文件:OplinkPowerConfigUtil.java   
/**
 * Find oplink port description type from optical ports.
 *
 * @param opsw switch
 * @param portNum the port number
 * @return port oplink port description type
 */
private PortDescType getPortDescType(OpenFlowOpticalSwitch opsw, PortNumber portNum) {
    for (PortDescPropertyType type : opsw.getPortTypes()) {
        List<? extends OFObject> portsOf = opsw.getPortsOf(type);
        for (OFObject op : portsOf) {
            if (op instanceof OFPortOptical) {
                OFPortOptical opticalPort = (OFPortOptical) op;
                if ((long) opticalPort.getPortNo().getPortNumber() == portNum.toLong()) {
                    return PortDescType.values()[opticalPort.getDesc().get(0).getPortType()];
                }
            }
        }
    }
    return PortDescType.NONE;
}
项目:onos    文件:OpenFlowDeviceProvider.java   
private PortDescription buildPortDescription(PortDescPropertyType ptype, OFObject port,
        OpenFlowOpticalSwitch opsw) {
    if (port instanceof OFPortOptical) {
        return buildPortDescription(ptype, (OFPortOptical) port, opsw);
    }
    return buildPortDescription(ptype, (OFExpPort) port);
}
项目:athena    文件:OpenFlowDeviceProvider.java   
private PortDescription buildPortDescription(PortDescPropertyType ptype, OFObject port) {
    if (port instanceof OFPortOptical) {
        return buildPortDescription(ptype, (OFPortOptical) port);
    }
    return buildPortDescription(ptype, (OFExpPort) port);
}
项目:onos    文件:OpenFlowDeviceProvider.java   
/**
 * Build a portDescription from a given a port description describing some
 * Optical port.
 *
 * @param port description property type.
 * @param port the port to build from.
 * @return portDescription for the port.
 */
private PortDescription buildPortDescription(PortDescPropertyType ptype, OFPortOptical port,
        OpenFlowOpticalSwitch opsw) {
    checkArgument(!port.getDesc().isEmpty());

    // Minimally functional fixture. This needs to be fixed as we add better support.
    PortNumber portNo = PortNumber.portNumber(port.getPortNo().getPortNumber());

    boolean enabled = !port.getState().contains(OFPortState.LINK_DOWN)
            && !port.getConfig().contains(OFPortConfig.PORT_DOWN);
    boolean adminDown = port.getConfig().contains(OFPortConfig.PORT_DOWN);
    SparseAnnotations annotations = makePortAnnotation(port.getName(),
                                                       port.getHwAddr().toString(),
                                                       adminDown).build();

    if (port.getVersion() == OFVersion.OF_13
            && ptype == PortDescPropertyType.OPTICAL_TRANSPORT) {
        // At this point, not much is carried in the optical port message.
        LOG.debug("Optical transport port message {}", port.toString());
    } else {
        // removable once 1.4+ support complete.
        LOG.debug("Unsupported optical port properties");
    }

    OFPortDescPropOpticalTransport desc = port.getDesc().get(0);
    switch (desc.getPortSignalType()) {
        // FIXME: use constants once loxi has full optical extensions
        case 2:     // OMS port
            // Assume complete optical spectrum and 50 GHz grid
            Set<OchSignal> signals = null;
            if (opsw instanceof HandlerBehaviour) {
                DriverHandler driverHandler = ((HandlerBehaviour) opsw).handler();
                if (driverHandler != null && driverHandler.hasBehaviour(LambdaQuery.class)) {
                    try {
                        signals = driverHandler.behaviour(LambdaQuery.class).queryLambdas(portNo);
                    } catch (NullPointerException e) {
                        signals = null;
                    }
                }
            }
            Frequency minFreq;
            Frequency maxFreq;
            Frequency channelSpacing;
            if (signals == null || signals.isEmpty()) {
                minFreq = Spectrum.U_BAND_MIN;
                maxFreq = Spectrum.O_BAND_MAX;
                channelSpacing = Frequency.ofGHz(50);
            } else {
                Comparator<OchSignal> compare =
                        (OchSignal a, OchSignal b) -> a.spacingMultiplier() - b.spacingMultiplier();
                OchSignal minOch = Collections.min(signals, compare);
                OchSignal maxOch = Collections.max(signals, compare);
                minFreq = minOch.centralFrequency();
                maxFreq = maxOch.centralFrequency();
                channelSpacing = minOch.channelSpacing().frequency();
            }
            return omsPortDescription(portNo, enabled, minFreq,
                    maxFreq, channelSpacing, annotations);
        case 5:     // OCH port
            OchSignal signal = new OchSignal(GridType.DWDM, ChannelSpacing.CHL_50GHZ, 0, 4);
            return ochPortDescription(portNo, enabled, OduSignalType.ODU4,
                    true, signal, annotations);
        default:
            break;
    }

    return new DefaultPortDescription(portNo, enabled, FIBER, 0, annotations);
}