code: func (e *endpoint) WritePacket(r *stack.Route, gso *stack.GSO, hdr buffer.Prependable, payload buffer.VectorisedView, protocol tcpip.TransportProtocolNumber, ttl uint8, loop stack.PacketLooping) *tcpip.Error {
  	length := uint16(hdr.UsedLength() + payload.Size())
  	ip := header.IPv6(hdr.Prepend(header.IPv6MinimumSize))
  	ip.Encode(&header.IPv6Fields{
  		PayloadLength: length,
  		NextHeader:    uint8(protocol),
  		HopLimit:      ttl,
  		SrcAddr:       r.LocalAddress,
  		DstAddr:       r.RemoteAddress,
  	})
  
  	if loop&stack.PacketLoop != 0 {
  		views := make([]buffer.View, 1, 1+len(payload.Views()))
  		views[0] = hdr.View()
  		views = append(views, payload.Views()...)
  		vv := buffer.NewVectorisedView(len(views[0])+payload.Size(), views)
  		e.HandlePacket(r, vv)
  	}
  	if loop&stack.PacketOut == 0 {
  		return nil
  	}
  
  	r.Stats().IP.PacketsSent.Increment()
  	return e.linkEP.WritePacket(r, gso, hdr, payload, ProtocolNumber)
  }
docs: // WritePacket writes a packet to the given destination address and protocol.