github.com/database64128/shadowsocks-go@v1.7.0/service/udp.go (about)

     1  package service
     2  
     3  import (
     4  	"errors"
     5  	"time"
     6  )
     7  
     8  const (
     9  	// minimumMTU is the minimum allowed MTU.
    10  	minimumMTU = 1280
    11  
    12  	// defaultRelayBatchSize is the default batch size of recvmmsg(2) and sendmmsg(2) calls in relay sessions.
    13  	//
    14  	// On an i9-13900K, the average number of messages received in a single recvmmsg(2) call is
    15  	// around 100 in iperf3 tests. Bumping the msgvec size to greater than 256 does not seem to
    16  	// yield any performance improvement.
    17  	//
    18  	// Note that the mainline iperf3 does not use sendmmsg(2) or io_uring for batch sending at the
    19  	// time of writing. So this value is still subject to change in the future.
    20  	defaultRelayBatchSize = 256
    21  
    22  	// defaultServerRecvBatchSize is the default batch size of a UDP relay's main receive routine.
    23  	defaultServerRecvBatchSize = 64
    24  
    25  	// defaultSendChannelCapacity is the default capacity of a UDP relay session's uplink send channel.
    26  	defaultSendChannelCapacity = 1024
    27  
    28  	// minNatTimeoutSec is the minimum allowed NAT timeout in seconds.
    29  	minNatTimeoutSec = 60
    30  
    31  	// defaultNatTimeout is the default duration after which an inactive NAT entry is evicted.
    32  	defaultNatTimeout = 5 * time.Minute
    33  )
    34  
    35  var ErrMTUTooSmall = errors.New("MTU must be at least 1280")