示例#1
0
        private bool Validate(byte[] buffer, int msgLength)
        {
            // Recalculate CRC64 and check against checksum in the head
            var   decoder       = new Decoder(buffer, 0);
            ulong receivedCrc   = decoder.Decode64U();
            ulong calculatedCrc = Crc64.Compute(buffer, decoder.Position, msgLength - decoder.Position);

            return(receivedCrc == calculatedCrc);
        }
示例#2
0
        private void SendWithChecksum(byte[] data, int length)
        {
            // add a CRC64 checksum in the reserved space
            ulong crc     = Crc64.Compute(data, RESERVED, length - RESERVED);
            var   encoder = new Encoder(data, 0);

            encoder.Encode64U(crc);
            RawSend(data, length);

            if (kcp.WaitSnd > 1000 && logger.WarnEnabled())
            {
                logger.LogWarning("Too many packets waiting in the send queue " + kcp.WaitSnd + ", you are sending too much data,  the transport can't keep up");
            }
        }