Python: binary string error simulation

孤者浪人 提交于 2019-12-24 07:59:11

问题


I am currently writing a test for validating some error-correcting code:

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"

Is there a python class I can use to automatically generate error(burst error, single event, reordering, etc) on a binary string? Eg:

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.)

I know that such a class could be easily implementable for binary check validation. However, I need a more complete class to test more complex error detecting code such as CRC. I have already used Netem (http://www.linuxfoundation.org/collaborate/workgroups/networking/netem) in the past to modify packets entering and leaving interfaces in a telecom lab. However, I doubt Netem would be a good solution to my problem this time as my whole test is planned to be run on my desktop computer only. Also, I am working on Windows 7 this time. Moreover, Netem does not provide a complete/complex enough set of functions for my test implementation.

Any help/suggestion would be greatly appreciated.

Thanks!

Related question: How to shuffle a list with Gaussian distribution

来源:https://stackoverflow.com/questions/13703464/python-binary-string-error-simulation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!