Appearance
How it works
This page explains what PBXsight is made of and what happens, step by step, when you start a test: who opens which connection, what goes on the wire, how audio is sent and measured, where the PBX-side numbers come from, and what ends up on disk. Read it once before your first real test — most surprises in results (a missing MOS, a setup time that looks too high, calls that don't show up as test traffic) are explained here.
First step: nothing to do here — read it once before your first real test, or come back when a result surprises you.
One program
PBXsight is a single Go binary. Everything runs in one process:
| Part | What it does |
|---|---|
| Web UI + API | The Vue UI is embedded in the binary and served by the same HTTP server as the REST API (default 127.0.0.1:8080, HTTPS optional). REST is used for actions and for loading data; a WebSocket (/ws) pushes one tick per second with the live PBX state and the run in progress. Every request needs a login — see Users and roles. |
| Runner | Plans and validates a test, enforces the safety limits, allows one run at a time (the always-on watch runs beside it), registers the phones, starts the caller engine, collects numbers every second and computes the verdict at the end. |
| Caller engine | Places the SIP traffic of load tests: calls (INVITE, digest authentication, CANCEL, BYE) and registrations, at a controlled rate. |
| Virtual phones | Test extensions that PBXsight registers like real phones: the callers of every call test, and the callees of calls between test extensions and busy hour. |
| Media engine | Sends a test tone over RTP or SRTP for every answered call and measures the audio that comes back. |
| Collectors | Read the PBX side: FreeSWITCH over the Event Socket (ESL), Kamailio over JSON-RPC, rtpengine through the small pbxsight-agent. One set per PBX profile, all connected at once. |
| Storage | SQLite (one file, default ./pbxsight.db) for runs, per-second samples, profiles, extension sets, schedules and users; a folder runs/<run id>/ per run for its logs. |
Why one process: nothing to install besides the binary, no external SIP tool, and the caller engine, the media engine and the collectors share one clock. That shared clock is what makes per-call joins (the tester's setup time against FreeSWITCH's timestamps) and one-way audio delay possible.
The caller engine and virtual phones
Callers are phones
Real phones register first and then place calls over the connection they registered on. PBXsight does the same:
- Before the first call, every caller extension registers as a virtual phone (REGISTER, then the digest round on
401/407). Phones register at min(10,safety.max_registration_rate) per second, so 200 callers take about 20 s. The Dashboard and New test page show a Test starting card with the progress and a Stop button meanwhile. - Each call is then sent over its caller's registration connection — the same TCP/TLS connection, or UDP socket, the phone registered on. The connection is already up, so the setup time measures the call, not a TLS handshake.
- Calls are spread round-robin over the callers. With a fixed number of calls smaller than the number of callers, only as many callers register as there are calls.
- A caller whose phone didn't register places no calls; if none registered, the start is refused with the most common reason (e.g.
REGISTER: 403 Forbidden).
What a virtual phone does while it is registered:
| Behaviour | Value | Why |
|---|---|---|
| Connections | One per phone (its own user agent): TCP/TLS connection or UDP socket | Like a real device; the SIP entry point sees one connection per extension. |
| Requested expiry | Callers 3600 s; callees 300 s (busy hour: the form's Registration expires, default 300 s) | Callers re-register rarely, so they add next to no load during a run. |
| Re-REGISTER | At a random 60–90 % of the granted expiry | Phones that registered together don't re-register in waves. |
| Keepalive | CRLF every 25 s on TCP/TLS | Proxies close idle connections; real phones send these too. |
| Lost connection | Checked every second; reconnect and re-register (retry after 10 s on failure) | A dropped connection doesn't silently end the test for that phone. |
| TLS | The server certificate is not verified, no client certificate | Test PBXes often use self-signed certificates. |
| Other requests | OPTIONS, NOTIFY, INFO, MESSAGE answered 200 OK | Keeps the PBX's qualify/keepalive checks happy. |
| After the run | REGISTER Expires: 0 for every phone, 50 at a time, all within 2 minutes | Leaves the registrar clean. |
Registration tests are the exception: there the extensions are the load. Each extension gets its own user agent and connection (with the same CRLF keepalive), registers at the test's rate, re-registers on its interval, and un-registers at the end — see Registration.
All traffic goes to one address
The profile's SIP host is resolved to its IPv4 addresses at the start of a run. With several addresses (for example two proxies behind one name) the run uses one of them — the one you pick in the New test form, or a random one. Every request of the run, including CANCEL, ACK and in-dialog requests, is sent to that address; the tester never resolves tenant domains in Request-URIs. The address used is stored with the run.
The tester's own address in Via, Contact and SDP is the profile's local IP, or, when empty, the address of the interface that routes to the SIP host. The media IP defaults to the local IP.
A call on the wire
- INVITE with an SDP offer: one codec (G.722 by default, or PCMA/PCMU) plus
telephone-event,ptime 20;RTP/SAVPwith an SDESa=cryptokey when the profile's media mode issrtp, otherwiseRTP/AVP. Only one codec is offered so the audio the engine sends always matches what was negotiated. - The PBX challenges (401 or 407); the engine answers with ACK and repeats the INVITE with credentials.
- Provisional responses (100, 180, 183), then 200 OK with the SDP answer, then ACK.
- Audio flows for the hold time, then the tester sends BYE and expects 200 OK.
Setup time runs from sending the first INVITE to receiving the 200 OK, the challenge round trip included — that is what a user experiences between dialling and the call being connected (for the echo test, which answers at once). It is broken down further on Setup time and its breakdown.
Timers. Until the authenticated INVITE is sent (or ringing starts when there is no challenge), every response must arrive within 8 s; otherwise the call counts as timeout (an INVITE that got a 100 Trying is then CANCELled; one with no response at all is not, as SIP requires). From then on the PBX has 30 s to answer; after that the engine sends CANCEL and counts no_answer. A BYE that gets no final response within 8 s counts as BYE failed. Over UDP, retransmissions follow the SIP transaction timers.
During the hold. A BYE from the PBX is answered 200 OK and counted as hung up by PBX. A re-INVITE inside the call (session timer, hold) is answered with the original SDP. A new INVITE to a caller phone is refused (480 — callers take no calls).
Failures are counted by their final response code (486, 503, 404, …), or as timeout, no_answer, connect_error, transport_error, or aborted (the run was stopped while the call was ringing).
Pacing
The engine starts each call 1 ÷ rate seconds after the previous one (at 4 CPS, every 250 ms). Once a second the runner sets the current rate: a ramp rises linearly, Find the limit follows its steps, busy hour follows its traffic model. A rate change applies at once.
Max concurrent calls caps the calls in progress. When the cap is full, the next call waits for a free slot; there is no catch-up burst afterwards (a call due more than 200 ms ago starts now instead of bunching up). So at a steady rate:
calls up ≈ CPS × (setup time + hold) ≈ CPS × hold
and a cap below that silently lowers the achieved rate — the New test form warns, and the Call rate chart shows placed below target.
Worked example: how much is "2 CPS, 30 s hold"?
- New calls: 2 per second → 120 per minute.
- Calls up at a steady rate: 2 × 30 = 60, plus a few in setup.
- Media: 60 streams × 50 packets/s = 3000 packets/s sent by the tester and about as many coming back.
- For calls between test extensions the PBX carries 60 A-legs and 60 B-legs: 120 channels.
Calls between test extensions
c1 is the caller's Call-ID; FreeSWITCH passes the header on, which pairs the two legs' streams. In this mode (and in busy hour) PBXsight also plays the callee. The callee extensions register as virtual phones before the first call; the caller dials the callee's extension number, FreeSWITCH runs its dialplan and bridges the call to a B-leg towards the callee's registered contact, and the B-leg reaches the virtual phone over its own registration connection (the phone never listens on a port, like a phone behind NAT).
The callee phone:
- accepts only test traffic: an INVITE carrying this run's
X-PBXsight-Runheader, or from one of this run's caller extensions. Anything else gets603 Decline— a real call that happens to reach a test extension is not answered. - answers
200 OKwith one codec, preferring the run's codec when it was offered, so the call stays free of transcoding. The offer's media profile must match the profile's media mode (SRTP witha=crypto, or plainRTP/AVP); otherwise it answers488. - sends audio from a second media engine (the phones' engine, on its own ports) for the hold time, and hangs up itself 30 s after the caller's hold if the caller's BYE never arrives. In busy hour the phone draws a random hold per call and hangs up itself.
The caller's INVITE carries X-PBXsight-Call: <caller's Call-ID>. FreeSWITCH copies X- headers to the B-leg, so the callee sees the same value. That value links the two media streams of one call: each side knows when the other sent each frame, and since both engines run in one process with one clock, the one-way delay per direction is simply arrival time minus the other side's send time.
The media engine
Media mode is a profile setting:
| Mode | What flows during the hold |
|---|---|
none | Nothing: SDP only. Signaling tests; FreeSWITCH may end long holds with MEDIA_TIMEOUT. No MOS. |
rtp | Plain RTP from the media engine. |
srtp | SRTP with SDES keys (AES_CM_128_HMAC_SHA1_80), a random key per run. Use it when the path requires SRTP (e.g. rtpengine forcing RTP/SAVP for TLS clients). |
Calls between test extensions and busy hour need rtp or srtp.
The signal. A tone at 400.5 Hz, 1 s on / 1 s off, encoded in the call's codec (G.722, PCMA or PCMU), sent in 20 ms frames: 50 packets per second per call, each frame sent at its exact time relative to the stream's start (no drift). The odd 400.5 Hz makes every tone frame of the 2-second loop unique, so a frame that comes back can be recognised and matched to the moment it was sent.
When a stream starts. The caller engine writes the PBX's SDP answer of each answered call to the run's media.log; the runner reads that file every 100 ms and starts a stream towards the address and port in the answer (with the PBX's SRTP key for decrypting its audio). The stream sends for the hold time and keeps listening 1 s longer for late echo.
Sockets. The engine binds tester.media_sockets UDP sockets (default 4): RTP on tester.media_port, +2, +4, +6 (default 16000, 16002, 16004, 16006), RTCP on each port + 1. A call's socket is chosen from a hash of its Call-ID, so the INVITE can name its port before the stream exists. Each socket has its own receive loop and send worker, because one UDP socket is serialized by the operating system — more sockets carry more streams. The virtual phones' engine uses the ports right after (default 16008–16015). All port numbers and firewall rules are on Ports and firewall.
RTCP (tester.rtcp, on by default). Every 5 s each stream sends a compound RTCP packet — a sender report with a reception report of the audio coming back, plus the CNAME — from its RTP port + 1 to the remote's RTP port + 1 (the offer has no rtcp-mux); SRTCP in srtp mode. Media relays such as rtpengine compute their per-call MOS from these reports.
What is measured (per call, when it ends):
| Measurement | Echo test (calls to a number) | Calls between test extensions |
|---|---|---|
| Loss | Round trip: frames that didn't come back, from the returning stream's sequence numbers | Per direction |
| Jitter | RFC 3550 interarrival jitter of the returning stream | Per direction |
| Delay | Round trip: arrival − send time of the same frame | One way: arrival − the other engine's send time |
| MOS | E-model estimate from round trip, jitter and loss | Per direction, from 2 × one-way delay |
| Late frames | Frames the engine sent ≥ 60 ms after their time (or never) — the tester fell behind | Both engines |
The MOS estimate is a simplified E-model:
effective delay = round trip ÷ 2 + 2 × jitter + 10 ms R = 93.2 − effective ÷ 40 (effective < 160 ms) R = 93.2 − (effective − 120) ÷ 10 (otherwise) R = R − 2.5 × loss % MOS = 1 + 0.035 R + 0.000007 R (R − 60)(100 − R), capped to 1 … 4.5
Delay matching needs the payload to come back unchanged. If the PBX transcodes (a different codec on the way back), loss and jitter are still measured, but the round-trip check is skipped. Details and worked examples: Audio quality and MOS.
The data sources
The tester measures the whole call from the outside. The PBX-side sources each see one component from the inside.
FreeSWITCH (ESL)
A persistent connection to the Event Socket (default port 8021), reconnecting with backoff.
- Polls —
show calls count,show channels count,show registrations countandstatus(sessions, sessions per second, idle CPU where the FreeSWITCH version reports it): every 1 s while a run is active, every 5 s otherwise (esl.poll_interval,esl.idle_poll_interval). - Events —
CHANNEL_CREATE,CHANNEL_ANSWER,CHANNEL_HANGUP_COMPLETE(with hangup cause, SIP status and thertp_audio_in_*statistics of the leg) and the sofia registration eventsregister,unregister,expire,register_failure. - Channel list —
show channels as jsonevery 5 s during call tests and watches when the stuck-call check is on.
From these come: calls and channels on the PBX, registrations, hangup causes, FreeSWITCH's MOS of the audio it received on each leg, FreeSWITCH's idle CPU, the A/B-leg timestamps behind the setup breakdown, and stuck calls.
Kamailio (JSON-RPC, optional)
One URL per Kamailio, polled every 5 s during a run (30 s otherwise): core.uptime, stats.fetch all, tls.info when available and core.version on connect. The counters of all Kamailios are summed. PBXsight's own polls are subtracted (Kamailio counts them like SIP requests). Restarts are detected from the uptime.
rtpengine (via pbxsight-agent, optional)
rtpengine's control interface has no access control, so PBXsight doesn't talk to it over the network. A small read-only pbxsight-agent runs on each rtpengine host, reads rtpengine's Prometheus metrics and its ng interface locally (ping, statistics, list, query — nothing else is possible), plus CPU from /proc, and serves them over HTTP with a token and an allow-list. PBXsight polls each agent every 5 s during a run (30 s otherwise) and, during runs, fetches a per-call summary that it joins to the run's calls by SIP Call-ID.
What each source sees — and doesn't
| Source | Sees | Doesn't see |
|---|---|---|
| Tester (caller + media engine) | Every SIP response and its timing, setup time per call, failures by code, audio loss/jitter/delay/MOS per call, its own CPU | Where time or packets were lost between it and FreeSWITCH; anything about other traffic |
| FreeSWITCH ESL | Channels, calls, registrations, hangup causes, leg timestamps (dialplan, callee leg), FreeSWITCH's inbound audio quality, CPU, all traffic on the PBX | Requests Kamailio rejected or dropped (they never reach FreeSWITCH), what happens before the INVITE arrives, the relay's view of the media, audio quality in the direction FreeSWITCH sends |
| Kamailio | Requests received, transactions, replies it sent itself (its own 403/404/503), drops, TCP/TLS connections, shared memory, restarts | Who was rejected (counters only, no per-call data), anything inside FreeSWITCH, media |
| rtpengine | Sessions, timeouts (media stopped without a hangup), packet errors, offer processing time, ports in use, kernel vs. userspace forwarding, MOS from RTCP, host and rtpengine CPU; per call: packets each way, one-way media | SIP signaling beyond its offer/answer/delete, FreeSWITCH, calls that bypass the relay. Its numbers are host totals: all calls, not only the test's |
That is why the diagnosis combines them: a setup time that grows while FreeSWITCH's idle CPU falls points at FreeSWITCH; one that grows while Kamailio's open transactions climb but rtpengine's offer time stays flat means Kamailio is waiting for something behind it. The rules are on What to look at.
Every source except the tester is optional. Without ESL, load tests still run and give the tester's view; the PBX-side cards, the FreeSWITCH MOS check, the setup breakdown and stuck calls are missing, and a PBX watch can't start. Cards and hints for a missing source are simply left out.
Test traffic tagging
A PBX under test usually carries other traffic too, and it all arrives from the same proxy address. To tell its own traffic apart, PBXsight tags every request:
| Tag | Where | Used for |
|---|---|---|
X-PBXsight-Run: <run id> | Every REGISTER and INVITE | FreeSWITCH exposes it as variable_sip_h_X-PBXsight-Run on the channel events: the call belongs to this run. Callee phones accept only INVITEs with it (or from a run caller). |
User-Agent: pbxsight/<run id> | Every request | Registration events carry no X- headers, so they are matched by the user agent. |
X-PBXsight-Call: <Call-ID> | Every INVITE | Joins the tester's setup time of a call with FreeSWITCH's A-leg (per-call before FreeSWITCH), and links the two media streams of a call between test extensions. |
| Extension + domain | The run's extension set | An event of a test extension (caller, registering user, or the B-leg towards a callee) in exactly that domain also counts, even when a header got lost. The domain must match: the same extension number in another tenant is not test traffic. |
A run's ESL counters (test view) contain only matching events; the Dashboard's global counters contain everything. The filter is set before the phones register, so their first REGISTERs count. A PBX watch has no filter: it records all traffic.
Run ids look like 20261127-142305-k3fz (start time plus four random characters).
A run, from start to finish
- Plan and validate. The request is checked against the extension set and the profile's safety limits (allowed destinations, max CPS, concurrency, registration rate, number of virtual phones, estimated duration) and the criteria. All problems come back together (
422). Without a valid licence the start is refused (402); while another run is active or starting,409. - Prepare. Pick the target address, determine the local and media IP, open the media engine's sockets, set the ESL test filter and switch the collectors to their fast poll interval.
- Register phones. Callees first, then callers, at up to 10 per second. Stop works in this phase: no more REGISTERs, the phones registered so far un-register, and the run is recorded as
stopped. - Run. The caller engine places calls (or registrations); the media engine starts a stream per answered call. Once a second the runner sets the rate, collects the counters of the engine, the media engine, the phones, ESL, Kamailio, rtpengine and the tester's CPU into one sample, stores it, and pushes it to the browsers. For busy hour and find the limit the samples also fill trend windows (one per step in find the limit, which may end the run early after failed steps).
- Stop. The run ends when its calls are done (a number of calls), its calling period is over (a duration), the limit rule ends it, or someone presses Stop. Calls in progress finish their hold; whatever is still up hold + 15 s later is hung up (CANCEL while ringing, BYE when answered). The runner also enforces a deadline of estimated duration + hold + 15 s + 30 s, capped at
safety.max_duration. Shutting PBXsight down hangs up at once. - Finish. With ESL, wait 1.5 s for late events; then un-register the phones, take a last sample, compute the summary (totals, percentiles, audio, setup breakdown, components, windows, limit) and the verdict, and store them. Status is
completed, orstoppedwhen stopped by a user or the deadline.
A PBX watch has the same frame without steps 3 and 4's traffic: it needs ESL to be connected at the start, records all traffic (no test filter) every second for its duration, and ends with the same kind of summary, trend windows and verdict. See PBX watch.
What is stored
| Where | What |
|---|---|
test_runs (SQLite) | One row per run: type, profile, extension set, who started it, status, times, the parameters with the resolved plan, the effective criteria, the target address used, and the summary with the verdict (JSON). A free-text label for comparisons. |
samples | One JSON document per second of the run: rates, counters, active calls, setup times, audio, PBX, Kamailio, rtpengine and CPU fields. Missing data is stored as null, so charts show gaps, not zeros. |
counters | SIP response codes and hangup causes of the run. |
runs/<run id>/ (tester.work_dir) | caller.log (the run's log and the SIP stack's warnings; no passwords), media.log (the SDP answer per answered call, hangups), phones.log (the virtual phones), watch.log (a watch's failures, at most 2000 lines). |
Deleting a run removes its rows and its folder. The HTML report and exports are produced from this stored data at any time. Secrets in the database (ESL passwords, agent tokens, SIP passwords) are encrypted with a key file next to it — see Secrets at rest and backups.
PBX profiles
A profile is one system under test: its SIP entry point and transport, media mode and IPs, ESL, Kamailio and rtpengine sources, stuck-call thresholds, safety limits and default pass/fail criteria. One installation can hold several (dev, QA, a staging copy); all profiles' collectors stay connected, so the Dashboard shows each one live, and the profile picker in the top bar decides which one you work with. Extension sets, runs and schedules belong to a profile. Only one run at a time still applies across all profiles; the always-on watch is the exception and runs beside load tests. See PBX profiles.