Search the Asterisk Blog

New PJSIP Logging Functionality

By Joshua C. Colp

When PJSIP support was written for Asterisk we naturally needed the ability to display the SIP messages being sent and received. This took the form of the res_pjsip_logger module which hooks into the message sending and receiving path and logs the messages. The functionality was written to be familiar to users of chan_sip by allowing it to be toggled on and off and allowing a specific IP address or hostname to be specified. This has worked for some time but there is always room for improvement. As of Asterisk 13.34.0, 16.11.0, and 17.5.0 some new functionality is available alongside this!

Multiple IPs and Subnet Support

The “pjsip set logger host” CLI command now supports specifying a subnet mask, for example:

As well you can now place “add” at the end to have it be an additional host or subnet to log for:

Console Disabling Support

In some cases you may not want PJSIP logging to go to the console. There is now a CLI command to toggle this on and off:

PCAP Output Support

Finally a really handy option is the ability to output messages in a pcap file, so you can later filter and view in such tools as Wireshark:

Packets are placed into the pcap as UDP packets in all cases and they are unencrypted. This even applies if you are using, for example, SIP over Websockets with TLS.

The Future

Adding these changes also provided the foundation for potential future improvements. These could be the ability to have multiple independent logging sessions going on or the ability to also include RTP packets in the pcap file as well. Stay tuned in case these or other things are added!

There's One Comment

Add to the Discussion

Your email address will not be published. Required fields are marked *

About the Author

Joshua C. Colp

Joshua Colp is a Senior Software Developer at Digium and a long time Asterisk developer. He originally started in the community submitting simple patches and grew into improving and creating new core components of Asterisk itself. He is a self-taught programmer who believes in finding the balance between doing things the way they should be done and doing what is right for the people using the software. In his spare time he enjoys smashing fax machines.

See All of Joshua C.'s Articles