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 8012885
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T19:28:19+00:00 2026-06-04T19:28:19+00:00

I am trying to write an event-based c/c++ program which detects that how many

  • 0

I am trying to write an event-based c/c++ program which detects that how many times the network cable or the physical link (carrier signal) went down and how much packet loss is in the link. For the packet-loss, i would prefer it that it will check every second.Ideally, the pseudo code should look like;

 //C program for checking how many times physical link went down  
    if(event==physical_link_down)
    {
    link_down++;
    }

//separate C program for packet loss
    while(true)
    {
    check_packet_loss;
    sleep(1);
    }

If I’m correct, I can get the following information by doing an ifconfig where the word “RUNNING” means we have an active physical link and packet loss can be calculated from dropped/error field.

I’m using Ubuntu OS btw.

I’m thinking of doing grep with ifconfig through my C program to get the required information. Is my approach correct? Second, how do I grep through a C program as I don’t know how to do it? Similar questions have been asked but mostly those questions were asked for Windows environment. Any help will be appreciated! 🙂

  • 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-04T19:28:22+00:00Added an answer on June 4, 2026 at 7:28 pm

    As long as I know getifaddrs, only allows to know the RX or TX bytes, packet loss…, but not to know the status of the physical link.

    The interfaces used to know if the link is up or down, are ETHTOOL, or MII (wich are implemented with ethtool and mii-tool userland applications), one of those interfaces should be implemented in your network driver.

    The best code I know for this task it’s a part of the debian-installer, wich determines if a link is up. It tries with ethtool, and if it’s not successfull with mii-tool. Here you can find the code.

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

Sidebar

Related Questions

i am trying to write a custom event which should get fire when user
I'm trying to write a unit test that will raise an event on a
I am trying to write something that will fire an event anytime the hard
I'm trying to write an MPI version of a program that runs an odd/even
I’m trying to write a custom TCP based long polling server that will serve
For Pi Day, I am trying to write a Java program that tries to
I'm trying to write a fairly complex JPQL statement that sorts results based on
I am trying to write a program in C that allows me to move
I'm trying to write a callback event system in DirectX9. I'm attempting to use
I'm trying to figure out if I can write an automatic script/function/event in SQL

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.