Trace an Asterisk Call Through the Dialplan with sngrep
Trace one Asterisk call with sngrep. Match SIP call flows to dialplan Executing lines, follow call IDs in the log, and capture with sngrep options.
By Arkay · Updated · Published

How do you trace one Asterisk call end to end?
Watch the SIP side and the dialplan side of the same call at the same time. sngrep shows each SIP dialog as a message flow in the terminal. The Asterisk console shows each dialplan step as a line with extension@context:priority and the application that runs.
The two views come from different tools, so you line them up yourself. A dialplan step shows where a call is in your configuration. A SIP message shows what the endpoints and the server sent to each other. Neither view alone shows the whole call.
The steps below run in this order: capture or open the SIP trace, turn on verbose output, read the Executing lines beside the matching SIP messages, and reset the debug settings when you finish.
What does each tool show about one call?
We compiled this comparison on November 14, 2026, from sngrep's own documentation and from the official Asterisk documentation. The sngrep sources are the irontec/sngrep README, the version 1.9.0 man page and the project wiki. The Asterisk sources are pages on docs.asterisk.org. The comparison was compiled from those pages and was not tested.
| Tool | Command or setting | What it shows about one call |
|---|---|---|
| sngrep live capture | sngrep port 5060 | SIP dialogs and their message flow in the terminal |
| sngrep offline | sngrep -I file.pcap | The same view, read from a saved pcap file |
| sngrep headless | sngrep -N -O file.pcap | Capture only, with no interface |
| Asterisk SIP log | pjsip set logger on | SIP messages inside the Asterisk console |
| Asterisk dialplan trace | core set verbose 5 | Each step as extension@context:priority and the application it runs |
| Asterisk call ID | Automatic | A C-XXXXXXXX tag on the log lines for the call |
| Asterisk debug log file | logger add channel | A full log file to read after the call |
| Asterisk live calls | core show channels | Channel, Location, State and Application(Data) for each live call |
Each row is explained in the sections below. The table shows which view to open, so it does not list every option.
How do you capture the call with sngrep?

Install sngrep with your system's package manager. The sngrep installation page lists these commands.
| System | Command |
|---|---|
| Debian and recent Ubuntu | apt-get install sngrep |
| Fedora, CentOS, RHEL or AlmaLinux | dnf copr enable irontec/sngrep, then dnf install sngrep |
| Alpine | apk add sngrep |
| macOS | brew install sngrep |
| OpenWRT | opkg install sngrep |
On Fedora and the related systems, enable the repository first, then install the package.
Once sngrep is installed, start it with a device and a filter. The -d option picks the capture device, and the default is any. A trailing BPF filter works like the filters in tcpdump and ngrep, so you can limit the view to one port or one host.
sngrep port 5060
sngrep -d eth0 -O save.pcap port 5060 and udp
The first line opens the live view and keeps only packets on port 5060. The second line captures on the device eth0, which is an example name, and saves every captured packet to save.pcap with -O. The filter keeps only UDP packets on port 5060.
Use -c to limit the call list to calls. It shows only dialogs that start with an INVITE request, so other dialogs are hidden.
A match expression goes after the options. sngrep matches it against message payloads. The -i option makes the match case-insensitive, and -v inverts it. When one request matches, the later messages in that dialog are captured too, so the whole call stays together.
sngrep -c
sngrep -i alice
The first line shows only INVITE dialogs. The second line keeps dialogs where a request contains alice, in any letter case. The messages that follow in those dialogs stay in view.
To read a saved file, use -I. It reads packets from a pcap file instead of a network device, and it can take a BPF filter too.
sngrep -I file.pcap host <sip-host-ip> and port 5060
The -I option opens file.pcap. The filter keeps packets to or from one host on port 5060. Replace <sip-host-ip> with an address from your own capture. Without a BPF filter, all SIP packets in the file are shown.
How do you read the sngrep call flow?
In the call list, press Enter on a dialog to open its call flow. Press Space to select dialogs, and press p to pause. The keys below move you around each screen. They come from sngrep's wiki pages for the call list and the call flow.
| Screen | Key | What it does |
|---|---|---|
| Call list | Enter | Shows the selected dialog's message flow |
| Call list | Space | Selects a dialog |
| Call list | F2 or s | Saves dialogs to a pcap file |
| Call list | F3, / or Tab | Opens a display filter |
| Call list | F4 or x | Shows a dialog with its related one |
| Call list | F6 or r | Shows raw text |
| Call list | F7 or f | Opens advanced filters |
| Call list | p | Pauses |
| Call flow | Enter | Shows the current message raw |
| Call flow | F2 or d | Toggles SDP info in the arrows |
| Call flow | F3 or t | Toggles the preview panel |
| Call flow | F4 or x | Shows the dialog and its extended one |
| Call flow | F7 or c | Changes the color mode |
| Call flow | D | Shows only messages with SDP |
| Call flow | Esc or q | Goes back |
Use F4 or x in the call flow to see the extended flow, which covers both legs of a call. The extended flow needs an X-CID or X-Call-ID header that names the related Call-ID. If no second leg appears, check those headers first.
Press Enter on a message in the call flow to see its raw text. The raw text includes the SIP headers, so you can compare them with the messages the Asterisk console prints.
How do you see the dialplan steps in the Asterisk console?
Two commands in the Asterisk CLI give you the console view. The core set verbose command sets the level of verbose messages on the console. The Asterisk debug examples use level 5, so this guide uses 5 too.
*CLI> core set verbose 5
*CLI> pjsip set logger on
The first line raises the verbose level so each dialplan step prints as it runs. The second line turns on the PJSIP logger, which prints SIP messages in the console. The PJSIP logger needs Asterisk 12 or higher.
Each dialplan step appears as a line like this:
-- Executing [100@from-internal:1] Playback("SIP/6001-00000005", "demo-congrats") in new stack
Read the line from left to right. The two dashes and the word Executing mark a dialplan step. The text in brackets is extension@context:priority. Here the extension is 100, the context is from-internal, and the priority is 1, which is the step number inside that extension. Playback is the application that runs. Its arguments sit in parentheses: the channel SIP/6001-00000005 and the file demo-congrats. The line ends with the words in new stack.
The core show channels command lists live channels. Its output has four columns: Channel, Location, State and Application(Data). Run the command during a call to see which application each live channel is in.
To match the console to sngrep, follow these steps.
- Start sngrep with a filter for the call's SIP port, for example
sngrep port 5060. - Open the call in the call list and note the time of its first INVITE.
- In the Asterisk console, watch the Executing lines that appear at the same time.
- Compare the SIP messages in the call flow with the Executing lines, to see which application ran when each message arrived.
How do you follow one call through the Asterisk log?
Asterisk tags log lines with call identifiers. The tag has the form C-XXXXXXXX, where XXXXXXXX is an 8-digit hexadecimal value. No setup is needed for this. The same ID appears in core show channel output, so you can find it there too.
The setting lives in logger.conf:
[general]
use_callids = yes
The [general] line starts the section for the main logging settings. The use_callids line writes call IDs into log messages. The default is yes, so this line matters only if someone set it to no and you want it back.
To follow one call, use these steps.
- Find a line for the call in the console, such as an Executing line, and copy its C- tag.
- Search the log file for that tag.
- Read the matching lines in order. They are the steps that one call ran.
grep "C-00000000" /var/log/asterisk/debug_log_123456
The grep command prints each line that contains the text in quotes. C-00000000 is an example ID, so use the tag from your own call. The path is the debug log file from the next section, so that log must be running before the call.
How do you keep a full debug log for one call?
For a full record, add a log channel from the CLI. The channel lasts until Asterisk restarts, the logger module reloads or the log files rotate, so add it again after any of those.
*CLI> logger add channel debug_log_123456 notice,warning,error,debug,verbose,dtmf
*CLI> core set verbose 5
*CLI> core set debug 5
The first line adds a log channel named debug_log_123456. It writes notice, warning, error, debug, verbose and dtmf messages to /var/log/asterisk/debug_log_123456. The second line raises the verbose level to 5. The third line raises the debug level to 5. You can add a module name at the end of core set debug to show debug messages from one module only.
When the test ends, reset both levels.
*CLI> core set verbose 0
*CLI> core set debug 0
The first line sets verbose back to 0. The second line sets debug back to 0. The Asterisk docs recommend that you do not turn on debug mode on a production system unless you are debugging a specific issue, so reset debug as soon as the test is over.
How do you capture calls on a busy server without the interface?
Headless capture runs sngrep without its screen. Use -N to turn off the interface, so sngrep only captures, and -O to save the packets to a file. The -q option hides dialog output in this mode.
sngrep -N -q -O file.pcap -l <N> -R port 5060
The -N option runs sngrep without the interface, just capturing. The -q option hides the dialog output. The -O option saves the captured packets to file.pcap. The -l option sets a capture limit of N dialogs. Replace <N> with the number you want. The limit must be above 1, and it cannot be disabled. The -R option rotates calls when the limit is reached. The filter port 5060 limits the capture to that port.
To add the RTP payload to the capture, add -r. Keep debug off on a busy production server unless you are chasing a specific issue. When the capture is done, open the file with sngrep -I file.pcap, and add a filter if you need one.
What do you do when the trace does not match?
Most gaps come from a filter, a setting or a missing header. Check these first.
| Symptom | What to check |
|---|---|
| sngrep shows no calls | Check the device with -d and the BPF filter. With -c, only dialogs that start with an INVITE request appear. |
| A dialog you expected is missing | Remove -c, and check whether a match expression is limiting the list. |
| F4 shows no related dialog | The extended flow needs an X-CID or X-Call-ID header that names the related Call-ID. |
| Log lines have no C- tag | Check use_callids in logger.conf. The default is yes. |
| The console is flooded with debug output | Run core set debug 0 and core set verbose 0. |
| The debug log channel is gone | It ends when Asterisk restarts, the logger module reloads or the log files rotate. Add it again. |
| SIP messages do not appear in the console | pjsip set logger on needs Asterisk 12 or higher. The PJSIP troubleshooting guide suggests core set verbose 4, core set debug 4 and pjsip set logger on for a failing scenario. |
If a pcap file does not open, check the file name after -I. Any filter goes after the file name.
Advanced examples: how do you combine these steps?
These three examples combine the options from this guide. Each one uses only commands and options described above.
The first example captures a busy server and reads the file later.
sngrep -N -q -O busy.pcap -l <N> -R port 5060
sngrep -I busy.pcap host <sip-host-ip> and port 5060
The first line captures headless on port 5060, saves to busy.pcap and rotates calls when the dialog limit is reached. The second line reads the saved file later and keeps packets to or from <sip-host-ip> on port 5060. Replace that placeholder with an address from your own capture.
The second example shows only the INVITE dialogs that contain one name.
sngrep -i -c alice
The -c option keeps only INVITE dialogs. The -i option makes the match for alice case-insensitive. Use it when you want the calls where that name appears in the messages.
The third example sets up the console and the log before a test call.
*CLI> logger add channel debug_log_123456 notice,warning,error,debug,verbose,dtmf
*CLI> core set verbose 5
*CLI> core set debug 5
*CLI> pjsip set logger on
Start sngrep in a second terminal with sngrep port 5060, place the test call, and copy the C- tag of its Executing lines from the console. Search the log for that tag, as shown earlier, and compare those lines with the call flow. When you are done, reset the levels.
*CLI> core set verbose 0
*CLI> core set debug 0
Both levels return to 0, so the console and the log stop collecting extra detail.
More guides in Open-Source PBX and SIP Servers.
Related guides
Frequently asked questions
- How do you read a saved pcap file in sngrep?
- Run sngrep -I followed by the file name, for example sngrep -I file.pcap. Add a BPF filter after the file name if you need one. sngrep then reads the saved packets instead of a network device.
- What does a -- Executing line in the Asterisk console mean?
- It is one dialplan step. The text in brackets gives the extension, context and priority. The next part names the application that runs and its arguments.
- How do you install sngrep on Debian, Ubuntu, Fedora, Alpine or macOS?
- Use apt-get install sngrep on Debian and recent Ubuntu, and dnf copr enable irontec/sngrep then dnf install sngrep on Fedora. Use apk add sngrep on Alpine and brew install sngrep on macOS.