github.com/GeniusesGroup/libgo@v0.0.0-20220929090155-5ff932cb408e/tcp/const.go (about)

     1  /* For license and copyright information please see the LEGAL file in the code repository */
     2  
     3  package tcp
     4  
     5  import (
     6  	"github.com/GeniusesGroup/libgo/timer"
     7  )
     8  
     9  // ATTENTION:::: Don't changed below settings without any good reason
    10  // https://man7.org/linux/man-pages/man7/tcp.7.html
    11  const (
    12  	// default congestion-control algorithm to be used for new tcp sockets
    13  	CongestionControlAlgorithm = CongestionControlAlgorithm_Reno
    14  
    15  	// When enabled, connectivity to some destinations could be
    16  	// affected due to older, misbehaving middle boxes along the
    17  	// path, causing connections to be dropped.  However, to
    18  	// facilitate and encourage deployment with option 1, and to
    19  	// work around such buggy equipment, the tcp_ecn_fallback
    20  	// option has been introduced.
    21  	ExplicitCongestionNotification = ExplicitCongestionNotification_EnabledOnRequested
    22      // Enable RFC 3168, Section 6.1.1.1. fallback. When enabled,
    23      // outgoing ECN-setup SYNs that time out within the normal
    24      // SYN retransmission timeout will be resent with CWR and ECE cleared.
    25  	ExplicitCongestionNotification_fallback = true
    26  
    27  	// negative of TCP_QUICKACK in linux which will disable the "Nagle" algorithm
    28  	DelayedAcknowledgment         = true
    29  	DelayedAcknowledgment_Timeout = 500 * timer.Millisecond
    30  	// NoDelay controls whether the operating system should delay
    31  	// packet transmission in hopes of sending fewer packets (Nagle's algorithm).
    32  	// The default is true (no delay), meaning that data is
    33  	// sent as soon as possible after a Write.
    34  	NoDelay = true // TODO::: need it in user-space??
    35  
    36  	// keep-alive message means send ACK to peer to force OS and
    37  	// any NAT mechanism in network layer to keep open the tcp stream in their routing tables.
    38  	KeepAlive_Message = true
    39  
    40  	// The number of seconds between TCP keep-alive probes.
    41  	KeepAlive_Interval = 75 * timer.Second
    42  	// The maximum number of TCP keep-alive probes to send before giving up and
    43  	// killing the socket connection if no response is obtained from the other end.
    44  	KeepAlive_Probes = 9
    45  	// The time (in seconds) the connection needs to remain idle before TCP starts sending keepalive probes.
    46  	// terminated after approximately an additional 11 minutes (9 probes an interval of 75 seconds apart)
    47  	KeepAlive_Idle = 7200 * timer.Second // (2 hours)
    48  
    49  	// Linger sets the behavior of Close on a connection which still
    50  	// has data waiting to be sent or to be acknowledged.
    51  	//
    52  	// If sec < 0 (the default), the operating system finishes sending the
    53  	// data in the background.
    54  	//
    55  	// If sec == 0, the operating system discards any unsent or
    56  	// unacknowledged data.
    57  	//
    58  	// If sec > 0, the data is sent in the background as with sec < 0. On
    59  	// some operating systems after sec seconds have elapsed any remaining
    60  	// unsent data may be discarded.
    61  	Linger = -1
    62  
    63  	// The lifetime of orphaned FIN_WAIT2 state sockets. This
    64  	// option can be used to override the system-wide setting in
    65  	// the file /proc/sys/net/ipv4/tcp_fin_timeout for this
    66  	// socket. This is not to be confused with the socket(7)
    67  	// level option SO_LINGER.  This option should not be used in
    68  	// code intended to be portable.
    69  	Linger2 = 0
    70  )
    71  
    72  // ATTENTION:::: Don't changed below settings without any good reason
    73  const (
    74  	MinPacketLen      = 20 // 5words * 4bit
    75  	OptionDefault_MSS = 536
    76  )