What is an ASN file and how do I use it?

Edwin picture Edwin · Aug 16, 2013 · Viewed 13.4k times · Source

I am trying to work with a communication protocol (S1AP to be specific) and I am trying to define messages to test.

The LTE 36.413 specification details this protocol and also give an ASN.1 file definition at the bottom of the pdf. I have seen ASN files being used in the dissector for WireShark, and I am guessing that I might be able to use it to generate messages in accordance with the specification.

I was wondering how you use ASN.1 files. I have been researching and have found information on ASN.1 compilers and other information related to it, but all the information has left me very confused as nobody has explained clearly how to use it. Could someone please help me understand how to use it?

Answer

Edwin picture Edwin · Aug 16, 2013

After much hunting I have found out what ASN.1 files are.

These ASN.1 files essentially contains protocol description and packet description. Using these ASN.1 files, you can generate .c and .h files to be used in some application you wish to use these for. This is really handy because you don't have to create your own message database. You just need to compile the ASN.1 files and you C files will be compiled for your use.

Now, you must be wondering, how do I compile this? Well, you generally need some sort of an ASN.1 compiler. You have to pay for some, but I was able to find an open source one that works with Linux and Windows. There is potential that it may work on MAC as well since that is UNIX based as long as you have the necessary dependencies. In any case here is the link to this web page. I will not explain how to use it because I think this web page does a lovely job at documenting usage. Hope this helps someone as much as it helped me.

Check out the compiler here http://lionet.info/asn1c/blog/

If that link does not work for you, you may need to try a commercial one such as OSS Nocklava ASN1.C compiler or if money is of concern, then it might be worth making your own database despite the amount of time this will take.

All the best.