Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3485094
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T10:51:59+00:00 2026-05-18T10:51:59+00:00

this is my first question here @stackoverflow. I’m writing a monitoring tool for some

  • 0

this is my first question here @stackoverflow.

I’m writing a monitoring tool for some VoIP production servers, particularly a sniff tool that allows to capture all traffic (VoIP calls) that match a given pattern using pcap library in Perl.

I cannot use poor selective filters like e.g. “udp” and then do all the filtering in my app’s code, because that would involve too much traffic and the kernel wouldn’t cope reporting packet loss.

What I do then is to iteratively build the more selective filter possible during the capture. At the beginning I capture only (all) SIP signalling traffic and IP fragments (the pattern match has to be done at application level in any case) then when I find some information about RTP into SIP packets, I add ‘or’ clauses to the actual filter-string with specific IP and PORT and re-set the filter with setfilter().

So basically something like this:

  1. Initial filter : “(udp and port 5060) or (udp and ip[6:2] & 0x1fff != 0)” -> captures all SIP traffic and IP fragments

  2. Updated filter : “(udp and port 5060) or (udp and ip[6:2] & 0x1fff != 0) or (host IP and port PORT)” -> Captures also the RTP on specific IP,PORT

  3. Updated filter : “(udp and port 5060) or (udp and ip[6:2] & 0x1fff != 0) or (host IP and port PORT) or (host IP2 and port PORT2)” -> Captures a second RTP stream as well

And so on.

This works quite well, as I’m able to get the ‘real’ packet loss of RTP streams for monitoring purposes, whereas with a poor selective filter version of my tool, the RTP packet loss percentage wasn’t reliable because there was some packets missing due to packet drop by kernel.

But let’s get to the drawback of this approach.

Calling setfilter() while capturing involves the fact that libpcap drops packets received “while changing the filter” as stated in code comments for function set_kernel_filter() into pcap-linux.c (checked libpcap version 0.9 and 1.1).

So what happens is that when I call setfilter() and some packets arrive IP-fragmented, I do loose some fragments, and this is not reported by libpcap statistics at the end: I spotted it digging into traces.

Now, I understand the reason why this action is done by libpcap, but in my case I definitely need not to have any packet drop (I don’t care about getting some unrelated traffic).

Would you have any idea on how to solve this problem that is not modifying libpcap’s code?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T10:51:59+00:00Added an answer on May 18, 2026 at 10:51 am

    What about starting up a new process with the more specific filter. You could have two parallel pcap captures going at once. After some time (or checking that both received the same packets) you could stop the original.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Greetings to all! This is my first question here on stackoverflow. I have a
this is my first question to stackoverflow so here it goes... I use cruise
Greetings everyone. This is my first question here at stackoverflow so please bear with
Hey stackoverflow - This is my first question here. I have 2 tables in
this is my first question here so I hope I can articulate it well
Hi again fellow Flashers :) My first question poised here at StackOverFlow dealt with
This is my first question on stackoverflow. I just wonder why my getJSON code
This is my first question in StackOverflow, so I would try to explain my
Good morning, all. This is my first question on stackoverflow, so hopefully this isn't
This is my first question so please be patient :) Background: I'm implementing an

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.