Protocol message cross-layer communication method and device and electronic equipment

A protocol message and communication method technology, which is applied in the field of devices and electronic equipment, and the field of protocol message cross-layer communication method, can solve problems such as waste of computing resources, packet loss of protocol messages, etc., and achieve the goal of reducing waste and improving safety and reliability Effect

Inactive Publication Date: 2018-10-12
SHENZHEN FORWARD IND CO LTD
4 Cites 11 Cited by

AI-Extracted Technical Summary

Problems solved by technology

[0006] No matter which one is used, it will cause a waste of computing resources, and when there is a proto...
the structure of the environmentally friendly knitted fabric provided by the present invention; figure 2 Flow chart of the yarn wrapping machine for environmentally friendly knitted fabrics and storage devices; image 3 Is the parameter map of the yarn covering machine
View more

Method used

In the above-mentioned process of sending protocol message, the cross-layer communication of each protocol message has independent protocol family support, and there are different sending and receiving queues, so that other protocol messages cross-layer when avoiding message being attacked Packet loss occurs during communication; it solves the problem that in the existing cross-layer tec...
the structure of the environmentally friendly knitted fabric provided by the present invention; figure 2 Flow chart of the yarn wrapping machine for environmentally friendly knitted fabrics and storage devices; image 3 Is the parameter map of the yarn covering machine
View more

Abstract

The invention provides a protocol message cross-layer communication method and device and electronic equipment, and relates to the field of communication technology. The method comprises the followingsteps: calling a sending function provided by a kernel, and filling message data information and extension information of a protocol message needing to be sent; calling a packet processing callback function in a pre-created socket in the kernel, and switching the protocol message from a user-mode space to a kernel-mode space; and packaging the protocol message switched into the kernel-mode space,and sending the packaged protocol message to a specified outcoming interface according to the extension information. Through adoption of the protocol message cross-layer communication method providedby the embodiment of the invention, the sent protocol message can be processed correspondingly, and enters a corresponding kernel processing branch, thereby reduce the waste of system resources. Whena certain protocol message has burst traffic, the cross-layer communication of other protocol messages is not influenced, thereby improving the security and reliability of a network.

Application Domain

Technology Topic

Image

  • Protocol message cross-layer communication method and device and electronic equipment
  • Protocol message cross-layer communication method and device and electronic equipment
  • Protocol message cross-layer communication method and device and electronic equipment

Examples

  • Experimental program(3)

Example Embodiment

[0050] Example 1:
[0051] An embodiment of the present invention provides a method for cross-layer communication of protocol packets. The execution body of the method is a CPU that has received packet processing, that is, the CPU has received the protocol packet and stores the protocol packet in a pre-created in the socket's buffer. see figure 1 As shown, the method includes the following steps:
[0052] S101: Call the sending function provided by the kernel, and fill in the message data information and extension information of the protocol message to be sent.
[0053] The above message data information and extension information are stored in the buffer of the pre-created socket during the packet receiving process. The protocol processing module calls the system call send function (sendto) to fill in the data of the protocol message to be sent. The parameter part of the sending address option is filled with some extended information (such as the Layer 2 header, the number of the outgoing interface...).
[0054] Before the above step S101, an extended protocol number needs to be defined in the kernel, that is, a socket is pre-created in the kernel, and the protocol family is re-registered, which mainly includes the registration of the socket release callback function and the packet sending processing callback function. The process includes the following steps, see figure 2 shown:
[0055] S201: Determine whether there is a raw socket that is allowed to be used.
[0056] Specifically, it is judged whether the user is allowed to use the raw socket, that is, the raw socket RAW SOCKET, for security control.
[0057] If yes, execute step S202: determine whether to create an original socket.
[0058] If not, return an error.
[0059] After judging whether to create the original socket, if it agrees to create, then execute step S203: allocate the storage space of the original socket, and initialize the original socket; the initialization includes: basic data initialization, protocol family number initialization, set The initialization of the callback function of receiving and releasing and the initialization of the callback function of sending packets.
[0060] Specifically, through the function void sock_init_data(struct socket*sock,struct sock*sk) provided by the kernel, the entire structure of struct sock is initialized, including a lot of specific basic data. In addition, a series of protocol family numbers and socket release are also performed. The initialization of the callback function and the receiving packet processing callback function. After the initialization process is completed, step S204 is performed: adding the initialized socket to the protocol family socket chain list.
[0061] Raw sockets, allowing direct access to lower-level protocols, such as IP, ICMP protocols, it is often used to test new protocol implementations, or to access new devices configured in existing services, because raw sockets can be freely controlled A variety of protocols under Windows can control the underlying transport mechanism of the network, so raw sockets can be used to manipulate network layer and transport layer applications. For example, RAW SOCKET can be used to receive ICMP and IGMP protocol packets sent to the host, or to receive IP packets that cannot be processed by the TCP/IP stack, or to send some custom headers or custom protocol IP packets.
[0062] Network monitoring technology relies heavily on RAW SOCKET. The difference between raw sockets and standard sockets (standard sockets refers to the stream sockets and packet sockets introduced earlier) is: raw sockets Words can read and write IP packets that are not processed by the kernel, while stream sockets can only read data of the TCP protocol, and packet sockets can only read data of the UDP protocol. Therefore, if you want to access other protocols to send data you must use raw sockets.
[0063] After calling the sending function provided by the kernel and filling in the message data information and extension information of the protocol message to be sent, perform the following steps:
[0064] S102: Call the packet sending processing callback function in the socket pre-created in the kernel to convert the protocol message from the user-mode space to the kernel-mode space.
[0065] The specific conversion process includes the following steps, see image 3 shown:
[0066] S301: Call the copy function in the packet sending processing callback function to copy the message data information in the protocol message from the user state space to the message data buffer in the kernel state space.
[0067] S302: Copy the extended information in the protocol message to the address option buffer of the kernel state space.
[0068] Specifically, memcpy_fromiovec is used to copy the message data information and extension information of the protocol message from the user mode space to the data transmission buffer in the kernel mode space.
[0069] S103: Perform packet processing on the protocol packet converted to the kernel state space, and send the packet-processed protocol packet to a designated outbound interface according to the extended information.
[0070] Among them, the packet processing of the protocol packets converted to the kernel state space includes the following steps, see Figure 4 shown:
[0071] S401: Reassemble the message data information of the protocol message converted to the kernel state space into a standard Ethernet frame.
[0072] Send the packet-processed protocol packet to the specified outbound interface according to the extended information, which includes the following steps. See Figure 5 shown:
[0073] S501: Extract the interface information required for sending the protocol message from the extended information.
[0074] S502: Determine whether the interface information is correct.
[0075] If yes, step S503 is executed: the interface information is used as the designated outgoing interface, and the packet-processed protocol packet is sent to the designated outgoing interface.
[0076] Specifically, directly extract msg_name from the extended information structmsghdr filled in by the protocol processing module to parse out some extended information required for data transmission; make a legality judgment according to the outbound interface number of the extended information, and return an error directly; if it is correct, then Use the interface information as the designated outgoing interface, and send the packet-processed protocol packets to the designated outgoing interface.
[0077] In the above process of sending protocol packets, the cross-layer communication of each protocol packet is supported by an independent protocol family and has different sending and receiving queues, which avoids the occurrence of cross-layer communication of other protocol packets when the packet is attacked. Packet loss situation; solves the problem that in the existing cross-layer technology, when a certain protocol packet has burst traffic, it affects the cross-layer communication of other protocol packets, and improves the security and reliability of the network. In addition, the above process also solves the problem of unnecessary waste of system resources caused by packets entering unnecessary kernel processing branches in the existing cross-layer communication.
[0078] The method for cross-layer communication of a protocol message provided by the embodiment of the present invention includes: calling a sending function provided by the kernel, filling in the message data information and extension information of the protocol message to be sent; calling a socket in a pre-created socket in the kernel The packet processing callback function converts the protocol packet from the user mode space to the kernel mode space; performs packet processing on the protocol packet converted to the kernel mode space, and sends the packetized protocol packet to the specified outbound interface according to the extended information . The protocol packet cross-layer communication method provided by the embodiment of the present invention can perform corresponding processing on the protocol packet to be sent, so that it enters the corresponding kernel processing branch, thereby reducing the waste of system resources. When burst traffic occurs, the cross-layer communication of other protocol packets will not be affected, which improves the security and reliability of the network.

Example Embodiment

[0079] Embodiment 2:
[0080] An embodiment of the present invention provides a device for cross-layer communication of protocol packets, see Image 6 As shown, the apparatus includes: a protocol processing module 61 , a protocol family processing module 62 , and a packet sending module 63 .
[0081] The protocol processing module 61 is a module in the user mode, and the protocol family processing module 62 and the packet sending module 63 are modules in the kernel mode. The protocol processing module 61 is used to call the sending function provided by the kernel, and fill in the message data information and extension information of the protocol message to be sent; the protocol family processing module 62 is used to call the pre-created socket in the kernel. The packet sending processing callback function converts the protocol packet from the user mode space to the kernel mode space; the packet sending module 63 is used to encapsulate the protocol packet converted to the kernel mode space, and according to the extension information, the packetized protocol packet is processed. The message is sent to the specified outgoing interface.
[0082] In addition, the protocol family processing module 62 is also used to call the copy function in the packet sending processing callback function, and copy the packet data information in the protocol packet from the user mode space to the packet data buffer in the kernel mode space; The extended information in the text is copied to the address option buffer of the kernel space.
[0083] The packet sending module 63 is also used to extract the interface information required for sending the protocol message from the extended information; determine whether the interface information is correct; if so, use the interface information as the designated outbound interface, and send the packetized protocol message to the specified outgoing interface.
[0084] In the apparatus for cross-layer communication of protocol packets provided by the embodiments of the present invention, each module has the same technical features as the foregoing method for cross-layer communication of protocol packets, and therefore, the above functions can also be implemented. For the specific working process of each module in the device, refer to the above method embodiments, and details are not repeated here.

Example Embodiment

[0085] Embodiment three:
[0086] An embodiment of the present invention provides an electronic device, see Figure 7 As shown, the electronic device includes: a processor 70, a memory 71, a bus 72 and a communication interface 73, the processor 70, the communication interface 73 and the memory 71 are connected through the bus 72; Executable modules, such as computer programs. The processor implements the steps of the method as described in the method embodiment when the computer program is executed.
[0087] The memory 71 may include a high-speed random access memory (RAM, Random Access Memory), and may also include a non-volatile memory (non-volatile memory), such as at least one disk memory. The communication connection between the network element of the system and at least one other network element is realized through at least one communication interface 73 (which may be wired or wireless), and the Internet, wide area network, local network, metropolitan area network, etc. can be used.
[0088] The bus 72 may be an ISA bus, a PCI bus, an EISA bus, or the like. The bus can be divided into an address bus, a data bus, a control bus, and the like. For ease of presentation, Figure 7 is represented by a double-headed arrow, but does not imply that there is only one bus or one type of bus.
[0089]The memory 71 is used to store a program, and the processor 70 executes the program after receiving the execution instruction, and the method executed by the device defined by the stream process disclosed in any of the foregoing embodiments of the present invention can be applied to processing in the processor 70 , or implemented by the processor 70 .
[0090] The processor 70 may be an integrated circuit chip with signal processing capability. In the implementation process, each step of the above-mentioned method can be completed by a hardware integrated logic circuit in the processor 70 or an instruction in the form of software. The above-mentioned processor 70 may be a general-purpose processor, including a central processing unit (Central Processing Unit, CPU for short), a network processor (Network Processor, NP for short), etc.; it may also be a digital signal processor (Digital Signal Processing, DSP for short) , Application Specific Integrated Circuit (ASIC for short), Field-Programmable Gate Array (FPGA for short) or other programmable logic devices, discrete gate or transistor logic devices, and discrete hardware components. Various methods, steps, and logical block diagrams disclosed in the embodiments of the present invention can be implemented or executed. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like. The steps of the method disclosed in conjunction with the embodiments of the present invention may be directly embodied as executed by a hardware decoding processor, or executed by a combination of hardware and software modules in the decoding processor. The software modules may be located in random access memory, flash memory, read-only memory, programmable read-only memory or electrically erasable programmable memory, registers and other storage media mature in the art. The storage medium is located in the memory 71, and the processor 70 reads the information in the memory 71, and completes the steps of the above method in combination with its hardware.
[0091] The computer program product of the method for cross-layer communication of protocol packets provided by the embodiments of the present invention includes a computer-readable storage medium storing non-volatile program codes executable by a processor, and the instructions included in the program codes can be used to execute For the specific implementation of the methods described in the foregoing method embodiments, reference may be made to the method embodiments, and details are not described herein again.
[0092] Those skilled in the art can clearly understand that, for the convenience and brevity of description, for the specific working process of the above-described apparatus and electronic device, reference may be made to the corresponding process in the foregoing method embodiments, which will not be repeated here.
the structure of the environmentally friendly knitted fabric provided by the present invention; figure 2 Flow chart of the yarn wrapping machine for environmentally friendly knitted fabrics and storage devices; image 3 Is the parameter map of the yarn covering machine
Login to view more

PUM

no PUM

Description & Claims & Application Information

We can also present the details of the Description, Claims and Application information to help users get a comprehensive understanding of the technical details of the patent, such as background art, summary of invention, brief description of drawings, description of embodiments, and other original content. On the other hand, users can also determine the specific scope of protection of the technology through the list of claims; as well as understand the changes in the life cycle of the technology with the presentation of the patent timeline. Login to view more.
the structure of the environmentally friendly knitted fabric provided by the present invention; figure 2 Flow chart of the yarn wrapping machine for environmentally friendly knitted fabrics and storage devices; image 3 Is the parameter map of the yarn covering machine
Login to view more

Similar technology patents

Sheet product dispenser

ActiveUS20170290472A1Reduce wasteDomestic applicationsFull paperEngineering
Owner:GPCP IP HLDG LLC

Classification and recommendation of technical efficacy words

  • Reduce waste
  • Improve safety and reliability

Electric power supply device with electric shock protection function

Owner:国网安徽省电力有限公司铜陵市义安区供电公司
Who we serve
  • R&D Engineer
  • R&D Manager
  • IP Professional
Why Eureka
  • Industry Leading Data Capabilities
  • Powerful AI technology
  • Patent DNA Extraction
Social media
Try Eureka
PatSnap group products