CN107306256A - A kind of communications protocol analytic method based on character string type data - Google Patents
A kind of communications protocol analytic method based on character string type data Download PDFInfo
- Publication number
- CN107306256A CN107306256A CN201610254953.XA CN201610254953A CN107306256A CN 107306256 A CN107306256 A CN 107306256A CN 201610254953 A CN201610254953 A CN 201610254953A CN 107306256 A CN107306256 A CN 107306256A
- Authority
- CN
- China
- Prior art keywords
- protocol
- communications protocol
- information
- format
- communications
- 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
Links
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L69/00—Network arrangements, protocols or services independent of the application payload and not provided for in the other groups of this subclass
- H04L69/22—Parsing or analysis of headers
Landscapes
- Engineering & Computer Science (AREA)
- Computer Security & Cryptography (AREA)
- Computer Networks & Wireless Communication (AREA)
- Signal Processing (AREA)
- Communication Control (AREA)
Abstract
The invention discloses a kind of communications protocol analytic method based on character string type data, a communications protocol edit tool is provided first to tester's typing or imports existing communications protocol information, and preserve into the xml document of specified format, then tester is when receiving the data of measured piece, communications protocol parsing module automatically parses which kind of protocol format the packet being currently received belongs to, and the value of each interior protocol fields of the protocol format, it is easy in test process carry out test judgement and processing.The present invention can automatically be parsed, recognized and handled to transceiving data in communication process.Typical case's application such as ethernet communication, serial communication.
Description
Technical field
Patent of the present invention is related to oneself of a kind of general I/O communications protocol based on character string type
Dynamic analytic method, can automatically be parsed, recognized and be handled to transceiving data in communication process.
Typical case's application such as ethernet communication, serial communication.
Background technology
In embedded software Automated Black Box Testing, many tested softwares are communicated with outside
The communications protocol of character string type packet is all based on, and this is generally required to character string type
Packet is parsed, so as to calculate the concrete numerical value of each field inside character string;Although
For a tested software, its communications protocol is relatively fixed, can after data are received according to
The communications protocol that this tested software is provided writes decoding program in test program, if a but quilt
Survey and be related to a variety of different communications protocol in software or multiple tested softwares tested,
The analytical capabilities that communications protocol is then realized in test program are one pretty troublesome and lose time
Thing, therefore introduce a kind of work(that can be automatically parsed for different communications protocol
Can be extremely important.
Due to communication data packets, for the packet of character string type, often length is not fixed, therefore
Receive how to go out each data field fast resolving in packet according to protocol characteristic after data
The problem of to be most critical.
The content of the invention
In view of the above-mentioned deficiency that presently, there are, the present invention provides a kind of based on character string type data
Communications protocol analytic method, the problem of on the one hand solving communication data packets random length be another
Aspect also solves the problem of being parsed automatically according to communications protocol form.
To reach above-mentioned purpose, embodiments of the invention are adopted the following technical scheme that:
A kind of communications protocol analytic method based on character string type data, comprises the following steps:
Step 1, the editor of communications protocol, including step 1.1 is to 1.3:
Step 1.1 is there is provided a communications protocol edit tool to user;
Step 1.2, user is by existing communications protocol Data Enter or imports the communications protocol volume
The instrument of collecting;
Step 1.3, user is assisted the communication of typing or importing by the communications protocol edit tool
View information preserves into the xml document of specified format;
Step 2, the parsing of communications protocol, including step 2.1 is to 2.9:
Step 2.1, start;
Step 2.2, message is received from measured piece;
Step 2.3, protocol resolution module starts real-time communication protocol analysis;
Step 2.4, concentrated in common class protocol format information and carry out protocol format matching;
Step 2.5, judge whether that the match is successful, if then going to step 2.8, otherwise go to step
Rapid 2.6;
Step 2.6, matched in the protocol format under current demand signal;
Step 2.7, judge whether that the match is successful, if then going to step 2.8, otherwise go to step
Rapid 2.9;
Step 2.8, the actual content of each protocol element in communication bag is parsed automatically;
Step 2.9, terminate.
According to one aspect of the present invention, in step 1.1, the communications protocol edit tool is adopted
Developed with eclipse.
According to one aspect of the present invention, in step 1.2, the communications protocol information is described
Stored in communications protocol edit tool using chained list mode.
According to one aspect of the present invention, in step 1.2, the composition of the communications protocol information
Including communications protocol form base class, protocol element info class, protocol element position info class, agreement
Element length information, protocol element data content information, protocol format info class, communications protocol
Info class.
According to one aspect of the present invention, in step 2.4, the common class protocol format information
Collection definition is all general communications protocol forms between different systems under test (SUT) or module.
The advantage that the present invention is implemented:
For other similar approach, the present invention is in embedded software Automated Black Box Testing neck
Domain has stronger versatility, reusability and ease for use, no matter communication two party uses TCP or UDP
Or serial ports or other manner are communicated, as long as the packet based on character string type, this hair
It is bright that fast automatic parsing can be carried out to it.
Brief description of the drawings
Technical scheme in order to illustrate the embodiments of the present invention more clearly, below will be to embodiment
In required for the accompanying drawing that uses be briefly described, it should be apparent that, drawings in the following description
Only some embodiments of the present invention, for those of ordinary skill in the art, are not paying
On the premise of going out creative work, other accompanying drawings can also be obtained according to these accompanying drawings.
Fig. 1 is the schematic diagram that communications protocol is parsed.
Fig. 2 is communications protocol editing interface figure.
Fig. 3 is the main composition class of communications protocol format information.
Fig. 4 is the composition of communications protocol base class information.
Fig. 5 is the composition of protocol element information category information.
Fig. 6 is the composition of protocol element position information category information.
Fig. 7 is the composition of protocol format information category information.
Fig. 8 is the composition of communications protocol information category information.
Fig. 9 is the analytical algorithm flow chart of communications protocol.
Embodiment
Below in conjunction with the accompanying drawing in the embodiment of the present invention, to the technical side in the embodiment of the present invention
Case is clearly and completely described, it is clear that described embodiment is only the present invention one
Divide embodiment, rather than whole embodiments.Based on the embodiment in the present invention, this area is general
The every other embodiment that logical technical staff is obtained under the premise of creative work is not made,
Belong to the scope of protection of the invention.
As shown in figure 1, the principle of the present invention is:One communications protocol edit tool is provided first
To tester's typing or the existing communications protocol information of importing, the communications protocol of typing or importing
Information can preserve into the xml document of specified format automatically by communications protocol edit tool, so
Tester, when receiving the data of measured piece, calls logical when carrying out automatic test afterwards
Protocol resolution module is interrogated, communications protocol parsing module can automatically parse the number being currently received
Belong to the value of each protocol fields in which kind of protocol format, and the protocol format according to bag, so
It is easy in test process carry out test judgement and processing.
The present invention is made up of two submodules, specific as follows:
First, communications protocol edit tool:There is provided friendly man machine operation interface will communicate for user
Agreement imports.
Communications protocol edit tool is developed using eclipse, and user can set or import herein logical
Protocol format is interrogated, one embodiment of editing interface is as shown in Figure 2.
User can edit the form of communications protocol in similar editing interface, then will be logical
News protocol information preserve into can cross-platform parsing xml formatted files, facilitate protocol resolution module
Parsed.
2nd, communications protocol parsing module:In communication process, communication can be automatically parsed
The concrete numerical value of each field in bag;In view of in actual use, to the packet received
Parsing is often required that provides response in a short period of time, and this requires to parse communication data packets
Time is more short better, therefore selection standard C Plus Plus realizes the analytical capabilities of communications protocol.
In communication process, software is received calls analytical function to be parsed automatically after data, in order to
Ensure resolution speed, user adopts in the communications protocol particular content that communications protocol editing interface is set
Stored with chained list mode, load all contents of this communications protocol before parsing first into internal memory,
During parsing, progress one by one is matched, have encounter one it is unmatched, directly jump out matching
It is next, untill matching successfully, after matching terminates, while returning to what the match is successful
The occurrence of each field.
The main composition of communications protocol form and the C++ class design method of each part are as follows:
The main composition of communications protocol information as shown in figure 3, including communications protocol form base class,
Protocol element info class, protocol element position info class, protocol element length information, protocol element
Data content information, protocol format info class, communications protocol info class,.
Arrow in Fig. 3 is a kind of method for expressing inherited between C++ class, in the present embodiment table
Show that " protocol element info class " is inherited from " communications protocol base class ";" agreement list
First position info class " is also to inherit from " communications protocol base class ".There is no this arrow table
There is no this inheritance between bright class.
Protocol element length information, protocol element data content information describe protocol element respectively
Length information and data content information.
1st, the design of communications protocol base class is as shown in Figure 4.
Communications protocol form base class CProtocolUnit_Base
Attribute:
E_ProtocolUnit_Type m_eProtocolUnit_Type;// protocol element class
Type (byte/data bit)
char m_szName[MAX_NAME_LENGTH];// protocol element title
char m_szDesc[MAX_STRING_LEN];// protocol element is described
unsigned long m_ulUniqueID;// protocol element unique ID value
bool m_bReserved;// whether it is reserved word
bool m_bReserved_AutoZero;Whether // reserved word fills out 0 automatically
CProtocolUnit_Value*m_pValue;// data content information
Method:
Nothing
2nd, the design of protocol element info class is as shown in Figure 5.
Protocol element info class CProtocolUnit
Attribute:
bool m_bBitStruct;// whether it is bit field structure
bool m_bCanDivision;// whether can also resolve into sub-protocol unit letter
Breath collection
bool m_bLittleEndian;// whether low sequence byte is stored in initial address
bool m_bExpand;// whether deploy display
bool m_bArray;// whether it is array
list<CProtocolUnit*>m_Protocol_Child;// sub-protocol list
Metamessage collection, it is effective during m_bCanDivision=true
CLenBase_ProtocolUnit*m_pProtocolUnit_Len;// length information
list<CProtocolUnit_Bit*>m_Protocol_Child_Bits;// bit field knot
Structure body information is effective during m_bBitStruct=true
Method:
bool If_Matched();During // automatic analysis protocol information, this function is called to judge
Whether agreement length and content information with it is actual consistent
3rd, the design of protocol element position info class is as shown in Figure 6.
Protocol element position info class CProtocolUnit_Bit
Attribute:
unsigned short m_usStartBit;// start bit
unsigned short m_usBitnum;// data bits
Main method:
bool If_Matched();During // automatic analysis protocol information, this function is called to judge
Whether agreement length and content information with it is actual consistent
4th, the design of protocol format info class is as shown in Figure 7.
Protocol format info class CProtocolForm
Attribute:
E_ProtocolType m_eProtocolType;// protocol format class
Type (common class/certain kinds)
char m_szProtocolName[MAX_NAME_LENGTH];// protocol format title
list<CProtocolUnit*>m_ProtocolInfo;Under // the protocol format
Specific protocol information, store in a recursive manner
Main method:
During // automatic analysis protocol information, this function is called to judge whether the length and content of agreement
Information is consistent with reality
// function performance:Judge the data content information of protocol element specified whether with it is actual
Unanimously, the match is successful if consistent
Bool Match_ProtocolUnit (unsigned long ulLen, // association
Discuss bag content-length value
Unsigned char*pValue, // protocol packet data content information
Unsigned long ulStartPos, the content of // specified protocol unit is entirely being wrapped
Original position in content (byte is unit)
The CProtocolUnit*pProtocolUnit, // protocol element specified
unsigned long&ulProtocolUnitLen);The length value of // protocol element
5th, the design of communications protocol info class is as shown in Figure 8.
Communications protocol info class CProtocolInfo
Attribute:
vector<CProtocolForm*>m_CommRecvProtocol;// public
Class protocol format information collection
map<char*,CProtocolParent*>m_RecvProtocol;// specific
Class protocol format information collection
CProtocolForm*m_pProtocolForm_Matched;// matching
Successful protocol format information
Main method:
During // automatic analysis protocol information, this function is called to judge whether the length and content of agreement
Information is consistent with reality
// function performance:The protocol format information specified is matched, and is calculated in the protocol format
The data content information of all protocol elements
void Matching_ProtocolUnit(unsigned long ulLen,unsigned
char*pValue);
The automatic analytical algorithm of communications protocol is as shown in Figure 9:In test execution, test system
Receive after the message that measured piece is sended over, carry out agreement in reception class protocol format automatically
Matching and parsing, after successfully resolved in automatically derived protocol format all protocol elements data
Content, is easy to follow-up test processes.
It is " public in the attribute in " common class protocol format information collection " corresponding diagram 8 in Fig. 7
Common class protocol format information collection ", refers to all identicals between different systems under test (SUT) or module
Protocol format, is just all included into common class protocol format information concentration, is so carrying out agreement solution
During analysis, matching parsing is carried out in " common class protocol format information collection " first, is conducive to fast
Fast parses actual protocol format and its data content.
When designing communications protocol, by some, general (it is identical that multiple signals are used as far as possible
Communications protocol form) communications protocol be defined on common class protocol format information concentration, be easy to improve
Protocol analysis speed.
The foregoing is only a specific embodiment of the invention, but protection scope of the present invention is simultaneously
This is not limited to, any those skilled in the art is in technology model disclosed by the invention
In enclosing, the change or replacement that can be readily occurred in should be all included within the scope of the present invention.
Therefore, protection scope of the present invention should be based on the protection scope of the described claims.
Claims (5)
1. a kind of communications protocol analytic method based on character string type data, it is characterised in that
Comprise the following steps:
Step 1, the editor of communications protocol, including step 1.1 is to 1.3:
Step 1.1 is there is provided a communications protocol edit tool to user;
Step 1.2, user is by existing communications protocol Data Enter or imports the communications protocol volume
The instrument of collecting;
Step 1.3, user is assisted the communication of typing or importing by the communications protocol edit tool
View information preserves into the xml document of specified format;
Step 2, the parsing of communications protocol, including step 2.1 is to 2.9:
Step 2.1, start;
Step 2.2, message is received from measured piece;
Step 2.3, protocol resolution module starts real-time communication protocol analysis;
Step 2.4, concentrated in common class protocol format information and carry out protocol format matching;
Step 2.5, judge whether that the match is successful, if then going to step 2.8, otherwise go to step
Rapid 2.6;
Step 2.6, matched in the protocol format under current demand signal;
Step 2.7, judge whether that the match is successful, if then going to step 2.8, otherwise go to step
Rapid 2.9;
Step 2.8, the actual content of each protocol element in communication bag is parsed automatically;
Step 2.9, terminate.
2. the communications protocol parsing side according to claim 1 based on character string type data
Method, it is characterised in that in step 1.1, the communications protocol edit tool uses eclipse
Exploitation.
3. the communications protocol parsing side according to claim 1 based on character string type data
Method, it is characterised in that in step 1.2, the communications protocol information is compiled in the communications protocol
Stored in the instrument of collecting using chained list mode.
4. the communications protocol parsing side according to claim 1 based on character string type data
Method, it is characterised in that in step 1.2, the composition of the communications protocol information includes communication and assisted
Discuss form base class, protocol element info class, protocol element position info class, protocol element length letter
Breath, protocol element data content information, protocol format info class, communications protocol info class.
5. the communications protocol parsing side according to claim 1 based on character string type data
Method, it is characterised in that in step 2.4, what the common class protocol format information collection was defined is
All general communications protocol forms between different systems under test (SUT) or module.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201610254953.XA CN107306256B (en) | 2016-04-22 | 2016-04-22 | Communication protocol analysis method based on character string type data |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201610254953.XA CN107306256B (en) | 2016-04-22 | 2016-04-22 | Communication protocol analysis method based on character string type data |
Publications (2)
Publication Number | Publication Date |
---|---|
CN107306256A true CN107306256A (en) | 2017-10-31 |
CN107306256B CN107306256B (en) | 2021-02-12 |
Family
ID=60152512
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201610254953.XA Active CN107306256B (en) | 2016-04-22 | 2016-04-22 | Communication protocol analysis method based on character string type data |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN107306256B (en) |
Cited By (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN109981599A (en) * | 2019-03-06 | 2019-07-05 | 南京理工大学 | A kind of the general-purpose data parsing platform and method of communication data stream |
CN110012031A (en) * | 2019-04-26 | 2019-07-12 | 中国电子科技集团公司第二十九研究所 | Data message is general to automatically parse method and storage method |
CN114928662A (en) * | 2022-04-22 | 2022-08-19 | 深圳市天陆海导航设备技术有限责任公司 | Communication method for supporting multiple interfaces by user-defined protocol |
Citations (10)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101035111A (en) * | 2007-04-13 | 2007-09-12 | 北京启明星辰信息技术有限公司 | Intelligent protocol parsing method and device |
CN101287010A (en) * | 2008-06-12 | 2008-10-15 | 华为技术有限公司 | Method and apparatus for identifying and verifying type of message protocol |
CN101834848A (en) * | 2010-03-29 | 2010-09-15 | 北京航空航天大学 | Method for describing protocol by using XML and protocol resolving system built by same |
CN102215206A (en) * | 2010-04-01 | 2011-10-12 | 上海凌屹信息科技有限公司 | Method and device for identifying network protocol based on NPTA technology |
CN104052766A (en) * | 2013-03-13 | 2014-09-17 | 北京中科联众科技股份有限公司 | Comprehensive intelligent communication method and system of heterogeneous network based on cloud calculating |
US9087179B1 (en) * | 2006-07-10 | 2015-07-21 | Kyocera Corporation | System for detecting and converting digital rights management profiles |
US20150268962A1 (en) * | 2014-03-24 | 2015-09-24 | GoofyFoot Labs | Asynchronous Circuit Design |
US20150271130A1 (en) * | 2014-03-19 | 2015-09-24 | Labtech Llc | Systems and methods for provisioning, configuring, diagnosing, and maintaining out-of-band management of computing devices |
US20160014138A1 (en) * | 2014-07-08 | 2016-01-14 | International Business Machines Corporation | Encoding ldap role and domain information in a fixed format |
US20160087887A1 (en) * | 2014-09-22 | 2016-03-24 | Hei Tao Fung | Routing fabric |
-
2016
- 2016-04-22 CN CN201610254953.XA patent/CN107306256B/en active Active
Patent Citations (10)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US9087179B1 (en) * | 2006-07-10 | 2015-07-21 | Kyocera Corporation | System for detecting and converting digital rights management profiles |
CN101035111A (en) * | 2007-04-13 | 2007-09-12 | 北京启明星辰信息技术有限公司 | Intelligent protocol parsing method and device |
CN101287010A (en) * | 2008-06-12 | 2008-10-15 | 华为技术有限公司 | Method and apparatus for identifying and verifying type of message protocol |
CN101834848A (en) * | 2010-03-29 | 2010-09-15 | 北京航空航天大学 | Method for describing protocol by using XML and protocol resolving system built by same |
CN102215206A (en) * | 2010-04-01 | 2011-10-12 | 上海凌屹信息科技有限公司 | Method and device for identifying network protocol based on NPTA technology |
CN104052766A (en) * | 2013-03-13 | 2014-09-17 | 北京中科联众科技股份有限公司 | Comprehensive intelligent communication method and system of heterogeneous network based on cloud calculating |
US20150271130A1 (en) * | 2014-03-19 | 2015-09-24 | Labtech Llc | Systems and methods for provisioning, configuring, diagnosing, and maintaining out-of-band management of computing devices |
US20150268962A1 (en) * | 2014-03-24 | 2015-09-24 | GoofyFoot Labs | Asynchronous Circuit Design |
US20160014138A1 (en) * | 2014-07-08 | 2016-01-14 | International Business Machines Corporation | Encoding ldap role and domain information in a fixed format |
US20160087887A1 (en) * | 2014-09-22 | 2016-03-24 | Hei Tao Fung | Routing fabric |
Cited By (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN109981599A (en) * | 2019-03-06 | 2019-07-05 | 南京理工大学 | A kind of the general-purpose data parsing platform and method of communication data stream |
CN110012031A (en) * | 2019-04-26 | 2019-07-12 | 中国电子科技集团公司第二十九研究所 | Data message is general to automatically parse method and storage method |
CN114928662A (en) * | 2022-04-22 | 2022-08-19 | 深圳市天陆海导航设备技术有限责任公司 | Communication method for supporting multiple interfaces by user-defined protocol |
CN114928662B (en) * | 2022-04-22 | 2023-09-29 | 深圳市天陆海导航设备技术有限责任公司 | Communication method for supporting multiple interfaces by custom protocol |
Also Published As
Publication number | Publication date |
---|---|
CN107306256B (en) | 2021-02-12 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN103001971B (en) | A kind of network packet analytic method | |
Willcock et al. | An introduction to TTCN-3 | |
US20060280178A1 (en) | Script-based parser | |
CN103312551B (en) | The method of testing of CGI(Common gateway interface) and testing apparatus | |
CN104050080B (en) | User space debugs the method and system of linux kernel | |
CN104144156B (en) | Message processing method and device | |
CN104298921B (en) | Animation source file security breaches inspection method and device | |
CN104063401B (en) | The method and apparatus that a kind of webpage pattern address merges | |
CN111191422B (en) | File format conversion method, device and computer readable storage medium | |
CN107306256A (en) | A kind of communications protocol analytic method based on character string type data | |
CN104679495B (en) | software identification method and device | |
CN111741019A (en) | Communication protocol analysis method and system based on field description | |
CN107066243A (en) | A kind of parsing of general airborne-bus interface control document and packaging method | |
CN113887173A (en) | XML-based protocol dynamic packaging and analyzing method | |
CN105046159A (en) | Modification identifier based OOX text document privacy information detection method | |
CN110266702A (en) | Wireshark protocol analysis method based on XML | |
CN106941501A (en) | A kind of data communications method and device | |
CN106295346A (en) | A kind of application leak detection method, device and the equipment of calculating | |
CN110471663A (en) | A kind of code compiling method, device and electronic equipment | |
CN103378994A (en) | Method and terminal for testing communication equipment | |
CN103542865B (en) | Investigating method and device | |
CN112235316A (en) | Data communication method for instrument integration | |
CN105429982A (en) | Method and device for analyzing communication content between client and server | |
CN106992899A (en) | A kind of network interface test device and method | |
CN110266554A (en) | A kind of test method of privately owned communication protocol |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |