CN101697546A - Method for implementing protocol data unit (PDU) used for packing and unpacking network bytes - Google Patents

Method for implementing protocol data unit (PDU) used for packing and unpacking network bytes Download PDF

Info

Publication number
CN101697546A
CN101697546A CN200910233479A CN200910233479A CN101697546A CN 101697546 A CN101697546 A CN 101697546A CN 200910233479 A CN200910233479 A CN 200910233479A CN 200910233479 A CN200910233479 A CN 200910233479A CN 101697546 A CN101697546 A CN 101697546A
Authority
CN
China
Prior art keywords
field
type
protocol
fields
packing
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.)
Granted
Application number
CN200910233479A
Other languages
Chinese (zh)
Other versions
CN101697546B (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.)
Whale Cloud Technology Co Ltd
Original Assignee
ZTEsoft Technology 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 ZTEsoft Technology Co Ltd filed Critical ZTEsoft Technology Co Ltd
Priority to CN200910233479A priority Critical patent/CN101697546B/en
Publication of CN101697546A publication Critical patent/CN101697546A/en
Application granted granted Critical
Publication of CN101697546B publication Critical patent/CN101697546B/en
Expired - Fee Related legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Data Exchanges In Wide-Area Networks (AREA)

Abstract

The invention discloses a method for implementing a protocol data unit (PDU) used for packing and unpacking network bytes, which comprises the following steps: firstly, defining an XML field configuration file of a needed transmission protocol; and then performing packing and unpacking, wherein the XML field configuration file comprises order, length and data type of fields in the transmission protocol. The method solves the problems of complex programming model and inconvenient protocol field change in the conventional network programming, improves the efficiency of network byte stream programming, facilitates packing and unpacking the network bytes, shields the difference of high-low bytes, and provides good debugging information and unified traffic monitoring.

Description

The protocol Data Unit PDU implementation method that is used for the network bytes packing and unpacks
Technical field
The present invention relates to telecom business support system, the especially packing of the real-time Socket message of Online Charging System, separate packet technology, specifically a kind of protocol Data Unit PDU implementation method that is used for the network bytes packing and unpacks.
Background technology
The Modern Telecommunication business support system generally all is made up of a plurality of network element nodes, finish functions such as charging, comprehensive customer service, Short Message Service Gateway, voice gateways, the control that continues respectively, in order to provide telecommunication service to the end user, need mutual communication between each network element, finish functions such as data sync, business continuing control, in such complicated distributed system, ubiquitous based on the network service demand of TCP/IP.
Traditional network bytes is packed and unpacked needs to pay close attention to various java data type conversion constantly the details that is binary data, and the position that need note current packing, parsing field when programming.This programming mode has proposed higher requirement to programmer's ability, and as easy as rolling off a log makeing mistakes.Traditional network bytes packaging technique also has a problem that autgmentability is bad, and that is exactly when increasing new procotol, the code that need write packing again and unpack.Therefore, this packing and the method that unpacks are too loaded down with trivial details, and in the programming model complexity, protocol fields needs to use inconvenience under the situation of often change, can not satisfy simple, the easily requirement of expansion.
Summary of the invention
The objective of the invention is at the packing of existing network bytes and the method complexity that unpacks, in the programming model complexity, protocol fields needs under the situation of often change, use inconvenience, can not satisfy the problem that simple, easy expansion requires, propose a kind of protocol Data Unit PDU implementation method that is used for the network bytes packing and unpacks that solves the complex network programming.
Technical scheme of the present invention is:
A kind of protocol Data Unit PDU implementation method that is used for the network bytes packing and unpacks, it may further comprise the steps:
(a). define the expandable mark language XML field configuration file of required host-host protocol, comprise order, length and the data type of field in the host-host protocol;
(b). packing: read the field configuration file of this agreement, obtain the data type and the data length of each field, the java fundamental type numerical value of this each field of agreement is set then, read all fields of this agreement successively:
If this field is the java fundamental type, the java fundamental type numerical value of this field is converted to byte data; If this field is a son bag type, read all fields of son bag, be packaged into byte data successively; Travel through all fields of this agreement, obtain final byte arrays;
(c). unpack: the byte arrays that acquisition need unpack, according to the protocol fields configuration file that reads in advance, obtain the data length of an only field:
If the java basic data type that this field is is converted to predefined java basic data type with byte data; If the type of this field is a son bag type, resolve all fields of this child bag successively, obtain the java basic data type; Travel through all fields of this agreement, resolve successively and obtain the java basic data type.
Beneficial effect of the present invention:
The invention solves the programming model complexity that exists in the legacy network programming, the problem of protocol fields change inconvenience provides the packing of a kind of network bytes stream simple, easily expansion, unpacking method.
The present invention improves the efficient of network bytes stream programming, make the network bytes packing, unpack and become simple; Shielded the difference of high low byte, good Debugging message is provided and unified traffic monitoring is provided.
Description of drawings
Fig. 1 concerns schematic diagram in each object in the PDU implementation method of the present invention.
Embodiment
The present invention is further illustrated below in conjunction with drawings and Examples.
Define order, length, the data type of field in the agreement by the XML configuration file.The complexity read-write of shielding original data type is automatically converted to intelligible basic data type with it, realizes that high low byte preface arbitrarily changes, and can adapt to protocol configuration flexibly.
Shown in figure one, the relation in each object in the PDU implementation method has been described, relevant noun is described as follows:
Protocol object (Protocol): abstract by the byte stream that one or more PDU objects are formed, can represent a complete agreement, such as the MML agreement, the SMPP agreement
Son bag (PduBean): for the distincter protocol object of organizing, perhaps reuse protocol definition, can use the form of son bag to organize protocol fields
Protocol fields object (PduField): not subdivisible PDU object, the Field Definition of an atom of expression
PDU: interface definition, protocol object, Zi Bao, protocol fields all realize the IPdu interface, can realize self-contained between such object like this, can think a kind of realization of component pattern.
During concrete enforcement:
Definition, the exploitation how the example explanation is used the network packing, separated packet technology realization agreement that be embodied as with a MML agreement.
One, as shown in the table as the byte that requires in the agreement:
The message opening flag Verification and Operation information The affairs head Can the thread of a conversation Message header Message-length The message opening flag
The message sending order
Two, definition protocol configuration file is as follows:
<?xml?version=″1.0″encoding=″UTF-8″?>
<zsmart>
<protocol>
<bufferDefine?name=″MML″>
<!--defining main message body--〉
<buffer?id=″MML_REQ″seq=″1″fieldname=″MsgBeginFlag″type=″5″
Length=" 4 " defaultValue=" ' SC " ' comments=" message opening flag "/〉
<buffer?id=″MML_REQ″seq=″2″fieldname=″TotalLen″type=″5″
Length=" 4 " defaultValue=" 0000 " comments=" total length field "/〉
<buffer?id=″MML_REQ″seq=″3″fieldname=″msgHeader″type=″0″
Length=" 4 " defaultValue=" " comments=" message header, son bag "/〉
<buffer?id=″MML_REQ″seq=″4″fieldname=″MML_SessionHeader″
Type=" 0 " length=" 4 " defaultValue=" ' SC " ' comments=" the meeting thread of a conversation, son bag "/〉
<buffer?id=″MML_REQ″seq=″5″fieldname=″MML_transHeader″
Type=" 0 " length=" 4 " defaultValue=" ' SC " ' comments=" affairs head, son bag "/〉
<buffer?id=″MML_REQ″seq=″6″fieldname=″MML_CMD″type=″5″
Length=" 0 " defaultValue=" " comments=" MML instruction "/〉
<buffer?id=″MML_REQ″seq=″7″fieldname=″CheckSum″type=″5″
Length=" 8 " defaultValue=" 9B94EDA4 " comments=" verification and "/〉
<!--definition message chieftain bag--〉
<buffer?id=″msgHeader″seq=″1″fieldname=″version″type=″5″
Length=" 4 " defaultValue=" 1.00 " comments=" version number "/〉
<buffer?id=″msgHeader″seq=″2″fieldname=″endFlag″type=″5″
Length=" 8 " defaultValue=" JS123456 " comments=" end mark "/〉
<buffer?id=″msgHeader″seq=″3″fieldname=″serviceName″type=″5″
Length=" 8 " defaultValue=" PPS " comments=" Service name "/〉
<!--definition session chieftain bag--〉
<buffer?id=″MML_SessionHeader″seq=″1″fieldname=″session_id″
Type=" 5 " length=" 8 " defaultValue=" 00000000 " comments=" session id "/〉
<buffer id=″MML_SessionHeader″ seq=″2″
fieldname=″session_control_word″type=″5″length=″6″defaultValue=″DlgCon″
Comments=" session control word "/〉
<buffer?id=″MML_SessionHeader″seq=″3″fieldname=″session_reserved″
Type=" 5 " length=" 4 " defaultValue=" FFFF " comments=" session reserved word "/〉
<!--definition affairs chieftain bag--〉
<buffer?id=″MML_transHeader″seq=″1″fieldname=″trans_id″type=″5″
Length=" 8 " defaultValue=" 00000001 " comments=" affairs ID "/〉
<buffer?id=″MML_transHeader″seq=″2″fieldname=″trans_control_word″
Type=" 5 " length=" 6 " defaultValue=" TxBeg " comments=" affairs control word "/〉
<buffer?id=″MML_transHeader″seq=″3″fieldname=″trans_reserved″
Type=" 5 " length=" 4 " defaultValue=" FFFF " comments=" affairs reserved word "/〉
<!--definition heartbeat message--〉
<buffer?id=″MML_HEART″seq=″1″fieldname=″MsgBeginFlag″
Type=" 5 " length=" 4 " defaultValue=" ' SC " ' comments=" message opening flag "/〉
<buffer?id=″MML_HEART″seq=″2″fieldname=″TotalLen″type=″5″
Length=" 4 " defaultValue=" 0004 " comments=" total length field "/〉
<buffer?id=″MML_HEART″seq=″3″fieldname=″msgBody″type=″5″
Length=" 4 " defaultValue=" HBHB " comments=" total length field "/〉
<buffer?id=″MML_HEART″seq=″4″fieldname=″CheckSum″type=″5″
Length=" 8 " defaultValue=" 00000000 " comments=" verification and "/〉
</bufferDefine>
</protocol>
</zsmart>
Profile Description:
1, bufferDesine: define a procotol bag
2, buffer: define a single protocol fields
3, Id: define this field and belong to that son bag
4, Seq: the serial number in the child bag (in a son bag, sequence number can not repeat)
5, Fieldname: field name, in a son bag, field name can not repeat
Type: corresponding java data type 1:Byte 2:Short 3:Int 4:Long 5:String (variable length) 6:byte[] array 7:CString, with the character string of NULL end
7, length: field length, if the character string of variable length is made as 0 with length, if field type is Byte, Short, Int, Long can use the default-length of java
8, defaultValue: default value, can the field default value be set by this field, if do not give this field settings, will use predefined default value during packing.
Owing to specified the length and the order of each field when protocol definition, all PDU can be according to finishing automatic packing in proper order and unpacking.
Three, in program, quote protocol object, finish protocol packing, unpack.
Packing process is as follows:
Read configuration file, obtain data type, the data length of a field; The java fundamental type numerical value of each field is set; Java fundamental type numerical value with each field is converted to byte data successively; If this field is a son bag type, obtain all fields that change the son bag, be packaged into byte data successively.Travel through all fields, obtain final byte arrays.
It is as follows to separate packet procedures:
The byte arrays that acquisition need unpack according to the protocol fields configuration of reading in advance, obtains the data length of an only field, and byte data is converted to predefined java basic data type; Similarly,, resolve all fields of this child bag successively, obtain the java basic data type if the type of this field is a son bag field.Travel through all fields, resolve successively and obtain the java basic data type.
Four, the PDU interface programming for example
The simple protocol packing
// acquisition MML heartbeat protocol definition
Protocol?mmlReq=ProtocolTools.getProtocol(″MML.MML_HEART″,1);
// the msgBody field value is set, its residual value uses the default configuration of configuration file
mmlReq.getPduField(″msgBody″).setValue(″HBHB″);
// packetizes messages
byte[]heartBytes=mmlReq.pack();
logger.info(″MML Heart ″+heartBytes.length+″Bytes
″+PubFunc.hexToString(heartBytes));
// print protocol bag details
logger.info(mmlReq);
Top code has been demonstrated the process of using the PDU programming model to pack, can see, and utilizes PDU programming model framework, can realize protocol packing very easily.Promote the efficient of programming.
Execution result
-MML?Heart?16Bytes?27?53?43?27?30?30?30?30?48?42?48?42?31?32?32?32
-mmlHeart:
,[MsgBeginFlag,S,′SC′,,len=4,Hex?=27 53 43
27 ],[TotalLen,S,0000,,len=4,Hex=30 30 30
30 ],[msgBody,S,HBHB,,len=4,Hex=48 42 48
42],[CheckSum,S,1222,,len=4,Hex=31?32?32?32]
Top output result has shown title, length, corresponding java value, 16 hex value of each protocol fields, contrasts 16 binary information of whole bag, can obtain needed Debugging message very easily.
The part that the present invention does not relate to prior art that maybe can adopt all same as the prior art is realized.

Claims (1)

1. one kind is used for the protocol Data Unit PDU implementation method that network bytes is packed and unpacked, and it is characterized in that it may further comprise the steps:
(a). define the expandable mark language XML field configuration file of required host-host protocol, comprise order, length and the data type of field in the host-host protocol;
(b). packing: read the field configuration file of this agreement, obtain the data type and the data length of each field, the java fundamental type numerical value of this each field of agreement is set then, read all fields of this agreement successively:
If this field is the java fundamental type, the java fundamental type numerical value of this field is converted to byte data; If this field is a son bag type, read all fields of son bag, be packaged into byte data successively; Travel through all fields of this agreement, obtain final byte arrays;
(c). unpack: the byte arrays that acquisition need unpack, according to the protocol fields configuration file that reads in advance, obtain the data length of an only field:
If the java basic data type that this field is is converted to predefined java basic data type with byte data; If the type of this field is a son bag type, resolve all fields of this child bag successively, obtain the java basic data type; Travel through all fields of this agreement, resolve successively and obtain the java basic data type.
CN200910233479A 2009-10-30 2009-10-30 Method for implementing protocol data unit (PDU) used for packing and unpacking network bytes Expired - Fee Related CN101697546B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN200910233479A CN101697546B (en) 2009-10-30 2009-10-30 Method for implementing protocol data unit (PDU) used for packing and unpacking network bytes

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN200910233479A CN101697546B (en) 2009-10-30 2009-10-30 Method for implementing protocol data unit (PDU) used for packing and unpacking network bytes

Publications (2)

Publication Number Publication Date
CN101697546A true CN101697546A (en) 2010-04-21
CN101697546B CN101697546B (en) 2012-10-03

Family

ID=42142620

Family Applications (1)

Application Number Title Priority Date Filing Date
CN200910233479A Expired - Fee Related CN101697546B (en) 2009-10-30 2009-10-30 Method for implementing protocol data unit (PDU) used for packing and unpacking network bytes

Country Status (1)

Country Link
CN (1) CN101697546B (en)

Cited By (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101944025A (en) * 2010-09-16 2011-01-12 福建鑫诺通讯技术有限公司 Automatic TCP/UDP (Transmission Control Protocol/User Datagram Protocol) data packing and unpacking method based on PYTHON language
CN102571775A (en) * 2011-12-27 2012-07-11 长春希达电子技术有限公司 Server communication module, client communication module and network communication system
CN102611530A (en) * 2012-03-08 2012-07-25 北京神州数码思特奇信息技术股份有限公司 Telecommunication data encoding method and telecommunication data decoding method
CN104426992A (en) * 2013-09-10 2015-03-18 中国科学院沈阳自动化研究所 Information transmission method based on material transmission system
CN106528823A (en) * 2016-11-18 2017-03-22 中国银行股份有限公司 Message configuration and output method and device
CN104426992B (en) * 2013-09-10 2019-07-16 中国科学院沈阳自动化研究所 A kind of information transferring method based on material transmission system
CN111641638A (en) * 2020-05-28 2020-09-08 浪潮(北京)电子信息产业有限公司 Data transmission method and related device

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101370165A (en) * 2007-08-17 2009-02-18 中兴通讯股份有限公司 Data packet transmission method for multimedia broadcasting service
CN101388900B (en) * 2007-09-12 2014-05-28 电信科学技术研究院 Processing method, apparatus and system for protocol data unit filling

Cited By (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101944025A (en) * 2010-09-16 2011-01-12 福建鑫诺通讯技术有限公司 Automatic TCP/UDP (Transmission Control Protocol/User Datagram Protocol) data packing and unpacking method based on PYTHON language
CN102571775A (en) * 2011-12-27 2012-07-11 长春希达电子技术有限公司 Server communication module, client communication module and network communication system
CN102611530A (en) * 2012-03-08 2012-07-25 北京神州数码思特奇信息技术股份有限公司 Telecommunication data encoding method and telecommunication data decoding method
CN104426992A (en) * 2013-09-10 2015-03-18 中国科学院沈阳自动化研究所 Information transmission method based on material transmission system
CN104426992B (en) * 2013-09-10 2019-07-16 中国科学院沈阳自动化研究所 A kind of information transferring method based on material transmission system
CN106528823A (en) * 2016-11-18 2017-03-22 中国银行股份有限公司 Message configuration and output method and device
CN106528823B (en) * 2016-11-18 2019-08-30 中国银行股份有限公司 A kind of configuration of message and output method and device
CN111641638A (en) * 2020-05-28 2020-09-08 浪潮(北京)电子信息产业有限公司 Data transmission method and related device

Also Published As

Publication number Publication date
CN101697546B (en) 2012-10-03

Similar Documents

Publication Publication Date Title
CN101697546B (en) Method for implementing protocol data unit (PDU) used for packing and unpacking network bytes
JP2018517371A (en) Data processing method, communication device, and communication system
CN106254381A (en) Protocol analysis method, device and comprise the Layer2 switching system of protocol analysis device
WO2017012453A1 (en) Method and device for data transmission
US20200112383A1 (en) Method and apparatus for sending and receiving multiframe, and storage medium
CN107483592A (en) A kind of transaction processing method based on General Front End Processor and a kind of General Front End Processor
WO2020199422A1 (en) Flexible ethernet link management method and system
CN101882975B (en) Method for transmitting data by using preamble of Ethernet frame
WO2019128462A1 (en) Data transmission method, sending apparatus and receiving apparatus
CN102438017A (en) Routing function-based conversion apparatus of Modbus protocol and BACnet Ethernet protocol and conversion method thereof
JP2017054411A (en) API conversion adapter, API conversion system, and API conversion program
CN112463706B (en) Data transmitting and receiving method and communication terminal
CN105471726B (en) The method and apparatus of retransmitting paramater transmitting
CN103731345A (en) Network message processing method and equipment
CN101771617B (en) Method and system for following point-to-point bandwidth, remote terminal equipment and home terminal equipment
CN101355601B (en) Network official telephone for digital microwave system and implementing method thereof
WO2022134697A1 (en) Interface data interaction method, distributed unit, and central unit
CN112491569B (en) Equipment management method, device, equipment and computer readable storage medium
WO2017084515A1 (en) Method and device for transmitting data code stream
CN101741757B (en) Message sending method and communication equipment
CN107342920A (en) Things-internet gateway access device and its data interactive method
CN1972314B (en) Serial interface simulation method on Ethernet interface and component applying the same
CN106993263A (en) Method, the system of equipment automatic numbering in bluetooth mesh networks
CN103338229B (en) The exchange method of remote terminal unit and data transmission unit and system
CN105227544A (en) Realize the device and method of different agreement message conversion

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
C56 Change in the name or address of the patentee
CP01 Change in the name or title of a patent holder

Address after: Yuhuatai District of Nanjing City, Jiangsu province 210012 Bauhinia Road No. 68

Patentee after: ZTESOFT TECHNOLOGY Co.,Ltd.

Address before: Yuhuatai District of Nanjing City, Jiangsu province 210012 Bauhinia Road No. 68

Patentee before: NANJING ZTESOFT TECHNOLOGY Co.,Ltd.

CP03 Change of name, title or address

Address after: 210012 room 627, Ning Shuang Road, Yuhuatai District, Nanjing, Jiangsu, 627

Patentee after: WHALE CLOUD TECHNOLOGY Co.,Ltd.

Address before: 210012 No. 68 Bauhinia Road, Yuhuatai District, Jiangsu, Nanjing

Patentee before: ZTESOFT TECHNOLOGY Co.,Ltd.

CP03 Change of name, title or address
CF01 Termination of patent right due to non-payment of annual fee

Granted publication date: 20121003

CF01 Termination of patent right due to non-payment of annual fee