Skip to content

b2bua module

Alfred E. Heggestad edited this page Mar 11, 2018 · 2 revisions

Baresip can be configured as a Back-to-Back Useragent by using the b2bua module. In this configuration baresip will be configured with two accounts, one for inbound calls and one for outbound calls. In this configuration baresip will act as a transcoder, and re-encoding the audio and/or video stream.

Network map

This figure shows how the b2bua can be configured in the network:

  .--------------.      .---------.      .--------------.
  |              |      |         |      |              |
  | User-Agent A |----->|  B2BUA  |----->| User-Agent B |
  |              |      |         |      |              |
  '--------------'      '---------'      '--------------'

User-Agent A originates all the outgoing calls. User-Agent A can setup the B2BUA server as an "Outbound SIP Proxy", to force all outgoing calls to go via the B2BUA. Normal To headers can be used. User-Agent B is the endpoint receiving the incoming calls, in this example.

Compiling

The b2bua module must be explicitly enabled:

$ make EXTRA_MODULES=b2bua
$ sudo make EXTRA_MODULES=b2bua install

Sample configuration

#
# baresip configuration
#

#------------------------------------------------------------------------------

# SIP
sip_listen		0.0.0.0:5080

# Audio
audio_player		aubridge,nil
audio_source		aubridge,nil

#------------------------------------------------------------------------------
# Modules

# UI Modules
module			stdio.so

# Audio codec Modules (in order)
module			g711.so

# Audio driver Modules
module			aubridge.so

#------------------------------------------------------------------------------
# Temporary Modules (loaded then unloaded)

module_tmp		account.so

#------------------------------------------------------------------------------
# Application Modules

module_app		b2bua.so

This is a very simplified configuration file, it contains only the relevant parts. The SIP stack will be listening on port 5080. The audio driver aubridge is a special pseudo module that will bridge the audio stream between the inbound and outbound call. The only application module loaded is b2bua.so

And here is the accounts file:

#
# SIP accounts - one account per line
#
<sip:[email protected]>;auth_pass=none;regint=0;b2bua=inbound
<sip:[email protected]>;auth_pass=none;regint=0;b2bua=outbound

You must have two SIP accounts. The inbound UA must have a special parameter b2bua=inbound. The outbound UA must have a special parameter b2bua=outbound. The authentication password is not used. The SIP Registration is disabled.

Running the B2BUA

The B2BUA can be started like this:

$ ./baresip -f /Users/alfredh/.baresip-b2bua -v
baresip v0.5.8 Copyright (C) 2010 - 2018 Alfred E. Heggestad et al.
Local network address:  IPv4=en0:10.0.0.107 
ui: stdio
aucodec: PCMU/8000/1
aucodec: PCMA/8000/1
ausrc: aubridge
auplay: aubridge
Populated 2 accounts
module: loading app b2bua.so
b2bua: module loaded
Populated 2 audio codecs
Populated 0 audio filters
Populated 0 video codecs
Populated 0 video filters
baresip is ready.

Making a call from A to B

User-Agent A can be configured with an outbound proxy that points to B2BUA.

Here is an example from baresip: (Any SIP Client can be used)

<sip:[email protected]>;auth_pass=none;regint=0;outbound="sip:10.0.0.107:5080"

NOTE: 10.0.0.107 is the IP-address of the B2BUA Server. Now the call can be made from A to B and test if the B2BUA is working!

Final notes

The b2bua module is very simple and was written just for fun. It is considered experimental for now, but should work and be functional. More features can be added if needed. Video should also work, I will leave it as an exercise to the reader.