XMPP Voice Call Setup Tracing – OTT Voice Observations – Part 4

In the previous post, I’ve had a look at how the voice calls codec and other parameters are exchanged and negotiated between two XMPP clients such as the Conversations messenger running on Android. As I operate my own XMPP server, I can trace right in the middle and while there is end to end encryption for message content and voice calls, most parts of the signaling message for a voice call setup are going through the server in plain text. I use the Prosody XMPP server and there are several ways to trace there:

The method I have used for many years is to set the logging level to ‘debug’ and then analyze the log file. This approach creates a lot of data, which is not necessarily ideal when looking for voice call setup messages for a particular user. Also, it seems that even when set to debug, not all details of an XMPP stanza message is contained in the log. So I searched around a bit and found out that recent versions of Prosody have a command to trace signaling messages of particular users on the shell. Here’s an example to trace stanza messages for my account on the server and write them to a file (I changed the server name for privacy reasons):

sudo prosodyctl shell watch stanzas martin@xyz.com > ~/prosody.log

The command outputs all signaling messages for my account (stanzas) and their xml encoded content. Unfortunately, the xml encoding is optimized for size and not readability, so I needed something in addition to make the output readable to the human eye. Xmllint is a great tool to do this and here’s a Bash one liner that runs over the log and generates a more human readable version with spaces between individual messages for even better readability. The concatenation of commands does not look beautiful, but it does its job:

{ echo '<root>'; cat prosody.log; echo '</root>'; } \
| xmllint --format - \
| awk '
  /<root>/ || /<\/root>/ { next }   # drop wrapper tags
  { print }
  /<\/(message|presence|iq)>/ || /<(message|presence|iq)[^>]*\/>/ {
    print ""
    print ""
  }
' > prosody-pretty.xml

And there we go, a human readable trace output for a single XMPP user!

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.