📜 ⬆️ ⬇️

Asterisk: ngrep, sipgrep, sngrep, protocol diagram

This is a small note about a pair of utilities that I use from time to time to work with an asterisk (for debugging telephony and viewing SIP packets). Many colleagues do not know about simpler utilities that could save a minute or two of working time.

The following discussion focuses on ngrep, sipgrep, sngrep, js-sequence-diagrams


Sip


Sometimes you need to quickly analyze: and what does it go with us in the REGISTER package? Or INVITE left, but was there an answer?
')
The well-known wireshark and tcpdump programs take dumps in which you can find information about all the packets that passed on the necessary interface on the network, as well as analyze these packets and find the sessions.

But tcpdump is too low-level, and wireshark is cumbersome, often all its functionality is not required. Therefore, you can use ngrep, sipgrep or sngrep, and solve the problem without attracting heavy artillery.

ngrep
Often this utility is already in the system, but if not, it is easy to install from the packages of your distribution. Allows you to see in real time where you are going on traffic.

You can filter SIP packets like this:

ngrep -q -d any -p -W byline '' 'port 5060' 


And so you can filter the packages where there is the word REGISTER (that is, both the REGISTER packages and the answers to them)

 ngrep -q -d any -p -W byline 'REGISTER' 


Since ngrep is more about the network than about SIP, there are still other examples of applications .



sipgrep

It looks like ngrep, only allows you to watch SIP protocol traffic: for example, there are options to search in certain fields of the package - To, From, Contact, there is a highlight of some values.

Show all SIP traffic:

 sipgrep -d any 


Shows To: 101 traffic with a session report:

 sipgrep -d any -t 101 -G 


More information on installation and use on the project page .



sngrep

Thank you, Emily_Rose . Perhaps the most advanced utility. You can see in real time what is happening with the SIP dialogs on your SIP server.

Just install it and run it.


Project page sngrep

Of course, communication problems are not always limited to problems with SIP signaling. If there are problems with RTP, packet loss, voice gurgling, then you should use more powerful tools (the Kamailio project has a page dedicated to SIP and RTP analysis tools ).

Protocol Chart


Sometimes it is necessary not to analyze existing packages, but to draw a protocol diagram in order to imagine where what package goes like, such as:


For this, it is convenient to use the js-sequence-diagrams page , the diagram is written in words, and then converted into a clear picture, it can be attached to the task tracker to the task or added to the documentation.


I hope that this information will also come in handy at work.
What utilities do you use?

Source: https://habr.com/ru/post/274919/


All Articles