func (f *fakeNetworkEndpoint) WritePackets(r *stack.Route, gso *stack.GSO, hdrs []stack.PacketDescriptor, payload buffer.VectorisedView, params stack.NetworkHeaderParams, loop stack.PacketLooping) (int, *tcpip.Error) {
	panic("not implemented")
}
WritePackets implements stack.LinkEndpoint.WritePackets.
package stack_test
import (
	"bytes"
	"fmt"
	"math"
	"sort"
	"strings"
	"testing"
	"time"
	"github.com/google/go-cmp/cmp"
	"github.com/google/netstack/tcpip"
	"github.com/google/netstack/tcpip/buffer"
	"github.com/google/netstack/tcpip/header"
	"github.com/google/netstack/tcpip/link/channel"
	"github.com/google/netstack/tcpip/network/ipv6"
	"github.com/google/netstack/tcpip/stack"
)
const (
	fakeNetNumber        tcpip.NetworkProtocolNumber = math.MaxUint32
	fakeNetHeaderLen                                 = 12
	fakeDefaultPrefixLen                             = 8
	fakeControlProtocol tcpip.TransportProtocolNumber = 2
	defaultMTU = 65536
)
type fakeNetworkEndpoint struct {
	nicID      tcpip.NICID
	id         stack.NetworkEndpointID
	prefixLen  int
	proto      *fakeNetworkProtocol
	dispatcher stack.TransportDispatcher
	ep         stack.LinkEndpoint
}
func (f *fakeNetworkEndpoint) MTU() uint32 {
	return f.ep.MTU() - uint32(f.MaxHeaderLength())
}
func (f *fakeNetworkEndpoint) NICID() tcpip.NICID {
	return f.nicID
}
func (f *fakeNetworkEndpoint) PrefixLen() int {
	return f.prefixLen
}
func (*fakeNetworkEndpoint) DefaultTTL() uint8 {
	return 123
}
func (f *fakeNetworkEndpoint) ID() *stack.NetworkEndpointID {
	return &f.id
}
func (f *fakeNetworkEndpoint) HandlePacket(r *stack.Route, pkt tcpip.PacketBuffer) {
	f.proto.packetCount[int(f.id.LocalAddress[0])%len(f.proto.packetCount)]++
	b := pkt.Data.First()
	pkt.Data.TrimFront(fakeNetHeaderLen)
	if b[2] == uint8(fakeControlProtocol) {
		nb := pkt.Data.First()
		if len(nb) < fakeNetHeaderLen {
			return
		}
		pkt.Data.TrimFront(fakeNetHeaderLen)
		f.dispatcher.DeliverTransportControlPacket(tcpip.Address(nb[1:2]), tcpip.Address(nb[0:1]), fakeNetNumber, tcpip.TransportProtocolNumber(nb[2]), stack.ControlPortUnreachable, 0, pkt)
		return
	}
	f.dispatcher.DeliverTransportPacket(r, tcpip.TransportProtocolNumber(b[2]), pkt)
}
func (f *fakeNetworkEndpoint) MaxHeaderLength() uint16 {
	return f.ep.MaxHeaderLength() + fakeNetHeaderLen
}
func (f *fakeNetworkEndpoint) PseudoHeaderChecksum(protocol tcpip.TransportProtocolNumber, dstAddr tcpip.Address) uint16 {
	return 0
}
func (f *fakeNetworkEndpoint) Capabilities() stack.LinkEndpointCapabilities {
	return f.ep.Capabilities()
}
func (f *fakeNetworkEndpoint) WritePacket(r *stack.Route, gso *stack.GSO, params stack.NetworkHeaderParams, loop stack.PacketLooping, pkt tcpip.PacketBuffer) *tcpip.Error {
	f.proto.sendPacketCount[int(r.RemoteAddress[0])%len(f.proto.sendPacketCount)]++
	b := pkt.Header.Prepend(fakeNetHeaderLen)
	b[0] = r.RemoteAddress[0]
	b[1] = f.id.LocalAddress[0]
	b[2] = byte(params.Protocol)
	if loop&stack.PacketLoop != 0 {
		views := make([]buffer.View, 1, 1+len(pkt.Data.Views()))
		views[0] = pkt.Header.View()
		views = append(views, pkt.Data.Views()...)
		f.HandlePacket(r, tcpip.PacketBuffer{
			Data: buffer.NewVectorisedView(len(views[0])+pkt.Data.Size(), views),
		})
	}
	if loop&stack.PacketOut == 0 {
		return nil
	}
	return f.ep.WritePacket(r, gso, fakeNetNumber, pkt)
}