Specific embodiment
Example embodiments are described in detail here, and the example is illustrated in the accompanying drawings.Following description is related to
When attached drawing, unless otherwise indicated, the same numbers in different drawings indicate the same or similar elements.Following exemplary embodiment
Described in embodiment do not represent all embodiments consistent with the application.On the contrary, they be only with it is such as appended
The example of the consistent device and method of some aspects be described in detail in claims, the application.
It is only to be not intended to be limiting the application merely for for the purpose of describing particular embodiments in term used in this application.
It is also intended in the application and the "an" of singular used in the attached claims, " described " and "the" including majority
Form, unless the context clearly indicates other meaning.It is also understood that term "and/or" used herein refers to and wraps
It may be combined containing one or more associated any or all of project listed.
It will be appreciated that though various information, but this may be described using term first, second, third, etc. in the application
A little information should not necessarily be limited by these terms.These terms are only used to for same type of information being distinguished from each other out.For example, not departing from
In the case where the application range, the first information can also be referred to as the second information, and similarly, the second information can also be referred to as
One information.Depending on context, word as used in this " if " can be construed to " ... when " or " when ...
When " or " in response to determination ".
The embodiment of the present application can be applied in NIC driver, wherein the NIC driver is located at operating system
User's state space.
In the embodiment of the present application, NIC driver can be for based on DPDK (Data Plane Development
Kit, data plane development kit) driver.DPDK is that a kind of function library of high speed data processing and driving are gathered, can be with
Data processing performance and handling capacity is greatly improved, improves the working efficiency of data plane application program.
Illustratively, which can include but is not limited to linux system.
Illustratively, electronic equipment locating for the NIC driver in the present embodiment can include but is not limited to service
Device, such as the biggish server of packet throughput.
In the present embodiment, NIC driver can be used for connecting network interface card and target service process, such as the equipment of Fig. 1
Shown in configuration diagram 1, the data between target service process, NIC driver and network interface card can pass through user's state space
Quick transmission channel transmitted so that the transmission process of data can realize number with workaround system kernel state space
According to bottom transmission optimization, improve the performance of the electronic equipment of big handling capacity, reduce the utilization rate of CPU in equipment.
Illustratively, target service process can be the application program with specified services processing logic, for example, can lead to
It crosses target business process and carries out transcoding processing.
Network interface card is also named " network adapter ", and full name in English is " Network Interface Card ", referred to as " NIC ", net
Card is one of component most basic in local area network, it is the hardware device for connecting computer and network.Either twisted pair line connection,
Coaxial cable connection or optical fiber connection, it is necessary to the communication of data is just able to achieve by means of network interface card.Network interface card is according to data link
Layer control is to divide including Ethernet card, token ring network interface card, ATM (Asynchronous Transfer Mode, asynchronous transmission mould
Formula) network interface card etc.;Classifying according to physical layer has wireless network card, RJ-45 network interface card, coaxial cable network interface card, light network interface card etc., this implementation
Example to the concrete type of network interface card with no restriction.
It should be noted that quickly transmission channel can encapsulate in such a way that system is called, or pass through privately owned association
View encapsulation, the present embodiment to this with no restriction.
Equipment configuration diagram based on Fig. 1, the mistake that NIC driver is carried out data transmission by following embodiment
Journey is illustrated:
With reference to Fig. 2, a kind of step of the embodiment of the method for data receiver shown in one exemplary embodiment of the application is shown
Rapid flow chart, can specifically include following steps:
Step 101, the target data of network interface card write-in is read from network interface card shared drive.
Illustratively, target data can be for based on udp protocol, Transmission Control Protocol (Transmission Control
Protocol, transmission control protocol) etc. agreements data, which may include audio, video data, signaling data etc..
In this step, network interface card shared drive is NIC driver and the memory buffer positioned at network interface card that network interface card is shared
Area.Illustratively, network interface card shared drive may include FIFO (First Input First Output, first in first out) buffering
Area, buffer circle Ring Buffer (when using to the end of buffer area, start the cycle over use from Buffer again
Buffer area) etc..
It should be noted that network interface card shared drive belongs to the memory of network interface card, it is both not belonging to kernel state space, has also been not belonging to
User's state space, it belongs to hardware buffer, is network interface card and the buffer area that NIC driver is shared.In trawl performance initialization
When, a network interface card shared drive is distributed in the memory of network interface card, this network interface card shared drive is to receive data to network interface card to make
, due to being to transmit data to the DMA of network interface card (Direct Memory Access, direct memory access), so net
Card shared drive can be the continuous memory of physics.
A kind of scene that possible network interface card receives data is as follows in the present embodiment: data packet packet on cable first by
Network interface card obtains, and network interface card can check CRC (Cyclic Redundancy Check, the cyclic redundancy check) verification of packet, guarantees
Then the integrality of data is removed packet, frame frame is obtained.Network interface card can also check the target MAC (Media Access Control) address in MAC packet,
If with the MAC Address of this network interface card it is different if abandon (except promiscuous mode).Network interface card by frame copy to network interface card it is shared in
Deposit, when the data in network interface card shared drive are a complete data packets, network interface card trigger hardware interrupts or software interrupt (if it is
Ring Buffer then triggers software interrupt), to notify NIC driver to receive target data.
After NIC driver detects interruption, then target data is read from network interface card shared drive.In a kind of possibility
Embodiment in, NIC driver can come out target data copies, and execute step 102.
Step 102, the decapsulation information of the target data is determined.
The NIC driver of the present embodiment can integrate OSI (Open System Interconnect, open system
Interconnection) interrelated logic of data link layer, network layer and transport layer in reference model, complete Correlation method for data processing function.
The present embodiment can be applied to the scene of data decapsulation, can first pass through the solution that step 102 obtains target data
Packaging information.In one embodiment, decapsulation information can be obtained by obtaining the control information that target data carries.
As an example, decapsulation information can include but is not limited to: destination slogan, purpose physical address, purpose
The information such as IP address.
Wherein, port numbers are for marking port.Port includes physical port and logic port, and physical port is for connecting
Interface between physical equipment, logic port are the ports for being used for Differentiated Services in logic.Port in ICP/IP protocol is exactly
Logic port distinguishes different services by different logic ports.It is compiled by 16bit the port of one IP address
Number, it can have up to 65536 ports.Illustratively, the destination slogan in the present embodiment can be the port of logic port
Number, the logic port is for distinguishing different business process.
Address, also known as network interface card are physically for physical address, that is, MAC (Media Access Control, medium access control)
Location refers to the unique address of the whole network being solidificated in network interface card EPROM (a kind of flash chip, usually can be erasable by program),
It is that host is identified by physical address during the physical transfer of network bottom layer.For example, the physical address of Ethernet card
Size is 48bit (bit), and first 24 are supplier numbers, and latter 24 are numbered for network interface card.
IP address (Internet Protocol Address, Internet protocol address) is a kind of system that IP agreement provides
One address format, it is one logical address of each network and each host assignment on internet, is shielded with this
The difference of physical address.
Step 103, according to the decapsulation information, the target data is decapsulated.
In this step, NIC driver can decapsulate target data according to decapsulation information.
In a kind of possible embodiment, the process of decapsulation may include checking procedure, illustratively, the verification
Journey at least may include following process:
Purpose physics address check, with judge the purpose physical address whether be network interface card physical address.
Purpose IP address verification, with judge the destination IP address whether be locating host IP address.
Port numbers verification, to judge whether the destination slogan is registered port numbers.
Verification and verification, with verify the target data verification and whether correctly.
It illustratively, can be by the purpose physical address of acquisition and the object of network interface card when carrying out purpose physics address check
Reason address is matched, and judges whether the two is consistent, if unanimously, verification passes through, continues to execute the mistake of purpose IP address verification
Journey;If inconsistent, the target data is abandoned.
It should be noted that the process of above-mentioned purpose physical address verification is not limited to execute in NIC driver,
It can be executed in network interface card, when network interface card judges purpose physical address for the physical address of this network interface card, then to network interface card shared drive
Target data is written, otherwise abandons the target data.
It, can host locating for the purpose IP address and NIC driver by acquisition when carrying out purpose IP address verification
IP address matched, whether consistent both judge, if unanimously, verification passes through, continue to execute the process of port numbers verification;
If inconsistent, the target data is abandoned.
In a verification scene, the process of port numbers verification may include judging whether destination slogan is registered
Port numbers.Wherein, registered port numbers refer to the port numbers registered in NIC driver, the registered port numbers
It can be carried out data transmission by quick transmission channel for characterizing the corresponding business process of the port numbers.
It is above-mentioned to judge whether destination slogan is registered port numbers in a kind of possible embodiment, it can wrap
Include following sub-step:
The destination slogan is searched from registered port numbers list;If searching successfully, the destination slogan is determined
For registered port numbers;If searching failure, determining the destination slogan not is registered port numbers.
Specifically, NIC driver can safeguard a registered port numbers list, recording in the registered port numbers list has
Multiple registered port numbers.When purpose physics address check and purpose IP address verification all pass through, NIC driver
During carrying out port numbers verification, destination slogan can be searched in registered port numbers list, if searching successfully, table
Show that the destination slogan is the port numbers that target service process has been registered to NIC driver;If searching failure, mesh is determined
Port numbers be the port numbers that do not register.
In a kind of possible embodiment, registered port numbers list can generate in the following way:
The registration information that each business process is written in preset public buffer area is received, the registration information includes described
The corresponding port numbers of business process;The port numbers of registration are recorded into port numbers list.
The present embodiment can preset a public buffer area for being registered for business process, illustratively, should
Public buffer area can be fifo queue or other common buffer.
When business process is needed through quick transmission channel to transmit data, can be infused in NIC driver
Volume, one of registration process includes the registration information being written in public buffer area.As an example, the registration information is extremely
It less may include the corresponding port numbers of business process.After NIC driver receives the registration information, then by the end of registration
It is safeguarded in slogan write-in port numbers list.
When business process is not needed using quick transmission channel, then can send to NIC driver includes port numbers
Log-off message, NIC driver can delete corresponding port numbers according to the log-off message from port numbers list.
For business process, it can be decided whether to infuse to NIC driver according to the type of service of its processing
Volume port numbers, for example, for the business process of processing UDP message packet, then it can be to NIC driver registered port numbers.
, can with the verification of verification object data and whether correctly during above-mentioned verification and (checksum) are verified.
Checksum refers to the cumulative of transmission digit, and when transfer is finished, recipient can judge whether to be connected to according to this numerical value
All data.If values match, illustrate that transmission has been completed.In a kind of possible realization, NIC driver
By received target data (including inspection and field) by the complement code and operation of the same method progress 1 of sender, cumulative knot
Fruit negates code again.If obtained result is 0, indicate that transmission is correct;Otherwise, illustrate that transmission has mistake.
Step 104, when passed the verification, then the target data of decapsulation is sent in target service process.
In this step, when the check results of above-mentioned checking procedure be all verification by (verifying successfully) result when, then net
The target data of decapsulation can be sent in the corresponding target service process of destination slogan by card driver, to complete to solve
Encapsulation process.
In the present embodiment, the target of network interface card write-in is read positioned at the NIC driver of user's state space of operating system
After data, the decapsulation information comprising destination slogan that available target data carries, and according to decapsulation information pair
Target data is decapsulated.The process wherein decapsulated may include whether verification destination slogan is registered port numbers
Etc. checking procedures, when passed the verification, the target data of decapsulation is then sent in target service process by NIC driver.
To realize the process of data decapsulation in NIC driver, the performance of NIC driver is improved.And entire deblocking
Dress process is in the completion of user's state space, so that the kernel state space of the transmission workaround system of data, realizes data
Bottom transmission optimization, the performance of lifting means reduces the utilization rate of CPU in equipment.
With reference to Fig. 3, the embodiment of the method for another data receiver shown in one exemplary embodiment of the application is shown
Flow chart of steps is sent to the mistake of target service process in conjunction with the packet receiving timing diagram 1 of Fig. 4 in the present embodiment to target data
Cheng Jinhang more specific description (in Fig. 4, network interface card shared drive is not showed that), the present embodiment can specifically include following step
It is rapid:
Step 201, the target data of network interface card write-in is read from network interface card shared drive.
Step 202, the decapsulation information of the target data is determined.
As an example, decapsulation information can include but is not limited to: destination slogan, purpose physical address, purpose
The information such as IP address.
Step 203, according to the decapsulation information, the target data is decapsulated, wherein the decapsulation
Process includes checking procedure, and the checking procedure includes: whether the verification destination slogan is registered port numbers.
In this step, NIC driver can decapsulate target data according to decapsulation information.
In a kind of possible embodiment, the process of decapsulation may include checking procedure, illustratively, the verification
Journey at least may include following process:
Purpose physics address check, with judge the purpose physical address whether be network interface card physical address.
Purpose IP address verification, with judge the destination IP address whether be locating host IP address.
Port numbers verification, to judge whether the destination slogan is registered port numbers.
Verification and verification, with verify the target data verification and whether correctly.
Step 204, when passed the verification, user corresponding to the destination slogan is written into the target data of decapsulation
In shared drive, the core buffer that this driver is shared with target service process is saved as in the user sharing, by institute
State the target data that target service process reads the decapsulation from the user sharing memory.
In the present embodiment, NIC driver is carried out data transmission with target service process by user sharing memory.
Wherein, memory headroom that NIC driver creates in user's state space, sharing with business process is saved as in user sharing.
In one implementation, NIC driver can be created according to the process identification (PID) of port numbers or business process
Build the user sharing memory shared with business process.
After NIC driver decapsulates target data, it can search or create and be somebody's turn to do according to destination slogan
The corresponding user sharing memory of destination slogan, as the corresponding user sharing memory of target service process.It then will decapsulation
Target data be written in the user sharing memory.
For target service process, it can be read from its corresponding user sharing memory by way of poll
Then target data is handled the target data in packet receiving queue into the packet receiving queue of this process.Certain the present embodiment
It is not limited to this, NIC driver can also notify target service process to fetch into user sharing memory by informing mechanism
According to.
The present embodiment carries out two by the way that user sharing memory is arranged between NIC driver and target service process
Data transmission between person, the mode that shared drive is uniformly accessed into can reduce between NIC driver and target service process
The degree of coupling, the upgrading of NIC driver and logic Modification have substantially no effect on target service process, because of user sharing memory
Read-write mode it is constant, target service process substantially just do not have to change, with this promoted calculate equipment performance.
With reference to Fig. 5, the embodiment of the method for another data receiver shown in one exemplary embodiment of the application is shown
Flow chart of steps is sent to the mistake of target service process in conjunction with the packet receiving timing diagram 2 of Fig. 6 in the present embodiment to target data
Cheng Jinhang more specific description (in Fig. 6, network interface card shared drive is not showed that), the present embodiment can specifically include following step
It is rapid:
Step 301, the target data of network interface card write-in is read from network interface card shared drive.
Step 302, the decapsulation information of the target data is determined.
As an example, decapsulation information can include but is not limited to: destination slogan, purpose physical address, purpose
The information such as IP address.
Step 303, according to the decapsulation information, the target data is decapsulated, wherein the decapsulation
Process includes checking procedure, and the checking procedure includes: whether the verification destination slogan is registered port numbers.
In this step, NIC driver can decapsulate target data according to decapsulation information.
In a kind of possible embodiment, the process of decapsulation may include checking procedure, illustratively, the verification
Journey at least may include following process:
Purpose physics address check, with judge the purpose physical address whether be network interface card physical address.
Purpose IP address verification, with judge the destination IP address whether be locating host IP address.
Port numbers verification, to judge whether the destination slogan is registered port numbers.
Verification and verification, with verify the target data verification and whether correctly.
Step 304, when passed the verification, the corresponding packet receiving team of the destination slogan is written into the target data of decapsulation
In column, to read the target data from the packet receiving queue by the corresponding target service process of the destination slogan.
It in the present embodiment, can be directly by decapsulation after NIC driver decapsulates target data
Target data is written in the corresponding packet receiving queue of destination slogan, directly to read mesh from packet receiving queue by target service process
Mark data.
The difference of the embodiment of the present embodiment and Fig. 3 is: the present embodiment does not need to carry out by user sharing memory
Data transmission, NIC driver directly by the corresponding packet receiving queue of target data write-in destination slogan, reduce data
The number of copy improves the efficiency of transmission of target data.
With reference to Fig. 7, the embodiment of the method for another data receiver shown in one exemplary embodiment of the application is shown
Flow chart of steps, in the present embodiment, the packet receiving timing diagram 3 in conjunction with Fig. 8 are not registered port numbers to destination slogan
Data receiver scene is illustrated, and the present embodiment can be used for transmitting non-UDP message (such as the number of TCP and some other agreements
According to), it can specifically include following steps:
Step 401, the target data of network interface card write-in is read from network interface card shared drive.
Step 402, the decapsulation information of the target data is determined.
As an example, decapsulation information can include but is not limited to: destination slogan, purpose physical address, purpose
The information such as IP address.
Step 403, according to the decapsulation information, the target data is decapsulated, wherein the decapsulation
Process includes checking procedure, and the checking procedure includes: whether the verification destination slogan is registered port numbers.
In this step, NIC driver can decapsulate target data according to decapsulation information.
In a kind of possible embodiment, the process of decapsulation may include checking procedure, illustratively, the verification
Journey at least may include following process:
Purpose physics address check, with judge the purpose physical address whether be network interface card physical address.
Purpose IP address verification, with judge the destination IP address whether be locating host IP address.
Port numbers verification, to judge whether the destination slogan is registered port numbers.
Verification and verification, with verify the target data verification and whether correctly.
Step 404, when determining the destination slogan not is registered port numbers, the target data is sent to
The packet receiving queue for the kernel forwarding module being connect with this driver, to be passed through the target data by the kernel forwarding module
It is sent in the corresponding target service process of the destination slogan by Microsoft Loopback Adapter connected to it driving.
In the present embodiment, kernel forwarding module and Microsoft Loopback Adapter driving are in the kernel state space of operating system.Such as
Shown in the equipment architecture diagram 2 of Fig. 9, NIC driver and target service process can also carry out data by normal transmission channel
Transmission.When NIC driver determines that destination slogan is not registered port numbers, then pass through normal transmission channel for mesh
Mark data are sent in target service process.
When realizing, as shown in figure 9, target data can will be sent to connecing for kernel forwarding module by NIC driver
Queue is received, kernel forwarding module obtains target data from receiving queue, and target packet is sent to Microsoft Loopback Adapter driving.
Microsoft Loopback Adapter driving is located at data link layer in the present embodiment, by checking target MAC (Media Access Control) address judges whether it is oneself needs
The data of processing then abandon the target data if it find that MAC Address is inconsistent with oneself, unanimously just remove MAC information and send
Its IP address is judged to network layer (L3 agreement), it is then true according to the destination slogan of target data by transport layer (L4 agreement)
Surely it is which business process by the machine come processing target data, and target data is sent to mesh in such a way that system is called
It marks in business process.
The present embodiment can be adapted for data packet protocol stack is more complicated or the quantity of data packet is not too many number
According to transmitting scene, or the scene suitable for transmitting data failure by quick transmission channel, by kernel come processing target data,
The realization difficulty of the NIC driver of User space can be reduced.
With reference to Figure 10, the step for the embodiment of the method that a kind of data shown in one exemplary embodiment of the application are sent is shown
Rapid flow chart, in the present embodiment, in conjunction with Figure 11 give out a contract for a project timing diagram 1 to by quick transmission channel issue target data mistake
Journey is illustrated, and the present embodiment can specifically include following steps:
Step 501, for each registered port numbers in preset registered port numbers list, use corresponding to the registered port numbers
Family shared drive is polled, to determine target data that whether target service process is written in the user sharing memory.
In this step, the core buffer that NIC driver and target service process are shared is saved as in user sharing.
Illustratively, which can be identified with registered port numbers.
Wherein, registered port numbers are the port numbers that target service process is registered to NIC driver, which is used for
Characterize target service process.
A registered port numbers list can be safeguarded in NIC driver, have recorded one in the registered port numbers list
Or multiple registered port numbers, each registered port numbers have corresponding user sharing memory.NIC driver passes through to each note
Whether the corresponding user sharing memory of volume port numbers is polled, to judge the corresponding business process of the registered port numbers in the use
Target data is written in the shared drive of family.
In a kind of possible embodiment of the present embodiment, registered port numbers list can generate in the following way:
The registration information that each business process is written in preset public buffer area is received, the registration information includes described
The corresponding port numbers of business process;The port numbers of registration are recorded into port numbers list.
The present embodiment can preset a public buffer area for being registered for business process, illustratively, should
Public buffer area can be fifo queue or other common buffer.
When business process is needed through quick transmission channel to transmit data, can be infused in NIC driver
Volume, one of registration process includes the registration information being written in public buffer area.As an example, the registration information is extremely
It less may include the corresponding port numbers of business process.After NIC driver receives the registration information, then by the end of registration
Slogan is written in port numbers list as registered port numbers and is safeguarded.
When business process is not needed using quick transmission channel, then can send to NIC driver includes port numbers
Log-off message, NIC driver can delete corresponding port numbers according to the log-off message from port numbers list.
Step 502, the target data of target service process write-in is read from user sharing memory;
When NIC driver, which determines, has target data in user sharing memory, then read from the user sharing memory
Target data out.
Step 503, the corresponding packaging information of the target data is obtained;
In this step, NIC driver can obtain its corresponding packaging information according to target data.As one kind
Example, packaging information can include but is not limited to: source port number, destination slogan, source IP address, purpose IP address, source physics
Address and purpose physical address etc..
In a kind of possible embodiment of the present embodiment, step 503 may include following sub-step:
Sub-step S11 obtains the source port number, the destination slogan, the source IP that the target data carries
Address, the destination IP address and the source physical address.
It, can be with when target data is written in target service process in user sharing memory in a kind of possible scene
Carry the source port number (i.e. the corresponding port numbers of target service process) of the target data, destination slogan (will be sent to
Port numbers), source IP address (IP address of host i.e. where target service process), the purpose IP address (host that will be sent to
IP address) and information such as source physical address (MAC Address of Network Card of host i.e. where target service process).
Then NIC driver can obtain target data carrying when obtaining target data from user sharing memory
The information such as source port number, destination slogan, source IP address, purpose IP address and source physical address.
Sub-step S12 searches the destination IP address in preset cache table and executes sub-step if searching successfully
S13 executes sub-step S14 if searching failure.
Sub-step S13 obtains purpose physical address corresponding with the destination IP address from the cache table.
Sub-step S14 obtains the purpose object according to the destination IP address by the way of Address Resolution Protocol ARP
Manage address.
Illustratively, the mapping relations of multiple IP address with corresponding physical address be can store in cache table.Determine mesh
IP address after, the purpose IP address can be searched in cache table first and is directly obtained in cache table if searching successfully
Obtain purpose physical address corresponding with purpose IP address.It, can be according to the purpose IP address, using ARP if searching failure
The mode of (Address Resolution Protocol, address resolution protocol) obtains purpose physical address.
In one example, the working principle of ARP is: by the ARP request comprising purpose IP address when host transmission information
The All hosts being broadcast on network, and return message is received, purpose physical address is determined with this;Receiving should after returning to message
Purpose IP address and purpose physical address are stored in the cache table of the machine and retain certain time, and directly inquiry is slow when next time requests
Table is deposited to economize on resources.
Step 504, network interface card shared drive is written into the target data and the packaging information so that network interface card according to
The packaging information issues the target data.
It, can be by target data and encapsulation after NIC driver obtains target data and corresponding packaging information
Information is inserted in network interface card shared drive, wherein network interface card shared drive is the memory for the network interface card that NIC driver is shared with network interface card
Buffer area.
In a kind of possible embodiment, target data and corresponding packaging information are inserted net by NIC driver
Mode in card shared drive can be with are as follows: NIC driver is the header information that target data addition includes packaging information, structure
Framing frame, and copy frame to network interface card shared drive, it is handled by network interface card.
The frame not being fully finished (scarce CRC) is encapsulated as by network interface card after listening to network interface card shared drive write-in data
The data packet packet that can be sent, such as addition head synchronizing information and CRC check, are then sent out target data by cable
It sees off.
In the present embodiment, NIC driver is polled to the corresponding user sharing memory write-in number of targets of registered port numbers
After accordingly, the target data is read, and obtains the corresponding packaging information of target data, then believes target data and its encapsulation
Breath write-in network interface card shared drive, is sent target data according to packaging information by network interface card.Entire data transmission procedure with
Family state space is completed, and the kernel state space of operating system has been bypassed, and realizes the bottom transmission optimization of data, promotes trawl performance
The performance of program reduces the utilization rate of CPU in equipment.
With reference to Figure 12, the embodiment of the method that another data shown in one exemplary embodiment of the application are sent is shown
Flow chart of steps issues target data to by quick transmission channel in conjunction with the timing diagram 2 of giving out a contract for a project of Figure 13 in the present embodiment
Process is illustrated, and the present embodiment can specifically include following steps:
Step 601, when detecting that target data is written in network interface card shared drive in target service process, judge the target
Whether the corresponding port numbers of business process are registered port numbers.
In this step, network interface card shared drive is the core buffer for the network interface card that NIC driver is shared with network interface card.
In the present embodiment, target data, trawl performance can be directly written in target service process in network interface card shared drive
Program can detect whether target service process in network interface card shared drive is written target data by way of poll.Work as inspection
When measuring target data, then NIC driver can obtain source port number (i.e. target from the information that the target data carries
The port numbers of business process), then judge whether the corresponding port numbers of target service process are registered port numbers.
In a kind of possible embodiment of the present embodiment, judge the corresponding port numbers of target service process whether be
The step of registered port numbers may include following sub-step:
The corresponding port numbers of target service process are searched from registered port numbers list;If searching successfully, determining should
Port numbers are registered port numbers;If searching failure, determining the port numbers not is registered port numbers.
Specifically, NIC driver can safeguard a registered port numbers list, recording in the registered port numbers list has
Multiple registered port numbers.NIC driver can search the port of target service process in registered port numbers list
Number, if searching successfully, then it represents that the port numbers are the port numbers that target service process has been registered to NIC driver;If searching
Failure, then determine that the port numbers are the port numbers that do not register.
In a kind of possible embodiment, registered port numbers list can generate in the following way:
The registration information that each business process is written in preset public buffer area is received, the registration information includes described
The corresponding port numbers of business process;The port numbers of registration are recorded into port numbers list.
Step 602, if the corresponding port numbers of target service process are registered port numbers, the number of targets is obtained
According to corresponding packaging information;
It, then can be into when NIC driver detects that the corresponding port numbers of target service process are registered port numbers
One step obtains the corresponding packaging information of target data.As an example, packaging information can include but is not limited to: source port
Number, destination slogan, source IP address, purpose IP address, source physical address and purpose physical address.
In a kind of possible embodiment of the present embodiment, step 602 may include following sub-step:
Obtain the source port number, the destination slogan, the source IP address, the mesh that the target data carries
IP address and the source physical address;The destination IP address is searched in preset cache table, wherein the cache table
Store the mapping relations of multiple IP address with corresponding physical address;If searching successfully, obtained from the cache table and institute
State the corresponding purpose physical address of purpose IP address;If searching failure, according to the destination IP address, assisted using address resolution
The mode of view ARP obtains the purpose physical address.
Step 603, the network interface card shared drive is written into the packaging information, so that network interface card is according to the packaging information
Issue the target data.
In a kind of possible embodiment of the present embodiment, step 603 is specifically as follows:
The network interface card shared drive is written into the purpose physical address.
Since target service process is by target data and source port number, destination slogan, source IP address, destination IP
In address and source physical address write-in network interface card shared drive, then after NIC driver acquisition packaging information, it is only necessary to will
Purpose physical address is written in network interface card function memory, so as to reduce the number of data copy.
The difference of the embodiment of the present embodiment and Figure 10 is: target service process can be used as answering for NIC driver
With, directly access NIC driver.The present embodiment does not need to obtain target data, trawl performance by user sharing memory
After program obtains the purpose physical address of target data, it is only necessary to network interface card shared drive is written in purpose physical address, is reduced
The number of data copy improves the efficiency of transmission of target data.
With reference to Figure 14, the embodiment of the method that another data shown in one exemplary embodiment of the application are sent is shown
Flow chart of steps, in the present embodiment, in conjunction with Figure 15 give out a contract for a project timing diagram 3 by normal transmission channel send data scene into
Row explanation, the present embodiment can be used for transmitting non-UDP message (such as data of TCP and some other agreements), specifically can wrap
Include following steps:
Step 701, the target data that kernel forwarding module is sent is received.
The target data is the data that business process of the port numbers not in registered port numbers list is sent, the business into
Journey, which is used to drive to Microsoft Loopback Adapter, sends target data, target data to be forwarded in kernel forwarding module by Microsoft Loopback Adapter.
In the present embodiment, kernel forwarding module and kernel state of the Microsoft Loopback Adapter driving in operating system are empty
Between.
Step 702, the target data is written in network interface card shared drive, for network interface card processing.
As shown in figure 15, target service process calls (call) that target data is sent to kernel state space by system
In, kernel state space by transport layer (L4 agreement) in target data plus corresponding port number information (including source port number
And destination slogan), so that destination host distinguishes this purpose data, learning should specifically be handled by which task of the machine.
It is that target data adds IP address information (including source IP address and purpose IP address) in network layer (L3 agreement), enables data
Confirmation should reach some specific host, then pass through the adjoining Neighboring subsystem of data link layer and flow control
Subsystem is target data plus Microsoft Loopback Adapter driving is sent to after MAC Address, and target data is sent out in then Microsoft Loopback Adapter driving
It send to kernel forwarding module, target data is written in the transmit queue of this module kernel forwarding module, and NIC driver can
To obtain target data from the transmit queue of the kernel forwarding module, and target data is inserted in network interface card shared drive, with
It is read for network interface card.
The present embodiment can be adapted for data packet protocol stack is more complicated or the quantity of data packet is not too many number
According to transmitting scene, or the scene suitable for transmitting data failure by quick transmission channel, target data is carried out by kernel
Transmission, it is possible to reduce the realization difficulty of the NIC driver of User space.
Difference is shown using quick transmission channel and the data transfer mode in normal transmission channel, Figure 16 according to above-mentioned
Test and comparison schematic diagram in data transmission scheme, in the Single NIC machine of same performance, the longitudinal axis is the CPU free time hundred of system
Divide ratio, horizontal axis is the PPS (page per second, quantity per second of giving out a contract for a project) of the transmitting-receiving of data packet, and wherein packet size is 100 words
Section.It can see from the data of Figure 16, when the server CPU free time is 50% or more, using normal transmission channel (system
Method of calling) 1,500,000 PPS or so can be gone to.And 10,000,000 PPS can be gone to using quick transmission channel, handling capacity is reached close to 7
Times.It estimates in idle lower situation, has bigger multiple and increase.But generally still need to reserve some CPU to business
It uses, does not take into account that the case where exhausting CPU.
In addition, quickly transmission channel and it is existing certain support RDMA (Remote Direct Memory Access, remotely
Immediate data access) scheme performance it is suitable.
Corresponding with the embodiment of preceding method, present invention also provides data sink embodiments and data to send
Installation practice.
Figure 17 is please referred to, a kind of knot of data sink embodiment shown in one exemplary embodiment of the application is shown
Structure block diagram, described device include in NIC driver, and the NIC driver is located at user's state space of operating system, institute
Stating device includes:
Data read module 801, for reading the target data of network interface card write-in from network interface card shared drive, wherein described
Network interface card shared drive is the core buffer for the network interface card that this driver and network interface card are shared;
Information determination module 802 is decapsulated, for determining the decapsulation information of the target data, the decapsulation information
Including destination slogan;
Decapsulation module 803, for being decapsulated to the target data, wherein institute according to the decapsulation information
The process for stating decapsulation includes checking procedure, and the checking procedure includes: whether the verification destination slogan is registered
Port numbers;
Data transmission blocks 804, for when passed the verification, then by the target data of decapsulation be sent to target service into
Cheng Zhong.
In a kind of possible embodiment of the application, the data transmission blocks 804 may include following submodule:
Submodule is written in user sharing memory, corresponding to the destination slogan for being written the target data of decapsulation
User sharing memory in, the core buffer that this driver and target service process are shared is saved as in the user sharing,
The target data of the decapsulation is read from the user sharing memory by the target service process.
In the alternatively possible embodiment of the application, the data transmission blocks 804 may include following submodule
Block:
Submodule is written in packet receiving queue, and the corresponding packet receiving of the destination slogan is written in the target data for that will decapsulate
In queue, to read the target data from the packet receiving queue by the corresponding target service process of the destination slogan.
In a kind of possible embodiment of the application, the decapsulation information further includes purpose physical address and mesh
IP address;
The decapsulation module includes following submodule:
Physical address verifies submodule, for carrying out purpose physics address check, to judge that the purpose physical address is
The no physical address for network interface card;
IP Address Velocity submodule, for carrying out purpose IP address verification, to judge whether the destination IP address is institute
Locate the IP address of host;
Verification and verification submodule, for being verified and being verified, to verify the verification and whether just of the target data
Really.
In a kind of possible embodiment of the application, the decapsulation module includes following submodule:
Port numbers judging submodule, for searching the destination slogan, the registration end from registered port numbers list
It include multiple registered port numbers in slogan list;If searching successfully, determine that the destination slogan is registered end
Slogan;If searching failure, determining the destination slogan not is registered port numbers.
In a kind of possible embodiment of the application, the registered port numbers list generates in the following way:
The registration information that each business process is written in preset public buffer area is received, the registration information includes described
The corresponding port numbers of business process;
The port numbers of registration are recorded into port numbers list.
In a kind of possible embodiment of the application, if the destination slogan is not registered port numbers, institute
State device further include:
Kernel sending module, for the target data to be sent to the kernel forwarding module connecting with this driver
Packet receiving queue, the target data is sent to institute via Microsoft Loopback Adapter connected to it driving by the kernel forwarding module
It states in the corresponding target service process of destination slogan;
Wherein, the kernel forwarding module and Microsoft Loopback Adapter driving are in the kernel state space of operating system.
Figure 18 is please referred to, a kind of knot of data sending device embodiment shown in one exemplary embodiment of the application is shown
Structure block diagram, described device include in NIC driver, and the NIC driver is located at user's state space of operating system, institute
Stating device includes:
Poller module 901, for being directed to each registered port numbers in preset registered port numbers list, to the registered port numbers
Corresponding user sharing memory is polled, to determine mesh that whether target service process is written in the user sharing memory
Mark data, wherein the core buffer that this driver is shared with the target service process is saved as in the user sharing, it should
Registered port numbers are the port numbers that the target service process is registered to this driver;If so, invocation target reading data
Module;
Target data read module 902, for reading the target data;
Packaging information obtains module 903, for obtaining the corresponding packaging information of the target data;
Information writing module 904, for network interface card shared drive to be written in the target data and the packaging information, with
So that network interface card issues the target data according to the packaging information, wherein the network interface card shared drive be this driver with
The core buffer of the shared network interface card of network interface card.
In a kind of possible embodiment of the application, the packaging information include: source port number, destination slogan,
Source IP address, purpose IP address, source physical address and purpose physical address;
The packaging information obtains module 903 and is specifically used for:
Obtain the source port number, the destination slogan, the source IP address, the mesh that the target data carries
IP address and the source physical address;
The destination IP address is searched in preset cache table, wherein the cache table store multiple IP address with it is right
The mapping relations for the physical address answered;
If searching successfully, purpose physical address corresponding with the destination IP address is obtained from the cache table;
If searching failure, according to the destination IP address, the purpose is obtained by the way of Address Resolution Protocol ARP
Physical address.
Figure 19 is please referred to, another data sending device embodiment shown in one exemplary embodiment of the application is shown
Structural block diagram, described device include in NIC driver, and the NIC driver is located at user's state space of operating system,
Described device includes:
Port numbers judgment module 1001 detects that number of targets is written in network interface card shared drive in target service process for working as
According to when, judge whether the corresponding port numbers of target service process are registered port numbers;Wherein, the network interface card shared drive
For the core buffer for the network interface card that this driver and network interface card are shared;If so, packaging information is called to obtain module;
Packaging information obtains module 1002, for obtaining the corresponding packaging information of the target data;
Packaging information writing module 1003, for the network interface card shared drive to be written in the packaging information, so that net
Card issues the target data according to the packaging information.
In a kind of possible embodiment of the application, packaging information writing module 1003 is specifically used for:
The network interface card shared drive is written into the purpose physical address.
Figure 20 is please referred to, a kind of knot of data processing system embodiment shown in one exemplary embodiment of the application is shown
Structure block diagram, the data processing system include NIC driver 10 and target service in operating system user state space
Process 20, the NIC driver 10 can be realized the step in above method embodiment when executing program.
For apparatus and system embodiment, since it corresponds essentially to embodiment of the method, so related place referring to
The part of embodiment of the method illustrates.
The apparatus embodiments described above are merely exemplary, wherein described, unit can as illustrated by the separation member
It is physically separated with being or may not be, component shown as a unit may or may not be physics list
Member, it can it is in one place, or may be distributed over multiple network units.It can be selected according to the actual needs
In some or all of the modules realize the purpose of application scheme.Those of ordinary skill in the art are not paying creative labor
In the case where dynamic, it can understand and implement.
Present invention also provides a kind of electronic equipment, including memory, NIC driver and storage are on a memory simultaneously
The computer program that can be run in NIC driver, the NIC driver realize the above method when executing described program
Step in embodiment.
Present invention also provides a kind of computer readable storage mediums, are stored thereon with computer program, described program quilt
Step when execution in implementation method embodiment.
Theme described in this specification and the embodiment of feature operation can be realized in the following: Fundamental Digital Circuit,
Computer software or firmware, the computer including structure disclosed in this specification and its structural equivalents of tangible embodiment are hard
The combination of part or one or more of which.The embodiment of theme described in this specification can be implemented as one or
Multiple computer programs, i.e. coding are executed by data processing equipment on tangible non-transitory program carrier or are controlled at data
Manage one or more modules in the computer program instructions of the operation of device.Alternatively, or in addition, program instruction can be with
It is coded on manually generated transmitting signal, such as electricity, light or electromagnetic signal that machine generates, the signal are generated will believe
Breath encodes and is transferred to suitable receiver apparatus to be executed by data processing equipment.Computer storage medium can be machine can
Read storage equipment, machine readable storage substrate, random or serial access memory equipment or one or more of which group
It closes.
Processing described in this specification and logic flow can by execute one of one or more computer programs or
Multiple programmable calculators execute, to execute corresponding function by the way that output is operated and generated according to input data.Institute
It states processing and logic flow can also be by dedicated logic circuit-such as FPGA (field programmable gate array) or ASIC (dedicated collection
At circuit) Lai Zhihang, and device also can be implemented as dedicated logic circuit.
The computer for being suitable for carrying out computer program includes, for example, general and/or special microprocessor or it is any its
The central processing unit of his type.In general, central processing unit will refer to from read-only memory and/or random access memory reception
Order and data.The basic module of computer includes central processing unit for being practiced or carried out instruction and for storing instruction
With one or more memory devices of data.In general, computer will also be including one or more great Rong for storing data
Amount storage equipment, such as disk, magneto-optic disk or CD etc. or computer will be coupled operationally with this mass-memory unit
To receive from it data or have both at the same time to its transmission data or two kinds of situations.However, computer is not required to have in this way
Equipment.In addition, computer can be embedded in another equipment, such as car-mounted terminal, mobile phone, personal digital assistant
(PDA), Mobile audio frequency or video player, game console, global positioning system (GPS) receiver or such as general serial
The portable memory apparatus of bus (USB) flash drive, names just a few.
It is suitable for storing computer program instructions and the computer-readable medium of data including the non-volatile of form of ownership
Memory, medium and memory devices, for example including semiconductor memory devices (such as EPROM, EEPROM and flash memory device),
Disk (such as internal hard drive or removable disk), magneto-optic disk and CD ROM and DVD-ROM disk.Processor and memory can be by special
It is supplemented or is incorporated in dedicated logic circuit with logic circuit.
Although this specification includes many specific implementation details, these are not necessarily to be construed as the model for limiting any invention
It encloses or range claimed, and is primarily used for describing the feature of the specific embodiment of specific invention.In this specification
Certain features described in multiple embodiments can also be combined implementation in a single embodiment.On the other hand, individually implementing
Various features described in example can also be performed separately in various embodiments or be implemented with any suitable sub-portfolio.This
Outside, although feature can work in certain combinations as described above and even initially so be claimed, institute is come from
One or more features in claimed combination can be removed from the combination in some cases, and claimed
Combination can be directed toward the modification of sub-portfolio or sub-portfolio.
Similarly, although depicting operation in the accompanying drawings with particular order, this is understood not to require these behaviour
Make the particular order shown in execute or sequentially carry out or require the operation of all illustrations to be performed, to realize desired knot
Fruit.In some cases, multitask and parallel processing may be advantageous.In addition, the various system modules in above-described embodiment
Separation with component is understood not to be required to such separation in all embodiments, and it is to be understood that described
Program assembly and system can be usually integrated in together in single software product, or be packaged into multiple software product.
The specific embodiment of theme has been described as a result,.Other embodiments are within the scope of the appended claims.?
In some cases, the movement recorded in claims can be executed in different order and still realize desired result.This
Outside, the processing described in attached drawing and it is nonessential shown in particular order or sequential order, to realize desired result.In certain realities
In existing, multitask and parallel processing be may be advantageous.
The foregoing is merely the preferred embodiments of the application, not to limit the application, all essences in the application
Within mind and principle, any modification, equivalent substitution, improvement and etc. done be should be included within the scope of the application protection.