# Response Time Analysis for Nonperiodic CAN Message Based on GI/G/1 Queue Model

Authors: Fei Meng; Ying Zhu; Zhenzhong Chu
Journal: Mathematical Problems in Engineering
 (2021)

---

## Abstract

Controller area network (CAN) has wide applications in modern industrial control systems. Automobile manufacturers use this communication protocol for vehicle control, which is subject to real-time and high-reliability performance. However, with the increasing actuators gathered in the vehicle, time delay will lead to a serious problem for the vehicle safety and performance control. Thus, the information transmission stability of the CAN message needs to be investigated. In order to find out the delay response time of nonperiodic CAN message in the vehicle bus area, the response of the message transmitted in the CAN bus is modeled based on the GI/G/1 queue theory. The test platform is developed to verify the methodology. In the experimental test, some conditions with different IDs, load ratios, and priorities are investigated. Experimental results are compared with the theoretical results, and the simulation results show that the method is valid and verify the real response delay time of nonperiodic CAN message.


---

## Body

## 1. Introduction

With the rapid development of the vehicle technology, vehicles are developed as a transportation facility and become more convenient for people. More and more functions are developed for comfort, accessibility, and practicality compared with the past. In order to meet the comfortable and reliability demands of passengers, modern technology has integrated entertainment equipment, personal communication electronic device, wireless connection, and other functions into one car. All these components connected to the network system achieve their function through the electronic control units (ECUs); with the increasing demand for cars, the number of ECUs is growing. There may be more than 100 ECUs to provide all the electronic functions in high-end vehicles [1–3]. Since the information is exchanged through those ECUs with the interconnected data buses, it is necessary to optimize the communication network to reduce the cost and improve the performance.Controller area network [4–6] is designed as a microcontroller in the automotive industry and has become a global standard. Now CAN has been well extensively used in other areas due to its high real-time properties and low cost, such as industrial automation, aircraft industry, industrial control, safety protection, and other fields. No matter in which field, the real-time analysis of CAN bus is still the research; see [7–9] and the references therein. In [2], Sato and Fukumoto analyzed the response time of CAN with randomly occurring messages based on M/G/1 queuing theory. Lim et al. [10] investigated the signal distortion in a controller area network with flexible data rate, and the presented model-based analysis can closely approximate the size and time response of ringing and the extent of bit time distortion. Mubeen et al. [11] analyzed periodic, sporadic, and mixed transmission of messages in CAN with implementation of priority queues and FIFO queues.However, for the general CAN bus network communication, due to the message triggered randomly, the real-time property is also related to the random sending messages. In this paper, the nonperiodic CAN bus communication is investigated. Based on the queue theory GI/G/1 and the bit-stuffing mechanism, the delay time can be read clearly at different ratios.The rest of this paper is organized as follows. Section2 mainly describes the basics of CAN bus and mathematical queue GI/G/1 model. Section 3 presents the delay model of nonperiodic CAN message which is composed of queue theory about the waiting time and bit-stuffing mechanism about the transmission time. The experimental platform is set up in Section 4. In Section 5, the analysis work about the data compared with the experimental theory is developed. Finally, Section 6 concludes the paper.


## 2. Theoretical Analysis

CAN is a multimaster serial communication bus, and it is designed not only with high bit rate and high antielectromagnetic interference but also detecting any occurring error. The CAN communication protocol mainly described the ways of information communication between different devices. With the CAN layer and the definition of the open systems interconnection (OSI), all devices can communicate with the same layer. Real communication can be implemented on every equipment between two layers, and information was only interconnected by physical media. Usually, the specification of CAN defines the bottom transmission via two layers: the data link layer and physical layer. CAN communication could use a variety of physical media, such as twisted-pair cable and optical fiber. The most commonly used is twisted-pair wiring. Signals using a differential voltage and two signal lines are referred to as CAN_H and CAN_L, the static voltage is about 2.5 V, the state is expressed as logic 1, which can also be called a Recessive, and CAN_H is higher than CAN_L, which can be presented as logic 0, known as the “dominant”; thus, CAN_H equals 3.5 V and CAN_L becomes 1.5 V.The delay of CAN communication can be divided into four parts: generation delay, queuing delay, transmission delay, and delivery delay [12]. The generation delay refers to the time from receiving the request of sending message from the sending node processor to writing the message data into the cache queue; queuing delay refers to the time from the message frame entering the sending buffer queue to the time when the message frame occupies the bus; the transmission delay refers to the time from the message occupying the bus to leaving the bus; delivery delay refers to the time when a message departs from the bus to the receiving node receiving data and providing it to the target processor. Generally, the generation delay and the delivery delay are generally related to the characteristics of the hardware electrical equipment, and the delay time is small. Therefore, once considering the CAN communication delay, the queuing delay and the transmission delay are considered. This paper mainly discusses these two parts of the CAN delay.


### 2.1. Transmission Mechanism of CAN Bus

Data in CAN bus is divided into two types: one is the standard frame, and the other is extended frames. The main difference between these is the length of identifier ID. The schematic diagram of the standard frames is shown in Figure1.Figure 1
Standard format of CAN data frame.The main difference of two CAN types between standard frame and extended frame is the length of message. The standard frame has an 11-bit identifier and the extended one has 29-bit identifier. The identifier must be unique, which means that the message derived from different sources must have different identifiers.Once the bus is at least 6 recessive bits, it is called idle, and all nodes join in the bus with pending messages ready to transmit from the identifier field. According to the arbitration mechanism, a node will not transmit a message if it sent a recessive bit, and the bus level is dominant. Only when the node level is the same as the bus level through whole ID field will the node be allowed to transmit messages. That means the message ID is used for the arbitration mechanism: the smaller the ID, the higher the priority. Thus, the identifier has two purposes: (1) the priority of the frame and (2) making the receivers able to filter frames. It should be noted that the data transmit in the bus will only have 0∼8 bytes and each byte of message occupies 8 bits in data field, and the data field has 0∼64 bits. For more details about other fields in the frame, the reader is referred to [2, 9].CAN uses NRZ (non-return-to-zero) encoding mode for bit synchronization. In CAN bus, it will be seen as an error flag when the bus has 6 consecutive same polarity bits (000000 or 111111). To avoid those special bit patterns, once a send node has successively transmitted 5 same polarity bits (00000 or 11111), it will additionally add one opposite polarity bit (as a stuff bit). When the receive node has detected 5 same polarity bits, it will remove the stuff bit. This process is called bit-stuffing mechanism.


### 2.2. Queue Mode Modeling

Queuing is a normal phenomenon in daily life; for example, people queue to register in the hospital and line up in the store and cars on the highway queue to toll station. The queue system [13–15] consists of two parts: one needs to be served and the other provides the services. Those people or things that need to be served are called customers and service for customers is called service counter. The queuing service system can be seen as the customers and the service counter. The GI/G/1 queue [16, 17] model is usually described as follows: the customers arrived at time T1, T2, T3…; arrival time interval sequence τn=Tn−Tn−1, where (n = 1,2, …, τ0  = 0) are independent from each other and follow the same distribution function At; t≥0, and 0<1/λ=∫0∞tdAt; here λ>0 is a constant. The service time sequence χ_i,i>1 of customers needed is independent and follows the general distribution Bt, and 0<1/μ=∫0∞tdBt is taken as the average service time. The system follows the FIFO (first-in-first-out) mechanism and only has one service counter.In GI/G/1 queue system,Cn can be seen as the nth customer arriving in the system at time Tn, and wn can be seen as the waiting time of customer Cn. Customer Cn+1 arriving in the system will meet two statuses: one is that the service counter is busy and the other is that the service counter is idle. The two statuses are shown in Figures 2(a) and 2(b). The process can be formulated as(1)τn+1+wn+1=wn+χn.Figure 2
Message arriving in different service states. (a) WhenCn+1 arrives in the system, the service is busy. (b) When Cn+1 arrives in the system, the service is idle.
(a)(b)Here,wn+1=wn+χn−τn+1 is the n+1th customer’s waiting time when it arrives in the system, and thereby wn+1 could be greater than 0 or equal to 0. wn+1 could be shown as(2)wn+1=wn+χn−τn+1,wn+χn−τn+1>0,0,wn+χn−τn+1≤0.LetUn=χn−τn+1, and equation (2) can be described as(3)wn+1=max0,wn+χn−τn+1=max0,wn+Un.According to equation (3), we can know that(4)w1=max0,w0+U0,w2=max0,w1+U1=max0,U1+max0,w0+U0,wn=max0,wn−1+Un−1=max0,Un−1,Un−1+Un−2,…,+U0+w0.According to [18], the upper boundary of the average waiting time for the mean waiting time of the GI/G/1 system is adopted. In this paper, when ρ<1, there will be(5)EWq≤λDχi+Dτi21−ρ.Here,Dχi is the variance of service time, Dτi is the variance of arrive interval time, and ρ=λ/μ indicates the load level or intensity of the system. Thereby, the inequation can be deduced into two parts.(6)EWq≤ρEWq+λDχi+Dτi2.In equation (6), the first part on the right can be seen as the waiting time of customers in the queue when a new message arrived, and the second part is the average service time of the current customer served by service counter when a new message arrived. That means if EWrs denotes the current customer-rest service time when a new customer arrives, we can get(7)EWrs=λDχi+Dτi2.The average staying time of a message can be obtained by the total time of the average service time and average waiting time, and the expression is(8)EW=1μ+λDχi+Dτi21−ρ.


## 2.1. Transmission Mechanism of CAN Bus

Data in CAN bus is divided into two types: one is the standard frame, and the other is extended frames. The main difference between these is the length of identifier ID. The schematic diagram of the standard frames is shown in Figure1.Figure 1
Standard format of CAN data frame.The main difference of two CAN types between standard frame and extended frame is the length of message. The standard frame has an 11-bit identifier and the extended one has 29-bit identifier. The identifier must be unique, which means that the message derived from different sources must have different identifiers.Once the bus is at least 6 recessive bits, it is called idle, and all nodes join in the bus with pending messages ready to transmit from the identifier field. According to the arbitration mechanism, a node will not transmit a message if it sent a recessive bit, and the bus level is dominant. Only when the node level is the same as the bus level through whole ID field will the node be allowed to transmit messages. That means the message ID is used for the arbitration mechanism: the smaller the ID, the higher the priority. Thus, the identifier has two purposes: (1) the priority of the frame and (2) making the receivers able to filter frames. It should be noted that the data transmit in the bus will only have 0∼8 bytes and each byte of message occupies 8 bits in data field, and the data field has 0∼64 bits. For more details about other fields in the frame, the reader is referred to [2, 9].CAN uses NRZ (non-return-to-zero) encoding mode for bit synchronization. In CAN bus, it will be seen as an error flag when the bus has 6 consecutive same polarity bits (000000 or 111111). To avoid those special bit patterns, once a send node has successively transmitted 5 same polarity bits (00000 or 11111), it will additionally add one opposite polarity bit (as a stuff bit). When the receive node has detected 5 same polarity bits, it will remove the stuff bit. This process is called bit-stuffing mechanism.


## 2.2. Queue Mode Modeling

Queuing is a normal phenomenon in daily life; for example, people queue to register in the hospital and line up in the store and cars on the highway queue to toll station. The queue system [13–15] consists of two parts: one needs to be served and the other provides the services. Those people or things that need to be served are called customers and service for customers is called service counter. The queuing service system can be seen as the customers and the service counter. The GI/G/1 queue [16, 17] model is usually described as follows: the customers arrived at time T1, T2, T3…; arrival time interval sequence τn=Tn−Tn−1, where (n = 1,2, …, τ0  = 0) are independent from each other and follow the same distribution function At; t≥0, and 0<1/λ=∫0∞tdAt; here λ>0 is a constant. The service time sequence χ_i,i>1 of customers needed is independent and follows the general distribution Bt, and 0<1/μ=∫0∞tdBt is taken as the average service time. The system follows the FIFO (first-in-first-out) mechanism and only has one service counter.In GI/G/1 queue system,Cn can be seen as the nth customer arriving in the system at time Tn, and wn can be seen as the waiting time of customer Cn. Customer Cn+1 arriving in the system will meet two statuses: one is that the service counter is busy and the other is that the service counter is idle. The two statuses are shown in Figures 2(a) and 2(b). The process can be formulated as(1)τn+1+wn+1=wn+χn.Figure 2
Message arriving in different service states. (a) WhenCn+1 arrives in the system, the service is busy. (b) When Cn+1 arrives in the system, the service is idle.
(a)(b)Here,wn+1=wn+χn−τn+1 is the n+1th customer’s waiting time when it arrives in the system, and thereby wn+1 could be greater than 0 or equal to 0. wn+1 could be shown as(2)wn+1=wn+χn−τn+1,wn+χn−τn+1>0,0,wn+χn−τn+1≤0.LetUn=χn−τn+1, and equation (2) can be described as(3)wn+1=max0,wn+χn−τn+1=max0,wn+Un.According to equation (3), we can know that(4)w1=max0,w0+U0,w2=max0,w1+U1=max0,U1+max0,w0+U0,wn=max0,wn−1+Un−1=max0,Un−1,Un−1+Un−2,…,+U0+w0.According to [18], the upper boundary of the average waiting time for the mean waiting time of the GI/G/1 system is adopted. In this paper, when ρ<1, there will be(5)EWq≤λDχi+Dτi21−ρ.Here,Dχi is the variance of service time, Dτi is the variance of arrive interval time, and ρ=λ/μ indicates the load level or intensity of the system. Thereby, the inequation can be deduced into two parts.(6)EWq≤ρEWq+λDχi+Dτi2.In equation (6), the first part on the right can be seen as the waiting time of customers in the queue when a new message arrived, and the second part is the average service time of the current customer served by service counter when a new message arrived. That means if EWrs denotes the current customer-rest service time when a new customer arrives, we can get(7)EWrs=λDχi+Dτi2.The average staying time of a message can be obtained by the total time of the average service time and average waiting time, and the expression is(8)EW=1μ+λDχi+Dτi21−ρ.


## 3. Delay Analysis for Nonperiodic CAN Message

Based on the knowledge of queue theory, if messages occupy the bus and transmitted data was considered as service, then the nodes in the CAN bus need to occupy the bus in the messages transmission process which can be regarded as customer, and the CAN bus provides the physical media to transmit the messages by arbitration and managing the message transmission; the bus can be called service counter.Generally, the messages in the CAN bus system are sent continuously; the total number of customers is infinite, and let the arrival interval time of customer follow general independent distribution. The CAN bus employs the Carrier Sense Multiple Access (CSMA) protocol to arbitrate the messages. This means that if the low-priority message is sent, the higher-priority message needs to wait to be sent until the low-priority messages are sent completely, and if the higher-priority messages are sent, the priority message cannot be sent. This process accords with the service protocol of nonpreemptive discrimination of priorities. The status of transmission finish for a message in CAN bus is only when all the bits were sent completely. Thus, we could consider the transmission time as the service time. Due to the fact that the CAN bus transmission time followed a probability distribution according to the difference of stuffing bit, the service time followed the general probability distribution. There are many nodes in a CAN bus but only one node can send message transmitted on the bus at a moment, which means that there is only one service counter. On the basis of these features of the CAN bus transmission mechanism, we adopt the GI/G/1 queue theory [12, 19, 20] to model the delay of nonperiodic CAN messages.


### 3.1. Queue Theory and the Waiting Time

The model of CAN bus queue and service is shown in Figure3. The following can be summarized based on the figure:(1)
N nodes in CAN bus represent n customer’s arrival interval time sequence, and they share one bus.(2)
The customers have priority; the range of the priority from high to low was 1, 2, …,n, respectively. Service mechanism employs the nonpreemptive discrimination of priorities.(3)
The speeds of arrivals areλ1, λ2, …, λn.(4)
The customer’s service time followed the general distribution, and, in different levels, the average service time is1/μ1, 1/μ2, …, 1/μn.Figure 3
The model of CAN bus queue and service.On the basis of the message priority from high to low, the first high-priority message is called class 1, the higher-priority message is class 2, and the lowest-priority message is classn. For the class 1 message, its average waiting time EWq1 is expressed as below. When a class 1 message arrives, the remaining transmission time (the average rest service time) of the messages that are transmitting through the bus is EWrs, and the average waiting time is supposed to be(9)EWq1≤EWrs.From equation (7), the average rest service time is supposed to be(10)EWrs=∑i=1nλiDχi+Dτi2.Here,n represents the n kinds of messages, λi represents the speed of class i message arrivals, Dχi is the variance of transmission time, and Dτi is the variance of arrive interval time. For the class 2 message, its average waiting time EWq2 is expressed as follows:(1)
EWrs is the remaining transmission time (the average rest service time) of the messages that are transmitting through the bus.(2)
When class 2 message arrives, the total transmission time of remaining class 1 message in the queueEW2rt is supposed to be(11)EW2rt=λ1EW1μ1=ρ1EWq1.(3)
When class 2 message arrives and during its waiting period, a new class 1 message arrives, and the total transmission time of new higher-priority (class 1) message is supposed to be(12)EW2nrt=λ1EWq2μ1=ρ1EWq2.According to equations (9), (11), and (12), the average waiting time of class 2 message can be deduced:(13)EWq2≤EWq11+ρ11−ρ1.For the classi message, its average waiting time EWqi is expressed as follows:(1)
EWrs is the remaining transmission time (the average rest service time) of the messages that are transmitting through the bus.(2)
When classi message arrives, the total transmission time of remaining higher priority than i messages in the queue EWirt is supposed to be(14)EWirt=∑j=1i−1λjEWqjμj=∑j=1i−1ρjEWqj.(3)
When classi message arrives and during its waiting period, a new higher-priority message arrives, and the total transmission time of new higher-priority messages is supposed to be(15)EWinrt=∑j=1i−1λjEWqiμj=∑j=1i−1ρjEWqi.According to equations (14) and (15), the message average waiting time of class i can be deduced:(16)EWi=1μi+EWqi≤EWqi−11−∑j=1i−2ρj+ρi−11−∑j=1i−1ρj.


### 3.2. Bit-Stuffing Mechanism and the Transmission Time

The transmission time is regarded as service time, so we need to figure out the transmission time. As mentioned above for the bit-stuffing mechanism, it will make the real transmitted message bits be greater than original bits.According to the CAN standard, before the bit-stuffing mechanism, the total number of bits in a CAN frame is(17)N=8Li+g+13.Here,Li is the number of bits of the data in messages, 0≤Li≤8; g is the number of control bits in CAN frame, and, for standard frame, g=34; and, for extended frame, g=54. The total number of bits exposed to bit-stuffing is 8Li + g; the remainder including Cyclic Redundancy Check (CRC) delimiter bit, ACK field, EOF, and Int, all 13 bits, are without bit-stuffing.After bit-stuffing, the total number of bits of a message is(18)N=8Li+g+13+T,where T is the total number of stuffed bits.In the worst situation, an opposite polarity bit every 4 bits will be inserted, as shown in Figure4. Due to exposure to bit-stuffing only having 8Li + g bits, the maximum of T is(19)Tmax=8Li+g−14.Figure 4
The worst-case scenario bit-stuffing.The transmission time of a message in the worst situation will be(20)Ciwcrt=8Li+g+13+8Li+g−14τbit,where τbit represents the time taken to transmit a bit on bus.In fact, the message’s stuffing bits are always less than the worst-case scenario; the value ofT is less than the maximum Tmax, and the real transmission time is less than the value as shown in equation (20); the relationship between transmission time Ci and stuffing bits T satisfies the equation(21)Ci=8Li+g+13+Tτbit.Due to the bits having different arrangements, the transmission time changes randomly. In [9], after bit-stuffing, the real probabilities of having a certain frame length can be calculated. If we transmit a message with 7 bytes, before bit-stuffing, the length of a frame can be at most 103 bits and among them 90 bits are exposed to bit-stuffing. In this 90-bit probabilities model, the following will be assumed: (1) equal probability of bit values 0 and 1 and (2) no dependency among bits. According to the bit-stuffing probability distribution, the mean and variance of transmission time can be calculated by using equation (21). The mean and variance of transmission time for standard format messages with 7 bytes are 106.48104 τbitt and 2.0078405 τbit2, respectively.As mentioned above, according to the waiting time and the transmission time, the online delay of nonperiodic CAN message can be derived from equations (8), (16), and (21).(22)EWi=1μi+EWqi,where 1/μi=Ci=8Li+g+13+Tτbit represents the average service time and EWqi≤EWqi−11−∑j=1i−2ρj+ρi−1/1−∑j=1i−1ρj represents the average waiting time.


## 3.1. Queue Theory and the Waiting Time

The model of CAN bus queue and service is shown in Figure3. The following can be summarized based on the figure:(1)
N nodes in CAN bus represent n customer’s arrival interval time sequence, and they share one bus.(2)
The customers have priority; the range of the priority from high to low was 1, 2, …,n, respectively. Service mechanism employs the nonpreemptive discrimination of priorities.(3)
The speeds of arrivals areλ1, λ2, …, λn.(4)
The customer’s service time followed the general distribution, and, in different levels, the average service time is1/μ1, 1/μ2, …, 1/μn.Figure 3
The model of CAN bus queue and service.On the basis of the message priority from high to low, the first high-priority message is called class 1, the higher-priority message is class 2, and the lowest-priority message is classn. For the class 1 message, its average waiting time EWq1 is expressed as below. When a class 1 message arrives, the remaining transmission time (the average rest service time) of the messages that are transmitting through the bus is EWrs, and the average waiting time is supposed to be(9)EWq1≤EWrs.From equation (7), the average rest service time is supposed to be(10)EWrs=∑i=1nλiDχi+Dτi2.Here,n represents the n kinds of messages, λi represents the speed of class i message arrivals, Dχi is the variance of transmission time, and Dτi is the variance of arrive interval time. For the class 2 message, its average waiting time EWq2 is expressed as follows:(1)
EWrs is the remaining transmission time (the average rest service time) of the messages that are transmitting through the bus.(2)
When class 2 message arrives, the total transmission time of remaining class 1 message in the queueEW2rt is supposed to be(11)EW2rt=λ1EW1μ1=ρ1EWq1.(3)
When class 2 message arrives and during its waiting period, a new class 1 message arrives, and the total transmission time of new higher-priority (class 1) message is supposed to be(12)EW2nrt=λ1EWq2μ1=ρ1EWq2.According to equations (9), (11), and (12), the average waiting time of class 2 message can be deduced:(13)EWq2≤EWq11+ρ11−ρ1.For the classi message, its average waiting time EWqi is expressed as follows:(1)
EWrs is the remaining transmission time (the average rest service time) of the messages that are transmitting through the bus.(2)
When classi message arrives, the total transmission time of remaining higher priority than i messages in the queue EWirt is supposed to be(14)EWirt=∑j=1i−1λjEWqjμj=∑j=1i−1ρjEWqj.(3)
When classi message arrives and during its waiting period, a new higher-priority message arrives, and the total transmission time of new higher-priority messages is supposed to be(15)EWinrt=∑j=1i−1λjEWqiμj=∑j=1i−1ρjEWqi.According to equations (14) and (15), the message average waiting time of class i can be deduced:(16)EWi=1μi+EWqi≤EWqi−11−∑j=1i−2ρj+ρi−11−∑j=1i−1ρj.


## 3.2. Bit-Stuffing Mechanism and the Transmission Time

The transmission time is regarded as service time, so we need to figure out the transmission time. As mentioned above for the bit-stuffing mechanism, it will make the real transmitted message bits be greater than original bits.According to the CAN standard, before the bit-stuffing mechanism, the total number of bits in a CAN frame is(17)N=8Li+g+13.Here,Li is the number of bits of the data in messages, 0≤Li≤8; g is the number of control bits in CAN frame, and, for standard frame, g=34; and, for extended frame, g=54. The total number of bits exposed to bit-stuffing is 8Li + g; the remainder including Cyclic Redundancy Check (CRC) delimiter bit, ACK field, EOF, and Int, all 13 bits, are without bit-stuffing.After bit-stuffing, the total number of bits of a message is(18)N=8Li+g+13+T,where T is the total number of stuffed bits.In the worst situation, an opposite polarity bit every 4 bits will be inserted, as shown in Figure4. Due to exposure to bit-stuffing only having 8Li + g bits, the maximum of T is(19)Tmax=8Li+g−14.Figure 4
The worst-case scenario bit-stuffing.The transmission time of a message in the worst situation will be(20)Ciwcrt=8Li+g+13+8Li+g−14τbit,where τbit represents the time taken to transmit a bit on bus.In fact, the message’s stuffing bits are always less than the worst-case scenario; the value ofT is less than the maximum Tmax, and the real transmission time is less than the value as shown in equation (20); the relationship between transmission time Ci and stuffing bits T satisfies the equation(21)Ci=8Li+g+13+Tτbit.Due to the bits having different arrangements, the transmission time changes randomly. In [9], after bit-stuffing, the real probabilities of having a certain frame length can be calculated. If we transmit a message with 7 bytes, before bit-stuffing, the length of a frame can be at most 103 bits and among them 90 bits are exposed to bit-stuffing. In this 90-bit probabilities model, the following will be assumed: (1) equal probability of bit values 0 and 1 and (2) no dependency among bits. According to the bit-stuffing probability distribution, the mean and variance of transmission time can be calculated by using equation (21). The mean and variance of transmission time for standard format messages with 7 bytes are 106.48104 τbitt and 2.0078405 τbit2, respectively.As mentioned above, according to the waiting time and the transmission time, the online delay of nonperiodic CAN message can be derived from equations (8), (16), and (21).(22)EWi=1μi+EWqi,where 1/μi=Ci=8Li+g+13+Tτbit represents the average service time and EWqi≤EWqi−11−∑j=1i−2ρj+ρi−1/1−∑j=1i−1ρj represents the average waiting time.


## 4. Experimental Test

Actually, the nonperiodic CAN messages transmission is a triggering process. In real condition, the CAN nodes get a send request which is random and then the message is sent. Therefore, we use the random sequence as the messages arrival interval time in this experiment through the random interval sequence to send CAN messages in send nodes and use the oscilloscope to detect the received messages in the receiving node and save the datum.The experimental platform includes two parts: the hardware network nodes system and the data collecting system. The hardware devices adopt the Freescale MC9S12X series single chip which is built-in CAN module. This nodes system totally has five nodes, which are consistent with three built-in CAN modules and two CAN analyzer device named CANalyst as four send nodes and one receive node. In more detail, one built-in CAN module acts as a receiving node, the other built-in module acts as the sending node, and the test built-in CAN module and two CAN analyzer act as the interrupt nodes to change the bus load ratio and compete the bus with the sending node. The test and save system was the digital oscilloscope; it could give intuitive level changes and could save the delay datum about the sending and receiving moment. The whole platform is shown in Figure5. Numbers 1, 2, and 5 are the CAN module embedded in the Freescale 16-bit MC9S12X series single chip. Number 1 is the sending node in CAN bus, number 2 is the interrupting node in CAN bus, and number 5 is a receiving node in CAN bus; numbers 3 and 4 are the CAN analyzers as two interrupting nodes in the CAN bus; number 6 is a high-accuracy digital oscilloscope, as the delay time data save system; number 7 is the computer, mainly for the CANalyst sent data through a software interface on the computer.Figure 5
The experimental platform for testing the delay of CAN messages.In the experimental platform, the delay of nonperiodic CAN messages with different bus load ratios at different IDs and different priorities is tested and saved in an actual CAN communication process.


### 4.1. Nonperiodic CAN Test Results

The experiment is implemented and the data are handled, respectively, in ID1, ID2, ID3, and ID4 with ratios of 9.84%, 12.208%, 15.168%, and 18.974%. In each test, 50 time intervals are set, 51 messages are sent at one time, and 10 times data are saved for the data of every ID with every bus load ratio. Then, the time difference between receiving and sending is adopted to be the response time, and the value obtained is the average of 10 test data. The following are the detailed data for the nonperiodic CAN messages’ response time.In the first experiment, ID1 is set as the send node, and the nonperiodic CAN messages transmitted from the send node to receive node are tested. Then, deal with the datum to get the difference between receiving moment and sending moment and the other operations. In the second experiment, ID1 is set as the send node and, like the first experiment, the third and fourth experiments are similar to the above; the response times of nonperiodic CAN messages are obtained in Table1.Table 1
The response time in four load ratios.
Ratio (%)9.8412.20815.16818.974ID1 (s)0.0010515410.0010701960.0010457520.00108549ID2 (s)0.001045490.0010962960.0011220040.001081569ID3 (s)0.0014862750.001505490.0015215690.001535294ID4 (s)0.0015106750.0015127450.0015415690.001555991


## 4.1. Nonperiodic CAN Test Results

The experiment is implemented and the data are handled, respectively, in ID1, ID2, ID3, and ID4 with ratios of 9.84%, 12.208%, 15.168%, and 18.974%. In each test, 50 time intervals are set, 51 messages are sent at one time, and 10 times data are saved for the data of every ID with every bus load ratio. Then, the time difference between receiving and sending is adopted to be the response time, and the value obtained is the average of 10 test data. The following are the detailed data for the nonperiodic CAN messages’ response time.In the first experiment, ID1 is set as the send node, and the nonperiodic CAN messages transmitted from the send node to receive node are tested. Then, deal with the datum to get the difference between receiving moment and sending moment and the other operations. In the second experiment, ID1 is set as the send node and, like the first experiment, the third and fourth experiments are similar to the above; the response times of nonperiodic CAN messages are obtained in Table1.Table 1
The response time in four load ratios.
Ratio (%)9.8412.20815.16818.974ID1 (s)0.0010515410.0010701960.0010457520.00108549ID2 (s)0.001045490.0010962960.0011220040.001081569ID3 (s)0.0014862750.001505490.0015215690.001535294ID4 (s)0.0015106750.0015127450.0015415690.001555991


## 5. Comparative Analysis

As discussed above, we can calculate the theory value of the upper boundary of response time with different ratios and different priorities as shown in Table2. According to the experiment, the ratios of 9.84%, 12.208%, 15.168%, and 18.974% are chosen. Due to the fact that the bus baud rate is 250 kb/s, the value of τbit is 4μs. It is worth mentioning that the ID also means the priority, and the lowest ID has the highest priority which is already mentioned in Section 3.Table 2
Upper boundary response time of CAN message.
Ratio (%)ID1ID2ID3ID49.840.0027540.0028360.0029890.00308412.2080.0028500.0028900.0030480.00321115.1680.0029140.0029610.0031260.00338618.9740.0029720.0030560.003230.003632Table2 shows the response time trend with different priorities in ratios of 9.84%, 12.208%, 15.168%, and 18.974%, respectively. Figure 6(a) shows the priority increase in a certain bus load ratio, and the upper boundary of response time is increased. Figure 6(b) shows the bus load ratio increase in a certain priority; the upper boundary of response time is increased, and when the priority is the lowest, the trend of response time increases more quickly than the others, and the highest one is stable.Figure 6
Theory response time in a certain ratio with different priorities and ratios.
(a)(b)The experimental data are processed in the same ways as in the theory part. From Table2, the trend about the response time with different priorities in ratios of 9.84%, 12.208%, 15.168%, and 18.974% is obtained and it is shown in Figures 7(a) and 7(b).Figure 7
Experimental response time in a certain ratio, respectively, with different priorities and ratios.
(a)(b)From Figure7(a), we can draw the conclusion that, with the priority decrease in a certain bus load ratio, the upper boundary of response time is increasing; and, from Figure 7(b), it is shown that, with the bus load ratio increase in a certain priority, the upper boundary of response time is increasing and when the priority is lower, the response time is higher than the higher priority.Comparing the test and theory data, Figures8(a)∼8(d) represent the relationship between the test delay time of nonperiodic CAN messages and the theory in different bus load ratios; the results show that the theory analysis about the experimental data of the nonperiodic CAN message delay time is under the upper boundary of theory response time in GI/G/1queue system; and the trend of experimental change curve is similar to the theory.Figure 8
Results of theory and test. (a) Ratio = 9.84%. (b) Ratio = 12.208%. (c) Ratio = 15.168%. (d) Ratio = 18.974%.
(a)(b)(c)(d)


## 6. Conclusions

This paper adopts the GI/G/1 queue system model to analyze the nonperiodic CAN messages time delay performance with nonpreemptive discrimination of priorities, and the experimental data reflect the reliability of the upper boundary of waiting time and the service time obtained by the bit-stuffing mechanism. The similarity between mathematical theory and the experiment about the trends of delay time in different ratios with different priorities also shows that the mathematical theory of the GI/G/1 queue system is feasible. Using the upper boundary of response time, the new model for the worse scenario of response time to handle the case of messages transmit in CAN bus will be investigated in the future.



---

*Source: 5515287-2021-07-19.xml*