Skip to content
sidhantjohnaindPublic

About

High-performance native SIP B2BUA server bridging JioFiber VoIP (Jio IMS) to any standard SIP softphone (Linphone, MicroSIP, Zoiper) over LAN or VPN.

Topics

Resources

Stars

3 stars

Watchers

0 watching

Forks

Latest commit

Β 

History

126 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

JioFiber SIP B2BUA

A lightweight, native SIP Back-to-Back User Agent (B2BUA) that bridges JioFiber VoIP (Jio IMS) to any standard SIP softphone β€” over LAN, Tailscale, ZeroTier, WireGuard, or any VPN.

No Docker. No Asterisk. No cloud. Runs as a single binary.


Features

  • Zero-dependency binary β€” single executable for Windows, Linux x86_64, Linux ARM64, and RISC-V 64
  • Embedded Native OTP Provisioner β€” automatically requests OTP and provisions credentials directly from your Jio router without needing Python
  • Standard SIP UDP Transport: Listens on UDP port 5061 for all softphones (MicroSIP, Linphone, GS Wave, etc.)
  • Upstream Carrier TLS Transport: Secure TLS v1.2 (5068) to Jio IMS router/ONT
  • Strict Port Binding: Binds cleanly to 5061 and exits immediately if port is occupied
  • Automatic SIP registration with Jio IMS with self-healing credential rotation recovery
  • Full call flow bridging β€” outgoing calls, incoming calls, BYE, CANCEL, re-INVITE
  • Multi-network support β€” LAN, Tailscale, ZeroTier, WireGuard, OpenVPN
    • Per-call dynamic source IP detection using OS kernel routing table (getsockname connect trick)
    • Solves one-way audio and call teardown failures across VPN overlays
    • Zero static IP configuration needed
  • Robust Teardown Handling β€” clean SIP CANCEL & BYE handling without double-hangup assertions
  • PUBLISH / presence passthrough for softphone status
  • Zero SSD wear logging β€” 512 KB RAM ring-buffer + Windows Named Pipe (\\.\pipe\jio_b2bua_logs)
  • Codec support β€” Native AMR-WB (16 kHz), AMR-NB (8 kHz), PCMA, PCMU, telephone-event DTMF

Performance & Architecture Improvements vs Precursor Projects

Compared to earlier Python/Asterisk/Docker implementations (such as jiofiber-sip-proxy, JFC-microsip, and Asterisk bridge setups), this native C++ B2BUA delivers significant performance, resource, and operational enhancements:

Performance & Feature Metric Precursor Projects (Python / Docker / Asterisk) Native C++ B2BUA (sipserver)
Memory Footprint (RAM) ~250 MB – 1.5 GB (Python VM, Docker overhead, Asterisk daemon) ~8 MB – 15 MB RAM (Ultra-lightweight native process)
Packet Forwarding Latency ~20 ms – 50 ms (Python GIL contention & virtual container network bridges) < 1 ms Sub-millisecond latency (Native C++ multi-threaded PJSIP stack)
Binary & Dependencies Requires Python 3, Pip packages, Docker Engine, or full Asterisk stack Zero dependencies β€” Single ~1.7 MB compiled binary
Provisioning Flow External Python scripts or manual HTTP web forms 100% Native Embedded C++ Provisioner (OTP request & credential extraction inside binary)
Disk & SSD Impact Continuous disk IO log writes and container storage wear Zero SSD Wear β€” 512 KB RAM ring-buffer + Windows Named Pipe stream
VPN Overlay Routing Static IP binding (causes 1-way audio / disconnects over Tailscale/WireGuard) Dynamic OS Kernel Routing (getsockname) β€” dynamic multi-interface IP detection
Local Softphone Signaling Unencrypted complex signaling Standard SIP UDP (5061) β€” universal compatibility with all softphones (MicroSIP, Linphone, GS Wave)
Port Collision Handling Silent failures or background process hangs Strict Port Binding β€” instant fail-fast detection if port 5061 is occupied

Quick Start

⚑ 1-Line Copy & Paste Installers

πŸͺŸ Windows (PowerShell):

Open PowerShell and paste:

irm https://raw.githubusercontent.com/sidhantjohnaind/sipserver/master/install_windows.ps1 | iex

🐧 Linux (x86_64 / ARM64 / RISC-V):

Open Terminal and paste:

curl -sSL https://raw.githubusercontent.com/sidhantjohnaind/sipserver/master/install_linux.sh | sudo bash

πŸ“¦ Download Pre-Built Binaries & Installers

Go to Releases to download standalone packages:

Platform Download Link Package Name Type / Notes
Windows x64 (1-Click Installer) πŸš€ Download 64-bit Setup (JioFiber_B2BUA_Setup_x64.exe) JioFiber_B2BUA_Setup_x64.exe ⚑ 1-Click Windows GUI Installer (Auto-configures Firewall, Service & Shortcuts)
Windows x64 (Standalone MSVC) πŸ“₯ Download b2bua_msvc.exe b2bua_msvc.exe ⚑ Native MSVC Executable (Dual Windows Service + Console Mode)
Linux x86_64 Standalone 🐧 Download b2bua-linux-amd64 b2bua-linux-amd64 βœ… Native Linux AMD64 binary with AMR-NB / G.711
Linux ARM64 Standalone 🐧 Download b2bua-linux-arm64 b2bua-linux-arm64 βœ… Pre-built for Raspberry Pi / ARM64 Routers / SBCs
Linux RISC-V 64 Standalone 🐧 Download b2bua-linux-riscv64 b2bua-linux-riscv64 βœ… Pre-built for RISC-V 64-bit SBCs / VisionFive / Milk-V
Linux 1-Click Script 🐧 Download install_linux.sh install_linux.sh ⚑ 1-Click Linux Installer (Auto-detects Arch, Firewall, Systemd)

Windows on ARM (Snapdragon X Elite / Surface Pro ARM / Windows 11 ARM64): Windows 11 ARM64 includes Microsoft's Prism x64 emulation engine β€” the standard b2bua_msvc.exe (x64) runs on all Windows ARM devices with near-native speed and zero configuration needed. A native ARM64 build script (src/build_win_arm64.py) is also provided if you have the MSVC ARM64 cross-compile toolchain installed.

2. Provision credentials (one-time)

The provisioner is built directly into the binary (100% pure C++).

  • Interactive CLI / First Run:
    ./b2bua --provision              # Linux
    b2bua_msvc.exe --provision       # Windows
    • Prompts for your Jio router IP (default 192.168.29.1) and the OTP sent to your registered Jio mobile number.
    • Automatically whitelists your device, fetches your SIP credentials, and saves .env.
  • Windows 1-Click PowerShell (install_windows.ps1): Automatically detects if .env is missing, opens b2bua_msvc.exe --provision in a console window for OTP entry, and then registers and starts the Windows Service.
  • Windows GUI Setup (JioFiber_B2BUA_Setup_x64.exe): Installs b2bua_msvc.exe and, on a first-time install (when .env is missing), launches b2bua_msvc.exe --console so you can enter your OTP and confirm SUCCESS: Registered with Jio IMS!. Once you close that console window (Ctrl+C), the installer starts the JioFiberB2BUA background service.
  • CLI flags: --provision / --otp (provision .env and exit), --auto-otp (allow one-time interactive OTP prompt on 403), --env <path> (use a specific .env file), --console / -c (Windows console mode).

πŸ”„ Universal Multi-Boot & Dual-Boot Bidirectional Sync Tools

If you multi-boot (Windows 11 / Windows 10 / Ubuntu / Debian / Arch) on the same machine, or need to transfer credentials to another PC, use the universal sync utilities:

  • 🐧 From Linux (./b2bua_sync.sh):
    ./b2bua_sync.sh        # Interactive menu
    ./b2bua_sync.sh auto   # Auto-detects newer timestamp & synchronizes across drives
    ./b2bua_sync.sh push   # Pushes Linux configuration to all detected Windows/NTFS partitions
    ./b2bua_sync.sh pull   # Pulls Windows configuration into Linux & restarts service
    ./b2bua_sync.sh export # πŸ“¦ Exports 1-Click ZIP Archive (JioFiber_Config_Backup.zip) to Desktop
    ./b2bua_sync.sh import # πŸ“₯ Imports configuration directly from a ZIP Archive
    ./b2bua_sync.sh diff   # Compares config files across both OSes
  • πŸͺŸ From Windows (b2bua_sync.bat):
    • Double-click b2bua_sync.bat to scan all drive letters (C: through Z:) and sync directly with other Windows/Linux partitions, or export/import the portable JioFiber_Config_Backup.zip archive with 1 click.

3. Run & Deployment Options

πŸͺŸ Windows:

  • 1-Click PowerShell Setup (install_windows.ps1) [Recommended]:
    • Downloads b2bua_msvc.exe, runs --provision interactively if .env is missing, configures Firewall rules, and registers + starts the JioFiberB2BUA service.
  • 1-Click GUI Setup (JioFiber_B2BUA_Setup_x64.exe):
    • Configures Windows Service, Firewall rules, and Start Menu / Desktop shortcuts.
  • Manual Batch & PowerShell Scripts:
    • Run Console Mode: Double-click run_windows.bat
    • Install Service: Right-click scripts/install_windows_service.bat -> Run as Administrator
    • Uninstall Service Only: Right-click scripts/uninstall_windows_service.bat -> Run as Administrator
    • Complete Uninstall: Run uninstall_windows.ps1 as Administrator (removes Windows Service & Firewall rules)
    • Free Stale Ports: Double-click scripts/kill_ports.bat to clear port 5061.

🐧 Linux:

  • 1-Click Systemd Service Installer [Recommended]:
    sudo bash install_linux.sh
    (Or via curl: curl -sSL https://raw.githubusercontent.com/sidhantjohnaind/sipserver/master/install_linux.sh | sudo bash)
  • Manual & Uninstall Scripts:
    • Complete Uninstall: sudo ./uninstall_linux.sh (removes systemd service & firewall rules)
    • Run in Terminal / WSL: chmod +x scripts/run_wsl.sh && ./scripts/run_wsl.sh (or ./b2bua)
    • Free Stale Ports: chmod +x scripts/kill_ports.sh && ./scripts/kill_ports.sh

πŸ“Š Linux Service Management:

  • Status Check: sudo systemctl status jiofiber-b2bua
  • View Live Logs: sudo journalctl -u jiofiber-b2bua -f
  • Restart Service: sudo systemctl restart jiofiber-b2bua

4. Configure your softphone

Setting Value
SIP Server / Domain <your-pc-ip>:5061
Transport UDP
Username any (e.g. 100 or 101)
Password any (e.g. 1234)

Tailscale / VPN users: Use your Tailscale / VPN IP (e.g. 100.x.x.x:5061) as the SIP server in your softphone. The B2BUA automatically detects and routes across the correct VPN interface.

Softphone (Linphone / MicroSIP / GS Wave)
  ↕  SIP UDP port 5061
[B2BUA Proxy]  ←── .env credentials
  ↕  TLS v1.2 port 5068 (Carrier Encrypted)
Jio IMS / ONT (192.168.29.1)
  ↕
PSTN / Mobile Networks

The B2BUA acts as a full SIP proxy:

  • Listens on UDP & TCP 5061 for local softphones (Linphone, Sipnetic, MicroSIP)
  • Registers upstream with Jio IMS over TLS 5068
  • Bridges all call legs transparently with native AMR-WB (16 kHz HD Voice), AMR-NB (8 kHz), and G.711 PCMA/PCMU audio
  • Rewrites Contact and SDP headers per-call to match the correct network interface

πŸŽ™οΈ CRITICAL: Audio Quality & AMR Codec Configuration (Must Read)

Warning

Use only SIP clients that support AMR (AMR/8000) (such as baresip with amr.so, Linphone, Sipnetic, or GS Wave) and set AMR/8000 as the top-priority codec. Clients without AMR/8000 (such as stock MicroSIP, which falls back to PCMA/PCMU) force G.711 β†’ PCM β†’ AMR transcoding, which causes robotic voice on the receiver side.

Available codecs depend on the particular softphone build. AMR-NB, PCMA, and PCMU are narrowband; AMR-WB can carry wideband speech when the negotiated call path preserves it. The conference bridge decodes and re-encodes audio even when both call legs negotiate AMR; it does not currently provide encoded-packet passthrough. See Linux audio regression and source build for the isolated known-audio test and verified build procedure.

πŸͺŸ MicroSIP Audio Setup (Windows):

In MicroSIP, click Menu βž” Settings (βš™οΈ) βž” Audio:

  • Audio Codecs: Move AMR/8000/1 (or AMR-WB/16000/1) to the top of the enabled codecs list (followed by L16/8000/1).
  • VAD (Voice Activity Detection): Enable (Checked) β€” eliminates background microphone hiss when silent.
  • Echo Cancellation (EC):
    • If using Headphones / Headsets: Keep EC disabled or mic volume moderate to prevent voice suppression.
    • If using Loudspeakers: Keep EC enabled to prevent acoustic feedback.

πŸ“± Linphone / Sipnetic / GS Wave Setup (Android / iOS):

  • In Settings βš™οΈ βž” Audio βž” Codecs:
    • Enable AMR-WB (16000 Hz) and AMR (8000 Hz).
    • Place them at the highest priority above PCMA/PCMU.

Building from Source

For Linux ARM64 or AMD64, the Docker source build compiles PJSIP with its standard build system and includes an isolated audio regression target. It does not reuse checked-in executables. For an opt-in G.722 client and 16 kHz conference, see the wideband path and validation guide.

Note: Stock PJSIP 2.15.1 is used with two small Jio IMS compatibility patches provided in patches/ (applied automatically using python apply_patches.py). All B2BUA proxy logic is contained in src/b2bua.cpp.

Step 1 β€” Download stock PJSIP 2.15.1

Download the official release and extract it:

# Option A: GitHub release
wget https://github.com/pjsip/pjproject/archive/refs/tags/2.15.1.tar.gz
tar -xzf 2.15.1.tar.gz
mkdir -p third_party
mv pjproject-2.15.1 third_party/

# Option B: Direct source zip (Windows)
# Download from: https://github.com/pjsip/pjproject/releases/tag/2.15.1
# Extract to: third_party\pjproject-2.15.1\

Step 2 β€” Apply Jio IMS Compatibility Patches

Run the automated cross-platform patch script once after extracting PJSIP:

python apply_patches.py

This applies two small compatibility patches to PJSIP 2.15.1:

  1. opencore_amr.c: Enforces octet-aligned AMR, sets bitrate to 12.2kbps (Mode 7), echoes mode-set in SDP, and disables VAD for Jio IMS.
  2. stream.c: Enables trace logging for jitter buffer frame retrieval.

Step 3 β€” Build Binaries & 1-Click Installers

Windows x64 Binary & Inno Setup Installer:

python src/build_opencore_amr.py
python src/build_msvc_pjsip.py
"C:\Program Files (x86)\Inno Setup 6\ISCC.exe" installer.iss

Output: bin/windows-x64/b2bua_msvc.exe & JioFiber_B2BUA_Setup_x64.exe

Windows ARM64 (MSVC cross-compile):

python src/build_win_arm64.py

Output: bin/windows-arm64/b2bua_win_arm64.exe

Linux x86_64 (native / WSL):

python3 src/build_wsl.py        # full build
bash scripts/build_wsl_linux.sh # fast incremental rebuild

Output: bin/linux-amd64/b2bua

Linux ARM64 (cross-compile):

# Install cross-compiler first:
sudo apt install gcc-aarch64-linux-gnu g++-aarch64-linux-gnu

python3 src/build_arm64.py

Output: bin/linux-arm64/b2bua

Linux RISC-V 64-bit (cross-compile):

# Install cross-compiler:
sudo apt install gcc-riscv64-linux-gnu g++-riscv64-linux-gnu

python3 src/build_riscv64.py

Output: bin/linux-riscv64/b2bua

What the build scripts do

The build scripts (src/build_*.py and scripts/build_wsl_linux.sh) compile PJSIP 2.15.1 source alongside src/b2bua.cpp into standalone binaries. No system PJSIP install is needed.


Configuration Reference (.env)

File Storage Locations (.env)

Environment / Mode Configuration (.env) Storage Path Notes
Windows Service Mode C:\Program Files\JioFiberB2BUA\.env install_windows.ps1 copies an existing .env or runs b2bua_msvc.exe --provision
Windows Portable / Console Current working directory or same directory as b2bua_msvc.exe Can also be overridden with --env <path>
Linux Systemd Service Directory where install_linux.sh was executed WorkingDirectory=$SCRIPT_DIR configures systemd to use local folder
Fallback Paths $HOME/.jio_b2bua.env or /etc/jio_b2bua.env Checked automatically if .env is not in CWD/exe directory

.env Variable Reference

Variable Description Example / Default
IPV4_ADDRESS Your PC's LAN IP 192.168.29.195
LOCAL_PORT UDP SIP port for softphones 5061
TLS_PORT TLS port to Jio router 5068
RTP_PORT Base RTP port 52000
PUBLIC_ID Your Jio SIP URI sip:+91XXXXXXXXXX@br.wln.ims.jio.com
SIP_AUTH_USER SIP auth username 91XXXXXXXXXX@br.wln.ims.jio.com
SIP_PASSWORD SIP password xxxxxxxxxx
SIP_REALM SIP auth realm br.wln.ims.jio.com
REGISTRAR_HOST Jio router IP 192.168.29.1
MAX_CALLS Max simultaneous calls 16
LOG_LEVEL PJSIP log verbosity (1–5) 4
TLS_VERIFY Verify TLS cert (0=skip) 0
ENABLE_WIDEBAND Opt-in 16 kHz conference + G.722 (Docker source build) 0

Viewing Logs

Windows:

view_logs.bat

Linux:

journalctl -u jiofiber-b2bua -f

Supported Softphones

Tested and working:

  • Linphone (Android / iOS / Desktop)
  • Sipnetic (Android)
  • MicroSIP (Windows β€” requires an AMR-enabled build; stock builds fall back to PCMA/PCMU and sound robotic on the receiver side)
  • PhonerLite (Windows)
  • Zoiper (Android / iOS)
  • Asterisk (as upstream SIP trunk)

Acknowledgements

This project stands on the shoulders of prior reverse-engineering and open-source telephony work. Huge thanks to:

  • JFC-Group β€” the community that first mapped out how JioFiber's JUICE/IMS client provisions and registers. In particular JFC-microsip (the provisioning/config flow that jfc_configure.py derives from) and the JFC pjproject work that proved the patch path. Without their groundwork the +sip.instance shape, the OTP whitelist flow, and the rotating-password behaviour would have stayed a black box.
  • ankurpandeyvns/jiofiber-sip-proxy β€” Special thanks to Ankur Pandey for reverse-engineering the Jio router HTTP provisioner API, OTP authorization flow, and SIP IMS auth parameters.
  • sivatheja10/jiofiber-bridge β€” Special thanks to Siva Theja for initial SIP bridge research and protocol flow analysis.
  • krishnab-bot (PR #3, PR #4) β€” for diagnosing and fixing the G.711 10 ms/20 ms frm_per_pkt packet-sizing bug, adding the reproducible Docker Linux source build and isolated RTP audio regression suite (tests/audio/), and contributing the opt-in ENABLE_WIDEBAND (16 kHz / G.722 / AMR-WB) media path.
  • pjproject / PJSIP β€” the SIP/media stack the B2BUA is built on; the patches here are small deltas against it.
  • opencore-amr β€” the AMR-NB/AMR-WB codec that makes IMS audio interoperate with plain softphones.
  • Tailscale / WireGuard β€” the overlay network glue enabling remote calling.

This repo's contribution is the native end-to-end integration β€” a single-binary self-healing B2BUA that solves inbound call routing, correct AMR mode-set echo, automatic multi-interface RTP routing (Tailscale/LAN), and zero-SSD-wear RAM logging.

If you built on something here or spot missing attribution, please open an issue or PR.


Disclaimer

This software interoperates with your own telephone line for personal use, the same way the official app on your own router does. It reimplements a client to a service you pay for. Check your provider's terms; you are responsible for how you use it. Provided as-is, no warranty. Not affiliated with, or endorsed by, any ISP or provider.


License

MIT License β€” see LICENSE

About

High-performance native SIP B2BUA server bridging JioFiber VoIP (Jio IMS) to any standard SIP softphone (Linphone, MicroSIP, Zoiper) over LAN or VPN.

Topics

Resources

Stars

3 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages