Пример #1
0
 /// <summary>
 /// Sends the ack.
 /// </summary>
 /// <param name='ackType'>
 /// Ack type.
 /// </param>
 private void sendAck(bool ackType)
 {
     byte[] ackBuf = new byte[(int)TransSize.ACKSIZE];
     ackBuf [(int)TransCHKSUM.SEQNO] = (byte)
                                       (ackType ? (byte)buffer [(int)TransCHKSUM.SEQNO] : (byte)(buffer [(int)TransCHKSUM.SEQNO] + 1) % 2);
     ackBuf [(int)TransCHKSUM.TYPE] = (byte)(int)TransType.ACK;
     checksum.calcChecksum(ref ackBuf, (int)TransSize.ACKSIZE);
     link.send(ackBuf, (int)TransSize.ACKSIZE);
 }
Пример #2
0
 /// <summary>
 /// Sends the ack.
 /// </summary>
 /// <param name='ackType'>
 /// Ack type.
 /// </param>
 private void sendAck(bool ackType)
 {
     byte[] ackBuf = new byte[(int)TransSize.ACKSIZE];
     ackBuf[(int)TransCHKSUM.SEQNO] = (byte)
                                      (ackType ? (byte)buffer[(int)TransCHKSUM.SEQNO] : (byte)(buffer[(int)TransCHKSUM.SEQNO] + 1) % 2);
     ackBuf[(int)TransCHKSUM.TYPE] = (byte)(int)TransType.ACK;
     checksum.calcChecksum(ref ackBuf, (int)TransSize.ACKSIZE);
     if ((++errorCount) == 3) // der er brugt if-statement til at tælle antal error.
     {
         ackBuf[2]++;
         Console.WriteLine($"Byte: (2) --> {errorCount} Transmitted ACK package)");
     }
     link.send(ackBuf, (int)TransSize.ACKSIZE);
 }
Пример #3
0
 /// <summary>
 /// Sends the ack.
 /// </summary>
 /// <param name='ackType'>
 /// Ack type.
 /// </param>
 private void sendAck(bool ackType)
 {
     byte[] ackBuf = new byte[(int)TransSize.ACKSIZE];
     ackBuf [(int)TransCHKSUM.SEQNO] = (byte)
                                       (ackType ? (byte)buffer [(int)TransCHKSUM.SEQNO] : (byte)(buffer [(int)TransCHKSUM.SEQNO] + 1) % 2);
     ackBuf [(int)TransCHKSUM.TYPE] = (byte)(int)TransType.ACK;
     checksum.calcChecksum(ref ackBuf, (int)TransSize.ACKSIZE);
     if (++errorCount == 2)           // Simulate noise
     {
         ackBuf[1]++;                 // Important: Only spoil a checksum-field (ackBuf[0] or ackBuf[1])
         Console.WriteLine("Noise! byte #1 is spoiled in the third transmitted ACK-package");
     }
     link.send(ackBuf, (int)TransSize.ACKSIZE);
 }
Пример #4
0
/// <summary>
/// Sends the ack.
/// </summary>
/// <param name='ackType'>
/// Ack type.
/// </param>
        private void SendAck(bool ackType)
        {
            byte[] ackBuf = new byte[(int)TransSize.ACKSIZE];
            ackBuf [(int)TransCHKSUM.SEQNO] = (byte)
                                              (ackType ? (byte)_buffer [(int)TransCHKSUM.SEQNO] : (byte)(_buffer [(int)TransCHKSUM.SEQNO] + 1) % 2);
            ackBuf [(int)TransCHKSUM.TYPE] = (byte)(int)TransType.ACK;
            _checksum.calcChecksum(ref ackBuf, (int)TransSize.ACKSIZE);
            if (++_errorCount == 3)
            {
                ackBuf[1]++;
                Console.WriteLine("Byte 1 spoiled in ACK-package {0}", _errorCount);
            }
            _link.Send(ackBuf, (int)TransSize.ACKSIZE);
        }
Пример #5
0
        /// <summary>
        /// Sends the ack.
        /// </summary>
        /// <param name='ackType'>
        /// Ack type.
        /// </param>
        private void sendAck(bool ackType)
        {
            byte[] ackBuf = new byte[(int)TransSize.ACKSIZE];
            ackBuf[(int)TransCHKSUM.SEQNO] = (byte)
                                             (ackType ? (byte)buffer[(int)TransCHKSUM.SEQNO] : (byte)(buffer[(int)TransCHKSUM.SEQNO] + 1) % 2);
            ackBuf[(int)TransCHKSUM.TYPE] = (byte)(int)TransType.ACK;
            checksum.calcChecksum(ref ackBuf, (int)TransSize.ACKSIZE);

            if (++errorCount2 == 10)
            {
                ackBuf[1]++;
                Console.WriteLine("  -   Noise introduced - byte 1 has been spoiled in ACK-message");
            }

            link.send(ackBuf, (int)TransSize.ACKSIZE);
        }
Пример #6
0
        /// <summary>
        /// Sends the ack.
        /// </summary>
        /// <param name='ackType'>
        /// Ack type.
        /// </param>
        private void SendAck(bool ackType)
        {
            byte[] ackBuf = new byte[(int)TransSize.ACKSIZE];
            ackBuf[(int)TransCHKSUM.SEQNO] = (byte)
                                             (ackType ? _buffer[(int)TransCHKSUM.SEQNO] : (byte)(_buffer[(int)TransCHKSUM.SEQNO] + 1) % 2);
            ackBuf[(int)TransCHKSUM.TYPE] = (byte)(int)TransType.ACK;
            _checksum.calcChecksum(ref ackBuf, (int)TransSize.ACKSIZE);

            if (++_noiseSimulation == 2)
            {
                ackBuf[0]++;
                _noiseSimulation = 0;
            }

            _link.Send(ackBuf, (int)TransSize.ACKSIZE);
        }
Пример #7
0
        /// <summary>
        /// Sends the ack.
        /// </summary>
        /// <param name='ackType'>
        /// Ack type.
        /// </param>
        private void SendAck(bool ackType)
        {
            byte[] ackBuf = new byte[(int)TransSize.ACKSIZE];
            ackBuf[(int)TransCHKSUM.SEQNO] = (byte)(ackType
                ? buffer[(int)TransCHKSUM.SEQNO]
                : (byte)(buffer[(int)TransCHKSUM.SEQNO] + 1) % 2);

            ackBuf[(int)TransCHKSUM.TYPE] = (byte)(int)TransType.ACK;
            checksum.calcChecksum(ref ackBuf, (int)TransSize.ACKSIZE);

            if (++bitErrorIntroduction == 2)
            {
                ackBuf[0]++;
                bitErrorIntroduction = 0;
            }

            link.Send(ackBuf, (int)TransSize.ACKSIZE);
        }
Пример #8
0
        /// <summary>
        /// Sends the ack.
        /// </summary>
        /// <param name='ackType'>
        /// Ack type.
        /// </param>
        private void sendAck(bool ackType)
        {
            byte[] ackBuf = new byte[(int)TransSize.ACKSIZE];
            ackBuf [(int)TransCHKSUM.SEQNO] = (byte)
                                              (ackType ? (byte)buffer [(int)TransCHKSUM.SEQNO] : (byte)(buffer [(int)TransCHKSUM.SEQNO] + 1) % 2);
            ackBuf [(int)TransCHKSUM.TYPE] = (byte)(int)TransType.ACK;
            checksum.calcChecksum(ref ackBuf, (int)TransSize.ACKSIZE);

            //Force error
            errorCount++;
            if (errorCount == 7)
            {
                ackBuf [0]++;
                Console.WriteLine("Fejl i ACK");
            }
            //

            link.send(ackBuf, (int)TransSize.ACKSIZE);
        }
Пример #9
0
        /// <summary>
        /// Sends the ack.
        /// </summary>
        /// <param name='ackType'>
        /// Ack type.
        /// </param>
        private void sendAck(bool ackType)
        {
            byte[] ackBuf = new byte[(int)TransSize.ACKSIZE];
            ackBuf[(int)TransCHKSUM.SEQNO] = (byte)
                                             (ackType ? (byte)buffer[(int)TransCHKSUM.SEQNO] : (byte)(buffer[(int)TransCHKSUM.SEQNO] + 1) % 2);
            ackBuf[(int)TransCHKSUM.TYPE] = (byte)(int)TransType.ACK;
            checksum.calcChecksum(ref ackBuf, (int)TransSize.ACKSIZE);

            ///*
            // bitfejl
            if (++errorCount == 2)
            {
                ackBuf[1]++;
                Console.WriteLine("FEJL I ACK");
            }
            //*/

            link.send(ackBuf, (int)TransSize.ACKSIZE);
        }