Thursday 18 May 2017

Convert (ASN.1) BCD value to human-readable string

Hi I have a hexadecimal value produced by decoding CDR file in which the property type is an Octet String data type (ANS.1 syntax). I want to convert/interpret the BCD(hexadecimal string) to human readable string value.

Here's the output of the decoded cdr file using MARBEN ASN.1 CDR Converter.

<?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>

Like the <servedIMSI>15650000000010F5</servedIMSI> and the <iPBinV4Address>674B8802</iPBinV4Address>. For reference, the actual value of servedIMSI is 515600000000015 and for iPBinV4Address is 103.75.136.2. I am trying to figure out how can I be able to format the values to human readable string using nodejs.

Below are ASN.1 specification for the said two properties

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

Any help will be appreciated.



via Roxxy

No comments:

Post a Comment