# setsockopt: TCP_MAXRT



## Juan_ma (Sep 5, 2012)

Hi,

 Do you know if BSD 4.4 standard tcp option is available in FreeBSD: TCP_MAXRT? I cannot see it in the man pages.

 Does any body know if it is going to be supported?

Thanks,

Juanma


----------



## SirDice (Sep 5, 2012)

From tcp(4):

```
rexmit_min, rexmit_slop
                        Adjust the retransmit timer calculation for TCP.  The
                        slop is typically added to the raw calculation to take
                        into account occasional variances that the SRTT
                        (smoothed round-trip time) is unable to accommodate,
                        while the minimum specifies an absolute minimum.
                        While a number of TCP RFCs suggest a 1 second minimum,
                        these RFCs tend to focus on streaming behavior, and
                        fail to deal with the fact that a 1 second minimum has
                        severe detrimental effects over lossy interactive con-
                        nections, such as a 802.11b wireless link, and over
                        very fast but lossy connections for those cases not
                        covered by the fast retransmit code.  For this reason,
                        we use 200ms of slop and a near-0 minimum, which gives
                        us an effective minimum of 200ms (similar to Linux).
```


----------



## Juan_ma (Sep 5, 2012)

Thanks for you quick reply SirDice.

I'm not sure rexmit_min, rexmit_slop can be used for what I would like.

I would like to use TCP_MAXRT in order to say TCP connection is broken once this timer is elapsed. Another way of achieving it would be to do it by means of TM_TCP_MAX_REXMIT option. rexmit_min, rexmit_slop seems to be more related to the minimum time to start retransmission.

Here you have what BSD 4.4 socket API says about it:

Sets the amount of time in seconds before the connection is broken once TCP starts retransmitting, or probing a zero window when the peer does not respond. A TCP_MAXRT value of 0 means the system default, and -1 means retransmit forever. If a positive value is specified, it may be rounded up to the connection next retransmission time. Note that unless the TCP_MAXRT value is -1 (transmit forever), the connection can also be broken if the number of maximum retransmission TM_TCP_MAX_REXMIT has been reached. See TM_TCP_MAX_REXMIT below.
Default 0. Meaning: use the system default of TM_TCP_MAX_REXMIT times network computed round trip time for an established connection. For a non-established connection, since there is no computed round trip time yet, the connection can be broken when either 75 seconds or when TM_TCP_MAX_REXMIT times default network round trip time have elapsed, whichever occurs first).


----------



## expl (Sep 6, 2012)

Juan_ma said:
			
		

> Thanks for you quick reply SirDice.
> 
> I'm not sure rexmit_min, rexmit_slop can be used for what I would like.
> 
> ...



You can implement this behavior using SO_RCVTIMEO and SO_SNDTIMEO flags on socket covered in setsockopt().

edit:
This will not work if you are running multithreaded environment or asynchronous sockets.


----------

