Changes between Version 6 and Version 7 of Internal/OpenFlow/Controllers/Nox


Ignore:
Timestamp:
Nov 9, 2010, 7:53:00 PM (14 years ago)
Author:
akoshibe
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Internal/OpenFlow/Controllers/Nox

    v6 v7  
    8484}}}
    8585
    86 == 3. Customizing your component ==
     86= 3. Customizing your component =
    8787All applications under nox are found in either netapps., coreapps, or webapps. Each app is contained in a directory that includes code for the applications' modules (e.g. routing modules implementing specific algorithms), and a list, named meta.json, used by nox to find and load modules at startup.
    8888
    8989By itself, your new component only knows how to initiate a channel with an !OpenFlow switch, and to start up the "liveness check" echo requests. This section is a compilation of information on the nox libraries that can be used to define your own controller.
    9090
    91 == 3.1 Adding flags. ==
    92 The `configure` function allows you to define options for your application. When starting nox_core, flags can be specified by the application name, followed by an '=', then your flag(s):
     91== 3.1 The configure function. ==
     92The `configure` function allows you to register the events that the module will respond to via the `Disposition` type function (more detail later on regarding this), and to define options for your application.
     93
     94=== 3.1.1. starting modules with flags ===
     95When starting nox_core, flags can be specified by the application name, followed by an '=', then your flag(s):
    9396{{{
    9497./nox_core -v -i ptcp:6633 switch="noflow"
     
    9699I'm guessing if it can take multiple options, you can string multiple flags by delimiting each option with a comma or another '='.
    97100
     101=== 3.1.2. registering events. ===
     102This is done with the `register_handler` which takes your event's name and allows you to specify a NOX event to bind to it:
     103
     104{{{
     105 register_handler<Flow_in_event>
     106        (boost::bind(&SPRouting::handle_flow_in, this, _1));
     107}}}
     108Here, a Flow_in_event (defined in NOX libraries) is taken as an argument to the module specific Disposition type function `handle_flow_in`.
     109
     110This snippet is taken from the built-in routing module (netapps/routing/sprouting.cc, .hh) which makes an OF switch behave like a router. The sprouting module is fairly complex and can be used to see how a module is built; we'll be using pieces of this module (along with others where specified) throughout this page. 
     111
     112=== 3.1.3. defining flags/options. ===
     113It seems customary to define and check for flags within configure function, but this doesn't have to be the case. For example, in sprouting, there is a separate function called `validate_args`.
    98114 
     115A more "traditional" way of doing this is through the Configuration object (found in  nox/src/nox/component.hh):
     116{{{
     117class Configuration {
     118public:
     119    virtual ~Configuration();
     120   
     121    /* Retrieve a value of an XML configuration key. */
     122    virtual const std::string get(const std::string& key) const = 0;
     123
     124    /* Return true if the XML key exists. */
     125    virtual const bool has(const std::string& key) const = 0;
     126
     127    /* Return all XML keys. */
     128    virtual const std::list<std::string> keys() const = 0;
     129   
     130    /* Return all command line arguments of the component. */
     131    virtual const Component_argument_list get_arguments() const = 0;
     132
     133    /* Return list of arguments. */
     134    virtual const hash_map<std::string, std::string>
     135    get_arguments_list(char d1 = ',', char d2 = '=') const = 0;
     136};
     137}}}
     138
     139This class allows you to input flags as described earlier in 3.1.1. Actually using the class involves something like this (from switch.cc).
     140{{{
     141Switch::configure(const Configuration* conf) {
     142...
     143   BOOST_FOREACH (const std::string& arg, conf->get_arguments()) {
     144        if (arg == "noflow") {
     145            setup_flows = false;
     146        } else {
     147            VLOG_WARN(log, "argument \"%s\" not supported", arg.c_str());
     148        }
     149    }
     150...
     151}}}
     152 
     153== 3.2. Event triggers ==
     154=== 3.2.1 The Disposition type ===
     155
    99156
    100157