CN114567583A - Method for transmitting routing message from network card to routing module through kernel - Google Patents
Method for transmitting routing message from network card to routing module through kernel Download PDFInfo
- Publication number
- CN114567583A CN114567583A CN202210175902.3A CN202210175902A CN114567583A CN 114567583 A CN114567583 A CN 114567583A CN 202210175902 A CN202210175902 A CN 202210175902A CN 114567583 A CN114567583 A CN 114567583A
- Authority
- CN
- China
- Prior art keywords
- tap
- message
- kernel
- file
- routing
- 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.)
- Pending
Links
Images
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L45/00—Routing or path finding of packets in data switching networks
- H04L45/14—Routing performance; Theoretical aspects
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L69/00—Network arrangements, protocols or services independent of the application payload and not provided for in the other groups of this subclass
- H04L69/16—Implementation or adaptation of Internet protocol [IP], of transmission control protocol [TCP] or of user datagram protocol [UDP]
Abstract
The invention provides a transmission method of routing messages from a network card to a routing module through a kernel, which comprises the following steps: when the VLAN is configured with the IP, a corresponding TAP is created, and a corresponding char device is generated under the file directory of the Linux device; when a TAP device is created, a corresponding char device is generated under a file directory of the Linux device, and a user program can open a file for reading and writing like opening a common file; when the SDK receives the routing message, calling a write () function to write the message into the TAP file; when the routing module sends a message through the protocol stack, a read () function is called to inquire whether data needing to be sent out exists on the TAP equipment or not from the kernel. The invention carries out message interaction between the SDK driver (user mode) and the kernel protocol stack by using TAP, only concerns the user mode, and has strong expansibility; the invention reduces programming complexity, uses programmers to concentrate on user states, and enhances code maintainability and expansibility.
Description
Technical Field
The invention relates to a transmission method of routing messages in a route (or a three-layer switch), in particular to a transmission method of routing messages from a network card to a routing module through a kernel.
Background
In a traditional three-layer device, each VLAN corresponds to an IP segment, and they can configure IP addresses to form a routing interface. When the vlan configures the ip, a network device (net _ device) is created in the linux kernel accordingly. When receiving the routing message, judging whether the destination ip is the vlan, if so, sending the message to the network equipment, and then transmitting the message to a network protocol stack in the kernel. The message is processed by the protocol stack and finally transmitted to the routing module (ospf, rip, bgp). On the contrary, when sending a network message, the routing module sends data into the network protocol stack through system call (socket), and finally reaches the network device (net _ device) of the corresponding VLAN, and then schedules the driver to transmit the message to the network device, so as to send the message out. When a plurality of three-layer vlans exist, a plurality of network devices can be created, coding relates to a kernel mode and a user mode, and the method is difficult and poor in expansibility.
The information disclosed in this background section is only for enhancement of understanding of the general background of the invention and should not be taken as an acknowledgement or any form of suggestion that this information forms the prior art already known to a person skilled in the art.
Disclosure of Invention
The invention aims to provide a method for transmitting a routing message from a network card to a routing module through a kernel, which aims to solve the problems in the prior art.
In order to achieve the purpose, the invention adopts the following technical scheme:
the invention provides a transmission method of routing messages from a network card to a routing module through a kernel, which comprises the following steps:
when the VLAN is configured with the IP, a corresponding TAP is established, and a corresponding char device is generated under the file directory of the Linux device;
when a TAP device is created, a corresponding char device is generated under a file directory of the Linux device, and a user program can open a file for reading and writing like opening a common file;
when the switching chip SDK receives a routing message, a write () function is called to write the message into a TAP file, at the moment, for a Linux network layer, the TAP equipment receives a packet of data, a kernel is requested to receive the data, and the data is transmitted to a routing module through a kernel protocol stack as if a common physical network card receives a packet of data from the outside;
when a message is sent by the routing module through the protocol stack, a read () function is called to inquire whether data needing to be sent exists on the TAP equipment or not from the kernel, and if so, the read () function is called to send the message through the SDK packet sending interface.
By adopting the technical scheme, the invention has the following beneficial effects:
the invention carries out message interaction between the SDK driver (user mode) and the kernel protocol stack by using TAP, only concerns the user mode, and has strong expansibility; the invention reduces programming complexity, uses programmers to concentrate on user states, and enhances code maintainability and expansibility.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, and it is obvious that the drawings in the following description are some embodiments of the present invention, and other drawings can be obtained by those skilled in the art without creative efforts.
FIG. 1 is a flow chart of a transmission method of routing messages from a network card to a routing module via a kernel according to the present invention;
fig. 2 is a flow chart of configuration of each device node of the TSN network according to the present invention.
Detailed Description
The technical solutions of the present invention will be described clearly and completely with reference to the accompanying drawings, and it is to be understood that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
The following detailed description of embodiments of the invention refers to the accompanying drawings. It should be understood that the detailed description and specific examples, while indicating the present invention, are given by way of illustration and explanation only, not limitation.
Referring to fig. 1, the present embodiment provides a method for transmitting a routing packet from a network card to a routing module via a kernel, including the following steps:
in the above figure, when VLAN configures IP, a corresponding TAP is created, and at this time, a corresponding char device is generated under the Linux device file directory.
When a TAP device is created, a corresponding char device is generated in a file directory of the Linux device, and a user program can open the file for reading and writing like opening a common file.
When the switching chip SDK receives the routing message, the write () function is called to write the message into the TAP file, at this time, for the Linux network layer, the TAP device receives a packet of data, the kernel is requested to receive the packet of data, and the packet of data is received from the outside through the kernel protocol stack to the routing module as if the ordinary physical network card receives the packet of data.
When a message is sent by the routing module through the protocol stack, a read () function is called to inquire whether data needing to be sent exists on the TAP equipment or not from the kernel, and if so, the read () function is called to send the message through the SDK packet sending interface.
According to the scheme, the TAP is used for performing message interaction with the kernel protocol stack in the SDK driver (user mode), only the user mode is concerned, and the expansibility is strong.
As shown in fig. 2, each device node of the TSN network is mainly configured to:
when configuring VLAN IP, creating TAP virtual equipment;
starting TAP tasks, mainly processing the receiving and sending messages of each TAP virtual device:
after the package is received from the SDK, judging which TAP virtual equipment is, and writing a message into the kernel through writing the corresponding char equipment;
polling whether each TAP equipment has a message from the kernel or not, and if so, calling an SDK packet sending interface to send out the message.
Finally, it should be noted that: the above embodiments are only used to illustrate the technical solution of the present invention, and not to limit the same; while the invention has been described in detail and with reference to the foregoing embodiments, it will be understood by those skilled in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some or all of the technical features may be equivalently replaced; and the modifications or the substitutions do not make the essence of the corresponding technical solutions depart from the scope of the technical solutions of the embodiments of the present invention.
Claims (1)
1. A transmission method for routing messages from a network card to a routing module through a kernel is characterized by comprising the following steps:
when the VLAN is configured with the IP, a corresponding TAP is created, and a corresponding char device is generated under the file directory of the Linux device;
when a TAP device is created, a corresponding char device is generated under a file directory of the Linux device, and a user program can open a file for reading and writing like opening a common file;
when the switching chip SDK receives a routing message, a write () function is called to write the message into a TAP file, at the moment, for a Linux network layer, the TAP equipment receives a packet of data, a kernel is requested to receive the data, and the data is transmitted to a routing module through a kernel protocol stack as if a common physical network card receives a packet of data from the outside;
when a message is sent by the routing module through the protocol stack, a read () function is called to inquire whether data needing to be sent exists on the TAP equipment or not from the kernel, and if so, the read () function is called to send the message through the SDK packet sending interface.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202210175902.3A CN114567583A (en) | 2022-02-24 | 2022-02-24 | Method for transmitting routing message from network card to routing module through kernel |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202210175902.3A CN114567583A (en) | 2022-02-24 | 2022-02-24 | Method for transmitting routing message from network card to routing module through kernel |
Publications (1)
Publication Number | Publication Date |
---|---|
CN114567583A true CN114567583A (en) | 2022-05-31 |
Family
ID=81715783
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202210175902.3A Pending CN114567583A (en) | 2022-02-24 | 2022-02-24 | Method for transmitting routing message from network card to routing module through kernel |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN114567583A (en) |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN103312601A (en) * | 2013-05-31 | 2013-09-18 | 汉柏科技有限公司 | Data message processing method from user mode to kernel mode |
CN103428226A (en) * | 2013-08-30 | 2013-12-04 | 天津汉柏汉安信息技术有限公司 | Method and system for communication of user state and inner core |
CN106101012A (en) * | 2016-07-06 | 2016-11-09 | 广州海格通信集团股份有限公司 | A kind of method of satellite IP gateway protocol adaptation |
CN108712308A (en) * | 2018-06-06 | 2018-10-26 | 郑州云海信息技术有限公司 | The method and apparatus that the network equipment is detected in virtual network |
-
2022
- 2022-02-24 CN CN202210175902.3A patent/CN114567583A/en active Pending
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN103312601A (en) * | 2013-05-31 | 2013-09-18 | 汉柏科技有限公司 | Data message processing method from user mode to kernel mode |
CN103428226A (en) * | 2013-08-30 | 2013-12-04 | 天津汉柏汉安信息技术有限公司 | Method and system for communication of user state and inner core |
CN106101012A (en) * | 2016-07-06 | 2016-11-09 | 广州海格通信集团股份有限公司 | A kind of method of satellite IP gateway protocol adaptation |
CN108712308A (en) * | 2018-06-06 | 2018-10-26 | 郑州云海信息技术有限公司 | The method and apparatus that the network equipment is detected in virtual network |
Non-Patent Citations (1)
Title |
---|
CHENGQIUMING: "TAP/TUN/VETH理解", Retrieved from the Internet <URL:https://blog.csdn.net/chengqiuming/article/details/79840092> * |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN108370343B (en) | Network hub, transfer method, and vehicle-mounted network system | |
JP7289332B2 (en) | Electronic control unit, frame generation method and program | |
CN1742473B (en) | Common protocol layer architecture and methods for transmitting data between different network protocols and a common protocol packet | |
JP4370999B2 (en) | Network system, node, node control program, and network control method | |
EP2533475B1 (en) | Method and system for host route reachability in packet transport network access ring | |
US20050147119A1 (en) | Computer program products supporting integrated communication systems that exchange data and information between networks | |
JP7192074B2 (en) | Network hub, transfer method and in-vehicle network system | |
US9240899B2 (en) | Method for implementing virtual network port and embedded device for implementing virtual network port | |
US7328270B1 (en) | Communication protocol processor having multiple microprocessor cores connected in series and dynamically reprogrammed during operation via instructions transmitted along the same data paths used to convey communication data | |
US7269661B2 (en) | Method using receive and transmit protocol aware logic modules for confirming checksum values stored in network packet | |
TWI535251B (en) | Method and system for low-latency networking | |
CN112637198B (en) | Multi-protocol self-adaption module design method based on OPC UA PubSub | |
CN107332834B (en) | PRP network connection method under Windows system | |
CN101222437B (en) | Method and system for transparent transmission of BPDU packet in two-layer switching network | |
CN101997772B (en) | Flow control method, device, system and network equipment | |
CN1276635C (en) | Priority enhanced information transfer device and its method | |
CN108494679A (en) | A kind of SSH message forwarding methods and device for realizing router based on linux system | |
CN114567583A (en) | Method for transmitting routing message from network card to routing module through kernel | |
CN109587749B (en) | Data sending method and system | |
CN104471538A (en) | Data stream processing method, device and system | |
CN104023091B (en) | A kind of multilink fusion method and equipment | |
US20040059806A1 (en) | System and method for indicating the status of a communications link/traffic activity on non-protocol aware modules | |
CN108881026A (en) | A kind of BGP message forwarding method and device for realizing router based on linux system | |
Cisco | Cisco IOS Bridging and IBM Networking Command Reference, Volume 1 Release 12.1 | |
Cisco | Bridging and IBM Networking Configuration Guide Cisco IOS Release 11.3 |
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 |