http://java.mblogger.cn/ddonwi/posts/1632.aspx
First, introducing Abstract Syntax Notation One (ASN.1) is a description language independent of the machine for describing messages delivered on the network.
Standards include: ISO 8824-1 | Itu-T X.680: Specification of Basic Notation,
ISO 8824-2 | ITU-T X.681: Information Object Specification,
ISO 8824-3 | ITU-T X.682: Constraint Specification,
ISO 8824-4 | ITU-T X.683: Parameterization of Asn.1
ASN.1 is particularly suitable for representing complex, variation and scalable data structures in modern communication applications.
ASN.1 can be divided into two parts
Grammatical rules: describe the contents of the message from the aspects of data type, content order, or structure.
Code Rules: How to encode data in actual messages
Features:
Expressing simple and complex type
Constraints according to the size and / or value of the type
You can also add stronger constraints
Field can be marked as Optional
The upper hand indicates the type name, the representation of the representation variable name / field name starting.
Second, ASN.1 Terminology 1. Abstract syntax Description Universal data structure allows defining data types and values 2. The collection of data types (Data type) values can be a simple type or struct type to name 3. Encoding is used to represent byte sequences of data values 4. Encoding rules gives mapping methods from one syntax to another 5. Transfer Syntax bit mode (BITS Pattern) description data How is it in transmission?
Third, the ASN.1 module definition module (Module): The basic construction block module definition format in the ASN.1 specification is as follows:
Fourth, ASN.1 Simple Type 1. Basic Type: Boolean, Integer, ENUMERATED, REAL, BIT STRING, OCTET STRING 2. String Type (subset of ISO10646-1) NUMERICSTRING (0-9, VisibleString Graphicstring Utf8String IA5String (ASCII) 3. Object Type Object Identifier ObjectDescriptor Object Identifier: An arbitrary non-negative integer sequence for tag objects (such as Algorithm, etc.) 4. Other type NULL null value Utctime YYMMDD HHMM [SS]
5. ASN.1 Type Definition Syntax:
Internet Object Identifier :: = {ISO (1) ORG (3) DOD (6) 1} Private Object Identifier :: = {Internet 4}
Eight, ASN.1 SEQUENCE structure type corresponds to the C language struct type definition UserAccount :: = SEQUENCE {username PrintableString, password PrintableString, accountNr INTEGER} assignment myAccount UserAccount :: = {username "tly", password "guesswhat", accountNr 2345} SEQUENCE oF corresponds to the C language type definition array MemberCountries :: = SEQUENCE oF PrintableString AccountRegistry :: = SEQUENCE oF UserAccount assignment eastAsia MemberCountries :: = { "China", "Japan", "Korean", "DPR"} SET similar sEQUENCE, without regard to the order type definition components UserAccount :: = SET {username [0] PrintableString, password [1] PrintableString, accountNr [2] INTEGER} assignment myAccount UserAccount :: = {accountNr 2345, username "tly" The Password "Gueswhat"} set of set types, each component type is the same, regardless of the order type definition keywords :: = set of printableString assignment SomeAasn1keywords keywords :: = {"integer", "Boolean", "real"} asn. 1 Introduction
Source: http://asn1.elibl.tm.fr/en/introduction/index.htm Translation: Ddonwi (Ddonwi@sina.com) Description: I was first touching asn.1, I don't know what it is? So I found this information and translated side by reading. I hope that the master can pointed out the mistakes I understand, let me understand the final revision date of ASN.1 asn.20
Main concept
ASN.1 is a Noteation that describes data transmission in the communication protocol, which is independent of language implementation and physical representation, independent of complexity of the application.
ASN.1 (Abstract Sysntax NOTATION NUMBER ONE Abstract Syntax) is a standard in which the abstract data type specification is defined.
It provides a series of predefined basic types, such as Integers, Booleans (Boolean), Character strings (ia5string, universtring ...), bit strings, ... and it can define struct types , Such as: Structures (Sequence), Lists (Sequence of), Choice Between Types (choice), ...
Subtyping constraints can also be applied to any ASN.1 type to limit the range of values of the type.
Unlike a lot of other claims scalable syntax, ASN.1 provides the scalability of processing and supporting early configuration systems and new systems, new versions and old versions.
ASN.1 sends any forms (audio, video, data, etc.) that must be transmitted. ASN.1 can only include structural aspects of information (there is no operation that has been defined or taken into account). It is not a programming language. One of Asn.1 success is that it adopts a standardized encoding rule such as BER (Basic Encoding Rules) or new PER (Packed EncodingRules), which is useful for applications that are limited by bandwidth. These coding rules describe how to translate the values defined in the ASN.1 to be suitable for transmission (for example, they can be converted to transposetable bytes, or reverse transformation), which is used with machines, programming languages or applications. The representation of the program has nothing to do. ASN.1 encoding method is more advanced than many competitors, can transmit scalable information quickly and reliable - this is a advantage of radio bandwidth. Since ASN.1 has become an international standard since 1982, its encoding rules are mature and have long-term reliability and interoperability tracking records.
Almost all operating systems support ASN.1, ASN.1 also supports popular programming languages such as Java, C and C , and more old programming languages such as Cobol. An example of a wide range of ASN.1 is that there are many tools that have supported more than 150 different computer platforms. There is a large number of testing ASN.1 tools have been used for a long time. With these tools, you can bring new products to the market faster, at least, you can recall those new code-based products that do not have effectively tested. Case study
If a company has a warehouse connected to several sales outlets, the purchase is saved in this warehouse, and the ship is transferred from this warehouse. This company needs an agreement with the following characteristics: order collection in local sales outlets; they are sent to the warehouse, where managing delivery goods; through the customer's requirements, the delivery receipt must be sent back to the sales outlet to do the next step.
The protocol can be expressed as the following two ASN.1 modules: module-order definitions automatic tags :: = Begin
ORDER :: = sequence {header order-header, items sequence of order-line}
Order-header :: = sequence {number order-number, date date, client client, payment payment-method}
ORDER-NUMBER :: = NumericString (Size (12))
Date :: = NumericString (size (8)) - MMDDYYYYYYYYY
Client :: = SEQUENCE {Name Printablestring (size (1..20)), STREET PrintAbleString (Size (1..50)) Optional, Postcode NumericString (Size (5)), Town Printablestring (Size (1..30) ), Country printablestring (size (1..20)) Default default-country} default-country printablestring :: = "france"
Payment-method :: = choice {check numericString (size (15)), CREDIT-CARD CREDIT-CARD, CASH NULL}
Credit-card :: = sequence {type card-type, number numericString (size (20)), expiry-date numericString (size (6)) - mmyyyy -} card-type :: = Enumerated {cb (0) , Visa (1), Eurocard (2), Diners (3), American-express (4)}
Order-line :: = sequence {item-code item-code, label label, quantity quantity, price cents}
Item-code :: = numericString (size (7))
Label :: = Printablestring (size (1..30))
Quantity :: = choice {UNITES INTEGER, MILLIMETRES INTEGER, MILLIGRAMES INTEGER}
CENTS :: = Integer
Delivery-report :: = sequence {Order-code ORDER-NUMBER, DELIVERY Sequence of Delivery-line}
Delivery-line :: = sequence {item item-code, quantity quantity}
End
Protocol Definitions Automatic Tags :: = Beginimports Order, Delivery-Report, Item-Code, Quantity, Order-Number from Module-ORDER;
PDU :: = choice {Question Choice {Question1 ORDER, Question2 item-code, question3 Order-number, ...}, answer choice {answer1 Delivery-Report, Answer2 Quantity, Answer3 Delivery-Report, ...}} END