Debug SIP protocol in Asterisk¶
Let's suppose, you want to see which SIP messages come from user user001 and which responses are sent back.
For this perform next actions:
2. Turn on SIP debug for user user001:
# asterisk -rx "sip set debug peer user001"
To capture this way Asterisk should know IP address of a user.
Thus, user should be either registered, or user's IP address should be configured in user's settings.
In case if you know IP address of a user, but don't know, under which peer it's registered/configured, you can capture dump, using IP address:
# asterisk -rx "sip set debug ip 192.168.1.1"
In case if you need to debug all SIP messages (and not from/to specific peer/IP address), execute following:
# asterisk -rx "sip set debug on"
3. You can watch results either in Asterisk console or in log file.
Asterisk console is convenient to use to quickly check if any messages come from client.
However console doesn't allow to perform text search.
Log file is convenient to use, if you wish to perform search inside of big amount of messages.
Also file is more convenient to use, if you use SIP debugging together with Asterisk debugging
- Asterisk console
Enter console mode:
# asterisk -r
After this you'll see SIP messages arriving on the console.
Warning! Messages amount could be big and might hang your terminal application. Use search in log file in this case.
- log file
Perform search for IP address of a client, or message type, for example, REGISTER, in file /var/log/asterisk/messages.
After you've found first match, you can use call Id from SIP message to find all messages for particular SIP dialog.
Then traverse over all found messages from SIP dialog.
Principle of working with log files is described in section How to work with log file
4. To prevent from disk space overflow turn off debugging once you've finished:
# asterisk -rx "sip set debug off"