1

我目前正在编写一个测试来验证一些纠错代码:

inputData1  = "1001011011"
inputData2  = "1001111011"
fingerPrint1 = parityCheck.getParityFingerprint(inputData1)
                                      # Expected: fingerPrint1=0

fingerPrint2 = parityCheck.getParityFingerprint(inputData2)
                                      # Expected: fingerPrint2=1

if fingerPrint1 == fingerPrint2:
    print "Test failed: errorCorrectingAlgo1 failed to detect error"
else:
    print "Test success: errorCorrectingAlgo1 successfully detected error"

是否有一个 python 类可以用来在二进制字符串上自动生成错误(突发错误、单个事件、重新排序等)?例如:

inputData1 = "1001011011"
inputData1BurstError = applyBurstError(inputData1)  # Eg: inputData1BurstError =
                                         ("1011111011", or "1001000000", or etc.)

inputData1RandomError = applyRandomError(inputData1)# Eg: inputData1RandomError =
                                         ("0001101011", or "0111101101", or etc.)

inputData1Reordering = applyReordering(inputData1)  # Eg: inputData1Reordering =
                                         ("0101110011", or "1101101001", or etc.)

inputData1SingleEvent = applySingleEvent(inputData1)# Eg: inputData1SingleEvent =
                                         ("1001011011", or "1000011011", or etc.)

我知道这样一个类可以很容易地实现二进制检查验证。但是,我需要一个更完整的类来测试更复杂的错误检测代码,例如 CRC。我过去已经使用过 Netem ( http://www.linuxfoundation.org/collaborate/workgroups/networking/netem ) 来修改电信实验室中进入和离开接口的数据包。但是,我怀疑这次 Netem 是否能很好地解决我的问题,因为我的整个测试计划仅在我的台式计算机上运行。另外,这次我正在使用 Windows 7。此外,Netem 没有为我的测试实现提供一套完整/复杂的功能。

任何帮助/建议将不胜感激。

谢谢!

相关问题:How to shuffle a list with Gaussian distribution

4

0 回答 0