Menu

AFP usage

There are three possibilities to use AFP:

  1. AFP in the Abstract Network Layer
  2. AFP in the Application Layer
  3. AFP using the core API

AFP in the Abstract Network Layer

AFP is integrated in the Abstract Network Layer of famouso. Thus, it is used automatically if it is not disabled by the underlying Network Layer or your famouso configuration. In case you want to disable it or change the default configuration, see Changing AFP configuration used in the Abstract Network Layer. This is also useful to reduce resource consumption, especially on micro-controller platforms. See AFP resource consumption on micro-controllers for general hints on reducing resource consumption.

AFP in the Application Layer

AFP can be used at the Application Layer as well. This is useful if it is disabled in the Abstract Network Layer (e.g. if the Network Layer does not support it), if you want to transmit large events or if your application wants to benefit from forward error correction.

The convenient way is to utilize famouso::mw::afp::AFPPublisherEventChannel and famouso::mw::afp::AFPSubscriberEventChannel which extend famouso's PublisherEventChannel and SubscriberEventChannel with automatic AFP usage.

There are only a few differences:

  1. You must #include "mw/afp/AFPPublisherEventChannel.h" or/and #include "mw/afp/AFPSubscriberEventChannel.h".
  2. An AFP configuration is needed, see How to configure AFP.
  3. You have to define which MTU the AFP event channels should use (maximum size of fragments including header). If the MTU is known at compile time, it can should be used as template argument for AFPPublisherEventChannel (to enable some compile time checks). Otherwise the MTU template argument must be set to zero to choose a template specialization supporting MTU selection at time of channel construction.
  4. The AFP event channels offer an event type parameter allowing to choose another event type. This might have a larger maximum size for example. For AFPSubscriberEventChannel the parameter of the callback mus have this event type as well.

An example of how to use the AFP event channel with large events can be found in the file tst/approved/AFP/famcat.cc.

AFP using the core API

An alternative to AFP event channels described in the previous section is to use the core API directly. Using these API is not so convenient, but has other advantages.

For example you can...

  • ...change the fragmentation loop. You may generate some output, publish fragments to multiple channels or do anything else in between.
  • ...employ famouso::afp::DefragmentationProcessorKeepEventSupport to keep events for later processing without copying the data.
  • ...use AFP without famouso. The AFP defragmentation relies on the guarantee of lower layers that none of the fragments handed over to AFP is corrupted.

For fragmentation you need to #include "mw/afp/Fragmenter.h" and utilize the class famouso::mw::afp::Fragmenter. To learn how to use the API you can have a look at the example tst/approved/AFP/core_al_publish.cc, at include/mw/afp/AFPPublisherEventChannel.h or include/mw/anl/AbstractNetworkLayer.h.

Defragmentation requires #include "mw/afp/Defragmentation.h" and to use the classes famouso::mw::afp::DefragmentationProcessor and famouso::mw::afp::DefragmentationStep. Examples can be found in tst/approved/AFP/core_al_subscribe.cc, include/mw/afp/AFPSubscriberEventChannel.h or include/mw/anl/AbstractNetworkLayer.h.