Hello App – Mul Controller App development note

This post will demonstrate how to write an application for Mul Controller.

Prerequisites

1. MuL Controller code and other required packages/libraries. Please refer to this post for more detailed instruction.

2. Average C language knowledge

Sample Application

A sample application for MuL controller can be found here .  Such an application is called a system app since it hooks up with internal apis of MuL controller.  (Another form of application is web-based application which makes use of REST/python apis which is not mentioned here and is covered here )  

Breakdown of the “hello” app:

1. Initialization and Registration

module_init(hello_module_init);

The above registers the entry point for the application which will be invoked during init time.

2. Application registration with mul-core

Registration is the first step to do before we can push flows, watch network events from the app

hello_module_init() -

mul_register_app_cb(NULL, /* Application specific arg */
                    HELLO_APP_NAME, /* Application Name */
                    C_APP_ALL_SW, /* Send any switch's notification */
                    C_APP_ALL_EVENTS, /* Send all event notification per switch */
                    0, /* If any specific dpid filtering is requested */
                    NULL, /* List of specific dpids for filtering events */
                    &hello_app_cbs); /* Event notifier call-backs */

3. React to events

static void
hello_sw_add(mul_switch_t *sw)
{
    /* Add few default flows in this switch */
    hello_install_dfl_flows(sw->dpid);
    c_log_debug("switch dpid 0x%llx joined network",
                 (unsigned long long)(sw->dpid));
}

In the above code snippet we add some default flows to a switch whenever it joins the network. Please check the function  hello_install_dfl_flows() in hello.c for more information how to push flows using Mul apis.

There you go !! A completely working network app on openMUL in less than 200 lines of code.

More advanced examples of applications can be  found here and here.

Advertisements

One thought on “Hello App – Mul Controller App development note

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s