[Twisted-Python] Writing a low-level network debugging tool

Jonathan Ballet jon at multani.info
Fri Nov 27 07:05:35 MST 2015


Hi all,

I'm trying to toubleshoot network connectivity issues we have in one of 
our office and I would like to monitor some metrics which seems to be 
relevant for us, especially when trying to open TCP connections towards 
external endpoints.

In particular, I'm looking for a way to get the following information 
(let's say I want to monitor the connectivity towards the swisscom.com, 
port 80 using TCP):

* how long does it take to resolv the domain name to (at least) one of 
its IP address
   - against a specified name server or using the system configured 
servers
   - how many tries did it require
     * if there were several tries, the timing of each ones

* how long does it take to get the first bytes of the endpoint
   - how long does it take to complete the TCP connection handshake
   - the status of the packets exchanged (how many retries, how many 
packets lost, etc.)

It's not exactly the same, but the curl option --write-out allows to get 
this kind of values (especially time_namelookup, time_connect, 
time_pretransfer, time_starttransfer and time_total) but I would like to 
have more flexibility and more in-depth informations (like the state of 
the packets exchanged, etc.)

How far can I do this kind of things with Twisted? I know I can somewhat 
easily get the timings of the name resolution, the TCP connection 
handshake also and the time to first byte(s), but what about the 
packets? I haven't look at the code of Twisted Names yet, but if it's 
doing the DNS request by itself, I may be able to plug-in somewhere and 
have my request counter and the timers associated, but I'm not sure if 
the underlying details of the TCP protocol are exposed to the upper 
layer such as Twisted?

Thanks for the help!

  Jonathan



More information about the Twisted-Python mailing list