views:

21

answers:

0

I want to meassure the time it takes for an interface on a linux system to a) become up and b) become IP capable.

This would invoke as a first step to get the linux kernel to tell in some way to call a python function when an 'interface up request' has been sent.

  1. Some application (e.g. d-bus) requests: 'iface up' => timer_1.start()
  2. kernel recognizes the interface is up => timer_1.stop()
  3. interface send's out DHCP request => timer_2.start()
  4. interface has an IP => timer_2.stop()

I could perform task 1 and 2 in a different way, by polling a POSIX call (SIOCGIFFLAGS, 0x8913) over and over again. So if the endless loop recognizes a change it starts and stops timer1. But this is not very precise, as the result depends on the resolution the loop runs.

There is already a solution for this written in python out there:

http://code.activestate.com/recipes/65449-query-whether-an-interface-is-up-on-unix/

How would you solve such a thing on a linux system with twisted and python?

Any help is greatlly appreciated...