Skip to content

Instantly share code, notes, and snippets.

@daniestevez
Created October 28, 2016 14:04
Show Gist options
  • Save daniestevez/259cb53a8e85692c93e8192fa053e338 to your computer and use it in GitHub Desktop.
Save daniestevez/259cb53a8e85692c93e8192fa053e338 to your computer and use it in GitHub Desktop.
Outernet LDPC test
~/free-outernet $ python
Python 3.4.3 (default, Jan 11 2016, 14:18:01)
[GCC 4.9.3] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import ldpc
>>> from functools import reduce
>>> data = [66, 98, 247, 43, 153, 140, 6, 61, 60, 144, 107, 112, 193, 108, 227, 134, 66, 220, 217, 1, 51, 2, 31, 29, 20, 3, 177, 125, 140, 42, 138, 90, 141, 194, 220, 245, 16, 158, 119, 23, 48, 31, 165, 40, 65, 121, 55, 227, 56, 62, 29, 201, 220, 10, 237, 130, 4, 66, 138, 14, 103, 129, 24, 25, 228, 49, 65, 172, 129, 163, 192, 86, 236, 83, 175, 238, 99, 190, 6, 16, 162, 198, 96, 157, 3, 248, 39, 129, 220, 237, 3, 217, 85, 54, 136, 147, 114, 32, 181, 65, 193, 231, 180, 204, 33, 223, 134, 148, 41, 100, 57, 107, 234, 106, 161, 167, 45, 110, 233, 154, 246, 120, 127, 190, 197, 199, 201, 2, 32, 223, 204, 11, 199, 190, 217, 133, 203, 254, 237, 113, 170, 153, 72, 183, 77, 229, 245, 63, 23, 27, 0, 194, 86, 51, 165, 22, 8, 177, 240, 248, 115, 135, 243, 248, 101, 227, 14, 170, 172, 11, 26, 39, 216, 178, 102, 123, 225, 107, 158, 128, 172, 88, 30, 239, 240, 104, 179, 69, 172, 133, 131, 48, 127, 73, 244, 209, 115, 103, 208, 12, 244, 226, 156, 179, 145, 34, 173, 144, 149, 148, 184, 14, 167, 52, 162, 115, 35, 166, 122, 177, 145, 0, 21, 169, 132, 98, 44, 103, 150, 77, 109, 104, 237, 10, 6, 22, 112, 128, 96, 222, 197, 226, 64, 94, 254, 161, 2, 88, 95, 108, 125, 35, 19, 227, 4, 110, 46, 2, 210, 139, 215, 151, 130, 203, 249, 99, 114, 134, 103, 151, 81, 2, 213, 181, 92, 86, 109, 107, 38, 164, 18, 233, 73, 146, 141, 220, 53, 185, 20, 117, 150, 113, 61, 100, 110, 96, 0, 131, 49, 145, 202, 114, 152, 162, 247, 236, 29, 216, 35, 229, 130, 110, 66, 150, 163, 156, 69, 225, 116, 220, 112, 28, 78, 49, 235, 113, 211, 232, 45, 90, 145, 233, 79, 57, 100, 195, 134, 2, 171, 6, 69, 58, 189, 207, 144, 133, 202, 24, 132, 189, 36, 48, 3, 255, 86, 36, 8, 183, 55, 24, 205, 73, 93, 97, 2, 112, 78, 176, 128, 2, 62, 171, 234, 96, 195, 215, 68, 6, 74, 80, 88, 36, 239, 76, 78, 122, 9, 174, 37, 37, 81, 105, 55, 207, 216, 60, 88, 253, 73, 89, 133, 205, 208, 198, 50, 102, 244, 53, 116, 164, 35, 217, 49, 218, 152, 217, 194, 138, 80, 123, 132, 94, 111, 197, 6, 211, 171, 250, 148, 147, 109, 51, 144, 8, 123, 32, 0, 57, 4, 57, 105, 19, 77, 149, 82, 194, 238, 134, 110, 16, 151, 197]
>>> fec = [153, 97, 53, 15, 79, 37, 230, 44, 134, 159, 185, 192, 222, 95, 223, 122, 152, 254, 55, 131, 111, 218, 161, 44, 181, 192, 160, 66, 237, 115, 38, 159, 30, 82, 57, 158, 96, 249, 151, 77, 196, 102, 70, 94, 229, 195, 187, 3, 148, 200, 195, 117, 254, 19, 244, 128, 214, 219, 153, 98, 178, 20, 184, 0, 138, 186, 195, 136, 22, 74, 157, 161, 247, 79, 18, 155, 20, 138, 199, 17, 89, 187, 242, 167, 25, 216, 246, 28, 13, 25]
>>> ldpc.seed = 1000
>>> M = ldpc.left_matrix_init(452, 543, 2)
>>> reduce(lambda a, b: a ^ b, [data[i] for i in M[0]], 0)
163
>>> fec[0]
153
>>>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment