A kind of business data packet tracing implementation method
Technical field
The present invention relates to the communications field, relate to a kind of business data packet tracing implementation method or rather.
Background technology
In the mutual software systems of message bag Network Based are used, between application program and the application program by communications protocol Network Based, message bag interaction data as transmission control protocol/procotol TCP/IP (TransmissionControl Protocol/Internet Protocol) agreement, existing IP network agreement packet catcher can only be followed the tracks of in the mode of IP network protocol data bag, does not have ripe business data flow tracking mode.
Summary of the invention
In view of this, main purpose of the present invention is to provide a kind of business data packet tracing implementation method, with the function that realizes that the mutual application program real time data of communication Network Based is followed the tracks of.
For reaching above purpose, technical scheme of the present invention is achieved in that
The method of the invention comprises the steps:
A, load by tracked host program and to follow the tracks of stake, the described target program of stake of following the tracks of in described host program, loading;
B, start trace routine, receive the address of described host program, and send the request of tracking to host program by this trace routine;
Tracking stake in C, the described host program is according to this request detection host program, and sends the relevant information of this interaction message when detecting host program and send interaction message to trace routine;
D, if described trace routine has been accepted the customization request that the user sends, then this trace routine is collected the relevant information of described interaction message, and asks to handle according to this customization.
Load the tracking stake by providing source code encapsulation class to carry out the integrated mode of source code level; Perhaps, by dynamic link library is provided, loads in the mode of dynamic link library and to follow the tracks of stake.
The address of described host program comprises the IP address and the PORT COM of host program.
Host program is present on the different physical locations with the tracking stake, carries out communication with Transmission Control Protocol between the two.
Described trace routine is also accepted the customization request that the user sends, and handles according to this customization request after collecting the relevant information of described interaction message.
Described customization request is the explanation of operational data structure, trace routine is accepted to be converted into discernible binary system Dat file after this customization request, and the structure exhibition information of explaining by described binary system Dat file after collecting the relevant information of described interaction message.
Described trace routine is also accepted the customization request of user's transmission and sends it to follow the tracks of stake, follows the tracks of stake and asks the relevant information of interaction message is carried out sending to trace routine after the preliminary treatment by this customization.
Described customization request comprises caller, called, controll block, program internal module, business agent's job number or message number filtercondition, or comprises these condition combination in any.
Described method further comprises: the user sends to trace routine and comprises the customization request of following the tracks of the time started and following the tracks of duration, and trace routine is accepted this customization mode with timed task of asking and started and close trace flow.
Trace routine also is provided with the filtercondition of server end message and is sent to and follows the tracks of stake, follows the tracks of stake and accepts to detect the interaction message that host program sends according to the condition of describing in the message that is provided with is set after this is provided with message, and be sent to trace routine after it is filtered.
Described interaction message comprises network interaction message, the inner interaction message of host program or log information.
It is mutual by the inside that the output interface that is arranged on host program inside detects host program to follow the tracks of stake, receives inner interaction message or log information, and its copy is sent to trace routine.
After described tracking request is accepted in described tracking stake, keep network communication to be connected by handshake mechanism and trace routine.
Comprise further behind the step D that trace routine stops tracking message to following the tracks of the stake transmission, after this message is accepted in the tracking stake, disconnects the connection with trace routine.
Following the tracks of stake accepts also to consult version and message byte preface and press the syllable sequence of determining with trace routine to send the interaction message relevant information after the described tracking request; Described trace routine is then distinguished different operating system message byte prefaces according to the version information of consulting, and the relevant information of described interaction message is converted to unified syllable sequence.
The relevant information of described interaction message is meant the copy of this interaction message or a certain field information of this interaction message.
Described tracked host program is a plurality of, and described trace routine comes the mutual sequential of acknowledge message according to the relevant information of a plurality of relevant host program interaction message of collecting.
The present invention sends to tracking server based on Transmission Control Protocol with business data packet then by the tracking stake that provides with dynamic base or source code mode is provided in host program.Host program may reside on the different physical locations with the tracking stake, can carry out communication with Transmission Control Protocol between the two, and then make the packet of tracking can be sent to the far-end tracking server, to realize the remote tracing of network interaction message.Tracking server also can be explained also mutual track of display message and message internal information according to the service logic of customization, thereby has reduced the workload of analyzing IP packet.Trace routine also can be explained structure according to customization, and internet message is showed the user intuitively, makes things convenient for the analysis of service message.Tracking server can be according to artificial appointment real-time tracking simultaneously, and tracking server can customize the host and send the filtered data bag, thereby reduces network traffics.Tracking server also can carry out timing according to user's instruction to be followed the tracks of.Under the situation that tracking server is not followed the tracks of, home server can not send any message logging message, thereby does not influence the performance of home server.This method also provides cross-platform characteristic simultaneously, follow the tracks of stake and the message bag of Unix, two kinds of different syllable sequences of Windows can be sent to trace routine,, confirm different syllable sequences, and show analysis according to following the tracks of the defined version information of stake by trace routine at same showing interface window.Described keeping track of content is not limited to network interaction message, and inner interaction message of program and log information also can be tracked.
Description of drawings
Fig. 1 is the networking schematic diagram of the method for the invention;
Fig. 2 is the schematic flow sheet of the method for the invention;
Fig. 3 is for following the tracks of handshake mechanism schematic flow sheet between stake and the trace routine.
Embodiment
The networking of business data packet tracing implementation method of the present invention as shown in Figure 1, wherein, host program is meant and requires tracked target program that this target program carries out interacting message based on mode and other programs of communications protocol.In host program, load and follow the tracks of stake, described tracking stake is meant the target program that loads in host program, be used to receive the trace command of trace routine, the network communication of keep following the tracks of between stake and the trace routine connects, and the network communication message of host program is sent to the far-end trace routine.This target program can be that the source code form also can be the form of dynamic link library.Trace routine issues trace command to following the tracks of stake, and will follow the tracks of a service message stream of beaming back and preserve displaying.
Core concept of the present invention comprises the steps: as shown in Figure 2
A, loading tracking stake in host program;
B, startup trace routine, described trace routine receives the address of tracked host program, and sends the request of tracking to host program;
Described request is accepted in C, tracking stake, when detecting host program transmission interaction message, sends the relevant information of this interaction message to trace routine according to described request;
D, trace routine are collected the relevant information of described interaction message.
As the described business data packet tracing implementation method of the first embodiment of the present invention, specifically comprise the steps:
A, loading messages tracking stake in host program;
Can load by providing source code encapsulation class to carry out the integrated mode of source code level, also can be by dynamic link library be provided, load in the mode of dynamic link library.Host program may reside on the different physical locations with the tracking stake, can carry out communication with Transmission Control Protocol between the two.
B, start trace routine, receive the IP address and the PORT COM information of tracked host program.
C, trace routine send the information order that request is followed the tracks of to host program, and described information order is accepted in the tracking stake and trace routine carries out communication initialization and other configuration initialization.
Maintenance network communication between D, tracking stake and the trace routine connects, and when the tracking stake detects host program transmission network communication message, sends the copy of this network communication message to trace routine.
E, trace routine are preserved after collecting message copying.
Follow the tracks of between stake and the trace routine and can keep network communication to connect by handshake mechanism, as shown in Figure 3:
After following the tracks of an information order that the request of accepting the trace routine transmission is followed the tracks of, follow the tracks of stake and connect message to connect to the trace routine transmission.After connection was set up, the tracking stake sent heartbeat request to trace routine, and trace routine is accepted to feed back a heartbeat response message to the tracking stake after the described heartbeat request.
As the second embodiment of the present invention, trace routine is showed the message copying that traces into according to the operational data structure of customization.The user sends the customization request to trace routine, described customization request is the explanation of operational data structure, comprise message structure definition and two files of message number definition, trace routine is accepted this customization request, is that trace routine can be discerned binary system Dat file by the message conversion program with user-defined file conversion.Trace routine is showed described message copying according to the structure of described binary system Dat file explanation after collecting message copying.
As the third embodiment of the present invention, the user sends the customization request to trace routine, and described customization request comprises to be followed the tracks of the time started and follow the tracks of duration.After trace routine is accepted described customization request, start and close trace flow in the mode of timed task.When trace routine adopts the plug-in unit mode, for trace routine increases a plug-in unit dynamic base, after accepting the customization request, trace routine only need be provided with the time that needs tracking and stop to follow the tracks of according to user's request in this plug-in unit, promptly can start and close trace flow in the mode of timed task.
As the fourth embodiment of the present invention, trace routine is provided with the service end filtercondition, determines which message bag sends to trace routine.This filtercondition is provided with message sends to corresponding tracking stake, follow the tracks of stake and accept the described message that is provided with, check the message bag of each network communication message that host program sends according to the condition of describing in the message that is provided with is set, it is filtered, the message bag after filtering is sent to trace routine.Trace routine is collected behind the message bag after the described filtration its preservation.
As the fifth embodiment of the present invention, trace routine also can be accepted user's message screening customization request, trace routine should customize request and be sent to the tracking stake, follow the tracks of stake and ask the message bag of each network communication message that host program is sent to carry out filtration treatment according to this customization, pretreated relevant information is sent to trace routine preserves.Trace routine also can oneself be accepted user's message screening customization request, and the message of collecting is carried out preserving or displaying after the filtration treatment according to this request.Described user's message screening customization request comprises the various filterconditions that the user is provided with, as caller, called, controll block, program internal module, business agent's job number, message number etc., or the flexible combination of these conditions.
As the sixth embodiment of the present invention, keeping track of content is not limited to network interaction message, and inner interaction message of host program and log information also can be tracked.In host program inside output interface is set, it is inner mutual by this output interface detection host program to follow the tracks of stake, receives this inside interaction message and log information, sends the copy of inner interaction message and log information to trace routine.
As the seventh embodiment of the present invention, trace routine can be followed the tracks of a plurality of tracking stakes simultaneously, and can be by following the tracks of stake and trace routine local zone time separately, the message that tracking is obtained sorts, and realizes the message time sequence trace analysis of multi-process, many equipment with this.Trace routine receives the address of a plurality of tracked host programs, and sends the request of tracking to a plurality of host programs; Described request is accepted in tracking stake in the described host program, according to this request detection host program, when detecting host program transmission interaction message, sends the relevant information of this interaction message to trace routine; Trace routine comes the mutual sequential of acknowledge message according to the relevant information of the interaction message of a plurality of relevant host programs of collecting.
Business data packet tracing implementation method of the present invention has cross-platform characteristic.Trace routine sends the information order that request is followed the tracks of to host program, and described information order is accepted in the tracking stake and trace routine carries out communication initialization and other configuration initialization, finishes determining of version, message byte preface with this.Follow the tracks of stake and the message bag of Unix, two kinds of different syllable sequences of Windows can be sent to trace routine, by trace routine according to following the tracks of the defined version information of stake, distinguish different operating system message byte prefaces, transforming message is unified syllable sequence and shows the user then.
When trace routine adopts the plug-in unit mode, when needs increase client functionality newly, only need according to the plug-in unit template that has defined corresponding expanded function dynamic base be set in client, can in trace routine, increase function corresponding by registering functional.