嗨我有一个十六进制值,它是通过解码CDR文件产生的,其中属性类型是Octet String数据类型(ANS.1语法)。我想将BCD(十六进制字符串)转换/解释为人类可读的字符串值。
这是使用MARBEN ASN.1 CDR转换器解码的cdr文件的输出。
<?xml version="1.0" encoding="UTF-8"?>
<CallEventRecord>
<pGWRecord>
<recordType>85</recordType>
<servedIMSI>15650000000010F5</servedIMSI>
<pGWAddress>
<iPBinaryAddress>
<iPBinV4Address>674B8802</iPBinV4Address>
</iPBinaryAddress>
</pGWAddress>
<chargingID>10932225</chargingID>
<servingNodeAddress>
<iPBinaryAddress>
<iPBinV4Address>674B8802</iPBinV4Address>
</iPBinaryAddress>
</servingNodeAddress>
<accessPointNameNI>test.be.ph</accessPointNameNI>
<pdpPDNType>0001</pdpPDNType>
<servedPDPPDNAddress>
<iPAddress>
<iPBinaryAddress>
<iPBinV4Address>0A010505</iPBinV4Address>
</iPBinaryAddress>
</iPAddress>
</servedPDPPDNAddress>
<dynamicAddressFlag>
<true />
</dynamicAddressFlag>
<listOfTrafficVolumes>
<ChangeOfCharCondition>
<dataVolumeGPRSUplink>775838</dataVolumeGPRSUplink>
<dataVolumeGPRSDownlink>1321848</dataVolumeGPRSDownlink>
<changeCondition>
<recordClosure />
</changeCondition>
<changeTime>1705161557142B0800</changeTime>
</ChangeOfCharCondition>
</listOfTrafficVolumes>
<recordOpeningTime>1705161547452B0800</recordOpeningTime>
<duration>569</duration>
<causeForRecClosing>16</causeForRecClosing>
<recordSequenceNumber>36</recordSequenceNumber>
<nodeID>isp.com</nodeID>
<localSequenceNumber>1000035</localSequenceNumber>
<apnSelectionMode>
<mSorNetworkProvidedSubscriptionVerified />
</apnSelectionMode>
<servedMSISDN>368909000032</servedMSISDN>
<chargingCharacteristics>0800</chargingCharacteristics>
<chChSelectionMode>
<servingNodeSupplied />
</chChSelectionMode>
<servingNodePLMNIdentifier>15F506</servingNodePLMNIdentifier>
<rATType>6</rATType>
<mSTimeZone>2300</mSTimeZone>
<userLocationInformation>1815F506000115F5060F424100</userLocationInformation>
<servingNodeType>
<ServingNodeType>
<gTPSGW />
</ServingNodeType>
</servingNodeType>
</pGWRecord>
</CallEventRecord>
与<servedIMSI>15650000000010F5</servedIMSI>
和<iPBinV4Address>674B8802</iPBinV4Address>
类似。作为参考,serveIMSI的实际值是515600000000015,而iPBinV4Address的实际值是103.75.136.2。我试图找出如何使用nodejs将值格式化为人类可读的字符串。
以下是上述两个属性的ASN.1规范
IPBinV4Address ::= OCTET STRING (SIZE(4))
IMSI ::= TBCD-STRING (SIZE (3..8))
TBCD-STRING ::= OCTET STRING
-- This type (Telephony Binary Coded Decimal String) is used to
-- represent several digits from 0 through 9, *, #, a, b, c, two
-- digits per octet, each digit encoded 0000 to 1001 (0 to 9),
-- 1010 (*), 1011 (#), 1100 (a), 1101 (b) or 1110 (c); 1111 used
-- as filler when there is an odd number of digits.
-- bits 8765 of octet n encoding digit 2n
-- bits 4321 of octet n encoding digit 2(n-1) +1
任何帮助将不胜感激。