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

  • SEARCH
  • Home
  • 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 8763909
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T15:53:39+00:00 2026-06-13T15:53:39+00:00

So I basically have the ability to capture some packets from a multicast environment

  • 0

So I basically have the ability to capture some packets from a multicast environment and I save them to file and then I multicast them out to applications which expect multicast data. I do this for simulation purposes. It’s a relatively simple tool, and it has served me well when replaying 10 or even 50K packets to an application running in gdb. My replay loop looks like this:

for (size_t i = 0; i < packets_.size(); ++i)
    publisher_.publish(packets_[i].buf_, packets_[i].len_);

and the problem is that when packets_.size() is around 100-200K (I would never need to do more than that) I seem to experience packet loss when somebody is listening. I am guessing this is because they are replayed in one continuous burst. If I tried things like:

for (size_t i = 0; i < packets_.size(); ++i)
{
    if (i % Y == 0) usleep(X);
    publisher_.publish(packets_[i].buf_, packets_[i].len_);
}

for varying amounts in Y and X (like 1000/1000 and many other combos) but this doesn’t work very well. My guess was that I could patch this up if I could busy chew cycles on every iteration for a very small amount of time. Busy chew because I don’t want to yield to other processes and thus take longer than expected, but a very small amount, not even a millisecond because that would entail 200 seconds of waiting to multicast out the packets. Repeated calls in a loop to a sleep function seem to yield and slow me down considerably, which is why I was wondering what a simple way to spin for maybe a quarter, fifth, half, or so of a millisecond (roughly) be?

Or if there would be a better and simple way to patch this for this use case?

  • 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-06-13T15:53:41+00:00Added an answer on June 13, 2026 at 3:53 pm

    Function below keeps system ‘busy’ for some unspecified time:

    static long slow( volatile long l ) {
       while ( l-- > 0 )  ;
       return l ;
    }
    

    Take some number, let’s say 1000, and then run slow( N ) and at the same time count how long did it take taking clock_t t = clock() before and after call. Increase N, and repeat the same opertion until you find the number N that will keep the loop busy for 1 second. You will have now a function and a number that will keep the system busy for one second.

    Hope it will help.

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

Sidebar

Related Questions

I basically have a program that filters records from one excel file to another
I basically have a unix process running and it is doing some heavy processing
I have written a jQuery plugin called waitForImages . It basically gives the ability
We have an app that basically parsers some web pages. The thing is the
I basically have three tables, posts, images and postimages (this simply contains the ids
I basically have a server set up and I'm accepting new clients(UNIX) and i'm
I basically have the following string in the format: A,B,C:D,E,F What I am trying
I basically have 7 select statements that I need to have the results output
I basically have to do a update of a record. I have a set
I basically have to write a clone of the UNIX ls command for a

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.