{"id":467,"date":"2011-10-10T09:41:37","date_gmt":"2011-10-10T07:41:37","guid":{"rendered":""},"modified":"2020-01-08T09:00:32","modified_gmt":"2020-01-08T08:00:32","slug":"ngrep-tool-voip-analysis","status":"publish","type":"post","link":"https:\/\/nil.uniza.sk\/en\/ngrep-tool-voip-analysis\/","title":{"rendered":"Using ngrep tool for SIP diagnostics"},"content":{"rendered":"<h3 class=\"wp-block-heading\">Ngrep &#8211; a tool for VoIP analysis <\/h3>\n\n\n<p>Ngrep is an interesting tool which may be used for SIP real time analysis. It is usable to capture SIP Messages which are flowing on\/from of our SIP server.<\/p>\n<p>Installation is straightforward, directly debian repository:<\/p>\n<pre>apt-get install ngrep\n<\/pre>\n<p><\/p>\n<p>Usage example:<\/p>\n<pre>ngrep -d eth0 -p -q -W byline port 5060 &gt; test.txt<\/pre>\n<p>where:<\/p>\n<p>-d &#8211; which interface will be used to capture data, usable if server has more than one interface<\/p>\n<p>-p &#8211; does not put an interface to promiscuity mode (capture only our frames\/packets)<\/p>\n<p>-q &#8211; quiet mode, does not print other information, only application headers<\/p>\n<p>-W byline &#8211; display output by lines<\/p>\n<p>&#8211; port &#8211; listen on port (either source or destination)<\/p>\n<p><a href=\"http:\/\/manpages.debian.net\/cgi-bin\/man.cgi?query=ngrep&amp;apropos=0&amp;sektion=0&amp;manpath=Debian+Sid&amp;format=html&amp;locale=en\">More info on manual pages.<\/a><\/p>\n<p><\/p>\n<p>Example of captured SIP&nbsp;traffic:<\/p>\n<pre>interface: eth0 (158.193.152.0\/255.255.255.0)\nfilter: (ip or ip6) and ( port 5060 )\n\nU 62.168.119.189:9190 -&gt; 158.193.152.29:5060\n.\n................\n\nU 62.168.119.189:9190 -&gt; 158.193.152.29:5060\nREGISTER sip:ps.sip.uniza.sk SIP\/2.0.\nTo: palo&lt;sip:palo@ps.sip.uniza.sk&gt;.\nFrom: palo&lt;sip:palo@ps.sip.uniza.sk&gt;;tag=94146277.\nVia: SIP\/2.0\/UDP 192.168.1.100:9190;branch=z9hG4bK-d87543-958860331-1--d87543-;rport.\nCall-ID: 4f1b38568018f36c.\nCSeq: 2 REGISTER.\nContact: &lt;sip:palo@192.168.1.100:9190&gt;;expires=0.\nMax-Forwards: 70.\nAllow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, NOTIFY, MESSAGE, SUBSCRIBE, INFO.\nUser-Agent: eyeBeam release 3004w stamp 16863.\nContent-Length: 0.\n.\n\n\nU 158.193.152.29:5060 -&gt; 62.168.119.189:9190\nSIP\/2.0 200 OK.\nTo: palo&lt;sip:palo@ps.sip.uniza.sk&gt;;tag=329cfeaa6ded039da25ff8cbb8668bd2.ff32.\nFrom: palo&lt;sip:palo@ps.sip.uniza.sk&gt;;tag=94146277.\nVia: SIP\/2.0\/UDP 192.168.1.100:9190;branch=z9hG4bK-d87543-958860331-1--d87543-;rport=9190;received=62.168.119.189.\nCall-ID: 4f1b38568018f36c.\nCSeq: 2 REGISTER.\nServer: OpenSER (1.3.2-notls (x86_64\/linux)).\nContent-Length: 0.\n.<\/pre>\n<p>Options and other usage examples:<\/p>\n<pre>USAGE:usage: ngrep &lt;-hNXViwqpevxlDtTRM&gt; &lt;-IO pcap_dump&gt; &lt;-n num&gt; &lt;-d dev&gt; &lt;-A num&gt;\n             &lt;-s snaplen&gt; &lt;-S limitlen&gt; &lt;-W normal|byline|single|none&gt; &lt;-c cols&gt;\n             &lt;-P char&gt; &lt;-F file&gt; &lt;match expression&gt; &lt;bpf filter&gt;\n   -h  is help\/usage\n   -V  is version information\n   -q  is be quiet (don't print packet reception hash marks)\n   -e  is show empty packets\n   -i  is ignore case\n   -v  is invert match\n   -R  is don't do privilege revocation logic\n   -x  is print in alternate hexdump format\n   -X  is interpret match expression as hexadecimal\n   -w  is word-regex (expression must match as a word)\n   -p  is don't go into promiscuous mode\n   -l  is make stdout line buffered\n   -D  is replay pcap_dumps with their recorded time intervals\n   -t  is print timestamp every time a packet is matched\n   -T  is print delta timestamp every time a packet is matched\n   -M  is don't do multi-line match (do single-line match instead)\n   -I  is read packet stream from pcap format file pcap_dump\n   -O  is dump matched packets in pcap format to pcap_dump\n   -n  is look at only num packets\n   -A  is dump num packets after a match\n   -s  is set the bpf caplen\n   -S  is set the limitlen on matched packets\n   -W  is set the dump format (normal, byline, single, none)\n   -c  is force the column width to the specified size\n   -P  is set the non-printable display char to what is specified\n   -F  is read the bpf filter from the specified file\n   -N  is show sub protocol number\n   -d  is use specified device instead of the pcap default\n\nEXAMPLES:\n ngrep -qt -W byline port 5060\n ngrep -d any port 5060 -W byline &gt; outfile.txt\n ngrep -q '8005551212' port 5060 #&lt;swk&gt;:  only shows packets on 5060 with 8005551212 inside the payload<\/pre>\n<p><\/p>\n\n\n<h3 class=\"wp-block-heading\">Other tools<\/h3>\n\n\n\n<ul class=\"wp-block-list\"><li><a href=\"https:\/\/nil.uniza.sk\/en\/tools-for-a-quick-sip-diagnostics\/\">ngrep, sipgrep and sngrep<\/a><\/li><li><a href=\"https:\/\/nil.uniza.sk\/en\/using-tcpdump-diagnostics-dns-debian\/\">tcpdump<\/a><\/li><li><a href=\"https:\/\/nil.uniza.sk\/en\/using-ipgrab-sip-diagnostics\/\">ipgrab<\/a><\/li><\/ul>","protected":false},"excerpt":{"rendered":"<p>Ngrep is an intersting tool which may be used for SIP real time analysis. It is usable to capture SIP&nbsp;Messages which are flowing on\/from of our SIP&nbsp;server.<\/p>\n<p>Installation is straightforward, directly debian repository:<\/p>\n<pre>\r\napt-get install ngrep\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p>Usage example:<\/p>\n<pre>\r\nngrep -d eth0 -p -q -W byline port 5060 &gt; test.txt<\/pre>\n<p>where:<\/p>\n<p>-d &#8211; which interface will be used to capture data, usable if server has more as one interface<\/p>\n<p>-p &#8211; does not put an interface to promiscuite mode (capture only our frames\/packets)<\/p>","protected":false},"author":7,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_seopress_robots_primary_cat":"","_seopress_titles_title":"","_seopress_titles_desc":"","_seopress_robots_index":"","_kad_blocks_custom_css":"","_kad_blocks_head_custom_js":"","_kad_blocks_body_custom_js":"","_kad_blocks_footer_custom_js":"","_kad_post_transparent":"","_kad_post_title":"","_kad_post_layout":"","_kad_post_sidebar_id":"","_kad_post_content_style":"","_kad_post_vertical_padding":"","_kad_post_feature":"","_kad_post_feature_position":"","_kad_post_header":false,"_kad_post_footer":false,"footnotes":""},"categories":[685,809],"tags":[],"class_list":["post-467","post","type-post","status-publish","format-standard","hentry","category-linux_-_howto-en","category-sip-tools-en"],"taxonomy_info":{"category":[{"value":685,"label":"Linux - HOWTO"},{"value":809,"label":"Tools"}]},"featured_image_src_large":false,"author_info":{"display_name":"admin","author_link":"https:\/\/nil.uniza.sk\/en\/author\/admin\/"},"comment_info":10,"category_info":[{"term_id":685,"name":"Linux - HOWTO","slug":"linux_-_howto-en","term_group":0,"term_taxonomy_id":683,"taxonomy":"category","description":"","parent":0,"count":71,"filter":"raw","cat_ID":685,"category_count":71,"category_description":"","cat_name":"Linux - HOWTO","category_nicename":"linux_-_howto-en","category_parent":0},{"term_id":809,"name":"Tools","slug":"sip-tools-en","term_group":0,"term_taxonomy_id":807,"taxonomy":"category","description":"","parent":771,"count":10,"filter":"raw","cat_ID":809,"category_count":10,"category_description":"","cat_name":"Tools","category_nicename":"sip-tools-en","category_parent":771}],"tag_info":false,"_links":{"self":[{"href":"https:\/\/nil.uniza.sk\/en\/wp-json\/wp\/v2\/posts\/467","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/nil.uniza.sk\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/nil.uniza.sk\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/nil.uniza.sk\/en\/wp-json\/wp\/v2\/users\/7"}],"replies":[{"embeddable":true,"href":"https:\/\/nil.uniza.sk\/en\/wp-json\/wp\/v2\/comments?post=467"}],"version-history":[{"count":0,"href":"https:\/\/nil.uniza.sk\/en\/wp-json\/wp\/v2\/posts\/467\/revisions"}],"wp:attachment":[{"href":"https:\/\/nil.uniza.sk\/en\/wp-json\/wp\/v2\/media?parent=467"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nil.uniza.sk\/en\/wp-json\/wp\/v2\/categories?post=467"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nil.uniza.sk\/en\/wp-json\/wp\/v2\/tags?post=467"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}