Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fetching the TCP RTT in Linux

Tags:

linux

procfs

I need to fetch the RTT for TCP flow. I have looked into the proc file system but not able to get the RTT value of TCP .If any one having any idea regarding it that, in which file RTT would be stored pleae share.

Thanks in advance.

like image 378
Karan_Rana Avatar asked Apr 26 '13 08:04

Karan_Rana


People also ask

How is TCP RTT measured?

Propagation delay is the length of time taken for a request to reach its destination. The propagation delay is usually the dominant component in RTT and you can get a good estimate of RTT by a simple formula: RTT = 2 x Propagation delay.


3 Answers

Maybe the ss (socket statistics) util available in the iproute utils can help you with this.

# ss -i 'src 1.1.1.1:1234 and dst 2.2.2.2:1234'
State      Recv-Q Send-Q                         Local Address:Port                             Peer Address:Port
ESTAB      0      0                              1.1.1.1:1234                                   2.2.2.2:1234
    reno wscale:2,7 rto:3380 rtt:855/602.5 ato:40 ssthresh:2 send 27.3Kbps rcv_space:5840

If you want more information what the rtt field is i think it is best to take a look at ss.c.

like image 184
Mattias Wadman Avatar answered Nov 22 '22 02:11

Mattias Wadman


You can so this using tcpprobe (inserts a hook into the tcp_recv processing path using kprobe and records the state of a TCP connection in response to incoming packets).

Explained here: Extract TCP round trip time (RTT) estimations on linux

like image 41
kakhkAtion Avatar answered Nov 22 '22 01:11

kakhkAtion


It also possible to print the cached rtts (and rttvar, cwnd) for previous destinations using the ip command:

sudo ip tcp_metrics
like image 40
Pierz Avatar answered Nov 22 '22 01:11

Pierz