## Calculating CRC for HT-SIG in 802.11n Preamble

| |
[ 所属分类 开发（python） | 发布者 店小二05 | 时间 2016 | 作者 红领巾 ] 0人收藏点击收藏

The HT-SIG field of 802.11n PLCP preamble contains a 8-bit CRC for the receiver to validate the sanity of the header. Here is how to calculate it.

HT-SIG contains 48 bits and spans in 2 OFDM symbols (BPSK modulated, 1/2 rate). This diagram from the 802.11-2012 standard describes the logic to calculate the CRC for the first 34 bits of the field.

Here is a python version of the implementation.

def calc_crc(bits): c = [1] * 8 for b in bits: next_c = [0] * 8 next_c[0] = b ^ c[7] next_c[1] = b ^ c[7] ^ c[0] next_c[2] = b ^ c[7] ^ c[1] next_c[3] = c[2] next_c[4] = c[3] next_c[5] = c[4] next_c[6] = c[5] next_c[7] = c[6] c = next_c return [1-b for b in c[::-1]]

c is the 8-bit shift register. For each incoming bits, we calculate the next value of each bit in the register and store them in next_c .

Finally, we perform two operations: reverse and two's complement. Note that c[7] is the first output bit.

The standard also provides a test case.

>>> s = '1 1 1 1 0 0 0 1 0 0 1 0 0 1 1 0 0 0 0 0 0 0 0 0 1 1 1 0 0 0 0 0 0 0' >>> bits = [int(b) for b in s.split()] >>> calc_crc(bits) [1, 0, 1, 0, 1, 0, 0, 0]

tags: next,gt,bits,bit,HT,calculate,CRC,SIG

1.凡CodeSecTeam转载的文章,均出自其它媒体或其他官网介绍,目的在于传递更多的信息,并不代表本站赞同其观点和其真实性负责；
2.转载的文章仅代表原创作者观点,与本站无关。其原创性以及文中陈述文字和内容未经本站证实,本站对该文以及其中全部或者部分内容、文字的真实性、完整性、及时性，不作出任何保证或承若；
3.如本站转载稿涉及版权等问题,请作者及时联系本站,我们会及时处理。