Python:二进制字符串错误模拟
我目前正在编写一个测试,用于验证某些纠错代码:Python:二进制字符串错误模拟,python,binary-data,crc,error-code,Python,Binary Data,Crc,Error Code,我目前正在编写一个测试,用于验证某些纠错代码: inputData1 = "1001011011" inputData2 = "1001111011" fingerPrint1 = parityCheck.getParityFingerprint(inputData1) # Expected: fingerPrint1=0 fingerPrint2 = parityCheck.getParityFingerprin
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类可以用来自动生成二进制字符串上的ErrorBurstError、single event、reordering等?例如:
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修改进出接口的数据包。但是,我怀疑Netem这次是否能很好地解决我的问题,因为我的整个测试计划只在我的台式计算机上运行。另外,这次我正在使用Windows7。此外,Netem没有为我的测试实现提供足够完整/复杂的函数集
如有任何帮助/建议,将不胜感激
谢谢
相关问题:string不是最佳选择。Python字符串是不可变的。您没有项目分配s[2]='a'是不可能的,每次更改都将创建字符串的新副本。也许您应该了解NumPy NumPy-arrays。inputData是一个字符串,因为它是通过将正则表达式匹配应用于在另一个programModelSim上运行的VHDL模拟的输出文件而获得的。尽管如此,我还是会按照您的建议来研究NumPy NumPy阵列。非常感谢:-@Peter Schneider:我发布了一个关于这个问题的新问题,你能看一下吗。谢谢。