Profiling the network stack

Is there any way to hook into the various parts of the networking stack (DNS resolution, TCP handshake, etc) to measure performance? I know you can add an NSURLProtocol to measure some parts, but I wonder if there's any way to measure further down the stack.

Profiling the network stack
 
 
Q