Simulation analysis of communication performance of PROFIBUS in single and multiple master mode

With the application of digital information technology and communication technology, industrial intelligence and integration also began to develop rapidly, and the importance of the research on bus communication in industrial control communication also increased. As the first international bus standard, PROFIBUS has been widely used in the field of industrial control; in recent years, it was mainly used to connect devices to the control layer and convert data through token transmission. Based on the understanding of the transmission mechanism of PROFIBUS fieldbus protocol, this article carries out a simulation study on its communication performance. Through analysis of the data link layer, changing the target token cycle time (high and low priority) and random setting each site message number, as well as the number of master station and slave station, how the main token latency and packet loss rate and efficiency of bus affect the change of performance parameters was observed. For multiple communication systems, the relationship between the address value on the main token ring and transport performance is found by experiments on the site address value on the main token ring and the target token cycle time value. Finally, the scheduling algorithm is applied to the communication scheduling of PROFIBUS fieldbus. The results confirm that the scheduling algorithm has better transmission efficiency than the traditional MAC media access protocol under the condition that the load rate does not exceed 100%, which makes up for the shortcomings of the original PROFIBUS bus system and makes the communication performance better.


Introduction
The distributed control system is gradually formed in the field of industrial control. From the initial development to the present, distributed control system has experienced five stages of development: start-up, maturity, openness, integration, and synthesis. 1 With the continuous expansion of industrial control system, the importance of system integration and the improvement of communication transmission efficiency is increasing. By by digital communication technologies, it can realize the convenient real-time observation of the field signal. At the same time, the application of fieldbus enables the smart devices to be directly added to the field devices, which greatly improves the convenience of equipment installation. Based on the fieldbus system, the field equipment can be connected together in two transmission lines, and the users can independently design and choose the modules for installation according to the requirements. PROFIBUS media access method is a deterministic media access control method. The media access method is a simplified token protocol. The protocol specifies that the node which holds the token has the right to transmit the message. In the control system configuration, the determined master stations together constitute the token ring network, and the token information is transmitted in two directions on the token ring network. Each site can detect messages sent by other sites during each transmission without conflicts, which is more suitable for real-time application environments. PROFIBUS is widely applied in the control field, including power, process control, environmental engineering, processing, and other industries. 2 Systematically in this article surrounding the main communication transmission process simulation transmission experiment, around the fieldbus communication message transmission relationship between the process parameters were analyzed, and through the packet loss rate, transmission efficiency, token waiting time realtime performance indexes provide the theoretical basis for the optimization improvement of system ''was changed into'' In this article, the communication transmission simulation experiments was carried out, and some important parameters affecting the message transmission,such as packet loss rate, transmission efficiency, token waiting time, were analyzed to provide the theoretical basis for the optimization improvement of system. The real-time communication simulation process designed for the data link layer provides the data and the theory of experience; it provides a certain theoretical basis for the practical engineering application of PROFIBUS field bus the field of industrial control. The conclusion of this article can be used by the practical engineering applicator or operator in the configuration and parameter setting of the bus control system.

PROFIBUS communication protocol
According to the number of master stations, PROFIBUS fieldbus control system can be divided into a single-master station communication system and multi-master station communication system. Token ring refers to a kind of transmission binding between master stations in a multi-master station system. The primary station on the ring carries out token transmission according to the address value of the primary station, while the primary station holding the token can carry out data transmission. In a single-master station and multi-slave station system, there is no token transmission, and data transmission is conducted between the master and slave stations according to the question and answer mechanism.

Protocol introduction
PROFIBUS fieldbus is a simplified token bus that integrates the advantages of bus and ring bus. PROFIBUS is a bus in the physical layer, and a ring in the data link layer, that is, a token type. 3 This integration mode enables the physical layer, that is, the field equipment, to increase or decrease at any time for convenient operation. In data transmission, the bandwidth is not limited.
The bus system adopts mixed-media access to achieve controlled media (MAC) access. 3 The PROFIBUS protocol in German standards stipulates that the information transmitted by each station is divided into two categories: high priority and low priority (including periodic information, aperiodic information, and management information). MAC is a simplified TT protocol for PROFIBUS fieldbus. Fieldbus nodes are divided into master and slave stations. 4 Only the master station node can receive the token, and all the master stations constitute a ring network to connect the master stations on the bus. The master station on the token ring network transfers tokens according to the size of the address value.
A significant feature of PROFIBUS's simplified token protocol is that it does not limit bandwidth, that is, it does not guarantee the allocation of fixed time for transmission information. 5 When the token is initialized, each master station on the token ring is assigned an address, and the next state of the token ring depends on the address value of the primary station. According to the size of the set target token cycle time value, the token carries out the polling transfer operation between each primary station according to the link table of the primary station. The master station holding the token can transmit the master and slave station information. Messages transmitted are classified according to their high and low priority, and messages of the same priority are processed on a first-in-first-out basis. The MAC media transmission mechanism can briefly describe the node with the smallest address of the primary station and create a token after power on, which is passed from a primary station to the next station. 6 The token receiver has the right to transmit the message within the specified token holding time. The node with the token will transmit the token to the next station in the link table of the primary station after transmitting the message.
There are three main parameters in the PROFIBUS performance analysis. The first is the target token cycle time T TR , which refers to the time between the receipt of the token from the current master station and the arrival of the next token at that master station. The second is the actual token cycle time T RR . It refers to the polling process dealing with token rotation time for each field node. The third is that the difference between the first two is called the master token holding time T TH . during the target token cycle time, each node for data transmission in address value size order, receive priority transmission high-priority token site data, data transmission a high priority, if T TR . T RR , namely T TR . 0, continued to transfer the node under a highpriority information (if any) the node, after transfer the node all high-priority information, found that there are still, the lower priority information transmission, the transmission principle of detailed Figure 1 flow diagram is shown in the diagram below. Since the duration of token time is calculated before the information transmission, as long as the transmission of information begins, the transmission must be completed, even if in the transmission process, it will occur phenomenon that token cycle time is equal to 0, this situation is called time overflow. This can lead to confusion or delay. So the bus access mechanism has a direct effect on the delay of network transmission.

Experimental parameters
At the time of programming, the parameter names are defined as in Table 1.

Communication performance evaluation index
1. Target token cycle time T TR : in the total polling, the set token rotation time is the target time from the arrival of the command card to the arrival of the next token at the site. 2. Node waiting time T i W : i is the site address value, when data are transmitted, the waiting time for the node to transmit the message from the station. 3. Packet loss rate T i M : the efficiency of each node sending high-priority messages and low-priority messages. That is, the ratio of successfully transmitted messages to the total number of messages to be transmitted. The calculation formula is shown in formula (1) below.
Note: S i t -total number of packets to be sent by -i station. S i r -the total number of packets actually sent by station I (experimental measurement) 4. Bus transmission efficiency T L : the percentage of the ratio between the total number of transmitted packets and the total number of packets in a single token polling cycle. The calculation formula is shown in formula (2) below.  where M iL and N iL refer to the total number of high and low-priority messages, respectively, completed by all slave stations when the polling cycle is L.

Single-master and multiple-slave communication model
A typical PROFIBUS DP system with a single-master station is mainly controlled by a programmable logic controller or a single host (central controller).
According to the token-type transmission mechanism of PROFIBUS bus, since tokens are only transmitted between master stations when the system works, there is no token transmission in the single-master station system, and only the master-slave transmission mechanism is studied. During the cycle time of a single target token, the master station USES the network to send a query frame to the slave station, and the slave station answers. In the communication process, the transmission efficiency is determined according to the number of messages on the node and the transmission mechanism. Different loads and different target token cycle time Settings have a certain impact on transmission performance.
The construction of simulation model. Based on the VS2010, communication simulation process is divided into three parts: data acquisition, data transmission and data result processing. In the actual system, the transmitted data is mainly sent to the site from the controller of the upper level, and the number of messages received by the site or the detector can detect the data in real time. 7 There is some uncertainty in the field data.
In order to better match the actual bus communication in the simulation process, random functions are used in the data input module to generate random data in each polling calculation. Performance is characterized by the message length of each station with no memory and random arrival. Here, the random function is selected and the seed number is set to perform the random simulation, controlling the random number to meet the probabilistic events in the specific region and ensuring sufficient randomness.
The core protocol transmission mechanism code is as follows v2.push_back(t);// } Experimental analysis. From the experimental simulation, input/output data and the simulation of the actual number of message transmission to calculate the packet loss rate,the average packet loss rate in 20 polling cycles for the single-node, according to the type . The diagram was shown as Figure 3.
With the increase of the target token cycle time, the packet loss rate of node transmission presents a decreasing trend in a large range. According to the different polling tasks of each node in actual field engineering, the efficiency of node message transmission will have a non-linear change. Within the allowable range of data error, according to the variation range of Figure 4 curve, it can be concluded that the packet loss rate of bus communication is inversely related to the size of the target token cycle time. With the increase of the target token cycle time, the number of packets that can be transmitted by each station increases, and the packet loss rate decreases accordingly. However, if the target token cycle time is too large, the transmission efficiency may decrease. Therefore, setting the target token cycle time correctly is the key problem in the circular transmission.
As can be seen from Figure 4, the bus access efficiency increases with the increase of the target token cycle time. Within a certain range, the two are in a positive linear relationship. As the target token cycle time increases, the token wait time for each node and the data transferred amount for each node increase. When the target token cycle time is large enough to complete the full transmission of periodic data and non-periodic data of each node, all messages of the node can be transmitted, but in this case the waiting time of the node is long and the communication timeliness is low.
As can be seen from Figure 5, as the number of slave stations increases, the load data increases, or the packet cycle becomes longer, the packet loss rate increases gradually in a large range during single-cycle polling. This is also a phenomenon of increasing message transmission delay, because in practical engineering applications, reasonable load should be carried, so that the transmission efficiency and packet loss rate can be within a reasonable range.

Multi-master fashion
In PROFIBUS bus control system, each node carries out data transmission and command transmission through the bus as shown in Figure 2. In order to ensure the reliability and timeliness of transmission, the communication between sender task generation and receiver task acceptance and application task is timeconstrained. Different conditions were applied to the message to be transmitted conditions in the process of the whole transmission delay, in a polling total time delay is called measurement period, 8 also some scholars abroad as end to end communication time delay, 9 specifically refers to the master-slave site a switching cycle, data transmission, and control cycle is mainly produced by information delay, packet queuing delay, data transmission delay, send delay composition as shown in Figure 6. 10-12 1. Information delay: the time for the sending task node to generate the application task and add the task to the transmission queue is mainly affected by the performance of the sending end. 2. Message queuing delay: after a message arrives on the queue, it waits for the arrival of the token and is processed. This delay is mainly affected by the information transmission mechanism and load size. 3. Data transmission delay: the time taken from the sender to the receiver to transmit the message, which is mainly affected by the communication rate and the length of message frames, that is, the single message transmission cycle. 4. Transmission delay: the time consumed by data processing and forwarding, mainly refers to the time occupied by message decoding and reassembly.    Table 2.
According to the above results, the cyclic relationship between node token waiting time and target token is drawn, as shown in Figure 7 below.
As can be seen from Figure 7, in the case of fixed address value, with the increase of the target token cycle time, the waiting time of single-node token gradually increases. When the target token rotation time increases to a certain extent, the waiting time of node token remains unchanged within a small range.   In order to observe the rule more intuitively, experiments were carried out to calculate the average waiting time of each node token, which is represented in Figure 9.
As can be seen from Figure 9, the token ring network's intermediate site token wait time is shorter with the same load rate.

PROFIBUS communication performance optimization
PROFIBUS fieldbus is a typical real-time system. [13][14][15] As for industrial network communication, real-time mechanism does not mean only high speed. It means that messages can be transmitted before their deadline, which is reflected in the boundedness of periodic information transmission. It can be seen from the simulation model in the previous section that the station message priority can only be high or low. High-priority message refers to those more particularly high real-time performance of safety management related message, in the practical engineering application, the quantity is small low-priority message is much and no class distinctions, Whether it can be transmission or not is entirely determined by the time the    master station holds the token completely. 16,17 For complex multi-master station systems, the control performance of different controllers is different and the target token cycle time set by manufacturers is also different. When constructing a multi-master station for configuration, it becomes more difficult to set the target token cycle time.
If it is so small, only high-priority messages can be transmitted, while low-priority messages cannot be sent or even lost, which affects the real-time performance of system communication. If it is so large, the overall transmission efficiency of the system will be lower. 11,18 The simulation results in section 3 also verify this point. Faced with the above problems, it is necessary to improve the scheduling method of priority of PROFIBUS communication system information, so as to improve the real-time performance of PROFIBUS fieldbus.

Communication simulation based on scheduling algorithm
This article combines the earliest information scheduling algorithm (EDF scheduling algorithm) to improve the communication and transmission process of PROFIBUS fieldbus.
EDF scheduling algorithm rules. EDF scheduling algorithm is also known as the earliest deadline information scheduling algorithm. 11 It is an algorithm to determine the priority order according to the deadline of the transmission task. The deadline is the maximum time from which a message can be effectively executed. [19][20][21] Absolute deadline is the difference between the time a message is sent and the maximum time it can be effectively responded to. In a single queue, the message transmission sequence is sorted by the response deadline time of each arrival message. In each transmission, the message with the earliest deadline date is allowed to work first to ensure the real-time performance of bus transmission to the greatest extent. 22 In the EDF scheduling algorithm, the priority definition assignment of message transmission is defined as where d i (t) is the deadline for task i at time t.
PROFIBUS simulation model based on EDF algorithm. In order to ensure the real-time performance of PROFIBUS communication, messages in PROFIBUS control system are classified according to the real-time performance. 23,24 During transmission, messages transmitted by PROFI BUS are divided into the following three types: 1. Strong high-priority message: It mainly refers to high-priority message under MAC mechanism. It refers to the system to ensure the safe operation of information security instructions. It is characterized by strong real-time performance and no delay is allowed. Once the delay occurs, the system will be harmed greatly. 2. High-priority message: It mainly refers to the message with earlier message deadline date and shorter message transmission cycle. It is characterized by strong real-time performance, small allowable delay range, and significant impact on system communication performance. 3. Low-priority message: It mainly refers to messages such as information management and command report, which mainly refers to messages that arrive late in the deadline. The characteristic is that there is no real-time delay is allowed, and the delay will not affect the communication performance of the system.

Experimental analysis
In the simulation dealing with two-dimensional array simulation high and low-priority message arrived, the first column of the array represents the message transmission time and the second column represents an array of the message transmission deadline queue. On the basis of the second column in the array, relative deadline decided the size of the message queue within the message priority sorting. Because EDF scheduling algorithm is mainly used to improve the low-priority message efficiency, a low-priority message queue should be considered as shown in Figure 10. The arrival message data conforms to the form of one-dimensional array. M stands for the high-priority message queue, while N stands for the low-priority message queue. The data distribution is shown in Table 3. The number of master stations is 5, the first column of values in N represents the cycle of message transmission of each node, and the second column of values in N represents the deadline of low-priority queues at each station in milliseconds. The ''-'' symbol indicates that the corresponding message has no deadline date, that is, the point is considered as non-real-time message information, and the transmission time is allowed to be much later than the message information with an absolute deadline date. In practical engineering applications, the message transmission cycle is always less than the deadline date. If the message transmission cycle is greater than the absolute cut-off date, the message transmission error will occur and the transmission cannot be completed. The static scheduling algorithm under MAC is to carry out data response according to the frame command of random response. In simulation, the scheduling order of data transmission is simulated with the randomly generated message sequence. In the EDF scheduling algorithm, the transmission rule is determined according to the size of the deadline, and the transmission with a small absolute deadline is the first.
Based on the EDF scheduling algorithm, when the target token cycle time = 20, the real-time performance and transmission efficiency are calculated after polling for 10 cycles. The bus transmission efficiency based on the two scheduling algorithms is plotted in Figure 11.
According to the simulation results and the random packet transmission cycle (about 40 ms) combined with the target token cycle time (20 ms) ratio, it can be concluded that the simulation results under the load factor is equal to about 200%, the two curves in the figure of the contrast trend can be seen that under the condition Figure 10. Flowchart of data transfer mechanism of PROFIBUS bus based on EDF scheduling algorithm.  2  3  1  7  2  3  2  5  2  -1  8  1  -2  4  1  8  1  7  2  -2  8  2  6  1  4  1  8  1  7  1  6  2  -2  4  2  3  2  6  2  5  1  7  2  -2  4 of the load factor is bigger, the transmission efficiency of the two basic consistent.
In order to better analyze the advantages and disadvantages of the EDF scheduling algorithm and the traditional scheduling algorithm, the load rate was changed for several experiments to observe the success rate of message transmission. In order to visually see the performance, the comparison results were plotted in Figure 12.
As it can be seen from Figure 12, when the load rate is small, it is reflected in the target token cycle time setting; that is, the target token cycle time setting is relatively large, which is large enough to complete all message transmission, and the bus transmission efficiency of EDF scheduling algorithm is basically consistent with the original scheduling algorithm, as shown in Figure 12 (d). When the load is moderate, that is, the target token cycle time can complete partial lowpriority message transmission, the EDF scheduling algorithm has a better transmission rate than the original scheduling algorithm, as shown in Figures 12 (b) and (c). When the load rate is large, the target token cycle time is small and only a few low-priority messages can be transmitted, as shown in Figure 12 (a). At this point, the transmission efficiency of the two is similar, but the EDF scheduling algorithm can ensure the transmission of messages with strong real-time performance, so that the success rate of message transmission is improved to some extent.

Conclusion
In the field bus industrial control system, there is an important bridge between the management layer and the application layer. As a field bus with broad application background, the communication performance of PROFIBUS is the core evaluation index when it is applied.
The communication mechanism of bus is the most basic research objective of the bus. This article studies the communication performance of PROFIBUS fieldbus from both vertical and horizontal perspectives. The research model used intelligent programming software to analyze its transmission mechanism to get rid of the hardware redundancy of the traditional devices. The single-master slave station and multi-master slave station were modeled and the indexes were analyzed. The experimental results provide theoretical support for engineering practice.

Declaration of conflicting interests
The author(s) declared no potential conflicts of interest with respect to the research, authorship, and/or publication of this article.

Funding
The author(s) received no financial support for the research, authorship, and/or publication of this article.