CN103269284B - The catching method of real-time network data - Google Patents

The catching method of real-time network data Download PDF

Info

Publication number
CN103269284B
CN103269284B CN201310185076.1A CN201310185076A CN103269284B CN 103269284 B CN103269284 B CN 103269284B CN 201310185076 A CN201310185076 A CN 201310185076A CN 103269284 B CN103269284 B CN 103269284B
Authority
CN
China
Prior art keywords
network interface
kernel
user space
interface card
kernel state
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.)
Expired - Fee Related
Application number
CN201310185076.1A
Other languages
Chinese (zh)
Other versions
CN103269284A (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.)
Opzoon Technology Co Ltd
Original Assignee
Opzoon Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Opzoon Technology Co Ltd filed Critical Opzoon Technology Co Ltd
Priority to CN201310185076.1A priority Critical patent/CN103269284B/en
Publication of CN103269284A publication Critical patent/CN103269284A/en
Application granted granted Critical
Publication of CN103269284B publication Critical patent/CN103269284B/en
Expired - Fee Related legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Landscapes

  • Data Exchanges In Wide-Area Networks (AREA)

Abstract

The present invention provides the catching method of a kind of real-time network data, described method to include: S1: initialize kernel state, and the registration of kernel network interface card transmitting-receiving message function is deleted in initialization procedure;S2: kernel state provides the patch of bulk memory application, Mmap internal memory to map and the interface function ioctl of User space operation kernel, and records initial address and the initial address in network card configuration space of physical memory;S3: User space detects the acquisition bus number of network interface card, device numbering and function numbering automatically, and communicates with kernel state according to described interface function ioctl;And network interface card transmitting-receiving message is carried out corresponding resource distribution and the configuration of relevant network interface card depositor, User space carries out packet sending and receiving.The present invention is by providing the catching method of a kind of real-time network data, it is achieved that network interface card drives in kernel loads and receives and dispatches message at User space, eliminates the performance loss that kernel state trawl performance interrupts and data copy causes.

Description

The catching method of real-time network data
Technical field
The present invention relates to network technology, particularly to the catching method of a kind of real-time network data.
Background technology
At present, being directed to data capture method has kernel loads trawl performance, carries out packet sending and receiving, Business Processing is at kernel.By kernel loads trawl performance, carry out packet sending and receiving, at ten thousand Broadcoms The impact of big flow is lower causes a large amount of interruption to consume certain cpu performance (particularly X86 system Framework), the kernel state of linux operating system copies to the data of User space and will also result in and be simultaneously The loss of system performance.Data capture method also has User space to load trawl performance, carries out message receipts Sending out, Business Processing is at User space.Loaded trawl performance by User space, carry out packet sending and receiving, solve The performance loss of case above of having determined, but process (such as linux for some main frame message traffics Pppoe, dhcp etc. of kernel) need perception actual physics network and network interface state, and Kernel do not have network interface can sense operation, now arise that problem.
Summary of the invention
(1) solve the technical problem that
Present invention solves the technical problem that the catching method being to provide a kind of real-time network data, energy Enough eliminate the performance loss that kernel state trawl performance interrupts and data copy causes, and meet net The perception problems of network interface.
(2) technical scheme
The invention provides the catching method of a kind of real-time network data, described method includes:
S1: kernel state is initialized, and in initialization procedure, kernel network interface card is transmited and receive telegrams The registration of literary composition function is deleted;
S2: kernel state provides the patch of bulk memory application, Mmap internal memory to map and User space The interface function ioctl of operation kernel, records the initial of physical memory after application to bulk memory Address and the initial address in network card configuration space;
S3: User space detects the acquisition bus number of network interface card, device numbering and function numbering automatically, And communicate with kernel state according to described interface function ioctl;
S4: User space obtains the initial address of described physical memory and described network card configuration space Initial address, and network interface card transmitting-receiving message is carried out corresponding resource distribution and relevant network interface card depositor Configuration, User space carries out packet sending and receiving.
Preferably, same what the registration of kernel state network interface card transmitting-receiving message function was deleted in step S1 Time, go kernel state network interface card to enable and interrupt.
Preferably, the patch of bulk memory application described in step S2 is used for so that Linux applies for Bulk continuous print internal memory.
Preferably, Mmap internal memory described in step S2 maps for by kernel state network interface card physically Location is mapped as User space virtual address.
Preferably, interface function ioctl described in step S2 leads to kernel state for User space Letter.
Preferably, step S3 specifically includes:
S31: obtain in kernel corresponding according to bus number, device numbering and the function numbering of network interface card Pci_dev, net_device structure, and and User space set up mapping relations;
Kernel state pci equipment is enabled by described interface function ioctl, arranges by S32: User space DMA address and acquisition mac address of nic;
S33: User space registration User space end network interface, according to mapping relations will obtain described in Mac address of nic is mapped as virtual address, and transmits and receive telegrams according to the virtual address configuration after mapping Literary composition depositor and initialization transmitting-receiving bag resource.
Preferably, receive and dispatch bag resource described in step S33 to include receiving and dispatching queue, descriptor or interior Deposit application.
Preferably, User space carries out network interface shape by described interface function ioctl with kernel state The renewal of state.
(3) beneficial effect
The present invention is by providing the catching method of a kind of real-time network data, it is achieved that network interface card interior Core drive load receives and dispatches message at User space, eliminates the interruption of kernel state trawl performance and data are copied The performance loss that shellfish is caused, two sockets of registration maintenance, meet kernel state, use respectively simultaneously The family state perception demand to physical network and Interface status.
Accompanying drawing explanation
Fig. 1 is the method flow diagram that the present invention provides.
Detailed description of the invention
Below in conjunction with the accompanying drawing in the embodiment of the present invention, to the technical side in the embodiment of the present invention Case is clearly and completely described.
Embodiment 1:
The invention provides the catching method of a kind of real-time network data, as it is shown in figure 1, described side Method includes:
S1: kernel state is initialized, and in initialization procedure, kernel network interface card is transmited and receive telegrams The registration of literary composition function is deleted, and removes the resource distribution that transmitting-receiving message is relevant simultaneously;In making network interface card Core state can not receive and dispatch message, remains User space and carries out packet sending and receiving, internal nucleoreticulum card transmitting-receiving message Resource be no longer allocated, the hardware register that transmitting-receiving message is relevant no longer configures.But It it is that kernel state carries out normal pci bus and arranges and interface registration etc. all retains, it is ensured that core network Interface can configure the operations such as ip, route, sub-interface and bridge binding.
While the registration of kernel network interface card transmitting-receiving message function being deleted, go to make by kernel network interface card Can interrupt.Go to enable and interrupt eliminating the performance loss that network interface card packet sending and receiving causes.
S2: kernel state provides the patch of bulk memory application, Mmap internal memory to map and User space The interface function ioctl of operation kernel, records the initial of physical memory after application to bulk memory Address and the initial address in network card configuration space;
The patch of described bulk memory application is used for so that Linux applies for bulk continuous print internal memory. Described Mmap internal memory maps for kernel state mac address of nic is mapped as User space virtually Location, described interface function ioctl communicates with kernel state for User space so that User space energy Enough have access to DMA(Direct Memory Access, direct memory access) internal memory.
S3: User space detects the acquisition bus number of network interface card, device numbering and function numbering automatically, And communicate with kernel state according to the described interface function ioctl of kernel state offer, obtain kernel The initial address of the described physical memory of state record and the initial address in network card configuration space, logical Crossing physical address map is virtual address, and network interface card transmitting-receiving message is carried out corresponding resource distribution And the configuration of relevant network interface card depositor, User space carries out packet sending and receiving.
Step S3 specifically includes:
S31: obtain in kernel corresponding according to bus number, device numbering and the function numbering of network interface card Pci_dev, net_device structure, and and User space set up mapping relations;Described mapping is closed System operates for the net_device structure searching kernel during when User space operation network interface card.
Kernel state pci equipment is enabled by interface function ioctl, arranges directly by S32: User space Memory access address and acquisition mac address of nic;
S33: User space registration User space end network interface, according to mapping relations will obtain described in Mac address of nic is mapped as virtual address, and transmits and receive telegrams according to the virtual address configuration after mapping Literary composition depositor and initialization transmitting-receiving bag resource.
Receive and dispatch bag resource described in step S33 to include receiving and dispatching queue, descriptor or internal memory application, Ensure that User space can be normally carried out packet sending and receiving.Network interface card is entered during for kernel initialization The User space that row is arranged be not configured, and User space is only registered and safeguards the network of User space end Interface, User space carries out network interface state more by described interface function ioctl with kernel state Newly.
Embodiment of above is merely to illustrate the present invention, and not limitation of the present invention, relevant The those of ordinary skill of technical field, without departing from the spirit and scope of the present invention, Can also make a variety of changes and modification, the technical scheme of the most all equivalents falls within the present invention Category, the scope of patent protection of the present invention should be defined by the claims.

Claims (7)

1. the catching method of a real-time network data, it is characterised in that described method includes:
Step S1: kernel state is initialized, and in initialization procedure, kernel network interface card is received Transmit messages literary composition function registration delete;
Step S2: kernel state provides the patch of bulk memory application, Mmap internal memory to map and uses The interface function ioctl of family state operation kernel, records physical memory after application to bulk memory Initial address and the initial address in network card configuration space;
Step S3: User space detects the acquisition bus number of network interface card, device numbering and function automatically Numbering, and communicate with kernel state according to described interface function ioctl;Obtain in described physics The initial address deposited and the initial address in described network card configuration space, and network interface card transmitting-receiving message is entered Row corresponding resource distribution and the configuration of network interface card depositor of being correlated with, User space carries out packet sending and receiving;
Wherein, in step S1 while the registration of kernel state network interface card transmitting-receiving message function is deleted, Go kernel state network interface card to enable and interrupt.
Method the most according to claim 1, it is characterised in that big described in step S2 The patch of block internal memory application is used for so that Linux applies for bulk continuous print internal memory.
Method the most according to claim 1, it is characterised in that Mmap described in step S2 Internal memory maps for kernel state mac address of nic is mapped as User space virtual address.
Method the most according to claim 1, it is characterised in that connect described in step S2 Mouth function ioctl communicates with kernel state for User space.
Method the most according to claim 1, it is characterised in that step S3 specifically includes:
Step S31: kernel state obtains according to bus number, device numbering and the function numbering of network interface card Pci_dev, net_device structure corresponding in kernel, and set up mapping relations with User space;
Step S32: User space by described interface function ioctl to kernel state pci equipment enable, DMA address is set and obtains mac address of nic;
Step S33: User space registration User space end network interface, according to mapping relations by acquisition Described mac address of nic is mapped as virtual address, and receives according to the virtual address configuration after mapping Transmit messages literary composition depositor and initialize transmitting-receiving bag resource.
Method the most according to claim 5, it is characterised in that receive described in step S33 Resource of giving out a contract for a project includes receiving and dispatching queue, descriptor or internal memory application.
Method the most according to claim 1, it is characterised in that User space pass through described in connect Mouth function ioctl and kernel state carry out the renewal of network interface state.
CN201310185076.1A 2013-05-17 2013-05-17 The catching method of real-time network data Expired - Fee Related CN103269284B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201310185076.1A CN103269284B (en) 2013-05-17 2013-05-17 The catching method of real-time network data

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201310185076.1A CN103269284B (en) 2013-05-17 2013-05-17 The catching method of real-time network data

Publications (2)

Publication Number Publication Date
CN103269284A CN103269284A (en) 2013-08-28
CN103269284B true CN103269284B (en) 2016-09-14

Family

ID=49012893

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201310185076.1A Expired - Fee Related CN103269284B (en) 2013-05-17 2013-05-17 The catching method of real-time network data

Country Status (1)

Country Link
CN (1) CN103269284B (en)

Families Citing this family (15)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103747115B (en) * 2013-12-30 2017-08-01 武汉邮电科学研究院 Virtual machine IP address based on Microsoft Loopback Adapter finds method
CN103902371B (en) * 2014-03-14 2017-11-28 汉柏科技有限公司 A kind of User space program obtains kernel jiffies method and system
CN104090750A (en) * 2014-06-05 2014-10-08 汉柏科技有限公司 Method and device for acquiring limited access information in user mode
CN104077190A (en) * 2014-06-09 2014-10-01 汉柏科技有限公司 ARM internet access drive user mode transplanting method and system
CN108989107A (en) * 2018-07-17 2018-12-11 北京中科网威信息技术有限公司 A kind of the statistics adjustment method and device of the network interface card transmitting-receiving message based on Shen prestige framework
CN109753368B (en) * 2018-12-20 2020-12-04 清华大学 Real-time data sending method and system
CN111835613B (en) * 2019-04-23 2022-07-08 厦门网宿有限公司 Data transmission method of VPN server and VPN server
CN112491570A (en) * 2019-09-11 2021-03-12 中兴通讯股份有限公司 Method, device and storage medium for setting link state of virtual network card
CN111181736B (en) * 2019-12-31 2022-04-05 奇安信科技集团股份有限公司 Data transmission method, device, system and medium
CN114513381B (en) * 2020-11-16 2023-07-25 沈阳中科数控技术股份有限公司 AF_XDP-based real-time Ethernet field bus data packet processing method
CN114513382B (en) * 2020-11-16 2023-07-25 沈阳中科数控技术股份有限公司 Real-time Ethernet field bus network data packet processing method based on network card
CN112463662B (en) * 2020-12-16 2024-04-05 福州创实讯联信息技术有限公司 Method and terminal for user mode control of I2C equipment
CN114401232A (en) * 2021-12-27 2022-04-26 中国电信股份有限公司 Data transmission method and device, electronic equipment and storage medium
CN115174410A (en) * 2022-07-27 2022-10-11 阿里巴巴(中国)有限公司 Resource allocation method, device and equipment
CN115473811A (en) * 2022-09-21 2022-12-13 西安超越申泰信息科技有限公司 Network performance optimization method, device, equipment and medium

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102098227A (en) * 2011-03-03 2011-06-15 成都市华为赛门铁克科技有限公司 Packet capture method and kernel module
CN102200930A (en) * 2011-05-26 2011-09-28 华为数字技术有限公司 Synchronous variable mapping method and device, synchronous variable freeing method and synchronous variable deleting method
CN102497434A (en) * 2011-12-16 2012-06-13 中国科学院计算技术研究所 Establishing method of kernel state virtual network equipment and packet transmitting and receiving methods thereof
WO2012177447A2 (en) * 2011-06-23 2012-12-27 Microsoft Corporation Programming interface for data communications

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102098227A (en) * 2011-03-03 2011-06-15 成都市华为赛门铁克科技有限公司 Packet capture method and kernel module
CN102200930A (en) * 2011-05-26 2011-09-28 华为数字技术有限公司 Synchronous variable mapping method and device, synchronous variable freeing method and synchronous variable deleting method
WO2012177447A2 (en) * 2011-06-23 2012-12-27 Microsoft Corporation Programming interface for data communications
CN102497434A (en) * 2011-12-16 2012-06-13 中国科学院计算技术研究所 Establishing method of kernel state virtual network equipment and packet transmitting and receiving methods thereof

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
"实时Linux下网络报文捕获平台的研究与实现";段辰生;《中国优秀硕士学位论文全文数据库,信息科技辑》;20091115;第4.2-4.4节 *

Also Published As

Publication number Publication date
CN103269284A (en) 2013-08-28

Similar Documents

Publication Publication Date Title
CN103269284B (en) The catching method of real-time network data
CN103312601B (en) Data message processing method from user mode to kernel mode
US8174984B2 (en) Managing traffic on virtualized lanes between a network switch and a virtual machine
CN101267361B (en) A high-speed network data packet capturing method based on zero duplication technology
CN103259735B (en) A kind of communication means of the programmable virtual router based on NetFPGA
US8392565B2 (en) Network memory pools for packet destinations and virtual machines
US7752360B2 (en) Method and system to map virtual PCIe I/O devices and resources to a standard I/O bus
CN105320628B (en) Enable single I/O equipment more shared adaptive devices, system and methods
CN102932444B (en) Load balancing module in finance real-time transaction system
CN102904729B (en) The intelligent acceleration network card of more applications is supported according to agreement, port shunt
CN103414535B (en) Data sending method, data receiving method and relevant devices
CN101990002A (en) Controller integration
CN102790777B (en) Network interface adapter register method and driving equipment, server
CN103827842B (en) Message is write to controller storage space
CN107294869A (en) A kind of method and system of Microsoft Loopback Adapter message crawl
CN105407140A (en) Calculation resource virtualization system of networked test system and method thereof
CN101841470A (en) High-speed capturing method of bottom-layer data packet based on Linux
CN103581181A (en) Data packet capturing, processing and sending method and system
CN106155960A (en) Shake hands and the UART serial port communication method of EDMA based on GPIO
CN103354530A (en) Virtualization network boundary data flow gathering method and apparatus
CN102497434A (en) Establishing method of kernel state virtual network equipment and packet transmitting and receiving methods thereof
CN101873337A (en) Zero-copy data capture technology based on rt8169 gigabit net card and Linux operating system
CN106302322A (en) A kind of virtual-machine data flow management method and system
CN103763173A (en) Data transmission method and computing node
CN105337789A (en) Method and device for monitoring flow of virtual network

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
CF01 Termination of patent right due to non-payment of annual fee

Granted publication date: 20160914

Termination date: 20180517

CF01 Termination of patent right due to non-payment of annual fee