Summary of the invention
The embodiment of the present application proposes the method and apparatus for being used for transmission data.
In a first aspect, the embodiment of the present application provides a kind of method for being used for transmission data, this method comprises: determining and number
Carry out data transmission the mesh of used destinations traffic agreement and the target data to be passed for transporting to the data receiver according to receiving end
Mark classification;It calls first interface, the third interface to match with the destinations traffic agreement, calling and the destinations traffic agreement and is somebody's turn to do
The second interface that target category matches simultaneously, using the first interface, the second interface and the third interface, by the number of targets
According to being encapsulated as target packet, wherein the first interface, the second interface, the third interface are respectively used to generate the number of targets
According to the packet header of packet, payload and packet tail;The target packet is sent to the data receiver.
In some embodiments, first interface, third interface that the calling and the destinations traffic agreement match, call with
The second interface that the destinations traffic agreement and the target category match simultaneously, comprising: from the set of interfaces prestored, call with
The first interface and third interface that the destinations traffic agreement matches, and call and the destinations traffic agreement and the target category
The second interface to match simultaneously.
In some embodiments, which generates as follows: extracting multiple configuration files, each configuration
File record has the package head format information of the data packet for meeting communication protocol a kind of, packet tail format information and at least one is effectively negative
Carry format information;For each configuration file, the configuration file is recorded respectively package head format information, each effectively
Load format information, packet tail format information are parsed, and first interface that is corresponding, matching with the configuration file, extremely is generated
Few a second interface, third interface;The interface to match with each communication protocol is included into set of interfaces.
In some embodiments, this utilizes the first interface, the second interface and the third interface, which is sealed
Dress is target packet, comprising: extracts preset packet header parameter information and packet tail parameter information;The packet header parameter information is inputted
To the first interface, which is input to the second interface, which is input to the third interface, point
It Sheng Cheng not packet header, payload and packet tail;Successively packet header generated, payload and packet tail are spliced, generate target data
Packet.
In some embodiments, which includes the first address in packet header, the value of packet header parameter, the packet header parameter
The storage space size of the data type of the offset address and packet header parameter relative to first address, the packet tail parameter information include
Verification mode mark and verification initial position.
In some embodiments, this method further include: in response to receiving the data to be resolved of data receiver transmission
Packet, the packet tail of the first address in the packet header based on the data packet to be resolved and the data packet to be resolved, to the data packet to be resolved into
Row verification;In response to determining that the data packet to be resolved by verification, calls the 4th interface to match with the destinations traffic agreement,
The packet header of the data packet to be resolved is parsed using the 4th interface, determines the packet header parameter information of the data packet to be resolved
With the length in the packet header of the data packet to be resolved;The address that the first address in the packet header of the data packet to be resolved length will be deviated is true
It is set to the first address of the payload of the data packet to be resolved, to determine the payload of the data packet to be resolved;It calls and is somebody's turn to do
The 5th interface that destinations traffic agreement matches parses the payload of the data packet to be resolved, determines the number to be resolved
According to the value of the parameters in the payload of packet.
Second aspect, the embodiment of the present application provide a kind of device for being used for transmission data, which comprises determining that list
Member is configured to determining carry out data transmission used destinations traffic agreement with data receiver and data to be passed of transporting to connect
The target category of the target data of receiving end;Generation unit is configured to call match with the destinations traffic agreement first to connect
Mouthful, third interface, call the second interface to be matched simultaneously with the destinations traffic agreement and the target category, first connect using this
Mouthful, the second interface and the third interface, which is encapsulated as target packet, wherein the first interface, this second
Interface, the third interface are respectively used to generate the packet header of the target packet, payload and packet tail;Transmission unit, configuration are used
In sending the target packet to the data receiver.
In some embodiments, which is further configured to: from the set of interfaces prestored, calling and the mesh
The first interface and third interface that mark communication protocol matches, and call with the destinations traffic agreement and the target category simultaneously
The second interface to match.
In some embodiments, the device further include: extraction unit is configured to extract multiple configuration files, each
Configuration file record have the package head format information of the data packet for meeting communication protocol a kind of, packet tail format information and at least one have
Imitate load format information;First resolution unit is configured to respectively record the configuration file each configuration file
Package head format information, each payload format information, packet tail format information parsed, generate it is corresponding, match with this
Set first interface, at least one second interface, third interface that file matches;It is included into unit, is configured to lead to each
The interface that letter agreement matches is included into set of interfaces.
In some embodiments, which includes: extraction module, is configured to extract preset packet header parameter information
With packet tail parameter information;Input module is configured to the packet header parameter information being input to the first interface, by the target data
It is input to the second interface, which is input to the third interface, generates packet header, payload and packet respectively
Tail;Generation module is configured to successively splice packet header generated, payload and packet tail, generates target packet.
In some embodiments, which includes the first address in packet header, the value of packet header parameter, the packet header parameter
The storage space size of the data type of the offset address and packet header parameter relative to first address, the packet tail parameter information include
Verification mode mark and verification initial position.
In some embodiments, device further include: verification unit is configured in response to receiving the data receiver
The data packet to be resolved sent, the packet tail of the first address in the packet header based on the data packet to be resolved and the data packet to be resolved are right
The data packet to be resolved is verified;Second resolution unit is configured in response to determining that the data packet to be resolved passes through verification,
The 4th interface to match with the destinations traffic agreement is called, is carried out using packet header of the 4th interface to the data packet to be resolved
Parsing, determines the length of the packet header parameter information of the data packet to be resolved and the packet header of the data packet to be resolved;Will offset should be to
The address of the first address in packet header of the parsing data packet length is determined as the first address of the payload of the data packet to be resolved, with
Determine the payload of the data packet to be resolved;Call the 5th interface to match with the destinations traffic agreement to the number to be resolved
It is parsed according to the payload of packet, determines the value of the parameters in the payload of the data packet to be resolved.
The third aspect, the embodiment of the present application provide a kind of electronic equipment, comprising: one or more processors;Storage dress
Set, for storing one or more programs, when the one or more program is executed by the one or more processors so that this one
A or multiple processors realize the method for being such as used for transmission any embodiment in the method for data.
Fourth aspect, the embodiment of the present application provide a kind of computer-readable medium, are stored thereon with computer program, should
The method for being such as used for transmission any embodiment in the method for data is realized when program is executed by processor.
The method and apparatus provided by the embodiments of the present application for being used for transmission data are counted by determining with data receiver
According to the target category for transmitting used destinations traffic agreement and the target data to be passed for transporting to the data receiver, then call
First interface, the third interface to match with the destinations traffic agreement calls same with the destinations traffic agreement and the target category
The target data is encapsulated as mesh using the first interface, the second interface and the third interface by the matched second interface of phase
Data packet is marked, finally sends the target packet to the data receiver, so as to based on interface and destinations traffic agreement
Matching, target data is encapsulated as to meet the target packet of destinations traffic agreement, does not need manually to carry out meeting destinations traffic
The data packet format of agreement is write, to improve the flexibility of data transmission.
Specific embodiment
The application is described in further detail with reference to the accompanying drawings and examples.It is understood that this place is retouched
The specific embodiment stated is used only for explaining related invention, rather than the restriction to the invention.It also should be noted that in order to
Convenient for description, part relevant to related invention is illustrated only in attached drawing.
It should be noted that in the absence of conflict, the features in the embodiments and the embodiments of the present application can phase
Mutually combination.The application is described in detail below with reference to the accompanying drawings and in conjunction with the embodiments.
Fig. 1 is shown can be using the method for being used for transmission data of the application or the example for the device for being used for transmission data
Property system architecture 100.
As shown in Figure 1, system architecture 100 may include 101 network 102 of earth station (Ground Station) and unmanned plane
(Unmanned Aerial Vehicle/Drones, UAV) 103.Network 102 is between earth station 101 and unmanned plane 103
The medium of communication link is provided.Network 102 may include various connection types, such as wireless communication link etc..
In practice, earth station 101 is the combat operations center of entire UAV system, and control content may include for nobody
The transmitting of the flight course of machine, flight track, the task function of payload, the normal work of communication link and unmanned plane
With recycling etc..Unmanned plane 103 is the not manned aircraft manipulated using radio robot and the presetting apparatus provided for oneself, or
Person fully or is intermittently automatically operated by car-mounted computer.
Earth station 101 can be interacted by network 102 and unmanned plane 103, to receive or send message etc..Work as ground
101 are stood when sending information to unmanned plane 103 by network 102, earth station 101 is data sending terminal, and unmanned plane 103 connects for data
Receiving end.When unmanned plane 103 sends information by 102 ground station 101 of network, unmanned plane 103 is data sending terminal, earth station
101 be data receiver.
Data sending terminal, which can be determined, to carry out data transmission used communication protocol with data receiver, to be passed transports to number
The information such as the classification according to the data of receiving end can also call the corresponding interface to be packaged data to be transmitted, generate and meet
The data packet of corresponding communication protocol, to transmit the data packet.
It should be noted that the method for being used for transmission data provided by the embodiment of the present application is generally held by data sending terminal
Row, correspondingly, the device for being used for transmission data is generally arranged in data sending terminal.
It should be pointed out that when data sending terminal (such as earth station 101) receives data receiver (such as unmanned plane
103) information (such as data packet to be resolved) for sending or returning, at this point it is possible to which the corresponding interface is called to parse the information.
It should be understood that the number of earth station, network and unmanned plane in Fig. 1 is only schematical.According to realize needs,
It can have any number of earth station, network and unmanned plane.
With continued reference to Fig. 2, the process of one embodiment of the method for being used for transmission data according to the application is shown
200.The method for being used for transmission data, comprising the following steps:
Step 201, it is determining carry out data transmission with data receiver used in destinations traffic agreement and to be passed transport to number
According to the target category of the target data of receiving end.
In the present embodiment, the method operation electronic equipment thereon for being used for transmission data can determine and data receiver
End carries out data transmission the target class of the target data of used destinations traffic agreement and data receiver to be transmitted to above-mentioned
Not.In practice, communicated from different electronic equipments, it usually needs different communication protocol is relied on, it can be by above-mentioned electronics
Equipment and current data receiver carry out data transmission relied on communication protocol and are determined as destinations traffic agreement.Based on above-mentioned
Destinations traffic agreement, above-mentioned electronic equipment can transmit various types of other data to above-mentioned data receiver, for example, the class of data
It not can be heartbeat packet, posture information, control instruction, GPS (Global Positioning System, global positioning system)
Information etc..Above-mentioned electronic equipment can be using the data of current data receiver to be transmitted to above-mentioned as target data, by the mesh
The classification of mark data is determined as target category.
In practice, communication protocol refers to that both entities complete communication or service be must comply with rule and agreement.Communication
Information and meaning that format, the information unit that protocol definition data cell uses should include, connection type, information send and
Received timing etc., so that it is guaranteed that data are successfully transmitted to determining place in network.In general, two equipment interact,
The authenticated byte stream transmitted is properly termed as payload (alternatively referred to as payload).Before transmission, data sending terminal needs
Packet header and packet tail are added to payload according to the format of communication protocol, form data packet.Data receiver is receiving data
Bao Hou needs to remove packet header, packet tail, obtains the data in payload.In general, packet header indicates the start bit of a frame data
It sets, packet tail indicates the tail portion of a frame data, and packet tail usually stores the check value of data sending terminal calculating.For different communication
Agreement, the composition in packet header and definition are usually different.Different classes of data are transmitted, the composition of payload is usually difference
, verification mode is also usually different.
In an application scenarios, above-mentioned electronic equipment can be earth station 101 as shown in Figure 1, above-mentioned data receiver
End can be unmanned plane 103 as shown in Figure 1.Earth station communicates from the unmanned plane that different manufacturers produce, it usually needs
Use different communication protocol.Earth station can send the data of the classifications such as control instruction to unmanned plane.
In another application scenarios, above-mentioned electronic equipment can be unmanned plane 103 as shown in Figure 1, and above-mentioned data connect
Receiving end can be earth station 101 as shown in Figure 1.Unmanned plane can send heartbeat packet, posture information, GPS information with ground station
Etc. various types of other data.
It should be noted that above-mentioned electronic equipment and data receiver can also be other equipment, for example, data receiver
It can be automatic guided vehicle (Automated Guided Vehicle, AGV), above-mentioned electronic equipment can be for controlling nobody
Control equipment of carrier etc..
Step 202, first interface, the third interface to match with destinations traffic agreement is called, calls and is assisted with destinations traffic
The second interface that negotiation target category matches simultaneously is sealed target data using first interface, second interface and third interface
Dress is target packet.
In the present embodiment, it can be previously stored in above-mentioned electronic equipment and be connect from what different communication protocol matched
Mouthful.The interface to match with each communication protocol may include the interface for realizing various functions, such as generating data packet
The interface in packet header, interface, the interface of packet tail for generating data packet of payload for generating data packet etc..Its
In, due to transmitting different classes of data, the composition of payload is usually different, therefore, for each communication protocol,
The interface of payload match with the communication protocol, for generating data packet can have multiple, each interface pair
Answer a kind of classification of data.
In the present embodiment, above-mentioned electronic equipment can call the first interface to match with above-mentioned destinations traffic agreement,
Third interface calls the second interface to be matched simultaneously with destinations traffic agreement and target category, using above-mentioned first interface, on
Second interface and above-mentioned third interface are stated, target data is encapsulated as target packet.Wherein, above-mentioned first interface, above-mentioned
Two interfaces, above-mentioned third interface are respectively used to generate packet header, payload and the packet tail of target packet.
In practice, above-mentioned first interface, above-mentioned second interface, above-mentioned third interface can be pre-generated and is stored in
It states in electronic equipment.Above-mentioned electronic equipment directly can call above-mentioned first interface, above-mentioned second interface and above-mentioned from local
Third interface.
In some optional implementations of the present embodiment, sets of interfaces can be previously stored in above-mentioned electronic equipment
It closes.Above-mentioned electronic equipment can call the first interface to match with above-mentioned destinations traffic agreement from the set of interfaces prestored
With third interface, and the second interface that calling matches simultaneously with above-mentioned destinations traffic agreement and above-mentioned target category.Practice
In, it may include the title of communication protocol in the interface name of each interface, the interface name of the interface for generating payload
The title of the classification of data can also be included in title.Above-mentioned electronic equipment can be by the matching of the character string in title, from connecing
In mouth set, above-mentioned first interface, above-mentioned second interface and above-mentioned third interface are called.
In some optional implementations of the present embodiment, above-mentioned set of interfaces can generate as follows:
The first step extracts multiple configuration files, wherein each configuration file, which can recorde, meets a kind of communication protocol
Data packet package head format information, packet tail format information and at least one payload format information.
In practice, the packet header of data packet generally comprise initial parameters (a usually fixed value, for example, 254) and packet header ginseng
Number (number, the length of payload, the classification of data of such as data packet).The packet header of each configuration file record as a result,
Format information may include but be not limited to following information: packet header opening flag (starting for being used to indicate packet header), packet header terminate to mark
Will (ending for being used to indicate packet header), the title of the corresponding communication protocol of the configuration file, initial parameters, above-mentioned packet header start to mark
The parameter information of the packet header parameter in region between will and above-mentioned packet header end mark (can orderly be wrapped by least one
The data type and title forms of head parameter).
In practice, the payload of data packet is usually the effective data of data sending terminal pre-transfer, generally can foundation
The different number of the content compilation of data.Each configuration file record each payload format information may include but
Be not limited to following information: payload opening flag (starting for being used to indicate payload), payload end mark (are used for
Indicate the ending of payload), the title of the classifications of corresponding data (can be character string forms, is convenient for and interface carries out
With), the ginseng of payload parameter in the region between above-mentioned payload opening flag and above-mentioned payload end mark
Number information (can be by the data type and title forms of at least one orderly payload parameter).
In practice, the packet tail of data packet is usually the check value that transmitting terminal calculates for storing data.Each configuration text
The packet tail format information of part record can include but is not limited to following information: packet tail opening flag (is used to indicate rising for packet tail
Begin), packet caudal knot bundle flag (ending for being used to indicate packet tail), verification mode mark (can be character string forms, be used to indicate school
The mode tested, for example, " CRC16 " is used to indicate CRC (Cyclic Redundancy Check, the circulation that verification mode is 16
Redundancy check)) and verification initial position.Wherein, above-mentioned verification initial position can be certain of the first address relative to data packet
A offset address is used to indicate and is verified since the verification initial position.
Herein, cyclic redundancy check is that a kind of generated according to data such as network packet or computer documents briefly fixes digit
A kind of hash function of check code is mainly used to the mistake for detecting or verifying data transmission or be likely to occur after saving.It is
Make error detection using the principle of division and remainder.It should be noted that above-mentioned cyclic redundancy check is research extensively at present
With the well-known technique of application, details are not described herein.
Second step, for each configuration file, the configuration file is recorded respectively package head format information, each
Payload format information, packet tail format information are parsed, and generation is corresponding, connects with the configuration file matches first
Mouth, at least one second interface, third interface.Implementing principle can be following above-mentioned:
The data type of packet header parameter is indicated with type, the title of packet header parameter is indicated with head, indicates that storage is empty with len
Between size, it is assumed that the packet header of data packet is made of type0, head0, type1, head1, type2, head2, data type
The storage space size (i.e. shared byte number) of type0, type1, type2 are respectively len0, len1, len2.So head0,
Head1, head2 are respectively 0, len0, len0+len1 relative to the offset address of the first address in packet header.By the data of each parameter
The storage space size of type is added to obtain the length in packet header.Therefore, apply corresponding memory (for the data type pair of each parameter
The sum for the storage space size answered) by the value of each packet header parameter according to the offset address of first address corresponding, relative to packet header
It is stored with the length of data type, the encapsulation in packet header can be completed.Therefore, the first address in known packet header, packet header parameter
Value, packet header parameter is relative to the offset address of first address, the feelings of the storage space size of the data type of above-mentioned packet header parameter
Under condition, the generation in packet header may be implemented by the above method.It can be obtained using the above method as the method for realizing that packet header generates
For generating the first interface in packet header.Herein, the input parameter of first interface may include the first address in packet header, packet header parameter
Value, packet header parameter are relative to the offset address of first address, the storage space size of the data type of above-mentioned packet header parameter.
The data type of payload parameter is indicated with type, and the title of payload parameter is indicated with payload, it is assumed that
The title xxxxxx of the classification of data, payload is by type0, payload0, type1, payload1, type2, payload2
Composition can use principle identical with encapsulation packet header, realize the generation to payload.As an example, data can be sealed
Dress is following data structure: " xxxxxx_payload { type0payload0;type1payload1;
type2payload2}".It can obtain using the method for generating payload as the method for realizing that payload generates for giving birth to
At the second interface of payload.Since the method for generating second interface is approximate with the method for first interface is generated, herein no longer
It repeats.
Due to that in the case where known verification mode identifies and verifies initial position, can determine verification mode mark instruction
Verification mode, and verified using the verification mode and above-mentioned verification initial position, obtain check value, and packet tail is usually deposited
Check value is put, therefore, the method that check value can will be generated in the case where known verification mode identifies and verifies initial position
As the generation method of packet tail, the third interface for generating packet tail is obtained.
The interface to match with each communication protocol is included into set of interfaces by third step.
In some optional implementations of the present embodiment, after calling first interface, second interface, third interface,
Above-mentioned electronic equipment can generate as follows target packet: the first step, extract preset packet header parameter information and packet
Tail parameter information.Wherein, above-mentioned packet header parameter information and packet tail parameter information can be technical staff based on to target data
It analyzes and presets and be stored in above-mentioned electronic equipment.Herein, above-mentioned packet header parameter information may include the head in packet header
Address, the value of packet header parameter, above-mentioned packet header parameter are relative to the offset address of first address and the data type of above-mentioned packet header parameter
Storage space size.Above-mentioned packet tail parameter information may include verification mode mark and verification initial position.Second step, will be upper
It states packet header parameter information and is input to above-mentioned first interface, above-mentioned target data is input to above-mentioned second interface, by above-mentioned packet tail
Parameter information is input to above-mentioned third interface, generates packet header, payload and packet tail respectively.Third step, successively will be generated
Packet header, payload and the splicing of packet tail, generate target packet.
Step 203, target packet is sent to data receiver.
In the present embodiment, above-mentioned electronic equipment can send above-mentioned target packet to above-mentioned data receiver.
With continued reference to the signal that Fig. 3, Fig. 3 are according to the application scenarios of the method for being used for transmission data of the present embodiment
Figure.In the application scenarios of Fig. 3, earth station 301 is determining first to carry out data transmission used destinations traffic with unmanned plane 302
The target category of agreement and the target data to be passed for transporting to the data receiver.Then earth station 301 calls and the destinations traffic
First interface that agreement matches, third interface call the to match simultaneously with the destinations traffic agreement and the target category
Two interfaces generate packet header using the first interface, generate payload using second interface, generate packet tail using third interface,
It obtains the target data and is encapsulated as target data 303, finally send the target packet 303 to unmanned plane 302.
The method provided by the above embodiment of the application is carried out data transmission used by determining and data receiver
The target category of destinations traffic agreement and the target data to be passed for transporting to the data receiver is then called and is assisted with the destinations traffic
First interface, the third interface to match is discussed, second to match simultaneously with the destinations traffic agreement and the target category is called
The target data is encapsulated as target packet using the first interface, the second interface and the third interface by interface, finally to
The data receiver sends the target packet, so as to the matching based on interface Yu destinations traffic agreement, by target data
It is encapsulated as meeting the target packet of destinations traffic agreement, does not need the data packet format for manually carrying out meeting destinations traffic agreement
Write, thus improve data transmission flexibility.
With further reference to Fig. 4, it illustrates the processes 400 of another embodiment of the method for being used for transmission data.The use
In the process 400 of the method for transmission data, comprising the following steps:
Step 401, it is determining carry out data transmission with data receiver used in destinations traffic agreement and to be passed transport to number
According to the target category of the target data of receiving end.
In the present embodiment, the method operation electronic equipment thereon for being used for transmission data can determine and data receiver
End carries out data transmission the target class of the target data of used destinations traffic agreement and data receiver to be transmitted to above-mentioned
Not.
Step 402, first interface, the third interface to match with destinations traffic agreement is called, calls and is assisted with destinations traffic
The second interface that negotiation target category matches simultaneously is sealed target data using first interface, second interface and third interface
Dress is target packet.
In the present embodiment, set of interfaces can be previously stored in above-mentioned electronic equipment.Above-mentioned electronic equipment can be from
In the set of interfaces prestored, call the first interface and third interface to match with above-mentioned destinations traffic agreement, and call with
The second interface that above-mentioned destinations traffic agreement and above-mentioned target category match simultaneously.Wherein, above-mentioned first interface, above-mentioned second
Interface, above-mentioned third interface are respectively used to generate packet header, payload and the packet tail of target packet.
Step 403, target packet is sent to data receiver.
In the present embodiment, above-mentioned electronic equipment can send above-mentioned target packet to above-mentioned data receiver.
It should be noted that the operation of above-mentioned steps 401-403 and the operation of above-mentioned steps 201-203 are essentially identical, this
Place repeats no more.
Step 404, the data packet to be resolved sent in response to receiving data receiver, the packet based on data packet to be resolved
The first address of head and the packet tail of data packet to be resolved, verify data packet to be resolved.
In the present embodiment, the data packet to be resolved sent in response to receiving data receiver, above-mentioned electronic equipment can
With the packet tail of the first address in the packet header based on data packet to be resolved and data packet to be resolved, it is conducive to preparatory with above-mentioned data receiver
It the verification mode (i.e. the verification mode of verification mode mark instruction, such as cyclic redundancy check mode) of agreement and makes an appointment
Verification starting place value, verifies data packet to be resolved, obtains check value.If the packet tail of the check value and data packet to be resolved
Check value it is consistent, then can determine that above-mentioned data packet to be resolved passes through verification, it is believed that the data packet to be resolved is correct number
According to packet.
Step 405, the 4th to match with destinations traffic agreement is called by verification in response to determination data packet to be resolved
Interface parses the packet header of data packet to be resolved using the 4th interface, determines the packet header parameter information of data packet to be resolved
With the length in the packet header of data packet to be resolved;The address that the above-mentioned length of first address in the packet header of data packet to be resolved will be deviated determines
For the first address of the payload of data packet to be resolved, with the payload of determination data packet to be resolved;Calling and destinations traffic
The 5th interface that agreement matches parses the payload of data packet to be resolved, determines the effective negative of data packet to be resolved
The value of parameters in load.
In the present embodiment, above-mentioned electronic equipment can be executed in response to the above-mentioned data packet to be resolved of determination by verification
Following steps:
The first step calls the 4th interface to match with destinations traffic agreement, using above-mentioned 4th interface to number to be resolved
It is parsed according to the packet header of packet, determines the length of the packet header parameter information of data packet to be resolved and the packet header of data packet to be resolved
(the storage space size of the data type of each packet header parameter is added to obtain).Wherein, above-mentioned 4th interface can be used for parsing
The packet header of data packet.The parameter for being input to above-mentioned 4th interface may include the first address in packet header, the value of packet header parameter, packet header ginseng
Number is relative to the offset address of first address, the storage space size of the data type of above-mentioned packet header parameter.Above-mentioned 4th interface can
Corresponding offset address and length are deviated for the value of corresponding storage size, by this relative to the first address in packet header to obtain
Value is assigned to corresponding parameter, to realize the parsing to packet header, obtains the corresponding value of each packet header parameter.
The address for the above-mentioned length of first address for deviating the packet header of data packet to be resolved is determined as above-mentioned to be resolved by second step
The first address of the payload of data packet, with the payload of determination data packet to be resolved.As an example, if the length in packet header is
Head_len, then the address relative to the first address offset head_len in packet header is then the first address of payload.
Third step calls the 5th interface to match with destinations traffic agreement to carry out the payload of data packet to be resolved
Parsing, determines the value of the parameters in the payload of data packet to be resolved.Wherein, above-mentioned 5th interface can be used for parsing
The payload of data packet.Herein, the principle base of the principle of low 5th interface parsing payload and the 4th interface parsing packet header
This is identical, and details are not described herein again.
It should be noted that above-mentioned 4th interface and above-mentioned 5th interface can be pre-generated and is stored in above-mentioned electronics
In equipment.Above-mentioned electronic equipment directly can call above-mentioned 4th interface and above-mentioned 5th interface from local.It is above-mentioned in practice
4th interface, above-mentioned 5th interface can also be included into advance in above-mentioned set of interfaces.
Figure 4, it is seen that the method for being used for transmission data compared with the corresponding embodiment of Fig. 2, in the present embodiment
Process 400 highlight the step of parsing to the data packet received.The scheme of the present embodiment description as a result, not only can be with
Target data is encapsulated as meeting the target packet of destinations traffic agreement by the matching based on interface Yu destinations traffic agreement,
It can parse the data packet received, directly carry out the calling of interface, do not need the number for manually carrying out meeting destinations traffic agreement
It is write according to the method for writing and parse data packet of packet format, to further improve the flexibility of data transmission.
With further reference to Fig. 5, as the realization to method shown in above-mentioned each figure, this application provides one kind to be used for transmission number
According to device one embodiment, the Installation practice is corresponding with embodiment of the method shown in Fig. 2, which can specifically answer
For in various electronic equipments.
As shown in figure 5, the above-mentioned device 500 for being used for transmission data of the present embodiment comprises determining that unit 501, configuration is used
In it is determining carry out data transmission with data receiver used in destinations traffic agreement and data receiver to be transmitted to above-mentioned
The target category of target data;Generation unit 502 is configured to call match with above-mentioned destinations traffic agreement first to connect
Mouth, third interface, call the second interface to match simultaneously with above-mentioned destinations traffic agreement and above-mentioned target category, and utilization is above-mentioned
First interface, above-mentioned second interface and above-mentioned third interface, are encapsulated as target packet for above-mentioned target data, wherein above-mentioned
First interface, above-mentioned second interface, above-mentioned third interface be respectively used to generate the packet header of above-mentioned target packet, payload and
Packet tail;Transmission unit 503 is configured to send above-mentioned target packet to above-mentioned data receiver.
In some optional implementations of the present embodiment, above-mentioned generation unit 502 can further be configured to from
In the set of interfaces prestored, call the first interface and third interface to match with above-mentioned destinations traffic agreement, and call with
The second interface that above-mentioned destinations traffic agreement and above-mentioned target category match simultaneously.
In some optional implementations of the present embodiment, which can also include extraction unit, the first parsing list
Member and be included into unit (not shown).Wherein, said extracted unit may be configured to extract multiple configuration files, each
Configuration file record have the package head format information of the data packet for meeting communication protocol a kind of, packet tail format information and at least one have
Imitate load format information.Above-mentioned first resolution unit may be configured to for each configuration file, respectively to configuration text
Package head format information that part is recorded, each payload format information, packet tail format information are parsed, and are generated and are corresponded to
, first interface, at least one second interface, the third interface to match with the configuration file.The above-mentioned unit that is included into can match
It sets for the interface to match with each communication protocol to be included into set of interfaces.
In some optional implementations of the present embodiment, above-mentioned generation unit 502 may include extraction module, input
Module and generation module (not shown).Wherein, said extracted module may be configured to extract preset packet header parameter letter
Breath and packet tail parameter information.Above-mentioned input module, which may be configured to above-mentioned packet header parameter information being input to above-mentioned first, to be connect
Mouthful, above-mentioned target data is input to above-mentioned second interface, above-mentioned packet tail parameter information is input to above-mentioned third interface, respectively
Generate packet header, payload and packet tail.Above-mentioned generation module may be configured to successively by packet header generated, payload and
The splicing of packet tail, generates target packet.
In some optional implementations of the present embodiment, above-mentioned packet header parameter information includes the first address in packet header, packet
Value, the above-mentioned packet header parameter of head parameter are empty relative to the storage of the offset address of first address and the data type of above-mentioned packet header parameter
Between size, above-mentioned packet tail parameter information include verification mode mark and verification initial position.
In some optional implementations of the present embodiment, which can also include that verification unit and the second parsing are single
First (not shown).Wherein, above-mentioned verification unit may be configured in response to receiving above-mentioned data receiver transmission
Data packet to be resolved, the packet tail of the first address in the packet header based on above-mentioned data packet to be resolved and above-mentioned data packet to be resolved, to upper
Data packet to be resolved is stated to be verified.Above-mentioned second resolution unit may be configured in response to the above-mentioned data packet to be resolved of determination
By verification, the 4th interface to match with above-mentioned destinations traffic agreement is called, using above-mentioned 4th interface to above-mentioned to be resolved
The packet header of data packet is parsed, and determines the packet header parameter information of above-mentioned data packet to be resolved and the packet of above-mentioned data packet to be resolved
The length of head;The address for the above-mentioned length of first address for deviating the packet header of above-mentioned data packet to be resolved is determined as above-mentioned number to be resolved
According to the first address of the payload of packet, with the payload of the above-mentioned data packet to be resolved of determination;It calls and is assisted with above-mentioned destinations traffic
It discusses the 5th interface to match to parse the payload of above-mentioned data packet to be resolved, determines above-mentioned data packet to be resolved
The value of parameters in payload.
The device provided by the above embodiment of the application carries out data with data receiver by the way that determination unit 502 is determining
The target category of destinations traffic agreement and the target data to be passed for transporting to the data receiver used in transmitting then generates single
Member 502 calls first interface, the third interface to match with the destinations traffic agreement, calls and the destinations traffic agreement and the mesh
The mark classification second interface that matches simultaneously, using the first interface, the second interface and the third interface by the target data
It is encapsulated as target packet, last transmission unit 503 sends the target packet to the data receiver, so as to be based on connecing
The matching of mouth and destinations traffic agreement, target data is encapsulated as to meet the target packet of destinations traffic agreement, is not required to very important person
Work carries out writing for the data packet format for meeting destinations traffic agreement, to improve the flexibility of data transmission.
Below with reference to Fig. 6, it illustrates the computer systems 600 for the electronic equipment for being suitable for being used to realize the embodiment of the present application
Structural schematic diagram.Electronic equipment shown in Fig. 6 is only an example, function to the embodiment of the present application and should not use model
Shroud carrys out any restrictions.
As shown in fig. 6, computer system 600 includes central processing unit (CPU) 601, it can be read-only according to being stored in
Program in memory (ROM) 602 or be loaded into the program in random access storage device (RAM) 603 from storage section 608 and
Execute various movements appropriate and processing.In RAM 603, also it is stored with system 600 and operates required various programs and data.
CPU 601, ROM 602 and RAM 603 are connected with each other by bus 604.Input/output (I/O) interface 605 is also connected to always
Line 604.
I/O interface 605 is connected to lower component: the importation 606 including keyboard, mouse etc.;It is penetrated including such as cathode
The output par, c 607 of spool (CRT), liquid crystal display (LCD) etc. and loudspeaker etc.;Storage section 608 including hard disk etc.;
And the communications portion 609 of the network interface card including LAN card, modem etc..Communications portion 609 via such as because
The network of spy's net executes communication process.Driver 610 is also connected to I/O interface 605 as needed.Detachable media 611, such as
Disk, CD, magneto-optic disk, semiconductor memory etc. are mounted on as needed on driver 610, in order to read from thereon
Computer program be mounted into storage section 608 as needed.
Particularly, in accordance with an embodiment of the present disclosure, it may be implemented as computer above with reference to the process of flow chart description
Software program.For example, embodiment of the disclosure includes a kind of computer program product comprising be carried on computer-readable medium
On computer program, which includes the program code for method shown in execution flow chart.In such reality
It applies in example, which can be downloaded and installed from network by communications portion 609, and/or from detachable media
611 are mounted.When the computer program is executed by central processing unit (CPU) 601, limited in execution the present processes
Above-mentioned function.It should be noted that computer-readable medium described herein can be computer-readable signal media or
Computer readable storage medium either the two any combination.Computer readable storage medium for example can be --- but
Be not limited to --- electricity, magnetic, optical, electromagnetic, infrared ray or semiconductor system, device or device, or any above combination.
The more specific example of computer readable storage medium can include but is not limited to: have one or more conducting wires electrical connection,
Portable computer diskette, hard disk, random access storage device (RAM), read-only memory (ROM), erasable type may be programmed read-only deposit
Reservoir (EPROM or flash memory), optical fiber, portable compact disc read-only memory (CD-ROM), light storage device, magnetic memory
Part or above-mentioned any appropriate combination.In this application, computer readable storage medium, which can be, any include or stores
The tangible medium of program, the program can be commanded execution system, device or device use or in connection.And
In the application, computer-readable signal media may include in a base band or the data as the propagation of carrier wave a part are believed
Number, wherein carrying computer-readable program code.The data-signal of this propagation can take various forms, including but not
It is limited to electromagnetic signal, optical signal or above-mentioned any appropriate combination.Computer-readable signal media can also be computer
Any computer-readable medium other than readable storage medium storing program for executing, the computer-readable medium can send, propagate or transmit use
In by the use of instruction execution system, device or device or program in connection.Include on computer-readable medium
Program code can transmit with any suitable medium, including but not limited to: wireless, electric wire, optical cable, RF etc., Huo Zheshang
Any appropriate combination stated.
Flow chart and block diagram in attached drawing are illustrated according to the system of the various embodiments of the application, method and computer journey
The architecture, function and operation in the cards of sequence product.In this regard, each box in flowchart or block diagram can generation
A part of one module, program segment or code of table, a part of the module, program segment or code include one or more use
The executable instruction of the logic function as defined in realizing.It should also be noted that in some implementations as replacements, being marked in box
The function of note can also occur in a different order than that indicated in the drawings.For example, two boxes succeedingly indicated are actually
It can be basically executed in parallel, they can also be executed in the opposite order sometimes, and this depends on the function involved.Also it to infuse
Meaning, the combination of each box in block diagram and or flow chart and the box in block diagram and or flow chart can be with holding
The dedicated hardware based system of functions or operations as defined in row is realized, or can use specialized hardware and computer instruction
Combination realize.
Being described in unit involved in the embodiment of the present application can be realized by way of software, can also be by hard
The mode of part is realized.Described unit also can be set in the processor, for example, can be described as: a kind of processor packet
Include determination unit, generation unit and transmission unit.Wherein, the title of these units is not constituted under certain conditions to the unit
The restriction of itself, for example, determination unit is also described as, " determining and data receiver carries out data transmission used mesh
Mark the unit of the target category of communication protocol and the target data to be passed for transporting to data receiver ".
As on the other hand, present invention also provides a kind of computer-readable medium, which be can be
Included in device described in above-described embodiment;It is also possible to individualism, and without in the supplying device.Above-mentioned calculating
Machine readable medium carries one or more program, when said one or multiple programs are executed by the device, so that should
Device: it is determining carry out data transmission with data receiver used in destinations traffic agreement and the data receiver to be passed of transporting to
The target category of target data;First interface, the third interface to match with the destinations traffic agreement is called, is called and the target
The second interface that communication protocol and the target category match simultaneously, is connect using the first interface, the second interface and the third
Mouthful, which is encapsulated as target packet, wherein the first interface, the second interface, the third interface are respectively used to
Generate packet header, payload and the packet tail of the target packet;The target packet is sent to the data receiver.
Above description is only the preferred embodiment of the application and the explanation to institute's application technology principle.Those skilled in the art
Member is it should be appreciated that invention scope involved in the application, however it is not limited to technology made of the specific combination of above-mentioned technical characteristic
Scheme, while should also cover in the case where not departing from foregoing invention design, it is carried out by above-mentioned technical characteristic or its equivalent feature
Any combination and the other technical solutions formed.Such as features described above has similar function with (but being not limited to) disclosed herein
Can technical characteristic replaced mutually and the technical solution that is formed.