Migrating from chan_sip to res_pjsip
Overview
This page documents any useful tools, tips or examples on moving from the old chan_sip channel driver to the new chan_pjsip/res_pjsip added in Asterisk 12.Configuration Conversion Script
There is a script available to provide a basic conversion of a sip.conf config to a pjsip.conf config. It is not intended to work for every scenario or configuration; for basic configurations it should provide a good example of how to convert it over to pjsip.conf style config.To insure that the script can read any #include'd files, run it from the /etc/asterisk directory or in another location with a copy of the sip.conf and any included files. The default input file is sip.conf, and the default output file is pjsip.conf. Any included files will also be converted, and written out with a pjsip_ prefix, unless changed with the --prefix=xxx option.
Command line usage
# /path/to/asterisk/source/contrib/scripts/sip_to_pjsip/sip_to_pjsip.py --help Usage: sip_to_pjsip.py [options] [input-file [output-file]] input-file defaults to 'sip.conf' output-file defaults to 'pjsip.conf' Options: -h, --help show this help message and exit -p PREFIX, --prefix=PREFIX output prefix for include files
Example of Use
# cd /etc/asterisk # /path/to/asterisk/source/contrib/scripts/sip_to_pjsip/sip_to_pjsip.py Reading sip.conf Converting to PJSIP... Writing pjsip.conf
Side by Side Examples of sip.conf and pjsip.conf Configuration
These examples contain only the configuration required for sip.conf/pjsip.conf as the configuration for other files should be the same, excepting the Dial statements in your extensions.conf. Dialing with PJSIP is discussed in Dialing PJSIP Channels.Example Endpoint Configuration
This examples shows the configuration required for:- two SIP phones need to make calls to or through Asterisk, we also want to be able to call them from Asterisk
- for them to be identified as users (in the old chan_sip) or endpoints (in the new res_sip/chan_pjsip)
- both devices need to use username and password authentication
- 6001 is setup to allow registration to Asterisk, and 6002 is setup with a static host/contact
sip.conf
|
pjsip.conf
| ||
---|---|---|---|
|
|
Example SIP Trunk Configuration
This shows configuration for a SIP trunk as would typically be provided by an ITSP. That is registration to a remote server, authentication to it and a peer/endpoint setup to allow inbound calls from the provider.- SIP provider requires registration to their server with a username of "myaccountname" and a password of "1234567890"
- SIP provider requires registration to their server at the address of 203.0.113.1:5060
- SIP provider requires outbound calls to their server at the same address of registration, plus using same authentication details.
- SIP provider will call your server with a user name of "mytrunk". Their traffic will only be coming from 203.0.113.1
sip.conf
|
pjsip.conf
| ||
---|---|---|---|
|
|
Disabling res_pjsip and chan_pjsip
You may want to keep using chan_sip for a short time in Asterisk 12+ while you migrate to res_pjsip. In that case, it is best to disable res_pjsip unless you understand how to configure them both together.There are several methods to disable or remove modules in Asterisk. Which method is best depends on your intent.
If you have built Asterisk with the PJSIP modules, but don't intend to use them at this moment, you might consider the following:
- Edit the file modules.conf in your Asterisk configuration directory. (typically /etc/asterisk/)
noload => res_pjsip.so
noload => res_pjsip_pubsub.so
noload => res_pjsip_session.so
noload => chan_pjsip.so
noload => res_pjsip_exten_state.so
noload => res_pjsip_log_forwarder.so
- Restart Asterisk!
- Remove all PJSIP modules from the modules directory (often, /usr/lib/asterisk/modules)
- Remove the configuration file (pjsip.conf)
- Un-install and re-install Asterisk with no PJSIP related modules.
- If you are wanting to use chan_pjsip alongside chan_sip, you could change the port or bind interface of your chan_pjsip transport in pjsip.conf
Network Address Translation (NAT)
When configured with chan_sip, peers that are, relative to Asterisk, located behind a NAT are configured using the nat parameter. In versions 1.8 and greater of Asterisk, the following nat parameter options are available:
Value
|
Description
|
---|---|
no | Do not perform NAT handling other than RFC 3581. |
force_rport | When the rport parameter is not present, send responses to the source IP address and port anyway, as though the rport parameter was present |
comedia | Send media to the address and port from which Asterisk received it, regardless of where SDP indicates that it should be sent |
auto_force_rport | Automatically enable the sending of responses to the source IP address and port, as though rport were present, if Asterisk detects NAT. Default. |
auto_comedia | Automatically send media to the port from which Asterisk received it, regardless of where SDP indicates that it should be sent, if Asterisk detects NAT. |
Value
|
Description
|
---|---|
no | Do not perform NAT handling other than RFC 3581 |
yes | Send media to the port from which Asterisk received it, regardless of where SDP indicates that it should be sent; send responses to the source IP address and port as though rport were present; and rewrite the SIP Contact to the source address and port of the request so that subsequent requests go to that address and port. |
never | Do not perform any NAT handling |
route | Send media to the port from which Asterisk received it, regardless of where SDP indicates that it should be sent and rewrite the SIP Contact to the source address and port of the request so that subsequent requests go to that address and port. |
- rtp_symmetric - Send media to the address and port from which Asterisk receives it, regardless of where SDP indicates that it should be sent
- force_rport - Send responses to the source IP address and port as though port were present, even if it's not
- rewrite_contact - Rewrite SIP Contact to the source address and port of the request so that subsequent requests go to that address and port.
chan_sip (sip.conf)
|
chan_pjsip (pjsip.conf)
| ||
---|---|---|---|
|
|
No hay comentarios:
Publicar un comentario