I am doing some BER simulations with GNU Radio (stay tuned for the next post), and during my experiments I have stumbled upon a bug in the “Decode CCSDS 27″ block. This block is a Viterbi decoder for the CCSDS convolutional code with \(r=1/2\), \(k=7\) (note that the convention used by this block is first POLYA
then POLYB
so it doesn’t match the NASA-DSN convention nor the CCSDS/NASA-GSFC conventions, as I have mentioned in another post).
The bug consists in the block entering a “degraded” state after it has processed many symbols (on the order of several millions). In this degraded state, it doesn’t decode properly, producing lots of bit errors even if no input symbols are in error. Fortunately, there is another block in GNU Radio which can decode the CCSDS convolutional code, the “CC Decoder” included in FECAPI. This block doesn’t seem to suffer this issue. Here I describe how to replicate the bug, how to replace “Decode CCSDS 27” by “CC Decoder” and some other miscellaneous things related to this bug.
The code that replicates this bug is below. It is based on the BER testing workbench I’m using, so hopefully it will make more sense when I describe my BER tests completely in the next post.
For now, I’ll just say that the Python script runs a flowgraph which does the following: it generates a stream of 1’s of length N_BITS = 1e8
, it runs the stream through a G3RUH scrambler to produce a random-looking sequence, encodes this sequence using “Encode CCSDS 27”, uses the Viterbi decoder, and does G3RUH descrambling. Ideally, we would recover our constant stream of 1’s. The first bits in the output might not be 1’s, since the Viterbi decoder has to sync up. To compensate for this, the first 1000 output bits are dropped (I know this is a lot, since the Viterbi decoder has already synced up in 14 symbols). To check if the output is correct, the flowgraph groups the output into chunks of 100000 bits and computes the bit error rate in each chunk. We expect to get 0 bit error rate in all the chunks, since we are not introducing any noise. The first time, the flowgraph is run using “Decode CCSDS 27” and the second time it is run using “CC Decoder”.
When we run the script, we see the following output
BER with decode_ccsds_27_fb (0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.012389999814331532, 0.19276998937129974, 0.19111000001430511, 0.19077999889850616, 0.19219999015331268, 0.19153998792171478, 0.19179999828338623, 0.1923299878835678, 0.18963000178337097, 0.1918499916791916, 0.19139999151229858, 0.1911499947309494, 0.1916399896144867, 0.190870001912117, 0.18983998894691467, 0.19111000001430511, 0.19162999093532562, 0.19040998816490173, 0.19178999960422516, 0.19043999910354614, 0.19037999212741852, 0.19065000116825104, 0.19092999398708344, 0.19177000224590302, 0.19089999794960022, 0.19060999155044556, 0.18990999460220337, 0.1910099983215332, 0.19088999927043915, 0.19133999943733215, 0.1912200003862381, 0.18980999290943146, 0.1920499950647354, 0.19147999584674835, 0.19171999394893646, 0.19112999737262726, 0.18955999612808228, 0.19227999448776245, 0.19169999659061432, 0.1929899901151657, 0.1907700002193451, 0.18995998799800873, 0.19147999584674835, 0.1914999932050705, 0.19195999205112457, 0.19111000001430511, 0.19078999757766724, 0.1906299889087677, 0.19200000166893005, 0.19193999469280243, 0.19241999089717865, 0.19226999580860138, 0.1912499964237213, 0.19081999361515045, 0.1917800009250641, 0.19112999737262726, 0.1913899928331375, 0.1920199990272522, 0.1921899914741516, 0.19016999006271362, 0.1912200003862381, 0.19172999262809753, 0.19091999530792236, 0.19234000146389008, 0.1912899911403656, 0.19136999547481537, 0.19203999638557434, 0.1900699883699417, 0.19158999621868134, 0.1907999962568283, 0.1916399896144867, 0.19196999073028564, 0.1892399936914444, 0.19133999943733215, 0.19095999002456665, 0.19099000096321106, 0.19099000096321106, 0.19157999753952026, 0.1913899928331375, 0.19044999778270721, 0.19136999547481537, 0.19151999056339264, 0.19040998816490173, 0.19178999960422516, 0.1911899894475937, 0.19167999923229218, 0.1920199990272522, 0.1912499964237213, 0.1900699883699417, 0.19116999208927155, 0.19040998816490173, 0.19202999770641327, 0.19130998849868774, 0.1905899941921234, 0.19174998998641968, 0.19068999588489532, 0.190870001912117, 0.19141998887062073, 0.19061999022960663, 0.1911899894475937, 0.19127999246120453, 0.19053000211715698, 0.19139999151229858, 0.19112999737262726, 0.19200000166893005, 0.18925999104976654, 0.1908399909734726, 0.19071999192237854, 0.19273999333381653, 0.19108998775482178, 0.19026999175548553, 0.19025999307632446, 0.19169999659061432, 0.19235999882221222, 0.1914599984884262, 0.19183999300003052, 0.1912200003862381, 0.19121000170707703, 0.19211000204086304, 0.19202999770641327, 0.1912200003862381, 0.1918499916791916, 0.19049999117851257, 0.19245000183582306, 0.19220998883247375, 0.1918499916791916, 0.19192999601364136, 0.19183999300003052, 0.19066999852657318, 0.19245000183582306, 0.19158999621868134, 0.1915999948978424, 0.19217999279499054, 0.19157999753952026, 0.1921200007200241, 0.1918499916791916, 0.19073998928070068, 0.19207999110221863, 0.19179999828338623, 0.19172999262809753, 0.1915299892425537, 0.18979999423027039, 0.19085998833179474, 0.19133999943733215, 0.19155000150203705, 0.19205999374389648, 0.19115999341011047, 0.1912200003862381, 0.19088000059127808, 0.19091999530792236, 0.1912499964237213, 0.19171999394893646, 0.19153998792171478, 0.19181999564170837, 0.19257000088691711, 0.1903499960899353, 0.19133999943733215, 0.19155000150203705, 0.19222000241279602, 0.19133000075817108, 0.19214999675750732, 0.19153998792171478, 0.19002999365329742, 0.19160999357700348, 0.1911899894475937, 0.1912499964237213, 0.19103999435901642, 0.19051998853683472, 0.19136999547481537, 0.19147999584674835, 0.1904599964618683, 0.1919899880886078, 0.19050998985767365, 0.19016999006271362, 0.1910099983215332, 0.19148999452590942, 0.19098000228405, 0.1911899894475937, 0.19096998870372772, 0.19046999514102936, 0.19125999510288239, 0.19022999703884125, 0.19129998981952667, 0.1914999932050705, 0.19053000211715698, 0.19103999435901642, 0.19136999547481537, 0.19175998866558075, 0.19158999621868134, 0.19029998779296875, 0.19212999939918518, 0.19091999530792236, 0.19200000166893005, 0.19292999804019928, 0.1894499957561493, 0.19043999910354614, 0.19155000150203705, 0.19130998849868774, 0.19297999143600464, 0.19054000079631805, 0.19060999155044556, 0.19201000034809113, 0.19168999791145325, 0.1921899914741516, 0.19202999770641327, 0.1911899894475937, 0.19196999073028564, 0.19020000100135803, 0.19202999770641327, 0.19157999753952026, 0.1914999932050705, 0.19276998937129974, 0.19067999720573425, 0.19129998981952667, 0.1910799890756607, 0.19053000211715698, 0.19178999960422516, 0.1921200007200241, 0.1910099983215332, 0.19189999997615814, 0.1903499960899353, 0.19117999076843262, 0.19147999584674835, 0.19078999757766724, 0.19189000129699707, 0.19127999246120453, 0.19016999006271362, 0.19112999737262726, 0.19053000211715698, 0.1912499964237213, 0.19132000207901, 0.19146999716758728, 0.19080999493598938, 0.19122999906539917, 0.1915299892425537, 0.19140999019145966, 0.19110000133514404, 0.19115999341011047, 0.191430002450943, 0.19235999882221222, 0.1915699988603592, 0.1903499960899353, 0.19121000170707703, 0.19066999852657318, 0.19147999584674835, 0.1912899911403656, 0.19065000116825104, 0.19151999056339264, 0.19175998866558075, 0.1903200000524521, 0.19105999171733856, 0.19123999774456024, 0.19167999923229218, 0.19067999720573425, 0.1905899941921234, 0.19105999171733856, 0.1922300010919571, 0.1911899894475937, 0.19049999117851257, 0.19016999006271362, 0.19073998928070068, 0.1921599954366684, 0.19073998928070068, 0.19077999889850616, 0.1906599998474121, 0.19102999567985535, 0.1917099952697754, 0.1918499916791916, 0.1916399896144867, 0.19103999435901642, 0.19157999753952026, 0.1918099969625473, 0.19202999770641327, 0.1919099986553192, 0.19119998812675476, 0.19115999341011047, 0.19178999960422516, 0.19148999452590942, 0.19241999089717865, 0.19181999564170837, 0.19268999993801117, 0.19004999101161957, 0.1924399882555008, 0.19245000183582306, 0.19004999101161957, 0.19304999709129333, 0.19133999943733215, 0.1915299892425537, 0.1929899901151657, 0.19053000211715698, 0.19193999469280243, 0.19155000150203705, 0.19179999828338623, 0.1921899914741516, 0.18987999856472015, 0.19082999229431152, 0.19011999666690826, 0.1915699988603592, 0.1912200003862381, 0.1918799877166748, 0.1916399896144867, 0.19067999720573425, 0.191430002450943, 0.19051998853683472, 0.1925099939107895, 0.19056999683380127, 0.19200000166893005, 0.19177000224590302, 0.19162999093532562, 0.19155000150203705, 0.19103999435901642, 0.19214999675750732, 0.19160999357700348, 0.19217999279499054, 0.19134999811649323, 0.18970999121665955, 0.1916700005531311, 0.19103999435901642, 0.19169999659061432, 0.19115999341011047, 0.19073998928070068, 0.1914599984884262, 0.1911899894475937, 0.19150999188423157, 0.1906299889087677, 0.19189000129699707, 0.18949998915195465, 0.19084998965263367, 0.19144000113010406, 0.19043999910354614, 0.1918799877166748, 0.1912499964237213, 0.19085998833179474, 0.1901099979877472, 0.1907299906015396, 0.19129998981952667, 0.1915699988603592, 0.19067999720573425, 0.19081999361515045, 0.19132000207901, 0.19169999659061432, 0.19214999675750732, 0.19115999341011047, 0.19008000195026398, 0.1915999948978424, 0.19151999056339264, 0.1928199976682663, 0.19053000211715698, 0.19059999287128448, 0.19117999076843262, 0.19127999246120453, 0.19257000088691711, 0.19148999452590942, 0.19070999324321747, 0.19223999977111816, 0.19084998965263367, 0.1919099986553192, 0.19209998846054077, 0.19153998792171478, 0.19166000187397003, 0.19126999378204346, 0.1912499964237213, 0.19151999056339264, 0.19110000133514404, 0.1920899897813797, 0.19202999770641327, 0.1904899924993515, 0.19101999700069427, 0.1917399913072586, 0.19129998981952667, 0.1925099939107895, 0.19082999229431152, 0.19181999564170837, 0.1918499916791916, 0.18953999876976013, 0.19196999073028564, 0.19021999835968018, 0.19160999357700348, 0.19137999415397644, 0.18990999460220337, 0.19171999394893646, 0.19082999229431152, 0.19040998816490173, 0.19193999469280243, 0.19082999229431152, 0.19073998928070068, 0.19121000170707703, 0.1913599967956543, 0.19166000187397003, 0.1901099979877472, 0.19211000204086304, 0.1908399909734726, 0.1921200007200241, 0.1922999918460846, 0.1907999962568283, 0.19022999703884125, 0.19084998965263367, 0.19110000133514404, 0.19123999774456024, 0.1913599967956543, 0.19096998870372772, 0.19242998957633972, 0.19001999497413635, 0.19127999246120453, 0.19112999737262726, 0.19133999943733215, 0.1903499960899353, 0.1911199986934662, 0.19025999307632446, 0.19227999448776245, 0.19085998833179474, 0.1919899880886078, 0.18927998840808868, 0.19106999039649963, 0.19073998928070068, 0.19226999580860138, 0.19103999435901642, 0.189410001039505, 0.19158999621868134, 0.1907999962568283, 0.1923299878835678, 0.19193999469280243, 0.19073998928070068, 0.1922999918460846, 0.1910099983215332, 0.19214999675750732, 0.1916700005531311, 0.19108998775482178, 0.1915299892425537, 0.19031000137329102, 0.1919499933719635, 0.19328999519348145, 0.19130998849868774, 0.19271999597549438, 0.19061999022960663, 0.19200000166893005, 0.19178999960422516, 0.19148999452590942, 0.19186998903751373, 0.1915299892425537, 0.1915299892425537, 0.19228999316692352, 0.1912200003862381, 0.1916700005531311, 0.19178999960422516, 0.19136999547481537, 0.19238999485969543, 0.19098000228405, 0.1904899924993515, 0.19082999229431152, 0.1912899911403656, 0.19082999229431152, 0.19216999411582947, 0.19119998812675476, 0.19094999134540558, 0.19148999452590942, 0.19082999229431152, 0.1919099986553192, 0.19139999151229858, 0.19141998887062073, 0.19134999811649323, 0.19247999787330627, 0.19106999039649963, 0.19141998887062073, 0.1921599954366684, 0.1918799877166748, 0.19175998866558075, 0.1914599984884262, 0.19004999101161957, 0.19167999923229218, 0.191430002450943, 0.19096998870372772, 0.191430002450943, 0.19127999246120453, 0.1903499960899353, 0.19127999246120453, 0.19220998883247375, 0.19043999910354614, 0.1920899897813797, 0.1904899924993515, 0.1904599964618683, 0.19047999382019043, 0.19119998812675476, 0.19189999997615814, 0.19132000207901, 0.19115999341011047, 0.1899299919605255, 0.19139999151229858, 0.19098000228405, 0.19112999737262726, 0.19141998887062073, 0.18994998931884766, 0.19162999093532562, 0.1918499916791916, 0.19195999205112457, 0.19113999605178833, 0.1896599978208542, 0.19226999580860138, 0.19106999039649963, 0.1927499920129776, 0.19102999567985535, 0.1906299889087677, 0.1911199986934662, 0.19140999019145966, 0.1920499950647354, 0.19257999956607819, 0.1905599981546402, 0.1912200003862381, 0.1918499916791916, 0.19178999960422516, 0.19220998883247375, 0.19207999110221863, 0.19082999229431152, 0.19122999906539917, 0.19160999357700348, 0.19105999171733856, 0.19113999605178833, 0.19223999977111816, 0.19241999089717865, 0.18995998799800873, 0.19115999341011047, 0.1916399896144867, 0.19068999588489532, 0.1920199990272522, 0.19144000113010406, 0.19174998998641968, 0.1916700005531311, 0.1899299919605255, 0.19133999943733215, 0.1910099983215332, 0.19127999246120453, 0.19200000166893005, 0.18985000252723694, 0.19092999398708344, 0.19122999906539917, 0.19088999927043915, 0.19074998795986176, 0.19102999567985535, 0.19175998866558075, 0.19022999703884125, 0.191430002450943, 0.19178999960422516, 0.1905899941921234, 0.19122999906539917, 0.1909099966287613, 0.19172999262809753, 0.19216999411582947, 0.19132000207901, 0.19001999497413635, 0.19155000150203705, 0.1903499960899353, 0.19088999927043915, 0.19174998998641968, 0.1906299889087677, 0.1913899928331375, 0.19122999906539917, 0.19095999002456665, 0.19117999076843262, 0.19094999134540558, 0.191430002450943, 0.19067999720573425, 0.19065000116825104, 0.19070999324321747, 0.19150999188423157, 0.19182999432086945, 0.18932999670505524, 0.1903200000524521, 0.1911499947309494, 0.19251999258995056, 0.1907700002193451, 0.19070999324321747, 0.19037999212741852, 0.19151999056339264, 0.19213999807834625, 0.19103999435901642, 0.19140999019145966, 0.19103999435901642, 0.19096998870372772, 0.19203999638557434, 0.19193999469280243, 0.19133999943733215, 0.19196999073028564, 0.1903200000524521, 0.19238999485969543, 0.1917800009250641, 0.19196999073028564, 0.19209998846054077, 0.19178999960422516, 0.19059999287128448, 0.1920499950647354, 0.19157999753952026, 0.1919099986553192, 0.1918799877166748, 0.19148999452590942, 0.1918499916791916, 0.1921899914741516, 0.19088000059127808, 0.19241999089717865, 0.19139999151229858, 0.19133999943733215, 0.19175998866558075, 0.1901399940252304, 0.19082999229431152, 0.19139999151229858, 0.19121000170707703, 0.19169999659061432, 0.19153998792171478, 0.19133000075817108, 0.19147999584674835, 0.1906599998474121, 0.19127999246120453, 0.19175998866558075, 0.191430002450943, 0.19214999675750732, 0.19202999770641327, 0.19078999757766724, 0.19164998829364777, 0.19156000018119812, 0.1926499903202057, 0.19108998775482178, 0.19206999242305756, 0.191430002450943, 0.1901399940252304, 0.19115999341011047, 0.19169999659061432, 0.19103999435901642, 0.1907299906015396, 0.19035999476909637, 0.19136999547481537, 0.1917800009250641, 0.19080999493598938, 0.19200000166893005, 0.19094999134540558, 0.19028998911380768, 0.1907999962568283, 0.1911899894475937, 0.19102999567985535, 0.19172999262809753, 0.19050998985767365, 0.19025999307632446, 0.19171999394893646, 0.19032999873161316, 0.1912499964237213, 0.1912499964237213, 0.19037999212741852, 0.19136999547481537, 0.1913899928331375, 0.19172999262809753, 0.19177000224590302, 0.19040998816490173, 0.19222000241279602, 0.1909099966287613, 0.19172999262809753, 0.1931699961423874, 0.19043999910354614, 0.1901099979877472, 0.19160999357700348, 0.1914999932050705, 0.1934799998998642, 0.19084998965263367, 0.19099999964237213, 0.19200000166893005, 0.1916399896144867, 0.1922999918460846, 0.1918799877166748, 0.19110000133514404, 0.19196999073028564, 0.18953999876976013, 0.1919499933719635, 0.19096998870372772, 0.1918799877166748, 0.1924399882555008, 0.1910799890756607, 0.19133999943733215, 0.19110000133514404, 0.19070999324321747, 0.19202999770641327, 0.19216999411582947, 0.19110000133514404, 0.19222000241279602, 0.19089999794960022, 0.19054999947547913, 0.19148999452590942, 0.1901099979877472, 0.19223999977111816, 0.1912200003862381, 0.19046999514102936, 0.19094999134540558, 0.19064000248908997, 0.1912200003862381, 0.19074998795986176, 0.19167999923229218, 0.1905599981546402, 0.19117999076843262, 0.19172999262809753, 0.19169999659061432, 0.19025999307632446, 0.191430002450943, 0.19146999716758728, 0.19196999073028564, 0.19127999246120453, 0.1902799904346466, 0.19116999208927155, 0.19108998775482178, 0.19082999229431152, 0.19148999452590942, 0.19073998928070068, 0.19155000150203705, 0.191430002450943, 0.19068999588489532, 0.19092999398708344, 0.1910799890756607, 0.19148999452590942, 0.19025999307632446, 0.19040998816490173, 0.19070999324321747, 0.19214999675750732, 0.191430002450943, 0.19028998911380768, 0.18970999121665955, 0.19033999741077423, 0.19174998998641968, 0.19132000207901, 0.1908399909734726, 0.19089999794960022, 0.1912200003862381, 0.19139999151229858, 0.1911899894475937, 0.1916399896144867, 0.19061999022960663, 0.1915699988603592, 0.1917800009250641, 0.19178999960422516, 0.19177000224590302, 0.19144000113010406, 0.19160999357700348, 0.19133999943733215, 0.1912499964237213, 0.19262999296188354, 0.19200000166893005, 0.19315999746322632, 0.18994998931884766, 0.19231998920440674, 0.1919099986553192, 0.19078999757766724, 0.19291000068187714, 0.19130998849868774, 0.19148999452590942, 0.19283999502658844, 0.1907700002193451, 0.1921599954366684, 0.19137999415397644, 0.19156000018119812, 0.1922999918460846, 0.19014999270439148, 0.19108998775482178, 0.19046999514102936, 0.191430002450943, 0.19098000228405, 0.19200000166893005, 0.19157999753952026, 0.19108998775482178, 0.1919099986553192, 0.18981999158859253, 0.1922599971294403, 0.1903200000524521, 0.19242998957633972, 0.1914599984884262, 0.1921200007200241, 0.19151999056339264, 0.19106999039649963, 0.19226999580860138, 0.19153998792171478, 0.19191999733448029, 0.1920199990272522, 0.18986999988555908, 0.1912899911403656, 0.19082999229431152, 0.19193999469280243, 0.19112999737262726, 0.1907700002193451, 0.19102999567985535, 0.1915999948978424, 0.1921599954366684, 0.19074998795986176, 0.1917800009250641, 0.19005998969078064, 0.19085998833179474, 0.1914599984884262, 0.19016999006271362, 0.19238999485969543, 0.19073998928070068, 0.1904899924993515, 0.19032999873161316, 0.19080999493598938, 0.1914999932050705, 0.19101999700069427, 0.1912200003862381, 0.18998999893665314, 0.19148999452590942, 0.19202999770641327, 0.1922999918460846, 0.19099999964237213, 0.18995998799800873, 0.19203999638557434, 0.19157999753952026, 0.19303999841213226, 0.19089999794960022, 0.19088999927043915, 0.19103999435901642, 0.19175998866558075, 0.19271999597549438, 0.19148999452590942, 0.19081999361515045, 0.19226999580860138, 0.19056999683380127, 0.1920899897813797, 0.19230999052524567, 0.19129998981952667, 0.19157999753952026, 0.1907999962568283, 0.19067999720573425, 0.19151999056339264, 0.19122999906539917, 0.19246000051498413, 0.19164998829364777, 0.1907700002193451, 0.19113999605178833, 0.1919899880886078, 0.19160999357700348, 0.19214999675750732, 0.19103999435901642, 0.19226999580860138, 0.1918099969625473, 0.18941999971866608, 0.1918799877166748, 0.19029998779296875, 0.19150999188423157, 0.19162999093532562, 0.18974000215530396, 0.19178999960422516, 0.19046999514102936, 0.1901399940252304, 0.19172999262809753, 0.1910099983215332, 0.1904599964618683, 0.19096998870372772, 0.19171999394893646, 0.1912499964237213, 0.19043999910354614, 0.1916700005531311, 0.1907700002193451, 0.19241999089717865, 0.19157999753952026, 0.19096998870372772, 0.1901099979877472, 0.19122999906539917, 0.19040998816490173, 0.19081999361515045, 0.19161999225616455, 0.19091999530792236, 0.19181999564170837, 0.19046999514102936, 0.19169999659061432, 0.19130998849868774, 0.1909399926662445, 0.19040998816490173, 0.19078999757766724, 0.19036999344825745, 0.1918099969625473, 0.19092999398708344, 0.1916700005531311, 0.1890600025653839, 0.1905899941921234, 0.1903200000524521, 0.1926099956035614, 0.19074998795986176, 0.19011999666690826, 0.19151999056339264, 0.19082999229431152, 0.1918799877166748, 0.19172999262809753, 0.19098000228405, 0.1916700005531311, 0.1912200003862381, 0.1919099986553192, 0.1919099986553192, 0.19102999567985535, 0.19185999035835266, 0.19000999629497528, 0.19248999655246735, 0.19337999820709229, 0.19133999943733215, 0.19257000088691711, 0.19106999039649963, 0.19235999882221222, 0.19168999791145325, 0.19202999770641327, 0.19185999035835266, 0.19133999943733215, 0.19166000187397003, 0.1921899914741516, 0.19067999720573425, 0.19196999073028564, 0.1921200007200241, 0.19110000133514404, 0.19189999997615814, 0.19130998849868774, 0.18976999819278717, 0.19117999076843262, 0.1911899894475937, 0.19098000228405, 0.19196999073028564, 0.19127999246120453, 0.19110000133514404, 0.19155000150203705, 0.1911899894475937, 0.19141998887062073, 0.1909099966287613, 0.19171999394893646, 0.19178999960422516, 0.19240999221801758, 0.19116999208927155, 0.19139999151229858, 0.19214999675750732, 0.1919099986553192, 0.19172999262809753, 0.19153998792171478, 0.19110000133514404, 0.19070999324321747, 0.19156000018119812, 0.1910799890756607, 0.19133000075817108, 0.19106999039649963, 0.19070999324321747, 0.19136999547481537, 0.1920899897813797, 0.19112999737262726, 0.19201000034809113, 0.19014999270439148, 0.190870001912117, 0.1910099983215332, 0.19073998928070068, 0.19172999262809753, 0.19139999151229858, 0.19046999514102936, 0.19020000100135803, 0.1916700005531311, 0.19085998833179474, 0.19099999964237213, 0.1917399913072586, 0.18975000083446503, 0.19133000075817108, 0.1921899914741516, 0.19214999675750732, 0.1910099983215332, 0.1896899938583374, 0.19247999787330627) BER with fec.cc_decoder (0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0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 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0)
We see that the “Decode CCSDS 27” block works fine for the first 41 blocks but then it degrades and produces around 19% BER for all the remaining blocks. In contrast, “CC Decoder” produces no bit errors, as expected.
I’m running a GNU Radio version which I compiled from the git master branch a few months ago. I don’t think this is very relevant, since the FEC code in GNU Radio hasn’t changed in years.
I wonder what is the problem that makes “Decode CCSDS 27” degrade in this way. Perhaps it is some numerical instability that accumulates over time, since the internal variables never get reset as the block continues processing symbols. In any case, it makes sense to switch to the “CC Decoder” block. The “Decode CCSDS 27” is an older block which is provided for backwards compatibility and because it is very easy to use. The “CC Decoder” block has several useful extra features and is integrated in the newer FECAPI.
The image below shows how to replace the “Decode CCSDS 27” block by the newer “CC Decoder”. With these parameters, the processing done in both rows is equivalent.
Note that “Decode CCSDS 27” outputs packed bytes, while the “FEC Extended Decoder” used by “CC Decoder” outputs unpacked bytes. Thus, to obtain the same behaviour, we need to use a “Pack K Bits” block with K=8
. However, in many cases we need unpacked bytes, so we used an “Unpack K Bits” blocks after the “Decode CCSDS 27” block. In this case, we do not need to unpack after the “FEC Extended Decoder”.
Another important thing to note is that the default parameter for the polynomials in the “CC Decoder” is [79, 109]
. This corresponds to POLYB, POLYA
. To obtain the same behaviour as “Decode CCSDS 27”, which uses POLYA, POLYB
, we must use the polynomials [109, 79]
.
The parameter “Frame Bits” is another new aspect of “CC Decoder”. In contrast with “Decode CCSDS 27”, this decoder works by chunks of bits. It waits until it has arranged a chunk of “Frame Bits” bits and then it runs the Viterbi decoder on that chunk. Setting this to a very low value adds an overhead, since the Viterbi decoder is called many times. Setting it to a high value introduces latency. Depending on the application, latency might or might not be an issue. I find that the value 80 is a good compromise, since on my system it does not introduce very much overhead in comparison with much larger “Frame Bits” values and it should still give good latency.
The “CC Decoder” has the following useful features. First, as we have seen, the polynomials are a parameter. Even though most of the time the same CCSDS polynomials are used, there are several conventions regarding the order and the bit inversion. The “CC Decoder” supports the convention of inverting the sign of the polynomial to invert the corresponding output bit (see this post). Therefore, the NASA-DSN convention can be written as [-109, 79]
and the CCSDS/NASA-GSFC convention can be written as [79, -109]
. This simplifies using different conventions, since with the “Decode CCSDS 27” one had to use several blocks to swap and invert bits.
Another nice feature of “CC Decoder” is that it uses Volk to do Viterbi decoding. Currently, the Viterbi Volk kernel has a generic implementation and an SSE3 implementation based on Spiral.
While “Decode CCSDS 27” works only in streaming mode, “CC Decoder” also supports the terminated, truncated and tailbiting modes. In fact, I am already using this block in terminated mode in the AO-40 FEC decoder in gr-satellites.
A very interesting thing regarding this degradation bug is that there is a longstanding issue in gr-outernet where some users report that after many hours of receiving correctly, the decoder suddenly stops producing packets. It can remain in that state for many hours and eventually it might come to life again. I have never been able to replicate this issue or to track it down, and this always left me puzzled. At some point we did suspect about the Viterbi decoder, as it was the more complex piece in the system. Now that I have discovered this degradation bug in “Decode CCSDS 27”, it may very well explain this issue in gr-outernet.
I have updated both gr-satellites and gr-outernet and replaced “Decode CCSDS 27” with “CC Decoder”. gr-outernet users that experienced the issue are invited to try the new version and check if it fixes the issue.
Hi Daniel,
This type of bug is one of the hardest to pin down. Excellent investigative work.
This weekend I will test the updated outernet decoder and will report my results here.
73, Edson PY2SDR