将(ASN.1)BCD值转换为可读的string

您好我有一个hex值通过解码属性types是一个八位组串数据types(ANS.1语法)的CDR文件生成的。 我想转换/解释BCD(hexstring)为人类可读的string值。

以下是使用MARBEN ASN.1 CDR Converter进行解码的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> 。 作为参考,被服务的IMSI的实际值是515600000000015,iPBinV4地址是103.75.136.2。 我想弄清楚如何能够使用nodejs将值格式化为可读的string。

下面是上述两个属性的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 

任何帮助将不胜感激。