code: func (e *endpoint) WritePacket(r *stack.Route, gso *stack.GSO, hdr buffer.Prependable, payload buffer.VectorisedView, protocol tcpip.NetworkProtocolNumber) *tcpip.Error {
  	if atomic.LoadUint32(&LogPackets) == 1 && e.file == nil {
  		logPacket("send", protocol, hdr.View())
  	}
  	if e.file != nil && atomic.LoadUint32(&LogPacketsToFile) == 1 {
  		hdrBuf := hdr.View()
  		length := len(hdrBuf) + payload.Size()
  		if length > int(e.maxPCAPLen) {
  			length = int(e.maxPCAPLen)
  		}
  
  		buf := bytes.NewBuffer(make([]byte, 0, pcapPacketHeaderLen+length))
  		if err := binary.Write(buf, binary.BigEndian, newPCAPPacketHeader(uint32(length), uint32(len(hdrBuf)+payload.Size()))); err != nil {
  			panic(err)
  		}
  		if len(hdrBuf) > length {
  			hdrBuf = hdrBuf[:length]
  		}
  		if _, err := buf.Write(hdrBuf); err != nil {
  			panic(err)
  		}
  		length -= len(hdrBuf)
  		if length > 0 {
  			for _, v := range payload.Views() {
  				if len(v) > length {
  					v = v[:length]
  				}
  				n, err := buf.Write(v)
  				if err != nil {
  					panic(err)
  				}
  				length -= n
  				if length == 0 {
  					break
  				}
  			}
  		}
  		if _, err := e.file.Write(buf.Bytes()); err != nil {
  			panic(err)
  		}
  	}
  	return e.lower.WritePacket(r, gso, hdr, payload, protocol)
  }
docs: // WritePacket implements the stack.LinkEndpoint interface. It is called by
  // higher-level protocols to write packets; it just logs the packet and forwards
  // the request to the lower endpoint.