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


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

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
                .read(LogicalDatastoreType.OPERATIONAL, tableIId).get();

            if(!tableOptional.isPresent()) {

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

            for (Flow flow : flows) {
            for (Flow flow : allFlows) {

                InstanceIdentifier<FlowStatisticsData> flowStatisticsIId = tableIId
                    .child(Flow.class, new FlowKey(flow.getId()))
                Optional<FlowStatisticsData> fsd = ovsBandwidthPollerImpl.dataBroker
                    .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");
    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

1 follower


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

Seen: 21 times

Last updated: Sep 28