MODBUS data transmission bandwidth optimization method
By building a multi-dimensional constraint model and data item association diagram, the optimal transmission strategy is generated, and real-time monitoring and adjustment are carried out, multiple technical problems in MODBUS data transmission bandwidth optimization are solved, and efficient, reliable and real-time data transmission is achieved.
Patent Information
- Application Number
- CN202411912468.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-24
- Publication Date
- 2025-03-11
- Estimated Expiration
- 2044-12-24
AI Technical Summary
In the optimization of MODBUS data transmission bandwidth, the existing technology has problems such as incomplete data feature extraction, simple priority evaluation mechanism, inaccurate bandwidth modeling, lack of dynamic optimization mechanism and insufficient exception handling capabilities, resulting in wasted bandwidth resources or delay in key data transmission.
By obtaining the basic information of each device, building a data item feature matrix and priority vector, establishing a multi-dimensional constraint model, building a weighted undirected graph of data item association, performing sub-graph division and multi-objective optimization calculation, generating an optimal transmission strategy, and making strategy adjustments through real-time monitoring and evaluation mechanisms.
It realizes comprehensive characterization of data item characteristics, unified optimization of bandwidth, real-time and reliability, dynamic optimization of optimal packetization of data items and transmission strategies, improves the efficiency and reliability of MODBUS data transmission, and ensures the real-time requirements of important data.
Smart Images

Figure CN119603157A_ABST
Abstract
Description
Technical Field
[0001] The invention belongs to the field of data transmission, in particular to a MODBUS data transmission bandwidth optimization method. Background Art
[0002] In the field of industrial automation, the MODBUS protocol is widely used in data acquisition and control systems on industrial sites due to its simplicity, openness and reliability. With the rapid development of the Industrial Internet of Things, the number of devices and data collection points has increased dramatically, resulting in increasing bandwidth pressure on fieldbus networks. Especially in scenarios such as power systems, intelligent manufacturing and process control, the contradiction between a large number of real-time data collection needs and limited communication bandwidth has become increasingly prominent. Optimizing the bandwidth utilization efficiency of MODBUS data transmission is not only related to the real-time performance and reliability of the system, but also directly affects the operating efficiency and stability of the entire industrial control system.
[0003] At present, the research on MODBUS data transmission bandwidth optimization mainly focuses on several aspects: first, balancing the network load through simple polling cycle adjustment, setting different acquisition frequencies according to the importance of data; second, using a priority-based data grouping method to group data items of the same priority together for transmission; third, using a fixed data frame packaging strategy to combine multiple register data with consecutive addresses into one message for transmission; fourth, avoiding network congestion by setting a static bandwidth limit threshold. These methods have improved bandwidth utilization efficiency to a certain extent, but the optimization effect is relatively limited.
[0004] However, the existing technology still has the following problems: data feature extraction is not comprehensive, only considering the continuity of register addresses, ignoring the impact of multi-dimensional features such as device identification and data type, resulting in unreasonable data grouping; the priority evaluation mechanism is too simple, not considering the time-varying characteristics and stability characteristics of data access mode, and cannot accurately reflect the actual importance of data items; bandwidth modeling is not accurate enough, ignoring the message overhead of the MODBUS protocol itself and the length difference of different types of data, resulting in actual bandwidth occupancy not meeting expectations; lack of dynamic optimization mechanism, the preset grouping strategy cannot adapt to changes in network conditions and business needs, and easily causes waste of bandwidth resources or transmission delays of key data; insufficient exception handling capabilities, lack of effective retransmission strategies and bandwidth adjustment mechanisms when communication errors occur, affecting system reliability; no complete performance evaluation system has been established, and it is impossible to quantitatively evaluate and continuously improve the optimization effect. These technical problems seriously restrict the improvement of MODBUS data transmission efficiency. Summary of the invention
[0005] The purpose of the invention is to provide a method for optimizing the bandwidth of MODBUS data transmission, in order to solve at least one technical problem existing in the prior art.
[0006] Technical solution, a method for optimizing MODBUS data transmission bandwidth, comprising the following steps:
[0007] S1. Obtain basic information of each device, perform feature analysis on the basic information, and generate a data item feature matrix; based on the data item feature matrix, calculate the data item priority vector; and construct a data item association matrix according to the data item feature matrix and the data item priority vector; wherein the basic information includes device identification, register type, register address, and register length;
[0008] S2. Based on the data item feature matrix, the data item priority vector and the pre-stored historical error rate data, a multi-dimensional constraint model of bandwidth consumption constraint, real-time constraint and reliability constraint is constructed; based on the multi-dimensional constraint model, a bandwidth consumption model is calculated; based on the bandwidth consumption model and the preset real-time requirement, a real-time constraint model is calculated; based on the bandwidth consumption model and the pre-stored historical error rate data, a reliability model is constructed;
[0009] S3. Based on the bandwidth consumption model, real-time constraint model, reliability model and data item association matrix, a weighted undirected graph of data item association is constructed; based on the weighted undirected graph, subgraph division is performed to generate an optimal data item grouping set; based on the optimal data item grouping set, multi-objective optimization calculation is performed to generate an optimal transmission strategy;
[0010] S4. Based on the optimal transmission strategy and pre-stored performance indicator thresholds, the data transmission process is monitored and evaluated in real time to generate performance evaluation results; the strategy is adjusted according to the performance evaluation results to obtain an adjusted transmission strategy; based on the adjusted transmission strategy, data transmission is executed and exception handling is performed to generate execution results and performance logs.
[0011] Beneficial effects: The present invention realizes a comprehensive characterization of data item features by constructing a multidimensional feature matrix and an association matrix; realizes unified optimization of bandwidth, real-time performance and reliability by establishing a multidimensional constraint model; realizes optimal grouping of data items by a graph theory algorithm; realizes dynamic optimization of transmission strategies by a closed-loop monitoring and adjustment mechanism; and not only improves the efficiency and reliability of MODBUS data transmission, but also ensures the real-time requirements of important data. BRIEF DESCRIPTION OF THE DRAWINGS
[0012] Figure 1 It is a flow chart of the present invention.
[0013] Figure 2 This is a flow chart of step S1 of the present invention.
[0014] Figure 3 This is a flow chart of step S2 of the present invention.
[0015] Figure 4 This is a flow chart of step S3 of the present invention.
[0016] Figure 5 This is a flow chart of step S4 of the present invention. DETAILED DESCRIPTION
[0017] like Figure 1 As shown, the present application proposes a MODBUS data transmission bandwidth optimization method, comprising the following steps:
[0018] S1. Obtain basic information of each device, perform feature analysis on the basic information, and generate a data item feature matrix; based on the data item feature matrix, calculate the data item priority vector; and construct a data item association matrix according to the data item feature matrix and the data item priority vector; wherein the basic information includes device identification, register type, register address, and register length;
[0019] S2. Based on the data item feature matrix, the data item priority vector and the pre-stored historical error rate data, a multi-dimensional constraint model of bandwidth consumption constraint, real-time constraint and reliability constraint is constructed; based on the multi-dimensional constraint model, a bandwidth consumption model is calculated; based on the bandwidth consumption model and the preset real-time requirement, a real-time constraint model is calculated; based on the bandwidth consumption model and the pre-stored historical error rate data, a reliability model is constructed;
[0020] S3. Based on the bandwidth consumption model, real-time constraint model, reliability model and data item association matrix, a weighted undirected graph of data item association is constructed; based on the weighted undirected graph, subgraph division is performed to generate an optimal data item grouping set; based on the optimal data item grouping set, multi-objective optimization calculation is performed to generate an optimal transmission strategy;
[0021] S4. Based on the optimal transmission strategy and pre-stored performance indicator thresholds, the data transmission process is monitored and evaluated in real time to generate performance evaluation results; the strategy is adjusted according to the performance evaluation results to obtain an adjusted transmission strategy; based on the adjusted transmission strategy, data transmission is executed and exception handling is performed to generate execution results and performance logs.
[0022] like Figure 2 As shown, according to one aspect of the present application, step S1 is further:
[0023] S11, reading basic information of each data item from pre-stored device data item configuration information; storing the basic information of each data item by row to generate an initial data item feature matrix; normalizing the initial data item feature matrix according to a preset number of matrix rows and feature numbers to obtain a data item feature matrix;
[0024] S12, reading the access frequency value and timeliness requirement value of each data item from the pre-stored historical access frequency and real-time requirement; calculating the priority score of each data item based on the access frequency value, timeliness requirement value and data item feature matrix of each data item; merging the priority scores of all data items into a vector form to generate a data item priority vector;
[0025] S13. Read the register address difference between each pair of data items from the data item feature matrix and calculate the address difference matrix; read the priority difference between each pair of data items from the data item priority vector and calculate the priority difference matrix; perform weighted combination of the address difference matrix and the priority difference matrix to generate a data item association matrix.
[0026] This embodiment constructs a data item feature matrix and a priority vector through pre-stored device data item configuration information, and generates a data item association matrix based on these, thereby realizing multi-dimensional characterization and correlation analysis of data item features. First, starting from the basic information of the device, through the construction of the feature matrix, the discrete device data items are converted into quantifiable feature vectors, providing a mathematical basis for subsequent optimization decisions. By introducing the priority vector, the importance of different data items can be quantitatively evaluated based on historical access frequency and real-time requirements. The association matrix finally generated establishes a multi-dimensional association relationship between data items, and the establishment of this association relationship provides an important basis for the subsequent data item grouping and transmission strategy optimization. This embodiment combines the static and dynamic features of device data items to construct a complete feature characterization system that can fully reflect the physical characteristics, access characteristics and business importance of data items.
[0027] According to one aspect of the present application, step S11 is further:
[0028] S111, reading basic information of each data item from pre-stored device data item configuration information, including device identification, register type, register address, and register length; writing the basic information of each data item into a data item information table according to a preset format; extracting all device identifications from the data item information table and removing duplicates to generate a device list;
[0029] S112, reading the register type of each data item from the data item information table; calculating the MODBUS function code according to the register type, and matching the MODBUS function code with the corresponding data item one by one to generate a function code mapping table; merging the data item information table and the function code mapping table to generate an extended data item table;
[0030] S113, read the register address and register length of each data item from the extended data item table, calculate the end address of each data item, and generate an address range table; sort the address range table according to the device identifier and the register address to generate an ordered address table; wherein the end address is e=a+l-1, a is the register address, and l is the register length;
[0031] S114, extracting data from the ordered address table and the extended data item table to construct an initial feature matrix; calculating the number of rows and the number of features of the initial feature matrix; based on the number of rows and the number of features of the initial feature matrix, using the min-max normalization method to normalize the register address and the end address to generate a normalized feature value; combining the normalized feature values to generate a data item feature matrix. Each row of the initial feature matrix contains a device identifier d, a register type r, a MODBUS function code f, a register address a, a register length l, and an end address e.
[0032] The data structure of the device data item configuration information is {device identifier d, register type r, register address a, register length l, data type t, scan cycle s}; device identifier d: 16-bit unsigned integer, uniquely identifying each device; register type r: 8-bit integer (1=coil, 2=discrete input, 3=holding register, 4=input register); register address a: 16-bit unsigned integer, indicating the starting address of the register; register length l: 16-bit unsigned integer, indicating the number of consecutive registers; data type t: 8-bit integer (1=bit, 2=word, 3=dword, 4=float); scan cycle s: 32-bit integer, unit: milliseconds.
[0033] This embodiment establishes a complete data item feature extraction and standardization system through systematic processing of device data item configuration information. First, a data item information table is constructed to realize the structured storage of basic information such as device identification, register type, address and length; then, through the establishment of a function code mapping table, a corresponding relationship is established between the register type and the MODBUS function code, providing a basis for subsequent communication protocol encapsulation; through the construction and sorting of the address range table, the orderly management of the data item address space is realized; finally, through min-max normalization processing, features of different dimensions are converted to a unified metric space. This embodiment not only provides a reliable data foundation for subsequent data item grouping and transmission optimization, but also eliminates the dimensional differences between different features through normalization processing, making each feature comparable in the subsequent optimization process; it improves the standardization of data processing and the accuracy of feature expression, and lays a solid data foundation for the entire optimization system.
[0034] According to one aspect of the present application, step S12 is further:
[0035] S121, reading the number of accesses of each data item in different time windows from the pre-stored historical access frequencies, and calculating the access frequencies of at least three different time scales; performing weighted calculation on the access frequencies of different time scales using an exponential smoothing method, and generating a comprehensive access frequency value;
[0036] S122, calculating the coefficient of variation of the comprehensive access frequency value; based on the coefficient of variation, determining the stability of the access pattern and generating an access stability index; combining the access stability index with the comprehensive access frequency value to generate an access pattern table;
[0037] S123, reading the response time limit of each data item from the pre-stored real-time requirements; grading the data items in the data item feature matrix according to the response time limit to generate a real-time grade; combining the real-time grade and the data in the access pattern table to calculate a preliminary priority score to generate an initial priority table;
[0038] S124. Read a preliminary priority score from the initial priority table; read an access stability index from the access pattern table; combine the preliminary priority score and the access stability index using a weighted combination method to obtain a final priority score; sort the final priority scores according to the scores to generate a data item priority vector.
[0039] The data structure of the historical access frequency is {device identifier d, data item identifier i, number of accesses n, time window w}; device identifier d: the identifier in the corresponding device configuration information; data item identifier i: a 32-bit integer that uniquely identifies the data item; number of accesses n: a 32-bit integer that records the total number of accesses within the time window; time window w: a 64-bit timestamp that records the start time of the statistics.
[0040] The data structure of the real-time requirement T is {data item identifier i, response time limit t, priority p}; data item identifier i: the identifier corresponding to the historical access frequency; response time limit t: a 32-bit integer in milliseconds, indicating the maximum allowed response time; priority p: an 8-bit integer (1-255), the smaller the value, the higher the priority.
[0041] In one embodiment of the present application, the process of generating the comprehensive access frequency value is specifically as follows: comprehensive access frequency F(i, t) = α·f_h(i, t) + β·f_d(i, t) + γ·f_w(i, t); wherein f_h(i, t) = λ_h·n_h(i, t)+ (1-λ_h)·f_h(i, t-1) is the hourly smoothing frequency; f_d(i, t) = λ_d·n_d(i, t) + (1-λ_d)·f_d(i, t-1) is the daily smoothing frequency; f_w(i, t) = λ_w·n_w(i, t) + (1-λ_w)·f_w(i, t-1) is the weekly smoothing frequency; n_h(i, t), n_d(i, t), n_w(i, t) are the number of visits in the current hour, day, and week respectively; λ_h, λ_d, λ_w are the smoothing coefficients of each time scale, and the value range is [0, 1]; α, β, γ are the time scale weights, and α+β+γ=1; i is the data item number; t is the current timestamp.
[0042] This embodiment realizes dynamic evaluation and quantitative expression of data item priority through comprehensive analysis of historical access frequency and real-time requirements. The access frequency of different time windows is weighted by exponential smoothing method, which effectively captures the time characteristics of data access pattern; through the introduction of coefficient of variation, quantitative evaluation of access pattern stability is realized; combining real-time level and access pattern characteristics, a comprehensive priority evaluation system is constructed. This embodiment not only takes into account the historical rules of data access, but also takes into account real-time requirements, making priority allocation more reasonable and dynamic. In particular, through the introduction of access stability index, the system can distinguish between stable periodic access and sudden access, thereby providing differentiated service strategies for different types of data access, improving the accuracy and adaptability of priority evaluation.
[0043] According to one aspect of the present application, step S13 is further:
[0044] S131. Extract the device identification data set {d1, d2...dn} from the data item feature matrix; calculate the device identification difference coefficient sij between any two data items i and j: if the device identification is the same, sij=0, otherwise sij=1; form all device identification difference coefficients into an n×n matrix to generate a device difference matrix S; where n is the total number of data items; i, j are data item serial numbers, ranging from [1, n];
[0045] S132, read the register address a and register length l of each data item from the data item feature matrix; calculate the address overlap between data items i and j, oij=(min(ei, ej)-max(ai, aj)+1) / (max(ei, ej)-min(ai, aj)+1), ei and ej are the end addresses, ai, aj are the start addresses of data items i and j; calculate the address difference dij=1-oij based on the address overlap; group all address differences into an n×n matrix to generate an address difference matrix A;
[0046] S133, read the priority score p of each data item from the data item priority vector; calculate the priority difference value vij=|pi-pj| between data items i and j; convert the difference value using the Gaussian normalization function: pij=exp(-vij 2 / (2σ 2 )), where σ is the priority standard deviation; all normalized priority differences are combined into an n×n matrix to generate a priority difference matrix B; where pi, pj are the priority scores of data items i and j; pij is the normalized priority difference;
[0047] S134, read the device identification weight Δ, address weight α and priority weight β from the pre-stored system weight parameters; perform weighted combination on the device difference matrix S, address difference matrix A and priority difference matrix B: rij = Δ×sij +α×dij + β×pij; form an n×n matrix with the weighted combined association values to generate a data item association matrix R. Where rij is the final association between data items i and j.
[0048] In one embodiment of the present application, the final relevance R(i, j) = α·(1-|A(i)-A(j)| / max_A) + β·exp(-(P(i)-P(j)) 2 / 2σ 2 ) + γ·(1-Δ(D(i), D(j))); where A(i) and A(j) are the normalized address values of data items i and j; max_A is the maximum address difference; P(i) and P(j) are the priority values of data items i and j; σ is the priority standard deviation; D(i) and D(j) are the device identifications of data items i and j; Δ(x, y) is the Kronecker function, which takes the value of 1 when x=y and 0 otherwise; α is the address weight coefficient, ranging from [0, 1]; β is the priority weight coefficient, ranging from [0, 1]; γ is the device identification weight coefficient, ranging from [0, 1]; and α+β+γ=1; i, j are the data item numbers, ranging from [1, n], and n is the total number of data items.
[0049] This embodiment establishes a complete data item association evaluation system through multi-dimensional association analysis. First, by constructing a device difference matrix, the data item association characteristics between different devices are quantified; by calculating the address overlap, the aggregation characteristics of data items in the address space are accurately described; by converting the priority differences through the Gaussian normalization function, a smooth measure of the similarity of data item priorities is established; finally, through the weighted combination method, the association characteristics of multiple dimensions are integrated into a unified association index. This embodiment not only considers the physical properties of the data items (device identification, address space), but also the business attributes (priority), making the association evaluation more comprehensive and accurate. In particular, by introducing the Gaussian normalization function, a nonlinear mapping of priority differences to association is achieved, avoiding the distortion that may be caused by simple linear mapping, and improving the accuracy and rationality of the data item association relationship evaluation.
[0050] like Figure 3 As shown, according to one aspect of the present application, step S2 is further:
[0051] S21, extracting the starting address, number of data items and current address of each data group from the data item feature matrix; calculating the initial bandwidth consumption value based on the starting address, number of data items and current address of each data group; reading the bandwidth constraint function parameters from the pre-stored system configuration parameters; constructing a bandwidth constraint equation group based on the initial bandwidth consumption value and the bandwidth constraint function parameters, and generating a bandwidth constraint component in the multidimensional constraint model; normalizing the initial bandwidth consumption value based on the bandwidth constraint component, and generating a standardized bandwidth consumption model;
[0052] S22, reading the priority value of each data item from the data item priority vector; reading the maximum allowable delay threshold from the pre-stored system configuration parameters; constructing a delay constraint function according to the priority value and the maximum allowable delay threshold, generating a real-time constraint component in the multidimensional constraint model; constructing a real-time constraint model based on the real-time constraint component and the priority value;
[0053] S23. Read the communication error rate of each device from the pre-stored historical error rate data; extract the bandwidth consumption benchmark value from the bandwidth consumption model; calculate the retransmission cost based on the communication error rate and the bandwidth consumption benchmark value; construct the reliability constraint component in the multidimensional constraint model based on the communication error rate, the bandwidth consumption benchmark value and the retransmission cost; construct a reliability evaluation function based on the reliability constraint component to generate a reliability model.
[0054] The data structure of the historical error rate data is {device identifier d, time period s, communication error count e, total communication count n}. Device identifier d: the identifier in the corresponding device configuration information; time period s: 64-bit timestamp range; communication error count e: 32-bit integer; total communication count n: 32-bit integer.
[0055] This embodiment is based on the feature matrix and priority vector, combined with historical error rate data, to construct a constraint model including three dimensions of bandwidth consumption, real-time and reliability. A complete multi-dimensional constraint system is established, which accurately quantifies the resource occupancy of data transmission through the bandwidth consumption model, ensures the timely transmission of high-priority data through the real-time constraint model, and considers the impact of communication quality on transmission efficiency through the reliability model. The establishment of this multi-dimensional constraint model realizes the comprehensive consideration and quantitative description of various key factors in the MODBUS data transmission process. In particular, a nonlinear constraint function is introduced in the bandwidth consumption model. This nonlinear mapping not only ensures the smooth change of bandwidth utilization, but also effectively prevents the sudden increase of bandwidth occupancy. At the same time, the priority is associated with the delay requirement through the real-time constraint model, and a differentiated service mechanism for data transmission is established.
[0056] According to one aspect of the present application, step S21 is further:
[0057] S211, extracting the starting address, number of data items and current address of each data group from the data item feature matrix; reading the MODBUS message header length and CRC check length from the pre-stored system configuration parameters; combining the starting address, number of data items, current address, MODBUS message header length and CRC check length of each data group according to a preset format to generate a data group basic table; calculating the continuous address range that can be merged for each data group to generate an address range table A;
[0058] S212. Based on the data group basic table, calculate the basic message overhead and data area length of each data group according to the MODBUS protocol specification; add the basic message overhead and the data area length to obtain the initial bandwidth consumption value; wherein the basic message overhead is equal to the sum of the MODBUS message header length and the CRC check length; the data area length is equal to the number of data items multiplied by the number of bytes of each data item;
[0059] S213, reading bandwidth constraint function parameters from pre-stored system configuration parameters; generating a bandwidth constraint table based on the initial bandwidth consumption value and the bandwidth constraint function parameters; calculating the actual bandwidth occupancy rate of each data group based on the bandwidth constraint table; the bandwidth constraint function is f(b)=k×b / (1+k×b), where k is the bandwidth constraint function parameter and b is the initial bandwidth consumption value;
[0060] S214, normalizing the initial bandwidth consumption value to generate a normalized bandwidth value; combining the normalized bandwidth value with the actual bandwidth occupancy rate to construct a bandwidth constraint equation group; and generating a standardized bandwidth consumption model based on the bandwidth constraint equation group and the initial bandwidth consumption value.
[0061] The data structure of the system configuration parameters is {bandwidth upper limit bMax, message size limit sMax, MODBUS message header length h, CRC check length c}. Bandwidth upper limit bMax: 32-bit floating point number, unit byte / s; message size limit sMax: 16-bit integer, unit byte; MODBUS message header length h: 8-bit integer, unit byte; CRC check length c: 8-bit integer, unit byte.
[0062] In one embodiment of the present application, the address range merging algorithm: address continuity determination function C(i, j) = min(1, max(0, (θ-ΔA(i, j)) / θ))·min(1, max(0, (η-ΔD(i, j)) / η)); wherein ΔA(i, j) is the address interval = |A_end(i)-A_start(j)|, A_end(i) is the end address of the i-th data item, A_start(j) is the starting address of the j-th data item; ΔD(i, j) is the data type difference; θ is the address interval threshold; η is the type difference threshold; when C(i, j)>0.5, it is determined to be mergeable.
[0063] The actual bandwidth usage B(x) = B_max (k x) / (1+k x) + B_base, where x is the original bandwidth demand; B_max is the maximum bandwidth capacity of the system; k is the bandwidth adjustment coefficient, which is used to control the slope of the curve; B_base is the basic bandwidth usage; when x approaches infinity, B(x) approaches B_max + B_base, ensuring that the bandwidth usage does not exceed the system upper limit.
[0064] The total message overhead B(G) = H_base + N_reg·L_type + F_code·K_f + CRC_len + Σ(O_i·Δ_i); where H_base is the basic frame header length; N_reg is the number of registers; L_type is the register type length; F_code is the function code; K_f is the function code overhead coefficient; CRC_len is the check code length; O_i is the additional option overhead; Δ_i is the option enable flag.
[0065] In another embodiment of the present application, the actual bandwidth occupancy rate R(t) = α·(B_cur(t) / B_max)·(1+ β·V_b(t))·(1 + γ·C_r(t)); wherein B_cur(t) is the current bandwidth usage at time t; B_max is the maximum bandwidth of the system; V_b(t) is the bandwidth change rate, V_b(t) = |B_cur(t)-B_cur(t-1)| / B_cur(t-1); C_r(t) is the communication conflict rate; α is the basic coefficient; β is the change rate influencing factor; γ is the conflict influencing factor; t is the timestamp.
[0066] Bandwidth constraint equation group: The bandwidth constraint model M(G) = Σ(w_i·F_i(x)), satisfies: F_1(x): Σ(B_k(t))≤B_max; F_2(x): max(D_k(t))≤D_max; F_3(x): min(R_k(t))≥R_min; where B_k(t) is the bandwidth occupancy of data group k at time t; D_k(t) is the transmission delay of data group k; R_k(t) is the reliability index of data group k; w_i is the constraint weight; B_max is the bandwidth upper limit; D_max is the delay upper limit; R_min is the reliability lower limit.
[0067] This embodiment realizes the accurate quantification and constraint of bandwidth resource usage in the MODBUS communication process through fine-grained bandwidth consumption analysis and modeling. First, through the construction of the data group basic table, the accurate characterization of each component of the MODBUS message structure is realized; through the establishment of the bandwidth basic table, the actual bandwidth occupation of the message overhead and data load is accurately quantified; through the introduction of the bandwidth constraint function, a nonlinear mapping relationship between bandwidth consumption and actual resource occupation is established; finally, through normalization processing and the construction of a group of constraint equations, a complete bandwidth consumption constraint system is formed. This embodiment not only takes into account the overhead characteristics of the MODBUS protocol itself, but also reflects the saturation characteristics of bandwidth resource usage through nonlinear constraint functions, making the allocation of bandwidth resources more reasonable and efficient, and improving the accuracy and rationality of bandwidth resource usage.
[0068] According to one aspect of the present application, step S22 is further:
[0069] S221, read the priority value p of each data item from the data item priority vector; read the maximum allowable delay threshold t from the pre-stored system configuration parameters; calculate the maximum allowable response time mt based on the priority value p: the maximum response time mt is equal to the basic response time t0 multiplied by the priority adjustment coefficient kp, and generate a delay constraint table T;
[0070] S222, extract the maximum response time mt of each data item from the delay constraint table T; consider the network transmission delay nt, the device processing delay dt and the system processing delay st; perform weighted superposition on these three types of delays to generate a comprehensive delay constraint value ct; construct the real-time constraint component in the multidimensional constraint model C according to the comprehensive delay constraint value ct, and generate a constraint component table D;
[0071] S223. Read the real-time constraint component from the constraint component table D; combine the real-time constraint component with the priority value p in the data item priority vector P; construct a delay constraint function f(t) that takes priority into consideration; set different constraint parameters according to different priority intervals to generate a real-time constraint model L.
[0072] In one embodiment of the present application, the priority delay adjustment coefficient K_p(i) = K_base·(1 + α·ln(P_max / P(i)))·(1 - β·V_f(i)); wherein K_base is the basic adjustment coefficient; P_max is the highest priority value; P(i) is the priority value of data item i; V_f(i) is the access frequency variation coefficient of data item i; α is the priority influencing factor, and its value range is [0, 1]; β is the stability influencing factor, and its value range is [0, 1]; V_f(i) = σ_f(i) / μ_f(i), σ_f(i) is the access frequency standard deviation, and μ_f(i) is the access frequency mean.
[0073] The comprehensive delay value D(i) = w_n·(L_n + T_n·H(i)) + w_d·(L_d + T_d·S(i)) + w_s·(L_s + T_s·Q(i)); where L_n, L_d, L_s are the basic delays of the network, device and system respectively; T_n, T_d, T_s are the unit data processing delays of each part respectively; H(i) is the number of network hops; S(i) is the device processing complexity; Q(i) is the system queue length; w_n, w_d, w_s are weight coefficients and w_n+w_d+w_s=1.
[0074] The delay constraint function f(t, i) = t_base·(1 + α·(1-P(i) / P_max))·(1 + β·ln(1+Q(t) / Q_max))·(1 + γ·U(t) / U_max); where t_base is the basic response time; P(i) is the priority of data item i; P_max is the highest priority value; Q(t) is the system queue length at time t; Q_max is the maximum queue length; U(t) is the system load rate at time t; U_max is the maximum load rate; α, β, and γ are adjustment coefficients.
[0075] This embodiment realizes a differentiated delay control mechanism based on priority by establishing a multi-level real-time constraint model. First, by establishing a delay constraint table, a dynamic correspondence is established between the priority and the maximum response time, and the priority adjustment coefficient is introduced to make the delay constraint adaptive; then, by considering the delay characteristics of three dimensions, namely, network transmission delay, device processing delay and system processing delay, a complete delay analysis framework is constructed; finally, by combining the real-time constraint component with the priority value, a delay constraint function considering the priority is established, and differentiated delay control of data of different priorities is realized. This embodiment can not only accurately reflect the impact of different types of delays on the real-time performance of the system, but also, through the priority adjustment mechanism, realize the tilted allocation of system resources to high-priority data, thereby ensuring the real-time requirements of key data. Through dynamic adjustment of delay constraint parameters, the system can maintain good real-time performance when the network load changes.
[0076] According to one aspect of the present application, step S23 is further:
[0077] S231, reading the communication error rate e of each device from the pre-stored historical error rate data; classifying and counting the error types (timeout, CRC error, data error, etc.); calculating the occurrence frequency and time distribution characteristics of each type of error, and generating an error characteristic table F;
[0078] S232, read error feature data from the error feature table F; extract the bandwidth consumption reference value b from the bandwidth consumption model; calculate the retransmission cost c of each error type based on the error occurrence probability p and the number of retransmissions n: the retransmission cost c is equal to the single transmission cost ct multiplied by the average number of retransmissions n; construct the reliability constraint component in the multidimensional constraint model C according to the retransmission cost c, and generate the retransmission constraint table R;
[0079] S233, read the reliability constraint component from the retransmission constraint table R; establish a reliability evaluation model based on the Markov chain; calculate the steady-state probability distribution of the system under different states; construct a reliability evaluation function based on the reliability constraint component and the state probability, and generate a reliability model R.
[0080] In one embodiment of the present application, the error feature vector E(i) = [λ_t·e_t(i), λ_c·e_c(i), λ_d·e_d(i)]·exp(-μ·Δt); wherein e_t(i) is the timeout error count; e_c(i) is the CRC error count; e_d(i) is the data error count; λ_t, λ_c, λ_d are the weight coefficients of each type of error; μ is the time attenuation coefficient; Δt is the time interval.
[0081] Retransmission cost C(i) = B_base·(1 + α·N_r(i))·(1 + β·P_f(i))·(1 + γ·T_d(i)); where B_base is the basic transmission cost; N_r(i) is the average number of retransmissions; P_f(i) is the failure probability; T_d(i) is the average retransmission delay; α is the retransmission impact factor; β is the failure impact factor; γ is the delay impact factor.
[0082] Markov chain reliability evaluation method: state transition probability P(t+1) = P(t)·T(λ, μ); reliability index R(t) = P_s(t) / (P_s(t)+P_f(t)); where T(λ, μ) is the state transition matrix [[1-λ, λ], [μ, 1-μ]]; λ is the failure rate; μ is the recovery rate; P_s(t) is the probability of normal state at time t; P_f(t) is the probability of failure state at time t; P(t) is the state probability vector at time t [P_s(t), P_f(t)].
[0083] This embodiment realizes accurate modeling and prediction of communication reliability by constructing a reliability assessment model based on Markov chain. First, through the establishment of an error feature table, the refined classification and statistics of different types of communication errors are realized; then, through the quantitative calculation of the retransmission cost, the impact of different types of errors on system performance is accurately evaluated; finally, through the Markov chain model, a dynamic description of the system reliability state transition is realized. This embodiment not only takes into account the current error rate, but also reflects the dynamic characteristics of system reliability through the state transition probability, making the reliability assessment more accurate and predictive. In particular, by combining the retransmission cost with the bandwidth consumption model, the system can optimize the use of bandwidth resources while ensuring communication reliability.
[0084] like Figure 4 As shown, according to one aspect of the present application, step S3 is further:
[0085] S31, reading the association value between each data item from the data item association matrix; taking each data item as a vertex of the graph and the association value between the data items as the weight of the edge, constructing a weighted undirected graph; generating a data item association graph based on the edge weight relationship between the vertices in the weighted undirected graph;
[0086] S32, reading an adjacency matrix from a data item association graph; reading a bandwidth constraint threshold from a bandwidth consumption model; iteratively calculating the adjacency matrix using an improved Kernighan-Lin algorithm to obtain a subgraph partitioning result that satisfies the bandwidth constraint threshold; sorting the subgraph partitioning results according to the magnitude of the association value to generate an optimal data item grouping set;
[0087] S33. Read the data item set information of each group from the optimal data item grouping set; read the bandwidth weight, real-time weight and reliability weight from the pre-stored system weight parameters; based on the bandwidth weight, real-time weight and reliability weight, substitute the data item set information of each group into the bandwidth consumption model, the real-time constraint model and the reliability model, perform weighted calculation, and obtain the weighted score of each group; based on the weighted score of each group, construct a weighted objective function; through iterative optimization calculation, obtain the packet transmission order that minimizes the weighted objective function, and generate the optimal transmission strategy.
[0088] In one embodiment of the present application, the improved Kernighan-Lin algorithm is specifically: group gain value G(A, B) = E_cut(A, B) - (α·W_in(A) + β·W_in(B)) / (W_max·|V|); wherein E_cut(A, B) is the sum of edge weights between groups; W_in(A) and W_in(B) are the sum of edge weights within a group; W_max is the maximum edge weight; |V| is the number of vertices; α and β are balance coefficients; intra-group bandwidth constraint C(X) = Σb(i, j)≤B_max, i, j∈X; b(i, j) is the bandwidth requirement between nodes i and j; B_max is the bandwidth constraint threshold; X is group A or B.
[0089] This embodiment constructs a weighted undirected graph of data item associations based on the previously generated model and matrix, and realizes the generation of optimal data item grouping and transmission strategy through graph theory algorithm. The data transmission optimization problem is converted into a graph theory problem, and the optimal subgraph partitioning under the condition of satisfying bandwidth constraints is realized through the improved Kernighan-Lin algorithm. By constructing a weighted undirected graph, the system can intuitively represent the association relationship between data items, and the rationality of the grouping results is guaranteed by determining the optimal number of subgraphs through the spectral clustering method. This embodiment not only takes into account the association strength between data items, but also ensures the feasibility of the grouping results through the bandwidth constraint threshold. The optimal transmission strategy finally generated achieves the overall optimization of bandwidth utilization, real-time performance and reliability through multi-objective optimization calculation.
[0090] According to one aspect of the present application, step S31 is further:
[0091] S311, reading the association value between each pair of data items from the data item association matrix; based on the association value, mapping each data item to a vertex, constructing a vertex set; based on the vertex set, calculating the initial connection relationship between the vertices, and generating a vertex mapping table;
[0092] S312, reading the vertex connection relationship from the vertex mapping table; obtaining the edge weight based on the vertex connection relationship and the association value; generating the influencing factor of the edge weight based on the device identification; combining the edge weight with the influencing factor, calculating the actual edge weight, and generating an edge weight table;
[0093] S313, reading data from the vertex mapping table and the edge weight table to construct an adjacency matrix; based on the adjacency matrix, calculating the degree and connectivity of each vertex; combining the degree and connectivity of the vertices to generate a graph structure feature table;
[0094] S314. Extract data from the graph structure feature table and the adjacency matrix to construct a complete weighted undirected graph structure; verify the connectivity and weight distribution of the weighted undirected graph structure, and output a data item association graph that represents the association relationship between data items.
[0095] This embodiment realizes the graph-theoretic expression and analysis of the association relationship between data items by constructing a weighted undirected graph structure. First, by establishing a vertex mapping table, accurate mapping of data items to graph structure vertices is realized; then, by considering the influencing factors of device identification on edge weights, a more accurate edge weight evaluation system is constructed; finally, by establishing a graph structure feature table, a comprehensive analysis of the connectivity and weight distribution of the graph is realized. This embodiment not only intuitively displays the association structure between data items, but also more accurately reflects the association characteristics at the device level through the introduction of influencing factors. Through the analysis of graph structure features, the system can better understand the topological relationship between data items, providing an important basis for subsequent grouping optimization.
[0096] According to one aspect of the present application, step S32 is further:
[0097] S321, read the adjacency matrix and the weight matrix from the data item association graph; multiply each element in the adjacency matrix by the corresponding element of the weight matrix to generate a weighted adjacency matrix; based on the weighted adjacency matrix, calculate the degree matrix of the graph to generate a graph feature matrix;
[0098] S322, extracting the connection relationship between nodes from the graph feature matrix, and calculating the Laplace matrix using the spectral clustering method; performing eigenvalue decomposition on the Laplace matrix to obtain eigenvalues and eigenvectors; determining the optimal number of subgraphs according to the eigenvalues, and generating a clustering parameter table;
[0099] S323, based on the parameters and feature vectors in the clustering parameter table, clustering is performed using the k-means algorithm to obtain an initial grouping; based on the initial grouping, the internal connectivity and external connectivity of each node are calculated to generate a gain value after the node is moved; the bandwidth constraint threshold is read from the bandwidth consumption model; if the gain value is positive and satisfies the bandwidth constraint threshold, node exchange is performed, and the process is repeated until a positive gain value cannot be obtained, and the optimized grouping is output; otherwise, the initial grouping is directly used as the optimized grouping; based on the optimized grouping, a subgraph partitioning table is generated;
[0100] S324, extracting the internal association value of each subgraph from the subgraph partition table and the data item association graph; calculating the association score of the subgraph based on the internal association value; and sorting the subgraphs in descending order according to the association score to generate an optimal data item grouping set, wherein the association score is equal to the weighted sum of the internal association value and the subgraph size.
[0101] In one embodiment of the present application, the normalized Laplacian matrix L = I - D -1 / 2 ·W·D -1 / 2 ; Eigenvalue decomposition L = U·Λ·U T ; The optimal number of subgraphs k = argmax(|λ_i - λ_(i+1)|); where I is the identity matrix; D is the degree matrix, D_ii = Σ_j W_ij; W is the weight matrix; λ_i is the i-th eigenvalue; U is the eigenvector matrix; the value range of i is [1, n-1], n is the number of nodes, and Λ is the eigenvalue matrix.
[0102] The correlation score S(G) = (α·I_d(G) + β·E_d(G))·(1 - γ·V_d(G)); where I_d(G) is the average correlation within the group; E_d(G) is the average correlation between groups; V_d(G) is the variance of the correlation within the group; α and β are weight coefficients and α+β=1; γ is the variance penalty coefficient; G is the grouping of data items to be evaluated.
[0103] This embodiment achieves the optimal grouping of data items through the improved Kernighan-Lin algorithm and spectral clustering method. First, the association strength information is introduced into the expression of the graph by constructing a weighted adjacency matrix; then the optimal number of subgraphs is determined by the spectral clustering method, avoiding the subjectivity of artificially determining the number of groups; finally, the improved Kernighan-Lin algorithm is used to achieve the optimal division under the condition of satisfying the bandwidth constraint. This embodiment not only takes into account the association strength between data items, but also ensures the feasibility of the grouping results through bandwidth constraints. In particular, by introducing the concept of gain value, the system can avoid local optimality in the iterative optimization process and obtain better grouping effect.
[0104] According to one aspect of the present application, step S33 is further:
[0105] S331, read the data item set information si of each group from the optimal data item grouping set; read the bandwidth weight α, real-time weight β and reliability weight γ from the pre-stored system weight parameters; calculate the initial weighted score is of each group: the initial weighted score is equal to the bandwidth weight α multiplied by the bandwidth score bs plus the real-time weight β multiplied by the real-time score ts plus the reliability weight γ multiplied by the reliability score rs, and generate a group score table P;
[0106] S332, read the initial score is of each group from the group score table P; substitute the bandwidth consumption model B to calculate the bandwidth evaluation value bv; substitute the real-time constraint model L to calculate the delay evaluation value tv; substitute the reliability model R to calculate the reliability evaluation value rv; combine the three evaluation values to generate a comprehensive evaluation table E;
[0107] S333, read the evaluation data from the comprehensive evaluation table E; construct a multi-objective optimization function f(x); use an improved genetic algorithm to iteratively optimize the objective function; update the population and verify the constraints in each iteration; obtain the packet transmission order that minimizes the weighted objective function, and generate the optimal transmission strategy T.
[0108] The data structure of the system weight parameter is {bandwidth weight α, real-time weight β, reliability weight γ, device identification weight Δ}. All weights are 32-bit floating point numbers with a value range of [0, 1], and the total weight = 1.0.
[0109] In one embodiment of the present application, the improved genetic algorithm is specifically as follows: fitness function F(x) = w1·(B_max-B(x)) / B_max + w2·(1-D(x) / D_max) + w3·R(x); wherein B(x) is the bandwidth occupancy of scheme x; D(x) is the maximum delay of scheme x; R(x) is the reliability index of scheme x; B_max is the bandwidth upper limit; D_max is the maximum allowed delay; w1, w2, w3 are weight coefficients and w1+w2+w3=1; the crossover operator adopts local sequential crossover based on priority protection; the mutation operator adopts adaptive probability p_m = p_base / (1+exp(ΔF / F_avg)), wherein p_base is the basic mutation probability, ΔF is the change in individual fitness, and F_avg is the average fitness of the population.
[0110] This embodiment achieves global optimization of the packet transmission order through a multi-objective optimization algorithm. First, by establishing a group score table, a comprehensive evaluation of each group in terms of bandwidth, real-time performance, and reliability is achieved; then, by constructing a multi-objective optimization function, the evaluation values of these three dimensions are unified into an optimization framework; finally, through an improved genetic algorithm, the transmission order optimization under multiple constraints is achieved. This embodiment not only considers the trade-offs between multiple performance indicators, but also, through the evolutionary characteristics of the genetic algorithm, is able to find better solutions under complex constraints. In particular, by verifying the constraints in each iteration, the feasibility of the optimization results is ensured. By converting the discrete group decision problem into a continuous optimization problem, the solution efficiency is improved, and at the same time, through the population evolution mechanism, the risk of falling into local optimality is avoided.
[0111] like Figure 5 As shown, according to one aspect of the present application, step S4 is further:
[0112] S41, reading a bandwidth utilization threshold, a response time threshold, and a reliability threshold from pre-stored performance indicator thresholds; based on the optimal transmission strategy, collecting bandwidth occupancy, response delay, and transmission success rate in real time during data transmission; comparing and calculating the bandwidth occupancy, response delay, and transmission success rate with the bandwidth utilization threshold, response time threshold, and reliability threshold, respectively, to generate a performance evaluation result;
[0113] S42, reading a performance deviation value from the performance evaluation result; reading an adjustment step size parameter from a pre-stored adjustment rule library; calculating an optimization parameter adjustment amount based on the performance deviation value and the adjustment step size parameter; applying the optimization parameter adjustment amount to the optimal transmission strategy to generate an adjusted transmission strategy;
[0114] S43. Read the data transmission order and grouping information from the adjusted transmission strategy; perform data transmission according to the data transmission order and grouping information, record the data during the transmission process, including bandwidth occupancy, response delay and transmission success rate, and obtain recorded data; write the recorded data into the performance log and generate the execution result of the data transmission.
[0115] This embodiment realizes dynamic adjustment and exception handling of transmission strategies through real-time monitoring and evaluation mechanisms. A closed-loop performance monitoring and optimization system is established. By collecting indicators such as bandwidth occupancy, response delay, and transmission success rate in real time, and comparing them with preset performance thresholds, performance anomalies can be discovered in a timely manner. Based on the performance evaluation results, the system can dynamically calculate the adjustment amount of the optimization parameters to achieve adaptive optimization of the transmission strategy. In particular, in the exception handling mechanism, the fault tolerance and reliability of the system are improved by establishing error type classification and corresponding recovery processes. At the same time, through the recording and analysis of performance logs, data support is provided for subsequent optimization.
[0116] According to one aspect of the present application, step S41 is further:
[0117] S411, read the bandwidth utilization threshold hb, response time threshold ht and reliability threshold hr from the pre-stored performance indicator threshold H; establish a performance indicator collection point list cp; set the sampling time interval ti; initialize the performance data cache pool dp, and generate a monitoring configuration table C;
[0118] S412, read the acquisition configuration from the monitoring configuration table C; collect the bandwidth occupancy rate rb in the data transmission process in real time; record the sending time st and receiving time rt of the data packet, and calculate the response delay td; count the number of transmission successes and failures, and calculate the transmission success rate sr; write the collected performance indicators into the real-time performance table R;
[0119] S413, read performance data from the real-time performance table R; calculate the deviation db between the bandwidth utilization and the threshold hb, the deviation dt between the response delay and the threshold ht, and the deviation dr between the transmission success rate and the threshold hr; normalize the deviation values; and combine to generate a performance evaluation result E.
[0120] This embodiment realizes real-time evaluation of the data transmission process by establishing a complete performance monitoring system. First, by establishing a monitoring configuration table, the systematic arrangement of performance indicator collection points is realized; then, by maintaining the real-time performance table, the dynamic tracking of key indicators such as bandwidth occupancy, response delay and transmission success rate is realized; finally, by generating performance evaluation results, the quantitative evaluation of the system operation status is realized. This embodiment can not only detect performance anomalies in a timely manner, but also make the performance indicators of different dimensions comparable by normalizing the deviation values. In particular, by setting a reasonable sampling time interval, it not only ensures the real-time nature of monitoring, but also avoids the system overhead caused by too frequent sampling.
[0121] According to one aspect of the present application, step S42 is further:
[0122] S421, read the bandwidth occupancy rate rb, response delay rt and transmission success rate rr from the performance evaluation result E; read the bandwidth utilization rate threshold hb, response time threshold ht and reliability threshold hr from the pre-stored performance indicator threshold H; calculate the deviation value of each performance indicator: the bandwidth deviation db is equal to the difference between the bandwidth occupancy rate rb and the bandwidth utilization threshold hb, the delay deviation dt is equal to the difference between the response delay rt and the response time threshold ht, and the reliability deviation dr is equal to the difference between the transmission success rate rr and the reliability threshold hr; combine the deviation values to generate a performance deviation table D;
[0123] S422, read the bandwidth weight α, real-time weight β and reliability weight γ from the pre-stored system weight parameter W; read each deviation value from the performance deviation table D; calculate the weighted comprehensive deviation value v, where the weighted comprehensive deviation value v is equal to the bandwidth weight α multiplied by the bandwidth deviation db plus the real-time weight β multiplied by the delay deviation dt plus the reliability weight γ multiplied by the reliability deviation dr; determine the adjustment direction dir according to the positive or negative of the weighted comprehensive deviation value v, and generate the adjustment direction table R;
[0124] S423, read the basic adjustment step length k0 from the pre-stored adjustment rule library K; read the weighted comprehensive deviation value v from the adjustment direction table R; calculate the dynamic adjustment coefficient c according to the absolute size of the deviation value v: when the deviation value is large, the dynamic adjustment coefficient c is greater than 1, and when the deviation value is small, the dynamic adjustment coefficient c is less than 1; multiply the basic adjustment step length k0 by the dynamic adjustment coefficient c to obtain the actual adjustment step length k, and generate the adjustment step length table K;
[0125] S424, read the actual adjustment step size k and adjustment direction dir from the adjustment step size table K; calculate the adjustment amount Δ of the optimization parameter, where Δ is equal to the actual adjustment step size k multiplied by the adjustment direction dir; read the original transmission parameters from the optimal transmission strategy T, and apply the adjustment amount Δ to the original transmission parameters; verify the validity of the adjusted parameters to ensure that the system constraints are met, and generate the adjusted transmission strategy T'.
[0126] The data structure of the performance indicator threshold H is {bandwidth utilization threshold hb, response time threshold ht, reliability threshold hr}. Bandwidth utilization threshold hb: 32-bit floating point number, value range [0, 1]; response time threshold ht: 32-bit integer, unit milliseconds; reliability threshold hr: 32-bit floating point number, value range [0, 1].
[0127] The data structure of the adjustment rule base K is {performance index i, adjustment step size k, adjustment direction d, threshold range r}. Performance index i: 8-bit integer (1=bandwidth, 2=response time, 3=reliability); adjustment step size k: 32-bit floating point number, value range [0, 1]; adjustment direction d: 8-bit integer (1=increase, -1=decrease); threshold range r: two 32-bit floating point numbers, indicating the minimum and maximum allowed values.
[0128] In one embodiment of the present application, a method for calculating the dynamic adjustment coefficient is as follows: adjustment coefficient K(t) = K_base·(1+ α·ΔP(t) + β·∫ΔP(t)dt + γ·dΔP(t) / dt); wherein K_base is the basic adjustment coefficient; ΔP(t) is the performance index deviation; α, β, and γ are PID adjustment parameters; the integral term ∫ΔP(t)dt adopts the accumulated deviation within the sliding time window W; the differential term dΔP(t) / dt adopts the deviation change rate of the most recent two sampling cycles; the performance index deviation ΔP(t) = w1·ΔB(t) / B_max + w2·ΔD(t) / D_max + w3·ΔR(t), wherein ΔB(t), ΔD(t), and ΔR(t) are the normalized deviations of bandwidth, delay, and reliability, respectively.
[0129] In another embodiment of the present application, the optimization adjustment coefficient K(t) = K_0·exp(-α·|ΔP(t)|)·(1 + β·∫ΔP(t)dt)·(1 + γ·sign(ΔP(t))·min(|dΔP(t) / dt|, M)); wherein K_0 is the initial adjustment coefficient; ΔP(t) is the performance deviation; α is the sensitivity coefficient; β is the integral adjustment coefficient; γ is the rate of change adjustment coefficient; M is the upper limit of the rate of change; sign() is the sign function.
[0130] This embodiment realizes adaptive optimization of transmission strategy by establishing a dynamic strategy adjustment mechanism. First, by establishing a performance deviation table, accurate quantification of performance anomalies is achieved; then, by generating an adjustment direction table, the optimization direction of strategy adjustment is determined; finally, by introducing a dynamic adjustment coefficient, adaptive control of the adjustment step length is achieved. This embodiment can not only adjust the transmission strategy in time according to performance deviation, but also make the adjustment process smoother and more stable by introducing a dynamic adjustment coefficient. In particular, by verifying the validity of the adjustment parameters, it is ensured that the adjusted strategy still meets the constraints of the system.
[0131] According to one aspect of the present application, step S43 is further:
[0132] S431, read the data transmission order and grouping information from the adjusted transmission strategy T'; extract the device identification d, the starting address a, the register length l and the function code f for each data group; assemble the request message header and the data area according to the MODBUS protocol specification; calculate and add the CRC check code to generate the transmission message set M;
[0133] S432, read each message from the transmission message set M; establish a device communication connection, record the connection time ct; send a request message and start the response timeout timer tt; receive a response message and record the response time rt; verify the CRC check code and function code of the response message; parse the response data and record the transmission status st, and generate a transmission status table S;
[0134] S433, read each transmission status st from the transmission status table S; when a communication error occurs, record the error type et, error time et and retry count rc; execute the preset error recovery process: reconnect for connection error, retransmit for timeout error, and verify for data error; record the recovery operation result or, and generate an exception handling record E;
[0135] S434. Read transmission data from the transmission status table S and exception handling record E; calculate the bandwidth occupancy rb, average response delay rt and transmission success rate rr of each data group; record the start time st, end time et, number of transmitted bytes tb and number of retries rc of the transmission process; write all performance indicators and process data into the performance log L in chronological order; generate the execution result R according to the transmission completion status and data correctness.
[0136] This embodiment achieves reliable execution of data transmission through a systematic execution mechanism and exception handling process. First, by generating a transmission message set, the standardized encapsulation of MODBUS messages is achieved; then, by maintaining the transmission status table, the communication process is accurately tracked; finally, by establishing an exception handling record, a systematic handling of various abnormal situations is achieved. This embodiment not only ensures the reliability of data transmission, but also provides data support for the continuous optimization of the system through the recording of performance logs. In particular, by classifying and processing different types of errors, the fault tolerance and stability of the system are improved. By establishing a standardized error recovery process, the impact of abnormal situations on the normal operation of the system is reduced.
[0137] In another embodiment of the present application, the basic information contained in each data item includes a register address and the number of registers. When reading multiple data items, the set of all data items that need to be read can be counted: X(n)={X_1, X_2, ..., X_n}={(A_1, N_1), (A_2, N_2), ..., (A_n, N_n)}, where X(n) is the data set; X_n is the data item, A_n is the register address, and N_n is the number of data item registers.
[0138] For the data items in the X(n) set, use the quick sort algorithm to sort the register addresses from small to large to obtain a new sequence; X(n) = {X_1', X_2', ..., X_n'} = {(A_1', N_1'), (A_2', N_2'), ..., (A_n', N_n')}; import the set into the dynamic programming algorithm to calculate the optimal transmission method, find the best data item combination, read the holding register request and holding register response. The MODBUS data transmission process is in bytes. Taking the reading of holding register data as an example, according to the MODBUS protocol format definition, the number of bytes required to read n registers is calculated as follows: T = 8 + (5 + 2 (n_j + a_j-a_i)), where T is the byte length, which is a time indicator for measuring the transmission bandwidth occupancy; a_j is the register address of the j data item, where a_j ≥ a_i, if there is only one data item a_j = a_i, n_j is the number of registers of the j data item. For example, if the data item X_1' needs to occupy 1 register and the data item X_2' needs to occupy 2 registers, and the address interval of the data items is 3, the transmission bandwidth T{X_1', X_2'} consumed under this combined transmission is: T{X_1', X_2'}=8+(5+2×(2+3))=23; for the existing T{X_i', X_j'} combination, X_i'=(a_i, n_i ) and X_j'=(a_j, n_j ), the transmission bandwidth T{X_i', X_j'} is: T{X_i', X_j'}=8+(5+2(n_j+a_j-a_i )). Assume that the data item information of X_k' is (a_k, n_k): the transmission bandwidth T{X_k'} for reading an X_k' data item is: T{X_k'}=8+(5+2(n_k+a_k-a_k ))=8+(5+2n_k ); the transmission bandwidth for reading the combination of T{X_i', X_j', X_k'} is, where a_k>a_i: T{X_i', X_j', X_k'}=8+(5+2(n_k+a_k-a_i )). The bandwidth increment ΔT of reading T{X_i', X_j', X_k'} compared with T{X_i', X_j'} is: ΔT=T{X_i', X_j', X_k'}-T{X_i', X_j'}=(8+(5+2(n_k+a_k-a_i )))-(8+(5+2(n_j+a_j-a_i )))=(2(n_k+a_k-a_i ))-(2(n_j+a_j-a_i ))=2(n_k+a_k )-2(n_j+a_j ).
[0139] When T{X_k'}-ΔT>0, T{X_i', X_j', X_k'} consumes less bandwidth than when transmitting a single data item X_k'. Combining ΔT and T{X_k'} formula, we can get:
[0140] T{X_k'}-ΔL>0;
[0141] (8+(5+2n_k ))-(2(n_k+a_k )-2(n_j+a_j ))>0;
[0142] (13+2n_k )-(2n_k+2a_k-2n_j-2a_j )>0;
[0143] 13-2a_k+2(n_j+a_j )>0;
[0144] When the condition 13-2a_k+2(n_j+a_j )>0 is met, the bandwidth increment of T{X_i', X_j', X_k'} is smaller than that of T{X_k'}, and the judgment condition is converted into the relationship between X_j' and X_k', that is, the transmission bandwidth increment of the data item is only related to the adjacent data items.
[0145] There is a set of data item combinations X(n)={(a_1', n_1'), (a_2', n_2'), ..., (a_n', n_n')}. To calculate the optimal bandwidth combination M for reading all data items, the algorithm can be designed as follows:
[0146] modbus_optimal_bandwidth(X):
[0147] N = len(X);
[0148] M[0] = 0;
[0149] for i = 1 to N-1 do:
[0150] M[i] = 0;
[0151] if 13 - 2 * X[i].a + 2 * (X[i-1].n + X[i-1].a) > 0 :
[0152] M[i] = i – 1.
[0153] The calculation result is combination M. When M[i] with subscript i is 0, that is, the starting data item of the current data item combination, and the next adjacent data item M[i+1]=i, that is, when the X[i+1] data item is combined with X[i] to obtain data, there is a smaller bandwidth increment, and so on. As long as the result of combination M is analyzed, the optimal bandwidth combination can be obtained:
[0154] X(n)={X_1',X_2',...,X_k'}+{X_(k+1)',X_(k+2)',...,X_n'};
[0155] T_min=T{X_1',X_2',...,X_k'}+T{X_(k+1)',X_(k+2)',...,X_n'}.
[0156] Refer to the combination M=M1+M2+…+Mn, send data request messages and get response messages according to the register addresses and register quantities of each combination, and then extract the corresponding register values according to the offset address of each data item, so as to obtain the values of all data items with minimal transmission bandwidth consumption.
[0157] This embodiment reduces the time consumption of invalid bytes during transmission, improves the utilization of line bandwidth, and the response speed of user interface data requests. Compared with the single data item collection strategy, more equipment data can be collected on the same line in one collection cycle, reducing equipment procurement costs.
[0158] The present invention realizes the comprehensive characterization of data features by establishing a complete data item feature extraction system, considering multi-dimensional features such as device identification, register type, register address and length, and constructing a function code mapping table and an address range table. By introducing the access frequency analysis and exponential smoothing method of multiple time windows, and combining the stability of the access mode with the coefficient of variation, a dynamic priority evaluation mechanism is established to accurately reflect the importance of data. By considering the protocol overhead such as the MODBUS message header length and the CRC check length in detail, and combining the nonlinear bandwidth constraint function, the accurate modeling of bandwidth consumption is realized. By establishing a complete real-time monitoring and evaluation mechanism, combined with a dynamic adjustment mechanism, the adaptive optimization of the transmission strategy is realized. By establishing a systematic exception handling process, different types of errors are classified and processed, and data support for continuous optimization is provided through performance log records. By establishing a multi-dimensional performance monitoring system, key indicators such as bandwidth occupancy, response delay and transmission success rate are tracked in real time, and the quantitative evaluation of performance is realized. In general, the present invention constructs a complete feature characterization, constraint modeling, optimization decision and dynamic adjustment mechanism, and realizes the intelligent bandwidth optimization of MODBUS data transmission. By constructing a multidimensional feature matrix and an association matrix, a comprehensive characterization of data item features is achieved; by establishing a multidimensional constraint model, unified optimization of bandwidth, real-time performance, and reliability is achieved; by applying graph theory algorithms, optimal grouping of data items is achieved; and by a closed-loop monitoring and adjustment mechanism, dynamic optimization of transmission strategies is achieved. The present invention improves the efficiency and reliability of MODBUS data transmission, while ensuring the real-time requirements of important data.
[0159] The preferred embodiments of the present invention are described in detail above; however, the present invention is not limited to the specific details in the above embodiments. Within the technical concept of the present invention, various equivalent transformations can be made to the technical solutions of the present invention, and these equivalent transformations all belong to the protection scope of the present invention.
Claims
1. A method for optimizing MODBUS data transmission bandwidth, characterized in that: The steps include: S1. Obtain basic information of each device, perform feature analysis on the basic information, and generate a data item feature matrix; based on the data item feature matrix, calculate the data item priority vector; and construct a data item association matrix according to the data item feature matrix and the data item priority vector; wherein the basic information includes device identification, register type, register address, and register length; S2. Based on the data item feature matrix, the data item priority vector and the pre-stored historical error rate data, a multi-dimensional constraint model of bandwidth consumption constraint, real-time constraint and reliability constraint is constructed; Based on the multi-dimensional constraint model, a bandwidth consumption model is calculated; combining the bandwidth consumption model and the preset real-time requirements, a real-time constraint model is calculated; according to the bandwidth consumption model and the pre-stored historical error rate data, a reliability model is constructed; S3. Based on the bandwidth consumption model, real-time constraint model, reliability model and data item association matrix, a weighted undirected graph of data item association is constructed; based on the weighted undirected graph, subgraph division is performed to generate an optimal data item grouping set; based on the optimal data item grouping set, multi-objective optimization calculation is performed to generate an optimal transmission strategy; S4. Based on the optimal transmission strategy and the pre-stored performance indicator threshold, the data transmission process is monitored and evaluated in real time to generate a performance evaluation result; the strategy is adjusted according to the performance evaluation result to obtain an adjusted transmission strategy; Based on the adjusted transmission strategy, data transmission is executed and exception handling is performed, and execution results and performance logs are generated.
2. A MODBUS data transmission bandwidth optimization method according to claim 1, characterized in that: Step S1 is further as follows: S11, reading basic information of each data item from pre-stored device data item configuration information; storing the basic information of each data item by row to generate an initial data item feature matrix; normalizing the initial data item feature matrix according to a preset number of matrix rows and feature numbers to obtain a data item feature matrix; S12, reading the access frequency value and timeliness requirement value of each data item from the pre-stored historical access frequency and real-time requirement; calculating the priority score of each data item based on the access frequency value, timeliness requirement value and data item feature matrix of each data item; merging the priority scores of all data items into a vector form to generate a data item priority vector; S13, reading the register address difference between each pair of data items from the data item feature matrix, and calculating the address difference matrix; reading the priority difference between each pair of data items from the data item priority vector, and calculating the priority difference matrix; The address difference matrix and the priority difference matrix are weightedly combined to generate a data item association matrix.
3. A MODBUS data transmission bandwidth optimization method according to claim 2, characterized in that: Step S2 is further as follows: S21, extracting the starting address, number of data items and current address of each data group from the data item feature matrix; calculating the initial bandwidth consumption value based on the starting address, number of data items and current address of each data group; reading the bandwidth constraint function parameters from the pre-stored system configuration parameters; constructing a bandwidth constraint equation group based on the initial bandwidth consumption value and the bandwidth constraint function parameters, and generating the bandwidth constraint component in the multidimensional constraint model; Based on the bandwidth constraint component, the initial bandwidth consumption value is normalized to generate a standardized bandwidth consumption model; S22, reading the priority value of each data item from the data item priority vector; reading the maximum allowable delay threshold from the pre-stored system configuration parameters; constructing a delay constraint function according to the priority value and the maximum allowable delay threshold, and generating a real-time constraint component in the multidimensional constraint model; Based on the real-time constraint components and priority values, a real-time constraint model is constructed; S23, reading the communication error rate of each device from the pre-stored historical error rate data; extracting the bandwidth consumption benchmark value from the bandwidth consumption model; and calculating the retransmission cost based on the communication error rate and the bandwidth consumption benchmark value; Based on the communication error rate, bandwidth consumption benchmark value and retransmission cost, the reliability constraint component in the multidimensional constraint model is constructed; Based on the reliability constraint components, a reliability evaluation function is constructed and a reliability model is generated.
4. A MODBUS data transmission bandwidth optimization method according to claim 3, characterized in that: Step S3 is further as follows: S31, reading the association value between each data item from the data item association matrix; taking each data item as a vertex of the graph and the association value between the data items as the weight of the edge, to construct a weighted undirected graph; Generate a data item association graph based on the edge weight relationship between vertices in a weighted undirected graph; S32, reading an adjacency matrix from a data item association graph; reading a bandwidth constraint threshold from a bandwidth consumption model; iteratively calculating the adjacency matrix using an improved Kernighan-Lin algorithm to obtain a subgraph partitioning result that satisfies the bandwidth constraint threshold; sorting the subgraph partitioning results according to the magnitude of the association value to generate an optimal data item grouping set; S33, reading the data item set information of each group from the optimal data item grouping set; reading the bandwidth weight, real-time weight and reliability weight from the pre-stored system weight parameters; based on the bandwidth weight, real-time weight and reliability weight, substituting the data item set information of each group into the bandwidth consumption model, the real-time constraint model and the reliability model, performing weighted calculation, and obtaining a weighted score for each group; Based on the weighted score of each group, a weighted objective function is constructed; Through iterative optimization calculation, the packet transmission order that minimizes the weighted objective function is obtained, and the optimal transmission strategy is generated.
5. A MODBUS data transmission bandwidth optimization method according to claim 4, characterized in that: Step S4 is further as follows: S41, reading a bandwidth utilization threshold, a response time threshold, and a reliability threshold from pre-stored performance indicator thresholds; based on the optimal transmission strategy, collecting bandwidth occupancy, response delay, and transmission success rate in real time during data transmission; comparing and calculating the bandwidth occupancy, response delay, and transmission success rate with the bandwidth utilization threshold, response time threshold, and reliability threshold, respectively, to generate a performance evaluation result; S42, reading a performance deviation value from the performance evaluation result; reading an adjustment step size parameter from a pre-stored adjustment rule library; and calculating an optimization parameter adjustment amount based on the performance deviation value and the adjustment step size parameter; Applying the optimization parameter adjustment amount to the optimal transmission strategy to generate an adjusted transmission strategy; S43. Read the data transmission order and grouping information from the adjusted transmission strategy; perform data transmission according to the data transmission order and grouping information, record the data during the transmission process, including bandwidth occupancy, response delay and transmission success rate, and obtain recorded data; write the recorded data into the performance log and generate the execution result of the data transmission.
6. A MODBUS data transmission bandwidth optimization method according to claim 5, characterized in that: Step S11 is further as follows: S111, reading basic information of each data item from pre-stored device data item configuration information, including device identification, register type, register address, and register length; writing the basic information of each data item into a data item information table according to a preset format; S112, reading the register type of each data item from the data item information table; calculating the MODBUS function code according to the register type, and matching the MODBUS function code with the corresponding data item one by one to generate a function code mapping table; merging the data item information table and the function code mapping table to generate an extended data item table; S113, reading the register address and register length of each data item from the extended data item table, calculating the end address of each data item, and generating an address range table; sorting the address range table according to the device identifier and the register address, and generating an ordered address table; S114, extracting data from the ordered address table and the extended data item table to construct an initial feature matrix; Calculate the number of rows and the number of features of the initial feature matrix; based on the number of rows and the number of features of the initial feature matrix, use the min-max normalization method to normalize the register address and the end address to generate normalized eigenvalues; combine the normalized eigenvalues to generate a data item feature matrix.
7. A MODBUS data transmission bandwidth optimization method according to claim 5, characterized in that: Step S12 is further as follows: S121, reading the number of accesses of each data item in different time windows from the pre-stored historical access frequencies, and calculating the access frequencies of at least three different time scales; performing weighted calculation on the access frequencies of different time scales using an exponential smoothing method, and generating a comprehensive access frequency value; S122, calculating the coefficient of variation of the comprehensive access frequency value; Based on the coefficient of variation, the stability of the access pattern is determined and an access stability index is generated; the access stability index is combined with the comprehensive access frequency value to generate an access pattern table; S123, reading the response time limit of each data item from the pre-stored real-time requirements; grading the data items in the data item feature matrix according to the response time limit to generate a real-time grade; Combine the data in the real-time level and access pattern table to calculate the preliminary priority score and generate the initial priority table; S124, reading a preliminary priority score from the initial priority table; Read access stability index from access pattern table; The preliminary priority score and the access stability index are combined using a weighted combination method to obtain the final priority score; Sort the final priority scores by high or low scores to generate a data item priority vector.
8. A MODBUS data transmission bandwidth optimization method according to claim 5, characterized in that: Step S21 is further as follows: S211, extracting the starting address, number of data items and current address of each data group from the data item feature matrix; reading the MODBUS message header length and CRC check length from the pre-stored system configuration parameters; combining the starting address, number of data items, current address, MODBUS message header length and CRC check length of each data group according to a preset format to generate a data group basic table; S212. Based on the data group basic table, calculate the basic message overhead and data area length of each data group according to the MODBUS protocol specification; add the basic message overhead and the data area length to obtain the initial bandwidth consumption value; wherein the basic message overhead is equal to the sum of the MODBUS message header length and the CRC check length; the data area length is equal to the number of data items multiplied by the number of bytes of each data item; S213, reading bandwidth constraint function parameters from pre-stored system configuration parameters; generating a bandwidth constraint table based on the initial bandwidth consumption value and the bandwidth constraint function parameters; Based on the bandwidth constraint table, calculate the actual bandwidth occupancy rate of each data group; S214, normalizing the initial bandwidth consumption value to generate a normalized bandwidth value; combining the normalized bandwidth value with the actual bandwidth occupancy rate to construct a bandwidth constraint equation group; and generating a standardized bandwidth consumption model based on the bandwidth constraint equation group and the initial bandwidth consumption value.
9. A MODBUS data transmission bandwidth optimization method according to claim 5, characterized in that: Step S31 is further as follows: S311, reading the association value between each pair of data items from the data item association matrix; based on the association value, mapping each data item to a vertex, constructing a vertex set; based on the vertex set, calculating the initial connection relationship between the vertices, and generating a vertex mapping table; S312, reading the vertex connection relationship from the vertex mapping table; obtaining the edge weight based on the vertex connection relationship and the association value; Based on the device identification, the influencing factor of the edge weight is generated; the edge weight and the influencing factor are combined to calculate the actual edge weight and generate an edge weight table; S313, reading data from the vertex mapping table and the edge weight table to construct an adjacency matrix; Based on the adjacency matrix, calculate the degree and connectivity of each vertex; Combine the degree and connectivity of vertices to generate a graph structure feature table; S314. Extract data from the graph structure feature table and the adjacency matrix to construct a complete weighted undirected graph structure; verify the connectivity and weight distribution of the weighted undirected graph structure, and output a data item association graph that represents the association relationship between data items.
10. A MODBUS data transmission bandwidth optimization method according to claim 5, characterized in that: Step S32 is further as follows: S321, read the adjacency matrix and the weight matrix from the data item association graph; multiply each element in the adjacency matrix by the corresponding element of the weight matrix to generate a weighted adjacency matrix; based on the weighted adjacency matrix, calculate the degree matrix of the graph to generate a graph feature matrix; S322, extracting the connection relationship between nodes from the graph feature matrix, and calculating the Laplace matrix using the spectral clustering method; Perform eigenvalue decomposition on the Laplace matrix to obtain eigenvalues and eigenvectors; Determine the optimal number of subgraphs based on the eigenvalues and generate a clustering parameter table; S323, based on the parameters and feature vectors in the clustering parameter table, using the k-means algorithm to perform clustering to obtain initial groups; Based on the initial grouping, the internal connectivity and external connectivity of each node are calculated to generate the gain value after moving the node; Read the bandwidth constraint threshold from the bandwidth consumption model; If the gain value is positive and meets the bandwidth constraint threshold, the nodes are exchanged and repeated until a positive gain value cannot be obtained, and the optimized grouping is output; otherwise, the initial grouping is directly used as the optimized grouping; based on the optimized grouping, a subgraph partitioning table is generated; S324, extracting the internal association value of each subgraph from the subgraph partition table and the data item association graph; Based on the internal correlation value, calculate the correlation score of the subgraph; According to the relevance score, the subgraphs are sorted in descending order to generate the optimal data item grouping set.
Citation Information
Patent Citations
Bus transmission performance dynamic scheduling method and device
CN115378762A
Method, system and device for quickly positioning bandwidth optimal value and medium
CN115529258A
Power grid structure chart-based power grid optimization method and device
CN118539432A
Comprehensive performance evaluation method for CNC machine tools based on improved pull-off grade method
US20200282503A1
Cited By
Configuration table analysis method, electronic device and program product
CN121173887A