Search in sources :

Example 1 with OFStatsRequest

use of org.projectfloodlight.openflow.protocol.OFStatsRequest in project onos by opennetworkinglab.

the class DefaultOFSwitch method processStatsRequest.

@Override
public void processStatsRequest(Channel channel, OFMessage msg) {
    if (msg.getType() != OFType.STATS_REQUEST) {
        log.warn("Ignoring message of type {}.", msg.getType());
        return;
    }
    OFStatsRequest ofStatsRequest = (OFStatsRequest) msg;
    OFStatsReply ofStatsReply = null;
    switch(ofStatsRequest.getStatsType()) {
        case PORT_DESC:
            List<OFPortDesc> portDescs = new ArrayList<>();
            Set<Port> ports = ofSwitchService.ports(networkId, deviceId);
            ports.forEach(port -> {
                OFPortDesc ofPortDesc = portDesc(port);
                portDescs.add(ofPortDesc);
            });
            ofStatsReply = FACTORY.buildPortDescStatsReply().setXid(msg.getXid()).setEntries(portDescs).build();
            break;
        case PORT:
            OFPortStatsRequest portStatsRequest = (OFPortStatsRequest) msg;
            OFPort ofPort = portStatsRequest.getPortNo();
            List<OFPortStatsEntry> portStatsEntries = new ArrayList<>();
            List<PortStatistics> portStatistics = ofSwitchService.getPortStatistics(networkId, deviceId);
            if (ofPort.equals(OFPort.ANY)) {
                portStatistics.forEach(portStatistic -> {
                    OFPortStatsEntry ofPortStatsEntry = portStatsEntry(portStatistic);
                    portStatsEntries.add(ofPortStatsEntry);
                });
            }
            ofStatsReply = FACTORY.buildPortStatsReply().setEntries(portStatsEntries).setXid(msg.getXid()).build();
            break;
        case METER_FEATURES:
            OFMeterFeatures ofMeterFeatures = FACTORY.buildMeterFeatures().build();
            ofStatsReply = FACTORY.buildMeterFeaturesStatsReply().setXid(msg.getXid()).setFeatures(ofMeterFeatures).build();
            break;
        case FLOW:
            List<OFFlowStatsEntry> flowStatsEntries = new ArrayList<>();
            List<FlowEntry> flowStats = ofSwitchService.getFlowEntries(networkId, deviceId);
            flowStats.forEach(flowEntry -> {
                OFFlowStatsEntry ofFlowStatsEntry = ofFlowStatsEntry(flowEntry);
                flowStatsEntries.add(ofFlowStatsEntry);
            });
            ofStatsReply = FACTORY.buildFlowStatsReply().setEntries(flowStatsEntries).setXid(msg.getXid()).build();
            break;
        case TABLE:
            List<OFTableStatsEntry> ofTableStatsEntries = new ArrayList<>();
            List<TableStatisticsEntry> tableStats = ofSwitchService.getFlowTableStatistics(networkId, deviceId);
            tableStats.forEach(tableStatisticsEntry -> {
                OFTableStatsEntry ofFlowStatsEntry = ofFlowTableStatsEntry(tableStatisticsEntry);
                ofTableStatsEntries.add(ofFlowStatsEntry);
            });
            ofStatsReply = FACTORY.buildTableStatsReply().setEntries(ofTableStatsEntries).setXid(msg.getXid()).build();
            break;
        case GROUP:
            List<Group> groupStats = ofSwitchService.getGroups(networkId, deviceId);
            List<OFGroupStatsEntry> ofGroupStatsEntries = new ArrayList<>();
            groupStats.forEach(group -> {
                OFGroupStatsEntry entry = ofGroupStatsEntry(group);
                ofGroupStatsEntries.add(entry);
            });
            ofStatsReply = FACTORY.buildGroupStatsReply().setEntries(ofGroupStatsEntries).setXid(msg.getXid()).build();
            break;
        case GROUP_DESC:
            List<OFGroupDescStatsEntry> ofGroupDescStatsEntries = new ArrayList<>();
            List<Group> groupStats2 = ofSwitchService.getGroups(networkId, deviceId);
            groupStats2.forEach(group -> {
                OFGroupDescStatsEntry entry = ofGroupDescStatsEntry(group);
                ofGroupDescStatsEntries.add(entry);
            });
            ofStatsReply = FACTORY.buildGroupDescStatsReply().setEntries(ofGroupDescStatsEntries).setXid(msg.getXid()).build();
            break;
        case DESC:
            ofStatsReply = FACTORY.buildDescStatsReply().setXid(msg.getXid()).build();
            break;
        default:
            log.debug("Functionality not yet supported for type {} statsType{} msg {}", msg.getType(), ofStatsRequest.getStatsType(), msg);
            break;
    }
    if (ofStatsReply != null) {
        log.trace("request {}; reply {}", msg, ofStatsReply);
        channel.writeAndFlush(Collections.singletonList(ofStatsReply));
    }
}
Also used : OFStatsReply(org.projectfloodlight.openflow.protocol.OFStatsReply) OFGroup(org.projectfloodlight.openflow.types.OFGroup) Group(org.onosproject.net.group.Group) OFGroupDescStatsEntry(org.projectfloodlight.openflow.protocol.OFGroupDescStatsEntry) Port(org.onosproject.net.Port) OFPort(org.projectfloodlight.openflow.types.OFPort) ArrayList(java.util.ArrayList) OFPortStatsRequest(org.projectfloodlight.openflow.protocol.OFPortStatsRequest) FlowEntry(org.onosproject.net.flow.FlowEntry) OFFlowStatsEntry(org.projectfloodlight.openflow.protocol.OFFlowStatsEntry) OFStatsRequest(org.projectfloodlight.openflow.protocol.OFStatsRequest) PortStatistics(org.onosproject.net.device.PortStatistics) TableStatisticsEntry(org.onosproject.net.flow.TableStatisticsEntry) OFPortDesc(org.projectfloodlight.openflow.protocol.OFPortDesc) OFGroupStatsEntry(org.projectfloodlight.openflow.protocol.OFGroupStatsEntry) OFTableStatsEntry(org.projectfloodlight.openflow.protocol.OFTableStatsEntry) OFPort(org.projectfloodlight.openflow.types.OFPort) OFPortStatsEntry(org.projectfloodlight.openflow.protocol.OFPortStatsEntry) OFMeterFeatures(org.projectfloodlight.openflow.protocol.OFMeterFeatures)

Example 2 with OFStatsRequest

use of org.projectfloodlight.openflow.protocol.OFStatsRequest in project onos by opennetworkinglab.

the class CalientFiberSwitchHandshaker method sendMsg.

@Override
public final void sendMsg(OFMessage m) {
    OFMessage newMsg = m;
    if (m.getType() == OFType.STATS_REQUEST) {
        OFStatsRequest sr = (OFStatsRequest) m;
        log.debug("Rebuilding stats request type {}", sr.getStatsType());
        switch(sr.getStatsType()) {
            case FLOW:
                OFCalientFlowStatsRequest request = this.factory().buildCalientFlowStatsRequest().setCookie(((OFFlowStatsRequest) sr).getCookie()).setCookieMask(((OFFlowStatsRequest) sr).getCookieMask()).setMatch(this.factory().matchWildcardAll()).setOutGroup(((OFFlowStatsRequest) sr).getOutGroup().getGroupNumber()).setOutPort(OFPort.ANY).setTableId(TableId.ALL).setXid(sr.getXid()).setFlags(sr.getFlags()).build();
                newMsg = request;
                break;
            case PORT:
                // TODO
                break;
            default:
                break;
        }
    }
    super.sendMsg(newMsg);
}
Also used : OFMessage(org.projectfloodlight.openflow.protocol.OFMessage) OFStatsRequest(org.projectfloodlight.openflow.protocol.OFStatsRequest) OFFlowStatsRequest(org.projectfloodlight.openflow.protocol.OFFlowStatsRequest) OFCalientFlowStatsRequest(org.projectfloodlight.openflow.protocol.OFCalientFlowStatsRequest)

Example 3 with OFStatsRequest

use of org.projectfloodlight.openflow.protocol.OFStatsRequest in project onos by opennetworkinglab.

the class OplinkSwitchHandshaker method sendMsg.

@Override
public final void sendMsg(OFMessage m) {
    List<OFMessage> messages = new ArrayList<>();
    messages.add(m);
    if (m.getType() == OFType.STATS_REQUEST) {
        OFStatsRequest sr = (OFStatsRequest) m;
        log.debug("OPLK Switch: Rebuilding stats request type {}", sr.getStatsType());
        switch(sr.getStatsType()) {
            case PORT:
                // Send experiment status request for Optical Fiber switch to device
                // Note: We just re-use calient message for a short term.
                OFCalientPortStatsRequest portRequest = this.factory().buildCalientPortStatsRequest().setXid(sr.getXid()).setFlags(sr.getFlags()).build();
                messages.add(portRequest);
                break;
            default:
                break;
        }
    } else {
        log.debug("OPLK Switch: sends msg:{}, as is", m.getType());
    }
    super.sendMsg(messages);
}
Also used : OFMessage(org.projectfloodlight.openflow.protocol.OFMessage) OFStatsRequest(org.projectfloodlight.openflow.protocol.OFStatsRequest) OFCalientPortStatsRequest(org.projectfloodlight.openflow.protocol.OFCalientPortStatsRequest) ArrayList(java.util.ArrayList)

Example 4 with OFStatsRequest

use of org.projectfloodlight.openflow.protocol.OFStatsRequest in project onos by opennetworkinglab.

the class OplinkEdfaHandshaker method sendMsg.

@Override
public final void sendMsg(OFMessage m) {
    List<OFMessage> messages = new ArrayList<>();
    messages.add(m);
    if (m.getType() == OFType.STATS_REQUEST) {
        OFStatsRequest sr = (OFStatsRequest) m;
        log.debug("OPLK EDFA rebuilding stats request type {}", sr.getStatsType());
        switch(sr.getStatsType()) {
            case PORT:
                // add Oplink experiment message to get the port's current power
                messages.add(oplinkUtil.buildPortPowerRequest());
                // add experiment message to get adjacent ports
                messages.add(oplinkUtil.buildPortAdjacencyRequest());
                break;
            default:
                break;
        }
    } else {
        log.debug("OPLK EDFA sends msg:{}, as is", m.getType());
    }
    super.sendMsg(messages);
}
Also used : OFMessage(org.projectfloodlight.openflow.protocol.OFMessage) OFStatsRequest(org.projectfloodlight.openflow.protocol.OFStatsRequest) ArrayList(java.util.ArrayList)

Example 5 with OFStatsRequest

use of org.projectfloodlight.openflow.protocol.OFStatsRequest in project onos by opennetworkinglab.

the class OplinkRoadmHandshaker method sendMsg.

@Override
public final void sendMsg(OFMessage m) {
    List<OFMessage> messages = new ArrayList<>();
    messages.add(m);
    if (m.getType() == OFType.STATS_REQUEST) {
        OFStatsRequest sr = (OFStatsRequest) m;
        log.debug("OPLK ROADM rebuilding stats request type {}", sr.getStatsType());
        switch(sr.getStatsType()) {
            case PORT:
                // add Oplink experiment message to get the port's current power
                messages.add(oplinkUtil.buildPortPowerRequest());
                // add experiment message to get adjacent ports
                messages.add(oplinkUtil.buildPortAdjacencyRequest());
                break;
            default:
                break;
        }
    } else {
        log.debug("OPLK ROADM sends msg:{}, as is", m.getType());
    }
    super.sendMsg(messages);
}
Also used : OFMessage(org.projectfloodlight.openflow.protocol.OFMessage) OFStatsRequest(org.projectfloodlight.openflow.protocol.OFStatsRequest) ArrayList(java.util.ArrayList)

Aggregations

OFStatsRequest (org.projectfloodlight.openflow.protocol.OFStatsRequest)5 ArrayList (java.util.ArrayList)4 OFMessage (org.projectfloodlight.openflow.protocol.OFMessage)4 Port (org.onosproject.net.Port)1 PortStatistics (org.onosproject.net.device.PortStatistics)1 FlowEntry (org.onosproject.net.flow.FlowEntry)1 TableStatisticsEntry (org.onosproject.net.flow.TableStatisticsEntry)1 Group (org.onosproject.net.group.Group)1 OFCalientFlowStatsRequest (org.projectfloodlight.openflow.protocol.OFCalientFlowStatsRequest)1 OFCalientPortStatsRequest (org.projectfloodlight.openflow.protocol.OFCalientPortStatsRequest)1 OFFlowStatsEntry (org.projectfloodlight.openflow.protocol.OFFlowStatsEntry)1 OFFlowStatsRequest (org.projectfloodlight.openflow.protocol.OFFlowStatsRequest)1 OFGroupDescStatsEntry (org.projectfloodlight.openflow.protocol.OFGroupDescStatsEntry)1 OFGroupStatsEntry (org.projectfloodlight.openflow.protocol.OFGroupStatsEntry)1 OFMeterFeatures (org.projectfloodlight.openflow.protocol.OFMeterFeatures)1 OFPortDesc (org.projectfloodlight.openflow.protocol.OFPortDesc)1 OFPortStatsEntry (org.projectfloodlight.openflow.protocol.OFPortStatsEntry)1 OFPortStatsRequest (org.projectfloodlight.openflow.protocol.OFPortStatsRequest)1 OFStatsReply (org.projectfloodlight.openflow.protocol.OFStatsReply)1 OFTableStatsEntry (org.projectfloodlight.openflow.protocol.OFTableStatsEntry)1