Internals of Network Processing

This chapter presents an overview of how network loading and rendering is implemented in OpenVIP. It covers technical details of OpenVIP that are rarely if ever needed in development of OpenVIP plugins. The reader is adviced to consult both reference documentation and source code on details.

Processing a network involves several actions on the side of OpenVIP core library. They happen in three phases: loading of the network, initializing and rendering. Loading and rendering can easily be customized by providing non-default implementation of used algorithms -- e.g. to improve performance when rendering specific networks or to load networks from another file format. Individual steps are briefly discussed below.

Note that you can't take advantage of customizations described in this section if you are using the highlevel API. Direct access through UPF is necessary.

Loading Networks: INetworkLoader

OpenVIP can use any component that implements openvip.INetworkLoader interface to read networks. By default only single loader implementation for reading OpenVIP Network Format is available (its name is in openvip.NETWORK_FORMAT_LOADER constant), but more implementations can be added.

INetworkLoader.Load implementation must - in addition to parsing the file and validating it - do:

  • create modules

  • set its parameters and validate that no required parameter is omitted and all parameters are set to legal values

  • connect modules' connectors, verify that connectors are compatible, ensure consistency of related openvip.Network fields

  • propagate IStreamInfo objects

In the processing of doing this, Load must call EnumParams, SetParams, EnumConnectors and SetStreams on all modules in the network (in this order).

It is clear this process is quite complicated. It is recommended that any new INetworkLoader implementation works by translating its input into the format understood by openvip.NETWORK_FORMAT_LOADER and then calling it's Load.

Rendering: IScheduler

Scheduler is OpenVIP component that plans execution of IModule::Process and IModule::QueryRequirements so that all terminal modules finish rendering. Scheduler can be customized in same manner as the loader and openvip.SCHEDULER_SIMPLE is the standard implementation. Scheduler is given the network together with list of individual passes. It has to process the passes in given order, but it is free to reorder computation within each pass as it sees fit. Typical scheduler will recursively repeat these three actions:

  • call QueryRequirements to obtain list of required data

  • satisfy requirements

  • call Process with obtained data

Putting It All Together

INetworkLoader is used to load the network into memory. If the net passes all validity checks (i.e.INetworkLoader.Load returns true), passes description for IScheduler must be generated and all modules contained in the network initialized. Both is done in src/core/proc_control.cpp and is not customizable (it is simple piece of code that can't be done in much different way). This fixed part of processing only (preparing IScheduler.TaskDesc aside) calls Initialize method of every module that implementes IParametrizable before running the scheduler and Shutdown afterwards. See Process in proc_control.cpp.