func (c *Context) Stack() *stack.Stack {
	return c.s
}
Stack returns a reference to the stack in the Context.
package context
import (
	"bytes"
	"testing"
	"time"
	tcpip "github.com/brewlin/net-protocol/protocol"
	"github.com/brewlin/net-protocol/pkg/buffer"
	"github.com/brewlin/net-protocol/checker"
	"github.com/brewlin/net-protocol/protocol/header"
	"github.com/brewlin/net-protocol/link/channel"
	"github.com/brewlin/net-protocol/protocol/network/ipv4"
	"github.com/brewlin/net-protocol/protocol/network/ipv6"
	"github.com/brewlin/net-protocol/pkg/seqnum"
	"github.com/brewlin/net-protocol/stack"
	"github.com/brewlin/net-protocol/protocol/transport/tcp"
	"github.com/brewlin/net-protocol/pkg/waiter"
)
const (
	StackAddr = "\x0a\x00\x00\x01"
	StackPort = 1234
	TestAddr = "\x0a\x00\x00\x02"
	TestPort = 4096
	StackV6Addr = "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01"
	TestV6Addr = "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02"
	StackV4MappedAddr = "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff" + StackAddr
	TestV4MappedAddr = "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff" + TestAddr
	V4MappedWildcardAddr = "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\x00\x00\x00\x00"
	testInitialSequenceNumber = 789
)
var defaultWindowScale = tcp.FindWndScale(tcp.DefaultBufferSize)
type Headers struct {
	SrcPort uint16
	DstPort uint16
	SeqNum seqnum.Value
	AckNum seqnum.Value
	Flags int
	RcvWnd seqnum.Size
	TCPOpts []byte
}
type Context struct {
	t      *testing.T
	linkEP *channel.Endpoint
	s      *stack.Stack
	IRS seqnum.Value
	Port uint16
	EP tcpip.Endpoint
	WQ waiter.Queue
	TimeStampEnabled bool
}
func New(t *testing.T, mtu uint32) *Context {
	s := stack.New([]string{ipv4.ProtocolName, ipv6.ProtocolName}, []string{tcp.ProtocolName}, stack.Options{})
	if err := s.SetTransportProtocolOption(tcp.ProtocolNumber, tcp.SendBufferSizeOption{1, tcp.DefaultBufferSize, tcp.DefaultBufferSize * 10}); err != nil {
		t.Fatalf("SetTransportProtocolOption failed: %v", err)
	}
	if err := s.SetTransportProtocolOption(tcp.ProtocolNumber, tcp.ReceiveBufferSizeOption{1, tcp.DefaultBufferSize, tcp.DefaultBufferSize * 10}); err != nil {
		t.Fatalf("SetTransportProtocolOption failed: %v", err)
	}
	id, linkEP := channel.New(1000, mtu, "")
	if err := s.CreateNIC(1, id); err != nil {
		t.Fatalf("CreateNIC failed: %v", err)
	}
	if err := s.AddAddress(1, ipv4.ProtocolNumber, StackAddr); err != nil {
		t.Fatalf("AddAddress failed: %v", err)
	}
	if err := s.AddAddress(1, ipv6.ProtocolNumber, StackV6Addr); err != nil {
		t.Fatalf("AddAddress failed: %v", err)
	}
	s.SetRouteTable([]tcpip.Route{
		{
			Destination: "\x00\x00\x00\x00",
			Mask:        "\x00\x00\x00\x00",
			Gateway:     "",
			NIC:         1,
		},
		{
			Destination: "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
			Mask:        "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
			Gateway:     "",
			NIC:         1,
		},
	})
	return &Context{
		t:      t,
		s:      s,
		linkEP: linkEP,
	}
}
func (c *Context) Cleanup() {
	if c.EP != nil {
		c.EP.Close()
	}
}