概述
在VOIP的使用过程中,最常见的问题就是信令不通和语音质量问题。
通常的问题跟踪手段包括日志分析、抓包分析。
抓包的工具有wireshark、tcpdump等等,如果是只针对sip信令的抓包,则sngrep更专业好用。
sngrep对SIP抓包的专业性体现在:
- 实时抓取,实时展示。
- 可以作为sip PCAP查看器。
- 对sip信令中的任意字段设置过滤器。
- 对一个dialog的sip信令自动关联。
环境
centos6,centos7
安装
依赖库
yum install ncurses-devel make libpcap-devel pcre-devel openssl-devel git gcc autoconf automake
yum源
vi /etc/yum.repos.d/irontec.repo
[irontec]
name=Irontec RPMs repository
baseurl=http://packages.irontec.com/centos/$releasever/$basearch/
安装
rpm --import http://packages.irontec.com/public.key
yum install sngrep
命令帮助
[root@localhost ~]# sngrep --help
Usage: sngrep [-hVcivNqrD] [-IO pcap_dump] [-d dev] [-l limit] [-B buffer] [-LHE capture_url] [<match expression>] [<bpf filter>]
-h --help This usage
-V --version Version information
-d --device Use this capture device instead of default
-I --input Read captured data from pcap file
-O --output Write captured data to pcap file
-B --buffer Set pcap buffer size in MB (default: 2)
-c --calls Only display dialogs starting with INVITE
-r --rtp Capture RTP packets payload
-l --limit Set capture limit to N dialogs
-i --icase Make <match expression> case insensitive
-v --invert Invert <match expression>
-N --no-interface Don't display sngrep interface, just capture
-q --quiet Don't print captured dialogs in no interface mode
-D --dump-config Print active configuration settings and exit
-f --config Read configuration from file
-F --no-config Do not read configuration from default config file
-R --rotate Rotate calls when capture limit have been reached
-H --eep-send Homer sipcapture url (udp:X.X.X.X:XXXX)
-L --eep-listen Listen for encapsulated packets (udp:X.X.X.X:XXXX)
-E --eep-parse Enable EEP parsing in captured packets
测试
指定网卡br0抓包
sngrep –d br0
主界面,展示所有抓取的sip信令,按照dialog展示
上下选择某一个dialog,enter进入查看信令细节,本图是一个注册过程的信令
本图是一个呼叫dialog的完整信令交互展示
总结
sngrep是一个非常好用的sip呼叫跟踪工具,还有很多的细节和使用方法有待开发。
比如我们可以在sip server上对指定号码抓取呼叫信令和rtp媒体流,用来跟踪定位问题。
空空如常
求真得真