CN100493046C - Coding/decoding method for communication system information and coder/decoder - Google Patents

Coding/decoding method for communication system information and coder/decoder Download PDF

Info

Publication number
CN100493046C
CN100493046C CNB2006101402182A CN200610140218A CN100493046C CN 100493046 C CN100493046 C CN 100493046C CN B2006101402182 A CNB2006101402182 A CN B2006101402182A CN 200610140218 A CN200610140218 A CN 200610140218A CN 100493046 C CN100493046 C CN 100493046C
Authority
CN
China
Prior art keywords
communication system
system information
data structure
type
data
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Expired - Fee Related
Application number
CNB2006101402182A
Other languages
Chinese (zh)
Other versions
CN1929461A (en
Inventor
沈小荣
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Huawei Technologies Co Ltd
Original Assignee
Huawei Technologies Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Huawei Technologies Co Ltd filed Critical Huawei Technologies Co Ltd
Priority to CNB2006101402182A priority Critical patent/CN100493046C/en
Publication of CN1929461A publication Critical patent/CN1929461A/en
Application granted granted Critical
Publication of CN100493046C publication Critical patent/CN100493046C/en
Expired - Fee Related legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Abstract

This invention discloses decoding method and its coding device of communication system, which comprises the following steps: defining communication system message each element logic relationship into one data structure as comment by elements; defining relative data structure type according to information element property; when coding communication information, according to data structure and other types to input data structure coder for each data structure element to get said communication data; when decoding communication message, according to data structure and other types to read communication system data flow to read data structure element for decoding to get the communication system data.

Description

The decoding method of communication system information and coding and decoding device
Technical field
The present invention relates to the encoding and decoding technique in the communications field, relate in particular to a kind of decoding method and encoder of communication system information.
Background technology
Message in the communication system generally is described and defines with document form, is converted into the form that computer can be handled by computer, thereby realizes the encoding and decoding to message.In cataloged procedure, computer is converted to the bit stream that communication system equipment can be handled with communication system information; In decode procedure, computer is decoded as the message semantic definition that people can discern with message bit stream.
(Information Element IE), is used to carry different kinds of information to comprise some information units in the communication system information.IE has different attributes, maybe can repeat as optional, essential; Also have logical relation between the IE, comprise a plurality of information units as an information unit, the former is as group, and the latter is as the member of this group.We can say that communication system information is formed by a plurality of IE combined nestings.Some message, as Diameter message, IE quantity is more, the logicality between IE is stronger, and therefore the efficient to encoding and decoding requires also higher thereupon.
The initial proposition of Diameter is as the improvement of Radius agreement or substitutes that its introducing is that it mainly contains following function as the aaa protocol of supporting based on the AAA framework of IP technology:
During the resource of authentication (Authentication) user in using network system to the affirmation of user identity;
Authorize (Authorization) network system authorized user to use its resource in a particular manner;
(Accounting) network system of chargeing is collected, recording user is to the use of Internet resources, so that collect resource accounting to the user, perhaps is used for purposes such as audit.
Referring to Fig. 1, be the message format schematic diagram of Diameter.
Diameter message is made up of message header and message body, and Fig. 1 has provided the message header form.The head of Diameter message comprises 20 bytes, version information (Version) that 4 bytes are 8bit and the message-length (Message Lenth comprises message header length) of 24bit.Message flag position that 4 bytes subsequently are 8bit and the command code (Command-Code) of 24bit.Application identities (Application-Code), hop-by-hop sign (Hop-by-Hop Identifier) and end-to-end sign (End-to-End Identifier) all have 4 bytes, wherein application identities is in order to the suitable application of Indication message, the hop-by-hop sign is used to judge request and the corresponding relation of replying, and end-to-end sign is mainly used in the inspection of repetition message.
Whole bytes behind the message header are exactly the particular content of message body, with property value to (AVP, form Attribute-Value-Pair) is end to end convergence one by one.The form of AVP also is made up of head and data.
Referring to Fig. 2, be DiameterAVP form schematic diagram.
As shown in Figure 2, the header structure of AVP is: 4 bytes are AVP code (AVP Code), 4 bytes subsequently are made of the AVP sign of 8bit and the AVP length (AVP Length comprises the AVP head length) of 24bit, and the AVP sign is used to notify receiving terminal how to handle this attribute.
Byte behind the head is exactly a data content.Different AVP may have different data types, as UTF8string, Unsigned32, Unsigned64, Enumerated, and Group etc.
The implication of each several part is as follows among the AVP:
The classification of AVP Code:AVP, for example the Code value of Original-Host AVP is 264;
V: the Vendor-ID field whether occurs among identifying this AVP head;
M: identify this AVP and whether belong to essential AVP, with regard to a specific Diameter order, there are some AVP to occur, for example Original-Host AVP and Original-Realm AVP must occur, and Session-ID AVP must occur among the charging utility command word of Diameter;
P: whether the data division that identifies this AVP has passed through encryption;
AVP Length: this AVP comprises the length of data division, and the data division length of any AVP all is necessary for 4 integral multiple, not enough fills with " 0 ";
Vendor-ID: optional, sign generates the supplier of the equipment of this AVP value;
Data: write down concrete data value, the type of concrete data is determined by AVP Code.
Table 1 is the example of a Diameter message content:
Table 1:
The AVP title Classification Data type Attribute
session_id
263 UTF8String Essential and fixed-site
origin_host
264 DiameterIdentity Essential
origin_realm
296 DiameterIdentity Essential
destination_realm
283 DiameterIdentity Essential
destination_host
293 DiameterIdentity Optional
auth_application_id
258 Unsigned32 Essential
vendor_specific_application_id
260 Grouped Optional
vendor_id
266 Unsigned32 Optional, the AVP group membership
auth_application_id 255 Unsigned32 Essential, the AVP group membership
acct_application_id
259 Unsigned32 Essential, the AVP group membership
service_context_id
461 UTF8String Essential
service_identifier 439 Unsigned32 Optional
user_name
1 UTF8String Optional
origin_state_id 278 Unsigned32 Optional
event_timestamp 55 Time Optional
cc_request_type 416 Enumerated Essential
cc_request_number 415 Unsigned32 Essential
cc_subscription_id 419 Unsigned64 Optional
subscription_id
443 Grouped Optional, can repeat
subscription_id_type 450 Enumerated Essential, the AVP group membership
subscription_id_data
444 UTF8String Essential, the AVP group membership
request_action 436 Enumerated Optional
................................... ... ....
Service-Specific-Data XXX .... Optional
................................... ... ....
As seen from the above table, AVP has following characteristics:
1, the logicality of AVP is strong, and each AVP has different data types, also has essential/optional attribute, whether can repeat attribute, and the AVP of GROUP type also comprises sub-AVP etc.;
2, AVP's essential/optional attribute, can repeat attribute and make that the total length of putting in order of AVP and Diameter message is uncertain;
3, need to carry a fairly large number of AVP in the Diameter message in general the application, reach more than 100 individual as AVP quantity in 3GPP TS32.260 V6.2.0 for the CCR (Credit Control Request) of IMS definition;
4, practical application also needs to remove self-defined AVP according to service needed.
Owing to above reason makes in the Diameter message body to AVP encoding and decoding and loaded down with trivial details, and error rate height.The traditional method of AVP coding is to fill in message body at each AVP in the message definition by byte one by one in the Diameter message body; The traditional method of AVP decoding is to travel through all AVP codes by byte order in the message body in the Diameter message body, when obtaining the AVP of needs, obtains the value of isolated AVP again by byte.Because the uncertain characteristics of the quantity of AVP and order in the Diameter message body, can not be with traditional data structure definition Diameter message body in the prior art.
This has also just caused having the following disadvantages in the prior art:
Application can not be by formal operations Diameter message body of data structure, need handle according to the logic of each AVP and generate Diameter message body, and this pilot process is loaded down with trivial details, and fills in message body by byte and cause error rate height; Simultaneously also because of there being according to requirements of service self-defined AVP, this makes the maintenance to message body be not easy very much, and index word is big in the time of need additions and deletions change AVP in message definition.
Summary of the invention
The invention provides a kind of method of communication system information encoding and decoding, in order to solve the problem that process is loaded down with trivial details, the error rate is high, maintenance difficulties is big when handling baroque communication system information that exists in the prior art.
The present invention provides a kind of encoder of communication system information in addition, in order to solve the problem that process is loaded down with trivial details, the error rate is high, maintenance difficulties is big when the communication system information of coding structure complexity that exists in the prior art.
The present invention also provides a kind of decoder of communication system information, and the process when the communication system information of decode structures complexity that exists in the prior art is loaded down with trivial details, the error rate is high in order to solve, the problem of easy care not.
The method of the embodiment of the invention comprises step:
The information element of non-set type in the communication system information is defined as basic data type, the information element of set type is defined as type of data structure, and with the member of information element as the data structure of described communication system information correspondence;
Type according to the attribute definition respective data structures member of described information element;
When the described communication system information of coding, according to described data structure and its member type input data structure member's coded data, and one by one described data structure member is encoded, obtain the message flow data of described communication system information;
When the described communication system information of decoding, read described communication system information flow data according to described data structure and its member type, and one by one the described data structure member who reads is decoded, obtain the decoded data of described communication system information.
According to said method of the present invention, the type according to the attribute definition respective data structures member of described information element comprises: if the attribute of the information element in the described communication system information is for repeating, then the corresponding data structure member's of definition type is for tabulating; If the attribute of the information element in the described communication system information is optional, the data structure member's of then definition correspondence type is a pointer.
In the said method, described coded data according to described data structure and its member type input data structure member comprises:
When described data structure is the data structure of described communication system information, if the member type of this data structure is a basic data type, then with the encoded data record of the information element of correspondence in this data structure member; If described data structure is the pairing data structure of group type information element, then with the encoded data record of its group membership's information element in the member of this data structure; And
If data structure member's type is tabulation, then that this data structure member is each coded data records in this tabulation as list items;
Read described communication system information flow data according to described data structure and its member type, comprising:
When described data structure is the data structure of described communication system information, if this data structure member type is basic data type, then with the message flow data record of the information element of correspondence in this data structure member; If described data structure is the pairing data structure of group type information element, then with the message flow data record of its group membership's information element in the member of this data structure; And
If data structure member's type is tabulation, then the each message flow data that occur of this data structure member are recorded in this tabulation as list items.
The size of described tabulation changes according to described data structure member's the number of times that repeats.
According to said method of the present invention, also further comprise step:
If the attribute of described information element is essential, when the described communication system information of coding,, then return error message if corresponding data structure member does not exist; When the described communication system information of decoding,, then return error message if do not get access to corresponding message flow data.
According to said method of the present invention, also further comprise step:
Data structure and its member type according to described communication system information generate addressable port and decoding interface; When the described communication system information of coding, call described addressable port and encode; When the described communication system information of decoding, call described decoding interface and decode.
In the said method, described data structure and its member type according to described communication system information generates addressable port and decoding interface, comprising:
Be respectively the data structure of described communication system information correspondence, and the pairing data structure of all group type information elements generates addressable port and decoding interface, and generate the call relation of described addressable port and decoding interface, and be the data structure member's prescribed coding interface and the decoding interface of the basic data type in all data structures according to the logical relation of each information element in the described communication system information.
In the said method,, specify the addressable port and the decoding interface of corresponding data type for the data structure member of described basic data type according to the data type of the information element of correspondence.
According to said method of the present invention, the logical relation of each information element is defined as described communication system information before the data structure in according to described communication system information, also further comprises step:
Dispose the defined file of described communication system information, describe all information elements and attribute and logical relation in the described communication system information in the described file;
The logical relation of each information element is defined as described communication system information in the data configuration steps in according to described communication system information, according to described defined file described communication system information is defined as a data structure.
With symbol or form, identify the attribute and the relation of described information element in the defined file of described communication system information.
When the structural change of communication system information, reconfigure the defined file of described communication system information.
The encoder of the communication system information that the embodiment of the invention provides comprises:
The organization definition module, be used for the information element of the non-set type of communication system information is defined as basic data type, the information element of set type is defined as type of data structure, and with the member of information element as the data structure of described communication system information correspondence; Type according to the attribute definition respective data structures member of described information element;
Coding module is used for according to the data structure of described organization definition module definition and its member type input member's coded data, and one by one described member is encoded, and obtains the code of described communication system information.
Above-mentioned encoder also comprises the addressable port generation module, is used for data structure and its member type generation addressable port according to the communication system information of described organization definition module definition;
When coding during described communication system information, described coding module is used to call the addressable port that described addressable port generation module generates and encodes.
Above-mentioned encoder also comprises the document definition module, is used to dispose the defined file of described communication system information, describes all information elements and attribute and logical relation in the described communication system information in the described file;
Described organization definition module is used for according to the defined file that described document definition module disposes described communication system information being carried out organization definition.
The decoder of the communication system information that the embodiment of the invention provides comprises:
The organization definition module, be used for the information element of the non-set type of communication system information is defined as basic data type, the information element of set type is defined as type of data structure, and with the member of information element as the data structure of described communication system information correspondence; And according to the attribute definition respective data structures member's of described information element type;
Decoder module is used for reading described communication system information flow data according to data structure and its member type of described organization definition module definition, and one by one the described member who reads is decoded, and obtains the decoded data of described communication system information.
Above-mentioned decoder also comprises the decoding interface generation module, is used for data structure and its member type generation decoding interface according to the communication system information of described organization definition module definition;
When decoding during described communication system information, described decoder module is used to call the decoding interface that described decoding interface module generates and decodes.
Above-mentioned decoder also comprises the document definition module, is used to dispose the defined file of described communication system information, describes all information elements and attribute and logical relation in the described communication system information in the described file;
Described organization definition module is used for according to the defined file that described document definition module disposes described communication system information being carried out organization definition.
Beneficial effect of the present invention is as follows:
(1) the present invention is by reorganizing all information elements in the communication system information according to its attribute and logical relation, set up data structure and specify its structure member, and definition data structure member's type, thereby can realize the Code And Decode process according to this data structure and its member type, improve the encoding-decoding efficiency of communication system information, reduced the error rate.
(2) the present invention is on the basis of the information element in the communication system information being carried out the definition of data structure definition and data structure member type, automatically generate the encoding and decoding interface, can realize the encoding and decoding of communication system information as long as when encoding and decoding, call corresponding encoding and decoding interface, thereby make encoding-decoding process simpler and more direct.
(3) the present invention is by the defined file of configuration communication system message, all information elements and attribute and logical relation in the communication system information described, and communication system information is carried out organization definition and generates the encoding and decoding interface according to this defined file, when the communication system information structural change, only need reconfigure this defined file, regenerate the encoding and decoding interface, thereby improved the maintainability of encoding-decoding process.
Description of drawings
Fig. 1 is the message format schematic diagram of Diameter;
Fig. 2 is a DiameterAVP form schematic diagram;
Fig. 3 is the Diameter message body AVP logical description chained list of the embodiment of the invention;
Fig. 4 is the schematic flow sheet of the Diameter message body AVP logical description of the embodiment of the invention;
Fig. 5 is the structuring definition procedure schematic diagram of the Diameter message body of the embodiment of the invention;
Fig. 6 is the schematic flow sheet that the addressable port of the Diameter message body of the embodiment of the invention is realized;
Fig. 7 is the schematic flow sheet that the decoding interface of the Diameter message body of the embodiment of the invention is realized;
Fig. 8 is the structural representation of encoder of the communication system information of the embodiment of the invention;
Fig. 9 is the structural representation of decoder of the communication system information of the embodiment of the invention.
Embodiment
In order to make purpose of the present invention, technical scheme and beneficial effect clear, embodiments of the present invention is described in detail below in conjunction with accompanying drawing.
Embodiments of the invention are according to attribute and the logical relation of the IE in the communication system information, IE are reorganized and the structure of definition communication system information, and the body encoding and decoding interface that gives information, and realize encoding and decoding to communication system information with this.
At first, according to the logical relation of each information element in the communication system information communication system information is defined as a data structure, all information elements are the member of this structure; And according to the attribute definition respective data structures member's of information element type;
When the described communication system information of coding, according to data structure and its member type input member's coded data, and one by one the member is encoded, obtain the communication system information flow data;
When the described communication system information of decoding, read described communication system information flow data according to data structure and its member type, and one by one the member who reads is decoded, obtain the decoded data of communication system information.
Encoding-decoding process with Diameter message is an example below, and the embodiment of the invention is described in detail.
According to foregoing description, before Diameter message is encoded, at first to customize Diameter message body defined file, with this input as Diameter message body encoding and decoding source code Core Generator.Diameter message body defined file is described AVP all in the Diameter message, comprise all properties to AVP (as essential/optional attribute, whether can repeat attribute etc.), AVP type (AVPCode), and the logical relation between AVP is described.The file format that Diameter message body defined file can conveniently read and edit for text, EXCEL file etc.Table 2 is examples of the Diameter message body that defines in Microsoft Excel.
Table 2:
AVPName AVP Code Value Type
<session_id> 263 UTF8String
{origin_host} 264 DiameterIdentity
{origin_realm} 296 DiameterIdentity
{destination_realm} 283 DiameterIdentity
[destination_host] 293 DiameterIdentity
{auth_application_id} 258 Unsigned32
[vendor_specific_application_id] 260 Grouped
[vendor_id] 266 Unsigned32
{auth_application_id} 255 Unsigned32
{acct_application_id} 259 Unsigned32
{service_context_id} 461 UTF8String
[service_identifier] 439 Unsigned32
[user_name] 1 UTF8String
[origin_state_id] 278 Unsigned32
[event_timestamp] 55 Time
{cc_request_type} 416 Enumerated
{cc_request_number} 415 Unsigned32
[cc_subscription_id] 419 Unsigned64
*[subscription_id] 443 Grouped
{subscription_id_type} 450 Enumerated
AVPName AVP Code Value Type
{subscription_id_data} 444 UTF8String
[request_action] 436 Enumerated
.............................. ... ....
[Service-Specific-Data] XXX ....
.............................. ... ....
The attribute of each AVP is represented by different symbols and form in the table 2:
<AVP〉show it is essential AVP and fixed-site;
{ AVP} shows it is essential AVP;
[AVP] shows it is optional AVP;
* AVP shows that this AVP can occur repeatedly;
The member of AVP group is represented in the indentation of AVP.
The effect of Diameter message body defined file is to describe Diameter message intuitively, and generates the logical description of Diameter message according to this document, realizes the realization of structuring definition of Diameter message body and encoding and decoding interface with this.
The logical description process of Diameter message promptly, is organized as the chain sheet form with Diameter message body defined file, and attribute and the logical relation of each IE is described with parameter.The process that generates the logical description of AVP in the Diameter message body according to Diameter message body defined file is as described below.
With C++ is example, organizes as all AVP in the Diameter message body of definition in the table 2 by following data structure:
typedef std::vector<CAvpDic>TAvpDicList;
typedef struct_CAvpDic
{
Std::string m_strAvpName; //AVP title
short m_nAvpCode;//AVP code
Int m_enAvpType; //AVP type, as Unsigned32, UTF8String, Groupcd etc.
Int m_enAvpFlag; Essential and the fixed-site of // mark AVP, essential, optional
Bool m_bRepetitious; Whether // mark AVP can repeat
TAvpDicList m_GroupMemberList; // write down all sub-AVP items during for Grouped as AVP
}CAvpDic
In the source code Core Generator, read in all AVP and attribute thereof in the Diameter message body defined file, generate the AVP logical description of Diameter message body according to the data structure of above-mentioned definition.Diameter message body as definition in the table 2 can be organized as the chained list of similar Fig. 3, and the generative process of this chained list as shown in Figure 4.
Referring to Fig. 4, be the schematic flow sheet of the Diameter message body AVP logical description of the embodiment of the invention, concrete steps comprise:
S401, read Diameter message body defined file.
All AVP in S402, the traversal Diameter message.
S403, if contain " * " in the AVPName row, it is TRUE that m_bRepetitious is set, and represents that this AVP can repeat;
S404, if contain "<" in the AVPName row, it is " fixed-site " mark that m_enAvpFlag is set;
If contain in the AVPName row " { ", it is " essential " mark that m_enAvpFlag is set;
If contain in the AVPName row " [", it is " optional " mark that m_enAvpFlag is set;
S405, remove " * ", "<", "〉", " { ", " } ", " [", "] " character in the AVPName row, record among the m_strAvpName;
S406, AVP CODE row are recorded m_nAvpCode;
S407, value type row are recorded m_enAvpType;
S408, if this row does not have indentation, this AVP is recorded the AVP tabulation (being expressed as the ROOT contact among Fig. 3) of Diameter message; If this row has indentation, this AVP is recorded in the m_GroupMemberList tabulation of upper strata AVP.Return step S402.
S409, after the description of finishing all IE, process ends.
For autocoding and the automatic decoding that realizes Diameter message, also to generate the structuring definition of Diameter message and the target source code of Code And Decode according to the AVP logical description of Diameter message.Encoding and decoding target source code is intended to provide the member's organization definition and the encoding and decoding interface of Diameter message body to business.
The principle of Diameter message body structuring definition is:
1) message body is defined as a data structure, each AVP is the member of structure for this reason;
2) be that the AVP of Grouped is defined as data structure with type, its sub-AVP is the member of this structure; Type is the member that the pairing data structure of the AVP of Grouped can be used as the data structure of message body correspondence;
3) with attribute be the formal definition of optional AVP, when pointer represents that this AVP will not occur during for NULL in message body with pointer;
4) with AVP the formal definition to tabulate of attribute for repeating, the big I of tabulation becomes with the quantity of the AVP that repeats.
Referring to Fig. 5, the structuring definition procedure schematic diagram for the Diameter message body of the embodiment of the invention comprises step:
S501, open header file.If what handle is Diameter message, opens the .h file of Diameter message, otherwise open the .h file of GroupedAVP.
S502, generation data structure name.If what handle is Diameter message, generates the structure title of Diameter message, otherwise generate the structure title of AVP.
All members among S503, the traversal m_GroupMemberList then go to step S512 if finish; Otherwise execution in step S504.
The value of S504, judgement m_enAvpFlag shows that as if this value AVP is optional, then execution in step S505; Otherwise execution in step S506.
S505, mark need be by the pointer definition members.
The value of S506, judgement m_bRepetitious shows that as if this value AVP can repeat, then execution in step S507; Otherwise execution in step S508.
S507, mark need use LIST definition member.
The value of S508, judgement m_enAvpType if this value shows that AVP is Grouped, then goes to step S509, otherwise goes to step S511.
S509, this algorithm of recurrence generate the structuring definition code of this AVP at the .h of Grouped AVP file.
The result of S510, integrating step S505 and step S507 uses the structure title person of being defined as; Go to step S503.
The result of S511, integrating step S505 and step S507 uses fundamental type definition member; Go to step S503.
S512, the statement of generation encoding and decoding interface.
S513, process ends.
After above-mentioned flow performing is finished, will generate 2 .h files, one is the .h file (wherein will introduce the AVP of Grouped type in case of necessity) of Diameter message definition, and another is the .h file that has defined the AVP of all Grouped types.
With C++ is example, the structuring definition that generates according to the listed Diameter message body of table 2 and the .h file source code of encoding and decoding interface can for:
class msg
{
public:
Std::string session_id; // essential AVP defines with basic data type
std::string origin_host;
std::string origin_realm;
std::string destination_realm;
Std::string * pdestination_host; // optional AVP is with the pointer formal definition
unsigned int auth_application_id;
Vendor_specific_application_id*pvendor_specific_applicat ion_id; // group AVP is with the pointer formal definition
std::string service_context_id;
…………………
Std::list<subscription_id *〉* psubscription_id; // the AVP that can repeat, and AVP is Grouped, optional, and then with tabulation and pointer formal definition
…………
Msg (char* pBuff); // decoding interface wherein will call vendor_specific_application_id, the decoding interface of subscription_id...
Int Encode (char* pBuff); // addressable port wherein will call the addressable port of vendor_specific_application_id during not for NULL as pvendor_specific_application_id
}
Wherein the structuring definition of vendor_specific_application_id and encoding and decoding interface:
class vendor_specific_application_id
{
public:
Unsignedint*pvendor_id; // optional AVP is with the pointer formal definition
unsigned int auth_application_id;
unsigned int acct_application_id;
Vendor_specific_application_id (char* pBuff); // decoding interface can be called by the decoding interface of msg
Int Encode (char* pBuff); // addressable port can be called by the addressable port of msg
………………………
};
With C++ is example, by the public encoding and decoding interface of basic data type definition can for:
The addressable port of STRING type:
int addStringAvp(short avpCode,std::string avpValue char* pBuff)
The decoding interface of STRING type:
std::string getStringAvp(shortavpCode,char* pBuff)
The addressable port of unsigned int type:
int addIntAvp(short avpCode,unsigned int avpValue char* pBuff)
The decoding interface of unsigned int type:
unsigned int getIntAvp(shortavpCode,char* pBuff)
The principle of Diameter message body encoding and decoding interface definition is:
1) provides public encoding and decoding interface by basic data type (as UTF8String, Unsigned32, Unsigned64, Enumerated etc.);
2) for type is that the data structure of the AVP correspondence of Grouped provides the encoding and decoding interface, in the realization of interface at each AVP member's encoding and decoding; If the member is Grouped, call the encoding and decoding interface that its corresponding data structure provides; Otherwise call the encoding and decoding interface of basic data type;
3) data structure for Diameter message correspondence provides the encoding and decoding interface, in the realization of interface at each AVP member's encoding and decoding; If the member is Grouped, call the encoding and decoding interface that its corresponding data structure provides; Otherwise call the encoding and decoding interface of basic data type.
Referring to Fig. 6, be the schematic flow sheet that the addressable port of the Diameter message body of the embodiment of the invention is realized, concrete steps comprise:
S601, open the coding project file.If what handle is Diameter message, opens the .cpp file of Diameter message, otherwise open the .cpp file of GroupedAVP.
S602, generation addressable port function header.If what handle is Diameter message, generates the addressable port function header of Diameter message, otherwise generate the addressable port function header of AVP.
All members among S603, the traversal m_GroupMemberList change step S612 if finish, otherwise execution in step S604.
The value of S604, judgement m_enAvpFlag shows that as if this value AVP is optional, then execution in step S605; Otherwise execution in step S606.
S605, generating code: if structure member's pointer returns mistake during for NULL.
The value of S606, judgement m_bRepetitious shows that as if this value AVP can repeat, then execution in step S607; Otherwise execution in step S608.
S607, generating code: all of traversal structure member tabulation.
S608, judge the value of m_enAvpType, if this value shows that AVP is Grouped, execution in step S609 then, otherwise execution in step S611.
S609, this algorithm of recurrence generate the addressable port code of this AVP at the .cpp of Grouped AVP file.
S610, generating code: the addressable port that calls this AVP counter structure; Go to rapid S603.
S611, generating code: the addressable port that calls fundamental type by the type of AVP; Go to rapid S603.
S612, addressable port code generate and finish.
After executing above-mentioned flow process, generate 2 .cpp files that are used to encode, one is the .cpp file of realizing the Diameter message coding, and another is a .cpp file of realizing the AVP coding of all Grouped types.
Referring to Fig. 7, the realization flow schematic diagram for the decoding interface of the Diameter message body of the embodiment of the invention comprises step:
S701, open the decoding project file.If what handle is Diameter message, opens the .cpp file of Diameter message, otherwise open the .cpp file of Grouped AVP.
S702, generation decoding interface function head.If what handle is Diameter message, generates the decoding interface function header of Diameter message, otherwise generate the decoding interface function header of AVP.
All members among S703, the traversal m_GroupMemberList then go to step S714 if finish, otherwise execution in step S704.
S704, generating code: the CODE according to AVP searches for AVP in message body.
S705, judge the value of m_enAvpFlag, if this value shows that AVP is non-optional, execution in step S706 then, otherwise execution in step S707.
S706, generating code: do not return mistake if find.
S707, judge the value of m_bRepetitious, if this value shows that AVP can repeat, execution in step S708 then, otherwise execution in step S712.
S708, judge the value of m_enAvpType, if this value shows that AVP is Grouped, execution in step S709 then, otherwise execution in step S711.
S709, this algorithm of recurrence generate the decoding interface code of this AVP at the .cpp of Grouped AVP file.
S710, generating code: the decoding interface that calls this AVP counter structure obtains the value of member variable; Go to step S703.
S711, generating code: the decoding interface that calls fundamental type by the type of AVP obtains the value of AVP and composes to member variable; Go to step S703.
S712, the value (can referring to step S708-711) of obtaining AVP according to the type of AVP are increased in the member variable tabulation.
S713, generating code: cyclic search AVP in message body, call the value that addressable port obtains AVP by the type of AVP and be increased to member's tabulation if find then; Go to step S703.
S714, decoding interface code generate and finish.
After executing above-mentioned flow process, generate 2 .cpp files that are used to decode, one is the .cpp file of realizing the Diameter source codec, and another is a .cpp file of realizing the AVP decoding of all Grouped types.
Above-mentioned realization flow can be generated executable command, as MakeDiameterCode.Before encoding and decoding Diameter message, generate the source code of Diameter message body encoding and decoding by the execution of this order.Can designated parameter in order, in order to show the source code that generates specified type.For example:
MakeDiameterCode MyDiameterMessage.txt -C
Illustrate: use the Diameter message definition in the MyDiameterMessage.txt file under the current directory to generate diameter message body encoding and decoding C++ source code.
MakeDiameterCode MyDiameterMessage.txt -J
Illustrate: use the Diameter message definition in the MyDiameterMessage.txt file under the current directory to generate diameter message body encoding and decoding JAVA source code.
The .h file that the application of Diameter message can be quoted Diameter message calls addressable port, realizes the coding to Diameter message, for example:
#include " msg.h " // the quote .h file of Diameter message
// following be Diameter message coding sample code
Msg* pMsg=new msg; // establishment message
PMsg-〉session_id=" mySessionId "; // value of AVP session_id is set
PMsg-〉origin_host=" origin_host "; // value of AVP origin_host is set
......
// value of optional AVP destination_realm is set
pMsg->pdestination_realm=new std::string("destination_realm");
// value of the AVP vendor_specific_application_id of optional GROUP type is set
pMsg -> pvendor_specific_application_id = newvendor_specific_application_id;
pMsg->pvendor_specific_application_id->acct_application_id=1
pMsg->pvendor_specific_application_id->auth_application_id=2;
Message flow shelf space behind the // application coding
char msgBuff[2048]={0};
// call addressable port
int iResult=pMsg->Encode(msgBuff);
Message flow behind the // message Msg coding is kept among the msgBuff, adds the Diameter message header and just can send this Diameter message.
The .h file that the application of Diameter message can be quoted Diameter message calls decoding interface, realizes the decoding to Diameter message.For example:
#include " msg.h " // the quote .h file of Diameter message
// following be decoding sample code, what wherein preserve among the msgBuff is that the Diameter message that receives is removed the message flow of message header part
// call decoding interface
msg *pMsg=new msg(msgBuff);
// can quoted message in the value of each AVP
cout<<"session_id:"<<pMsg->session_id<<endl;
cout<<"origin_host:"<<pMsg->origin_host<<endl;
cout<<"destination_realm:"<<pMsg->pdestination_realm)<<endl;
……
cout << "vendor_specific_application_id->acct_application_id:"<<pMsg->pvendor_specific_application_id->acct_application_id)<<endl;
……
When Diameter message body structure changes,, re-use structuring definition and encoding and decoding interface source code that the source code Core Generator regenerates Diameter message body as long as revise Diameter message body defined file.When the needs encoding and decoding, as long as call the encoding and decoding that newly-generated encoding and decoding interface just can be realized Diameter message.
Based on above-mentioned identical technical conceive, the embodiment of the invention provides a kind of encoder and a kind of decoder of communication system information.
Referring to Fig. 8, the structural representation for the code device of the communication system information of the embodiment of the invention comprises: document definition module, organization definition module, addressable port generation module and coding module.
The document definition module is used for the defined file of configuration communication system message, has described all information elements and attribute and the logical relation in the communication system information in this document.
The logical relation of each information element in the communication system information that the organization definition module is used for defining according to the document definition module is defined as a data structure with communication system information, and all information elements are the member of this structure; And according to the attribute definition respective data structures member's of information element type.
The addressable port generation module is used for generating addressable port according to the data structure of the communication system information of organization definition module generation and its member type.
Coding module is used for data structure and its member type according to the generation of organization definition module, input data structure member's coded data, and call the addressable port that the addressable port generation module generates and one by one the data structure member is encoded, obtain the communication system information flow data.
Referring to Fig. 9, the structural representation for the decoding device of the communication system information of the embodiment of the invention comprises: document definition module, organization definition module, decoding interface generation module and decoder module.
The document definition module is used for the defined file of configuration communication system message, has described all information elements and attribute and the logical relation in the communication system information in this document.
The logical relation of each information element is defined as a data structure with communication system information in the communication system information that the organization definition module is used for defining according to the document definition module, and all information elements are the member of this structure; And according to the attribute definition respective data structures member's of information element type.
The decoding interface generation module is used for generating decoding interface according to the data structure of the communication system information of organization definition module generation and its member type.
Decoder module is used for data structure and the member type according to the generation of organization definition module, read the communication system information flow data, and call decoding interface module generation decoding interface and one by one the member who reads is decoded, obtain the decoded data of communication system information.
Obviously, those skilled in the art can carry out various changes and modification to the present invention and not break away from the spirit and scope of the present invention.Like this, if of the present invention these are revised and modification belongs within the scope of claim of the present invention and equivalent technologies thereof, then the present invention also is intended to comprise these changes and modification interior.

Claims (18)

1, a kind of decoding method of communication system information is characterized in that, may further comprise the steps:
The information element of non-set type in the communication system information is defined as basic data type, the information element of set type is defined as type of data structure, and with the member of information element as the data structure of described communication system information correspondence;
Type according to the attribute definition respective data structures member of described information element;
When the described communication system information of coding, according to described data structure and its member type input data structure member's coded data, and one by one described data structure member is encoded, obtain the message flow data of described communication system information;
When the described communication system information of decoding, read described communication system information flow data according to described data structure and its member type, and one by one the described data structure member who reads is decoded, obtain the decoded data of described communication system information.
2, the method for claim 1 is characterized in that, described attribute definition respective data structures member's according to described information element type comprises:
If the attribute of the information element in the described communication system information is for repeating, the data structure member's of then definition correspondence type is tabulation;
If the attribute of the information element in the described communication system information is optional, the data structure member's of then definition correspondence type is a pointer.
3, method as claimed in claim 2 is characterized in that,
Described coded data according to described data structure and its member type input data structure member comprises:
When described data structure is the data structure of described communication system information, if the member type of this data structure is a basic data type, then with the encoded data record of the information element of correspondence in this data structure member; If described data structure is the pairing data structure of group type information element, then with the encoded data record of its group membership's information element in the member of this data structure; And
If data structure member's type is tabulation, then that this data structure member is each coded data records in this tabulation as list items;
Describedly read described communication system information flow data, comprising according to described data structure and its member type:
When described data structure is the data structure of described communication system information, if this data structure member type is basic data type, then with the message flow data record of the information element of correspondence in this data structure member; If described data structure is the pairing data structure of group type information element, then with the message flow data record of its group membership's information element in the member of this data structure; And
If data structure member's type is tabulation, then the each message flow data that occur of this data structure member are recorded in this tabulation as list items.
4, method as claimed in claim 2 is characterized in that, the size of described tabulation changes according to described data structure member's the number of times that repeats.
5, the method for claim 1 is characterized in that, also further comprises step:
If the attribute of described information element is essential, when the described communication system information of coding,, then return error message if corresponding data structure member does not exist; When the described communication system information of decoding,, then return error message if do not get access to corresponding message flow data.
6, the method for claim 1 is characterized in that, also further comprises step:
Data structure and its member type according to described communication system information generate addressable port and decoding interface;
When the described communication system information of coding, call described addressable port and encode;
When the described communication system information of decoding, call described decoding interface and decode.
7, method as claimed in claim 6 is characterized in that, described data structure and its member type according to described communication system information generates addressable port and decoding interface, comprising:
Be respectively the data structure of described communication system information correspondence, and the pairing data structure of all group type information elements generates addressable port and decoding interface, and generate the call relation of described addressable port and decoding interface according to the logical relation of each information element in the described communication system information, and
Data structure member's prescribed coding interface and decoding interface for the basic data type in all data structures.
8, method as claimed in claim 7 is characterized in that, according to the data type of the information element of correspondence, specifies the addressable port and the decoding interface of corresponding data type for the data structure member of described basic data type.
9, the method for claim 1 is characterized in that, the logical relation of each information element is defined as described communication system information before the data structure in according to described communication system information, also further comprises step:
Dispose the defined file of described communication system information, describe all information elements and attribute and logical relation in the described communication system information in the described file;
The logical relation of each information element is defined as described communication system information in the data configuration steps in according to described communication system information, according to described defined file described communication system information is defined as a data structure.
10, method as claimed in claim 9 is characterized in that, with symbol or form, identifies the attribute and the relation of described information element in the defined file of described communication system information.
11, method as claimed in claim 9 is characterized in that, when the structural change of communication system information, reconfigures the defined file of described communication system information.
As each described method of claim 1-11, it is characterized in that 12, described communication system information is a Diameter message, described information element is that property value is right.
13, a kind of encoder of communication system information is characterized in that, comprising:
The organization definition module, be used for the information element of the non-set type of communication system information is defined as basic data type, the information element of set type is defined as type of data structure, and with the member of information element as the data structure of described communication system information correspondence; And according to the attribute definition respective data structures member's of described information element type;
Coding module is used for according to the data structure of described organization definition module definition and its member type input member's coded data, and one by one described member is encoded, and obtains the code of described communication system information.
14, encoder as claimed in claim 13 is characterized in that, also comprises the addressable port generation module, is used for data structure and its member type generation addressable port according to the communication system information of described organization definition module definition;
When coding during described communication system information, described coding module is used to call the addressable port that described addressable port generation module generates and encodes.
15, encoder as claimed in claim 13, it is characterized in that, also comprise the document definition module, be used to dispose the defined file of described communication system information, describe all information elements and attribute and logical relation in the described communication system information in the described file;
Described organization definition module is used for according to the defined file that described document definition module disposes described communication system information being carried out organization definition.
16, a kind of decoder of communication system information is characterized in that, comprising:
The organization definition module, be used for the information element of the non-set type of communication system information is defined as basic data type, the information element of set type is defined as type of data structure, and with the member of information element as the data structure of described communication system information correspondence; And according to the attribute definition respective data structures member's of described information element type;
Decoder module is used for reading described communication system information flow data according to data structure and its member type of described organization definition module definition, and one by one the described member who reads is decoded, and obtains the decoded data of described communication system information.
17, decoder as claimed in claim 16 is characterized in that, also comprises the decoding interface generation module, is used for data structure and its member type generation decoding interface according to the communication system information of described organization definition module definition;
When decoding during described communication system information, described decoder module is used to call the decoding interface that described decoding interface module generates and decodes.
18, decoder as claimed in claim 16, it is characterized in that, also comprise the document definition module, be used to dispose the defined file of described communication system information, describe all information elements and attribute and logical relation in the described communication system information in the described file;
Described organization definition module is used for according to the defined file that described document definition module disposes described communication system information being carried out organization definition.
CNB2006101402182A 2006-10-09 2006-10-09 Coding/decoding method for communication system information and coder/decoder Expired - Fee Related CN100493046C (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CNB2006101402182A CN100493046C (en) 2006-10-09 2006-10-09 Coding/decoding method for communication system information and coder/decoder

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CNB2006101402182A CN100493046C (en) 2006-10-09 2006-10-09 Coding/decoding method for communication system information and coder/decoder

Publications (2)

Publication Number Publication Date
CN1929461A CN1929461A (en) 2007-03-14
CN100493046C true CN100493046C (en) 2009-05-27

Family

ID=37859249

Family Applications (1)

Application Number Title Priority Date Filing Date
CNB2006101402182A Expired - Fee Related CN100493046C (en) 2006-10-09 2006-10-09 Coding/decoding method for communication system information and coder/decoder

Country Status (1)

Country Link
CN (1) CN100493046C (en)

Families Citing this family (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101695172B (en) * 2009-10-16 2012-06-27 北京天碁科技有限公司 Method and device for independent description and encoding of message interfaces of communication equipment
EP2557752B1 (en) * 2011-08-11 2017-09-27 Siemens Aktiengesellschaft Method and device for producing an end-to-end communication between two networks
CN102611530A (en) * 2012-03-08 2012-07-25 北京神州数码思特奇信息技术股份有限公司 Telecommunication data encoding method and telecommunication data decoding method
CN102929608A (en) * 2012-10-09 2013-02-13 大唐移动通信设备有限公司 Interface encoding/decoding method and system
CN103813306B (en) * 2012-11-08 2017-12-19 中兴通讯股份有限公司 Attribute carries method and device
CN104320218B (en) * 2014-10-30 2018-01-09 北京思特奇信息技术股份有限公司 A kind of convenient DCC message coding/decoding system and method

Also Published As

Publication number Publication date
CN1929461A (en) 2007-03-14

Similar Documents

Publication Publication Date Title
CN100493046C (en) Coding/decoding method for communication system information and coder/decoder
CN103886376B (en) System and method for rule-based information filtering
CN106559251A (en) A kind of Compilation Method and corresponding interface, component and system based on YANG models
CN103081430A (en) Method and apparatus for filtering streaming data
CN101651683B (en) Method for generating analysis source code of signaling message
CN107302443A (en) Equipment configuration method and device based on network configuration protocol
CN113691651B (en) Top-level planning visualization management method, system and storage medium based on IPv6 network
CN109104405A (en) Binary protocol coding, coding/decoding method and device
CN112822276A (en) Substation control layer communication method and system for transformer substation, electronic equipment and storage medium
CN107122324A (en) A kind of method for message transmission and device
CN104991941A (en) Information processing apparatus, information processing method, and computer program
CN101370003A (en) Method and apparatus for customizing communication protocol, method and apparatus for converting communication protocol description
CN104021121A (en) Method, device and server for compressing text data
CN112988740B (en) Power distribution network data storage method based on multiple data sources
CN103092607A (en) Encoding and decoding method of telecommunications call ticket
CN109068286A (en) A kind of method, medium and the equipment of information parsing
CN110601794B (en) ASN.1 coding and decoding module and message data coding and decoding method
CN103716127A (en) TTCN-3 based compression coding and decoding method and system
CN114065269A (en) Method for generating and analyzing bindless heterogeneous token and storage medium
CN104281632B (en) Coding-decoding method and system based on Object Protocol mapping
CN111770189B (en) Networking type medical big data grading transmission method and system
CN111064560B (en) Data encryption transmission method and device, terminal and data encryption transmission system
KR20180037487A (en) Method and recording medium for compatibility between iec61850 and opc ua
CN116415979B (en) Electricity price consultation management system based on knowledge graph technology
CN104703154B (en) A kind of short message storage method and system of LTE uplinks home gateway

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
C14 Grant of patent or utility model
GR01 Patent grant
C17 Cessation of patent right
CF01 Termination of patent right due to non-payment of annual fee

Granted publication date: 20090527

Termination date: 20121009