## 4 Frame ID Reusing  
After signal packing, we can get the best length of payload and the best network utilization. Based on this, a schedule of frame ID (FID) reusing is constructed. The reuse of FID is important to scheduling strategy, making the schedule to occupy the least slots under the requirements of real-time system, so as to retain as much free slots. As well as, when new nodes and new frames are added for scaling, not only the flexibility of the static schedule be improved, but also the network resources are saved as much as possible. Scheduling for frames of FlexRay network is shown in Figure 4.  
Figure 3: Frame packing flow chart. As shown in Figure 4, the repetition of message \(m_{0},m_{3},m_{4},m_{5}\) is 2, the repetition \(r_{m}\) of message \(m_{1}\) is 4, the repetition of message is determined by sending periodic \(p_{m}\) and communication cycle \(T_{bus}\). \[r_{m}=\frac{p_{m}}{T_{bus}} \tag{11}\]  
The period when message \(m\) is sent on the bus for the first time is called basic cycle, which can be represented in Figure 4 by the y-offset of the y-axis. So, the base cycle of message \(m_{0},m_{3},m_{4}\) is 1, the base cycle of message \(m_{1}\) is 3, and the base cycle of message \(m_{5}\) is 0. The basic cycle constraints are as follow. \[bc_{m}<r_{m} \tag{12}\]  
The relationship between basic cycle \(bc_{m}\) and repetition rate \(r_{m}\) is shown in Equation (13), \(N_{c}\) is the period for sending the current message. Where, \(bc_{m}\in\{0,1,\cdots,63\}\), \(r_{m}\in\{1,2,4,5,8,10,16,20,32,40,50,64\}\). \[N_{c}modr_{m}=bc_{m} \tag{13}\]  
The offset \(x_{m}\) is the location in the slot where message \(m\) was sent, which can be represented in Figure 4 by the x-offset of the x-axis. Such as the offset of message \(m_{4}\) is 4, the range of the offset is as shown in Equation (14). Where \(l_{s}\) is the size of static slot, \(l_{m}\) is the size of message. \[0<x_{m}\leq l_{s}-l_{m} \tag{14}\]  
For a set of packaged messages \(M\), the messages are sorted according to the following rules to ensure that the messages are closely arranged in the schedule and do not intersect each other. (1) The message having the smaller repetition rate will be sent more frequently. So, the message with a smaller repetition rate is arranged transmitting first. For the larger repetition rate of messages, it can be arranged flexibly because of they occupied fewer cycles. Thus, the remaining cycles are used to put them. Therefore, for message of each node, it should be arranged in the ascending order according to the repetition rate of packed messages. \[ \begin{array}{l}\forall m\in M,a,b\in K,a\
eq b,\\ r_{m_{a}}\leq r_{m_{b}},\ 0\leq a\leq b\leq k\end{array}  \tag{15}\]  
Figure 4: Frame schedule for FlexRay. (2) For messages with the same repetition, be sure to place the larger message at first, and fill the remaining payload in that slot with the smaller message. Therefore, messages in each node with the same repetition rate should be arranged in the decreasing order of its length. \[ \begin{split}\forall m\in M,a,b\in K,a\
eq b,\\ r_{m_{a}}=r_{m_{b}},l_{m_{a}}\geq l_{m_{b}},\ 0\leq a\leq b\leq k \end{split}  \tag{16}\]  
(3) They should not intersect for all repeated message in the schedule arrangement. Even if messages \(m\) and \(m^{\prime}\) have the same slot, the schedule does not intersect because of their different cycles. \[\forall i,j\in N_{o}:\ (b_{m}+r_{m}\times i)\text{mod}N_{c}\
eq(b_{m^{\prime}}+r_ {m^{\prime}}\times j)\text{mod}N_{c} \tag{17}\]  
All messages are sorted in ascending order by repetition rate as shown in Table 2, the repetition of \(m_{2}\) is same as \(m_{3}\) and \(m_{4}\), sort in descending order of payload size. When the message frame is assigned to the schedule, it is allocated from the low period. The communication cycle of FlexRay is 0-63. Because the frame is sent repeatedly according to the period, the sampling cycle \(T_{sp}\) is the super period of frames. In the case of message sent form nodes in Table 2, only 0-7 cycle needs to be considered.