linux - libpcap setfilter() function and packet loss -


this first question here @stackoverflow.

i'm writing monitoring tool voip production servers, particularly sniff tool allows capture traffic (voip calls) match given pattern using pcap library in perl.

i cannot use poor selective filters e.g. "udp" , filtering in app's code, because involve traffic , kernel wouldn't cope reporting packet loss.

what iteratively build more selective filter possible during capture. @ beginning capture (all) sip signalling traffic , ip fragments (the pattern match has done @ application level in case) when find information rtp sip packets, add 'or' clauses actual filter-string specific ip , port , re-set filter setfilter().

so this:

  1. initial filter : "(udp , port 5060) or (udp , ip[6:2] & 0x1fff != 0)" -> captures sip traffic , ip fragments

  2. updated filter : "(udp , port 5060) or (udp , ip[6:2] & 0x1fff != 0) or (host ip , port port)" -> captures rtp on specific ip,port

  3. updated filter : "(udp , port 5060) or (udp , ip[6:2] & 0x1fff != 0) or (host ip , port port) or (host ip2 , port port2)" -> captures second rtp stream well

and on.

this works quite well, i'm able 'real' packet loss of rtp streams monitoring purposes, whereas poor selective filter version of tool, rtp packet loss percentage wasn't reliable because there packets missing due packet drop kernel.

but let's drawback of approach.

calling setfilter() while capturing involves fact libpcap drops packets received "while changing filter" stated in code comments function set_kernel_filter() pcap-linux.c (checked libpcap version 0.9 , 1.1).

so happens when call setfilter() , packets arrive ip-fragmented, loose fragments, , not reported libpcap statistics @ end: spotted digging traces.

now, understand reason why action done libpcap, in case need not have packet drop (i don't care getting unrelated traffic).

would have idea on how solve problem not modifying libpcap's code?

what starting new process more specific filter. have 2 parallel pcap captures going @ once. after time (or checking both received same packets) stop original.


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -