Changes between Initial Version and Version 1 of Documentation/ariba_0_9_x


Ignore:
Timestamp:
Jun 21, 2013, 4:03:10 PM (11 years ago)
Author:
hock@…
Comment:

move wiki/ariba_0_9 to wiki/Documentation/ariba_0_9_x

Legend:

Unmodified
Added
Removed
Modified
  • Documentation/ariba_0_9_x

    v1 v1  
     1== '''Ariba 0.9.x Series''' ==
     2
     3The ariba 0.9.x development branch brings great performance and stability improvements at cost of backward compatibility.
     4
     5The network traffic was optimized on the binary level, and also some prior design descisions have been reconsidered to provide easier, faster and less error-prone interfaces. Therefore the new ariba 0.9.x series is not compatible with prior ariba version; in terms of network connectivity, and also most applications won't compile without some modifications. The latter is especially due the introduction of a new configuration format (using JSON or XML) and a cleaner interface to startup ariba in the application. Also bluetooth support and the bootstrap modules have not been ported to some new internal interfaces, yet and can't be used at the moment.
     6
     7Ariba 0.9.x is still under development and is currently in a testing phase. However you can get the code from our svn: [https://i72projekte.tm.uka.de/SpoVNet-KA/entwicklung/ariba/trunk Ariba-SVN]. We appreciate bug reports and feedback.
     8
     9''Please note that the [https://svn.tm.kit.edu/trac/spovnet-base/wiki/BaseGuide ariba documentation] still refers to the old ariba 0.8.x series. This page presents the new interfaces and changes of ariba 0.9.x.''
     10
     11=== ''' Changelog ''' ===
     12
     13A brief list of changes between ariba 0.8.x and 0.9.x:
     14
     15improvements:
     16    - new message classes (reboost, zero-copy)
     17    - "fast path" for direct links (skip overlay layer)
     18    - link-properties accessible from the application
     19    - System-Queue can call boost::bind functions
     20    - protlib compatibility removed (32bit overhead saved in every message)
     21    - addressing2, (a new interface for ip-/bluetooth addresses)
     22    - Address-Discovery discoveres only addresses on which we're actually listening
     23    - ariba serialization usage reduced (still used in Overlay-Msg)
     24    - Node::connect, easier and cleaner interface to start-up ariba from the application
     25    - ariba configs via JSON, XML, etc (boost::property_tree)
     26    - keep-alive overhead greatly reduced
     27    - (relayed) overlay links can actually be closed now
     28    - lost messages are detected in most cases
     29    - notification to the application when link is transformed into direct-link
     30    - overlay routing: send message to second best hop if it would be dropped otherwise
     31    - Sequence-Numbers (only mechanisms so far: upward compatibility)
     32    - various small fixes
     33 
     34regressions:
     35    - bluetooth is not yet working again
     36    - bootstrap modules deactivated
     37    - liblog4xx is not working (use cout-logging)
     38
     39== Using ariba 0.9.x ==
     40
     41To get to code, please check out the latest trunk version from our svn: [https://i72projekte.tm.uka.de/SpoVNet-KA/entwicklung/ariba/trunk Ariba-SVN]
     42
     43=== ''' Configuration format ''' ===
     44Ariba 0.9.x uses a new configuration format, based in boost::property_tree. Hence you can use the JSON format to store ariba configs. Other formats (e.g. XML) are supported, too. Please refor to the documentation: [http://www.boost.org/doc/libs/1_46_1/doc/html/property_tree.html Boost.PropertyTree]
     45
     46'''Example configuration file'''
     47{{{
     48//JSON
     49{
     50    "ariba": {
     51        "node_name": "Node1",
     52        "spovnet_name": "pingpong",
     53       
     54        "listen_on": [
     55            {"category": "TCPIP", "addr": "::", "port": 5000 }
     56        ],
     57       
     58        "bootstrap": {
     59            "direct": [
     60                {"category": "TCPIP", "addr": "127.0.0.1", "port": 41322 }
     61            ],
     62        }
     63    }
     64}
     65}}}
     66
     67  - As in earlier ariba versions the ''node_name'' and the ''spovnet_name'' can be specified. Please keep in mind that node names must be unique and all nodes must use the same spovnet name in order to communicate.
     68  - ''listen_on'' describes an array of local addresses, on which ariba will listen.
     69    - Since bluetooth is currently disabled, `category` must be `TCPIP`
     70    - `addr` can either be an ipv4 or ipv6 address ("::" is the ipv6 any-address)
     71    - a port can be specified, if port 0 is given, ariba will try to find a usable port (starting with port 41322)
     72  - ''bootstrap'' defines the bootstrap hints, the nodes ariba tries to connect in order to join the spovnet
     73    - Since the bootstrap modules are currently disabled, only direct bootstrapping is available
     74    - ''direct'' describes an array of remote endpoints ariba tries to connect to (same syntax as the `listen_on` field)
     75
     76Note that all ariba related config is stored in a field named `ariba`. The same JSON file can be used to store application specific config data as well.
     77
     78=== ''' Ping-pong example ''' ===
     79The ping-pong code in the SVN trunk differs from the detailed explanation in the wiki. Especially the new config format (see above) and `Node::connect`, the new easy and clean interface to start-up ariba (see below) is used.
     80
     81Please note that the ping-pong example still uses the old deprecated ariba messages (see next section "Message formats" for more information).
     82
     83{{{
     84#!cpp
     85void PingPong::startup()
     86{
     87    using boost::property_tree::ptree;
     88    using boost::property_tree::json_parser::read_json;
     89   
     90    logging_info( "[PINGPONG]\t starting up PingPong service ... " );
     91
     92    // read config
     93    ptree config;
     94    try
     95    {
     96        read_json(config_file, config);
     97    }
     98    catch ( exception& e )
     99    {
     100        logging_warn("ERROR: Failed to read config file »" << config_file << "«: ");
     101        logging_warn(e.what());
     102        logging_warn("---> Using fallback config.");
     103       
     104        config.put("ariba.spovnet_name", "pingpong");
     105    }
     106   
     107    // use node name also in the application
     108    name = config.get("ariba.node_name", "NO_NAME");
     109   
     110    // bind communication and node listener
     111    node.bind( this );                              /*NodeListener*/
     112    node.bind( this, PingPong::PINGPONG_SERVICEID); /*CommunicationListener*/
     113
     114    // connecting
     115    logging_debug( "connecting ... " );
     116
     117    node.connect(config.get_child("ariba"));
     118
     119    // ping pong started up...
     120    logging_info( "[PINGPONG]\t pingpong starting up with"
     121                        << " [spovnetid " << node.getSpoVNetId().toString() << "]"
     122                        << " and [nodeid " << node.getNodeId().toString() << "]" );
     123}
     124}}}
     125
     126  - `ptree config;` is an yet empty instance of boost::property_tree::ptree.
     127  - `read_json(config_file, config);` reads a config file (like the JSON file showed in the previous section) into the ptree instance `config`. The path of the JSON file is stored in `config_file`.
     128    - If the read fails, the except handler prints a warning and initiates a default config directly within the code via: `config.put("ariba.spovnet_name", "pingpong");`
     129  - The node variable is defined as attribute: `ariba::Node node;` (initialized with the standard constructor). Thoe follwing registers the callbacks from ariba:
     130    - `node.bind( this );`
     131    - `node.bind( this, PingPong::PINGPONG_SERVICEID);`
     132  - The following command starts ariba with the config stored in the ptree
     133    - `node.connect(config.get_child("ariba"));`
     134
     135''' Interfaces '''
     136  - The callbacks (functions in the application that are called from ariba) are declared in:
     137    - `ariba/CommunicationListener.h`.
     138  - The ariba interface (functions in ariba that can be called from the application) are declared in:
     139    - `ariba/Node.h`.
     140
     141=== ''' Message formats ''' ===
     142
     143The ping pong example still uses the old deprecated ariba::message messages with the ariba built-in serialization. For future applications please use the new reboost::message_t messages. Data is stored in high efficient zero-copy buffers of type reboost::shared_buffer_t. These buffers hold plain data, so you have to serialize the data "on your own".
     144
     145We recommend third-party serialization libraries like:
     146  - Protocol Buffers (http://en.wikipedia.org/wiki/Protocol_Buffers)
     147  - Message Pack      (http://en.wikipedia.org/wiki/MessagePack)
     148
     149
     150''' reboost::message_t '''
     151
     152The reboost::message_t is an Copy-on-Write Message with Shared Buffers.
     153
     154A message holds a limited (defined by `message_max_buffers`, typically `8`) number of shared buffers. One can add new buffers and messages in front and at the end of a message. If the no. of buffers exceed `message_max_buffers`, then the two smallest successive buffers are compacted to one buffer.
     155
     156Typical operations:
     157  - reboost::message_t msg;
     158    - creates an empty message
     159  - void message_t::push_back(shared_buffer_t)
     160  - void message_t::push_front(shared_buffer_t)
     161  - shared_buffer_t message_t::linearize()
     162  - size_t message_t::size()
     163
     164For more information refer to the source code: `ariba/utility/transport/messages/message.hpp`
     165
     166''' reboost::shared_buffer_t '''
     167
     168A simple shared buffer.
     169
     170Important: if not shared, a buffer is writable. After the buffer is shared, the buffer is immutable. It uses shared_ptr/default allocators and prints error messages to `cerr` if buffers leaked at the end of the program (only in `debug` mode).
     171
     172Typical operations:
     173
     174  - shared_buffer_t(size_t size)
     175    - creates a shared buffer of a specific size
     176    - allocates memory and frees after destruction
     177  - shared_buffer_t(unsigned char* buffer, size_t size)
     178    - creates a shared buffer from existing data
     179    - transfers ownership
     180    - frees memory after destruction
     181  - shared_buffer_t shared_buffer_t::operator()(size_t index, size_t size = 0)
     182    - return sub-buffer
     183    - example: `shared_buffer_t sub_buff = buff(15)`;
     184  - const uint8_t* data = buff.data();
     185    - access data as array (read-only)
     186  - uint8_t* data = buff.mutable_data();
     187    - access data as array (writable)
     188    - NOTE: only if buffer is not shared, yet
     189
     190For more information refer to the source code: `ariba/utility/transport/messages/shared_buffer.hpp`
     191
     192
     193=== ''' System Queue ''' ===
     194
     195Instead of implementing `ariba::utility::SystemEventListener` and multiplex different events in the `handleSystemEvent` callback, it's now possible to schedule a function call into the System Queue, using boost::bind.
     196
     197This may look like this:
     198
     199{{{
     200#!cpp
     201void MyClass::some_function()
     202{
     203    string param1 = "hello";
     204    int param2 = 5;
     205
     206    // schedule call of "myfunction(param1, param2)" into System Queue
     207    SystemQueue::instance().scheduleCall(
     208            boost::bind(
     209                    &MyClass::myfunction,
     210                    this,
     211                    param1,
     212                    param2)
     213        );
     214}
     215
     216void MyClass::myfunction(string param1, int param2)
     217{
     218    // do something
     219}
     220}}}
     221
     222Also `SystemQueue::scheduleCall` takes an optional second parameter `uint32_t delay`, to schedule a callback the given amount of milli-seconds in the future.