104 message transmission method and device based on priority queue algorithm
Through the 104 message transmission method based on the priority queue algorithm, the problem of low transmission efficiency of high priority message during network congestion is solved, and efficient and reliable message transmission is achieved, avoiding the blocking of sub-priority messages risk.
Patent Information
- Application Number
- CN202211429362.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-11-15
- Publication Date
- 2024-11-22
- Estimated Expiration
- 2042-11-15
AI Technical Summary
The existing IEC104 regulations cannot effectively ensure the rapid transmission of high-priority messages when network congestion is encountered, and sub-priority messages are easily blocked, resulting in the phenomenon of "head of team blocking".
Using the priority queue algorithm, by determining the priority of each 104 message, updating the structure parameters, and reordering it in the priority queue, ensuring that high-priority messages are transmitted in a timely manner and preventing sub-priority messages from being blocked.
Ensure the rapid transmission of high-priority data during network congestion and avoid permanent blocking of sub-priority messages, improving the efficiency and reliability of data transmission.
Smart Images

Figure CN115801697B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of data processing, and in particular to a 104 message transmission method and device based on a priority queue algorithm. Background Art
[0002] IEC104 protocol has become an important transmission method for data communication between devices in power secondary systems. IEC104 (IEC60870-5-104) protocol is formulated by the International Electrotechnical Commission. IEC104 protocol is located in the application layer of the standard network architecture, and data is transmitted through the TCP / IP protocol stack.
[0003] The IEC104 protocol has its own message format. By using multiple types of messages, the IEC104 protocol can complete a variety of functions. Different functions have different priorities. The IEC104 protocol defines the corresponding message priority according to the importance of different functions, and compiles the recommended priority order in the standard file of the protocol. However, when applying the 104 protocol, some data transmission systems do not optimize the transmission system based on the parameter of message priority. When the network transmission bandwidth is greater than the demand and the delay is low, that is, when there is no transmission bottleneck in the network, all messages can be transmitted on time. In this case, priority can be ignored, and the transmission delay is generally in the millisecond level. However, when there is a transmission bottleneck in the network, such as network congestion caused by damaged network equipment, or a large amount of data transmission in a short period of time, the above system will not be able to send high-priority messages in a timely and effective manner. Although some systems take priority parameters into consideration, the scheduling method is too mechanical, which can easily cause sub-priority messages to be blocked in the sending queue, resulting in "head of line blocking".
[0004] In the early days, the types of devices that used 104 protocol for transmission were single, and the communication volume was relatively fixed. With the advancement of intelligent power grids, the amount of data that needs to be transmitted through the network will become larger and larger, and the types of devices will also increase. As the amount and types of data that need to be transmitted using 104 protocol increase, when data is transmitted in a centralized manner, it is very easy to generate "burst transmission" in the network, which will cause network congestion.
[0005] When using the IEC104 protocol for network transmission in existing power systems, some systems are not optimized according to priority parameters and use a "first come, first served" strategy. That is, data is transmitted in the order of the message arrival time. This type of system generally fills the send buffer of the network protocol stack directly after receiving the 104 protocol message from the application. When there is no bottleneck in network transmission, this type of transmission method will not block the transmission of various messages. As the number and types of devices that need to use the 104 protocol for transmission increase, network congestion caused by burst transmission is very likely to occur. In this case, the above transmission method will not guarantee that high-priority messages can reach the receiver first.
[0006] Some systems take priority parameters into consideration, but the scheduling method uses a strict priority strategy, which specifies that some instructions can be directly queued for priority transmission. Although this transmission method takes priority parameters into consideration and ensures that some instructions can be transmitted first, it is too mechanical to use. Message priority is not a simple binary classification problem of "priority" or "non-priority", but is divided into multiple priority categories. Using this method, it is easy to block several types of "secondary priority" messages in the sending queue until the life cycle of these messages expires and they cannot be sent, resulting in a "head of line blocking" problem.
[0007] There is currently no effective solution to the problem in the prior art that 104 messages cannot be quickly transmitted with high efficiency and high priority when the network is congested. Summary of the invention
[0008] An embodiment of the present invention provides a 104 message reordering and transmission method based on a priority queue algorithm, by determining the priority of each 104 message, determining the structure parameters of the message, reordering in the priority queue according to the structure parameters, and transmitting the 104 message at the first of the priority queue, so as to solve the problem of ensuring priority transmission of high and low priority data when network congestion occurs.
[0009] To achieve the above-mentioned purpose, an embodiment of the present invention provides a 104 message transmission method based on a priority queue algorithm, including: obtaining a current 104 message and the type of the current 104 message; determining the priority of the current 104 message according to the type of the current 104 message and a preset type priority table; when the current 104 message has not entered the cache area, updating all the structure parameters in the priority queue of the cache area, popping out the structure parameter at the first position of the priority queue and sending its corresponding 104 message; when the current 104 message enters the cache area, calculating the structure parameters corresponding to the current 104 message according to the priority of the current 104 message, inserting the structure parameters corresponding to the current 104 message into the priority queue, popping out the structure parameter at the first position of the priority queue and sending its corresponding 104 message.
[0010] Further optionally, the structure parameters include: message ID, priority, number of waits and response level;
[0011] The corresponding structure parameters are calculated according to the priority of the current message 104, including: numbering the current message 104 to obtain the message ID of the current message 104, and adding the message ID to the first two bytes of the current message 104; assigning the waiting number of the current message 104 to 0; adding the priority to the structure parameters; and calculating the response level according to the waiting number and the priority.
[0012] Further optionally, inserting the structure parameters corresponding to the current message 104 into the priority queue includes: inserting the structure parameters into the priority queue for reordering according to the size of the response level in the structure parameters; wherein, the structure parameters with larger response levels are positioned more forward in the priority queue; and updating all structure parameters in the priority queue.
[0013] Further optionally, updating all structure parameters in the priority queue includes: adding 1 to the number of waiting times in each structure parameter; and calculating the latest response level corresponding to each structure parameter according to the number of waiting times and the priority.
[0014] Further optionally, popping out the structure parameter at the first position of the priority queue and sending its corresponding 104 message includes: identifying the first two bytes of the 104 message corresponding to the structure parameter at the first position of the priority queue; deleting the first two bytes of the 104 message, and sending the 104 message.
[0015] Another invention, an embodiment of the present invention also provides a 104 message transmission device based on a priority queue algorithm, including: a data acquisition module, used to obtain the current 104 message and the type of the current 104 message; a priority determination module, used to determine the priority of the current 104 message according to the type of the current 104 message and a preset type priority table; a first message transmission module, used to update all structure parameters in the priority queue of the cache area when the current 104 message has not entered the cache area, pop up the structure parameter at the first position of the priority queue and send its corresponding 104 message; a second message transmission module, used to calculate the structure parameters corresponding to the current 104 message according to the priority of the current 104 message when the current 104 message enters the cache area, insert the structure parameters corresponding to the current 104 message into the priority queue, pop up the structure parameter at the first position of the priority queue and send its corresponding 104 message.
[0016] Further optionally, the structure parameters include: message ID, priority, number of waits and response level;
[0017] The second message transmission module includes: a message ID calculation submodule, which is used to number the current message 104, obtain the message ID of the current message 104, and add the message ID to the first two bytes of the current message 104; a waiting number determination submodule, which is used to assign the waiting number of the current message 104 to 0; a priority adding submodule, which is used to add the priority to the structure parameter; a response level calculation submodule, which is used to calculate the response level according to the waiting number and the priority.
[0018] Further optionally, the second message transmission module also includes: a reordering submodule, used to insert the structure parameters into the priority queue for reordering according to the size of the response level in the structure parameters; wherein, the structure parameters with larger response levels are positioned more forward in the priority queue; and a structure parameter updating submodule, used to update all structure parameters in the priority queue.
[0019] Further optionally, the structure parameter updating submodule includes: a waiting times updating unit, used to add 1 to the waiting times in each structure parameter; and a response level updating unit, used to calculate the latest response level corresponding to each structure parameter according to the waiting times and the priority.
[0020] Further optionally, the second message transmission module also includes: an identification submodule, used to identify the first two bytes of the 104 message corresponding to the structure parameter located at the first position of the priority queue; a message ID deletion submodule, used to delete the first two bytes of the 104 message and send the 104 message.
[0021] The above technical solution has the following technical effects: by calculating the priority of each 104 message, the structure parameters of each 104 message are determined, the structure parameters are inserted into the priority queue, and the structure parameters at the first position of the priority queue are popped out, and the corresponding 104 message is sent. When network congestion occurs, it can ensure that high-priority data is transmitted first, and also ensure that the transmission of secondary priority messages will not be blocked all the time.
[0022] At the same time, the present invention also provides a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, and the above method is implemented when the processor executes the computer program.
[0023] At the same time, the present invention also provides a computer-readable storage medium, which stores a computer program for executing the above method.
[0024] In order to make the above and other purposes, features and advantages of the present invention more obvious and easy to understand, preferred embodiments are specifically cited below and described in detail with reference to the accompanying drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0025] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0026] Figure 1 A flowchart of a 104 message transmission method based on a priority queue algorithm provided in an embodiment of the present invention;
[0027] Figure 2 It is a schematic diagram of the location of the 104 protocol in the network protocol stack in the prior art;
[0028] Figure 3 It is a schematic diagram of the location of the buffer area of the 104 message provided in an embodiment of the present invention;
[0029] Figure 4 is a flow chart of a method for calculating structural parameters provided by an embodiment of the present invention;
[0030] Figure 5 is a flow chart of a method for inserting structure parameters into a priority queue provided by an embodiment of the present invention;
[0031] Figure 6 is a flow chart of a method for updating structure parameters provided by an embodiment of the present invention;
[0032] Figure 7 is a flow chart of a method for sending a message provided by an embodiment of the present invention;
[0033] Figure 8 is a flow chart of a method for sending messages in rounds provided by an embodiment of the present invention;
[0034] Fig. 9 It is a structural schematic diagram of a message transmission device 104 based on a priority queue algorithm provided in an embodiment of the present invention;
[0035] Fig.10 It is a structural schematic diagram of a submodule responsible for calculating structure parameters in the second message transmission module provided in an embodiment of the present invention;
[0036] Fig.11 It is a structural diagram of a submodule responsible for inserting structure parameters into a priority queue in a second message transmission module provided in an embodiment of the present invention;
[0037] Fig.12 is a schematic diagram of the structure of a structure parameter updating submodule provided in an embodiment of the present invention;
[0038] Fig.13 It is a structural diagram of a submodule responsible for message sending in the second message transmission module provided in an embodiment of the present invention.
[0039] Reference numerals: 100 - data acquisition module 200 - priority determination module 300 - first message transmission module 400 - second message transmission module 4001 - message ID calculation submodule 4002 - waiting number determination submodule 4003 - priority addition submodule 4004 - response level calculation submodule 4005 - reordering submodule 4006 - structure parameter update submodule 40061 - waiting number update unit 40062 - response level update unit 4007 - identification submodule 4008 - message ID deletion submodule DETAILED DESCRIPTION
[0040] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0041] In order to solve the problem that the prior art cannot quickly transmit 104 messages with high efficiency and high priority when the network is congested, an embodiment of the present invention provides a 104 message transmission method based on a priority queue algorithm, which is characterized by comprising:
[0042] S1. Obtain the current message 104 and the type of the current message 104;
[0043] The 104 message refers to the message transmitted by the 104 protocol, which is called the Application Protocol Data Unit (APDU).
[0044] IEC 104 (IEC 60870-5-104) is mainly used for power system control and information collection. IEC 104 is based on the transport layer TCP protocol.
[0045] Figure 2 FIG. 1 is a schematic diagram of the location of the 104 protocol in the network protocol stack in the prior art, such as Figure 2 As shown, the 104 protocol is located in the application layer of the standard network architecture, and its message content comes from power equipment that needs to use the network to transmit remote information, telemetry, remote control and other data. After the 104 protocol encapsulates the above information into a 104 protocol message, it uses the TCP / IP protocol stack in the operating system for data transmission, which uses port 2404.
[0046] According to the information content to be transmitted in the 104 protocol message, the message type can be divided into several categories. When obtaining the message, the type of the 104 message needs to be determined at the same time.
[0047] As an optional implementation, the type of each message 104 may be determined according to an identifier of a specific byte of each message 104 .
[0048] Specifically, the application protocol control information in the 104 message mainly defines various types of 104 message formats, which are used to implement the transmission control of the 104 message; the application service data unit in the 104 message defines "TI (type identification, TYPEIDENTIFICATION), COT (cause of transmission, CAUSE OF TRANSMISSION), call qualifier (QOI), information object arrangement (SQ)" and other information, which are used to implement the functions of different messages. The message priority is mainly identified by the above parameters in the 104 message. For example, the initialization end message is identified by the I format message (TI=70, COT=4), the remote control command response message is identified by the I format message (TI=45, COT=7 or 10), the event sequence record message is identified by the I format message (TI=1 or 30, COT=4, SQ=1), and the clock synchronization response message is identified by the I format message (TI=103, COT=7). The above content is an example. In fact, the systems in different places will adjust the message content according to the work needs. When actually using it, you need to refer to the standard documents of the 104 protocol in different places.
[0049] S2. Determine the priority of the current message 104 according to the type of the current message 104 and the preset type priority table;
[0050] The type of the current message 104 is compared with the preset type priority table to determine the priority of the current message 104 for transmission.
[0051] The preset type priority table provided in this embodiment is shown in Table 1, and its priority gradually decreases as the sequence number increases.
[0052] Table 1
[0053]
[0054]
[0055] S3. When the current message 104 does not enter the buffer area, all the structure parameters in the priority queue of the buffer area are updated, the structure parameter at the first position in the priority queue is popped out and the corresponding message 104 is sent;
[0056] Figure 3 104 is a schematic diagram of the location of the buffer area of the message provided in the embodiment of the present invention, such as Figure 3 As shown, in order to realize the priority transmission function of the 104 message, the embodiment of the present invention needs to design a sending buffer area. The sending buffer area refers to the location where the message is stored before it is pushed to the TCP / IP protocol stack after the message is encapsulated by the 104 protocol.
[0057] The buffer area stores a priority queue, which is composed of structure parameters. Each structure parameter corresponds to a 104 message. Of course, there may be a situation where no structure parameter exists in the priority queue.
[0058] As an optional implementation, the priority queue is a priority queue implemented based on a max-heap, which is a complete binary tree, and its property is that the value of each node is greater than or equal to the value of its left and right child nodes.
[0059] The process of sending a message is regarded as a round. The embodiment of the present invention is performed in rounds. In each round, at most one message is sent from the buffer area.
[0060] When the buffer determines that no new 104 message enters the buffer, all structure parameters in the priority queue of the buffer are updated. At this time, if there are structure parameters in the priority queue, the structure parameters at the head of the priority queue are directly popped out, and the 104 message corresponding to the structure parameters is sent.
[0061] S4. When the current message 104 enters the cache area, the structure parameters corresponding to the current message 104 are calculated according to the priority of the current message 104, the structure parameters corresponding to the current message 104 are inserted into the priority queue, the structure parameters at the first position of the priority queue are popped out and the corresponding message 104 is sent.
[0062] When the buffer determines that a new 104 message has entered, the structure parameters of the current 104 message are calculated first, and the structure parameters of the current 104 message are inserted into the priority queue for reordering. Then, the structure parameters of all 104 messages in the priority queue are updated. At this time, because a new message has been inserted into the buffer, there is at least one 104 message waiting to be sent. The structure parameters at the head of the priority queue are popped out, and the 104 message corresponding to the structure parameters is popped out and sent.
[0063] As an optional implementation, the structure parameters include: message ID, priority, waiting times and response level;
[0064] Figure 4 is a flow chart of a method for calculating structural parameters provided by an embodiment of the present invention, such as Figure 4 As shown, the corresponding structure parameters are calculated according to the priority of the current message 104, including:
[0065] S401, numbering the current message 104, obtaining the message ID of the current message 104, and adding the message ID to the first two bytes of the current message 104;
[0066] S402, assign the waiting times of the current message 104 to 0;
[0067] S403, adding the priority into the structure parameter;
[0068] S404: Calculate the response level according to the number of waiting times and the priority.
[0069] The buffer area allocates structure parameters for each message that arrives 104. The structure parameters are used to identify the message in the buffer area and determine the response level of the message in the buffer area according to the priority and waiting time, as shown in Table 2.
[0070] Table 2
[0071]
[0072]
[0073] As an optional implementation, Figure 5 is a flow chart of a method for inserting structure parameters into a priority queue provided by an embodiment of the present invention, such as Figure 5As shown, according to the structure parameters corresponding to the current message 104, the current message 104 is inserted into the priority queue, including:
[0074] S405, inserting the structure parameters into the priority queue for reordering according to the size of the response level in the structure parameters; wherein the structure parameter with a larger response level is positioned more forward in the priority queue;
[0075] According to the response level in the structure parameters of the current message 104, the corresponding structure parameters are inserted into the priority queue for reordering. Since the present embodiment uses a priority queue based on a max-heap implementation, based on the properties of the max-heap, when the structure parameters are inserted into the priority queue according to the response level, the structure parameters with the largest response level can be automatically recorded at the top of the priority queue. Specifically, when the cache receives the current message 104, its response level is calculated, and the structure parameters of the current message 104 are inserted into the tail of the priority queue. At this time, the order of the structure parameters in the priority queue will be automatically adjusted, and the structure parameter with the largest response level will be recorded at the top.
[0076] S406: Update all structure parameters in the priority queue.
[0077] After reordering, all structure parameters in the priority queue are updated according to uniform rules to execute the next round of message sending procedures.
[0078] As an optional implementation, Figure 6 is a flow chart of a method for updating structure parameters provided by an embodiment of the present invention, such as Figure 6 As shown, update all structure parameters in the priority queue, including:
[0079] S4061, add 1 to the number of waiting times in each structure parameter;
[0080] The number of waiting times in each structure parameter in the priority queue is increased by 1, which means that the structure parameter has completed another round of waiting.
[0081] S4062. Calculate the latest response level corresponding to each structure parameter according to the number of waiting times and the priority.
[0082] Then, the latest response level corresponding to each structure parameter is calculated based on the number of waits and the priority. This update operation will not destroy the properties of the max-heap priority queue (the value of each node is greater than or equal to the values of its left and right child nodes), so there is no need to reorder.
[0083] The response level is calculated based on the number of wait times and priority using the following formula:
[0084] q=a*p+b*t
[0085] Among them, q is the response level, p is the priority, t is the number of waiting times, and parameters a and b are the scaling factors, which can be assigned by the administrator. The default values are a=1 and b=1.
[0086] When the buffer area does not detect the entry of 104 message, the method for updating the structure parameters is the same as above.
[0087] As an optional implementation, Figure 7 is a flow chart of a method for sending a message provided by an embodiment of the present invention, such as Figure 7 As shown, the structure parameter at the first position of the priority queue is popped out and the corresponding 104 message is sent, including:
[0088] S407, identifying the first two bytes of the 104 message corresponding to the structure parameter at the first position of the priority queue;
[0089] Identify the message ID in the first two bytes of the 104 message corresponding to the structure parameter of the priority queue header.
[0090] S408, delete the first two bytes of the 104 message, and send the 104 message.
[0091] The first two bytes of the message 104 are deleted, that is, the message ID is deleted, and then the message is sent.
[0092] Figure 8 is a flow chart of a method for sending messages in rounds according to an embodiment of the present invention. Figure 8 As shown, the message sending process is carried out in rounds, with the priority queue as the main perspective. In each round, at most one message is sent from the buffer area.
[0093] The transmission method of the present invention first determines whether there is a new message entering the sending buffer area in this round. If not, the waiting number parameter t in all structure parameters in the priority queue is added by 1, and then the response level q in the structure parameter is updated. This update will not destroy the priority queue property based on the big top heap (the value of each node is greater than or equal to the value of its left and right child nodes), so the priority queue does not need to be reordered. Then, if there is a message to be sent in the queue, the priority queue header structure parameter is directly popped out, the corresponding message header ID mark is removed, and then the message is sent.
[0094] If a new message enters the sending buffer, the structure parameters for the message are calculated first, and according to the result of the response level q, it is inserted into the priority queue for reordering. Next, the waiting number parameter t of all structure parameters in the priority queue is added by 1, and then the response level q in the structure parameter is updated. This update will not destroy the priority queue property based on the max-heap (the value of each node is greater than or equal to the value of its left and right child nodes), so the priority queue does not need to be reordered. Then, because a new message is inserted into the sending buffer, there is at least one message waiting to be sent. Pop out the structure parameters of the priority queue header, remove the corresponding message header ID, and then send the message.
[0095] The embodiment of the present invention further provides a 104 message transmission device based on a priority queue algorithm, Fig. 9 104 is a schematic diagram of the structure of a message transmission device based on a priority queue algorithm according to an embodiment of the present invention. Fig. 9 As shown, the device comprises:
[0096] The data acquisition module 100 is used to acquire the current message 104 and the type of the current message 104;
[0097] The 104 message refers to the message transmitted by the 104 protocol, which is called the Application Protocol Data Unit (APDU).
[0098] IEC 104 (IEC 60870-5-104) is mainly used for power system control and information collection. IEC 104 is based on the transport layer TCP protocol.
[0099] like Figure 2 As shown, the 104 protocol is located in the application layer of the standard network architecture, and its message content comes from power equipment that needs to use the network to transmit remote information, telemetry, remote control and other data. After the 104 protocol encapsulates the above information into a 104 protocol message, it uses the TCP / IP protocol stack in the operating system for data transmission, which uses port 2404.
[0100] According to the information content to be transmitted in the 104 protocol message, the message type can be divided into several categories. When obtaining the message, the type of the 104 message needs to be determined at the same time.
[0101] As an optional implementation, the type of each message 104 may be determined according to an identifier of a specific byte of each message 104 .
[0102] Specifically, the application protocol control information in the 104 message mainly defines various types of 104 message formats, which are used to implement the transmission control of the 104 message; the application service data unit in the 104 message defines "TI (type identification, TYPEIDENTIFICATION), COT (cause of transmission, CAUSE OF TRANSMISSION), call qualifier (QOI), information object arrangement (SQ)" and other information, which are used to implement the functions of different messages. The message priority is mainly identified by the above parameters in the 104 message. For example, the initialization end message is identified by the I format message (TI=70, COT=4), the remote control command response message is identified by the I format message (TI=45, COT=7 or 10), the event sequence record message is identified by the I format message (TI=1 or 30, COT=4, SQ=1), and the clock synchronization response message is identified by the I format message (TI=103, COT=7). The above content is an example. In fact, the systems in different places will adjust the message content according to the work needs. When actually using it, you need to refer to the standard documents of the 104 protocol in different places.
[0103] The priority determination module 200 is used to determine the priority of the current message 104 according to the type of the current message 104 and the preset type priority table;
[0104] The type of the current message 104 is compared with the preset type priority table to determine the priority of the current message 104 for transmission.
[0105] The preset type priority table provided in this embodiment is shown in Table 1, and its priority gradually decreases as the sequence number increases.
[0106] The first message transmission module 300 is used to update all structure parameters in the priority queue of the cache area when the current message 104 has not entered the cache area, pop out the structure parameter at the first position in the priority queue and send the corresponding message 104;
[0107] like Figure 3 As shown, in order to realize the priority transmission function of the 104 message, the embodiment of the present invention needs to design a sending buffer area. The sending buffer area refers to the location where the message is stored before it is pushed to the TCP / IP protocol stack after the message is encapsulated by the 104 protocol.
[0108] The buffer area stores a priority queue, which is composed of structure parameters. Each structure parameter corresponds to a 104 message. Of course, there may be a situation where no structure parameter exists in the priority queue.
[0109] As an optional implementation, the priority queue is a priority queue implemented based on a max-heap, which is a complete binary tree, and its property is that the value of each node is greater than or equal to the value of its left and right child nodes.
[0110] The process of sending a message is regarded as a round. The embodiment of the present invention is performed in rounds. In each round, at most one message is sent from the buffer area.
[0111] When the buffer determines that no new 104 message enters the buffer, all structure parameters in the priority queue of the buffer are updated. At this time, if there are structure parameters in the priority queue, the structure parameters at the head of the priority queue are directly popped out, and the 104 message corresponding to the structure parameters is sent.
[0112] The second message transmission module 400 is used to calculate the structure parameters corresponding to the current message 104 according to the priority of the current message 104 when the current message 104 enters the cache area, insert the structure parameters corresponding to the current message 104 into the priority queue, pop out the structure parameters at the first position of the priority queue and send the corresponding 104 message.
[0113] When the buffer determines that a new 104 message has entered, the structure parameters of the current 104 message are calculated first, and the structure parameters of the current 104 message are inserted into the priority queue for reordering. Then, the structure parameters of all 104 messages in the priority queue are updated. At this time, because a new message has been inserted into the buffer, there is at least one 104 message waiting to be sent. The structure parameters at the head of the priority queue are popped out, and the 104 message corresponding to the structure parameters is popped out and sent.
[0114] As an optional implementation, the structure parameters include: message ID, priority, waiting times and response level;
[0115] Fig.10 is a schematic diagram of the structure of a submodule responsible for calculating structure parameters in the second message transmission module provided in an embodiment of the present invention, such as Fig.10 As shown, the second message transmission module 400 includes:
[0116] The message ID calculation submodule 4001 is used to number the current message 104, obtain the message ID of the current message 104, and add the message ID to the first two bytes of the current message 104;
[0117] The waiting times determination submodule 4002 is used to assign the waiting times of the current message 104 to 0;
[0118] The priority adding submodule 4003 is used to add the priority into the structure parameter;
[0119] The response level calculation submodule 4004 is used to calculate the response level according to the waiting times and the priority.
[0120] The buffer area allocates structure parameters for each message that arrives 104. The structure parameters are used to identify the message in the buffer area and determine the response level of the message in the buffer area according to the priority and waiting time, as shown in Table 2.
[0121] As an optional implementation, Fig.11 is a schematic diagram of the structure of a submodule responsible for inserting structure parameters into a priority queue in the second message transmission module provided in an embodiment of the present invention, such as Fig.11 As shown, the second message transmission module 400 also includes:
[0122] The reordering submodule 4005 is used to insert the structure parameters into the priority queue for reordering according to the size of the response level in the structure parameters; wherein the structure parameters with a larger response level are positioned more forward in the priority queue;
[0123] According to the response level in the structure parameters of the current message 104, the corresponding structure parameters are inserted into the priority queue for reordering. Since the present embodiment uses a priority queue based on a max-heap implementation, based on the properties of the max-heap, when the structure parameters are inserted into the priority queue according to the response level, the structure parameters with the largest response level can be automatically recorded at the top of the priority queue. Specifically, when the cache receives the current message 104, its response level is calculated, and the structure parameters of the current message 104 are inserted into the tail of the priority queue. At this time, the order of the structure parameters in the priority queue will be automatically adjusted, and the structure parameter with the largest response level will be recorded at the top.
[0124] The structure parameter updating submodule 4006 is used to update all structure parameters in the priority queue.
[0125] After reordering, all structure parameters in the priority queue are updated according to uniform rules to execute the next round of message sending procedures.
[0126] As an optional implementation, Fig.12 is a schematic diagram of the structure parameter updating submodule provided in an embodiment of the present invention, such as Fig.12 As shown, the structure parameter updating submodule 4006 includes:
[0127] The waiting number updating unit 40061 is used to increase the waiting number in each structure parameter by 1;
[0128] The number of waiting times in each structure parameter in the priority queue is increased by 1, which means that the structure parameter has completed another round of waiting.
[0129] The response level updating unit 40062 is used to calculate the latest response level corresponding to each structure parameter according to the waiting times and the priority.
[0130] Then, the latest response level corresponding to each structure parameter is calculated based on the number of waits and the priority. This update operation will not destroy the properties of the max-heap priority queue (the value of each node is greater than or equal to the values of its left and right child nodes), so there is no need to reorder.
[0131] The response level is calculated based on the number of wait times and priority using the following formula:
[0132] q=a*p+b*t
[0133] Among them, q is the response level, p is the priority, t is the number of waiting times, and parameters a and b are the scaling factors, which can be assigned by the administrator. The default values are a=1 and b=1.
[0134] When the buffer area does not detect the entry of 104 message, the method for updating the structure parameters is the same as above.
[0135] As an optional implementation, Fig.13 FIG. 1 is a schematic diagram of the structure of a submodule responsible for message sending in the second message transmission module provided in an embodiment of the present invention. Fig.13 As shown, the second message transmission module 400 also includes:
[0136] The identification submodule 4007 is used to identify the first two bytes of the 104 message corresponding to the structure parameter at the first position of the priority queue;
[0137] Identify the message ID in the first two bytes of the 104 message corresponding to the structure parameter of the priority queue header.
[0138] The message ID deletion submodule 4008 is used to delete the first two bytes of the 104 message and send the 104 message.
[0139] The first two bytes of the message 104 are deleted, that is, the message ID is deleted, and then the message is sent.
[0140] When the buffer area does not detect the entry of the 104 message, if the buffer area has a 104 message to be sent, the sending method is the same as above.
[0141] The above technical scheme has the following beneficial effects: this embodiment will generate a message response level parameter according to parameters such as each message priority and waiting time, and according to the parameter, use a priority queue based on a max-heap to reorder the messages in the sending buffer to determine the order of the current sending messages. The characteristics of the data structure of the priority queue are that the memory space occupied is consistent with the ordinary sorting algorithm, and the comprehensive efficiency when inserting new elements and reordering is better than the traditional sorting algorithm. It is particularly suitable for scenarios where new elements need to be inserted frequently and only the maximum value is concerned. As the transmission proceeds, the response level parameter will also be dynamically adjusted, and low-priority data will not be blocked in the sending buffer all the time; when there are messages to be sent, this method will reorder the messages in the sending buffer according to parameters such as each message priority and waiting time to determine the order of the current sending messages. Based on the present invention, when network congestion occurs, it can not only ensure that high-priority data is transmitted first, but also ensure that the transmission of sub-priority messages will not be blocked all the time.
[0142] Those skilled in the art will appreciate that embodiments of the present invention may be provided as methods, systems, or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0143] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0144] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0145] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0146] The present invention uses specific embodiments to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea. At the same time, for those skilled in the art, according to the idea of the present invention, there will be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as a limitation on the present invention.
Claims
1. A 104 message transmission method based on a priority queue algorithm, characterized in that: include: Obtain the current message 104 and the type of the current message 104; Determine the priority of the current message 104 according to the type of the current message 104 and the preset type priority table; When the current message 104 does not enter the buffer area, all the structure parameters in the priority queue of the buffer area are updated, the structure parameter at the first position in the priority queue is popped out and the corresponding message 104 is sent; When the current message 104 enters the buffer area, the structure parameter corresponding to the current message 104 is calculated according to the priority of the current message 104, the structure parameter corresponding to the current message 104 is inserted into the priority queue, the structure parameter at the first position of the priority queue is popped out and the corresponding message 104 is sent; The structural parameters include: message ID, priority, number of waiting times and response level; The calculating of the corresponding structural parameters according to the priority of the current message 104 includes: Numbering the current message 104 to obtain a message ID of the current message 104, and adding the message ID to the first two bytes of the current message 104; Assign the waiting number of the current message 104 to 0; Adding the priority to the structure parameter; Calculate the response level according to the number of waiting times and the priority; The inserting the structure parameter corresponding to the current message 104 into the priority queue includes: Inserting the structure parameters into the priority queue for reordering according to the size of the response level in the structure parameters; wherein the structure parameters with a larger response level are positioned more forward in the priority queue; Update all structure parameters in the priority queue.
2. The 104 message transmission method based on the priority queue algorithm according to claim 1 is characterized in that: The updating of all structure parameters in the priority queue includes: Add 1 to the number of waiting times in each structure parameter; The latest response level corresponding to each structure parameter is calculated according to the waiting times and the priority.
3. The 104 message transmission method based on the priority queue algorithm according to claim 1 is characterized in that: The step of popping out the structure parameter at the first position of the priority queue and sending the corresponding 104 message comprises: Identify the first two bytes of the 104 message corresponding to the structure parameter at the first position of the priority queue; Delete the first two bytes of the 104 message and send the 104 message.
4. A 104 message transmission device based on a priority queue algorithm, characterized in that: include: A data acquisition module, used to acquire the current message 104 and the type of the current message 104; A priority determination module, used to determine the priority of the current message 104 according to the type of the current message 104 and a preset type priority table; The first message transmission module is used for updating all the structure parameters in the priority queue of the cache area when the current message 104 does not enter the cache area, popping out the structure parameter at the first position of the priority queue and sending the corresponding message 104; A second message transmission module is used for calculating the structure parameters corresponding to the current message 104 according to the priority of the current message 104 when the current message 104 enters the cache area, inserting the structure parameters corresponding to the current message 104 into the priority queue, popping out the structure parameters at the first position of the priority queue and sending the corresponding message 104; The structural parameters include: message ID, priority, number of waiting times and response level; The second message transmission module includes: A message ID calculation submodule, used for numbering the current message 104, obtaining the message ID of the current message 104, and adding the message ID to the first two bytes of the current message 104; A waiting times determination submodule, used for setting the waiting times of the current message 104 to 0; A priority adding submodule, used for adding the priority into the structure parameter; A response level calculation submodule, used for calculating the response level according to the waiting times and the priority; The second message transmission module also includes: A reordering submodule, used for inserting the structure parameters into the priority queue for reordering according to the size of the response level in the structure parameters; wherein the structure parameters with a larger response level are positioned more forward in the priority queue; The structure parameter updating submodule is used to update all structure parameters in the priority queue.
5. The message transmission device 104 based on the priority queue algorithm according to claim 4 is characterized in that: The structure parameter updating submodule includes: The waiting number updating unit is used to increase the waiting number in each structure parameter by 1; The response level updating unit is used to calculate the latest response level corresponding to each structure parameter according to the waiting times and the priority.
6. The message transmission device 104 based on the priority queue algorithm according to claim 4, characterized in that: The second message transmission module also includes: An identification submodule, used to identify the first two bytes of the 104 message corresponding to the structure parameter at the first position of the priority queue; The message ID deletion submodule is used to delete the first two bytes of the 104 message and send the 104 message.
