Skip to main content

mod_bert — Bit Error Rate Test

mod_bert is a dialplan application module (src/mod/applications/mod_bert) that performs a naive Bit Error Rate Test (BERT) over a live call leg. It works exclusively with G.711 µ-law (PCMU) audio: the module continuously transmits the ITU-T digital milliwatt pattern and compares each received frame against that same pattern, accumulating error samples within a configurable sliding window to derive an error percentage.

Operators reach for mod_bert when qualifying interconnects, verifying codec pass-through, or stress-testing media paths. It fires custom events on sync acquisition, sync loss, and timeout so external tooling can record pass/fail state without inspecting logs.

Loading the Module

The module name for load and modules.conf.xml is mod_bert. It is not present in the default vanilla autoload_configs/modules.conf.xml and must be added manually:

<load module="mod_bert"/>

No special build flags or external libraries are required; the module compiles as part of the standard FreeSWITCH build tree.

Configuration: bert.conf.xml

mod_bert has no shipped configuration file and registers no configuration parameters through switch_xml_config. All tuning is done entirely through channel variables set before the application is executed.

Dialplan Applications

ApplicationPurposeArguments
bert_testRuns a BERT test on the current call leg until the channel hangs up or an error threshold triggers a hangup(none)

bert_test

Answers the channel, then enters a read/write loop that:

  1. Sends the 8-byte G.711 µ-law digital milliwatt pattern repeatedly.
  2. Reads each incoming frame and counts samples that do not match the expected pattern.
  3. At the end of each window period, computes the error percentage and fires the appropriate event.

The application takes no inline arguments; all behaviour is controlled by channel variables (see Channel Variables below).

<action application="bert_test"/>

A typical dialplan context for a loopback BERT test:

<extension name="bert">
<condition field="destination_number" expression="^bert$">
<action application="set" data="bert_timeout_ms=15000"/>
<action application="set" data="bert_max_err=5.0"/>
<action application="set" data="bert_hangup_on_error=true"/>
<action application="bert_test"/>
</condition>
</extension>

Channel Variables

VariableSet / ReadPurpose
bert_window_msReadDuration of each error-rate measurement window in milliseconds. Default: 1000.
bert_timeout_msReadHow long to wait for initial sync before firing a timeout event, in milliseconds. Default: 10000.
bert_max_errReadMaximum tolerated error percentage per window before declaring sync loss. Default: 10.0.
bert_hangup_on_errorReadIf true, hangs up the channel when sync is lost or a timeout fires. Default: unset (no hangup).
bert_debug_io_fileReadBase path for raw µ-law debug files. When set, the module writes <path>.in (received audio) and <path>.out (sent audio).
bert_timer_nameReadName of a FreeSWITCH timer (e.g., soft) to pace write frames independently of read blocking. When unset, no separate timer is used.
bert_stats_sync_lostSetSet to true when sync is lost within a window, false at start.
bert_stats_sync_lost_countSetRunning count of sync-loss events on this channel.

Events

mod_bert fires three custom SWITCH_EVENT_CUSTOM subclasses. All events include the standard channel headers populated by switch_channel_event_set_basic_data.

Event SubclassFired WhenExtra Headers
mod_bert::timeoutThe channel did not reach sync within bert_timeout_ms.(none beyond channel headers)
mod_bert::lost_syncError rate exceeded bert_max_err after a previously synced window.sync_lost_percent, sync_lost_count, cng_count, err_samples
mod_bert::in_syncError rate fell at or below bert_max_err for the first time (sync acquired).(none beyond channel headers)

Source: src/mod/applications/mod_bert