Skip to main content

Hook-types

Sometimes forwarded sample data shall be modified or filtered. VILLASnode supports hooks for this purpose. Hooks are simple callback functions which are called whenever a message is processed by a path.

There are several built-in hooks for:

  • collecting, show & reset statistics
  • drop reordered messages
  • verify message metadata
  • handle simulation restarts
  • remapping values of a sample
  • overwriting / updating timestamps
  • converting data-types
  • down-sampling

But main goal of this mechanism is to provide extensibility for the end user. Example applications for hooks might be:

  1. Filter sample values
  2. Manipulate sample values: FIR
  3. Transform sample values: FFT, DCT
  4. Update network emulation settings based on sample values

Hooks can be added to the processing pipeline in three places:

  • Node-read: Every time a sample is received from a node
  • Node-write: Every time a sample is sent to a node
  • Path: Every time a sample is processed within a path

Some hooks are built-in hooks which are by default enabled without a corresponding section in the configuration file. Usually, built-in hooks have no configurable options.

Currently, the following node-hook-types are supported:

TypeBuilt-inNode-readNode-writePathStateComment
averageyesyesyesstableCalculate average over some signals
caststableCast signals types
decimateyesyesyesstableDownsamping by integer factor
dpyesyesyesalphaTransform to/from dynamic phasor domain
dropyesyesstableDrop messages with reordered sequence numbers
dumpyesyesyesstableDump data to stdout
ebmalphaEnergy-based Metric
fixyesyesstableFix received data by adding missing fields
jitter_calcyesstableCalc jitter, mean and variance of GPS vs NTP TS
limit_rateyesyesyesstableLimit sending rate
luayesyesyesstableLua scripting support
pmu_dftyesyesyesstableCaluclate the phasor on a sample window
pps_tsyesyesyesstableTimestamp samples based on a PPS signal/edge within the sample
restartyesyesstableCall restart hooks for current node
roundyesyesyesstableRound floating point and complex signals to decimal digits
rmsyesyesyesstableCalculate the RMS value of a signal
scaleyesyesyesstableScale signals by a factor and add offset
shift_seqyesyesstableShift sequence number of samples
shift_tsyesyesstableShift timestamps of samples
skip_firstyesyesyesstableSkip the first samples
statsyesstableCollect statistics for the current path
tsyesyesyesstableOverwrite origin timestamp of samples with receive timestamp
printyesyesyesstablePrint the message to stdout

Writing custom hook functions

ToDo

This still needs to be written.