CN112328394B - Message sequence processing method, device and readable medium in protocol simulation - Google Patents

Message sequence processing method, device and readable medium in protocol simulation Download PDF

Info

Publication number
CN112328394B
CN112328394B CN202011209072.9A CN202011209072A CN112328394B CN 112328394 B CN112328394 B CN 112328394B CN 202011209072 A CN202011209072 A CN 202011209072A CN 112328394 B CN112328394 B CN 112328394B
Authority
CN
China
Prior art keywords
target event
message sequence
callback function
determining
message
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
CN202011209072.9A
Other languages
Chinese (zh)
Other versions
CN112328394A (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.)
Beijing Teletest Technology Co ltd
Original Assignee
Beijing Teletest 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 Beijing Teletest Technology Co ltd filed Critical Beijing Teletest Technology Co ltd
Priority to CN202011209072.9A priority Critical patent/CN112328394B/en
Publication of CN112328394A publication Critical patent/CN112328394A/en
Application granted granted Critical
Publication of CN112328394B publication Critical patent/CN112328394B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5027Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/54Interprogram communication
    • G06F9/546Message passing systems or structures, e.g. queues
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/14Session management
    • H04L67/143Termination or inactivation of sessions, e.g. event-controlled end of session

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Debugging And Monitoring (AREA)
  • Computer And Data Communications (AREA)

Abstract

The invention provides a message sequence processing method, a device and a readable medium in protocol simulation, wherein the method comprises the following steps: acquiring at least two message sequences, and executing for each message sequence: processing the message sequence according to a preset rule to trigger at least one target event, wherein the target event is used for representing the processing operation of the message sequence; determining a callback function corresponding to each target event, wherein the preset rule comprises a corresponding relation between the target event and the callback function, and the callback function is used for representing and executing processing operation corresponding to the target event; and completing the target event by calling a callback function. The invention can improve the processing efficiency of the message sequence in the protocol simulation.

Description

Message sequence processing method, device and readable medium in protocol simulation
Technical Field
The present invention relates to the field of protocol emulation, and in particular, to a method and apparatus for processing a message sequence in protocol emulation, and a readable medium.
Background
Protocol emulation is typically accomplished by way of sequential construction of serialized messages (i.e., message sequences) on both the server and client sides.
In fact, massive message sequences need to be tested concurrently in the protocol simulation process. Currently, for each message sequence, a process of establishing a connection, receiving a message and closing the connection needs to be completed by blocking waiting for connection establishment or non-blocking inquiry. In the running process of a large number of message sequences, both blocking waiting and non-blocking inquiry occupy CPU resources, so that CPU is idle, a large amount of time is wasted, the number of concurrent processing message sequences is limited, and therefore the efficiency of message sequence processing is reduced.
Disclosure of Invention
The embodiment of the invention provides a message sequence processing method, a device and a readable medium in protocol simulation, which can improve the efficiency of message sequence processing.
In a first aspect, an embodiment of the present invention provides a method for processing a message sequence in protocol emulation, including:
acquiring at least two message sequences;
for each of the message sequences, performing:
processing the message sequence according to a preset rule to trigger at least one target event, wherein the target event is used for representing the processing operation of the message sequence;
determining a callback function corresponding to each target event, wherein the preset rule comprises a corresponding relation between the target event and the callback function, and the callback function is used for representing and executing processing operation corresponding to the target event;
And completing the target event by calling the callback function.
Optionally, the processing the message sequence according to a preset rule to trigger at least one target event includes:
determining the running state of the message sequence according to a preset rule, wherein the running state comprises at least one of initiating connection establishment, initiating reception and initiating connection closing;
triggering a first target event when determining that the running state of the message sequence is that connection establishment is initiated, wherein the first target event is used for representing processing operation for establishing connection to the message sequence;
triggering a second target event when the running state of the message sequence is determined to be the initiation of receiving, wherein the second target event is used for representing the processing operation of receiving the message sequence;
and triggering a third target event when the running state of the message sequence is determined to be the initiation of closing the connection, wherein the third target event is used for representing the processing operation of closing the connection on the message sequence.
Optionally, the determining a callback function corresponding to each target event includes:
determining a first callback function corresponding to the first target event according to the corresponding relation in the preset rule;
Determining a second callback function corresponding to the second target event according to the corresponding relation in the preset rule;
and determining a third callback function corresponding to the third target event according to the corresponding relation in the preset rule.
Optionally, after the completing the target event by calling the callback function, the method further includes:
invoking the first callback function corresponding to the first target event, and feeding back a first signal, wherein the first signal is used for representing that the first target event is completed;
switching the running state of the message sequence to initiate reception according to the first signal;
invoking the second callback function corresponding to the second target event, and feeding back a second signal, wherein the second signal is used for representing that the second target event is completed;
switching the running state of the message sequence to initiate closing connection according to the second signal;
and calling the third callback function corresponding to the third target event, and feeding back a third signal, wherein the third signal is used for representing that the third target event is completed.
Optionally, after the completing the target event by calling the callback function, the method further includes:
counting the number of the message sequences completing each target event within a preset time length, and determining the number as the completion number;
judging whether the number of completed products is larger than a preset number threshold value or not;
and if the number of completed protocol simulation is greater than the preset number threshold, determining that the protocol simulation is completed.
In a second aspect, an embodiment of the present invention further provides a message sequence processing apparatus in protocol emulation, including:
the acquisition module is used for acquiring at least two message sequences;
the processing module is used for processing each message sequence acquired by the acquisition module according to a preset rule so as to trigger at least one target event, wherein the target event is used for representing the processing operation of the message sequence;
the determining module is used for determining a callback function corresponding to each target event triggered by the processing module, wherein the preset rule comprises a corresponding relation between the target event and the callback function, and the callback function is used for representing and executing processing operation corresponding to the target event;
And the calling module is used for completing the target event by calling the callback function determined by the determining module.
Optionally, the processing module includes:
the acquisition unit is used for determining the running state of the message sequence according to a preset rule, wherein the running state comprises at least one of connection establishment initiation, connection reception initiation and connection closing initiation;
the first triggering unit is used for triggering a first target event when the acquiring unit determines that the running state of the message sequence is the initiation of connection establishment, wherein the first target event is used for representing the processing operation of connection establishment of the message sequence;
the second triggering unit is used for triggering a second target event when the acquiring unit determines that the running state of the message sequence is the initiation of receiving, wherein the second target event is used for representing the processing operation of receiving the message sequence;
and the third triggering unit is used for triggering a third target event when the acquisition unit determines that the running state of the message sequence is the initiation of closing the connection, wherein the third target event is used for representing the processing operation of closing the connection to the message sequence.
Optionally, the determining module includes:
The first determining unit is used for determining a first callback function corresponding to the first target event according to the corresponding relation in the preset rule;
the second determining unit is used for determining a second callback function corresponding to the second target event according to the corresponding relation in the preset rule;
and the third determining unit is used for determining a third callback function corresponding to the third target event according to the corresponding relation in the preset rule.
Optionally, the method further comprises: calling a switching module;
the call switching module is used for executing the following operations:
invoking the first callback function corresponding to the first target event, and feeding back a first signal, wherein the first signal is used for representing that the first target event is completed;
switching the running state of the message sequence to initiate reception according to the first signal;
invoking the second callback function corresponding to the second target event, and feeding back a second signal, wherein the second signal is used for representing that the second target event is completed;
switching the running state of the message sequence to initiate closing connection according to the second signal;
And calling the third callback function corresponding to the third target event, and feeding back a third signal, wherein the third signal is used for representing that the third target event is completed.
Optionally, the method further comprises: a judging module is completed;
the completion judging module is used for executing the following operations:
counting the number of the message sequences completing each target event within a preset time length, and determining the number as the completion number;
judging whether the number of completed products is larger than a preset number threshold value or not;
and if the number of completed protocol simulation is greater than the preset number threshold, determining that the protocol simulation is completed.
In a third aspect, an embodiment of the present invention provides a message sequence processing apparatus in protocol emulation, which is characterized in that the apparatus includes: at least one memory and at least one processor;
the at least one memory for storing a machine readable program;
the at least one processor is configured to invoke the machine readable program to perform the method provided by the first aspect or any of the possible implementations of the first aspect.
In a fourth aspect, embodiments of the present invention provide a computer readable medium having stored thereon computer instructions which, when executed by a processor, cause the processor to perform the method provided by the first aspect or any of the possible implementations of the first aspect.
The invention provides a message sequence processing method, a device and a readable medium in protocol simulation, which are used for acquiring at least two message sequences, and executing for each message sequence: processing the message sequence according to a preset rule to trigger at least one target event, wherein the target event is used for representing the processing operation of the message sequence; determining a callback function corresponding to each target event, wherein the preset rule comprises a corresponding relation between the target event and the callback function, and the callback function is used for representing and executing processing operation corresponding to the target event; and completing the target event by calling a callback function. All processing operations needing to be waited, which are involved in the running process of each message sequence, are related to each message sequence by triggering an event corresponding to the processing operation, calling a callback function to execute the processing operation corresponding to the event, reducing the waiting time and the occupied space of CPU resources, so that a protocol can be processed simultaneously to simulate a larger number of message sequences, and the larger number of message sequences processed in the same time by the protocol simulation is indicative of higher efficiency of the protocol simulation. Therefore, the invention realizes the protocol simulation process of massive concurrency of the message sequences through event driving, and improves the processing efficiency of the message sequences in the protocol simulation.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings that are required in the embodiments or the description of the prior art will be briefly described, and it is obvious that the drawings in the following description are some embodiments of the present invention, and other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
FIG. 1 is a flow chart of a message sequence processing method in protocol emulation according to an embodiment of the present invention;
FIG. 2 is a flow chart of a message sequence processing method in another protocol emulation according to an embodiment of the present invention;
FIG. 3 is a schematic diagram of a device in which a message sequence processing apparatus is located in a protocol simulation according to an embodiment of the present invention;
fig. 4 is a schematic diagram of a message sequence processing apparatus in protocol simulation according to an embodiment of the present invention.
Detailed Description
For the purpose of making the objects, technical solutions and advantages of the embodiments of the present invention more apparent, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention, and it is apparent that the described embodiments are some embodiments of the present invention, but not all embodiments, and all other embodiments obtained by those skilled in the art without making any inventive effort based on the embodiments of the present invention are within the scope of protection of the present invention.
Fig. 1 is a flowchart of a message sequence processing method in protocol simulation according to an embodiment of the present invention, and as shown in fig. 1, the method may include the following steps:
step 101, obtaining at least two message sequences;
102, processing each message sequence according to a preset rule to trigger at least one target event;
step 103, determining callback functions corresponding to each target event;
step 104, completing the target event by calling a callback function.
In an embodiment of the present invention, by obtaining at least two message sequences, for each of the message sequences, performing: processing the message sequence according to a preset rule to trigger at least one target event, wherein the target event is used for representing the processing operation of the message sequence; determining a callback function corresponding to each target event, wherein the preset rule comprises a corresponding relation between the target event and the callback function, and the callback function is used for representing and executing processing operation corresponding to the target event; and completing the target event by calling a callback function. All processing operations needing to be waited, which are involved in the running process of each message sequence, are related to each message sequence by triggering an event corresponding to the processing operation, calling a callback function to execute the processing operation corresponding to the event, reducing the waiting time and the occupied space of CPU resources, so that a protocol can be processed simultaneously to simulate a larger number of message sequences, and the larger number of message sequences processed in the same time by the protocol simulation is indicative of higher efficiency of the protocol simulation. Therefore, the method realizes the protocol simulation process of massive concurrency of the message sequences through event driving, and improves the processing efficiency of the message sequences in the protocol simulation.
Optionally, as shown in fig. 1, a method for processing a message sequence in protocol emulation, in step 102, the message sequence is processed according to a preset rule to trigger at least one target event, which may be specifically implemented by the following ways:
determining the running state of the message sequence according to a preset rule, wherein the running state comprises at least one of initiating connection establishment, initiating reception and initiating connection closing;
triggering a first target event when determining that the running state of the message sequence is that connection establishment is initiated, wherein the first target event is used for representing processing operation for establishing connection to the message sequence;
triggering a second target event when the running state of the message sequence is determined to be the initiation of receiving, wherein the second target event is used for representing the processing operation of receiving the message sequence;
and triggering a third target event when the running state of the message sequence is determined to be the initiation of closing the connection, wherein the third target event is used for representing the processing operation of closing the connection on the message sequence.
In the embodiment of the invention, the running state of the message sequence is determined by monitoring the message sequence in the protocol simulation, and the target event corresponding to the running state is triggered according to the running state of the message sequence. Triggering a first target event for establishing connection of the message sequence when the running state of the message sequence is initiation of connection establishment; when the running state of the message sequence is that the receiving is initiated, triggering a second target event for the message sequence to receive the message; when the running state of the message sequence is that the connection is initiated to be closed, a third target event is triggered for the message sequence to close the connection. Therefore, in the protocol simulation process of the message sequence, according to the running state of the message sequence, triggering a target event corresponding to the running state, and completing the target event without waiting in a blocking mode or querying in a non-blocking mode, so that the waiting time of the message sequence is reduced, and the efficient running of a single message sequence in the protocol simulation is achieved.
In the embodiment of the invention, the message sequence is processed according to the preset rule, so that one target event can be triggered, and a plurality of target events can be triggered.
Optionally, as shown in fig. 1, a method for processing a message sequence in a protocol simulation, determining a callback function corresponding to each target event in step 103 may be specifically implemented by the following manner:
determining a first callback function corresponding to the first target event according to the corresponding relation in the preset rule;
determining a second callback function corresponding to the second target event according to the corresponding relation in the preset rule;
and determining a third callback function corresponding to the third target event according to the corresponding relation in the preset rule.
In the embodiment of the invention, the preset rule comprises the corresponding relation between the target event and the callback function, specifically: the first callback function is used for executing processing operation corresponding to the first target event, the second callback function is used for executing processing operation corresponding to the second target event, and the third callback function is used for executing processing operation corresponding to the third target event. Each message sequence has three running states of initiating connection establishment, initiating receiving and initiating connection closing, and the running states of initiating connection establishment, initiating receiving and initiating connection closing correspond to three target events of connection establishment, receiving and connection closing respectively. For three target events, three callback functions are acquired and used for executing processing operation corresponding to each target event, continuity of message sequence execution in the running process of the message sequence is guaranteed, time waiting for connection establishment, waiting for receiving or waiting for connection closing is reduced, and processing efficiency of the message sequence is improved.
In the embodiment of the invention, the callback function can be obtained directly from a callback function library which is built in advance, or the callback function corresponding to the target event can be created.
Optionally, the message sequence processing method in the protocol emulation as shown in fig. 1, after completing the target event through the callback function in step 104, further includes:
invoking the first callback function corresponding to the first target event, and feeding back a first signal, wherein the first signal is used for representing that the first target event is completed;
switching the running state of the message sequence to initiate reception according to the first signal;
invoking the second callback function corresponding to the second target event, and feeding back a second signal, wherein the second signal is used for representing that the second target event is completed;
switching the running state of the message sequence to initiate closing connection according to the second signal;
and calling the third callback function corresponding to the third target event, and feeding back a third signal, wherein the third signal is used for representing that the third target event is completed.
In the embodiment of the invention, a single message sequence is sequentially executed in protocol simulation, namely when the message sequence is in an operation state of initiating connection establishment, a first target event for establishing connection is triggered, a first callback function for executing connection establishment is called, and a first signal for indicating that connection establishment is completed is fed back; at the moment, according to the first signal, the running state of the message sequence is switched to initiate receiving, when the message sequence is in the running state for initiating receiving, a second target event for receiving is triggered, a second callback function for executing receiving is called, and a second signal for indicating that the receiving is completed is fed back; at this time, according to the second signal, the running state of the message sequence is switched to the connection closing state, when the message sequence is in the connection closing running state, a third target event for closing the connection is triggered, a third callback function for executing the connection closing is called, and a third signal for indicating that the connection closing is completed is fed back. When the third signal is received, then it is determined that the current message sequence completes the test. Thus, when the message sequence sequentially triggers three target events, the message sequence sequentially executes the three target events in sequence, the existence of the feedback signal ensures the sequential execution of a single message sequence, and the waiting of the message sequence in the protocol simulation test is avoided, so that the occupation space of CPU resources of the single message sequence is reduced.
Optionally, the message sequence processing method in the protocol emulation as shown in fig. 1, after completing the target event through the callback function in step 104, further includes:
counting the number of the message sequences completing each target event within a preset time length, and determining the number as the completion number;
judging whether the number of completed products is larger than a preset number threshold value or not;
and if the number of completed protocol simulation is greater than the preset number threshold, determining that the protocol simulation is completed.
In the embodiment of the invention, the number of message sequences of all target events is counted and the relation between the number and the preset number is compared, and when the number is larger than the threshold value of the preset number, the completion of the protocol simulation is determined. The preset number may be the number of message sequences tested by adopting the prior art method within a preset time period, or may be an expected value for completing the message sequences for the protocol simulation. Therefore, the high efficiency of the protocol simulation can be further determined by comparing the number of the message sequences for completing each target event within the preset time length with the preset number, and the result of the protocol simulation can be more intuitively displayed to the user.
As shown in fig. 2, in order to more clearly illustrate the technical solution and advantages of the present invention, the following details of a message sequence processing method in protocol simulation provided by the embodiment of the present invention specifically include the following steps:
step 201, at least two message sequences are acquired.
In this step, a preset duration of protocol simulation is set, a set number of message sequences of the required protocol simulation is determined, and the message sequences of the set number are acquired for the protocol simulation.
For example, the preset duration is m seconds, the set number is n tens of thousands, and n tens of thousands of message sequences are acquired for protocol simulation.
Step 202, determining the running state of the message sequence according to a preset rule, and executing step 203 if the running state is determined to be the initiation of connection establishment; if it is determined that the running state is to initiate reception, step 206 is executed; if it is determined that the running state is to close the connection, step 209 is performed.
In this step, the running state of the message sequence is determined by listening to the message sequence in the protocol emulation. The method comprises the following steps: when the running state of the message sequence is monitored to initiate connection establishment, acquiring an output parameter initiating connection establishment, analyzing the output parameter to obtain an analysis parameter, constructing an input parameter establishing connection based on the analysis parameter, and calling a functional interface socket corresponding to the connection establishment, namely a callback function, through event driving and the input parameter establishing connection so as to complete connection establishment of the message sequence. Similarly, when the running state of the monitored message sequence is the initiation of receiving, the message sequence is received by the method, and when the running state of the monitored message sequence is the initiation of closing the connection, the closing of the message sequence is completed by the method. Therefore, in the protocol simulation process of the message sequence, according to the running state of the message sequence, triggering a target event corresponding to the running state, and reducing the waiting time of the message sequence so as to achieve the efficient running of a single message sequence in the protocol simulation.
Step 203, triggering a first target event, and determining a first callback function corresponding to the first target event according to the corresponding relation in the preset rule.
In this step, when the running state of the message sequence is that connection establishment is initiated, the server sends a data segment with a flag bit of the synchronous sequence number to the client, requests connection establishment from the client, is used for indicating the intention of communication to the client, and informs the client to reply by using the target sequence number as the initial data segment. After receiving the request from the server, the client responds to the server with a data segment with an Acknowledgement (ACK) and a sync sequence number (Syn cookie, syn) flag bit, to inform the server that the data can be transmitted and can reply with the target sequence number as the initial data segment. And after receiving the data segment sent by the client, the server sends a confirmation response signal to the client, and at the moment, the server and the client complete 3-time handshake, trigger a protocol stack to establish a first target event of connection, and determine a first callback function for executing connection establishment according to the corresponding relation between the first target event and the first callback function in a preset rule.
Step 204, a first callback function is called, and a first signal is fed back.
In this step, an output parameter initiating connection establishment is obtained, the output parameter is analyzed to obtain an analysis parameter, an input parameter establishing connection is constructed based on the analysis parameter, a functional interface socket corresponding to the connection establishment is called through event driving and the input parameter establishing connection, namely a first callback function, so that connection establishment of a message sequence is completed, and a first signal that connection establishment is completed through the message sequence is fed back.
Step 205, switching the operation state of the message sequence to initiate reception according to the first signal, and executing step 206.
In this step, since the first signal indicates that the message sequence has completed establishing a connection, at this time, according to the message execution sequence of the message sequence, the running state of the message sequence is switched to initiate reception, so as to ensure the continuity of the message execution of the message sequence, reduce the unnecessary waiting time of the message protocol, and reduce the occupation space of the CPU resource of the message sequence as much as possible.
And 206, triggering a second target event, and determining a second callback function corresponding to the second target event according to the corresponding relation in the preset rule.
In this step, when the running state of the message sequence is that the receiving is initiated, a second target event of the protocol stack for establishing connection is triggered, and a second callback function for executing the receiving is determined according to the corresponding relationship between the second target event and the second callback function in the preset rule.
Step 207, call a second callback function and feed back a second signal.
In the step, the output parameters which initiate the receiving are acquired, the output parameters are analyzed to obtain the analysis parameters, the received input parameters are constructed based on the analysis parameters, the function interface socket corresponding to the receiving is called through event driving and the received input parameters, namely the second callback function, so that the receiving of the message sequence is completed, and the completed second signal is fed back to the receiving of the message sequence.
Step 208, according to the second signal, the running state of the message sequence is switched to initiate receiving, and step 209 is executed.
In this step, since the second signal indicates that the message sequence has been received, at this time, according to the message execution sequence of the message sequence, the running state of the message sequence is switched to initiate closing connection, so as to ensure continuity of message execution of the message sequence, reduce unnecessary waiting time of the message protocol, and reduce occupation space of CPU resources of the message sequence as much as possible.
And step 209, triggering a third target event, and determining a third callback function corresponding to the third target event according to the corresponding relation in the preset rule.
In this step, when the running state of the message sequence is that the connection is initiated to be closed, the server sends a request for stopping the TCP connection to the client, the control bit FIN is set to 1, after the client receives the state that the control bit FIN is 1, the TCP in the connection direction is confirmed to close the connection, the ACK is set to 1, the server puts forward the TCP connection request in the opposite connection direction to the client again, the control bit FIN is set to 1, the client confirms the request sent by the server, the ACK is set to 1, at this time, the client and the server complete 4 handshakes, a third target event for closing the connection by the protocol stack is triggered, and a third callback function for executing the connection is determined according to the corresponding relation between the third target event and the third callback function in the preset rule.
Step 210, call a third callback function and feed back a third signal.
In this step, an output parameter initiating closing connection is obtained, the output parameter is parsed to obtain a parsing parameter, an input parameter of closing connection is constructed based on the parsing parameter, a function interface socket corresponding to closing connection, namely a third callback function, is called through the input parameter of event-driven and closing connection to complete closing connection of a message sequence, and a third signal that closing connection of the message sequence is completed is fed back.
Step 211, switching the running state of the message sequence to initiate closing connection according to the third signal.
In this step, since the third signal indicates that the message sequence has completed closing the connection, at this time, according to the message execution sequence of the message sequence, the running state of the message sequence is switched to closing the reception, so as to ensure the continuity of the message execution of the message sequence, reduce the unnecessary waiting time of the message protocol, and reduce the occupation space of the CPU resource of the message sequence as much as possible.
Step 212, counting the number of message sequences for completing the third target event within the preset time period, and if the number is greater than a preset number threshold, determining that the protocol simulation is efficient.
In this step, the judging basis of the protocol simulation efficiency may be that the number of the message sequences completing the test within the preset time period reaches a preset number, where the preset number may be the number of the message sequences completing the test within the preset time period by using the prior art method. And counting the number of message sequences for completing each target event within a preset time period, and if the number is larger than a preset number threshold value, determining that the protocol simulation is completed, namely that the protocol simulation is efficient.
For example, in the prior art, the number of the message sequences that can be completed in the preset duration m seconds is a, and a is taken as a preset number threshold. In the embodiment of the invention, the number of the message sequences which can be completed in the preset time length m seconds is b based on the protocol simulation of the event-driven message sequences, and if the value b is greater than a, the protocol simulation in the embodiment of the invention is high-efficiency.
As shown in fig. 3 and fig. 4, the embodiment of the present invention provides a message sequence processing apparatus in a protocol simulation where the message sequence processing apparatus in the protocol simulation is located. The apparatus embodiments may be implemented by software, or may be implemented by hardware or a combination of hardware and software. In terms of hardware, as shown in fig. 3, a hardware structure diagram of a device where a message sequence processing apparatus is located in a protocol emulation according to an embodiment of the present invention is shown, where in addition to a processor, a memory, a network interface, and a nonvolatile memory shown in fig. 3, the device where the apparatus is located in the embodiment may generally include other hardware, such as a forwarding chip responsible for processing a packet, and so on. Taking a software implementation as an example, as shown in fig. 4, as a device in a logic sense, the device is formed by reading corresponding computer program instructions in the nonvolatile memory into the memory by the CPU of the device where the device is located.
As shown in fig. 4, a message sequence processing apparatus in protocol emulation provided by an embodiment of the present invention includes:
an acquisition module 401, configured to acquire at least two message sequences;
a processing module 402, configured to process, for each of the message sequences acquired by the acquiring module 401, the message sequence according to a preset rule, so as to trigger at least one target event, where the target event is used to characterize a processing operation on the message sequence;
a determining module 403, configured to determine a callback function corresponding to each of the target events triggered by the processing module 402, where the preset rule includes a correspondence between the target event and the callback function, and the callback function is used to characterize and execute a processing operation corresponding to the target event;
and a calling module 404, configured to complete the target event by calling the callback function determined by the determining module 403.
In the embodiment of the present invention, the obtaining module 401 may be used to perform the step 101 in the above method embodiment, the processing module 402 may be used to perform the step 102 in the above method embodiment, the determining module 403 may be used to perform the step 103 in the above method embodiment, and the calling module 404 may be used to perform the step 104 in the above method embodiment.
Optionally, as shown in fig. 4, the message sequence processing device in the protocol simulation, the processing module includes:
the acquisition unit is used for determining the running state of the message sequence according to a preset rule, wherein the running state comprises at least one of connection establishment initiation, connection reception initiation and connection closing initiation;
the first triggering unit is used for triggering a first target event when the acquiring unit determines that the running state of the message sequence is the initiation of connection establishment, wherein the first target event is used for representing the processing operation of connection establishment of the message sequence;
the second triggering unit is used for triggering a second target event when the acquiring unit determines that the running state of the message sequence is the initiation of receiving, wherein the second target event is used for representing the processing operation of receiving the message sequence;
and the third triggering unit is used for triggering a third target event when the acquisition unit determines that the running state of the message sequence is the initiation of closing the connection, wherein the third target event is used for representing the processing operation of closing the connection to the message sequence.
Optionally, as shown in fig. 4, the message sequence processing apparatus in protocol simulation, the determining module includes:
The first determining unit is used for determining a first callback function corresponding to the first target event according to the corresponding relation in the preset rule;
the second determining unit is used for determining a second callback function corresponding to the second target event according to the corresponding relation in the preset rule;
and the third determining unit is used for determining a third callback function corresponding to the third target event according to the corresponding relation in the preset rule.
Optionally, on the basis of the message sequence processing device in the protocol simulation shown in fig. 4, the method further comprises a call switching module;
the call switching module is used for executing the following steps:
invoking the first callback function corresponding to the first target event, and feeding back a first signal, wherein the first signal is used for representing that the first target event is completed;
switching the running state of the message sequence to initiate reception according to the first signal;
invoking the second callback function corresponding to the second target event, and feeding back a second signal, wherein the second signal is used for representing that the second target event is completed;
Switching the running state of the message sequence to initiate closing connection according to the second signal;
and calling the third callback function corresponding to the third target event, and feeding back a third signal, wherein the third signal is used for representing that the third target event is completed.
Optionally, on the basis of the message sequence processing device in the protocol simulation shown in fig. 4, the device further comprises a completion judging module;
the completion judging module is used for executing the following steps:
counting the number of the message sequences completing each target event within a preset time length, and determining the number as the completion number;
judging whether the number of completed products is larger than a preset number threshold value or not;
and if the number of completed protocol simulation is greater than the preset number threshold, determining that the protocol simulation is completed.
It will be appreciated that the structure illustrated in the embodiments of the present invention does not constitute a specific limitation on the message sequence processing apparatus in the protocol simulation. In other embodiments of the invention, the message sequence processing means in the protocol simulation may include more or less components than illustrated, or certain components may be combined, or certain components may be split, or different arrangements of components. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.
The content of the information interaction and execution process between each module and each unit in the device is based on the same conception as the embodiment of the method of the present invention, and specific content can be referred to the description in the embodiment of the method of the present invention, which is not repeated here.
The embodiment of the invention also provides a message sequence processing device in protocol simulation, which comprises the following steps: at least one memory and at least one processor;
the at least one memory for storing a machine readable program;
the at least one processor is configured to invoke the machine-readable program to perform the message sequence processing method in the protocol emulation in any embodiment of the present invention.
Embodiments of the present invention also provide a computer readable medium storing instructions for causing a computer to perform a method of message sequence processing in protocol emulation as described herein. In particular, a method or apparatus provided with a storage medium on which a software program code realizing the functions of any of the above embodiments is stored, and a computer (or CPU or MPU) of the method or apparatus may be caused to read out and execute the program code stored in the storage medium.
In this case, the program code itself read from the storage medium may realize the functions of any of the above-described embodiments, and thus the program code and the storage medium storing the program code form part of the present invention.
Examples of the storage medium for providing the program code include a floppy disk, a hard disk, a magneto-optical disk, an optical disk (e.g., CD-ROM, CD-R, CD-RW, DVD-ROM, DVD-RAM, DVD-RW, DVD+RW), a magnetic tape, a nonvolatile memory card, and a ROM. Alternatively, the program code may be downloaded from a server computer by a communication network.
Further, it should be apparent that the functions of any of the above-described embodiments may be realized not only by executing the program code read out by the computer, but also by an operation method or the like that causes an operation on the computer based on instructions of the program code to complete a part or all of the actual operations.
Further, it is understood that the program code read out by the storage medium is written into a memory provided in an expansion board inserted into a computer or into a memory provided in an expansion unit connected to the computer, and then a CPU or the like mounted on the expansion board or the expansion unit is caused to perform part and all of actual operations based on instructions of the program code, thereby realizing the functions of any of the above embodiments.
In summary, the method and the device for processing the message sequence in the protocol simulation provided by the embodiments of the present invention have at least the following beneficial effects:
1. In an embodiment of the present invention, by obtaining at least two message sequences, for each of the message sequences, performing: processing the message sequence according to a preset rule to trigger at least one target event, wherein the target event is used for representing the processing operation of the message sequence; determining a callback function corresponding to each target event, wherein the preset rule comprises a corresponding relation between the target event and the callback function, and the callback function is used for representing and executing processing operation corresponding to the target event; and completing the target event by calling a callback function. All processing operations needing to be waited, which are involved in the running process of each message sequence, are related to each message sequence by triggering an event corresponding to the processing operation, calling a callback function to execute the processing operation corresponding to the event, reducing the waiting time and the occupied space of CPU resources, so that a protocol can be processed simultaneously to simulate a larger number of message sequences, and the larger number of message sequences processed in the same time by the protocol simulation is indicative of higher efficiency of the protocol simulation. Therefore, the method realizes the protocol simulation process of massive concurrency of the message sequences through event driving, improves the processing efficiency of the message sequences in the protocol simulation, and executes the following steps for each message sequence by acquiring at least two message sequences: processing the message sequence according to a preset rule to trigger at least one target event, wherein the target event is used for representing the processing operation of the message sequence; determining a callback function corresponding to each target event, wherein the preset rule comprises a corresponding relation between the target event and the callback function, and the callback function is used for representing and executing processing operation corresponding to the target event; and completing the target event by calling a callback function. All processing operations needing to be waited, which are involved in the running process of each message sequence, are related to each message sequence by triggering an event corresponding to the processing operation, calling a callback function to execute the processing operation corresponding to the event, reducing the waiting time and the occupation space of CPU resources so as to be convenient for concurrent protocol simulation of a larger number of message sequences, wherein the larger number of message sequences of the protocol simulation indicates that the protocol simulation is more efficient. Therefore, the invention realizes the protocol simulation process of massive concurrency of the message sequences through event driving, and improves the processing efficiency of the message sequences in the protocol simulation.
2. In the embodiment of the invention, the running state of the message sequence is determined by monitoring the message sequence in the protocol simulation, and the target event corresponding to the running state is triggered according to the running state of the message sequence. Triggering a first target event for establishing connection of the message sequence when the running state of the message sequence is initiation of connection establishment; when the running state of the message sequence is that the receiving is initiated, triggering a second target event for the message sequence to receive the message; when the running state of the message sequence is that the connection is initiated to be closed, a third target event is triggered for the message sequence to close the connection. Therefore, in the protocol simulation process of the message sequence, according to the running state of the message sequence, triggering a target event corresponding to the running state, and completing the target event without waiting in a blocking mode or querying in a non-blocking mode, so that the waiting time of the message sequence is reduced, and the efficient running of a single message sequence in the protocol simulation is achieved.
3. In the embodiment of the invention, the preset rule comprises the corresponding relation between the target event and the callback function, specifically: the first callback function is used for executing processing operation corresponding to the first target event, the second callback function is used for executing processing operation corresponding to the second target event, and the third callback function is used for executing processing operation corresponding to the third target event. Each message sequence has three running states of initiating connection establishment, initiating receiving and initiating connection closing, and the running states of initiating connection establishment, initiating receiving and initiating connection closing correspond to three target events of connection establishment, receiving and connection closing respectively. For three target events, three callback functions are acquired and used for executing processing operation corresponding to each target event, continuity of message sequence execution in the running process of the message sequence is guaranteed, time waiting for connection establishment, waiting for receiving or waiting for connection closing is reduced, and processing efficiency of the message sequence is improved.
4. In the embodiment of the invention, a single message sequence is sequentially executed in protocol simulation, namely when the message sequence is in an operation state of initiating connection establishment, a first target event for establishing connection is triggered, a first callback function for executing connection establishment is called, and a first signal for indicating that connection establishment is completed is fed back; at the moment, according to the first signal, the running state of the message sequence is switched to initiate receiving, when the message sequence is in the running state for initiating receiving, a second target event for receiving is triggered, a second callback function for executing receiving is called, and a second signal for indicating that the receiving is completed is fed back; at this time, according to the second signal, the running state of the message sequence is switched to the connection closing state, when the message sequence is in the connection closing running state, a third target event for closing the connection is triggered, a third callback function for executing the connection closing is called, and a third signal for indicating that the connection closing is completed is fed back. When the third signal is received, then it is determined that the current message sequence completes the test. Thus, when the message sequence sequentially triggers three target events, the message sequence sequentially executes the three target events in sequence, the existence of the feedback signal ensures the sequential execution of a single message sequence, and the waiting of the message sequence in the protocol simulation test is avoided, so that the occupation space of CPU resources of the single message sequence is reduced.
5. In the embodiment of the invention, the number of message sequences of all target events is counted and the relation between the number and the preset number is compared, and when the number is larger than the threshold value of the preset number, the completion of the protocol simulation is determined. The preset number may be the number of message sequences tested by adopting the prior art method within a preset time period, or may be an expected value for completing the message sequences for the protocol simulation. Therefore, the high efficiency of the protocol simulation can be further determined by comparing the number of the message sequences for completing each target event within the preset time length with the preset number, and the result of the protocol simulation can be more intuitively displayed to the user.
It is noted that relational terms such as first and second, and the like, are used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Moreover, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the statement "comprises/comprising" does not exclude that an additional identical element is present in a process, method, article or apparatus that comprises the element.
Those of ordinary skill in the art will appreciate that: all or part of the steps for implementing the above method embodiments may be implemented by hardware related to program instructions, and the foregoing program may be stored in a computer readable storage medium, where the program, when executed, performs steps including the above method embodiments; and the aforementioned storage medium includes: various media in which program code may be stored, such as ROM, RAM, magnetic or optical disks.
Finally, it should be noted that: the foregoing description is only illustrative of the preferred embodiments of the present invention, and is not intended to limit the scope of the present invention. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention are included in the protection scope of the present invention.

Claims (8)

1. The message sequence processing method in the protocol simulation is characterized by comprising the following steps:
acquiring at least two message sequences;
for each of the message sequences, performing:
processing the message sequence according to a preset rule to trigger at least one target event, wherein the target event is used for representing the processing operation of the message sequence;
determining a callback function corresponding to each target event, wherein the preset rule comprises a corresponding relation between the target event and the callback function, and the callback function is used for representing and executing processing operation corresponding to the target event;
Completing the target event by calling the callback function;
the processing the message sequence according to the preset rule to trigger at least one target event comprises the following steps:
determining the running state of the message sequence according to a preset rule, wherein the running state comprises one of initiating connection establishment, initiating reception and initiating connection closing;
triggering a first target event when determining that the running state of the message sequence is that connection establishment is initiated, wherein the first target event is used for representing processing operation for establishing connection to the message sequence;
triggering a second target event when the running state of the message sequence is determined to be the initiation of receiving, wherein the second target event is used for representing the processing operation of receiving the message sequence;
and triggering a third target event when the running state of the message sequence is determined to be the initiation of closing the connection, wherein the third target event is used for representing the processing operation of closing the connection on the message sequence.
2. The method of claim 1, wherein said determining a callback function corresponding to each of said target events comprises:
determining a first callback function corresponding to the first target event according to the corresponding relation in the preset rule;
Determining a second callback function corresponding to the second target event according to the corresponding relation in the preset rule;
and determining a third callback function corresponding to the third target event according to the corresponding relation in the preset rule.
3. The method of claim 2, further comprising, after the completing the target event by calling the callback function:
invoking the first callback function corresponding to the first target event, and feeding back a first signal, wherein the first signal is used for representing that the first target event is completed;
switching the running state of the message sequence to initiate reception according to the first signal;
invoking the second callback function corresponding to the second target event, and feeding back a second signal, wherein the second signal is used for representing that the second target event is completed;
switching the running state of the message sequence to initiate closing connection according to the second signal;
and calling the third callback function corresponding to the third target event, and feeding back a third signal, wherein the third signal is used for representing that the third target event is completed.
4. A method according to any one of claims 1 to 3, further comprising, after said completing said target event by calling said callback function:
counting the number of the message sequences completing each target event within a preset time length, and determining the number as the completion number;
judging whether the number of completed products is larger than a preset number threshold value or not;
and if the number of completed protocol simulation is greater than the preset number threshold, determining that the protocol simulation is completed.
5. A message sequence processing apparatus in protocol emulation, comprising:
the acquisition module is used for acquiring at least two message sequences;
the processing module is used for processing each message sequence acquired by the acquisition module according to a preset rule so as to trigger at least one target event, wherein the target event is used for representing the processing operation of the message sequence;
the determining module is used for determining a callback function corresponding to each target event triggered by the processing module, wherein the preset rule comprises a corresponding relation between the target event and the callback function, and the callback function is used for representing and executing processing operation corresponding to the target event;
The calling module is used for completing the target event by calling the callback function determined by the determining module;
the processing module comprises:
an obtaining unit, configured to determine an operation state of the message sequence according to a preset rule, where the operation state includes one of initiating connection establishment, initiating reception, and initiating connection closing;
the first triggering unit is used for triggering a first target event when the acquiring unit determines that the running state of the message sequence is the initiation of connection establishment, wherein the first target event is used for representing the processing operation of connection establishment of the message sequence;
the second triggering unit is used for triggering a second target event when the acquiring unit determines that the running state of the message sequence is the initiation of receiving, wherein the second target event is used for representing the processing operation of receiving the message sequence;
and the third triggering unit is used for triggering a third target event when the acquisition unit determines that the running state of the message sequence is the initiation of closing the connection, wherein the third target event is used for representing the processing operation of closing the connection to the message sequence.
6. The apparatus of claim 5, wherein the determining module comprises:
The first determining unit is used for determining a first callback function corresponding to the first target event according to the corresponding relation in the preset rule;
the second determining unit is used for determining a second callback function corresponding to the second target event according to the corresponding relation in the preset rule;
and the third determining unit is used for determining a third callback function corresponding to the third target event according to the corresponding relation in the preset rule.
7. A message sequence processing apparatus in protocol emulation, comprising: at least one memory and at least one processor;
the at least one memory for storing a machine readable program;
the at least one processor being configured to invoke the machine readable program to perform the method of any of claims 1 to 4.
8. A computer readable medium having stored thereon computer instructions which, when executed by a processor, cause the processor to perform the method of any of claims 1 to 4.
CN202011209072.9A 2020-11-03 2020-11-03 Message sequence processing method, device and readable medium in protocol simulation Active CN112328394B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202011209072.9A CN112328394B (en) 2020-11-03 2020-11-03 Message sequence processing method, device and readable medium in protocol simulation

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011209072.9A CN112328394B (en) 2020-11-03 2020-11-03 Message sequence processing method, device and readable medium in protocol simulation

Publications (2)

Publication Number Publication Date
CN112328394A CN112328394A (en) 2021-02-05
CN112328394B true CN112328394B (en) 2024-03-01

Family

ID=74322789

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011209072.9A Active CN112328394B (en) 2020-11-03 2020-11-03 Message sequence processing method, device and readable medium in protocol simulation

Country Status (1)

Country Link
CN (1) CN112328394B (en)

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1777127A (en) * 2005-12-08 2006-05-24 中国移动通信集团公司 Protocol conformance measuring device and method
CN101510870A (en) * 2008-04-23 2009-08-19 北京德瑞海普科技有限公司 Method for simulating, verifying and organizing code grade network protocol based on script and module drive
JP2009252113A (en) * 2008-04-09 2009-10-29 Canon Inc Information processing apparatus, control method, and computer program
CN107888446A (en) * 2017-10-30 2018-04-06 北京奇安信科技有限公司 A kind of agreement robustness testing method and device
CN108075945A (en) * 2016-11-18 2018-05-25 腾讯科技(深圳)有限公司 A kind of application testing method and device
CN108563493A (en) * 2018-04-12 2018-09-21 郑州云海信息技术有限公司 A kind of event-driven method, device, equipment and readable storage medium storing program for executing
CN109002363A (en) * 2018-06-21 2018-12-14 郑州云海信息技术有限公司 A kind of event-handling method, device, equipment and readable storage medium storing program for executing

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1777127A (en) * 2005-12-08 2006-05-24 中国移动通信集团公司 Protocol conformance measuring device and method
JP2009252113A (en) * 2008-04-09 2009-10-29 Canon Inc Information processing apparatus, control method, and computer program
CN101510870A (en) * 2008-04-23 2009-08-19 北京德瑞海普科技有限公司 Method for simulating, verifying and organizing code grade network protocol based on script and module drive
CN108075945A (en) * 2016-11-18 2018-05-25 腾讯科技(深圳)有限公司 A kind of application testing method and device
CN107888446A (en) * 2017-10-30 2018-04-06 北京奇安信科技有限公司 A kind of agreement robustness testing method and device
CN108563493A (en) * 2018-04-12 2018-09-21 郑州云海信息技术有限公司 A kind of event-driven method, device, equipment and readable storage medium storing program for executing
CN109002363A (en) * 2018-06-21 2018-12-14 郑州云海信息技术有限公司 A kind of event-handling method, device, equipment and readable storage medium storing program for executing

Also Published As

Publication number Publication date
CN112328394A (en) 2021-02-05

Similar Documents

Publication Publication Date Title
US8966454B1 (en) Modeling and testing of interactions between components of a software system
CN112527879B (en) Kafka-based real-time data extraction method and related equipment
WO2014169565A1 (en) Terminal testing method and device
CN112256542B (en) eBPF-based micro-service system performance detection method, device and system
CN107577578B (en) Method, device and equipment for counting delay of NFS operation word and storage medium
CN110224896B (en) Network performance data acquisition method and device and storage medium
US11809882B2 (en) Interface calling method and apparatus, and computer-readable storage medium
CN111737022A (en) Interface calling method, system, equipment and medium based on micro-service
CN111221793A (en) Data mining method, platform, computer equipment and storage medium
CN108595331B (en) Asynchronous interface testing method, medium, device and computing equipment
CN110543428B (en) Application system testing method and device
CN111200651A (en) Method, system, device and medium for timed calling of microservice
CN112328394B (en) Message sequence processing method, device and readable medium in protocol simulation
CN110750453A (en) HTML 5-based intelligent mobile terminal testing method, system, server and storage medium
US10412778B2 (en) Data transmission method and apparatus for data service
CN111274325B (en) Platform automatic test method and system
WO2021226781A1 (en) Firewall rule updating method and apparatus, server, and storage medium
CN109460193B (en) IO processing method, device and terminal in storage system
US20100235360A1 (en) Synchronized relay messaging and coordinated network processing using snmp
US20180063005A1 (en) Non-blocking request processing method and device
CN113961194A (en) Engineering construction method, system, terminal and medium based on FLUTTER cross-application
CN108363922A (en) A kind of automation malicious code emulation detection method and system
CN113055468B (en) Chip management and control method, device and system
CN109618121A (en) The processing method and processing device of video conference information security
CN113986379B (en) Application starting method and device, computer equipment and storage 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