Ask is moving to Stack Overflow and Serverfault.com! Please use the "opendaylight" tag on either of these sites. This site is now in Read-Only mode

Revision history [back]

click to hide/show revision 1
initial version

If you want a detailed view of how ODL works, I recommend viewing theMD-SAL documentation and comparing it with the l2switch code repository to have an idea of the basics.

Flow rules are installed as per the OpenFlow protocol, which basically involves installing the flow rules in memory, in a data structure referred to as the flow tables (afaik). I'm not sure exactly how to target the memory explicitly, but I know that by querrying the openflow tables from MD-SAL, you can list every installed flow rule and get flow statistics:

private Map<Flow, FlowStatistics> getAllFlows() {
    List<Flow> allFlows = new ArrayList<>();
    Map<Flow, FlowStatistics> allFlowStatistics = new HashMap<>();
    for (int i = 0; i < POLLING_TOTAL_TABLES; i++) {
        Short tableId = (short) (i + POLLING_ROOT_TABLE + 1);

        try {
            InstanceIdentifier<Table> tableIId = MDSalAccessUtils.tableIId(nodeId, tableId);
            Optional<Table> tableOptional = ovsBandwidthPollerImpl.dataBroker
                 .newReadOnlyTransaction()
                .read(LogicalDatastoreType.OPERATIONAL, tableIId).get();

            if(!tableOptional.isPresent()) {
                continue;
            }

            List<Flow> flows = tableOptional.get().getFlow();

            for (Flow flow : flows) {
                allFlows.add(flow);
            }
            for (Flow flow : allFlows) {

                InstanceIdentifier<FlowStatisticsData> flowStatisticsIId = tableIId
                    .child(Flow.class, new FlowKey(flow.getId()))
                    .augmentation(FlowStatisticsData.class);
                Optional<FlowStatisticsData> fsd = ovsBandwidthPollerImpl.dataBroker
                    .newReadOnlyTransaction()
                    .read(LogicalDatastoreType.OPERATIONAL, flowStatisticsIId).get();
                if (fsd.isPresent()) {
                    allFlowStatistics.put(flow, fsd.get().getFlowStatistics());
                }
            }
        } catch (InterruptedException | ExecutionException e) {
            LOG.error("Error while fetching flow statistics");
            continue;
        }
    }
    return allFlowStatistics;
}

If you want a detailed view of how ODL works, I recommend viewing theMD-SAL documentation and comparing it with the l2switch code repository to have an idea of the basics.

Flow rules are installed as per the OpenFlow protocol, which basically involves installing the flow rules in memory, in a data structure referred to as the flow tables (afaik). I'm not sure exactly how to target the memory explicitly, but I know that by querrying the openflow tables from MD-SAL, you can list every installed flow rule and get flow statistics:

private Map<Flow, FlowStatistics> getAllFlows() {
    List<Flow> allFlows = new ArrayList<>();
    Map<Flow, FlowStatistics> allFlowStatistics = new HashMap<>();
    for (int i = 0; i < POLLING_TOTAL_TABLES; i++) {
        Short tableId = (short) (i + POLLING_ROOT_TABLE + 1);

        try {
            InstanceIdentifier<Table> tableIId = MDSalAccessUtils.tableIId(nodeId, tableId);
            Optional<Table> tableOptional = ovsBandwidthPollerImpl.dataBroker
                 .newReadOnlyTransaction()
                .read(LogicalDatastoreType.OPERATIONAL, tableIId).get();

            if(!tableOptional.isPresent()) {
                continue;
            }

            List<Flow> flows = tableOptional.get().getFlow();

            for (Flow flow : flows) {
                allFlows.add(flow);
            }
            for (Flow flow : allFlows) {

                InstanceIdentifier<FlowStatisticsData> flowStatisticsIId = tableIId
                    .child(Flow.class, new FlowKey(flow.getId()))
                    .augmentation(FlowStatisticsData.class);
                Optional<FlowStatisticsData> fsd = ovsBandwidthPollerImpl.dataBroker
                    .newReadOnlyTransaction()
                    .read(LogicalDatastoreType.OPERATIONAL, flowStatisticsIId).get();
                if (fsd.isPresent()) {
                    allFlowStatistics.put(flow, fsd.get().getFlowStatistics());
                }
            }
        } catch (InterruptedException | ExecutionException e) {
            LOG.error("Error while fetching flow statistics");
            continue;
        }
    }
    return allFlowStatistics;
}

Alternatively, I know that Openflow is generally queried with the Openflow utilities, like ovs-ofctl.

ovs-ofctl dump-flows {switch}

... should print all flow rules installed on a switch. This works in mininet too.

If you want a detailed view of how ODL works, I recommend viewing theMD-SAL documentation and comparing it with the l2switch code repository to have an idea of the basics.

Flow rules are installed as per the OpenFlow protocol, which basically involves installing the flow rules in memory, in a data structure referred to as the flow tables (afaik). There are 256 flow tables, and flow pipelining always begins on table 0 (sometimes referred to as the reserved TABLE port). I'm not sure exactly how to target the memory explicitly, but I know that by querrying the openflow tables from MD-SAL, you can list every installed flow rule and get flow statistics:

private Map<Flow, FlowStatistics> getAllFlows() {
    List<Flow> allFlows = new ArrayList<>();
    Map<Flow, FlowStatistics> allFlowStatistics = new HashMap<>();
    for (int i = 0; i < POLLING_TOTAL_TABLES; i++) {
        Short tableId = (short) (i + POLLING_ROOT_TABLE + 1);

        try {
            InstanceIdentifier<Table> tableIId = MDSalAccessUtils.tableIId(nodeId, tableId);
            Optional<Table> tableOptional = ovsBandwidthPollerImpl.dataBroker
                 .newReadOnlyTransaction()
                .read(LogicalDatastoreType.OPERATIONAL, tableIId).get();

            if(!tableOptional.isPresent()) {
                continue;
            }

            List<Flow> flows = tableOptional.get().getFlow();

            for (Flow flow : flows) {
                allFlows.add(flow);
            }
            for (Flow flow : allFlows) {

                InstanceIdentifier<FlowStatisticsData> flowStatisticsIId = tableIId
                    .child(Flow.class, new FlowKey(flow.getId()))
                    .augmentation(FlowStatisticsData.class);
                Optional<FlowStatisticsData> fsd = ovsBandwidthPollerImpl.dataBroker
                    .newReadOnlyTransaction()
                    .read(LogicalDatastoreType.OPERATIONAL, flowStatisticsIId).get();
                if (fsd.isPresent()) {
                    allFlowStatistics.put(flow, fsd.get().getFlowStatistics());
                }
            }
        } catch (InterruptedException | ExecutionException e) {
            LOG.error("Error while fetching flow statistics");
            continue;
        }
    }
    return allFlowStatistics;
}

Alternatively, I know that Openflow is generally queried with the Openflow utilities, like ovs-ofctl.

ovs-ofctl dump-flows {switch}

... should print all flow rules installed on a switch. This works in mininet too.