http://www.bjx.com.cn/files/wx/sjtx-2/15.htm
Implement H with C language ASN in the 323 protocol. 1 process
Su Huewin Wang Xiaoyan
(Huazhong University of Technology Telecom Information Teaching Research Office)
Abstract: In a heterogeneous computer environment, a basic requirement of communication is to have a standard external data representation, abstract syntax represents ASN. 1 has been widely used in protocol communication. This article develops H. The 323 protocol is an example, and the ASN is described in this process. 1 Coded C language implementation process, pointing out the basic principles.
Keywords: ASN. 1 H. 323 Per Compiler
In an environment consisting of a computer produced by different manufacturers, due to the difference in machine hardware and software configuration, there is often a difference in data representation (such as An ", numerical representation, word length). In order to interconnect each other between the manufacturers, we must eliminate these differences and should have a set of external data representations independent of computer hardware and software environment and implement them by codec. Abstract syntax represents asn. 1 (ITU - T REC.680 | ISO / IEC8824-1) and its basic encoding rule BER (ITU-T REC. X.690 | ISO / IEC8825-1) and tightening coding rules per (ITU-T Rec .X.691 | ISO / IEC8825-2) This role is acting as a number of application layer protocols, making interconnections between different systems. H. H. At the 323 protocol, due to the video, audio data and control news between the gateway, the gateway product may be different, soft and hardware environments produced by different manufacturers. Therefore, ASN is used. 1 Syntax indicator, the format of the transmitted is based on ASN. 1 The bitstream of the PER (Packed Encoding Rules) encoding format.
1. Implementation of an Asn1Toc compiler. The problem is now implemented asn. 1 The work of codec has two implementations of software and hardware. Although the hardware codec is fast processing, it is difficult to maintain, upgrade. Software codec can find a universal tool that has been implemented, but due to its versatility, it has increased the increase in occupancy resources, and has developed special H. 323 agreement, there are many redundancy. Therefore, our way is to use software implementation, and learn from the general tools to remove redundantness and achieve streamlined purposes. Develop H with structured C language 323 When the protocol stack, the first question encountered is how to put H. 225, H235 and H. 245 and other protocols give to ASN. 1 The data structure that is indicated by each message structure can "understand" the data structure. By comparing we are not difficult to implement ASN. 1 Mapping between the data structure to the C language data structure, the mapping relationship can be found in the literature [1]. From the ASN. 1 When the data type indicating the programming language is mapped, it is necessary to follow the following rules: The structure after the mapping should have sufficient information to encode or should have enough domain to store the decoded data, and the factors that consider Realized complexity and optimization storage, etc. Protocol X. 680 defines the ASN. 1 Some basic data types, protocol X. 690 gives how to perform BER (Basic Enco-Ding Rules) encoding, protocol X. 691 gives Per encodes for these data types, which can be combined into different structures, and ASNs appearing in a certain protocol. 1 Data type encoding has two options [2]. We use the method of coding and decoding functions to each new data type, using the ASN. 1 The compiler is automatically completed. Compilation of an ASN file. Pair of compiler. After the ASN file is compiled, it is generated. H and. C two files. . The C data type and ed / decoding function generated after the H file declaration is compiled. The C file is used to implement the edit / decoded function. 2. ASN1-C compiler implementation method (1) Implementing the preparation of the compiler to do before implementing the compiler, we must do the following work: a. Map of data structure is performed to implement ASN. 1 Type to Class C type translation work and exist in header files. Follow the rules as mentioned earlier, ASN. 1 Basic type see the protocol X. 680. B. Prepare Run-Time Library Function, including the BER runtime library function, Per runtime library function, and runtime public library functions. The BER runtime function library includes X. The basic data types of the basic data types specified in 680, the Per Runtime Function Library includes its Per encoding function, the public function library includes tracking, diagnostics, printing, error information processing, and other functions used for the first two library functions. This step design library function leaves an API interface for program call, and users can certainly call these functions to encode data. Here, the call to these functions can be automatically generated by the compiler. C file call. (2) After entering the compiler, the above work can be achieved after the work is done. ASN. 1 The compiler's compilation process includes: initialization, processing module definition header, a data type specified in a ground analysis protocol, generating compilation tables and C code. Specifically, the compilation process mainly includes three scans.
1 First scan analysis syntax, reporting syntax errors and generating compilation tables to ASN. 1 Module is defined as input, gramatic analysis, if a syntax error is found, the compiler will stop and report errors and the line number of the error, in order to simplify the generation of data type codec, this phase will enter the module Multi-level structured types are serialized. It defines that each sub-structure is a new type and gives it the name, and then this structured type can be redefined on each corresponding subdomain with the name of these new subdomains, filled with all the structures. code. 2 Second scan analysis compiling tables, report unfined data types to users, generates a very important role in compiling data type header files that contains C language, it is a detailed description of data. A table, in memory, so that we can easily process it. Such a record list lists all data types generated after the first scan. In ASN. 1 During the file, since the order of the type declaration is random, the following work should be done in advance: • When you encounter a "defined" data type that has not actually defined, you have a record framework for it for padding. . · When encountering a new type specified, it is necessary to check if the record type frame has been assigned. • When the compilation table is generated after the first scan, it should be noted that it should have the appropriate data type declaration order to suit the requirements of the C language compiler. 3 The third scan generates a C file according to the compiling table to realize the coding and decoding function of the coding and decoding function generated by the header file implementation of the coding and decoding function. This part of the code has strong regularity, which follows a model, such as first determined that the structure has an extension, and then determines whether there is optional (OP-TIONAL) or the Default to perform corresponding processing, specific How to deal with X. 690 (BER), X. 691 (Per) After processing, it is actually coding each sub-structure, until the end of this structure, if you want to get some debugging information or error information, you can also add another debug function or error handling. Functions, these functions can be obtained from the runtime function library. (3) Further optimization works to this step, the task implemented by the compiler is basically completed, and the program already has the available protocol data structure, and it is possible to perform edible and decoding. But what is done above is all ASN. 1 to C compiler must do, and we are h. 323 Agreement, this particularity has led to the addition of universal processing, we can also do some optimization for the development agreement itself. H. 323 Embedded Software for Gateway requires our program to reduce the occupation of resources, and our optimization of the code that has been generated, is also here, that is, the time to reduce memory or CPU. Optimization work can be optimized according to the three layers from the underlying to the top-level application, which are compiling levels, protocols, and user-level, which are introduced separately. Compiling level: Optimization in the compilation process in a reasonable way.