CN107579871B - Method and system for generating distributed test script based on model detection - Google Patents

Method and system for generating distributed test script based on model detection Download PDF

Info

Publication number
CN107579871B
CN107579871B CN201710606329.6A CN201710606329A CN107579871B CN 107579871 B CN107579871 B CN 107579871B CN 201710606329 A CN201710606329 A CN 201710606329A CN 107579871 B CN107579871 B CN 107579871B
Authority
CN
China
Prior art keywords
message
test
parallel
parallel test
component
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.)
Active
Application number
CN201710606329.6A
Other languages
Chinese (zh)
Other versions
CN107579871A (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.)
Tsinghua University
Original Assignee
Tsinghua University
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 Tsinghua University filed Critical Tsinghua University
Priority to CN201710606329.6A priority Critical patent/CN107579871B/en
Publication of CN107579871A publication Critical patent/CN107579871A/en
Application granted granted Critical
Publication of CN107579871B publication Critical patent/CN107579871B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Data Exchanges In Wide-Area Networks (AREA)
  • Maintenance And Management Of Digital Transmission (AREA)

Abstract

The invention discloses a generation method and a generation system of a distributed test script based on model detection, wherein the generation method comprises the steps of constructing a formal model and constraint which are adaptive to the specification of a network communication protocol; exploring a state space of the formal model by using a model detection tool, and if violation of the constraint exists, generating and outputting a counter-example corresponding to the violation by using the model detection tool; analyzing the counter example to obtain a process list and a message sequence in the counter example; and generating a distributed test script according to the process list and the message sequence. The method realizes the distributed test of the network communication protocol, and is beneficial to improving the accuracy of the network communication protocol test.

Description

Method and system for generating distributed test script based on model detection
Technical Field
The invention belongs to the technical field of network protocol testing, and particularly relates to a method and a system for generating a distributed test script based on model detection.
Background
Protocol testing technology is an important means for ensuring that a network communication protocol can be correctly realized and that different network devices are correctly interconnected. The conformance test is a basic protocol testing method, which is mainly used to detect whether the implementation of the protocol is in conformity with the specification of the protocol.
Test generation based on model detection is an important issue in this field, which is mainly to discover errors existing in a protocol specification based on model detection, and generate a test set (or test script) for a test activity. In most proposed test generation technologies based on model detection, the basic idea is to establish a formal model according to a protocol specification, and use a model detection tool to search for errors existing in the model, thereby generating a corresponding test set.
In the prior art, a test generation method based on model detection only considers a centralized test architecture, that is, one-to-one testing between a test system and a system to be tested, and does not relate to a distributed test architecture, that is, many-to-one testing between a plurality of test systems and a system to be tested. The network communication protocol mostly works by using a distributed architecture in an actual network, and the distributed test architecture is more beneficial to finding out errors possibly existing in the network communication protocol, so that the method is more suitable for testing the network communication protocol.
Disclosure of Invention
One of the technical problems to be solved by the present invention is that the test generation method based on model detection in the prior art is limited to a centralized test architecture, does not support a distributed test architecture, and is not beneficial to protocol testing.
In order to solve the above technical problem, an embodiment of the present application first provides a method for generating a distributed test script based on model detection, including: constructing a formal model and constraint which are adaptive to the specification of the network communication protocol;
exploring a state space of the formal model using a model detection tool, if there is a violation of the constraint, generating and outputting a counter-example corresponding to the violation by the model detection tool;
analyzing the counter example to obtain a process list and a message sequence in the counter example;
generating a distributed test script according to the process list and the message sequence
Preferably, the formal model includes processes describing network communication entities, channels describing network links, and data structures describing network communication protocol data; the constraints include general rules and specific functions related to the network communication protocol.
Preferably, the distributed test script comprises a main test unit and a plurality of parallel test units,
the main test component is arranged on a network entity in the distributed test network and is used for defining a test environment and connecting each parallel test component;
the parallel test components are respectively arranged on a plurality of network entities in the distributed test network and used for respectively testing the tested system.
Preferably, the generating a distributed test script according to the process list and the message sequence includes:
respectively initializing each process except the process corresponding to the tested system in the process list into a parallel test component;
establishing ports between the main test component and each parallel test component to connect each parallel test component;
establishing ports among all the parallel test components so as to connect all the parallel test components with each other;
each message in the sequence of messages is traversed to determine a test script for each parallel test element.
Preferably, traversing each message in the sequence of messages to determine a test script for each parallel test element comprises:
when determining messages sent out by the same parallel test element,
adding the sending of the message directly in a test script corresponding to the parallel test component if the message is the first message in a sequence of messages or a previous message to the message was sent or received by the parallel component;
if the previous message of the message is not sent or received by the parallel test component, firstly adding the receiving of the synchronous control message in the test script corresponding to the parallel test component, and then adding the sending of the message in the test script;
after adding the sending of the message to the test script of the parallel test component, if the message is not the last message in the sequence of messages and the message is addressed to the system under test, and the next message of the message is no longer sent by the parallel test component or by the system under test, adding the sending of the synchronization control message in the test script corresponding to the parallel test component.
Preferably, traversing each message in the sequence of messages to determine a test script for each parallel test element comprises:
in determining the messages received by the same parallel test element,
adding receipt of the message directly in a test script corresponding to the parallel test component;
after adding the receipt of the message to the test script of the parallel test component, if the message is not the last message of the sequence of messages and the sender of the latter message of the message is the other parallel test component, adding the sending of the synchronization control message in the test script corresponding to the parallel test component.
Preferably, before generating the distributed test script according to the process list and the message sequence, defining the format of the interactive messages between each parallel test component and the tested system and between each parallel test component according to the specification of a network communication protocol;
instantiating the interactive message according to the format when adding a message to a test script of a parallel test component.
Preferably, when the main test component is established, the method further comprises mapping the port of the parallel test component to the system port of the network entity running the distributed test script.
The embodiment of the application also provides a generation system of the distributed test script based on the model detection, which comprises a model establishing module, a model generating module and a model generating module, wherein the model establishing module is set to establish a formal model and constraint which are adaptive to the specification of a network communication protocol;
an counterexample generation module arranged to explore a state space of the formal model using a model detection tool, if there is a violation of the constraint, to generate and output by the model detection tool an counterexample corresponding to the violation;
the extraction module is used for analyzing the counter example to acquire a process list and a message sequence in the counter example;
a script generation module configured to generate a distributed test script according to the process list and the message sequence.
Compared with the prior art, one or more embodiments in the above scheme can have the following advantages or beneficial effects:
the distributed test script with the main test component and the distributed test component is established based on the model detection tool, so that the distributed test of the network communication protocol is realized, and the accuracy of the network communication protocol test is improved.
Additional advantages, objects, and features of the invention will be set forth in part in the description which follows and in part will become apparent to those having ordinary skill in the art upon examination of the following or may be learned from practice of the invention. The objectives and other advantages of the invention will be realized and attained by the structure particularly pointed out in the written description and claims hereof as well as the appended drawings.
Drawings
The accompanying drawings are included to provide a further understanding of the technology or prior art of the present application and are incorporated in and constitute a part of this specification. The drawings expressing the embodiments of the present application are used for explaining the technical solutions of the present application, and should not be construed as limiting the technical solutions of the present application.
FIG. 1 is a flowchart illustrating a method for generating a distributed test script based on model detection according to an embodiment of the present invention;
FIG. 2 is a schematic diagram of generation of a test script for a concurrent test component according to one embodiment of the invention;
fig. 3 is a schematic structural diagram of a system for generating a distributed test script based on model detection according to another embodiment of the present invention.
Detailed Description
The following detailed description of the embodiments of the present invention will be provided with reference to the accompanying drawings and examples, so that how to apply the technical means to solve the technical problems and achieve the corresponding technical effects can be fully understood and implemented. The embodiments and the features of the embodiments can be combined without conflict, and the technical solutions formed are all within the scope of the present invention.
Fig. 1 is a flowchart illustrating a method for generating a distributed test script based on model detection according to an embodiment of the present invention, where as shown in the figure, the method includes:
step S110, a formal model and a constraint which are suitable for the specification of the network communication protocol are constructed.
Step S120, searching the state space of the formalized model by using the model detection tool, if the constraint is violated, generating and outputting a counterexample corresponding to the violation by using the model detection tool.
Step S130, the counterexample is analyzed to obtain a process list and a message sequence in the counterexample.
And step S140, generating a distributed test script according to the process list and the message sequence.
Specifically, in step S110, the formal model established for the network communication protocol generally includes a process describing the network communication entity, a channel describing the network link, and a data structure describing the network communication protocol data. And constraints generally include some general rules to which the network communication protocol should adhere, as well as the specific functionality of the network communication protocol. By way of example, a general rule may include reachability of a network, etc., and a particular function may include restricted access to certain network entities, as well as some special requirements regarding security features, etc.
In addition, the concrete method and modeling language adopted in the embodiment of the invention are not limited, and the modeling method in the prior art can be selected according to actual conditions.
Next, in step S120, the model detection tool is an automated software tool that automatically verifies whether the formal model satisfies the constraint based on the model detection theory. The model detection tool can be used to explore the state space of the formalized model. The opposite example is that the model detection tool finds the output of the formal model after violation of the constraints, which typically includes a process list, a channel list, and corresponding states and message sequences of the formal model.
Establishing a formal model and a constraint, and generating and outputting a corresponding counter-example by using a model detection tool all belong to the prior art, and are not described herein again.
In step S130, the counter example output by the model detection tool is analyzed to obtain a process list and a message sequence in the counter example. The process in the counterexample is one entity with independent functionality, capable of independent activity. The process list records all processes in the counterexample. In an embodiment of the invention, a distributed test script is formed by creating a corresponding parallel test component for each process in the counter example.
The distributed test script generated in the embodiment of the invention comprises a main test component and a plurality of parallel test components, wherein the main test component can be arranged on a network entity in the distributed test network and used for defining the test environment and connecting the parallel test components. Different parallel test components can be arranged on the same network entity, or each parallel test component can be arranged on a plurality of network entities in the distributed test network respectively, and the parallel test components are used for testing the tested system respectively.
In step S140, each process except the process corresponding to the system under test in the process list is initialized to a parallel test unit. That is, in the main test component, for each process in the process list except for the process corresponding to the system under test, the creation of the corresponding parallel test component is added.
Then, a port is established between the main test unit and each parallel test unit to connect each parallel test unit. And simultaneously establishing ports among all the parallel test components so as to connect all the parallel test components with each other. That is, in the main test unit and each parallel test unit, ports for connecting other test units are respectively established.
And then traversing each message in the message sequence, judging according to the position of the message in the message sequence and a sender and a receiver of the message, and finally determining the test script of each parallel test component.
The following describes the generation process of the parallel test unit test script by taking a specific parallel test unit as an example with reference to fig. 2.
As shown in fig. 2, traversing each message in the message sequence, for the message sent by the parallel test unit, first determining whether the message is the first message in the message sequence, as shown in step S210. If the message is the first message in the sequence of messages, the sending of the message is added directly to the test script of the parallel test element, as shown in step S213.
If the message is not the first message in the sequence of messages, a determination is made as to whether the message immediately preceding the message was sent or received by the parallel test block, as shown in step S211. If the message preceding the message was sent or received by the parallel test unit, the sending of the message is added directly to the test script of the parallel test unit (step S213). If the message immediately preceding the message was not sent or received by the parallel test unit, the receiving of the synchronization control message added to the test script of the parallel test unit is performed first, as shown in step S212, and the sending of the message is added to the test script of the parallel test unit (step S213).
After the transmission of the message is added to the test script of the parallel test unit, it is determined whether the message is the last message in the message sequence, as shown in step S214. If the message is not the last message in the message sequence, it is determined whether the message is addressed to the system under test, as shown in step S215. And if the message is not sent to the system to be tested, the next message in the message sequence is continuously traversed without further processing. If the message is addressed to the system under test, it is further determined whether a message subsequent to the message is addressed by the system under test or the present parallel testing component, as shown in step S216. And if the next message of the message is sent by the tested system or the parallel test component, the next process is not carried out, and the next message in the message sequence is continuously traversed. If the next message of the message is not sent by the system under test or the parallel test component, the next message in the message sequence is traversed after the synchronous control message is added to the test script of the parallel test component, as shown in step S217.
If it is determined in step S214 that the last message in the message sequence has been traversed, the traversal process is directly ended.
For a message received by the parallel test component, the receipt of the message is first added directly to the test script of the parallel test component, as shown in step S220. It is then determined whether the message is the last message in the sequence of messages, as shown in step S221.
If the message is not the last message in the message sequence, it is determined whether a message subsequent to the message is sent by another parallel testing component, as shown in step S222. And if the next message of the message is not sent by other parallel test components, the next process is not carried out, and the next message in the message sequence is continuously traversed. If the next message of the message is sent by other parallel test components, the next message in the message sequence is continuously traversed after the synchronous control message is added to the test script of the parallel test component, as shown in step S223.
Likewise, if it is determined in step S221 that the last message in the message sequence has been traversed, the traversal process is directly ended.
Through the execution of the steps, a distributed test script supporting a distributed test architecture and used for performing distributed test on the network communication protocol can be generated.
In addition, it should be noted that, in an embodiment of the present invention, before the distributed test script is generated, specifically, before the main test component is generated, the format of the interaction messages between each parallel test component and the system under test and between each parallel test component is further defined according to the specification of the network communication protocol. In this way, when adding messages to the test script of the parallel test component, each message is specifically defined according to the format of the interactive message, i.e. each interactive message is instantiated, and each message instance is added to the test script of the parallel test component.
In other embodiments of the present invention, when the main test component is established, the ports of the parallel test components are mapped to the system ports of the network entity running the distributed test script.
In another embodiment of the present invention, a system for generating a distributed test script based on model detection is further provided, as shown in fig. 3, including a model building module 31 for performing the operation of step S110. A counter-example generating module 32 for executing the operation of step S120. An extraction module 33 for performing the operation of step S130. A script generating module 34 for performing the operation of step S140. The functions of the related modules can be obtained according to the foregoing embodiments, and are not described herein again.
The embodiment of the invention provides a distributed test script generation method based on model detection, which supports a distributed test architecture and can generate a synchronization strategy supporting parallel test components.
Although the embodiments of the present invention have been described above, the above descriptions are only for the convenience of understanding the present invention, and are not intended to limit the present invention. It will be understood by those skilled in the art that various changes in form and details may be made therein without departing from the spirit and scope of the invention as defined by the appended claims.

Claims (7)

1. A method for generating a distributed test script based on model detection comprises the following steps:
constructing a formal model and constraint which are adaptive to the specification of the network communication protocol;
exploring a state space of the formal model using a model detection tool, if there is a violation of the constraint, generating and outputting a counter-example corresponding to the violation by the model detection tool;
analyzing the counter example to obtain a process list and a message sequence in the counter example;
generating a distributed test script according to the process list and the message sequence, wherein the distributed test script comprises the following steps:
respectively initializing each process except the process corresponding to the tested system in the process list into a parallel test component;
establishing ports between the main test component and each parallel test component to connect each parallel test component;
establishing ports among all the parallel test components so as to connect all the parallel test components with each other;
traversing each message in the message sequence to determine a test script for each parallel test component; wherein the distributed test script comprises a main test component and a plurality of parallel test components; the main test component is arranged on a network entity in the distributed test network and is used for defining a test environment and connecting each parallel test component; the parallel test components are respectively arranged on a plurality of network entities in the distributed test network and used for respectively testing the tested system.
2. The generation method of claim 1, wherein the formal model includes a process describing a network communication entity, a channel describing a network link, and a data structure describing network communication protocol data; the constraints include general rules and specific functions related to the network communication protocol.
3. The method of generating as claimed in claim 1, wherein said traversing each message in said sequence of messages to determine a test script for each parallel test element comprises:
when determining messages sent out by the same parallel test element,
adding the sending of the message directly in a test script corresponding to the parallel test component if the message is the first message in a sequence of messages or a previous message to the message was sent or received by the parallel component;
if the previous message of the message is not sent or received by the parallel test component, firstly adding the receiving of the synchronous control message in the test script corresponding to the parallel test component, and then adding the sending of the message in the test script;
after adding the sending of the message to the test script of the parallel test component, if the message is not the last message in the sequence of messages and the message is addressed to the system under test, and the next message of the message is no longer sent by the parallel test component or by the system under test, adding the sending of the synchronization control message in the test script corresponding to the parallel test component.
4. The method of generating as claimed in claim 3, wherein said traversing each message in said sequence of messages to determine a test script for each parallel test element comprises:
in determining the messages received by the same parallel test element,
adding receipt of the message directly in a test script corresponding to the parallel test component;
after adding the receipt of the message to the test script of the parallel test component, if the message is not the last message of the sequence of messages and the sender of the latter message of the message is the other parallel test component, adding the sending of the synchronization control message in the test script corresponding to the parallel test component.
5. The generation method according to claim 3 or 4,
before generating a distributed test script according to the process list and the message sequence, defining the formats of interactive messages between each parallel test component and the tested system and between each parallel test component according to the specification of a network communication protocol;
instantiating the interactive message according to the format when adding a message to a test script of a parallel test component.
6. The generation method according to claim 3 or 4, wherein, when building a main test component, further comprising mapping a port of the parallel test component to a system port of a network entity running the distributed test script.
7. A generation system of a distributed test script based on model detection, arranged to perform the generation method of any one of claims 1 to 6, the generation system comprising:
a model building module configured to build a formal model and constraints that are compliant with a specification of a network communication protocol;
an counterexample generation module arranged to explore a state space of the formal model using a model detection tool, if there is a violation of the constraint, to generate and output by the model detection tool an counterexample corresponding to the violation;
the extraction module is used for analyzing the counter example to acquire a process list and a message sequence in the counter example;
a script generation module configured to generate a distributed test script according to the process list and the message sequence.
CN201710606329.6A 2017-07-24 2017-07-24 Method and system for generating distributed test script based on model detection Active CN107579871B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201710606329.6A CN107579871B (en) 2017-07-24 2017-07-24 Method and system for generating distributed test script based on model detection

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201710606329.6A CN107579871B (en) 2017-07-24 2017-07-24 Method and system for generating distributed test script based on model detection

Publications (2)

Publication Number Publication Date
CN107579871A CN107579871A (en) 2018-01-12
CN107579871B true CN107579871B (en) 2020-05-01

Family

ID=61033985

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201710606329.6A Active CN107579871B (en) 2017-07-24 2017-07-24 Method and system for generating distributed test script based on model detection

Country Status (1)

Country Link
CN (1) CN107579871B (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111382066B (en) * 2019-11-17 2023-04-14 海南大学 Software defined network application security attribute testing method in development
CN114328278B (en) * 2022-03-14 2022-06-17 南昌航空大学 Distributed simulation test method, system, readable storage medium and computer equipment

Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101408849A (en) * 2008-12-01 2009-04-15 中国科学技术大学 Method and system for compiling and executing TTCN-3 language
EP2063368A3 (en) * 2007-11-15 2010-03-10 Kabushiki Kaisha Toshiba Counter example analysis support apparatus
CN102141962A (en) * 2011-04-07 2011-08-03 北京航空航天大学 Safety distributed test framework system and test method thereof
CN102420727A (en) * 2012-01-05 2012-04-18 北京邮电大学 Distributed protocol test system and method
CN102624574A (en) * 2011-01-27 2012-08-01 西门子公司 Security testing method and device for protocol implementation
CN103036730A (en) * 2011-09-29 2013-04-10 西门子公司 Method and device for achieving safety testing on protocol implementation
CN103391224A (en) * 2013-07-22 2013-11-13 清华大学 Protocol layering test generation method based on parallel expansion finite-state machine
CN103414811A (en) * 2013-08-09 2013-11-27 北京中创信测科技股份有限公司 Method and system for synchronization test of multiple terminals

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20100333061A1 (en) * 2009-06-25 2010-12-30 Gm Global Technology Operations, Inc. Explicit state model checking of sl/sf models using the auto-generated code

Patent Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP2063368A3 (en) * 2007-11-15 2010-03-10 Kabushiki Kaisha Toshiba Counter example analysis support apparatus
CN101408849A (en) * 2008-12-01 2009-04-15 中国科学技术大学 Method and system for compiling and executing TTCN-3 language
CN102624574A (en) * 2011-01-27 2012-08-01 西门子公司 Security testing method and device for protocol implementation
CN102141962A (en) * 2011-04-07 2011-08-03 北京航空航天大学 Safety distributed test framework system and test method thereof
CN103036730A (en) * 2011-09-29 2013-04-10 西门子公司 Method and device for achieving safety testing on protocol implementation
CN102420727A (en) * 2012-01-05 2012-04-18 北京邮电大学 Distributed protocol test system and method
CN103391224A (en) * 2013-07-22 2013-11-13 清华大学 Protocol layering test generation method based on parallel expansion finite-state machine
CN103414811A (en) * 2013-08-09 2013-11-27 北京中创信测科技股份有限公司 Method and system for synchronization test of multiple terminals

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
基于扩展并行多组件状态机的网络协议测试研究;姚姜源;《中国博士学位论文全文数据库信息科技辑》;20160415;正文第24-28、47-52、102-119页 *

Also Published As

Publication number Publication date
CN107579871A (en) 2018-01-12

Similar Documents

Publication Publication Date Title
CN110933095A (en) Message parsing method and device
CN112187558B (en) Data verification method and device and electronic equipment
AU2018201721A1 (en) A formal method of verification and performance analysis for highly reliable communication system
CN103023708A (en) Method and system for testing communication protocol interface
CN102141951A (en) Chip simulation system and method
CN107579871B (en) Method and system for generating distributed test script based on model detection
CN116107893A (en) Heterogeneous platform embedded software test verification system and method
CN102291274A (en) System and method for realizing automatic adaptation of network testing instrument
CN101964923A (en) Configuration system and method for interactive commands
CN102841843B (en) Compatible determination methods and device
CN114513404A (en) Configuration method and device of time-sensitive network and computer-readable storage medium
CN117201601A (en) Internet of things equipment access method, device, equipment and storage medium
CN109799728B (en) Fault-tolerant CPS simulation test method based on hierarchical adaptive strategy
CN111625474A (en) Automatic testing method of alliance chain
CN116684302A (en) Method and device for testing vehicle-mounted Ethernet
CN116436540A (en) LED display screen receiving card testing method and device, testing card and storage medium
CN115657646A (en) Test method and device of CAN controller
CN115542875A (en) Vehicle detection method based on SOA service and related equipment
CN112527453B (en) Virtualization information simulation system, method and computer-readable storage medium
CN110798371A (en) Testing method of private communication protocol
CN111382066B (en) Software defined network application security attribute testing method in development
CN113722235A (en) Automatic testing method and device
CN109814871B (en) Node management method and system based on DDS bus
CN114237824A (en) Fault positioning method and device, computer readable medium and electronic equipment
CN113434382A (en) Database performance monitoring method and device, electronic equipment and computer readable medium

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