CN114513382B - Real-time Ethernet field bus network data packet processing method based on network card - Google Patents

Real-time Ethernet field bus network data packet processing method based on network card Download PDF

Info

Publication number
CN114513382B
CN114513382B CN202011276999.4A CN202011276999A CN114513382B CN 114513382 B CN114513382 B CN 114513382B CN 202011276999 A CN202011276999 A CN 202011276999A CN 114513382 B CN114513382 B CN 114513382B
Authority
CN
China
Prior art keywords
real
time ethernet
data packet
network card
data
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
CN202011276999.4A
Other languages
Chinese (zh)
Other versions
CN114513382A (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.)
Shenyang Zhongke Cnc Technology Co ltd
Original Assignee
Shenyang Zhongke Cnc 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 Shenyang Zhongke Cnc Technology Co ltd filed Critical Shenyang Zhongke Cnc Technology Co ltd
Priority to CN202011276999.4A priority Critical patent/CN114513382B/en
Publication of CN114513382A publication Critical patent/CN114513382A/en
Application granted granted Critical
Publication of CN114513382B publication Critical patent/CN114513382B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L12/00Data switching networks
    • H04L12/28Data switching networks characterised by path configuration, e.g. LAN [Local Area Networks] or WAN [Wide Area Networks]
    • H04L12/40Bus networks
    • H04L12/40006Architecture of a communication node
    • H04L12/40013Details regarding a bus controller
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L12/00Data switching networks
    • H04L12/28Data switching networks characterised by path configuration, e.g. LAN [Local Area Networks] or WAN [Wide Area Networks]
    • H04L12/40Bus networks
    • H04L12/40169Flexible bus arrangements
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L69/00Network arrangements, protocols or services independent of the application payload and not provided for in the other groups of this subclass
    • H04L69/08Protocols for interworking; Protocol conversion
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L69/00Network arrangements, protocols or services independent of the application payload and not provided for in the other groups of this subclass
    • H04L69/22Parsing or analysis of headers
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L12/00Data switching networks
    • H04L12/28Data switching networks characterised by path configuration, e.g. LAN [Local Area Networks] or WAN [Wide Area Networks]
    • H04L12/40Bus networks
    • H04L2012/40208Bus networks characterized by the use of a particular bus standard
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L12/00Data switching networks
    • H04L12/28Data switching networks characterised by path configuration, e.g. LAN [Local Area Networks] or WAN [Wide Area Networks]
    • H04L12/40Bus networks
    • H04L2012/4026Bus for use in automation systems

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Computer Security & Cryptography (AREA)
  • Small-Scale Networks (AREA)

Abstract

The invention relates to a real-time Ethernet field bus network data packet processing method based on a network card, relates to the technical field of numerical control, in particular to the technical field of real-time Ethernet field bus, and particularly relates to a real-time Ethernet field bus network data packet processing method based on a network card. Firstly, analyzing a transmission path of a real-time Ethernet field bus data packet in a native network card driver, and establishing a capturing point of the real-time Ethernet field bus data packet in the network card driver; then, analyzing the characteristics of the data packet at the capturing point, and establishing a data packet capturing method based on the native network card drive; finally, according to the bus protocol type of the data packet, the analysis processing method of the data packet in the native network card driver is designed.

Description

Real-time Ethernet field bus network data packet processing method based on network card
Technical Field
The invention relates to the technical field of numerical control, in particular to the technical field of real-time Ethernet field buses, and particularly relates to a real-time Ethernet field bus network data packet processing method based on a network card.
Background
At present, the real-time ethernet field bus in the numerical control system still adopts the traditional communication board card mode to transmit the network data packet, different field buses (such as EtherCAT, SSB-III real-time ethernet bus and the like) correspond to different communication board cards, a set of hardware board card corresponding to each field bus is developed aiming at each field bus, so that the system becomes bulkier and can not be reused, and the alternative scheme is to transmit the network data packet by adopting a standard network interface card. When the standard network card is adopted to transmit the real-time Ethernet field bus data packet, the network data packet is discarded after being transmitted to the kernel network protocol stack because the network data packet is not recognized by the network protocol stack, for example, the network data packet is transmitted to the kernel network protocol stack by modifying the kernel network mode, and the system delay and jitter are increased, so that the data packet must be captured and processed before entering the kernel network protocol stack, otherwise, the real-time performance of the system cannot be ensured.
In order to increase the real-time performance of the system and reduce the transmission and processing time of the data packets so as to meet the requirement of the middle-grade numerical control system on the real-time performance of network transmission, the ideal mode is to capture and process the real-time Ethernet bus data packets in the network card drive, so that how to design a simple and efficient network data packet processing method is a key for solving the real-time transmission of the real-time Ethernet field bus network data packets.
Disclosure of Invention
In order to solve the technical problems, the invention provides a real-time Ethernet field bus network data packet processing method based on a network card.
The technical scheme adopted by the invention for achieving the purpose is as follows:
a real-time Ethernet field bus network data packet processing method based on a network card comprises the following steps:
determining a transmission path of the real-time Ethernet field bus data packet in the original network card driver through debugging information output by the kernel debugging function, and establishing a capturing point of the real-time Ethernet bus data packet in the network card driver;
capturing real-time Ethernet bus data packets based on the native network card driver aiming at the real-time Ethernet bus data packet capturing points built in the network card driver;
according to the bus protocol type of the real-time Ethernet bus data packet, analyzing and processing the real-time Ethernet bus data packet in a native network card driver;
and according to the analyzed real-time Ethernet bus data, performing data exchange between the bottom layer drive based on the memory mapping mechanism and the real-time application program of the user space.
The real-time Ethernet field bus data packet type comprises any one of EtherCAT protocol and SSB-III protocol.
The network card is a control structure of an MAC controller and a PHY chip.
The capture point is located behind the annular queue mapped by the network card DMA.
The capturing of the real-time Ethernet bus data packet based on the native network card driver specifically comprises the following steps:
opening up a static memory for storing real-time Ethernet bus data packets in a kernel space;
selecting an interrupt source, setting interrupt as periodic trigger and setting interrupt period, and completing capturing of real-time Ethernet field bus data packets in an interrupt service routine;
the data is received in an interrupt-free mode, and the receiving interrupt generated when the real-time Ethernet bus data packet in the network card is mapped to the annular queue is shielded;
the data is read in a polling mode, and real-time Ethernet bus data packets in the annular queue are read into the opened static memory by continuously polling the network card.
The analyzing and processing of the real-time Ethernet bus data packet in the native network card driver specifically comprises the following steps:
opening a static memory for storing the parsed instruction data;
analyzing the real-time Ethernet bus data packet in the native network card driver, and determining the type of the real-time Ethernet bus data packet;
analyzing instruction data in the real-time Ethernet bus data packet according to the type of the real-time Ethernet bus data packet;
and storing the analyzed instruction data in a static memory according to a data organization format.
The data exchange between the bottom layer driver and the real-time application program of the user space based on the memory mapping mechanism is specifically as follows:
mapping the memory where the instruction data are located to a user space by adopting a memory mapping mechanism;
exchanging data with a real-time application program of a user space by adopting a message communication mechanism;
waiting for the next periodic polling of the data packet.
The invention has the following beneficial effects and advantages:
1. the real-time Ethernet field bus adopts a standard network card to transmit data packets, so that the variety structure of the hardware communication board card is effectively reduced. The real-time Ethernet field bus in the existing numerical control system still adopts the traditional communication board card mode to transmit bus data, different field buses (such as EtherCAT, SSB-III real-time Ethernet buses and the like) correspond to different communication board cards, and a set of hardware board card corresponding to each field bus is developed aiming at each field bus, so that the system becomes bulkier and non-reusable.
2. The real-time Ethernet bus data packet is captured and processed in the network card drive, so that the processing efficiency of the data packet can be effectively increased, the data volume interacted with the user-mode component can be reduced, and the delay and jitter of the system can be reduced. The native network card driver is in kernel space, so that the processing of the data packet is more efficient; meanwhile, the command and the state instruction of the data packet are analyzed in the native network card driver, and compared with the whole data packet, the data volume interacted with the user-mode component can be greatly reduced.
3. The real-time Ethernet data packet is received in an uninterrupted manner, so that switching of interrupt contexts is avoided, the data packet processing efficiency is improved, and the system delay is reduced. The control structure of the real-time Ethernet field bus is a master-slave control mode, in the network of the real-time Ethernet field bus, the numerical control system is a master station device for controlling the network, the slave stations are controlled servo drivers, I/O and the like, and the communication of the network is all initiated by the master station, so the master station receives the data packet fed back by the slave stations within a certain time after sending the data packet, and can receive the data packet in a polling mode so as to reduce the context switching caused by interruption.
Drawings
FIG. 1 is a block diagram of a real-time Ethernet Fieldbus network;
fig. 2 is a diagram of a capturing processing method of a data packet.
Detailed Description
The present invention will be described in further detail with reference to the accompanying drawings and examples.
The invention is suitable for the field of numerical control systems, in particular for the application occasions of adopting a standard network card to transmit real-time Ethernet field bus network data packets, and is particularly suitable for the application occasions of adopting the standard network card to transmit the real-time Ethernet field bus network data packets in a medium-high-grade numerical control system. Specific embodiments of the method of the present invention will be described in further detail below with reference to the accompanying drawings.
The real-time Ethernet field bus network data packet processing method based on the network card comprises the following steps:
1) Determining a transmission path of a real-time Ethernet field bus data packet in a native network card driver, and establishing a capturing point of the real-time Ethernet field bus data packet in the network card driver;
2) Aiming at a network data packet capturing point built in a network card driver, a data packet capturing method based on a native network card driver is designed;
3) According to the bus protocol type of the data packet, designing an analysis processing method of the data packet in the native network card driver;
4) According to the analyzed real-time Ethernet data, a data exchange method between a bottom layer driver and an upper layer user mode component based on a memory mapping mechanism is designed;
the transmission path of the real-time Ethernet field bus data packet in the native network card driver is determined, and the real-time Ethernet field bus is EtherCAT and SSB-III;
the method comprises the steps of determining a transmission path of a real-time Ethernet field bus data packet in a primary network card driver, wherein the network card is a control structure of an MAC controller and a PHY chip;
the transmission path of the real-time Ethernet field bus data packet in the native network card driver is determined, and the network card driver is the native network card driver of the Linux system;
the capturing point of the real-time Ethernet bus data packet is built in the native network card driver and is positioned behind the annular queue mapped by the network card DMA;
the method for capturing the data packet based on the native network card driver comprises the following steps:
a. static opening up a block of internal memory in kernel space for storing Ethernet data packet;
b. selecting an interrupt source, setting interrupt as periodic trigger and setting interrupt period, and completing capturing and analyzing processing work of real-time Ethernet field bus data packets in an interrupt service routine;
c. the data is received in a non-interrupt mode, and receiving interruption generated by the DMA data packet of the network card to the annular queue is shielded;
d. the data is read in a polling mode, and the data in the annular queue is read into the newly opened memory by continuously polling the network card equipment.
The analysis processing method of the data packet designed in the native network card driver comprises the following steps:
a. opening up a static memory for storing the parsed instruction data;
b. analyzing the Ethernet protocol data packet in the native network card driver, and determining the type of the real-time Ethernet data packet;
c. analyzing instruction data in the data packet according to the type of the data packet;
d. storing the analyzed instruction data in a static memory opened according to a data organization format;
the method for designing the data exchange between the bottom layer driver and the upper layer user mode component based on the memory mapping mechanism comprises the following steps:
a. mapping the memory where the instruction data are located to a user space by adopting a memory mapping mechanism;
b. adopting a message communication mechanism to exchange data with an upper user mode motion control component, wherein the upper motion control component is a real-time application program and is used for track planning, acceleration and deceleration control and interpolation calculation;
c. waiting for the next periodic polling of the data packet.
As shown in FIG. 1, the network structure of the real-time Ethernet field bus based on the native network card driver is the left half part of the figure, and by default, the network data packet firstly passes through the network card driver and the network protocol stack in the kernel space, and then is transmitted to the application program in the user space.
The data flow structure of the real-time Ethernet field bus based on the primary network card drive is shown in the right half part of fig. 1, real-time Ethernet data packets are DMA-transmitted to a ring queue inside the primary network card drive through the network cards, a data packet capturing processing module is added after the ring queue, the data packets in the ring queue are read in a polling mode, the real-time Ethernet data packets are analyzed, instruction data obtained through analysis are mapped into the ring queue in a user space through a mmap mechanism, and a motion thread in an upper-layer motion control assembly also reads the instruction data in the ring queue through a polling mechanism.
As shown in fig. 2, the capturing processing method of the real-time ethernet fieldbus data packet includes the following specific implementation steps:
A. static opening up two memory areas in the kernel space, wherein one memory area is used for storing Ethernet data packets, and the other memory area is used for storing instruction data;
B. setting a periodic clock interrupt or high-precision timing interrupt directly provided by hardware logic by adopting a high-precision clock timer (hrtimer) of a kernel, and completing capturing and analyzing processing work of real-time Ethernet field bus data packets in an interrupt service routine of each periodic interrupt;
C. the data is received in a non-interrupt mode, and receiving interruption generated by the DMA data packet of the network card to the annular queue is shielded;
D. and the data in the annular queue is read into the newly opened memory by continuously polling the network card equipment in a polling mode for reading the data packet.
E. Judging the type of a data packet of the real-time Ethernet field bus by analyzing the Ethernet protocol packet header, wherein the data packet types respectively comprise EtherCAT, SSB-III and other real-time Ethernet protocols;
F. according to the type of the data packet, analyzing instruction data of the data packet, wherein the instruction data of the EtherCAT protocol comprises periodic instruction data and aperiodic instruction data, the periodic instruction data adopts process data of the EtherCAT protocol to carry out data transmission, the periodic instruction data is divided into periodic command data and state data according to different transmission directions, the aperiodic instruction data adopts a mailbox of the EtherCAT protocol to carry out data transmission, and the aperiodic command data and the state data are respectively obtained according to different transmission directions; the SSB-III protocol is similar to the EtherCAT protocol, and the instruction data also comprises periodic instruction data and aperiodic instruction data, except that the SSB-III protocol adopts a mailbox for data transmission for the two data;
G. storing the analyzed instruction data in a static memory according to NML neutral message organization format of an RCS library, wherein the memory storage format of the memory is divided into a periodic data storage area and an aperiodic data storage area, the periodic data storage area and the aperiodic data storage area are further divided into a command message memory and a status message memory, and the analyzed instruction data is required to be stored in a corresponding area according to a corresponding format;
H. mapping the instruction data memory to a user space by adopting an mmap mechanism;
I. adopting an NML message communication mechanism of an RCS library to exchange data with an upper user state motion control component;
J. waiting for the next interrupt period to poll the data packet.

Claims (6)

1. The real-time Ethernet field bus network data packet processing method based on the network card is characterized by comprising the following steps of:
determining a transmission path of the real-time Ethernet field bus data packet in the original network card driver through debugging information output by the kernel debugging function, and establishing a capturing point of the real-time Ethernet bus data packet in the network card driver;
capturing real-time Ethernet bus data packets based on the native network card driver aiming at the real-time Ethernet bus data packet capturing points built in the network card driver;
according to the bus protocol type of the real-time Ethernet bus data packet, analyzing and processing the real-time Ethernet bus data packet in a native network card driver;
according to the analyzed real-time Ethernet bus data, performing data exchange between a bottom layer driver based on a memory mapping mechanism and a real-time application program of a user space;
the capturing of the real-time Ethernet bus data packet based on the native network card driver specifically comprises the following steps:
opening up a static memory for storing real-time Ethernet bus data packets in a kernel space;
selecting an interrupt source, setting interrupt as periodic trigger and setting interrupt period, and completing capturing of real-time Ethernet field bus data packets in an interrupt service routine;
the data is received in an interrupt-free mode, and the receiving interrupt generated when the real-time Ethernet bus data packet in the network card is mapped to the annular queue is shielded;
the data is read in a polling mode, and real-time Ethernet bus data packets in the annular queue are read into the opened static memory by continuously polling the network card.
2. The network card-based real-time ethernet fieldbus network packet processing method of claim 1 in which said real-time ethernet fieldbus packet type comprises any one of EtherCAT protocol and SSB-III protocol.
3. The method for processing real-time ethernet fieldbus network packets based on a network card according to claim 1, wherein said network card is a MAC controller plus PHY chip control structure.
4. The method for processing real-time ethernet fieldbus network packets based on a network card of claim 1 in which said capture point is located behind a circular queue to which the network card DMA maps.
5. The method for processing real-time ethernet field bus network packets according to claim 1 or 2, wherein the analyzing the real-time ethernet field bus packets in the native network card driver specifically comprises:
opening a static memory for storing the parsed instruction data;
analyzing the real-time Ethernet bus data packet in the native network card driver, and determining the type of the real-time Ethernet bus data packet;
analyzing instruction data in the real-time Ethernet bus data packet according to the type of the real-time Ethernet bus data packet;
and storing the analyzed instruction data in a static memory according to a data organization format.
6. The method for processing real-time ethernet fieldbus network packets based on network card according to claim 1, wherein said data exchange between the bottom driver and the real-time application program in the user space based on the memory mapping mechanism is specifically:
mapping the memory where the instruction data are located to a user space by adopting a memory mapping mechanism;
exchanging data with a real-time application program of a user space by adopting a message communication mechanism;
waiting for the next periodic polling of the data packet.
CN202011276999.4A 2020-11-16 2020-11-16 Real-time Ethernet field bus network data packet processing method based on network card Active CN114513382B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202011276999.4A CN114513382B (en) 2020-11-16 2020-11-16 Real-time Ethernet field bus network data packet processing method based on network card

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011276999.4A CN114513382B (en) 2020-11-16 2020-11-16 Real-time Ethernet field bus network data packet processing method based on network card

Publications (2)

Publication Number Publication Date
CN114513382A CN114513382A (en) 2022-05-17
CN114513382B true CN114513382B (en) 2023-07-25

Family

ID=81546963

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011276999.4A Active CN114513382B (en) 2020-11-16 2020-11-16 Real-time Ethernet field bus network data packet processing method based on network card

Country Status (1)

Country Link
CN (1) CN114513382B (en)

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101582895A (en) * 2009-06-18 2009-11-18 重庆邮电大学 EPA-based embedded industrial wireless WIA-PA gateway
CN101841470A (en) * 2010-03-29 2010-09-22 东南大学 High-speed capturing method of bottom-layer data packet based on Linux
CN103117900A (en) * 2013-02-01 2013-05-22 山东大学 Configurable industrial Ethernet data parsing system and parsing method
CN103269284A (en) * 2013-05-17 2013-08-28 汉柏科技有限公司 Method for capturing real-time network data
CN105187304A (en) * 2014-06-16 2015-12-23 阿自倍尔株式会社 Gateway device and packet capturing method

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101582895A (en) * 2009-06-18 2009-11-18 重庆邮电大学 EPA-based embedded industrial wireless WIA-PA gateway
CN101841470A (en) * 2010-03-29 2010-09-22 东南大学 High-speed capturing method of bottom-layer data packet based on Linux
CN103117900A (en) * 2013-02-01 2013-05-22 山东大学 Configurable industrial Ethernet data parsing system and parsing method
CN103269284A (en) * 2013-05-17 2013-08-28 汉柏科技有限公司 Method for capturing real-time network data
CN105187304A (en) * 2014-06-16 2015-12-23 阿自倍尔株式会社 Gateway device and packet capturing method

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
"基于AM3358处理器的嵌入式实时EtherCAT主站的构建";李备备;《组合机床与自动化加工技术》(第5期);第1-3节 *

Also Published As

Publication number Publication date
CN114513382A (en) 2022-05-17

Similar Documents

Publication Publication Date Title
CN109347884B (en) Method and device for converting real-time Ethernet to field bus and storage medium
CN106648896B (en) Method for dual-core sharing of output peripheral by Zynq chip under heterogeneous-name multiprocessing mode
CN211207146U (en) EtherCAT main station system with double data channels
CN110519138B (en) Profibus-DP master station protocol implementation method and system
CN110658751B (en) Implementation method of EtherCAT field bus control system
CN109739786A (en) A kind of dma controller and isomery acceleration system
CN111123806A (en) EtherCAT main station system with double data channels
CN112147927B (en) Multi-axis motion control system for two-channel bus communication
CN105117319A (en) Method for realizing real-time monitoring of multi-channel MDIO (Management Data Input Output) devices based on FPGA
CN102291337B (en) Gateway for switching communication based on EtherCAT (Ethernet for Control and Automation Technology) protocol and Profibus-DP (Process Field Bus-Decentralized Periphery) protocol and communication method thereof
CN105487403A (en) Establishment of motion control system based on CAN and simulation modeling method
CN112000446A (en) Data transmission method and robot
CN106657115A (en) Frequency converter control system and protocol conversion card thereof
CN114513382B (en) Real-time Ethernet field bus network data packet processing method based on network card
CN114513383B (en) Real-time Ethernet field bus data packet processing method based on original socket
CN114185830A (en) Multi-processor communication method, device, system and storage medium based on mailbox
CN112039746A (en) Industrial control network system
CN112491620B (en) Multi-channel data transmission controller based on SRIO and adjusting method
CN106603113A (en) Radar signal processor external communication control system
CN112333067B (en) Communication system and method for parallel operation of multiple controller systems
US7443886B1 (en) Communication protocol system and method
CN113609052A (en) Chip simulation system based on FPGA and microprocessor and implementation method
CN114509993B (en) Autonomous controllable numerical control system construction method based on domestic CPU
CN114513381B (en) AF_XDP-based real-time Ethernet field bus data packet processing method
CN108011751B (en) Airborne FlexRay communication interface device and method

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant