A FlexRay Dynamic Segment Message Scheduling Optimization Algorithm*

. In this paper, we present a new heuristic scheduling algorithm basing on DM algorithm, which makes up for the deficiency of the currently very little collaborative design of FlexRay dynamic segment scheduling method with the worst response time and bus utilization. The algorithm improves the comprehensive efficiency of message worst-case response time and uses bus utilization as the optimization target, and the best FID allocation scheme is obtained. The MATLAB simulation experiment of the scheduling scheme obtained good simulation results.


Introduction
As cars become more intelligent, automated, electronic, and green, the number of electronic control units (ECUs) and the number of signals that need to be transmitted within the car increases rapidly. The number of ECUs included in some high-end luxury cars already has exceeded 100 [1] and the number of signals transmitted inside the car has reached more than 2,500 [2][3]. Traditional CAN, LIN and other automotive buses, due to their inherent limitations, cannot meet the communication needs of future cars. FlexRay is well adapted to the future internal communication needs of cars due to its high bandwidth, high reliability and high fault tolerance [4][5]. In the automotive industry, FlexRay is the nextgeneration automotive bus standard for critical signal communications such as x-by-wire control systems.
The FlexRay dynamic segment uses a flexible time division multiple access (FTDMA) media access mechanism, which enhances bus communication flexibility [6], but also increases the difficulty and complexity of dynamic segment message scheduling. At present, the research of FlexRay dynamic segment is mostly aimed at improving bus utilization or reducing the worst response time of messages. It is used as a constraint to optimize the dynamic segment length and communication cycle length and parameter configuration. Based on the above research, this paper proposes a heuristic scheduling optimization algorithm that takes into account the bus utilization and worst response time.

Message bus utilization model
We assume that the FlexRay communication cycle length is composed of several Macroticks (MTs). The length of a MT is 1us. The number of the minimum dynamic slots is Nms (2 or more, less than or equal to 7988) [7], and the length is tms (2MT). Then the dynamic segment length TDS is: Assuming that the FlexRay static segment length TSS is known to be and remains constant, but the communication cycle TBUS varies with the length of TDS. To simplify the problem, assuming that the length of the communication cycle is known, the length of the dynamic segment is also determined. The paper supposes there are qth (q > 0) messages of K double bytes, and then the dynamic slot length q ms T is: When the bandwidth is 10M, the length of time for transmitting of one bit of data is equal to 0.1us; TAOP takes 1us; DTS takes 0.4us. This paper assumes that each dynamic segment occupies one dynamic slot, a total of Nms, and its dynamic segment bus utilization UBUS is: When the dynamic segment length is determined, the worst response time of the dynamic segment message is affected by the FID allocation method. This paper assumes that the worst response time of the qth message m with k bytes during the t period is as follows: Wherein, the maximum delay m  generated during the generation period just to miss the corresponding dynamic time slot [6]; the maximum delay ( ) t e m of the entire period caused by the same ID high priority message in the node and the low ID message in the bus cycle; last T is the longest time that a low ID message is sent first by the massage during the transmission period; m C is transmission delay for message m; in literature [7], TD T is the message generation delay and RD T is the message reception delay, which is a total of 0.2 s  .
To satisfy the overall schedulability of the message, it can also be sent out within the deadline within the worst response time. The deadline for satisfying the message should not be less than the worst response time, namely: The overall worst response time ( ) t R m of dynamic segment is:

Class DM heuristic scheduling algorithm
This paper assumes that the messages transmitted in the FlexRay dynamic segment: 1) all messages are aperiodic messages, and independent of each other; 2) all messages have a fixed length, and the length and other parameters are known [8]. The length of the communication cycle is known.
When dynamic segment length and message length are known, the assignment of frame ID and message priority is a decisive factor that affects the response time of dynamic segment message and network utilization of dynamic segment. The optimization algorithm aims at the overall efficiency  of maximum network utilization and minimum response time. The larger  value, the smaller the network utilization and the longer the overall response time, the following formula can be used for calculation : In the entire algorithm model, the initial FID allocation for each node is based on the DM-like algorithm q m ED . The longer the message deadline is, the shorter the message length is, the value of q m ED is the larger and the larger value is allocated FID, which represents the less urgent message and the lower message priority. It can be calculated using the following formula: In the loop optimization of the entire algorithm model, the  q m ED is used for FID allocation. The longer response time of message, the shorter deadline, and the higher bus occupancy rate represents the higher urgency of the message. The larger  q m ED value allocates the smaller FID. It can be calculated using the following formula: The comprehensive efficiency value of each calculation is compared with the previous one. If it is smaller than the previous one,the new value will be saved, otherwise it will not be saved, and will enter the next cycle. Then, the execution is repeated until the difference between two adjacent values dose not exceed the error value 10-10 after 5 consecutive times. The loop ends and the optimization result is output. The entire algorithm flow chart is shown in Figure 1.  In the MATLAB simulation experiment, the FlexRay dynamic segment message data in [6] is shown in Table 1. And with reference to its setting, the dynamic segment length is 1600 s  and the static segment length is 2000 s  .  When the FlexRay bus bandwidth is 2.5M and 10M respectively, the optimized frame ID allocation result of this algorithm is shown in Table 2. The experimental results show that the frame ID allocation results are not identical at different rates, and the message communication performance indicators will change.  Compared with the bus utilization in [6], Table 3 shows that the bus utilization increases by 26.67% and 36.76% respectively when the bandwidth is 2.5M and 10M, and the effectiveness of the dynamic segment scheduling optimization algorithm proposed in this paper is obtained. When the bandwidth is 2.5M, the comparison between the worst response time in this paper and [6] and the comparison table of comprehensive efficiency calculated according to formula (7) are shown in Table 4, decreasing by 50.25% and 60.37% respectively. When the bus bandwidth is 2.5M and 10M respectively, the overall efficiency of the algorithm is shown in Figure 2 and Figure 3.  The deficiencies of the literature [6] algorithm model: 1) based on the least common multiple of the dynamic segment message to calculate the worst response time, and non-periodic message to do the cyclical, which may increase the message corresponding time; 2) the worstcase response time and the coefficient of bus utilization in the optimization objective function established in Part 4 are selected, and there is uncertainty, which may make the optimization result into local optimization. In this paper, under the condition that the communication cycle and the dynamic segment length are known. The comprehensive influence of the different allocation of frame ID on the worst response time of the message and the bus utilization is studied. A specific mathematical module is given, and no uncertain parameters are selected. However, compared with the literature [6], the optimization of the dynamic segment length is not sufficient.

Conclusion
In this paper, from the perspective of comprehensive bus utilization and worst response time, the FlexRay dynamic segment message frame ID allocation optimization algorithm is designed on the basis of the calculation method of bus utilization and worst response time. The optimization algorithm is a DM-like heuristic scheduling algorithm, which not only considers the deadline of the message and the worst response time, but also includes the bus utilization and the message length. Through simulation verification, the comprehensive efficiency results that the proposed algorithm can improve bus utilization and reduce the worst response time.