locked
Question about function Scramble11a RRS feed

  • Question

  • Hi, I looked into the function Scramble11a in SoraSDK v1.5 and SoraSDK v1.6, and found a difference that makes me confused. The source codes are as follows.

    In SoraSDK v.15,

       

    __forceinline
    void Scramble11a(MDL * pmdlIn, char * pbOutput,
            unsigned int uiOutTotal, unsigned int uiCRC32, ULONG ulRadom)
    {
        unsigned char * pbIn;
        unsigned char * pbOut = (unsigned char *)
            (pbOutput + SERVICE_LEN_IN_BYTES);
        unsigned char * pbOutEnd = (unsigned char *)
            (pbOutput + uiOutTotal);
        unsigned int uiLen;
        unsigned int i;
        unsigned char bReg = (unsigned char)ulRadom;

        if ((bReg & 0xFE) == 0)
            bReg = 0xFF;
        bReg = 0xFF;

        pbOutput[0] = (bReg = *(SCRAMBLE_11A(bReg >> 1)));
        pbOutput[1] = (bReg = *(SCRAMBLE_11A(bReg >> 1)));

        while (pmdlIn)
        {
            ...   

        }

        // crc32
        ...

        *(pbOut++) = (bReg = *(SCRAMBLE_11A(bReg >> 1))) & 0xC0;

        while (pbOut != pbOutEnd)
        {
            *(pbOut++) = (bReg = *(SCRAMBLE_11A(bReg >> 1)));
        }

        pbOutput += SERVICE_LEN_IN_BYTES;
    }

    In SoraSDK v1.6,

       

    __forceinline
    void Scramble11a(MDL * pmdlIn, char * pbOutput,
            unsigned int uiOutTotal, unsigned int uiCRC32, ULONG /* ulRadom */)
    {
        unsigned char * pbIn;
        unsigned char * pbOut = (unsigned char *)
            (pbOutput + SERVICE_LEN_IN_BYTES);
        unsigned char * pbOutEnd = (unsigned char *)
            (pbOutput + uiOutTotal);
        unsigned int uiLen;
        unsigned int i;
     
        unsigned char bReg = 0xFF; // no random
     
     // scramble the services bits
        pbOutput[0] = (bReg = *(SCRAMBLE_11A(bReg >> 1)));
        pbOutput[1] = (bReg = *(SCRAMBLE_11A(bReg >> 1)));

        while (pmdlIn)
        {
           ...

        }

     
        // Scramble crc32
        ...

        // Append the PSDU with at least 6 zero bits as tail field
        // ref: 802.11a-1999 17.3.2
        // We should replace the six scrambled zero bits following the message end with six
       // non-scrambled zero bits!
     *(pbOut++) = (bReg = *(SCRAMBLE_11A(bReg >> 1))) & 0xC0;

        // Append more zero bytes
        while (pbOut != pbOutEnd)
        {
            *(pbOut++) = (bReg = *(SCRAMBLE_11A(bReg >> 1)));
        }
    }

    We can see that the difference between them is that, in Sora v1.5, pbOutput which points to the scrambled data adds itself by 2 bytes, while in Sora v1.6, the addition is no longer done. I wonder that this is a bug in Sora v1.5 since this addition will skip the Service part of the physical frame, making the Service part will not be transmitted out. As I understand, the Service  part initializes the scrambler and it provides the seed for the descrambler at the decoder. After Viterbi decoding, the descrambler will pick this seed to start descrambling. I also looked into the function VitDesCRC to make sure of my idea.

    In the function VitDesCRC, there are some codes as follows.

              // We need to do descramble and CRC here
                for ( i = 0; i < TB_OUTPUT_ >> 3; i++)
                {
                    // first two bytes are seed
                    if ( uiBytesOutput < 2)
                    {
                        uiBytesOutput += 2;
                        bSeed = (* (pVTOutput+1)) >> 1;
                        pVTOutput += 2;
                        i += 2; // as if we start from the 3rd char
                    }
                   
                    // scramble
                    bSeed = SCRAMBLE_11A_LUT[bSeed];
                    *pbOutput = (*pVTOutput) ^ bSeed;
                    bSeed >>= 1;

                    pVTOutput ++;
                    uiBytesOutput ++;

                   ...

            }

    I find that the descrambler sees the first two bytes as seed, skips them and starts descrambling from the 3rd char. Thus I think my idea above is ok.

    I have tested Sora v1.5 and it works well. But unluckily, Sora v1.6 works poor and even cannot synchronizes. I'm checking my experiment now.

    Here, my question is that why the function Scramble11a in Sora v1.5 needs to add pbOutput by 2 bytes itself but not in Sora v1.6?

    Waiting for your answer! Thanks.


    • Edited by ychm Saturday, April 28, 2012 7:07 AM
    Saturday, April 28, 2012 7:05 AM

Answers

  • Hi ychm,

    Thanks for your question. We don't think it is a bug to remove statement "pbOutput += SERVICE_LEN_IN_BYTES;", because it modifies the parameter pointer "pbOutput" in function scope, without side effects to the caller. This function behaviors in v1.5 and v1.6 are expected equivalent.

    Please let us known if you have any more questions.

    Thanks!

    Wednesday, May 2, 2012 3:06 AM
    Answerer

All replies

  • Hi ychm,

    Thanks for your question. We don't think it is a bug to remove statement "pbOutput += SERVICE_LEN_IN_BYTES;", because it modifies the parameter pointer "pbOutput" in function scope, without side effects to the caller. This function behaviors in v1.5 and v1.6 are expected equivalent.

    Please let us known if you have any more questions.

    Thanks!

    Wednesday, May 2, 2012 3:06 AM
    Answerer
  • Thank you very much.
    Wednesday, May 2, 2012 6:08 AM