2004-06-02 12:57:32

by Paul Rolland

[permalink] [raw]
Subject: TCP retransmission : how to detect from an application ?

Hello,

I've an application that is establishing TCP connection, and exchanges some
data.
However, from time to time, I suspect there are some packet loss, which are
corrected by the kernel (hell, TCP is reliable, isn't it :-), but I'd like
to know if an application can detect this (well, I don't want to be notified
of a packet loss once detected, but I'd like to get some stats before
closing
the connection).

Is there something possible ? Some ioctl ? Some /proc/magic-interface ?

Regards,
Paul

Paul Rolland, rol(at)as2917.net
ex-AS2917 Network administrator and Peering Coordinator

--

Please no HTML, I'm not a browser - Pas d'HTML, je ne suis pas un navigateur

"Some people dream of success... while others wake up and work hard at it"





2004-06-02 13:33:36

by Andi Kleen

[permalink] [raw]
Subject: Re: TCP retransmission : how to detect from an application ?

"Paul Rolland" <[email protected]> writes:

> I've an application that is establishing TCP connection, and exchanges some
> data.
> However, from time to time, I suspect there are some packet loss, which are
> corrected by the kernel (hell, TCP is reliable, isn't it :-), but I'd like
> to know if an application can detect this (well, I don't want to be notified
> of a packet loss once detected, but I'd like to get some stats before
> closing
> the connection).
>
> Is there something possible ? Some ioctl ? Some /proc/magic-interface ?

RTFM. man tcp -> TCP_INFO

-Andi

2004-06-02 14:58:33

by Paul Rolland

[permalink] [raw]
Subject: Re: TCP retransmission : how to detect from an application ?

Hello,

>
> RTFM. man tcp -> TCP_INFO
>
Thanks... It seems that my man pages are quite outdated, but I've found
the information I was missing.

Regards,
Paul

Paul Rolland, rol(at)as2917.net
ex-AS2917 Network administrator and Peering Coordinator

--

Please no HTML, I'm not a browser - Pas d'HTML, je ne suis pas un navigateur

"Some people dream of success... while others wake up and work hard at it"



2004-06-02 20:28:58

by Patrick McManus

[permalink] [raw]
Subject: Re: TCP retransmission : how to detect from an application ?

On Wed, 2004-06-02 at 08:57, Paul Rolland wrote:
> corrected by the kernel (hell, TCP is reliable, isn't it :-), but I'd like
> to know if an application can detect this (well, I don't want to be notified
> of a packet loss once detected, but I'd like to get some stats before
> closing
> the connection).

#include <linux/tcp.h>

struct tcp_info info;

getsockopt (... TCP_INFO ... &info ...);

and you get all of this (you'll have to see net/ipv4/tcp.c to see how it
all gets filled in.. I'm not aware of better documentation than that):

struct tcp_info
{
__u8 tcpi_state;
__u8 tcpi_ca_state;
__u8 tcpi_retransmits;
__u8 tcpi_probes;
__u8 tcpi_backoff;
__u8 tcpi_options;
__u8 tcpi_snd_wscale : 4, tcpi_rcv_wscale : 4;

__u32 tcpi_rto;
__u32 tcpi_ato;
__u32 tcpi_snd_mss;
__u32 tcpi_rcv_mss;

__u32 tcpi_unacked;
__u32 tcpi_sacked;
__u32 tcpi_lost;
__u32 tcpi_retrans;
__u32 tcpi_fackets;

/* Times. */
__u32 tcpi_last_data_sent;
__u32 tcpi_last_ack_sent; /* Not remembered, sorry. */
__u32 tcpi_last_data_recv;
__u32 tcpi_last_ack_recv;

/* Metrics. */
__u32 tcpi_pmtu;
__u32 tcpi_rcv_ssthresh;
__u32 tcpi_rtt;
__u32 tcpi_rttvar;
__u32 tcpi_snd_ssthresh;
__u32 tcpi_snd_cwnd;
__u32 tcpi_advmss;
__u32 tcpi_reordering;
};