CN101150488B - A receiving method for zero copy network packet - Google Patents

A receiving method for zero copy network packet Download PDF

Info

Publication number
CN101150488B
CN101150488B CN 200710177373 CN200710177373A CN101150488B CN 101150488 B CN101150488 B CN 101150488B CN 200710177373 CN200710177373 CN 200710177373 CN 200710177373 A CN200710177373 A CN 200710177373A CN 101150488 B CN101150488 B CN 101150488B
Authority
CN
China
Prior art keywords
buffer
message
buffering area
control structure
kernel
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN 200710177373
Other languages
Chinese (zh)
Other versions
CN101150488A (en
Inventor
历军
聂华
曾宇
刘朝辉
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Dawning Information Industry Beijing Co Ltd
Dawning Information Industry Co Ltd
Original Assignee
Dawning Information Industry Beijing Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Dawning Information Industry Beijing Co Ltd filed Critical Dawning Information Industry Beijing Co Ltd
Priority to CN 200710177373 priority Critical patent/CN101150488B/en
Publication of CN101150488A publication Critical patent/CN101150488A/en
Application granted granted Critical
Publication of CN101150488B publication Critical patent/CN101150488B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Computer And Data Communications (AREA)

Abstract

The invention discloses a zero copy network message receiving method, which belongs to zero copy method fields that the memory of a user space is directly mapped into a DMA buffer of the network card. The invention adopts the following technical proposals: A. the application program opens the device interface by invoking the function provided by the interface repository; B. a message buffer is applied in the memory of the user space; C. a buffer control structure is constructed; D. the information from the buffer control structure is received through mapping of the memory; E. the received message data is directly DMA transferred into the message receiving buffer; and F. the message data of the message receiving buffer is processed. The invention is applicable to the zero copy management method for receiving network data.

Description

A kind of receiving method for zero copy network packet
Technical field
The present invention relates to a kind of computer network data method of reseptance, particularly relate to a kind of receiving method for zero copy network packet that directly is mapped as internal memory network interface card DMA buffering area.
Background technology
What the computer operating system of prior art was used is layering thought, and network interface card drives in the inner nuclear layer operation, gives network interface card assignment message buffering area; Through the data in soft Interrupt Process message buffer and the application data district, and in soft Interrupt Process, realize Data Receiving when receiving message through protocol stack; So this network data receive mode; Though guaranteed the versatility in the general operation system, because the DRP data reception process of prior art need be passed through the kernel transmission, rather than user memory and network directly receive; So the application on the HVN that requires to transmit at a high speed, prior art can not satisfy the needs of application.
Summary of the invention
The present invention is directed in the prior art; Network interface card reception message will pass through kernel protocol stack and copy user's space to; Cause that packet receiving speed is low, waste system resource, can't satisfy HVN and use problem, provide a kind of and made application can directly visit network interface card DMA buffering area the rate request of data copy; Thereby greatly improve the network data inbound pacing, satisfy the Zero-copy method that HVN is used.
In order to realize the foregoing invention purpose, the present invention adopts following technical proposals:
A kind of receiving method for zero copy network packet, wherein, said method comprises that the function that following operating procedure: A, application call interface library provide opens equipment interface; B, open the equipment interface function and in the user's space internal memory, apply for the continuous internal memory of a slice, and pass to kernel to the buffering area first address and drive as message buffer; C, kernel drive according to buffering area first address and buffer size, structure buffer control structure, and pass to interface function to the physical address of control structure, and said structure comprises the physical address of each buffering area in information and the formation of message buffer formation; D, interface function obtain the information in the buffer control structure according to the address of buffer control structure through memory-mapped; E, NIC driver are got freebuf as the DMA buffering area that receives message from buffering sector row, and receive the message data that receives in the buffering area without the message that the direct DMA of kernel spacing is sent in the user memory; Message receives the message data in the buffering area in F, the application program processes user memory.
A kind of preferred receiving method for zero copy network packet; Wherein, the message among the said step B receives the length of buffering area formation and is specified by parameter, and the size of each buffering area is 2KB; For guaranteeing to be positioned on the continuous memory pages at the buffering area of user's space application; Save as shared drive in the application of interface library function, the concrete operations step among the said step B is: B1, interface library function application shared buffer, and be connected to shared buffer; B2, interface library function are passed to driving to the first address of shared buffer through system call.
Further preferred receiving method for zero copy network packet, wherein, the concrete operations step of said step C is: C1, kernel drive the size according to the buffer control structure of the size calculating needs of whole buffering area formation; C2, kernel drive the continuous page of application and construct buffering area formation control structure; C3, kernel drive the physical address that calculates each buffering area in the message queue, and said address is kept in the physical address table so that DMA uses; C4, kernel drive the physical address that calculates message buffer formation control structure, and the application interface built-in function is passed in said address.
Further preferred receiving method for zero copy network packet; Wherein, the concrete operations step of said step D is: D1, user interface built-in function obtain the physical address of the buffering area formation control structure of structure in the kernel driving from the data structure that system call is returned; D2, user interface built-in function are opened the memory device file; D3, user interface built-in function are mapped to the buffer control structure in the kernel through system call the address space of oneself.
Further preferred receiving method for zero copy network packet; Wherein, The concrete operations step of said step e is: E1, network interface card drive when distributing the DMA buffering area to network interface card not allocation buffer from the system protocol stack; But, from the buffer queue of user's space, take out freebuf and make DMA and use according to the control structure of zero-copy buffer; E2, network interface card are sent out interruption to driving after writing buffering area to message through dma mode, drive the packet receiving formation of putting into buffering area application.
Further preferred receiving method for zero copy network packet, wherein, the concrete operations step of said step F is: F1, application program confirm in which buffering area, message is arranged through buffer control structure; F2, application program need not copy message user's space to and directly use these messages from kernel spacing.
Technique scheme of the present invention owing to adopted the Zero-copy method of direct visit network interface card DMA buffering area, can satisfy HVN and use the rate request that data are received, and with existing network Data Receiving compared with techniques, has further saved system resource; Owing to introduced the memory mirror interconnection technique; Therefore direct data of access kernel space of user program; Even can directly visit the data in the physical equipment internal memory, thereby for application provides flexibly, Data Receiving is machine-processed easily, for the developer provides development environment widely; Data Receiving of the present invention (copy) is carried out at user's space application internal memory, therefore can construct the Data Receiving buffering area of large space, even can reach the GB level; Because in copy procedure, direct mapping physical internal memory, thereby the unsteadiness of having avoided newly-increased kernel module to bring; The present invention is at national network information security center; Test is caught message for carrying out message analysis to proprietary application on backbone network, and compared with prior art, message transmissions speed improves greatly; Such as on intel 82546 PCI-Express; The message of reception 64 bytes of process protocol stack, speed are up to per second and receive 270000 bags, take the cpu more than 80%; But receive message with Zero-copy method, speed can reach per second 710000 bags, takies cpu less than 10%.
Below in conjunction with accompanying drawing the present invention is explained further details.
Description of drawings
Fig. 1 is an operating procedure sketch map of the present invention;
Fig. 2 is the specific operation process sketch map of step B of the present invention;
Fig. 3 is the specific operation process sketch map of step C of the present invention;
Fig. 4 is the specific operation process sketch map of step D of the present invention;
Fig. 5 is the specific operation process sketch map of step e of the present invention;
Fig. 6 is the specific operation process sketch map of step F of the present invention.
Embodiment
Under the design philosophy of technique scheme of the present invention, the present invention can have multiple, explains through specific embodiment below.
Embodiment one
Fig. 1 is an operating procedure sketch map of the present invention.In the linux operating environment, as shown in Figure 1, the present invention carries out following operating procedure:
The equipment of the opening function that A, application call interface library provide.In this step, at first open network card equipment, confirm the DMA cache size and distribute to the percentage that receives formation, receiving mode, sending mode are set; More than operate and successfully then return network card equipment ID.
B, open the equipment interface function program and apply for that in the user's space internal memory the continuous internal memory of a slice is as message buffer.And pass to kernel to the buffering area first address and drive.
In this step, the maximum shared drive value of check system initial setting up is if the request memory value is then made amendment to the system default memory value greater than system default shared drive value.Memory size according to required distributes shared drive, successfully return the initial address of internal memory after, just can internally deposit into row and preserve data or lock operation.After using internal memory, this internal memory is returned to system.
C, kernel drive according to relevant parameters such as buffering area first address and buffer size, the structure buffer control structure, and comprising the information of message buffer formation, the physical address of each buffering area etc. in the formation.And pass to interface function to the physical address of control structure.
In this step; Driver can be applied for an internal memory; As the control handle of the overall situation, the member comprises the formation of describing transmission and receiving message, and this formation is made up of the reception formation of free time, idle transmit queue, the reception formation of data cached newspaper and the transmit queue of data cached newspaper; Describe the variable that drives mode of operation, mode of operation comprises normal mode and direct copy mode; Be used for process and reach variable of mutual exclusion etc. synchronously.After the control handle carries out initialization; Become the plurality of data piece sending in the user's space with reception message address Region Segmentation; Convert the first address of each piece the physical address of kernel spacing to, promptly the required address of dma operation is stored in the queue structure of control handle.
D, interface function obtain buffer control structure according to the address of buffer control structure through memory-mapped.
Physical address through mapping buffer memory handle in the present embodiment is operated more than the virtual address realization of user's space.
Thus much, kernel drives and the user interface function just can both have been taken the information in the control structure of buffering area.
E, NIC driver are got freebuf as the DMA buffering area that receives message from buffering sector row, can receive the message data that receives in the buffering area without the message that the direct DMA of kernel spacing is sent in the user memory;
Message receives the message data in the buffering area in F, the application program processes user memory.
Embodiment two
The difference of present embodiment and embodiment one is; The specific operation process of step B of the present invention is shown in Figure 2 as illustrating, the message among the said step B receives the length of buffering area formation and can be specified by parameter, and the size of each buffering area is 2KB; For guaranteeing to be positioned on the continuous memory pages at the buffering area of user's space application; Save as shared drive in the application of interface library function, because in linux operating system, shared drive is positioned on the continuous physical page.The concrete operations step is:
B1, interface library function application shared buffer, and be connected to shared buffer.
B2, interface library function are passed to driving to the first address of shared buffer through the ioctl system call.
Embodiment three
The difference of present embodiment and embodiment two is that the specific operation process of step C of the present invention is shown in Figure 3 as illustrating, the concrete operations step of said step C is:
C1, kernel drive the size according to the buffer control structure of the size calculating needs of whole buffering area formation.
C2, kernel drive the continuous page of application and construct buffering area formation control structure.
C3, kernel drive the physical address that calculates each buffering area in the formation, are kept in the physical address table so that DMA uses.
C4, kernel drive the physical address that calculates buffering area formation control structure, pass to the application interface built-in function.
Embodiment four
The difference of present embodiment and embodiment three is that the specific operation process of step D of the present invention is shown in Figure 4 as illustrating, the concrete operations step of said step D is:
D1, user interface built-in function obtain the physical address of the buffering area formation control structure of structure in the kernel driving from system call return data structure.
D2, user interface built-in function are opened memory device file/dev/mem.
D3, user interface built-in function are mapped to the buffer control structure in the kernel through system call mmap the address space of oneself.
Embodiment five
The difference of present embodiment and embodiment four is that the specific operation process of step e of the present invention is shown in Figure 5 as illustrating, the concrete operations step of said step e is:
E1, network interface card drive when distributing the DMA buffering area to network interface card not allocation buffer from the system protocol stack, but according to the control structure of zero-copy buffer, from the buffer queue of user's space, take out freebuf and make DMA and use.
E2, network interface card can be sent out interruption to driving after writing buffering area to message through dma mode, drive the packet receiving formation of putting into buffering area application.
Embodiment six
The difference of present embodiment and embodiment five is that the specific operation process of step F of the present invention is shown in Figure 6 as illustrating, the concrete operations step of said step F is:
F1, application program confirm in which buffering area, message is arranged through buffer control structure;
F2, application program need not copy message user's space to and directly use these messages from kernel spacing.
Should be noted that at last: above embodiment is only in order to technical scheme of the present invention to be described but not to its restriction; Although the present invention has been carried out detailed explanation with reference to the foregoing description; Under the those of ordinary skill in field be to be understood that: still can specific embodiments of the invention make amendment or be equal to replacement; And do not break away from any modification of spirit and scope of the invention or be equal to replacement, it all should be encompassed in the middle of the claim scope of the present invention.

Claims (6)

1. receiving method for zero copy network packet, wherein, said method comprises following operating procedure:
The function that A, application call interface library provide is opened equipment interface;
B, open the equipment interface function and in the user's space internal memory, apply for the continuous internal memory of a slice, and pass to kernel to the buffering area first address and drive as message buffer;
C, kernel drive according to buffering area first address and buffer size; The structure buffer control structure; And pass to the physical address of control structure and open the equipment interface function, said structure comprises the physical address of each buffering area in information and the formation of message buffer formation;
D, open the physical address of equipment interface function, obtain the information in the buffer control structure through memory-mapped according to buffer control structure;
E, network interface card drive from buffering sector row and get freebuf as the DMA buffering area that receives message, and are sent to the DMA buffering area that receives message to the message data that receives without the direct DMA of kernel spacing;
Message data in the DMA buffering area of F, application program processes reception message.
2. receiving method for zero copy network packet as claimed in claim 1; Wherein, The length of the message buffer among the said step B is specified by parameter, and the size of each buffering area is 2KB, for guaranteeing to be positioned on the continuous memory pages at the buffering area of user's space internal memory application; Open the application of equipment interface function in save as shared drive, the concrete operations step among the said step B is:
B1, open equipment interface function application shared buffer, and be connected to shared buffer;
B2, open the equipment interface function and pass to kernel to the first address of shared buffer through system call and drive.
3. receiving method for zero copy network packet as claimed in claim 1, wherein, the concrete operations step of said step C is:
C1, kernel drive the size according to the buffer control structure of the size calculating needs of whole buffering area formation;
C2, kernel drive the continuous page of application and construct buffer control structure;
C3, kernel drive the physical address that calculates each buffering area in the message queue, and said address is kept in the physical address table so that DMA uses;
C4, kernel drive the physical address that calculates the message buffer control structure, and said address are passed to open the equipment interface function.
4. receiving method for zero copy network packet as claimed in claim 1, wherein, the concrete operations step of said step D is:
D1, open the equipment interface function from the data structure that system call is returned, obtain kernel drive in the physical address of buffering area formation control structure of structure;
D2, open the equipment interface function and open the memory device file;
D3, open the equipment interface function and be mapped to the buffer control structure in the kernel through system call the address space of oneself.
5. zero-copy network newspaper zhang method of reseptance as claimed in claim 1, wherein, the concrete operations step of said step e is:
E1, network interface card drive when distributing the DMA buffering area to network interface card not allocation buffer from the system protocol stack, but according to the control structure of zero-copy buffer, from the buffer queue of user's space internal memory, take out freebuf and make DMA and use;
E2, network interface card are sent out interruption to the network interface card driving after writing buffering area to message through dma mode, and network interface card drives the packet receiving formation of putting into buffering area application.
6. receiving method for zero copy network packet as claimed in claim 1, wherein, said step F is:
F1, application program confirm in which buffering area, message is arranged through buffer control structure; Application program need not copy message the user's space internal memory to and directly use these messages from kernel spacing.
CN 200710177373 2007-11-15 2007-11-15 A receiving method for zero copy network packet Active CN101150488B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN 200710177373 CN101150488B (en) 2007-11-15 2007-11-15 A receiving method for zero copy network packet

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN 200710177373 CN101150488B (en) 2007-11-15 2007-11-15 A receiving method for zero copy network packet

Publications (2)

Publication Number Publication Date
CN101150488A CN101150488A (en) 2008-03-26
CN101150488B true CN101150488B (en) 2012-01-25

Family

ID=39250840

Family Applications (1)

Application Number Title Priority Date Filing Date
CN 200710177373 Active CN101150488B (en) 2007-11-15 2007-11-15 A receiving method for zero copy network packet

Country Status (1)

Country Link
CN (1) CN101150488B (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107480080A (en) * 2017-07-03 2017-12-15 香港红鸟科技股份有限公司 A kind of Zero-copy data stream based on RDMA

Families Citing this family (13)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102223285B (en) * 2010-04-16 2014-06-25 大唐移动通信设备有限公司 Method and network node for processing data message
CN102467473B (en) * 2010-11-03 2015-02-11 Tcl集团股份有限公司 Method and device for transmitting data between user space and kernel
CN102291298B (en) * 2011-08-05 2014-10-22 曾小荟 Efficient computer network communication method oriented to long message
CN103731364B (en) * 2014-01-16 2017-02-01 赛特斯信息科技股份有限公司 X86 platform based method for achieving trillion traffic rapid packaging
CN104239249B (en) * 2014-09-16 2017-08-04 国家计算机网络与信息安全管理中心 PCI E zero-copy DMA data transfer methods
CN104796337A (en) * 2015-04-10 2015-07-22 京信通信系统(广州)有限公司 Method and device for forwarding message
CN107204939A (en) * 2017-05-27 2017-09-26 南京南瑞继保电气有限公司 A kind of message processing method based on two-level cache
CN110391999B (en) * 2018-04-18 2022-12-16 海能达通信股份有限公司 Data communication method and system
CN109062713A (en) * 2018-07-26 2018-12-21 郑州云海信息技术有限公司 A kind of calling efficiency method and device improving same command line interface
CN109783250B (en) * 2018-12-18 2021-04-09 中兴通讯股份有限公司 Message forwarding method and network equipment
CN113127183B (en) * 2019-12-30 2024-06-14 阿里巴巴集团控股有限公司 Memory allocation method and device in user mode protocol stack
CN112039722B (en) 2020-08-12 2022-07-08 中国银联股份有限公司 MQTT protocol simulation method and simulation equipment
CN112769688B (en) * 2020-12-18 2022-07-29 南方电网科学研究院有限责任公司 Method and device for protocol stack adaptation, electronic equipment and storage medium

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1996271A (en) * 2006-12-30 2007-07-11 华为技术有限公司 System and method for transmitting data
CN101063963A (en) * 2006-04-26 2007-10-31 韩国电子通信研究院 File movement method supporting data zero-copy technique

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101063963A (en) * 2006-04-26 2007-10-31 韩国电子通信研究院 File movement method supporting data zero-copy technique
CN1996271A (en) * 2006-12-30 2007-07-11 华为技术有限公司 System and method for transmitting data

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107480080A (en) * 2017-07-03 2017-12-15 香港红鸟科技股份有限公司 A kind of Zero-copy data stream based on RDMA
CN107480080B (en) * 2017-07-03 2021-03-23 深圳致星科技有限公司 Zero-copy data stream based on RDMA

Also Published As

Publication number Publication date
CN101150488A (en) 2008-03-26

Similar Documents

Publication Publication Date Title
CN101150488B (en) A receiving method for zero copy network packet
CN101150487A (en) A transmission method for zero copy network packet
US11934341B2 (en) Virtual RDMA switching for containerized
Peter et al. Arrakis: The operating system is the control plane
Zhang et al. XenSocket: A high-throughput interdomain transport for virtual machines
US8392565B2 (en) Network memory pools for packet destinations and virtual machines
WO2017066944A1 (en) Method, apparatus and system for accessing storage device
JP5671150B2 (en) Lockless buffer management scheme for telecommunications network applications
US20020091863A1 (en) Interoperable network communication architecture
CN112422615A (en) Communication method and device
CN111966446B (en) RDMA virtualization method in container environment
CN101150485A (en) A management method for network data transmission of zero copy buffer queue
US7409468B2 (en) Controlling flow of data between data processing systems via a memory
CN103827842B (en) Message is write to controller storage space
US20040057380A1 (en) Controlling flow of data between data processing systems via a memory
CN102609298A (en) Network card virtualizing system and network card virtualizing method on basis of hardware array expansion
CN101150486A (en) A management method for receiving network data of zero copy buffer queue
CN111431757A (en) Virtual network flow acquisition method and device
US11347567B2 (en) Methods and apparatus for multiplexing data flows via a single data structure
CN107967225A (en) Data transmission method, device, computer-readable recording medium and terminal device
US11010165B2 (en) Buffer allocation with memory-based configuration
US7219157B2 (en) Application programming interface for network applications
Papadopoulou et al. A performance study of UCX over InfiniBand
CN102375789B (en) Non-buffer zero-copy method of universal network card and zero-copy system
EP3077914A1 (en) System and method for managing and supporting virtual host bus adaptor (vhba) over infiniband (ib) and for supporting efficient buffer usage with a single external memory interface

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
C14 Grant of patent or utility model
GR01 Patent grant
TR01 Transfer of patent right

Effective date of registration: 20220727

Address after: 100193 No. 36 Building, No. 8 Hospital, Wangxi Road, Haidian District, Beijing

Patentee after: Dawning Information Industry (Beijing) Co.,Ltd.

Patentee after: DAWNING INFORMATION INDUSTRY Co.,Ltd.

Address before: 100084 Beijing Haidian District City Mill Street No. 64

Patentee before: Dawning Information Industry (Beijing) Co.,Ltd.

TR01 Transfer of patent right