Ctrl K
ring2all.com

Media Engines Module Documentation

Table of Contents

  1. Module Overview (Technical)
  2. Module Overview (Commercial/Business)
  3. Module Overview (End User/Administrator)
  4. Configuration Categories
  5. Common Settings Reference
  6. Common Scenarios & Examples
  7. Limitations & Important Notes
  8. Troubleshooting Tips
  9. Glossary
  10. Lua Script Status ℹ️


1. Module Overview (Technical)

What Are Media Engines?

Media Engines is a Kamailio / RTPEngine configuration module that defines and manages external RTPEngine server pools. By maintaining node records in the database, the SBC backend can dynamically write the Kamailio configuration files required to balance active audio/video media streams across a network of distributed nodes.

Architecture

Plaintext
┌─────────────────────────────────────────────────────────────────┐
│                  Media Engines Architecture                     │
├─────────────────────────────────────────────────────────────────┤
│                                                                 │
│  SBC Admin UI (React)                                           │
│  ┌──────────────────────────────────────────────────────────┐   │
│  │        Media Engines Page                                │   │
│  │  Define nodes: host, port, weight, active status.        │   │
│  └──────────────────────────────────────────────────────────┘   │
│       │                                                         │
│       ▼ REST API (Fastify)                                      │
│  ┌──────────────────────────────────────────────────────────┐   │
│  │        Database: public.rtpengine_nodes                  │   │
│  └──────────────────────────────────────────────────────────┘   │
│       │                                                         │
│       ▼ Write / Generate config (Apply)                          │
│  ┌──────────────────────────────────────────────────────────┐   │
│  │        /etc/kamailio/sbc-rtpengines.cfg                  │   │
│  │  modparam("rtpengine", "rtpengine_sock", "udp:...")     │   │
│  └──────────────────────────────────────────────────────────┘   │
│       │                                                         │
│       ▼ Kamailio reads configuration                            │
│  ┌──────────────────────────────────────────────────────────┐   │
│  │        Kamailio mod_rtpengine                            │   │
│  │  Splits traffic among active sockets using weights.     │   │
│  └──────────────────────────────────────────────────────────┘   │
│                                                                 │
└─────────────────────────────────────────────────────────────────┘

Background Health Check

The SBC backend implements an autonomous background service (initRtpEngineHealthCheck) that runs every 30 seconds:

  • Sends a UDP ping packet formatted with the RTPEngine ng protocol (d7:command4:pinge) to each active node.
  • Measures network latency in milliseconds.
  • Updates node state (online / offline) and the measured latency directly in the database.
  • Runs an initial quick verification check 5 seconds after backend startup.

Key Tables

TablePurpose
public.rtpengine_nodesStores pool node definitions, status flags, and latency stats.

Key Files

FileDescription
src/modules/media/MediaEnginesPage.tsxFrontend view, modal form, and action controls.
src/modules/rtpengine-nodes/rtpengineController.tsFastify handlers for API CRUD operations, ping triggers, and configuration generation.
src/modules/rtpengine-nodes/rtpengineRoutes.tsFastify route declarations for /api/rtpengine-nodes.
/etc/kamailio/sbc-rtpengines.cfgInclude file loaded by Kamailio containing the active socket pool definition.
---

2. Module Overview (Commercial/Business)

Business Value

Managing external media handlers separates signaling (handled by the SBC/Kamailio) from RTP processing (handled by RTPEngine). This provides distinct benefits:

Without External Media EnginesWith External Media Engines
Single Point of Failure (SPOF) for mediaHigh Availability (HA) failover pools
Hard limit on concurrent call capacityHorizontal scale-out by adding new nodes
Manual, disruptive config file editsGUI-driven pool management without downtime
No insight into media engine healthContinuous real-time status and latency checks

Use Cases

  1. High Call Density Environments
- Distribute CPU-intensive RTP proxying/transcoding across dedicated servers.

  1. Geographical Latency Optimization
- Route media sessions through nodes physically closer to regional trunk providers.

  1. No-Downtime Maintenance
- Deactivate specific engines temporarily for upgrades without dropping active calls on other nodes.


3. Module Overview (End User/Administrator)

What Can You Do?

  • View Active Pool: Monitor a unified grid showing host addresses, port numbers, weights, statuses, real-time latencies, and last probed timestamps.
  • Add/Edit Node Dialog: Define Name, IP/Hostname, UDP control port, load balancer Weight, and Active flag.
  • Manual Ping: Trigger an instantaneous UDP diagnostics test to check server availability.
  • Apply Pool Configuration: Rebuild the Kamailio includes with active sockets.


4. Configuration Categories

When registering or editing an RTPEngine node, the following properties are defined:

  • Name
- Purpose: Unique user-friendly identifier.

- Tooltip: Unique name to identify this RTPEngine node.

  • IP / Hostname
- Purpose: Target network IP address or DNS record.

- Tooltip: IP address or DNS hostname of the external RTPEngine server.

  • Port (UDP)
- Purpose: UDP port where the external RTPEngine process listens for control packets.

- Tooltip: UDP control port where RTPEngine listens (default is 2223).

  • Weight
- Purpose: Load balancing distribution priority.

- Tooltip: Priority weight for load balancing. Higher values receive more traffic.

  • Active Node
- Purpose: Toggle switch to include/exclude the node in Kamailio's active list.

- Tooltip: Whether this node should be included in the active pool for Kamailio.

  • Description
- Purpose: Optional notes (e.g. data center location, provider name).

- Tooltip: Optional notes about this node (e.g. location, provider).


5. Common Settings Reference

ParameterDefaultRequiredDescription
NameYesDescriptive node name.
HostYesIP Address / DNS Hostname of the node.
Port2223YesControl socket port (UDP).
Weight1YesInteger priority (1-100). Higher weights get more call distribution.
ActivetrueYesIf false, the node is excluded from Kamailio's active includes.
DescriptionNoOptional text field for notes.
---

6. Common Scenarios & Examples

Scenario 1: Registering a Secondary RTPEngine Node

  1. Access the Media Engines section.
  2. Click Add Engine Node in the top right.
  3. Provide the details:
- Name: RTP-Node-B

- IP / Hostname: 192.168.10.15

- Port: 2223

- Weight: 2 (Gives this node double the traffic share relative to weight 1 nodes)

- Active: Enabled (Toggle set to Yes)

  1. Click Save. The background service will run a ping test and list the node.

Scenario 2: Node Maintenance and Deactivation

  1. Prior to shutting down an RTPEngine node for OS updates:
  2. Open the edit dialog by clicking the Edit pencil icon next to the target node.
  3. Change the Active Node toggle to No.
  4. Click Save.
  5. Click Apply Config to rebuild /etc/kamailio/sbc-rtpengines.cfg (excluding this socket).
  6. Reload/Restart Kamailio. Calls will gracefully shift to the remaining active nodes.


7. Limitations & Important Notes

WARNING
Configuration Application: Saving a node to the database does not instantly modify Kamailio behavior. You must click Apply Config to write the configuration include file and then restart/reload Kamailio to load the new parameters.
NOTE
Local Node Fallback: If zero active nodes are configured in the dashboard, the apply script automatically writes udp:127.0.0.1:2223 as a fallback setting to avoid breaking signaling.

8. Troubleshooting Tips

Node Status Shows "Offline"

  • Check Firewall: Ensure the SBC can communicate on the UDP control port (default 2223) of the target server.
  • Process Verification: Log into the target node and verify the RTPEngine daemon is active:
Bash
  systemctl status rtpengine
  

  • Control Interface: Ensure rtpengine is started with the correct --listen-ng interface mapping corresponding to the IP defined in the dashboard.

Manual Diagnostics Ping Failures

If you trigger a manual ping and receive a timeout:

  1. Verify the route between SBC and node IP is open.
  2. Test connection with nc or tcpdump on the node:
Bash
   tcpdump -i any udp port 2223
   

  1. Look for incoming ping commands (ping_... d7:command4:pinge) from the SBC.


9. Glossary

TermDefinition
RTPEngineA high-performance proxy for RTP traffic, handling audio/video streams, transcoding, and security.
ng protocolThe control protocol used by Kamailio and utilities to configure media parameters on RTPEngine instances.
Control PortThe UDP socket (typically 2223) where RTPEngine listens for JSON/Bencoded configuration commands.
WeightAn arbitrary integer determining the relative share of calls routed to a given media engine in a load balancer.
---

Lua Script Status ℹ️

No Lua Handler Required

ComponentStatus
Media Enginesℹ️ Pure configuration module — generates Kamailio includes.
Media Engines manages standard server configurations which are written out to native Kamailio include blocks (/etc/kamailio/sbc-rtpengines.cfg). No Lua script hooks are used.
Documentation last updated: May 2026
AI Assistant

👋 Hello! I'm your Ring2All documentation assistant. I can help you find information about configuring and using the Ring2All PBX platform.

How can I help you today?