Is there a method to retrieve a call's complete SIP trace?

We’re using Asterisk to provide simulated phones for automated testing.
We provide a display of the currently active phones and their associated channels.
It would be very nice to allow the viewer, if requested, a view of the SIP (INVITE, OK, …ACK) trace associated with the call or the SIP associated with the Registration.

When manually debugging I often connect an instance of asterisk, via asterisk -r …, with a “CLI command sip set debug on”. This looks a bit cumbersome to instrument to get the SIP associated with a particular REGISTER, or call.

Thanks for any attention and assistance.

There is no way of getting the full trace. If you enable sip history, you can request a one line per packet summary, from the CLI, by giving the SIP channel name. You can also have these automatically logged when the channel is hung up.

try with tcpdump and wireshark