A method for optimizing MODBUS data transmission bandwidth
By constructing a feature matrix and priority vector for data items, establishing a multidimensional constraint model, and generating a weighted undirected graph for optimal data grouping and transmission strategies, the problems of incomplete features, inaccurate priorities, imprecise bandwidth modeling, and insufficient dynamic optimization in MODBUS data transmission are solved, thereby improving data transmission efficiency and reliability.
Patent Information
- Application Number
- CN202411912468.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-24
- Publication Date
- 2025-11-07
- Estimated Expiration
- 2044-12-24
AI Technical Summary
Existing MODBUS data transmission methods fail to fully consider multi-dimensional characteristics such as device identification and data type, have inaccurate priority assessment, imprecise bandwidth modeling, lack dynamic optimization mechanisms, and have insufficient anomaly handling capabilities, resulting in limited data transmission efficiency and reliability.
By constructing a feature matrix and priority vector for data items, a multidimensional constraint model is established, a weighted undirected graph is generated for subgraph partitioning, the optimal transmission strategy is realized, and real-time monitoring and strategy adjustment are performed to generate execution results and performance logs.
It achieves comprehensive characterization of data items, unified optimization of bandwidth, real-time performance, and reliability, improves the efficiency and reliability of MODBUS data transmission, and ensures the real-time performance of important data.
Smart Images

Figure CN119603157B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The application belongs to the field of data transmission, and particularly relates to a MODBUS data transmission bandwidth optimization method. BACKGROUND
[0002] In the field of industrial automation, the MODBUS protocol is widely used in industrial field data acquisition and control systems due to its simplicity, openness and reliability. With the rapid development of industrial Internet of Things, the number of devices and data acquisition points has increased dramatically, leading to increasing bandwidth pressure on field bus networks. In particular, in power systems, intelligent manufacturing and process control scenarios, the contradiction between a large number of real-time data acquisition requirements and limited communication bandwidth is 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 operation efficiency and stability of the entire industrial control system.
[0003] Currently, the research on MODBUS data transmission bandwidth optimization mainly focuses on the following aspects: first, balancing network load through simple polling cycle adjustment, setting different acquisition frequencies according to the importance of data; second, using a data grouping method based on priority, grouping data items of the same priority for transmission; third, using a fixed data frame packing strategy to merge multiple register data with consecutive addresses in one message for transmission; and fourth, setting a static bandwidth limit threshold to avoid network congestion. These methods have improved bandwidth utilization efficiency to some extent, but the optimization effect is limited.
[0004] However, the existing technology still has the following problems: the data feature extraction is not comprehensive, only considering the continuity of register addresses, ignoring the influence of device identification, data type and other multi-dimensional features, resulting in unreasonable data grouping; the priority evaluation mechanism is too simple, without considering the time-varying characteristics and stability features of data access patterns, and cannot accurately reflect the actual importance of data items; the 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 a mismatch between actual bandwidth occupation and expectation; there is a lack of dynamic optimization mechanism, the pre-set grouping strategy cannot adapt to changes in network conditions and business requirements, easily causing waste of bandwidth resources or transmission delay of critical data; the abnormal handling capability is insufficient, lacking effective retransmission strategy and bandwidth adjustment mechanism when communication errors occur, affecting the reliability of the system; and there is no complete performance evaluation system to quantitatively evaluate and continuously improve the optimization effect. These technical problems seriously restrict the improvement of MODBUS data transmission efficiency. SUMMARY
[0005] The present application provides a MODBUS data transmission bandwidth optimization method to solve at least one technical problem in the prior art.
[0006] A technical solution, a method for optimizing MODBUS data transmission bandwidth, includes the following steps:
[0007] S1. Obtain basic information of each device, perform feature analysis, and generate a data item feature matrix; calculate the data item priority vector based on this matrix, and construct a data item association matrix.
[0008] S2. Based on the data item feature matrix, data item priority vector and pre-stored historical error rate data, construct a multi-dimensional constraint model and calculate the bandwidth consumption model, real-time constraint model and reliability model.
[0009] S3. Based on the bandwidth consumption model, real-time constraint model, reliability model and data item association matrix, construct a weighted undirected graph, perform subgraph partitioning and multi-objective optimization calculation, and generate the optimal transmission strategy.
[0010] S4. Based on the optimal transmission strategy and pre-stored performance indicator thresholds, perform real-time monitoring and evaluation of the data transmission process, adjust the strategy, transmit data and handle exceptions, and generate execution results and performance logs.
[0011] Beneficial effects: This invention achieves comprehensive characterization of data item features through the construction of multidimensional feature matrices and correlation matrices; achieves unified optimization of bandwidth, real-time performance, and reliability through the establishment of multidimensional constraint models; achieves optimal grouping of data items through graph theory algorithms; and achieves dynamic optimization of transmission strategies through closed-loop monitoring and adjustment mechanisms. It not only improves the efficiency and reliability of MODBUS data transmission but also ensures the real-time requirements of important data. Attached Figure Description
[0012] Figure 1 This is a flowchart of the present invention.
[0013] Figure 2 This is a flowchart of step S1 of the present invention.
[0014] Figure 3 This is a flowchart of step S2 of the present invention.
[0015] Figure 4 This is a flowchart of step S3 of the present invention.
[0016] Figure 5 This is a flowchart of step S4 of the present invention. Detailed Implementation
[0017] The present application will be described in more detail below with reference to specific embodiments, such as Figure 1 As shown, this application proposes a MODBUS data transmission bandwidth optimization method, which includes the following steps:
[0018] S1, acquire 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 a data item priority vector; based on the data item feature matrix and the data item priority vector, construct a data item association matrix; 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 pre-stored historical error rate data, construct a multi-dimensional constraint model of bandwidth consumption constraint, real-time constraint, and reliability constraint; based on the multi-dimensional constraint model, calculate a bandwidth consumption model; combine the bandwidth consumption model with a pre-set real-time requirement, and calculate a real-time constraint model; based on the bandwidth consumption model and the pre-stored historical error rate data, construct a reliability model;
[0020] S3, based on the bandwidth consumption model, the real-time constraint model, the reliability model, and the data item association matrix, construct a weighted undirected graph of data item association; based on the weighted undirected graph, perform subgraph division, and generate an optimal data item grouping set; based on the optimal data item grouping set, perform multi-objective optimization calculation, and generate an optimal transmission strategy;
[0021] S4, based on the optimal transmission strategy and pre-stored performance index threshold values, perform real-time monitoring and evaluation on the data transmission process, and generate performance evaluation results; perform strategy adjustment according to the performance evaluation results, and obtain an adjusted transmission strategy; based on the adjusted transmission strategy, perform data transmission and perform abnormality processing, and generate an execution result and a performance log.
[0022] As shown in Figure 2 According to one aspect of the present application, step S1 is further as follows:
[0023] S11, read the basic information of each data item from the pre-stored device data item configuration information; store the basic information of each data item by row to generate an initial data item feature matrix; perform normalization processing on the initial data item feature matrix according to a pre-set matrix row number and feature number, and obtain the data item feature matrix;
[0024] S12, read the access frequency value and timeliness requirement value of each data item from the pre-stored historical access frequency and real-time requirement; based on the access frequency value, the timeliness requirement value, and the data item feature matrix of each data item, calculate the priority score of each data item; combine 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, calculate the address difference degree matrix; read the priority difference between each pair of data items from the data item priority vector, calculate the priority difference degree matrix; combine the address difference degree matrix and the priority difference degree matrix by weighting, and generate the data item association matrix.
[0026] The embodiment constructs the data item feature matrix and the priority vector through the pre-stored device data item configuration information, and generates the data item association matrix based on the same, realizes multi-dimensional representation and correlation analysis of data item features. First, starting from the device basic information, the discrete device data items are converted into quantifiable feature vectors through the construction of the feature matrix, which provides 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 finally generated association matrix establishes the multi-dimensional correlation relationship between the data items, and the establishment of the correlation relationship provides an important basis for subsequent data item grouping and transmission strategy optimization. The embodiment combines the static features and dynamic features of the device data items, constructs a complete feature representation system, and can comprehensively reflect the physical characteristics, access characteristics and business importance of the data items.
[0027] According to an aspect of the present application, step S11 further comprises:
[0028] S111, read the basic information of each data item from the pre-stored device data item configuration information, including device identifier, register type, register address and register length; write the basic information of each data item into the data item information table according to a preset format; extract all device identifiers from the data item information table and remove duplicates to generate a device list;
[0029] S112, read the register type of each data item from the data item information table; calculate the MODBUS function code according to the register type, and correspond the MODBUS function code to the corresponding data item one by one to generate a function code mapping table; combine 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, extract data from the ordered address table and the extended data item table, 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, normalize the register address and the end address by using the min-max normalization method to generate normalized feature values; and combine 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, and scanning period s}. The device identifier d is a 16-bit unsigned integer, which uniquely identifies each device. The register type r is an 8-bit integer (1 = coil, 2 = discrete input, 3 = holding register, and 4 = input register). The register address a is a 16-bit unsigned integer representing the starting address of the register. The register length l is a 16-bit unsigned integer representing the number of consecutive registers. The data type t is an 8-bit integer (1 = bit, 2 = word, 3 = dword, and 4 = float). The scanning period s is a 32-bit integer with a unit of milliseconds.
[0033] The 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 structured storage of basic information such as device identifier, register type, address, and length. Then, a function code mapping table is established to establish a correspondence between register type and MODBUS function code, providing a basis for subsequent communication protocol packaging. Through the construction and ordering of the address range table, ordered management of the data item address space is realized. Finally, min-max normalization processing is performed to convert features of different dimensions to a unified measurement space. The embodiment not only provides a reliable data basis 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. The embodiment improves the standardization of data processing and the accuracy of feature expression, laying a solid data foundation for the entire optimization system.
[0034] According to one aspect of the present application, step S12 further comprises:
[0035] S121, reading the number of accesses of each data item in different time windows from the pre-stored historical access frequency, calculating the access frequency of at least three different time scales; and using an exponential smoothing method to calculate the access frequency of different time scales to generate a comprehensive access frequency value;
[0036] S122, calculate a coefficient of variation of the comprehensive access frequency value; determine stability of the access mode based on the coefficient of variation to generate an access stability index; combine the access stability index and the comprehensive access frequency value to generate an access mode table;
[0037] S123, read a response time limit of each data item from pre-stored real-time requirements; classify the data items in the data item feature matrix according to the response time limit to generate a real-time level; combine the real-time level and data in the access mode table to calculate a preliminary priority score to generate an initial priority table;
[0038] S124, read the preliminary priority score from the initial priority table; read the access stability index from the access mode table; combine the preliminary priority score and the access stability index by using a weighted combination method to obtain a final priority score; sort the final priority score according to the score from high to low to generate a data item priority vector.
[0039] The data structure of the historical access frequency is {device identifier d, data item identifier i, access frequency n, time window w}; the device identifier d corresponds to the identifier in the device configuration information; the data item identifier i is a 32-bit integer, which uniquely identifies the data item; the access frequency n is a 32-bit integer, which records the total access frequency in the time window; and the time window w is a 64-bit timestamp, which 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}; the data item identifier i corresponds to the identifier in the historical access frequency; the response time limit t is a 32-bit integer, with a unit of milliseconds, indicating the maximum allowed response time; and the priority p is an 8-bit integer (1-255), with a smaller value indicating a higher priority.
[0041] In an embodiment of the present application, the process of generating the comprehensive access frequency value is specifically: 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 access frequencies of the current hour, day and week respectively; λ_h, λ_d, λ_w are smoothing coefficients of each time scale, with a value range of [0, 1]; α, β, γ are time scale weights, and α+β+γ=1; i is the data item serial number; and t is the current timestamp.
[0042] The embodiment realizes dynamic evaluation and quantitative expression of data item priority through comprehensive analysis of historical access frequency and real-time requirement. The exponential smoothing method is used to perform weighted calculation on access frequency of different time windows, effectively capturing the time characteristics of data access mode. Through the introduction of the coefficient of variation, quantitative evaluation of access mode stability is realized. In combination with the real-time level and access mode characteristics, a comprehensive priority evaluation system is constructed. The embodiment not only considers the historical law of data access, but also takes into account the real-time requirement, so that the priority allocation is more reasonable and dynamic. In particular, through the introduction of the access stability index, the system can distinguish between stable periodic access and burst 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 further comprises:
[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; all device identification difference coefficients form an n×n matrix to generate a device difference matrix S; wherein n is the total number of data items; i, j are data item serial numbers, taking the value range [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 degree oij between data items i and j: oij=(min(ei, ej)-max(ai, aj)+1) / (max(ei, ej)-min(ai, aj)+1), where ei and ej are end addresses, ai and aj are the start addresses of data items i and j; based on the address overlap degree, calculate the address difference degree dij=1-oij; all address difference degrees form 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 between data items i and j: vij=|pi-pj|; use the Gaussian normalization function to convert the difference value: pij=exp(-vij / (2σ)), where σ is the priority standard deviation; all normalized priority difference degrees form an n×n matrix to generate a priority difference matrix B; wherein pi and pj are the priority scores of data items i and j; pij is the normalized priority difference degree. 2 2
[0047] S134, read the device identification weight Δ, the address weight α and the priority weight β from the pre-stored system weight parameters; weight and combine the device difference matrix S, the address difference matrix A and the priority difference matrix B: rij = Δxsij + αxdij + βxpij; compose an n x n matrix with the weighted and combined correlation degree values to generate the data item correlation matrix R. Wherein rij is the final correlation degree between data items i and j.
[0048] In an embodiment of the present application, the final correlation degree R(i, j) = α·(1-|A(i)-A(j)| / max_A) +β·exp(-(P(i)-P(j)) 2 / 2σ 2 ) + γ·(1-Δ(D(i), D(j))); wherein A(i) and A(j) are the normalized address values of data items i and j; max_A is the maximum address difference value; 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, taking 1 when x = y, and 0 otherwise; α is the address weight coefficient, taking the value range [0, 1]; β is the priority weight coefficient, taking the value range [0, 1]; γ is the device identification weight coefficient, taking the value range [0, 1]; and α + β + γ = 1; i, j are data item serial numbers, taking the value range [1, n], and n is the total number of data items.
[0049] The embodiment establishes a complete data item correlation degree evaluation system through multi-dimensional correlation analysis. Firstly, the data item correlation characteristics between different devices are quantified through the construction of the device difference matrix; the aggregation characteristics of data items in the address space are accurately described through the calculation of the address overlap degree; the smoothness of the data item priority similarity is established through the Gaussian normalization function to convert the priority difference; and finally, the correlation characteristics of multiple dimensions are integrated into a unified correlation degree index through the weighted combination method. The embodiment not only considers the physical attributes (device identification, address space) of the data items, but also considers the business attributes (priority), so that the correlation degree evaluation is more comprehensive and accurate. In particular, by introducing the Gaussian normalization function, the priority difference is nonlinearly mapped to the correlation degree, avoiding the distortion that may be caused by simple linear mapping, and improving the accuracy and rationality of the data item correlation relationship evaluation.
[0050] As shown in Figure 3 , according to one aspect of the present application, step S2 further comprises:
[0051] S21, extracting the start address, the data item number and the current address of each data group from the data item feature matrix; calculating an initial bandwidth consumption value based on the start address, the data item number and the current address of each data group; reading the bandwidth constraint function parameter from the pre-stored system configuration parameter; constructing a bandwidth constraint equation set based on the initial bandwidth consumption value and the bandwidth constraint function parameter, generating the bandwidth constraint component in the multi-dimensional constraint model; performing normalization processing on the initial bandwidth consumption value based on the bandwidth constraint component, 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 allowed delay threshold value from the pre-stored system configuration parameter; constructing a delay constraint function according to the priority value and the maximum allowed delay threshold value, generating the real-time constraint component in the multi-dimensional constraint model; constructing a real-time constraint model based on the real-time constraint component and the priority value.
[0053] S23, reading the communication error rate of each device from the pre-stored historical error rate data; extracting the bandwidth consumption reference value from the bandwidth consumption model; calculating the retransmission cost based on the communication error rate and the bandwidth consumption reference value; constructing the reliability constraint component in the multi-dimensional constraint model based on the communication error rate, the bandwidth consumption reference value and the retransmission cost; constructing a reliability evaluation function based on the reliability constraint component, generating a reliability model.
[0054] The data structure of the historical error rate data is {device identifier d, time period s, communication error number e, total communication number n}. The device identifier d corresponds to the identifier in the device configuration information; the time period s is a 64-bit timestamp range; the communication error number e is a 32-bit integer; and the total communication number n is a 32-bit integer.
[0055] The embodiment constructs a constraint model containing three dimensions of bandwidth consumption, real-time and reliability based on the feature matrix and the priority vector, combined with the historical error rate data. A complete multi-dimensional constraint system is established, the resource occupation of data transmission is accurately quantified through the bandwidth consumption model, the timely transmission of high-priority data is ensured through the real-time constraint model, and the influence of communication quality on transmission efficiency is considered through the reliability model. The establishment of such a 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, which not only ensures the smooth change of bandwidth utilization, but also effectively prevents the sudden increase of bandwidth occupation. 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 an aspect of the present application, step S21 further comprises:
[0057] S211, extract the start address, data item number and current address of each data group from the data item feature matrix; read the MODBUS message header length and CRC check length from the pre-stored system configuration parameters; combine the start address, data item number, current address, MODBUS message header length and CRC check length of each data group according to the preset format to generate a data group basic table; calculate the continuous address range that can be combined for each data group to generate an address range table A;
[0058] S212, based on the data group basic table, calculate the message basic overhead and data area length of each data group according to the MODBUS protocol specification; add the message basic overhead and data area length to obtain an initial bandwidth consumption value; wherein the message basic 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 product of the data item number and the byte number of each data item;
[0059] S213, read the bandwidth constraint function parameters from the pre-stored system configuration parameters; generate a bandwidth constraint table based on the initial bandwidth consumption value and the bandwidth constraint function parameters; calculate 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), k is the bandwidth constraint function parameter, and b is the initial bandwidth consumption value;
[0060] S214, normalize the initial bandwidth consumption value to generate a normalized bandwidth value; combine the normalized bandwidth value and the actual bandwidth occupancy rate to construct a bandwidth constraint equation set; generate a standardized bandwidth consumption model according to the bandwidth constraint equation set 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}. The bandwidth upper limit bMax: 32-bit floating point number, unit byte / s; the message size limit sMax: 16-bit integer, unit byte; the MODBUS message header length h: 8-bit integer, unit byte; the 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 start address of the j-th data item; ΔD(i, j) is the data type difference degree; θ is the address interval threshold; η is the type difference threshold; and when C(i, j) > 0.5, it is determined that it can be merged.
[0063] Actual bandwidth occupation B(x) = B_max·(k·x) / (1+k·x) + B_base; wherein x is the original bandwidth demand; B_max is the maximum bandwidth capacity of the system; k is a bandwidth adjustment coefficient for controlling the slope of the curve; B_base is the basic bandwidth occupation; and when x tends to infinity, B(x) tends to B_max + B_base, ensuring that the bandwidth usage does not exceed the upper limit of the system.
[0064] Packet total overhead B(G) = H_base + N_reg·L_type + F_code·K_f + CRC_len + Σ(O_i·Δ_i); wherein 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; and Δ_i is the option enable flag.
[0065] In another embodiment of the present application, the actual bandwidth occupation 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 influence factor; γ is the conflict influence factor; and t is the time stamp.
[0066] Bandwidth constraint equation set: Bandwidth constraint model M(G) = Σ(w_i·F_i(x)), which 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; wherein B_k(t) is bandwidth occupation of data group k at t time; D_k(t) is transmission delay of data group k; R_k(t) is reliability index of data group k; w_i is constraint weight; B_max is upper limit of bandwidth; D_max is upper limit of delay; R_min is lower limit of reliability.
[0067] The embodiment realizes accurate quantification and constraint of bandwidth resource usage in the MODBUS communication process through fine-grained bandwidth consumption analysis and modeling. First, the accurate description of each component of the MODBUS message structure is realized through the construction of the data group basic table; the actual occupation of bandwidth by the message overhead and data load is accurately quantified through the establishment of the bandwidth basic table; the nonlinear mapping relationship between bandwidth consumption and actual resource occupation is established through the introduction of the bandwidth constraint function; and finally, the complete bandwidth consumption constraint system is formed through normalization processing and the construction of the constraint equation set. The embodiment not only considers the overhead characteristics of the MODBUS protocol itself, but also reflects the saturation characteristics of bandwidth resource usage through the nonlinear constraint function, so that the allocation of bandwidth resources is more reasonable and efficient, and the accuracy and rationality of bandwidth resource usage are improved.
[0068] According to one aspect of the present application, step S22 further comprises:
[0069] S221, read the priority value p of each data item from the data item priority vector; read the maximum allowed delay threshold t from the pre-stored system configuration parameters; calculate the maximum 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 the 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; weight and superimpose the three types of delays to generate a comprehensive delay constraint value ct; construct the real-time constraint component in the multi-dimensional constraint model C according to the comprehensive delay constraint value ct, and generate the 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 the delay constraint function f(t) considering the priority; set different constraint parameters according to different priority intervals, and generate the real-time constraint model L.
[0072] In an embodiment of the present application, the priority latency adjustment coefficient K_p(i) = K_base·(1 + α·ln(P_max / P(i)))·(1 - β·V_f(i)); wherein K_base is a base adjustment coefficient; P_max is a highest priority value; P(i) is a priority value of data item i; V_f(i) is a variation coefficient of access frequency of data item i; α is a priority influence factor, with a value range of [0, 1]; β is a stability influence factor, with a value range of [0, 1]; V_f(i) = σ_f(i) / μ_f(i), σ_f(i) is a standard deviation of access frequency, and μ_f(i) is a mean value of access frequency.
[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)); wherein L_n, L_d, L_s are respectively base delays of network, device and system; T_n, T_d, T_s are respectively unit data processing delays of each part; H(i) is a network hop number; S(i) is a device processing complexity; Q(i) is a system queue length; w_n, w_d, w_s are weight coefficients and w_n + w_d + w_s = 1.
[0074] The latency 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); wherein t_base is a base response time; P(i) is a priority of data item i; P_max is a highest priority value; Q(t) is a system queue length at t time; Q_max is a maximum queue length; U(t) is a system load rate at t time; U_max is a maximum load rate; α, β, γ are adjustment coefficients.
[0075] The embodiment realizes the differentiated delay control mechanism based on priority by establishing a multi-level real-time constraint model. First, the dynamic corresponding relationship between the priority and the maximum response time is established through the establishment of the delay constraint table, and the priority adjustment coefficient is introduced to make the delay constraint adaptive. Then, by considering the delay characteristics of 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, the delay constraint function considering the priority is established, and the differentiated delay control of different priority data is realized. The embodiment can not only accurately reflect the influence of different types of delay on the real-time performance of the system, but also realize the inclined allocation of system resources to high-priority data through the priority adjustment mechanism, ensuring the real-time requirements of critical data. Through dynamic adjustment of the 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 further comprises:
[0077] S231, read the communication error rate e of each device from the pre-stored historical error rate data; classify and count according to error types (timeout, CRC error, data error, etc.); calculate the occurrence frequency and time distribution characteristics of each type of error, and generate an error feature table F;
[0078] S232, read the error feature data from the error feature table F; extract the bandwidth consumption reference value b from the bandwidth consumption model; based on the error occurrence probability p and the retransmission number n, calculate the retransmission cost c of each error type: the retransmission cost c is equal to the single transmission cost ct multiplied by the average retransmission number n; construct the reliability constraint component in the multi-dimensional constraint model C according to the retransmission cost c, and generate a retransmission constraint table R;
[0079] S233, read the reliability constraint component from the retransmission constraint table R; establish a reliability evaluation model based on Markov chain; calculate the steady-state probability distribution of the system in 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 decay coefficient; Δt is the time interval.
[0081] Re-transmission cost C(i) = B_base·(1 + a·N_r(i))·(1 + b·P_f(i))·(1 + g·T_d(i)); wherein B_base is a basic transmission cost; N_r(i) is an average re-transmission number; P_f(i) is a failure probability; T_d(i) is an average re-transmission delay; a is a re-transmission influence factor; b is a failure influence factor; g is a delay influence factor.
[0082] Markov chain reliability evaluation method: state transition probability P(t+1) = P(t)·T( l, m); reliability index R(t) = P_s(t) / (P_s(t)+P_f(t)); wherein T( l, m) is a state transition matrix [[1-l, l], [m, 1-m]]; l is a failure rate; m is a recovery rate; P_s(t) is a normal state probability at t time; P_f(t) is a failure state probability at t time; P(t) is a state probability vector [P_s(t), P_f(t)] at t time.
[0083] The embodiment realizes accurate modeling and prediction of communication reliability by constructing a Markov chain-based reliability evaluation model. First, the fine classification and statistics of different types of communication errors are realized by establishing an error feature table; then the influence of different types of errors on system performance is accurately evaluated by quantitative calculation of re-transmission cost; finally, the dynamic description of system reliability state transition is realized by a Markov chain model. The embodiment not only considers the current error rate, but also reflects the dynamic characteristics of system reliability through state transition probability, making the reliability evaluation more accurate and predictive. In particular, by combining re-transmission cost with a bandwidth consumption model, the system can optimize the use of bandwidth resources while ensuring communication reliability.
[0084] As shown in FIG. 1, according to one aspect of the present application, step S3 further comprises: Figure 4
[0085] S31, read the correlation degree value between each data item from the data item correlation matrix; construct a weighted undirected graph by taking each data item as a vertex of the graph and taking the correlation degree value between the data items as the weight of the edge; and generate a data item correlation graph based on the edge weight relationship between the vertices in the weighted undirected graph;
[0086] S32, read the adjacency matrix from the data item correlation graph; read the bandwidth constraint threshold from the bandwidth consumption model; perform iterative calculation on the adjacency matrix by using an improved Kernighan-Lin algorithm to obtain a subgraph partition result that satisfies the bandwidth constraint threshold; and sort the subgraph partition result according to the size of the correlation degree 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 group 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, real-time constraint model and reliability model to perform weighted calculation to 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 group transmission order that minimizes the weighted objective function, and generate an optimal transmission strategy.
[0088] In an 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 inter-group edge weights; W_in(A) and W_in(B) are the sums of intra-group edge weights; W_max is the maximum edge weight; |V| is the number of vertices; α and β are balance coefficients; the 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; and X is group A or B.
[0089] The embodiment is based on the previously generated model and matrix, constructs a weighted undirected graph associated with data items, and realizes the generation of an optimal data item grouping and transmission strategy through a 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 the bandwidth constraint is realized through the improved Kernighan-Lin algorithm. By constructing the weighted undirected graph, the system can intuitively represent the association relationship between data items, and by determining the optimal subgraph number through the spectral clustering method, the rationality of the grouping result is ensured. The embodiment not only considers the association strength between data items, but also ensures the realizability of the grouping result through the bandwidth constraint threshold. The finally generated optimal transmission strategy realizes the overall optimization of bandwidth utilization, real-time performance and reliability through multi-objective optimization calculation.
[0090] According to an aspect of the present application, step S31 is further:
[0091] S311, read the association degree value between each pair of data items from the data item association matrix; based on the association degree value, map each data item to a vertex to construct a vertex set; based on the vertex set, calculate the initial connection relationship between vertices to generate a vertex mapping table;
[0092] S312, read the vertex connection relationship from the vertex mapping table; obtain the edge weight based on the vertex connection relationship and the correlation value; generate an influence factor of the edge weight based on the device identifier; combine the edge weight and the influence factor to calculate an actual edge weight, and generate an edge weight table;
[0093] S313, read data from the vertex mapping table and the edge weight table to construct an adjacency matrix; calculate the degree and connectivity of each vertex based on the adjacency matrix; and generate a graph structure feature table in combination with the degree and connectivity of the vertex;
[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 representing the association relationship of the data item.
[0095] The embodiment realizes the graph theory expression and analysis of the data item association relationship by constructing a weighted undirected graph structure. First, the accurate mapping of the data item to the vertex of the graph structure is realized by establishing the vertex mapping table; then, a more accurate edge weight evaluation system is constructed by considering the influence factor of the device identifier on the edge weight; and finally, the connectivity and weight distribution of the graph are comprehensively analyzed by establishing the graph structure feature table. The embodiment not only intuitively displays the association structure between the data items, but also more accurately reflects the association characteristics at the device level by introducing the influence factor. Through the analysis of the graph structure features, the system can better understand the topological relationship between the data items, and provide an important basis for subsequent grouping optimization.
[0096] According to one aspect of the present application, step S32 is further provided as follows:
[0097] S321, read the adjacency matrix and the weight matrix from the data item association graph; multiply each element in the adjacency matrix with the corresponding element of the weight matrix to generate a weighted adjacency matrix; calculate the degree matrix of the graph based on the weighted adjacency matrix to generate a graph feature matrix;
[0098] S322, extract the connection relationship between nodes from the graph feature matrix, and calculate the Laplacian matrix by using the spectral clustering method; perform eigenvalue decomposition on the Laplacian matrix to obtain eigenvalues and eigenvectors; determine the optimal subgraph number according to the eigenvalues to generate a clustering parameter table;
[0099] S323, based on the parameters in the clustering parameter table and the feature vector, clustering is performed using a 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 mobile node; a bandwidth constraint threshold is read from the bandwidth consumption model; if the gain value is positive and meets the bandwidth constraint threshold, node exchange is performed, and the process is repeated until no positive gain value can be obtained, and the optimized grouping is output; otherwise, the initial grouping is directly taken as the optimized grouping; based on the optimized grouping, a subgraph partition table is generated;
[0100] S324, the internal association degree value of each subgraph is extracted from the subgraph partition table and the data item association graph; based on the internal association degree value, the association degree score of the subgraph is calculated; according to the association degree score, the subgraphs are sorted in descending order to generate an optimal data item grouping set. The association degree score is equal to the weighted sum of the internal association degree value and the subgraph size.
[0101] In an embodiment of the present application, the normalized Laplacian matrix L = I - D -1 / 2 ·W·D -1 / 2 ; eigenvalue decomposition L = U·Λ·U T ; optimal subgraph number 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 ith eigenvalue; U is the eigenvector matrix; i ranges from 1 to n-1, n is the number of nodes, and Λ is the eigenvalue matrix.
[0102] The association degree score S(G) = (α·I_d(G) + β·E_d(G))·(1 - γ·V_d(G)); where I_d(G) is the average intra-group association degree; E_d(G) is the average inter-group association degree; V_d(G) is the intra-group association degree variance; α and β are weight coefficients and α + β = 1; γ is the variance penalty coefficient; G is the data item grouping to be evaluated.
[0103] The present embodiment realizes the optimal grouping of data items through the improved Kernighan-Lin algorithm and the spectral clustering method. First, the association strength information is introduced into the expression of the graph through the construction of the weighted adjacency matrix; then the optimal subgraph number is determined through the spectral clustering method, avoiding the subjectivity of manually determining the number of groupings; finally, the optimal partition under the condition of meeting the bandwidth constraint is realized through the improved Kernighan-Lin algorithm. The present embodiment not only considers the association strength between data items, but also ensures the realizability of the grouping result through bandwidth constraints. In particular, by introducing the concept of gain value, the system can avoid local optimization in the iterative optimization process and achieve better grouping effect.
[0104] According to an aspect of the present application, step S33 is further composed of:
[0105] S331, reading data item set information si of each group from the optimal data item group set; reading bandwidth weight α, real-time weight β and reliability weight γ from the pre-stored system weight parameters; calculating initial weighted score is of each group: the initial weighted score is equal to bandwidth weight α multiplied by bandwidth score bs plus real-time weight β multiplied by real-time score ts plus reliability weight γ multiplied by reliability score rs, generating group score table P;
[0106] S332, reading initial score is of each group from group score table P; substituting bandwidth consumption model B to calculate bandwidth evaluation value bv; substituting real-time constraint model L to calculate time delay evaluation value tv; substituting reliability model R to calculate reliability evaluation value rv; combining the three evaluation values to generate comprehensive evaluation table E;
[0107] S333, reading evaluation data from comprehensive evaluation table E; constructing multi-objective optimization function f(x); using improved genetic algorithm to iteratively optimize the objective function; updating population and verifying constraint conditions in each iteration; obtaining the group transmission order that minimizes the weighted objective function, generating optimal transmission strategy T.
[0108] The data structure of the system weight parameters 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 sum = 1.0.
[0109] In an embodiment of the present application, the improved genetic algorithm is specifically: fitness function F(x) = w1·(B_max-B(x)) / B_max + w2·(1-D(x) / D_max) + w3·R(x); where B(x) is the bandwidth occupation of scheme x; D(x) is the maximum time delay of scheme x; R(x) is the reliability index of scheme x; B_max is the upper limit of bandwidth; D_max is the allowed maximum time delay; w1, w2, w3 are weight coefficients and w1+w2+w3=1; the crossover operator uses local order crossover based on priority protection; the mutation operator uses adaptive probability p_m = p_base / (1+exp(ΔF / F_avg)), where p_base is the basic mutation probability, ΔF is the individual fitness change, and F_avg is the average fitness of the population.
[0110] The embodiment realizes global optimization of the grouping transmission sequence through a multi-objective optimization algorithm. First, the establishment of the grouping score table realizes the comprehensive evaluation of each grouping in the three dimensions of bandwidth, real-time performance and reliability. Then, by constructing a multi-objective optimization function, the evaluation values of the three dimensions are unified into an optimization framework. Finally, through an improved genetic algorithm, the transmission sequence optimization under multiple constraint conditions is realized. The embodiment not only considers the trade-off between multiple performance indicators, but also, through the evolutionary characteristics of the genetic algorithm, can find a better solution under complex constraint conditions. In particular, by verifying the constraint conditions in each iteration, the feasibility of the optimization result is ensured. By converting the discrete grouping decision problem into a continuous optimization problem, the solving efficiency is improved, and through the population evolution mechanism, the risk of falling into local optimum is avoided.
[0111] As shown in Figure 5 According to one aspect of the present application, step S4 further comprises:
[0112] S41, read the bandwidth utilization threshold, response time threshold and reliability threshold from the pre-stored performance indicator threshold; based on the optimal transmission strategy, real-time collect the bandwidth occupation rate, response delay and transmission success rate in the data transmission process; compare and calculate the bandwidth occupation rate, response delay and transmission success rate with the bandwidth utilization threshold, response time threshold and reliability threshold respectively, and generate performance evaluation results;
[0113] S42, read the performance deviation value from the performance evaluation results; read the adjustment step parameter from the pre-stored adjustment rule library; based on the performance deviation value and the adjustment step parameter, calculate the optimization parameter adjustment amount; apply the optimization parameter adjustment amount to the optimal transmission strategy to generate the adjusted transmission strategy;
[0114] S43, read the data transmission sequence and grouping information from the adjusted transmission strategy; execute data transmission according to the data transmission sequence and grouping information, record the data in the transmission process, including bandwidth occupation rate, response delay and transmission success rate, and obtain the record data; write the record data into the performance log to generate the execution result of data transmission.
[0115] The embodiment realizes dynamic adjustment and abnormal handling of the transmission strategy through a real-time monitoring and evaluation mechanism. A closed-loop performance monitoring and optimization system is established, and by comparing the real-time collected indicators such as bandwidth occupation rate, response delay and transmission success rate with the pre-set performance threshold, performance abnormalities are found in time. Based on the performance evaluation results, the system can dynamically calculate the adjustment amount of the optimization parameter to realize adaptive optimization of the transmission strategy. In particular, in the abnormal handling mechanism, by establishing error type classification and corresponding recovery process, the fault tolerance and reliability of the system are improved. At the same time, through the record and analysis of the performance log, data support is provided for subsequent optimization.
[0116] According to an aspect of the present application, step S41 is further comprising:
[0117] S411, reading bandwidth utilization threshold hb, response time threshold ht and reliability threshold hr from pre-stored performance index threshold H; establishing performance index collection point list cp; setting sampling time interval ti; initializing performance data buffer pool dp, and generating monitoring configuration table C;
[0118] S412, reading collection configuration from monitoring configuration table C; collecting bandwidth occupation rate rb in real time during data transmission process; recording sending time st and receiving time rt of data packet, and calculating response delay td; counting the number of transmission success and failure, and calculating transmission success rate sr; and writing collected performance index into real-time performance table R;
[0119] S413, reading performance data from real-time performance table R; calculating deviation db of bandwidth utilization rate and threshold hb, deviation dt of response delay and threshold ht, and deviation dr of transmission success rate and threshold hr; performing normalization processing on deviation values; and combining to generate performance evaluation result E.
[0120] The embodiment realizes real-time evaluation of data transmission process by establishing a complete performance monitoring system. Firstly, the systematic arrangement of performance index collection points is realized through the establishment of monitoring configuration table; then, dynamic tracking of key indexes such as bandwidth occupation rate, response delay and transmission success rate is realized through the maintenance of real-time performance table; finally, quantitative evaluation of system running state is realized through the generation of performance evaluation result. The embodiment not only can discover performance abnormalities in time, but also makes performance indexes of different dimensions comparable through normalization processing of deviation values. In particular, by setting reasonable sampling time interval, the real-time of monitoring is ensured, and system overhead caused by too frequent sampling is avoided.
[0121] According to an aspect of the present application, step S42 is further comprising:
[0122] S421, reading bandwidth occupation rate rb, response delay rt and transmission success rate rr from performance evaluation result E; reading bandwidth utilization threshold hb, response time threshold ht and reliability threshold hr from pre-stored performance index threshold H; calculating deviation values of each performance index: bandwidth deviation db is equal to the difference between bandwidth occupation rate rb and bandwidth utilization threshold hb, delay deviation dt is equal to the difference between response delay rt and response time threshold ht, and reliability deviation dr is equal to the difference between transmission success rate rr and reliability threshold hr; and combining each deviation value to generate performance deviation table D;
[0123] S422, read bandwidth weight a, real-time weight b and reliability weight g from pre-stored system weight parameter W; read each deviation value from performance deviation table D; calculate weighted comprehensive deviation value v, wherein the weighted comprehensive deviation value v is equal to bandwidth weight a multiplied by bandwidth deviation db plus real-time weight b multiplied by time delay deviation dt plus reliability weight g multiplied by reliability deviation dr; determine adjustment direction dir according to the positive and negative of weighted comprehensive deviation value v, and generate adjustment direction table R;
[0124] S423, read basic adjustment step k0 from pre-stored adjustment rule library K; read weighted comprehensive deviation value v from adjustment direction table R; calculate dynamic adjustment coefficient c according to the absolute size of deviation value v: when the deviation value is larger, the dynamic adjustment coefficient c is greater than 1, and when the deviation value is smaller, the dynamic adjustment coefficient c is less than 1; multiply the basic adjustment step k0 by the dynamic adjustment coefficient c to obtain the actual adjustment step k, and generate adjustment step table K;
[0125] S424, read actual adjustment step k and adjustment direction dir from adjustment step table K; calculate the adjustment amount D of the optimization parameter, wherein D is equal to actual adjustment step k multiplied by adjustment direction dir; read original transmission parameter from optimal transmission strategy T, apply adjustment amount D to original transmission parameter; verify the effectiveness of the adjusted parameter to ensure that the system constraint conditions are met, and generate adjusted transmission strategy T'.
[0126] The data structure of performance index 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: millisecond; reliability threshold hr: 32-bit floating point number, value range [0, 1].
[0127] The data structure of adjustment rule library K is {performance index i, adjustment step k, adjustment direction d, threshold range r}. Performance index i: 8-bit integer (1=bandwidth, 2=response time, 3=reliability); adjustment step 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 representing the minimum and maximum allowed values.
[0128] In an embodiment of the present application, the dynamic adjustment coefficient calculation method is: adjustment coefficient K(t) = K_base·(1+ α·ΔP(t) + β·∫ΔP(t)dt + γ·dΔP(t) / dt); wherein K_base is a basic adjustment coefficient; ΔP(t) is a performance index deviation; α, β, γ are PID adjustment parameters; the integral term ∫ΔP(t)dt adopts the cumulative deviation in a sliding time window W; the differential term dΔP(t) / dt adopts the deviation change rate of the last two sampling periods; 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 normalized deviations of bandwidth, delay, and reliability, respectively.
[0129] In another embodiment of the present application, the optimal 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 an initial adjustment coefficient; ΔP(t) is a performance deviation; α is a sensitivity coefficient; β is an integral adjustment coefficient; γ is a change rate adjustment coefficient; M is a change rate upper limit; sign() is a sign function.
[0130] The embodiment realizes adaptive optimization of the transmission strategy by establishing a dynamic strategy adjustment mechanism. Firstly, the accurate quantification of performance abnormalities is realized by establishing a performance deviation table; then the optimization direction of the strategy adjustment is determined by generating an adjustment direction table; and finally, the adaptive control of the adjustment step is realized by introducing a dynamic adjustment coefficient. The embodiment not only adjusts the transmission strategy in time according to the performance deviation, but also makes the adjustment process smoother and more stable by introducing the dynamic adjustment coefficient. In particular, the effectiveness verification of the adjustment parameters ensures that the adjusted strategy still satisfies the constraint conditions of the system.
[0131] According to an aspect of the present application, step S43 further comprises:
[0132] S431, reading data transmission order and grouping information from the adjusted transmission strategy T'; extracting device identifier d, starting address a, register length l, and function code f for each data group; assembling a request message header and a data area according to the MODBUS protocol specification; calculating and adding a CRC check code to generate a transmission message set M;
[0133] S432, reading each message from the transmission message set M; establishing a device communication connection, recording the connection time ct; sending a request message and starting a response timeout timer tt; receiving a response message and recording the response time rt; verifying the CRC check code and function code of the response message; parsing the response data and recording the transmission status st, generating a transmission status table S;
[0134] S433, reading each transmission status st from the transmission status table S; when a communication error occurs, recording the error type et, the error time et and the retry count rc; performing a preset error recovery process: reconnecting for connection errors, retransmitting for timeout errors, and checking for data errors; recording the recovery operation result or, generating an exception handling record E;
[0135] S434, reading the transmission data from the transmission status table S and the exception handling record E; calculating the bandwidth occupancy rate rb, the average response delay rt and the transmission success rate rr of each data group; recording the start time st, the end time et, the number of transmitted bytes tb and the retry count rc of the transmission process; writing all performance indicators and process data in chronological order into a performance log L; generating an execution result R according to the transmission completion status and data correctness.
[0136] The embodiment realizes reliable execution of data transmission through a systematic execution mechanism and an exception handling process. First, the standardized packaging of MODBUS messages is realized through the generation of a transmission message set; then, the accurate tracking of the communication process is realized through the maintenance of a transmission status table; finally, the systematic handling of various types of exceptions is realized through the establishment of an exception handling record. The 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 a performance log. In particular, the fault tolerance and stability of the system are improved through the classification and handling of different types of errors. The influence of abnormal conditions on the normal operation of the system is reduced through the establishment of a standardized error recovery process.
[0137] In another embodiment of the present application, the basic information contained in each data item includes a register address and a register number, and when multiple data items are read, all data item sets 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 a data set; X_n is a data item, A_n is a register address, and N_n is the number of data item registers.
[0138] The data items in the set X(n) are sorted in ascending order of register address using a quicksort algorithm 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')}; the set is imported into a dynamic programming algorithm to calculate the optimal transmission method, find the best data item combination, and read the holding register request and holding register response. The MODBUS data transmission process is in bytes, and the reading of the holding register data is taken 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 index for measuring the bandwidth occupation; a_j is the register address of the j data item, where a_j ≥ a_i, and 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, the X_1' data item requires 1 register, the X_2' data item requires 2 registers, and the data item address interval is 3. The transmission bandwidth T{X_1', X_2'} of the combination is: T{X_1', X_2'} = 8 + (5 + 2 × (2 + 3)) = 23; 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)). Assuming that the X_k' data item information is (a_k, n_k): the transmission bandwidth T{X_k'} of reading one X_k' data item is: T{X_k'} = 8 + (5 + 2(n_k + a_k - a_k)) = 8 + (5 + 2n_k); the transmission bandwidth of reading the T{X_i', X_j', X_k'} combination 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, compared with the transmission of a single X_k' data item, T{X_i', X_j', X_k'} has smaller bandwidth consumption. According to the calculation of ΔT and T{X_k'}, it can be obtained that:
[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, T{X_i',X_j',X_k'} is smaller than T{X_k'} bandwidth increment, and the judgment condition is transformed 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 item.
[0145] There is a set of data item combinations X(n)={(a_1',n_1' ),(a_2',n_2' ),...,(a_n',n_n' )},calculate the optimal bandwidth combination M of 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 the subscript i of M[i] is 0, that is, the starting data item of the current data item combination, the adjacent next data item M[i+1]=i, that is, X[i+1] data item and X[i] combination get data, have smaller bandwidth increment, and so on. As long as the result of analyzing the combination M is obtained, 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] Referring to the combination M=M1+M2+…+Mn, the data request message is sent according to the register address and the number of registers of each combination and the response message is obtained, and then the corresponding register value is extracted according to the offset address of each data item, so that the values of all data items can be obtained, and the transmission bandwidth consumed is minimum.
[0157] The embodiment reduces the time consumption of invalid bytes in the transmission process, improves the utilization rate of line bandwidth, and improves the response speed of user interface data request.
[0158] The application establishes a complete data item feature extraction system, considers multi-dimensional features such as device identification, register type, register address and length, realizes comprehensive representation of data features through construction of function code mapping table and address range table. Through the introduction of multi-time window access frequency analysis and exponential smoothing method, combined with the calculation of the stability of the access mode by 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 MODBUS message header length and CRC check length in detail, combined with the nonlinear bandwidth constraint function, the accurate modeling of bandwidth consumption is realized. Through the establishment of 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 abnormal processing procedure, different types of errors are classified and processed, and continuous optimization data support is provided through performance log recording. Through the establishment of a multi-dimensional performance monitoring system, the key indicators such as bandwidth occupancy rate, response delay and transmission success rate are tracked in real time, and the performance is quantitatively evaluated. In general, the application constructs a complete feature representation, constraint modeling, optimization decision and dynamic adjustment mechanism, realizes intelligent bandwidth optimization of MODBUS data transmission. Through the construction of multi-dimensional feature matrix and correlation matrix, comprehensive representation of data item features is realized; through the establishment of multi-dimensional constraint model, the unified optimization of bandwidth, real-time performance and reliability is realized; through the application of graph theory algorithm, the optimal grouping of data items is realized; through the closed-loop monitoring and adjustment mechanism, the dynamic optimization of the transmission strategy is realized. The application improves the efficiency and reliability of MODBUS data transmission, while ensuring the real-time requirement of important data.
[0159] The preferred embodiments of the present application are described in detail above, but the present application is not limited to the specific details of the above-described embodiments, and various equivalent transformations of the technical solutions of the present application can be made within the technical concept of the present application, and these equivalent transformations all belong to the protection scope of the present application.
Claims
1. A method for optimizing MODBUS data transmission bandwidth, characterized in that, The method comprises the following steps: S1, obtaining basic information of each device, performing feature analysis, and generating a data item feature matrix; according to this, a data item priority vector is calculated, and a data item association matrix is constructed; S2, based on the data item feature matrix, the data item priority vector, and pre-stored historical error rate data, a multi-dimensional constraint model is constructed, and a bandwidth consumption model, a real-time constraint model, and a reliability model are calculated; S3, based on the bandwidth consumption model, the real-time constraint model, the reliability model, and the data item association matrix, a weighted undirected graph is constructed, subgraph division and multi-objective optimization calculation are performed, and an optimal transmission strategy is generated; S4, based on the optimal transmission strategy and pre-stored performance index thresholds, a data transmission process is monitored, evaluated, and adjusted in real time, data transmission and abnormal processing are performed, an execution result and a performance log are generated; Step S2 is further: S21, based on the data item feature matrix, an initial bandwidth consumption value is calculated; in combination with pre-stored bandwidth constraint function parameters, a bandwidth constraint component in the multi-dimensional constraint model is generated; according to this, the initial bandwidth consumption value is normalized to generate the bandwidth consumption model; S22, in combination with the data item priority vector and the pre-stored maximum allowed delay threshold, a delay constraint function is constructed, and a real-time constraint component in the multi-dimensional constraint model is generated; In combination with the priority value, the real-time constraint model is constructed; S23, in combination with the pre-stored historical error rate data and the bandwidth consumption benchmark value extracted from the bandwidth consumption model, the retransmission cost is calculated, and the reliability constraint component in the multi-dimensional constraint model is constructed; Accordingly, a reliability evaluation function is constructed to generate the reliability model.
2. The method of claim 1, wherein, Step S1 is further: S11, read the basic information of each data item of each device, perform normalization processing, and obtain a data item feature matrix; S12, read the access frequency value and the timeliness requirement value of each data item, combine the data item feature matrix, calculate the priority score of each data item, and merge to generate a data item priority vector; S13, read the register address difference value between each pair of data items from the data item feature matrix, calculate to obtain an address difference matrix; read the priority difference value between each pair of data items from the data item priority vector, calculate to obtain a priority difference matrix; combine the address and priority difference matrices by weighting to generate a data item association matrix.
3. The method of claim 2, wherein, Step S3 is further: S31, read the association degree value between each data item from the data item association matrix, and construct a weighted undirected graph; based on the edge weight relationship between the vertices, a data item association graph is generated; S32, read the adjacency matrix from the data item association graph, combine the bandwidth consumption model for iterative calculation, and sort according to the association degree value to generate an optimal data item grouping set; S33, combine the optimal data item grouping set and the pre-stored bandwidth weight, real-time weight, and reliability weight, and substitute into the bandwidth consumption model, the real-time constraint model, and the reliability model for weighted calculation to construct a weighted objective function; Through iterative optimization calculation, the grouping transmission sequence that minimizes the weighted objective function is obtained, and the optimal transmission strategy is generated.
4. The method of claim 3, wherein, Step S4 is further: S41, based on the optimal transmission strategy, the bandwidth occupation rate, response time delay and transmission success rate in the data transmission process are collected in real time; the bandwidth utilization rate, response time and reliability threshold are compared and calculated to generate a performance evaluation result; S42, the performance deviation value is read from the performance evaluation result; the adjustment step parameter is combined to calculate the optimization parameter adjustment amount and applied to the optimal transmission strategy to generate an adjusted transmission strategy; S43, the data transmission sequence and grouping information are read from the adjusted transmission strategy, the data transmission is executed, the data in the transmission process is recorded, and the performance log is written to generate an execution result of the data transmission.
5. The method of claim 4, wherein, Step S11 is further: S111, read the basic information of each data item and write it into the data item information table according to the preset format; S112, read the register type of each data item from the data item information table, calculate the MODBUS function code and correspond to the corresponding data item, and generate an extended data item table combined with the data item information table; 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 sort according to the device identifier and register address to generate an ordered address table; S114, extract data from the ordered address table and the extended data item table to construct an initial feature matrix; Calculate the number of rows and features; normalize the register address and end address accordingly, and combine to generate a data item feature matrix.
6. The method of claim 4, wherein, Step S12 is further: S121, read the access frequency of each data item in different time windows, calculate the access frequency of at least three different time scales and weighted calculation, and generate a comprehensive access frequency value; S122, calculate the coefficient of variation of the comprehensive access frequency value, and judge the stability of the access mode accordingly, and combine the comprehensive access frequency value to generate an access mode table; S123, read the response time limit of each data item, classify the data items in the data item feature matrix, calculate the preliminary priority score combined with the access mode table, and generate an initial priority table; S124, read the preliminary priority score from the initial priority table, combine the access stability index in the access mode table to form the final priority score; Sort them according to the score from high to low to generate a data item priority vector.
7. The method of claim 4, wherein, Step S21 is further: S211, extract the start address, data item number and current address of each data group from the data item feature matrix; combine the pre-stored MODBUS message header length and CRC check length to generate a data group basic table; S212, based on the data group basic table, calculate the message basic overhead and data area length of each data group, and add them to get the initial bandwidth consumption value; S213, read the bandwidth constraint function parameters, combine the initial bandwidth consumption value to generate a bandwidth constraint table; calculate the actual bandwidth occupation rate of each data group; S214, normalize the initial bandwidth consumption value, combine the actual bandwidth occupation rate to construct a bandwidth constraint equation set; generate a standardized bandwidth consumption model.
8. The method of claim 4, wherein, Step S31 is further: S311, read the correlation degree value between each pair of data items from the data item correlation matrix, construct a vertex set, calculate the initial connection relationship between vertices, and generate a vertex mapping table; S312, read the vertex connection relationship from the vertex mapping table, and obtain the edge weight by combining the correlation degree value; Combine the edge weight influence factor generated by the device identifier to calculate the actual edge weight and generate an edge weight table; S313, read data from the vertex mapping table and the edge weight table to construct an adjacency matrix; Calculate the degree and connectivity of each vertex to generate a graph structure feature table; S314, extract data from the graph structure feature table and the adjacency matrix to construct a weighted undirected graph structure; Verify its connectivity and weight distribution, and output the data item association graph representing the data item association relationship.
9. The method of claim 4, wherein, Step S32 is further: S321, read the adjacency matrix and weight matrix from the data item association graph, multiply to get the weighted adjacency matrix; calculate the degree matrix of the graph according to this to generate a graph feature matrix; S322, extract the connection relationship between nodes from the graph feature matrix, calculate the Laplacian matrix and perform eigenvalue decomposition to obtain the eigenvalue and eigenvector; Determine the number of optimal subgraphs according to this to generate a clustering parameter table; S323, based on the parameters in the clustering parameter table and the eigenvector, calculate the internal and external connection degrees of each node 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, perform node exchange, repeat until no positive gain value can be obtained, and output the optimized grouping; otherwise, directly take the initial grouping as the optimized grouping; based on the optimized grouping, generate a subgraph division table; S324, extract the internal correlation degree value of each subgraph from the subgraph division table and the data item association graph, calculate the correlation degree score of the subgraph; sort the subgraphs in descending order according to this to generate an optimal data item grouping set.
Citation Information
Patent Citations
Bus transmission performance dynamic scheduling method and device
CN115378762A
Power grid structure chart-based power grid optimization method and device
CN118539432A