func incSynRcvdCount() bool {
	synRcvdCount.Lock()
	if synRcvdCount.value >= SynRcvdCountThreshold {
		synRcvdCount.Unlock()
		return false
	}
	synRcvdCount.pending.Add(1)
	synRcvdCount.value++
	synRcvdCount.Unlock()
	return true
}
incSynRcvdCount tries to increment the global number of endpoints in SYN-RCVD
state. It succeeds if the increment doesn't make the count go beyond the
threshold, and fails otherwise.
package tcp
import (
	"crypto/sha1"
	"encoding/binary"
	"hash"
	"io"
	"sync"
	"time"
	"github.com/google/netstack/rand"
	"github.com/google/netstack/sleep"
	"github.com/google/netstack/tcpip"
	"github.com/google/netstack/tcpip/buffer"
	"github.com/google/netstack/tcpip/header"
	"github.com/google/netstack/tcpip/seqnum"
	"github.com/google/netstack/tcpip/stack"
	"github.com/google/netstack/waiter"
)
const (
	tsLen = 8
	tsMask = (1 << tsLen) - 1
	tsOffset = 24
	hashMask = (1 << tsOffset) - 1
	maxTSDiff = 2
)
var (
	SynRcvdCountThreshold uint64 = 1000
	mssTable = []uint16{536, 1300, 1440, 1460}
)
func encodeMSS(mss uint16) uint32 {
	for i := len(mssTable) - 1; i > 0; i-- {
		if mss >= mssTable[i] {
			return uint32(i)
		}
	}
	return 0
}
var synRcvdCount struct {
	sync.Mutex
	value   uint64
	pending sync.WaitGroup
}
type listenContext struct {
	stack    *stack.Stack
	rcvWnd   seqnum.Size
	nonce    [2][sha1.BlockSize]byte
	listenEP *endpoint
	hasherMu sync.Mutex
	hasher   hash.Hash
	v6only   bool
	netProto tcpip.NetworkProtocolNumber
	pendingMu sync.Mutex
	pending sync.WaitGroup
	pendingEndpoints map[stack.TransportEndpointID]*endpoint
}
func timeStamp() uint32 {
	return uint32(time.Now().Unix()>>6) & tsMask
}