Make sure that asterisk full logging is enabled
> nano /etc/asterisk/logger.conf
In logger.conf make sure that "full => notice,warning,error,debug,verbose" is uncommented.
If the line is not initially uncommented, uncomment the line, and reload the asterisk logger service:
> sudo asterisk rx " logger reload"
To Debug a specific SIP extension: e.g. extension '1000'
>sudo asterisk -rx "sip set debug peer 1000"
The same command could be used to debug a particular trunk.
Viewing the SIP message sequence for extension '1000'
> tail -f /var/log/asterisk/full | grep "CSeq:"
You should be able to see the basic sip message sequence: e.g.
CSeq: 102 NOTIFY
CSeq: 1862292122 INVITE
CSeq: 1862292122 INVITE
CSeq: 1862292122 ACK
CSeq: 1862292123 INVITE
CSeq: 1862292123 INVITE
CSeq: 1862292123 INVITE
CSeq: 1862292123 INVITE
CSeq: 1862292123 INVITE
CSeq: 1862292123 INVITE
CSeq: 1862292123 ACK
CSeq: 102 BYE
CSeq: 102 BYE
CSeq: 102 OPTIONS
CSeq: 102 OPTIONS
CSeq: 102 OPTIONS
CSeq: 102 OPTIONS
With sip debugging enabled and while a sip call is in progress:
> tail -f /var/log/asterisk/full | grep -i "Allow-Events:"