Ctrl K
ring2all.com

🔊 Part 6: Compiling, Packaging, and Configuring High-Performance RTPEngine on Debian 13

Welcome to the sixth installment of our "Debian 13 Clustering & Distribution" series. In the previous parts, we set up our custom APT repository, packaged FreeSWITCH and Kamailio, and deployed high-availability databases and file clusters. In this final guide, we will cover the compilation, packaging, and configuration of Sipwise RTPEngine, the high-performance media proxy. We will walk through building the modular .deb packages, publishing them to our central repository, setting up client-side configuration parameters (such as NAT split-IP mapping), enabling kernel-space packet forwarding for maximum performance, and integrating the engine with Kalixor/Kamailio.

🏗️ Why Use RTPEngine?

RTPEngine is a user-space/kernel-space media proxy that routes voice and video RTP packets between endpoints. It is particularly critical in systems where:

  1. NAT Traversal: Rewrites Session Description Protocol (SDP) payloads to bridge private networks and public networks.
  2. Encryption Bridging: Bridges standard RTP/AVP (used by trunk providers) with encrypted SRTP/SAVPF (used by WebRTC clients).
  3. Low Latency: Bypasses user-space processing entirely using a kernel module, saving CPU cycles and minimizing voice packet jitter.


🛠️ Phase 1: Environment & Dependency Setup

Compiling RTPEngine requires build tools along with development libraries for encryption, codec support (FFmpeg), database caching (Redis), systemd integration, and DKMS (Dynamic Kernel Module Support).

1.1 Install Compiling and Packaging Tools

Bash
apt-get update
apt-get install -y \
  sudo git build-essential devscripts dpkg-dev equivs fakeroot \
  autoconf automake libtool libtool-bin cmake pkg-config \
  wget curl unzip python-is-python3 python3-all-dev \
  python3-setuptools docbook-xsl xsltproc \
  libglib2.0-dev graphviz dh-make

1.2 Install Build Prerequisites

Bash
apt-get install -y \
  debhelper dh-python dkms dh-dkms default-libmysqlclient-dev \
  discount gperf libavcodec-dev libavfilter-dev \
  libavformat-dev libavutil-dev libbcg729-dev \
  libbencode-perl libcrypt-openssl-rsa-perl \
  libcrypt-rijndael-perl libcurl4-openssl-dev \
  libdigest-crc-perl libdigest-hmac-perl libevent-dev \
  libglib2.0-dev libhiredis-dev libio-multiplex-perl \
  libio-socket-inet6-perl libio-socket-ip-perl libiptc-dev \
  libjson-glib-dev libjson-perl libjwt-dev libmosquitto-dev \
  libncurses-dev libnet-interface-perl libopus-dev \
  libpcap-dev libpcre2-dev libsocket6-perl libspandsp-dev \
  libssl-dev libswresample-dev libsystemd-dev libtest2-suite-perl \
  liburing-dev libwebsockets-dev libwww-perl libxtables-dev \
  pandoc pkgconf python3 python3-websockets systemd-dev zlib1g-dev


⚙️ Phase 2: Compiling & Packaging RTPEngine

We clone Sipwise RTPEngine into /usr/src/rtpengine/src and build modular .deb packages.

2.1 Clone the Repository

Bash
mkdir -p /usr/src/rtpengine/deb
git clone -b master https://github.com/sipwise/rtpengine.git /usr/src/rtpengine/src
cd /usr/src/rtpengine/src

2.2 Compile and Package

Clean the repository workspace and run the Debian build script:

Bash
# Clean packaging workspace
fakeroot debian/rules clean

# Compile binary packages (-b builds binary-only, -us/-uc disables signing)
dpkg-buildpackage -us -uc -b -j$(nproc)

# Move all generated packages and build receipts to our deb directory
mv /usr/src/rtpengine/*.deb /usr/src/rtpengine/deb/
mv /usr/src/rtpengine/*.changes /usr/src/rtpengine/deb/ 2>/dev/null || true
mv /usr/src/rtpengine/*.buildinfo /usr/src/rtpengine/deb/ 2>/dev/null || true

The directory /usr/src/rtpengine/deb/ will contain:

ngcp-rtpengine-daemon_.deb: The main RTPEngine proxy daemon. ngcp-rtpengine-kernel-dkms_.deb: The DKMS package that automatically compiles the high-performance kernel module (xt_RTPENGINE) on client nodes. ngcp-rtpengine-recording-daemon_.deb: Optional call recording service. ngcp-rtpengine-utils_.deb: Maintenance and administration utilities. ngcp-rtpengine_.deb: Standard installer meta-package.

🌐 Phase 3: Publishing to the APT Repository Server

Upload the packages to your repository server (IP: , configured in Part 1) to distribute them across client nodes.

3.1 Upload Packages

Bash
scp /usr/src/rtpengine/deb/*.deb root@<YOUR_REPO_IP>:/var/www/pbx-repo/ring2all/trixie/apt/pool/b/base/

3.2 Rebuild the Repository Index

Log into your repository server over SSH and rebuild the repository index:

Bash
ssh root@<YOUR_REPO_IP> "BuildRepoRing2All"

The packages are now available to any server registered to your repository.


🔌 Phase 4: Client-Side Installation & Configuration

On your dedicated target RTPEngine media server:

4.1 Install Packages from Your Custom Repository

Run the repository bootstrap script, update the cache, and install RTPEngine. We must install the correct linux-headers so the kernel module compiles successfully:

Bash
# Bootstrap repository
wget -qO- https://repo.softswitchone.com/apt/setup_repo | bash
apt-get update

# Install compiler headers matching the running kernel
apt-get install -y dkms linux-headers-$(uname -r)

# Install RTPEngine
apt-get install -y ngcp-rtpengine-daemon ngcp-rtpengine-kernel-dkms ngcp-rtpengine-utils ngcp-rtpengine

Verify that the kernel module is compiled and loaded into memory:

Bash
lsmod | grep xt_RTPENGINE
# Expected output: xt_RTPENGINE   32768   0

4.2 Configure RTPEngine (/etc/rtpengine/rtpengine.conf)

Open /etc/rtpengine/rtpengine.conf and configure the following parameters. Pay close attention to NAT split-IP mappings and port bindings:

Ini
[rtpengine]
# --- Network Interfaces ---
# If the server has a public IP and private IP (NAT split-IP mapping):
# Format: logical_name/internal_ip logical_name/external_ip
interface = internal/192.168.10.50 external/76.13.102.50

# --- Port Settings ---
# UDP port range for media (RTP/RTCP packets)
port-min = 16384
port-max = 32768

# --- Control Sockets ---
# UDP port for receiving control instructions from Kamailio/Kalixor
listen-ng = 192.168.10.50:2223

# --- Kernel Space Data Forwarding ---
# Table index (must match the kernel iptables tables configuration)
table = 0

# --- Logging & Security ---
log-level = 5
log-facility = local0
run-as-user = rtpengine
run-as-group = rtpengine

Save the file and restart the daemon:

Bash
systemctl restart ngcp-rtpengine-daemon
systemctl status ngcp-rtpengine-daemon


🚀 Phase 5: High-Performance Kernel-Space Optimization

By default, RTPEngine acts as a user-space proxy: packets enter the kernel, are copied to user-space, processed, copied back to the kernel, and sent. In high-density environments, this copying causes latency and high CPU usage.

By enabling kernel-space forwarding, RTPEngine delegates the packet routing directly to the kernel network stack, achieving wire-speed performance.

5.1 Load the Kernel Module

Verify that the xt_RTPENGINE kernel module loads on boot. It should be automatically registered by DKMS during installation. To force load it manually:

Bash
modprobe xt_RTPENGINE

5.2 Configure kernel tables

The table value in rtpengine.conf is configured to table = 0. Ensure this interfaces with the kernel stack correctly:

Bash
# Create the forwarding table file inside sysfs if not automatically created
echo "add 0" > /proc/rtpengine/control

Review your journal logs to confirm kernel forwarding is enabled:

Bash
journalctl -u ngcp-rtpengine-daemon | grep -i "kernel"
# Expected output: Kernel-space packet forwarding successfully enabled.


🔗 Phase 6: Kalixor/Kamailio Integration

Now we link our SIP router (Kamailio / Kalixor) to our media engine.

6.1 Register the RTPEngine socket in Kamailio

On your Kamailio application server, edit your configuration file (or the database profile) to register the RTPEngine control socket. In Kamailio's kamailio.cfg:

Text
# --- RTPEngine module parameters ---
loadmodule "rtpengine.so"
modparam("rtpengine", "rtpengine_sock", "udp:192.168.10.50:2223")

6.2 Verify the Integration

Restart Kamailio and test the control socket connection:

Bash
kamailio -c -f /etc/kamailio/kamailio.cfg
systemctl restart kamailio

# Query active media engines using Kamailio CLI
kamcmd rtpengine.show all

Kamailio will list the RTPEngine socket status as UP and operational.

Your high-performance RTPEngine media proxy is now fully configured and integrated into your distributed telephony platform!

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?