Comparing Delay-Constrained ALOHA and CSMA: A Learning-Based Low-Complexity Approximate Approach

,


I. INTRODUCTION
Delay-constrained applications become widespread nowadays.Typical examples include multimedia communication systems such as real-time streaming and video conferencing [2], tactile Internet [3], [4], networked control systems (NCSs) such as remote control of unmanned aerial vehicles (UAVs) [5], [6], and cyber-physical systems (CPSs) such as medical tele-operations, X-by-wire vehicles/avionics, factory automation, and robotic collaboration [7]- [9].In such applications, each packet has a hard deadline: if it is not delivered before the deadline, it becomes useless and will be removed from the system.On the other hand, wireless communication is ubiquitous because it can be easily deployed with low cost and low complexity.We focus on delay-constrained wireless communication in this paper.Many works designed centralized scheduling policies in the downlink [2], [10]- [12], while a few works investigated distributed wireless access protocols in the uplink for delay-constrained traffic [13]- [19].
This work was supported in part by the National Natural Science Foundation of China under Grants 61902256, 62071236, and 61671007, in part by Tencent "Rhinoceros Birds"-Scientific Research Foundation for Young Teachers of Shenzhen University, and in part by the Fundamental Research Funds for the Central Universities of China under Grant 30920021127.A preliminary version of this paper was published in the 16 th IEEE International Conference on Control & Automation, 2020 [1].
L. Deng and Y. Yu are with Shenzhen Key Laboratory of Digital Creative Technology and Guangdong Province Engineering Laboratory for Digital Creative Technology, College of Electronics and Information Engineering, Shenzhen University, Shenzhen 518060, China (e-mail: ldeng@szu.edu.cn,1810262015@email.szu.edu.cn).
Y. Zhang is with School of Electronic and Optical Engineering, Nanjing University of Science and Technology, Nanjing 210094, China (e-mail: yijin.zhang@gmail.com).
Y. S. Han is with Shenzhen Institute for Advanced Study, University of Electronic Science and Technology of China, Shenzhen 518110, China (email: yunghsiangh@gmail.com).
ALOHA and carrier sense multiple access (CSMA) are two widely used random access protocols in traditional delayunconstrained wireless communication.The advantage of ALOHA is that it is extremely simple.Since Abramson invented pure ALOHA in 1970 [20], a variety of other ALOHAtype protocols have been designed.Among them, one popular type is slotted ALOHA, where users are synchronized and can only transmit data at the beginning of a slot [21].We focus on slotted ALOHA in the rest of this paper.For simplicity, we will sometimes call it ALOHA if there is no ambiguity through the context.There are also many types of extension for slotted ALOHA protocol, including slotted ALOHA for multipacket reception [22], [23], framed slotted ALOHA [24]- [26], and coded slotted ALOHA for successive interference cancellation (SIC) [27], [28].In addition, some works studied stability analysis for the slotted ALOHA systems [29]- [31].CSMA is a more sophisticated wireless access protocol than slotted ALOHA, which is divided into non-persistent CSMA, p-persistent CSMA and 1-persistent CSMA [32].Note that p-persistent CSMA is the most general one, which also has several versions, including a constant probability p, a uniform backoff strategy and a multi-stage backoff strategy, etc.Moreover, the behaviors of each such version can be closely approximated by each other (at least from the standpoint of maximum throughput) if the p value is selected to guarantee that the same average backoff interval is used [33], [34].In the rest of this paper, we will consider CSMA with a uniform backoff strategy.Previous studies have shown that the design of parameters is important to improve the performance of CSMA [33], [35], [36].There are also some works to compare ALOHA and CSMA under the delay-unconstrained setting [37], [38].We also remark that the discrete-time Markov chain (DTMC) is an important tool to analyze ALOHA and CSMA.For example, [22], [26], [29], [31] used DTMC to analyze • For a given number of users N , hard delay D, packet size L, we construct two Markov chains to analyze delayconstrained ALOHA and delay-constrained CSMA.By analyzing the state distributions of the Markov chains, we obtain the exact theoretical system timely throughput for delay-constrained ALOHA and CSMA.• The number of states of Markov chains in the previous exact characterization increases exponentially with respect to the number of users.Therefore, we can only compare the exact performance of delay-constrained ALOHA and CSMA for small-scale networks.We thus design a parameterized ALOHA (resp.CSMA) system in view of only one user where there are two parameters to be learned to approximate the original multi-user ALOHA (resp.CSMA) system.The numerical results show the effectiveness of this approximate approach.• Since our proposed low-complexity approach preserves the Markov-chain structure of the systems, a by-product of our approach is that we can compute some other interested performance metrics.In this paper, we show how to theoretically compute the average delivery time of those packets that have been delivered successfully before expiration.• Using our proposed low-complexity approximate approach, we compare delay-constrained ALOHA and C-SMA for different system settings, and then summarize the conditions under which delay-constrained ALOHA (resp.CSMA) outperforms delay-constrained CSMA (resp.ALOHA).The rest of this paper is outlined as follows.Sec.II describes the system model.In Sec.III, we construct two Markov chains to analyze the exact performance of delay-constrained ALOHA and CSMA, respectively.In Sec.IV, we propose a learning-based low-complexity approximate approach.In Sec.V, we show how to compute the average delivery time based on our low-complexity approach.Sec.VI provides numerical results and summarizes the conditions under which delay-constrained ALOHA (resp.CSMA) outperforms delayconstrained CSMA (resp.ALOHA).Sec.VII concludes this paper.

II. SYSTEM MODEL
We consider a wireless network with N users who need to independently deliver delay-constrained traffic to a common receiver by competing for a shared wireless channel.We consider a slotted system indexed from 1. Similar to previous studies [2], [10], [11], [15], we consider the framesynchronized traffic pattern.But we characterize the traffic pattern by parameters L ∈ Z + and D ∈ Z + .More precisely, starting from slot 1, each user has a new packet arrival every D slots. 1 All packets are of size L and have a hard delay of D slots.A packet will be useless and removed from the system if it cannot be delivered within D slots after its arrival.We also call the duration from slot Note that existing studies [2], [10], [11], [15] assume that all packets are of unit size, i.e., L = 1.To capture more practical applications, we generalize packet size to a positive integer L, meaning that a user needs L slots to deliver a packet.In addition, a packet can be divided into L different units for transmission but we do not allow partial delivery.Thus, a packet can contribute to the system performance in terms of timely throughput, which will be described in (1) shortly, only when the whole packet of size L has been completely delivered within D slots after its arrival.Since sending a packet needs at least L slots and the hard delay is D, without loss of generality, we assume that L ≤ D.
We illustrate an example of D = 3 and L = 2 in Fig. 1.Each user has a new packet of size L = 2 at the beginning of slot 1, which will expire and be removed from the system if it cannot be delivered completely within D = 3 slots.Then, at the beginning of slot 4, each user has another new packet of size L = 2, which again has a hard delay of D = 3 slots.The process continues with the same behaviours.
It is straightforward to see that any user has at most one non-expired packet for delivery in any slot.For any user, if the packet arrived at the beginning of a period has been completely delivered successfully to the receiver, this user remains idle until the end of this period.Therefore, for our wireless access problem, we do not need to handle the packet queueing problem.In addition, since each packet is of size L and the transmission capacity of each slot is only one unit, we divide each packet into L units and call them unit 1, unit 2, • • • , and unit L. In our wireless access problem, we sequentially transmit these L units.Namely, we keep transmitting unit i until it has been successfully delivered to the receiver.After that, we keep transmitting unit i+1.If the final unit L has been delivered successfully to the receiver before the end of this period, this packet is successfully delivered and can contribute to this user's timely throughput.
In this paper, we adopt conventional wireless access setting with a collision channel-if two or more users send data in the same slot, a collision happens and no data can be delivered to the receiver; if only one user transmits data, it can be successfully delivered to the receiver.Same as previous studies on delay-constrained communications, we use timely throughput to characterize the system performance.The timely throughput of user i is defined as Our goal is to maximize the system timely throughput R = N i=1 R i .An Practical Example.We consider a WiFi network in an industrial automation system where N PLCs (Programmable Logic Controllers) needs to send control messages to remote I/O devices via a WiFi AP, as shown in Fig. 2. According to the on-going IEC/IEEE standard 60802 [48], we assume that the control messages are isochronous or cyclic-synchronous such that they arrive periodically (say with period D) and the hard delay of such packets are the same with period D. Thus, the control messages of all N PLCs form a frame-synchronized traffic patter as shown in Fig. 1.In WiFi networks, all PLCs (stations) need to compete the channel for uplink transmission via random-access schemes, which are typically CSMA/CA.We further remark that indeed, the next generation WiFi (IEEE 802.11be, aka, WiFi 7) aims at supporting time-sensitive applications [49].Thus, our investigated model in this paper can be supported by this practical example.
In the following, we will consider two widely used distributed wireless access protocols, slotted ALOHA and CSMA.As we mentioned in Sec.I, we sometimes use ALOHA to represent slotted ALOHA if there is no ambiguity through the context in the rest of this paper.
We remark that in this work, we follow traditional analysis for ALOHA and CSMA by only considering a single-channel scenario.Namely, we do not consider frequency-domain resource allocation in a multi-channel scenario, like OFDMbased 5G system.Instead, we focus on the time-domain random access scheme in a single-channel scenario, e.g., a Wi-Fi network with a single shared channel.But we should note that there are some works studying multi-channel resource allocation for delay-constrained traffic in 5G systems with flexible numerology [50]- [52], where both time-domain (with varying slot length) and frequency-domain resources need to be allocated and generally a complex integer program problem is involved.In this paper, we do not consider such joint timedomain and frequency-domain resource allocation problem.We would leave it as a future direction to compare delayconstrained ALOHA and CSMA is such a complex multichannel system.

III. THEORETICAL ANALYSIS
A. ALOHA Mechanism.In (slotted) ALOHA protocol, in each slot, if a user has a packet that has not yet delivered successfully before its deadline, this user transmits the current unit of this packet to the receiver with probability p ∈ [0, 1]; otherwise, if unit L of the packet has been delivered successfully, this user remains idle.Note that the transmission probability p needs to be optimized to maximize the system timely throughput.We assume that the transmission events of all users in any slot are independent as same as the traditional delay-unconstrained ALOHA protocol [20], [31].
Markov Chain Analysis.For the given number of users N , packet size L, and hard delay D, we construct a Markov chain to analyze the theoretical performance of ALOHA.In particular, the system state in any slot is denoted by where l i ∈ {0, 1, • • • , L} is the number of units of the current (non-expired) packet that have been delivered successfully to the receiver before the current slot and t ∈ {1, 2, • • • , D, D + 1} is the index of the current slot relative to the beginning of this period.Note that we construct a virtual slot, i.e., t = D+1, to indicate the end of the period, which is used for calculating the system timely throughput from the state distribution.Let us consider an example with N = 2, L = 2 and D = 3.State s = [(l 1 , t), (l 2 , t)] = [(0, 1), (0, 1)] means that this slot is the beginning (the first slot) of the period and no unit has been delivered successfully to the receiver before this slot, since a new packet just arrives at the system in the beginning of this slot.State s = [(l 1 , t), (l 2 , t)] = [(0, 2), (1, 2)] means that this slot is the second slot of the period and no unit of user 1 has been delivered successfully to the receiver before this slot while unit 1 of user 2 has been delivered successfully to the receiver before this slot.State s = [(l 1 , t), (l 2 , t)] = [ (1,4), (2, 4)] means that this slot is the virtual slot to indicate the end of the period and user 1 only transmits one unit while user 2 has delivered the whole packet to the receiver.Therefore, the packet of user 2 contributes to the timely throughput of user 2 while the packet of user 1 is discarded and does not contribute to the timely throughput of user 1.Note that the state space, denoted by S ALOHA , is of size Now we construct the transition probabilities of the constructed Markov chain for ALOHA protocol.For state where N 1 is the set of users who have not yet completely delivered the packet and N 2 is the set of users who have already completely delivered the packet before this slot.That is, and Thus, in this slot, all users in N 2 remain idle and all users in N 1 transmit one unit with probability p.We can compute the transition probabilities as follows, and the transition probabilities from state s to all other states are zero.Note that (4) follows from the fact that there exists at most one successful transmission in any slot.
Now we have a transition matrix P = [P (s |s) : s, s ∈ S ALOHA ].Next we give an initial state distribution (in the beginning of slot 1) Then the state distribution in the beginning of slot 2 is Similarly, we can obtain the the state distribution in the beginning of the virtual slot D + 1, Based on the state distribution π D+1 , we can compute the timely throughput of user i by Then we can obtain the exact theoretical system timely throughput R = N i=1 R i .In addition, we would like to discuss how to calculate the D-th power of the transition matrix P , more precisely, how to calculate the RHS of ( 5).It is nature that we first get the D-th power of P , i.e., P D , which could have plenty of numerical methods.Anyway, P is a square matrix of size |S ALOHA |×|S ALOHA |.We need to do matrix-multiplying-matrix D − 1 times.However, what we need is π 1 P D rather than P D .Note that π 1 is a vector of size 1 × |S ALOHA |.We do not need to do matrix multiplication, but instead we only need to do vector-multiplying-matrix D times.Namely, we first get π 2 = π 1 P , which involves one vector-multiplying-matrix operation.We then get π 3 = π 1 P 2 = π 2 P , which again involves one vector-multiplying-matrix operation.We continue this process for D times.This computation process is much more faster than the one based on calculating P D .In this paper, we adopt this computation process.
Note that the achieved system timely throughput R depends on the number of users N , the hard delay D, the packet size L, and the transmission probability p.To show this dependance clearly, we denote R ALOHA (N, D, L, p) as the exact theoretical system timely throughput of ALOHA protocol for given N, D, L and p.
To maximize the system performance, we need to find the best transmission probability p, i.e., It is difficult to find closed-form p * (N, D, L).In this paper, we numerically search it with an adjustable step size to control the precision.We denote the maximum system timely throughput of ALOHA by R * ALOHA (N, D, L).We remark that although we use a brute-force-type searching algorithm to find p * (N, D, L), it is possible to use more efficient searching algorithm by exploiting the structure of R ALOHA (N, D, L, p).For example, we observes that R ALOHA (N, D, L, p) first increases and the decreases with respect to p, which enables more efficient searching algorithms.However, currently we lack of theoretical proofs for such structure.We thus leave it as a future direction to design more efficient searching algorithms.

B. CSMA
Mechanism.In CSMA/CA (carrier-sense multiple access with collision avoidance) protocol2 , each node has a capability of carrier sensing to check whether the wireless channel is idle or not.If a user has a new packet arrival (i.e., in the beginning of a period), it randomly selects an integer value b from [0, D − 1] as the backoff time 3 .Then, in each slot, the user performs carrier sensing.If the channel is busy, the backoff-time value b is frozen; otherwise the backoff-time value b decreases by 1.If b = 0, there are two cases.If the packet has been delivered or the remaining number of units is larger than the remaining number of slots before expiration, the user remains idle in this slot; otherwise, the user transmits the current unit to the receiver in this slot.If the transmitted unit is delivered successfully, the user attempts to transmit the next unit in the next slot; otherwise, if the transmitted unit is not delivered successfully (i.e., a collision happens), the user restarts the backoff process by randomly selecting an integer value b from [0, D − 1] as the new backoff time.The detailed behavior of each user is shown in Algorithm 1.We remark that delay-constrained CSMA is more complicated than traditional delay-unconstrained CSMA.We thus present Algorithm 1 to explicitly show all the details of our delay-constrained CSMA protocol.
Markov Chain Analysis.For the given number of users N , packet size L, and hard delay D, we present a Markov chain to analyze the exact theoretical performance of CSMA.In particular, the system state in any slot is denoted by where is the number of units that have been delivered successfully to the receiver before the current slot and t ∈ {0, 1, 2, • • • , D, D + 1} is the index of the current slot relative to the beginning of this period.Similar to ALOHA, we construct a virtual slot t = D + 1 to indicate the end of a period.In addition, we construct a virtual state Randomly select an integer b from [0, D − 1] Transmit unit u to the receiver in slot t 8: if The unit is delivered successfully then end if Remain idle Transmit unit u to the receiver in slot t

25:
if The unit is delivered successfully then  end if 38: end for to indicate the start of a period.This means that we construct another virtual slot t = 0 for each period.The state space of CSMA, denoted by S CSMA , is of size For the initial state s 0 , the transition probability to state Any user i ∈ N 1 either has already successfully delivered the packet or cannot complete the delivery even it transmits in all the rest of slots before the end of the period.Thus, any user i ∈ N 1 remains idle in this slot.The backoff-time value of any user i ∈ N 2 is 0, i.e., b i = 0, and thus it transmits the current unit in this slot.The backoff-time value of any user i ∈ N 3 is larger than 0, i.e., b i > 0, and thus it performs carrier sensing.
Let us denote the state in the next slot by which depends on the value of • N in state s and then discuss which of them will be changed (the changing parts of state s ).If |N 2 | = 0, no user transmits data in this slot.Thus, all users in N 3 sense to know that the channel is idle and decrease the backoff-time value by 1.Thus, the updated portion of state s is The transition probability is , only one user i ∈ N 2 transmits unit l i +1 in this slot.Thus, no collision happens and the transmission is successful.In addition, since the channel is busy, the backoff-time values of all users in N 3 are frozen.Thus, the updated portion of state s is Again, the transition probability is all users (more than one) in N 2 transmit data in this slot.Thus, a collision happens and all transmissions fail.Therefore, each of all users in N 2 restarts the backoff process by randomly selecting a backoff-time value from [0, D − 1].In addition, since the channel is busy, the backoff-time values of users in N 3 are frozen.Therefore, the updated portion of state s is There are in total D |N2| possibilities for state s and the transition probability is P (s |s) = Then the state distribution in the beginning of slot 1 is Similarly, we can obtain the state distribution in the beginning of the virtual slot D + 1 as Based on the state distribution π D+1 , we can compute the timely throughput of user i by Then we can obtain the exact theoretical system timely throughput R = N i=1 R i .Note that the achieved system timely throughput R depends on the number of users N , hard delay D, and packet size L.
To show this dependance clearly, we denote R CSMA (N, D, L) as the exact theoretical system timely throughput of CSMA protocol for given N, D and L.

IV. A LEARNING-BASED LOW-COMPLEXITY APPROXIMATE APPROACH
In the previous section, we use Markov-chain analysis to obtain the exact system timely throughput for both ALOHA and CSMA protocols.However, when we solve the equations ( 5) and ( 8) to obtain the final-slot state distributions for ALO-HA and CSMA, respectively, the computational complexity exponentially increases with respect to the total number of users, i.e., N .This is because the number of states for both ALOHA and CSMA exponentially increase with respect to N , as shown in ( 3) and (7).Therefore, we can only apply the exact approach in the previous section for small-scale networks.To compare ALOHA and CSMA broadly, we need to figure out how to evaluate the system timely throughput for practical medium-scale networks, say, up to 50 users.
In this section, we propose a learning-based low-complexity approach to obtain an approximate value of the exact system timely throughput for both ALOHA and CSMA.Note that the exact system timely throughput for ALOHA (resp.CSMA), i.e., R * ALOHA (N, D, L) (resp.R CSMA (N, D, L)), depends on three parameters, the number of users N , the hard delay D, and the packet size L. If we can learn functions R * ALOHA (N, D, L) and R CSMA (N, D, L), based on given networks, we can predict the system performance for any input network.This is the basic idea of the proposed learning-based low-complexity approach.Note that the function types could be very arbitrary and we also have a large number of machine learning approaches.
We next propose our learning approach by leveraging Markov-chain structures of ALOHA and CSMA.The basic idea is as follows.The exponential complexity of the exact approach comes from the number of users N .We thus try to reduce the total number of users but find a way to maintain the structure of the multi-user Markov chains.Note that the behavior pattern of each user is homogeneous in our considered multi-user wireless access system.Thus, it is reasonable to use a single user's performance to mimic the system performance.Such a technique has already been adopted by some existing works [53]- [56].More concretely, next we will respectively construct two parameterized singleuser Markov chains to mimic the original multi-user Markov chains for ALOHA and CSMA where the parameters need to be learned.

A. ALOHA
For ALOHA, we construct a single-user Markov chain parameterized by a transmission probability p t ∈ [0, 1] and a success probability p s ∈ [0, 1].The single-user Markov chain behaves as follows.In each slot of a period, if the packet of the user in this period has not been successfully delivered to the receiver, the user transmits the current unit to the receiver with probability p t .The transmitted unit is then delivered successfully with probability p s .The transmission probability p t mimics the transmission probability p in the original multiuser ALOHA system, while the success probability p s mimics the potential collision from other users in the original multiuser ALOHA system, as shown in Sec.III-A.Clearly, we can construct a Markov chain for this particular user similar to Sec.III-A.We obtain the final-slot state distribution to calculate the timely throughput, denoted by R Approx ALOHA (p t , p s ).The total number of state is (L+1)(D+1), which is linear with L and D, regardless of N .Thus, the computational complexity is exponentially reduced.Our goal is to estimate the achieved timely throughput of the original multi-user ALOHA system for given N, D, L, i.e., R * ALOHA (N, D, L), from the achieved throughput of this single-user system.Namely, for given , D, L, we aim at finding suitable p t and p s to minimize The reason that we use two parameters p t and p s to construct the single-user Markov chain for ALOHA is because the combination of p t and p s reasonably mimics the original multi-user ALOHA system.Clearly, when a packet has at least one remaining unit, a packet will deliver one unit successfully if the user transmits a packet (with probability t ) and the packet is transmitted successfully (with probability p s ).Thus, a packet will deliver one unit successfully with probability p t p s if it has at least one remaining unit.The transition probability can be obtained by replacing p in (4) with p t p s .Thus, the transition matrix of the single-user Markov chain only depends on the product of p t and p s , but does not depend on the individual value of p t or p s .Therefore, the achieved timely throughput R Approx ALOHA (p t , p s ) also only depends on the product of p t and p s .Without loss of generality, next we assume that p t = 1, i.e., the single user transmits the current unit in all slots for sure.We then denote the achieved timely throughput by R Approx ALOHA (p s ).Thus, for given N , D, L, we need to find suitable p s to minimize Namely, we need to learn function We construct the dataset as follows.For given D, L, and a small N , we obtain the exact system timely throughput, i.e., R * ALOHA (N, D, L), by using the multi-user Markov-chain analysis in Sec.III-A.We find the best p s to minimize (9) via the binary-search approach (since R Approx ALOHA (p t , p s ) strictly increases as p s increases).Then we obtain a dataset where K is the total number of data points and i is the index of a data point in the dataset.We apply machine learning approaches to predict function p s as shown in (10).Now given D, L, and a large N , we can use our learned model to predict p s and then construct a single-user Markov chain to obtain N • R Approx ALOHA (p s ), which serves as an approximate value of R * ALOHA (N, D, L).

B. CSMA
For CSMA, we construct a single-user Markov chain parameterized by a channel-busy probability p b ∈ [0, 1] and a collision probability p c ∈ [0, 1].The single user follows the same steps in Algorithm 1 except the followings.First, when the user performs carrier sensing as shown in lines 14 and 31 in Algorithm 1, the channel is busy with probability p b .Second, when the user transmits data as shown in lines 7 and 24, a collision happens with probability p c and thus the transmitted unit can be delivered successfully with probability 1 − p c .The channel-busy probability p b and the collision probability p c mimic the potential transmissions from other users in the original multi-user CSMA system, as shown in Sec.III-B.Clearly, we can construct a Markov chain for this single user similar to Sec.III-B.We remark that the notations p b and p c were also used for simplifying the analysis of delay-unconstrained CSMA [57], but our model here is for delay-constrained traffic.
We then obtain the final-slot state distribution to calculate the timely throughput, denoted by R Approx CSMA (p b , p c ).The total number of state is 1 + D(L + 1)(D + 1), which is linear with L and quadratic with D, regardless of N .Again, the computational complexity is exponentially reduced.Our goal is to estimate the achieved timely throughput of the original multiuser CSMA system for given N, D, L, i.e., R CSMA (N, D, L), from the achieved timely throughput of this single-user system.
Thus, we need to predict two parameters p b and p c for given parameters N, D and L, i.e.,

C. Differences between Our Approximate Approaches and Bianchi's Work [33]
Bianchi's paper [33] is the seminal work for analyzing the performance of CSMA used in IEEE 802.11.Bianchi constructed a single-user system to approximate the original multi-user CSMA system with the key assumption that each packet collides with constant and independent probability p.This inspires our approximate approaches in this section.However, our approaches work for frame-synchronized traffic pattern, which is significantly different from the full-buffer delay-unconstrained traffic pattern in [33].
First, in our frame-synchronized pattern, each user has a new packet arrival every D slots.Thus, it is possible that a user does not have any packet to transmit in a slot.Once a packet has been delivered in a frame, the user has to remain idle in the remaining slots of the frame.That's why we added l i to record units of a packet in the state of the Markov chain (see Eq. ( 2) and Eq. 6).However, in [33] with full-buffer traffic, there is no need to record whether there is a packet or not in the queue because each user always has content to transmit.
Second, under our delay-constrained traffic patter, a packet will expire and be removed from the system after its deadline.Thus, we need to record when a packet will expire.That's why we added t to record the elapsed time in the state of the Markov chain (see Eq. ( 2) and Eq. 6).However, in [33] with delay-unconstrained traffic, there is no need to record how much time a packet has experienced because a packet can be kept in the queue for however long time.
Finally, the slot duration in Bianchi's paper be either the constant backoff slot time (e.g., the duration of slot 8, 7, 6, 4, 3, 2, 1 in Fig. 1 of [33]) or the variable time in which a packet is transmited (e.g., the duration of slot 5 in Fig. 1 of [33]).Bianchi did not differentiate these two cases and constructed a Markov chain (i.e., Fig. 4 in [33]).In other words, in Bianchi's Markov chain, a state transition could experience a constant backoff slot time or a variable packet-transmission time.Such modeling is applicable to delay-unconstrained setting but not applicable to our delayconstrained setting.In our delay-constrained setting, we need to know exactly how much time a packet has experienced.That's why we discretize the system into equal-length slots and the state of our constructed Markov chain is captured at the beginning of each slot.In addition, in our constructed Markov chain for the approximate CSMA system in Sec.IV-B, we use two parameters, p b and p c , to characterize the system behaviours.Parameter p c is the collision probability, which is exactly parameter p in Bianchi's work [33].But we have an extra parameter p b , which is the channel-busy probability.It can model the busy behaviour of slot 5 in Fig. 1 of [33] but in the granularity of constant backoff slot time.
Therefore, we can see that our constructed Markov chain is significantly different from that in Bianchi's paper [33].Under the full-buffer delay-unconstrained traffic patter in [33], Bianchi obtained the closed-form stationary distribution and then got the closed-form of the transmission probability τ = τ (p), i.e., Eq. ( 7) of [33].After that, Bianchi connected the single-user approximate system to the original multi-user system by Eq. ( 9) of [33].Solving this equation, Bianchi obtained the collision probability p for the approximate singleuser system.However, under our frame-synchronized delayconstrained traffic patter, we cannot obtain the closed-form stationary distribution of our constructed Markov chain, which is significantly different from Bianchi's Markov chain in [33].As a result, we cannot obtain the parameters of our approximate single-user systems by solving an equation like Eq. ( 9) of [33].Instead, in this paper, we resort to use data-driven approaches to estimate such parameters, as shown in Sec.VI-B .

V. AVERAGE DELIVERY TIME
As we analyzed in Sec.IV, our proposed learning-based approximate approach can exponentially reduce the complexity of our considered delay-constrained ALOHA and CSMA systems.Furthermore, another good property of our approach is that we still preserve the Markov-chain structure of the systems.This enables us to compute more performance metrics in addition to the system average timely throughput.One important metric is the average delivery time of those packets that have been delivered successfully before expiration.Even though we consider a delay-constrained system where a packet remains valid if it is delivered before its expiration, smaller delivery time is still preferred in many applications.For example, in wireless NCSs, the remote controller can control the plant more accurately if the deliver time of of the control message is smaller.
Since our ALOHA and CSMA systems are frame-by-frame stationary, we focus on a particular frame.Denote random variable X by the delivery time of the packet in this frame, which is the number of slots from its arrival to its departure.The range of X is 1, 2, • • • , D, D + 1, • • • .Note that we allow X > D, which means that the packet has not delivered successfully before expiration.Namely, we have Note that we compute the average delivery time of those packets that have been delivered successfully before expiration.
Mathematically, this means that we need to compute For both ALOHA and CSMA systems, we can obtain P (X = k) based on π t , t = 1, 2, • • • , D, D + 1 which is the state distribution of slot t of our constructed single-user (approximate) Markov chain in Sec.IV.In particular, for the single-user ALOHA system, as shown in (2), the state is denoted as (l, t) which means that l units of the packet have been delivered before slot t.Thus, the delivery time X is not greater than k if and only if the whole packet has been delivered before slot k + 1, i.e., For CSMA system, as shown in ( 6), the state is denoted as (b, l, t) which means that the backoff-time value of the packet is b and l i units of the packet has been delivered before slot t.Again, the delivery time X is not greater than k if and only if the whole packet has been delivered before slot + 1, i.e.,  Based on P (X ≤ k) as shown in (13) for ALOHA and ( 14) for CSMA, we can compute Then we can obtain the average delivery time according to (12).

VI. NUMERICAL RESULTS
In this section, we conduct extensive simulations to illustrate the performance of our proposed learning-based low-complexity approach.We implement all algorithms and evaluate their using MATLAB and languages.All evaluations are conducted in a computer with two CPUs (Intel Xeon E5-2678 v3), one GPU (N-VIDIA GeForce GTX 2080 Ti), and 64GB memory, running Ubuntu 16.04.6LTS.All source code and dataset are publicly available in https://github.com/yuyouzhi/compare.dc.aloha.and.csma.

A. Confirm Our Exact Theoretical Analysis
In Sec.III, we used Markov-chain analysis to obtain the theoretical system timely throughput for both ALOHA and CSMA.We need to confirm the correctness of this exact approach.We consider N = 3, L = 2 and vary D from 2 to 10.We first use the proposed exact approach to get the theoretical system timely throughput.We then simulate a multi-user ALOHA system and a multi-user CSMA system to get the empirical system timely throughput by running 100,000 periods.The results are shown in Fig. 3.As we can see, the theoretical values match well with the empirical values for both ALOHA and CSMA.This confirms the correctness of our exact theoretical analysis in Sec.III.

B. Learning Results of the Approximate Approach
In our approximate approach, we need to learn parameter p s for ALOHA and learn parameters p b and p c for CSMA with respect to N, D, and L. We have collected 9,065 data points for both ALOHA and CSMA.Note that due to the limitations of our computation resources and the exponential complexity of the exact theoretical analysis, we can only get the theoretical system timely throughput for small-scale networks.To enlarge the dataset, we further use the empirical system timely throughput via simulation to collect more data points for practical medium-scale networks.We remark that we assume that the network has at most N = 50 users.It is a relatively moderate-size network and can capture a wide range of practical scenarios.For example, although most WiFi APs can theoretically support up to 250 users, it is generally suggested that at most 50 users connect to the same WiFi AP simultaneously in typical scenarios to ensure reasonable user experience 4 5 .In fact, in Bianchi's seminal work [33] for analyzing the performance of the DCF mechianisam of IEEE 802.11, all simulations were also conducted in a network with at most 50 users; see Figs. 7-10 in [33].We then randomly choose 80% of the dataset to be the training dataset and leave the rest 20% as the test dataset.We remark that the packet size is generally not very large due to the maximum transmission unit (MTU) limit.For example, the MTU of a MAC packet of Wi-Fi is 2304 bytes [58,.For this reason, we assume that L ≤ 5 in this paper.Since there are only 5 possible values for the packet size L, next we learn the parameters in the approximate approach for each L ∈ {1, 2, 3, 4, 5} separately.
In addition, for approximate CSMA, we need to predict two parameters p b and p c .Note that p b and p c jointly affect the system timely throughput R Approx CSMA (p b , p c ).We then observe that it is possible that R Approx CSMA (p b , p c ) = R Approx CSMA (p b , p c ) even if p b = p b and p c = p c .This results in ambiguity for predicting p b and p c .In fact, we have used the dataset to learn both p b and p c .However, due to the aforementioned ambiguity, the prediction error is relatively large.We thus preprocess the dataset as follows.For each L ∈ {1, 2, 3, 4, 5}, we divide the (N, D) plane into four regions with separation lines N = N 1 and D = D 1 , as shown in Fig. 4. For each region i ∈ {1, 2, 3, 4}, we select a best p b ∈ [0, 1] to minimize where R Approx CSMA (p b , p c ) is the achieved timely throughput of the approximate single-user CSMA system with parameters p b and p c , and R CSMA (N, D, L) is the achieved system timely throughput of the original multi-user CSMA system, as described in Sec.IV-B.For each separation (N 1 , D 1 ), we can get a total cost δ(N 1 , D 1 ) = 4 i=1 δ i (N 1 , D 1 ).We then iteratively find the best separation (N 1 , D 1 ) to minimize δ(N 1 , D 1 ).After this preprocessing, for each L, we have fixed the separation and also fixed the parameter p b for each of the four regions in Fig. 4.Then, we only need to learn parameter  p c for each region.This avoids the aforementioned ambiguity and improves the prediction accuracy.
After the preprocessing, we can use many possible machine learning approaches.In this paper, we consider three classic approaches: linear regression, neural network, and support vector regression (SVR) [59]- [61].The cost function is defined as the mean square error.Taking p s as an example, the cost function is where K is the total number of data points in the test dataset, pi s is the predicted value, and p i s is the true value.All three machine learning approaches could have different configurations.For linear regression, we consider both the first-order linear regression and the second-order linear regression.For neural network, we range the number of layers from one to three.For support vector regression (SVR), we consider three kernels: linear kernel, polynomial kernel, and radial basis function (RBF) kernel.We report the best-configuration results of these different learning approaches in Table I.We remark that it is possible to apply high-order linear regressions and multi-layer neural networks (even deep learning with many layers).However, based on our investigation, such approaches do not have benefits but lead to over-fitting.From Table I, we can see that the SVR is the best learning approach for both predicting p s for ALOHA and predicting p c for CSMA.
Although we have predicted parameters for ALOHA and CSMA, they are used to approximate the theoretical system timely throughput.Thus, we need to evaluate the accuracy of our proposed approximate approach.Again, we use the mean square error as the performance metric.Given N, D, L, for C. Compare ALOHA and CSMA Our goal of this paper is to compare ALOHA and CSMA for a broad number of system settings.With the help of our learning-based low-complexity approximate approach, we can compare ALOHA and CSMA for different N, D, L. It would be difficult to plot and view the three-dimension results.As we mentioned in Sec.VI-B, we consider L ≤ 5 in this paper.We thus plot the results in the (N, D) plane for each L ∈ {1, 2, 3, 4, 5}.The results are shown in Fig. 9.We have the following observations.For L = 1, ALOHA outperforms CSMA when N is small (N ≤ 25), while CSMA generally outperforms ALOHA when N is large (N > 25) except a small region when 30 ≤ N ≤ 35 and D ≤ 20.Overall, we can see that when L = 1, the number of users, i.e., N , has bigger impact than the delay D.
For L > 1, CSMA outperforms ALOHA in the majority of cases.Only when N is small and D is large, ALOHA is better than CSMA.In addition, as L increases, the percentage of cases that CSMA is better also increases.This suggests that CSMA benefits from large packet size L.

D. The Average Delivery Time of ALOHA and CSMA
Based on our proposed low-complexity approach, we have showed how to theoretically calculate the average delivery time for both ALOHA and CSMA system in Sec.V.In this part, we first confirm the analysis in Sec.V by comparing its result with empirical result.The results for ALOHA and CSMA are shown in Fig. 5 where p s = 0.4 and L = 2 and Fig. 6 where p b = 0.7, p c = 0.6, L = 2, respectively.For both figures, we can see that indeed our theoretical analysis matches well with the empirical result.This confirms the correctness of our analysis in Sec.V.In addition, we can see that the average delivery time increases as the hard delay D increases.This is an intuitive observation.
In addition, our analysis in Sec.V can be applied to compare the average delivery time of ALOHA and CSMA.In Fig. 8, we fix N = 4 and L = 4 and vary D from 5 to 29.We compare the average delivery time of ALOHA under the optimal s and CSMA under the optimal p c and p s .We can observe that the average delivery time of ALOHA is larger than that of

E. MPR Capability
In this paper, we only consider the traditional model of a single-packet reception (SPR) channel.Namely, a packet can be correctly received if and only if there is no other packet transmissions during its transmission.However, the new physical (PHY) layer techniques enables a single PHY channel to accommodate multiple concurrent transmissions, which is called multiple-packet reception (MPR) capability [36], [43], [62].According to our previous research on random access protocols with MPR capability [36], [43], [62], the random access protocol design with MRP is very different from that with SPR.Thus, as a first step to compare ALOHA and CSMA under the new delay-constrained settings, we follow traditional SPR model in this paper.
In this subsection, to gain some basic understandings on MRP model, we show some simulation results.We assume that the MPR capability is denoted by parameter γ, which is the maximal number of collided packets that can be received/decoded by the AP.We compare the achieved system timely throughput of both ALOHA and CSMA for γ = 1 (i.e., our current SPR model), γ = 2 and γ = 3, as shown in Fig. 7.We can see that when the MRP capability increases, both ALOHA and CSMA achieve better system timely throughput but ALOHA achieves higher improvement than CSMA.It deserves further investigations to explain such observations and study MPR model comprehensively, and we will leave it as a future direction.

VII. CONCLUSION
In this paper, we have applied Makrov chains to analyze the theoretical system performance for delay-constrained ALOHA and CSMA systems.Since the number of states of Markov chains grows exponentially, the exact approach can only be applied for small-scale networks.We have thus exploited the structures of ALOHA and CSMA protocols and proposed a learning-based low-complexity approximate approach.Our numerical results have shown the effectiveness of our proposed approximate approach.We have further used this approximate approach to compare ALOHA and CSMA for a broad number of system settings and summarized the conditions under which each of them outperforms the other one.We have also summarized the different settings under which ALOHA or CSMA is better as shown in Fig. 9.In the future, it is interesting and important to relax the frame-synchronized traffic pattern.Comparing ALOHA and CSMA for different settings where the red bullet (•) means that CSMA outperforms ALOHA and the blue bullet (•) means that ALOHA outperforms CSMA.We can see that for L = 1, ALOHA is better when N is small, and CSMA is better when N is large; for L > 1, ALOHA is better when N is small and D is large, and CSMA is better in other cases.

Fig. 1 .
Fig. 1.An example of the system model with D = 3 and L = 2.

Fig. 2 .
Fig. 2.An application of our system model.

and p c = f 3 (
N, D, L).The learning process for p b and p c is similar to that for p s in ALOHA as shown in Sec.IV-A.Now given D, L , and a large N , we can use our learned model to predict p b and p c and then construct a single-user Markov chain to obtain N • R Approx CSMA (p b , p c ), which serves as an approximate value of R * CSMA (N, D, L).

= 3 Fig. 7 .
Fig. 7.The system timely throughput of delay-constrained ALOHA and CSMA under MPR channel model.

Fig. 8 .
Fig. 8.The average delivery time of CSMA and ALOHA when N = 4 and L = 4.

L = 5 Fig. 9 .
Fig.9.Comparing ALOHA and CSMA for different settings where the red bullet (•) means that CSMA outperforms ALOHA and the blue bullet (•) means that ALOHA outperforms CSMA.We can see that for L = 1, ALOHA is better when N is small, and CSMA is better when N is large; for L > 1, ALOHA is better when N is small and D is large, and CSMA is better in other cases.

TABLE I THE
COST VALUE FOR PREDICTING PARAMETERS IN ALOHA AND CSMA UNDER DIFFERENT MACHINE LEARNING APPROACHES.
ALOHA (resp.CSMA) system, we use the single-user Markov chain parameterized by the best-learned success probability ps (resp.thebestchannel-busy probability pb and the best-learned collision probability pc ) to obtain the timely throughput, N times of which serves as the predicted (approximate) value for the theoretical system timely throughput of the multiuser ALOHA (resp.multi-userCSMA)system.The results are shown in TableII.As we can see, our prediction is very accurate with mean-square error in the order of 10 −4 for both ALOHA and CSMA.This shows the effectiveness of our approach.