Results 1 to 7 of 7

Thread: Determining Network Interface Bit Rates?

  1. #1
    Join Date
    Jan 2013
    Beans
    62
    Distro
    Ubuntu 14.04 Trusty Tahr

    Question Determining Network Interface Bit Rates?

    I'm writing a program in C that wants to measure the traffic volume on each network interface, as System Monitor does. Can someone tell me which library calls I want and where they're documented?

    Thanks.

  2. #2
    Join Date
    Feb 2007
    Location
    West Hills CA
    Beans
    10,048
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: Determining Network Interface Bit Rates?

    I would get friendly with netstat:

    Code:
    man netstat
    -------------------------------------
    Oooh Shiny: PopularPages

    Unumquodque potest reparantur. Patientia sit virtus.

  3. #3
    Join Date
    Jan 2013
    Beans
    62
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: Determining Network Interface Bit Rates?

    netstat is certainly one option. I'm really looking for library calls, though, as I eventually want to run this on a stripped-down system on an SBC so I'd prefer to avoid dealing with forking overhead, mode switches or relying on utilities that I may have removed to save space.

  4. #4
    Join Date
    Feb 2007
    Location
    West Hills CA
    Beans
    10,048
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: Determining Network Interface Bit Rates?

    http://unix.stackexchange.com/questi...ode-of-netstat

    http://src.gnu-darwin.org/src/usr.bi...netstat.c.html

    I challenge you to write a shorter algorithm (in C) to perform the same functions.
    -------------------------------------
    Oooh Shiny: PopularPages

    Unumquodque potest reparantur. Patientia sit virtus.

  5. #5
    Join Date
    Jan 2013
    Beans
    62
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: Determining Network Interface Bit Rates?

    Thank you. I shall have to read that code in depth this evening, but at first blush it appears to be exactly what I want. With any luck I can mark this thread solved by the end of the week.

  6. #6
    Join Date
    Feb 2007
    Location
    West Hills CA
    Beans
    10,048
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: Determining Network Interface Bit Rates?

    I would spend several hours running netstat with all of it's functions and get comfortable using it. Then if it does not do something that you want, you can modify the source code and recompile it (call it netstat2) or look at the System Monitor source code and see how it works.

    There are so many network monitor tools:

    Code:
    apt-cache search network monitor
    -------------------------------------
    Oooh Shiny: PopularPages

    Unumquodque potest reparantur. Patientia sit virtus.

  7. #7
    Join Date
    Aug 2011
    Location
    47°9′S 126°43W
    Beans
    2,165
    Distro
    Kubuntu 14.04 Trusty Tahr

    Re: Determining Network Interface Bit Rates?

    I have a script that tells me plenty of things about the network just by looking at the contents of /proc/net/dev
    Warning: unless noted otherwise, code in my posts should be understood as "coding suggestions", and its use may require more neurones than the two necessary for Ctrl-C/Ctrl-V.

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •