Disclosure of Invention
In view of this, embodiments of the present invention provide a message processing method and apparatus, so as to solve the problems in the prior art that a switch device sends a special management message and a normal management message in the same manner, which increases the burden of a TCP/IP protocol control channel and cannot locate a lost special message.
Therefore, the embodiment of the invention provides the following technical scheme:
the embodiment of the invention provides a message processing method, which comprises the following steps: receiving a message with a first mark; removing the first mark in the message in a physical layer, and adding a second mark in the message; wherein the first indicia is different from the second indicia; and sending the message added with the second mark to an application layer.
Optionally, the message with the first flag is obtained by adding the first flag to the message by a switch chip.
The embodiment of the invention also provides another message processing method, which comprises the following steps: acquiring a message; adding a second mark in the message; removing a second mark in the message in the physical layer, and adding a first mark in the message; wherein the first indicia is different from the second indicia; and sending the message added with the first mark to a switching chip.
Optionally, the message added with the first flag is sent to a port after the first flag is removed by a switch chip.
Optionally, the first flag is a DSA flag.
Optionally, the message includes at least one of: goose messages, sv messages.
An embodiment of the present invention provides a packet processing apparatus, including: the receiving module is used for receiving the message with the first mark; a first processing module, configured to remove the first flag in the message in a physical layer, and add a second flag in the message; wherein the first indicia is different from the second indicia; and the first sending module is used for sending the message added with the second mark to an application layer.
Optionally, the message with the first flag is obtained by adding the first flag to the message by a switch chip.
An embodiment of the present invention further provides another packet processing apparatus, including: the acquisition module is used for acquiring the message; the adding module is used for adding a second mark in the message; a second processing module, configured to remove a second flag from the message in the physical layer, and add the first flag to the message; wherein the first indicia is different from the second indicia; and the second sending module is used for sending the message added with the first mark to a switching chip.
Optionally, the message added with the first flag is sent to a port after the first flag is removed by a switch chip.
Optionally, the first flag is a DSA flag.
Optionally, the message includes at least one of: goose messages, sv messages.
The technical scheme of the embodiment of the invention has the following advantages:
the embodiment of the invention provides a message processing method and a device, which are used for receiving a message with a first mark, removing the first mark in the message in a physical layer, adding a second mark different from the first mark in the message, and sending the message added with the second mark to an application layer. The message is directly sent to the high-level application layer from the bottom physical layer, which is different from the prior art that the message is sent by the control channel of the TCP/IP protocol stack no matter the message is a common management message or a special management message, thereby reducing the burden of the control channel of the TCP/IP protocol stack. On the other hand, in the process of message transmission, different marks are added to the message when the message passes through different layers, and when the message is lost or is difficult to issue, the position of the lost message can be quickly positioned through the information of the different position marks, so that the time for searching and positioning the lost message is saved, and convenience is provided for the lost positioning of the message. The embodiment of the invention solves the problems that the switching equipment in the prior art sends the special management message and the common management message in the same way, so that the load of a TCP/IP protocol control channel is increased and the lost special message cannot be positioned.
Detailed Description
The technical solutions of the present invention will be described clearly and completely with reference to the accompanying drawings, and it should be understood that the described embodiments are some, but not all embodiments of the present invention. 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.
In the description of the present invention, it should be noted that the terms "center", "upper", "lower", "left", "right", "vertical", "horizontal", "inner", "outer", etc., indicate orientations or positional relationships based on the orientations or positional relationships shown in the drawings, and are only for convenience of description and simplicity of description, but do not indicate or imply that the device or element being referred to must have a particular orientation, be constructed and operated in a particular orientation, and thus, should not be construed as limiting the present invention. Furthermore, the terms "first," "second," and "third" are used for descriptive purposes only and are not to be construed as indicating or implying relative importance.
In the description of the present invention, it should be noted that, unless otherwise explicitly specified or limited, the terms "mounted," "connected," and "connected" are to be construed broadly, e.g., as meaning either a fixed connection, a removable connection, or an integral connection; can be mechanically or electrically connected; the two elements may be directly connected or indirectly connected through an intermediate medium, or may be communicated with each other inside the two elements, or may be wirelessly connected or wired connected. The specific meanings of the above terms in the present invention can be understood in specific cases to those skilled in the art.
In addition, the technical features involved in the different embodiments of the present invention described below may be combined with each other as long as they do not conflict with each other.
Example 1
The message processing method described in this embodiment is mainly used in communication devices of an electric power communication system, and can also be used in communication devices such as telecommunication, Unicom, Mobile, and the like.
In this embodiment, a message processing method is provided, fig. 1 is a flowchart of a message processing method according to an embodiment of the present invention, and in this embodiment, a process of sending a message from a physical layer to an application layer is described, as shown in fig. 1, the process includes the following steps:
step S101, receiving a message with a first mark; in the communication device of the power communication system, for example, the message with the first flag may be received from the switch chip, and the message with the first flag is obtained by adding the first flag to the message by the switch chip;
step S102, removing the first mark in the message in the physical layer, and adding a second mark in the message; wherein the first indicia is different from the second indicia; in the message transmission process, different marks are added to the message when the message passes through different layers, and when the message is lost or is difficult to issue, the position of the lost message can be quickly positioned through the information of the different position marks, so that the time for searching and positioning the lost message is saved, and convenience is provided for the lost positioning of the message; for example, the second flag may be a 0x9100 flag;
and step S103, sending the message added with the second mark to an application layer. The message is directly sent to the high-level application layer from the bottom-level physical layer.
Through the steps, the message with the first mark is received, the first mark in the message is removed from the physical layer, the second mark different from the first mark is added into the message, and the message with the second mark is sent to the application layer. The message is directly sent to the high-level application layer from the bottom physical layer, which is different from the prior art that the message is sent by the control channel of the TCP/IP protocol stack no matter the message is a common management message or a special management message, thereby reducing the burden of the control channel of the TCP/IP protocol stack. On the other hand, in the process of message transmission, different marks are added to the message when the message passes through different layers, and when the message is lost or is difficult to issue, the position of the lost message can be quickly positioned through the information of the different position marks, so that the time for searching and positioning the lost message is saved, and convenience is provided for the lost positioning of the message. The above steps solve the problems that the switching equipment in the prior art sends the special management message and the common management message in the same way, which causes the burden of increasing the TCP/IP protocol control channel and can not position the lost special message.
In an alternative embodiment, the first flag is a DSA flag.
In the field of power communication, in an optional embodiment, the message is a special management message, and may be, for example, a goose message or an sv message.
In this embodiment, another message processing method is further provided, fig. 2 is another flowchart of the message processing method according to the embodiment of the present invention, and in this embodiment, a process of sending a message from an application layer to a physical layer is described, as shown in fig. 2, the process includes the following steps:
step S201, obtaining a message; that is, the message is acquired in the application layer;
step S202, adding a second mark in the message; for example, a 0x9100 flag is marked in the message;
step S203, removing the second mark in the message in the physical layer, and adding the first mark in the message; wherein the first indicia is different from the second indicia; in the message transmission process, different marks are added to the message when the message passes through different layers, and when the message is lost or is difficult to issue, the position of the lost message can be quickly positioned through the information of the different position marks, so that the time for searching and positioning the lost message is saved, and convenience is provided for the lost positioning of the message;
step S204, the message added with the first mark is sent to the exchange chip.
Through the steps, the message is directly sent to the physical layer of the bottom layer from the application layer of the high layer, which is different from the prior art that the message is sent through the control channel of the TCP/IP protocol stack no matter the message is a common management message or a special management message, and the burden of the control channel of the TCP/IP protocol stack is reduced. On the other hand, in the process of message transmission, different marks are added to the message when the message passes through different layers, and when the message is lost or is difficult to issue, the position of the lost message can be quickly positioned through the information of the different position marks, so that the time for searching and positioning the lost message is saved, and convenience is provided for the lost positioning of the message. The above steps solve the problems that the switching equipment in the prior art sends the special management message and the common management message in the same way, which causes the burden of increasing the TCP/IP protocol control channel and can not position the lost special message.
After step S204, in an optional embodiment, after the switch chip receives the message with the first flag, the first flag in the message is removed, and the message is sent to the port through the switch chip.
In an alternative embodiment, the first flag is a DSA flag.
In the field of power communication, in an optional embodiment, the message is a special management message, and may be, for example, a goose message or an sv message.
This is described below in connection with a specific alternative embodiment.
According to the method for processing the special management message of the embedded system, provided by the embodiment of the invention, various special messages of the transformer substation can be positioned, if messages such as goose and sv exist, the method is applied to a power exchange management system, firstly, the hardware design of equipment meets the requirement of figure 3, and the equipment is powered on and started.
In the process of sending the message from the port to the application layer, in the process of power-on starting, the application program and the kernel are normally started, and the configuration exchange information of the exchange port can be managed and received.
Step 1, the system is powered on to run, the special management message packet is received and processed, bottom layer software communicates with an upper application protocol through an interrupt receiving function and middle package transmission of a network layer, after the system is powered on, DSA marks are added to a switching chip for the special management message coming from a port, the common switching message and the management message are not processed, then message data are sent to a linux bottom layer interrupt processing function together, and the message is detected, analyzed, recombined and packaged in the interrupt function.
And 2, judging whether the data packet is a special management message or not in the interrupt processing function packet receiving function, if so, removing the DSA label of the message, printing a special label (such as a 0x9100 label), and providing convenience for an application layer to analyze the message and support for message positioning through the 0x9100 label. If the message is not a special management message, no processing is performed.
And 3, the upper layer application receives the data packet, if the label is 0x9100, the data packet is considered as a special management message and is subjected to function processing of the special management message, and in the special processing function, classification processing of the message is performed according to different types of the message, for example, by identifying the type of the goose message (0x88B8), and analysis are performed according to data information of the message. If no label exists, the other messages are considered to be handed to other functions for processing.
In the process of sending the message to the port from the application layer, the system is powered on to operate, the special management message packet is sent and processed, the upper layer application protocol is called by the system, and the bottom layer sending function sends the management message to the corresponding hardware port.
And step 1, if the upper layer application sends a special management message to the corresponding port. Firstly, a label of 0x9100 is marked on a port special management message, other data packets are not processed, and the data packets are sent to a network equipment interface layer through a network protocol interface (such as a dev _ queue _ xmit () function).
And 2, after the data reaches the interface layer of the network equipment, entering linux bottom layer drive and entering an equipment drive function layer function (such as a hard _ start _ xmit () function).
And 3, in the function of the device driving function layer, removing the 0x9100 label of the special management message, marking a DSA label (only the data marked with the label can be forwarded), and not processing other types of data packets.
The following describes the location of lost messages by way of a specific alternative embodiment.
As shown in fig. 4, the packets are tracked at three positions (1), (2) and (3), when a 0x9100 tag is detected at position (3), it indicates that a packet may be lost in the channel transmitted to the application layer, if a DSA tag is detected at position (2) and no 0x9100 tag is detected at position (3), it indicates that a packet is lost on the path from the switch port to the bottom layer driver processing, and if a packet is present at position (1) and no DSA tag is present at position (2), it indicates that the packet does not pass through the switch chip.
Example 2
In this embodiment, a message processing apparatus is further provided, and the apparatus is used to implement the foregoing embodiments and preferred embodiments, and details of which have been already described are omitted. As used below, the term "module" may be a combination of software and/or hardware that implements a predetermined function. Although the means described in the embodiments below are preferably implemented in software, an implementation in hardware, or a combination of software and hardware is also possible and contemplated.
Fig. 5 is a block diagram of a message processing apparatus according to an embodiment of the present invention, and as shown in fig. 5, the message processing apparatus includes: a receiving module 51, configured to receive a message with a first flag; a first processing module 52, configured to remove the first flag from the message in the physical layer, and add a second flag to the message; wherein the first indicia is different from the second indicia; a first sending module 53, configured to send the message with the second flag added thereto to an application layer.
Optionally, the message with the first flag is obtained by adding the first flag to the message by the switch chip.
Optionally, the first flag is a DSA flag.
Optionally, the message includes at least one of: goose messages, sv messages.
Further functional descriptions of the modules are the same as those of the corresponding embodiments, and are not repeated herein.
Example 3
In this embodiment, a message processing apparatus is further provided, and the apparatus is used to implement the foregoing embodiments and preferred embodiments, and details of which have been already described are omitted. As used below, the term "module" may be a combination of software and/or hardware that implements a predetermined function. Although the means described in the embodiments below are preferably implemented in software, an implementation in hardware, or a combination of software and hardware is also possible and contemplated.
Fig. 6 is another structural block diagram of a message processing apparatus according to an embodiment of the present invention, as shown in fig. 6, including: an obtaining module 61, configured to obtain a message; an adding module 62, configured to add a second flag to the message; a second processing module 63, configured to remove the second flag from the message in the physical layer, and add the first flag to the message; wherein the first indicia is different from the second indicia; and a second sending module 64, configured to send the message with the first flag added thereto to a switch chip.
Optionally, the message added with the first flag is sent to the port after the first flag is removed by the switch chip.
Optionally, the first flag is a DSA flag.
Optionally, the message includes at least one of: goose messages, sv messages.
Further functional descriptions of the modules are the same as those of the corresponding embodiments, and are not repeated herein.
In summary, the embodiments of the present invention provide a special management channel, and when a management packet is lost or is difficult to issue, the position of the lost packet can be quickly located through information of different position tags, so that time for searching and locating the type of the lost packet is saved, and convenience is provided for message loss location. In the embodiment, a channel is directly established from the bottom layer for application, so that the special processing work of special messages in the management system of the power communication switching equipment is effectively solved, and the problem that some management services cannot stably run due to the sharing of the management channel and the service channel is solved. That is, the embodiment of the present invention directly processes the special management packet, and if the transmission of the special management packet is lost, the device tracks the packet, and according to different labels of the packet at different positions, the position of the lost packet can be quickly located, thereby saving the reliability of network packet transmission.
As will be appreciated by one skilled in the art, embodiments of the present invention may be provided as a method, system, or computer program product. Accordingly, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present invention may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The present invention is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
It should be understood that the above examples are only for clarity of illustration and are not intended to limit the embodiments. Other variations and modifications will be apparent to persons skilled in the art in light of the above description. And are neither required nor exhaustive of all embodiments. And obvious variations or modifications therefrom are within the scope of the invention.