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

0

how can i create a new module for opendaylight

asked 2017-09-26 14:05:09 -0700

Qasmaoui gravatar image

hello ,

im intrested in how opendaylight store openflow rules ( as i understand it store it in an in-memory database : some sorte of fache ) i need to build a module targetting this in-memory database how can i acces it's content any idea from where to start ?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2017-09-28 05:36:11 -0700

VincentJahjah gravatar image

updated 2017-09-28 05:40:17 -0700

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.

edit flag offensive delete publish link more
Login/Signup to Answer

Question Tools

Follow
1 follower

Stats

Asked: 2017-09-26 14:05:09 -0700

Seen: 21 times

Last updated: Sep 28