linux socket TCP control

In TCP protocol, it send the data to server and receive acknowledgement. if failed receive acknowledgement, then it will send again same data. it will try this for certain time. how can i control in socket created in linux? not seen any option in setsockopt function. is there any function exist to control this?

Linux Learner
Honestly man, at least try googling stuff.
.. or read the man page.
Hi Embedded,

Look at the famous Beej's Guide to Network Programming. It is dedicated to Linux Socket programming although it can be easily changed into Windows it has all Linux Network Programming types


I read SO_RCVTIMEO and SO_SNDTIMEO can control timing. if this time expire, then crossponding sending or receiving will fail. it will try again. how can i control that try to connection. is there any option?
I dion't understand. What control are you asking about?

I would have thought you already have everything you need.
in TCP once it send the packet and wait for acknowledge. if it is not receiving any ack, then it will send again data. after multiple attempts, it will show failed status. is there any way to control these multiple attempts?
I don't know. Have you looked at the source code for your platform?
As with so many things in Linux, this is explained in the man page
man tcp wrote:

These variables can be accessed by the /proc/sys/net/ipv4/* files or
with the sysctl(2) interface.
tcp_retries2 (integer; default: 15)
The maximum number of times a TCP packet is retransmitted in
established state before giving up. The default value is 15,
which corresponds to a duration of approximately between 13 to
30 minutes, depending on the retransmission timeout. The
RFC 1122 specified minimum limit of 100 seconds is typically
deemed too short.

I am seeing two files for retry, like

root@abc-desktop:cat /proc/sys/net/ipv4/tcp_retries1
root@abc-desktop:~/Desktop$ cat /proc/sys/net/ipv4/tcp_retries2

what is difference between tcp_retries1 and tcp_retries2, how these are used.

second, i am able to see any retries option for sysctl interface, like
1) /etc/sysctl.conf
2) sysctl function call.

How can i use this for setting retry option?

You've been looking at this for a month now. Have you considered looking at the source code? That's the whole point of open source.
Even open source has documentation: man 7 tcp describes the purpose of tcp_retries1 and tcp_retries2, and man 2 sysctl explains how to call sysctl, if you have to.

The only source code file you need to see is /usr/include/linux/sysctl.h to learn that tcp_retries2 is known to sysctl as NET_IPV4_TCP_RETRIES2
Topic archived. No new replies allowed.