1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171
|
ldu1::ldu1(const_bit_queue& frame_body) :
voice_data_unit(frame_body)
{
}
ldu1::~ldu1()
{
}
string
ldu1::duid_str() const
{
return string("LDU1");
}
uint16_t
ldu1::frame_size_max() const
{
return 1728;
}
/*
string
ldu1::nac_str() const
{
const size_t NAC_BITS[] = {
48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59
};
const size_t NAC_BITS_SZ = sizeof(NAC_BITS) / sizeof(NAC_BITS[0]);
uint32_t nac = extract(frame_body(), NAC_BITS, NAC_BITS_SZ);
return lookup(nac, NACS, NACS_SZ);
}
240 Link Control Word bits
void
ldu1::decode_lcw(uint16_t *decoded_lcw)
{
const size_t LCW_BITS[240] = {
410, 411, 412, 413, 414, 415, 416, 417, 418, 419, 420, 421,
422, 423, 424, 425, 426, 427, 428, 429, 432, 433, 434, 435,
436, 437, 438, 439, 440, 441, 442, 443, 444, 445, 446, 447,
448, 449, 450, 451, 600, 601, 602, 603, 604, 605, 606, 607,
608, 609, 610, 611, 612, 613, 614, 615, 616, 617, 618, 619,
620, 621, 622, 623, 624, 625, 626, 627, 628, 629, 630, 631,
632, 633, 634, 635, 636, 637, 638, 639, 788, 789, 792, 793,
794, 795, 796, 797, 798, 799, 800, 801, 802, 803, 804, 805,
806, 807, 808, 809, 810, 811, 812, 813, 814, 815, 816, 817,
818, 819, 820, 821, 822, 823, 824, 825, 826, 827, 828, 829,
978, 979, 980, 981, 982, 983, 984, 985, 986, 987, 988, 989,
990, 991, 992, 993, 994, 995, 996, 997, 998, 999, 1000, 1001,
1002, 1003, 1004, 1005, 1008, 1009, 1010, 1011, 1012, 1013, 1014, 1015,
1016, 1017, 1018, 1019, 1168, 1169, 1170, 1171, 1172, 1173, 1174, 1175,
1176, 1177, 1178, 1179, 1180, 1181, 1182, 1183, 1184, 1185, 1186, 1187,
1188, 1189, 1190, 1191, 1192, 1193, 1194, 1195, 1196, 1197, 1198, 1199,
1200, 1201, 1202, 1203, 1204, 1205, 1206, 1207, 1356, 1357, 1358, 1359,
1360, 1361, 1362, 1363, 1364, 1365, 1368, 1369, 1370, 1371, 1372, 1373,
1374, 1375, 1376, 1377, 1378, 1379, 1380, 1381, 1382, 1383, 1384, 1385,
1386, 1387, 1388, 1389, 1390, 1391, 1392, 1393, 1394, 1395, 1396, 1397
};
const uint16_t LCW_BITS_SZ = sizeof(LCW_BITS) / sizeof(LCW_BITS[0]);
uint16_t * encoded_lcw = new uint16_t[240];
for( int i = 0 ; i < LCW_BITS_SZ; ++i ){
encoded_lcw[i] = extract(frame_body(), LCW_BITS[i], LCW_BITS_SZ);
}
uint16_t *rs_codewords = new uint16_t[144];
decode_hamming( encoded_lcw, rs_codewords );
delete [] encoded_lcw;
decode_reed_solomon( rs_codewords, decoded_lcw );
delete [] rs_codewords;
}
uint16_t
ldu1::lcf(uint16_t *decoded_lcw) const
{
const size_t LCF_BITS[] = {
0, 1, 2, 3, 4, 5, 6 , 7
};
const size_t LCF_BITS_SZ = sizeof(LCF_BITS) / sizeof(LCF_BITS[0]);
const uint16_t lcf = extract(decoded_lcw, LCF_BITS, LCF_BITS_SZ);
return lcf;
}
string
ldu1::mfid_str(uint16_t *decoded_lcw) const
{
const size_t MFID_BITS[] = {
8, 9, 10, 11, 12, 13, 14, 15
};
const size_t MFID_BITS_SZ = sizeof(MFID_BITS) / sizeof(MFID_BITS_SZ);
uint8_t mfid = extract(decoded_lcw, MFID_BITS, MFID_BITS_SZ);
return lookup(mfid, MFIDS, MFIDS_SZ);
}
string
ldu1::tgid_str(uint16_t *decoded_lcw) const
{
const size_t TGID_BITS[] = {
32, 33, 34, 35, 36, 37, 38, 39,
40, 41, 42, 43, 44, 45, 46, 47,
};
const size_t TGID_BITS_SZ = sizeof(TGID_BITS) / sizeof(TGID_BITS[0]);
const uint16_t tgid = extract(decoded_lcw, TGID_BITS, TGID_BITS_SZ);
ostringstream os;
os << hex << showbase << setfill('0') << setw(4) << tgid;
return os.str();
}
string
ldu1::source_str(uint16_t *decoded_lcw) const
{
const size_t SOURCE_BITS[] = {
48, 49, 50, 51, 52, 53, 54, 55,
56, 57, 58, 59, 60, 61, 62, 63,
64, 65, 66, 67, 68, 69, 70, 71,
};
const size_t SOURCE_BITS_SZ = sizeof(SOURCE_BITS) /sizeof(SOURCE_BITS[0]);
const uint16_t source = extract(decoded_lcw, SOURCE_BITS, SOURCE_BITS_SZ);
ostringstream os;
os << hex << showbase << setfill('0') << setw(6) << source;
return os.str();
}
string
ldu1::destination_str(uint16_t *decoded_lcw) const
{
const size_t DESTINATION_BITS[] = {
24, 25, 26, 27, 28, 29, 30, 31,
32, 33, 34, 35, 36, 37, 38, 39,
40, 41, 42, 43, 44, 45, 46, 47,
};
const size_t DESTINATION_BITS_SZ = sizeof(DESTINATION_BITS) / sizeof(DESTINATION_BITS[0]);
const uint16_t destination = extract(decoded_lcw, DESTINATION_BITS, DESTINATION_BITS_SZ);
ostringstream os;
os << hex << showbase << setfill('0') << setw(6) << destination;
return os.str();
}
// put duid, nac, and lcw data into pickle
std::string
ldu1::snapshot(uint16_t *decoded_lcw) const
{
pickle p;
if (lcf(decoded_lcw) == 0)
{
p.add("duid", duid_str());
p.add("nac", nac_str());
p.add("mfid", mfid_str(decoded_lcw));
p.add("tgid", tgid_str(decoded_lcw));
p.add("source", source_str(decoded_lcw));
return p.to_string();
}
else if (lcf(decoded_lcw) == 0x03)
{
p.add("duid", duid_str());
p.add("nac", nac_str());
p.add("mfid", mfid_str(decoded_lcw));
p.add("dest", destination_str(decoded_lcw));
p.add("source", source_str(decoded_lcw));
return p.to_string();
}
else
{
p.add("duid", duid_str());
p.add("nac", nac_str());
return p.to_string();
}
}
*/
|