3. Back-to-back User Agent server

Last modified by Thibault Lemaire on 2024/03/25 11:01

Available in Flexisip 2.2 and later

Introduction

The back-to-back user agent server (b2bua server) is a generic flexisip service that can theoritically perform various kind of processing on calls, such as caller identity translation, media-level transcoding, that typically cannot be performed by a SIP proxy.

It operates between two parties of a call using two different SIP sessions bridged together, at signaling and media levels. As such, it may hide to one party the SIP session characteristics of the other party.

The back-to-back user-agent is never an end to itself, but a general technique to implement specific telephony services. This is why in Flexisip it comes with a concept of application, each application being there to implement specific services. As of version 2.2, two applications are provided:

  • trenscrypter - an application to perform transcoding of media encryption
  • sip-bridge - an application to perform SIP trunking.

Common features

All the b2bua applications are built against a common framework implementing the main back to back logic.

From a signaling point of view, the b2bua server supports the following features:

  • audio and video call establishment
  • call updates to toggle video
  • call pause/resume
  • call end
  • call error

Are not supported:

  • Early media
  • call update unrelated to video/audio toggling

The below diagram illustrate a typical call flow a back-to-back user-agent server processing a call between Alice and Bob.

                         b2bua           
   Alice                server                  Bob
     |                    | |                    |
     |      INVITE     F1 | |                    |
     |------------------->| |                    |
     |    100 Trying   F2 | |                    |
     |<-------------------| |       INVITE    F3 |
     |                    | |------------------->|
     |                    | |    100 Trying   F4 |
     |                    | |<-------------------|
     |                    | |    180 Ringing  F5 |
     |   180 Ringing   F6 | |<-------------------|
     |<-------------------| |                    |
     |                    | |       200 OK    F7 |
     |      200 OK     F8 | |<-------------------|
     |<-------------------| |         ACK     F9 |
     |         ACK    F10 | |------------------->|
     |------------------->| |                    |
     |   (S)RTP Media     | |   (S)RTP Media     |
     |<==================>| |<==================>|
     |        BYE     F11 | |                    |
     |------------------->| |        BYE     F12 |
     |      200 OK    F13 | |------------------->|
     |<-------------------| |       200 OK   F14 |
     |                    | |<-------------------|
     |                    | |                    |

The two calls operated by the b2bua server are called legs. Precisely, the outgoing call placed by Alice (on the previous diagram) is called leg A, while the incoming call received by Bob is called leg B.

Applications

Trenscrypter

This application aims at performing transcoding of media encryption protocols.

It accepts calls on leg A with media encryption established using SDES, DTLS-SRTP, ZRTP or not encrypted.

On leg B, media encryption establishment mode can be selected based on the recipient sip URI (see configuration for details). It allows the leg B call to use :

  • no encryption
  • SDES. In that case one can select the SRTP encryption suite from:
    • AES_CM_128_HMAC_SHA1_80
    • AES_CM_128_HMAC_SHA1_32
    • AES_256_CM_HMAC_SHA1_80
    • AES_256_CM_HMAC_SHA1_32
  • DTLS-SRTP
  • ZRTP

Sip-bridge (SIP trunking)

The sip-bridge application allows bridging calls to external SIP providers, such as ITSPs in order to connect to PSTN.

Example use case:

You are a company selling intercoms. You distribute a mobile app to let your users answer their door from their smartphone. Thanks to the SIP-bridge application, you can also give them the opportunity to answer their door (in audio only) even when they have no internet connectivity by falling back on the telephone network (sometimes called PSTN).

The user would configure their phone number to use as secondary/fallback contact on your mobile app. If they don't answer in a given amount of time, the call would be forwarded by Flexisip proxy to the B2BUA service, which would then bridge the call to a telephone gateway service on which you rent an account (ITSP companies).

See the configuration page for details on setting up the sip-bridge, and example configurations.

Operation

From a system perspective, the b2bua server runs as a daemon in its own process, and hence has no adherence on other Flexisip services from an execution standpoint. It can be started, stopped, restarted using usual systemd commands, for example:

systemctl status flexisip-b2bua

It can of course be started from a terminal, for example:

/opt/belledonne-communications/bin/flexisip --server b2bua --debug

Configuration

The configuration of the b2bua server is read by default from /etc/flexisip/flexisip.conf, mainly from the [b2bua-server] section and subsections like [b2bua-server::trenscrypter].

To operate the b2bua server must receive the incoming calls to intercept. A convenient way to do this is through the routes configuration of proxy's module::Forward.

Please refer to the Configuration page for details.