IoT Traffic Shaping and the Massive Access Problem*

IoT gateways aim to meet the deadlines and QoS needs of packets from as many IoT devices as possible, though this can lead to a form of congestion known as the Massive Access Problem (MAP). While much work was conducted on predictive or reactive scheduling schemes to match the arrival process of packets to the service capabilities of IoT gateways, such schemes may use substantial computation and communication between gateways and IoT devices. This paper proves that the recently proposed "Quasi-Deterministic-Transmission-Policy (QDTP)" traffic shaping approach which delays packets at IoT devices, substantially alleviates the MAP: QDTP does not increase overall end-to-end delay and reduces gateway queue length. We then introduce the Adaptive Non-Deterministic Transmission Pol-icy (ANTP) that requires only one packet buffer at the gateway, offering substantial QoS improvement over FIFO scheduling.


I. INTRODUCTION
The number of devices on the Internet may reach 30Bn by 2023 [1] with the majority being low-cost machine-type devices [20] communicating with base stations or IoT Gateways (IoTGW). Such large systems can cause a form of congestion [19] known as the "Massive Access Problem" (MAP) which has has often been addressed with reactive techniques that attempt to adapt to incoming traffic [23], [27], [31]- [33]. Despite the difficlty of managing distributed accesses [5]- [7], the cooperation among transmitters to improve channel usage efficiency and QoS has also been considered [16], [17].
Another approach [37]- [39] uses proactive prediction of IoT traffic patterns, such as Joint Forecasting-Scheduling (JFS) and Priority based on Average Load (PAL), allocating channel resources to IoT devices based on traffic characteristic [42], [43]. "Randomization of Generation Times" (RGT) [44] can be implemented at each device to improve JFS, with PAL and the Earliest-Deadline First algorithm. However, scheduling requires additional computation and time consuming Machine *Research supported by the EU H2020 Program under the IoTAC Research and Innovation Action, with Grant Agreement No. 952684. Learning (ML) is needed to analyze arrival and service characteristics, and the best schedules can incur computation and communication costs.
The simpler traffic shaping, widely used in networks [2], can reduce latency, and optimize the bandwidth available to certain packets by delaying other packets. Typically applied at the source or edge, it is defined by the International Telecommunication Union [3] as a scheme which "alters the traffic characteristics of a stream of cells ... to achieve a desired modification of those traffic characteristics, in order to achieve better network efficiency whilst meeting the QoS objectives or to ensure conformance ... with the consequence of increasing the mean cell transfer delay." Though traffic shaping is accomplished by delaying packets, it is sometimes confused with "traffic policing" which includes preventive packet dropping [4], while traffic shaping can result in more delay for some packets that may cause loss of data in finite buffers. Both techniques have been discussed for ATM [9], [12], IP [11], [13], [14], and Sensor Networks where traffic shaping with adaptive routing was also studied [21]. Recent work [22] addresses traffic shaping for large numbers of IoT Devices (IoTD) that forward packets to a single Gateway (IoTGW) with the Quasi-Deterministic-Transmission-Policy (QDTP) which delays packets at the IoTD at most D (fixed) time units, obtaining more deterministic arrivals within given time slots at the IoTGW; experiments with IoT data [47] show QDTP's effectiveness to alleviate the MAP and improve QoS.
In the present paper we prove that ANTP does not increase the overall end-to-end delay of packets as compared to an ordinary FIFO policy, including the traffic shaping delay and the delay at the IoTGW. We modify QDTP to propose the Adaptive Non-Deterministic Transmission Policy (ANTP) which shapes packet delay to match service times at the IoTGW, and prove that ANTP reduces the delay and reduces the packet queue length at the IoTGW to no more than one packet, hence also reduceing packet loss probabilities due to finite buffers.
In the sequel, Section II discusses the notation that is used and recalls Lindley's equation regarding the waiting time of the First-In-First-Out (FIFO) queue. Then, Section II-A details the QDTP algorithm [22], and develops an equation that resembles Lindley's equation for the total time spent by a packet in the IoTD (device) before being forwarded to the IoTGW. Assuming a Poisson process for the generation of IoT packets across all the IoTDs, in Section II-B we also derive new results concerning the probability distribution (and the average) of the number of IoTD's (i.e. IoT devices) that are witholding packets in the QDTP delay in steady-state.
Section III introduces the Adaptive Non-Deterministic Transmission (ANTP) policy in which the traffic shaping delay depends on individual packets and their service times at the gateway, which is practically feasible when service time is a function of (e.g., proportional to) known packet length. We prove that the ANTP delay also satisfies an equation structurally similar to Lindley's equation, and establish the stability condition. A formal analysis of ANTP end-to-enddelay is conducted, showing that each sample path of ANTP does not increase total delay as compared to a FIFO system that does not use ANTP. Also ANTP strongly reduces the need for buffer space at the gateway. The paper ends with conclusions and a discussion of further topics for research.

II. THE ORDINARY FIFO QUEUE AND QDTP
We consider a sequence of packets (or customers C n , n ≥ 0 characterized by an infinite sequence of variables: {(a n , S n : n ≥ 0}, which are the intrinsic characteristics of each successive packet that is created at an IoT node or source of packets. For each successive packet: • The 0 = a 0 ≤ a 1 ≤ a 2 , ... are the packet creation instants instants at the IoT nodes being considered; we also define the intervals between the creation times of packets A n+1 = a n+1 − a n . Note that the packets are created at any of the IoT nodes, so that each a n is a time stamp and successive packets may or may not originate at the same IoT node. • In order to shape the traffic, the IoT node may delay the transmission of a packet for some time using the QDTP or A-QDTP policy. • After this traffic shaping delay, the n − th packet is transmitted and arrives instantaneously at the IoTGW. Thus we are assuming that the transmission time from its source IoT node to the IoTGW is negligible, as compared to the other times of interest, such as the service (or processing and forwarding) time S n . • S n is the processing time of the n − th packet by the IoTGW, and at the IoTGW all packets are served in First-In-First-Out (FIFO) order. Thus Figure 1 describes the timing at the IoTGW when there is no traffic shaping.
In certain cases, for instance when the packet processing and forwarding time at the input gateway is proportional to the length of the packet, S n may be proportional to packet length. Assuming a simple, the well-known "Lindley's Equation" [45], [46], [48] gives us a recursive formula for computing the pure waiting time (before processing) of the successive packets when IoTD forwards each packet to the IoTGW as soon as it assembled (at time a n ), and the IoTGW processes packets in FIFO order: where for a real number X, we denote Thus if the IoT gateway acts as a FIFO processor and forwarder, the packet that arrives to it at time a n will have been processed and forwarded downstream out of the IoTGW, towards (for instance) a local edge server or a Cloud server, at time d n = a n + L n + S n . d n = a n + L n + S n Lindley's Equation: L n+1 =[L n + S n -A n+1 ] + A n+1 = a n+1 -a n n-th Packet Departure Instant Towards Edge Server or the Cloud d n n-th Packet Arrival Instant from the IoT Device (IoTD) a n L n S n Fig. 1. Schematic representation of a FIFO forwarding node. The packet that arrives at instant an waits in the buffer until it arrives at the head of the queue. It then receives service of duration Sn and leaves the server at time dn. Its waiting time is Ln, so that dn = an + Ln + Sn.
For the system without the QDTP policy: is the ordinary "response time" which includes both the waiting time and the service time.

A. The QDTP Policy
On the other hand, the Quasi-Deterministic Transmission Policy (QDTP) introduced in [22], is defined via a sequence of forwarding or release times t n for each C n , so that the customer arriving at a n is only released at some time t n into the FIFO queue for servicing, with t 0 = a 0 = 0, and: where D ≥ 0 is a constant. Obviously if D = 0 we are back at the ordinary FIFO service.
Lemma 1 The waiting times of packets at the IoTD (devices) using QDTP satisfy an expression similar to Lindey's equation: Furthermore, if the inter-arrival times {A n , n ≥ 1} are a sequence of independent and identically distributed random variables and E[A n ] > D, then we have the "stability result": lim n→∞ W n = W, in probability distribution. (6) where P rob[W < ∞] = 1.
Proof Note that the the departure instant of customer C n+1 from the QDTP delay unit is given by: = a n+1 if a n+1 ≥ t n + D n , or a n+1 + W n+1 = a n + W n + D if a n+1 < a n + W n + D, and a n+1 + W n+1 = a n+1 if a n+1 ≥ a n + W n + D, completing the proof of (5). On the other hand, the result (6) follows from the well known property of the Lindley equation for the GI/D/1 queue (deterministic service) [45] which is identical to (5).

B. QDTP with Poisson Arrivals and Deterministic Delays
As an interesting and illustrative special case, suppose that the incoming traffic is Poisson with arrival rate λ, and that D is constant as in [22]. Now W n+1 in (13) is identical to the waiting time of the n − th customer of an M/D/1 queue that has Poisson arrivals and constant service times, i.e. the {A n+1 , n ≥ 1} are independent and exponentially distributed random variables with parameter λ. However the key difference is that QDTP only has a waiting time, and no "service time" since as soon as the delay W n ends, the packet is released into the second queue for servicing, as shown in Figure 2 which covers the case where each of the QDTP delay D n may be distinct, which we call the Adaptive QDTP traffic shaping scheme which will be discussed in Section III.
Thus we can now compute the distribution of the random variable N , which is the number of packets waiting in steadystate at all of the IoT devices (the IoTDs) which are using the QDTP traffic shaping policy. We do this by relating N to the number M of customers in the M/D/1 queue with Poisson arrivals and constant service times in steady-state [48], see [46] eqn. (2.8), since the n − th packet leaves an IoTD to enter directly into the IoTGW input (see Denoting π k = P rob[N = k], p k = P rob[M = k], k ≥ 0, and defining the generating functions: which after some calculations yield: Π(z) = (p 0 + P (z))(z − 1) z , P (z) = p 0 e λ(z−1)D (z − 1) z − e λ(z−1)D . From queueing theory we know that for the distribution {π k , k ≥ 0} to exist we need the condition that 0 ≤ 1 − π 0 < 1. We also know that when the distribution exists it follows that 1 − π 0 = λD [48], which guaranties that the distribution {p k , k ≥ 0} also exists, since p k is obtained from (7).

C. Average Number of Packets Waiting at their IoTDs
With QDTP some of the packets will first wait at their "home" IoT devices before they are forwarded to the IoTGW. In the case of Poisson arrivals, the above analysis allows us to estimate the average number < N > that wait at their different IoTDs, from the average < M > of the number M in the M/D/1 queue at steady state. The computation is simple, because from (7) we have: < M > is available from the well-known Pollaczek-Khintchine formula [46], [48] applied to the M/D/1 queue, hence: and we know that we must have D < 1 λ . However more than that, we know that the average interdeparture times D n = E[t n+1 − t n ] of packets from the QDTP delay are given by: since when λE[A] < 1, both W n+1 and W n converge to the same W in distribution, and hence have the same mean.

III. THE ADAPTIVE QDTP POLICY: ANTP
Let us now pursue the ANTP case where the individual QDTP delays may depend on other system parameters, and hence we allow D n to vary with each value of n, so that the departure instants from the IoTDs to the gateway IoTGW are: and each D n can be chosen as a function of the parameter S n . Indeed, when we examine the data shown in Figure 3 from a publicly available source [47], we see that the length of IP packets emanating from IoT devices have substantial a n t n d n =a n +W n +V n +S n W n+1 =[W n +D n -A n+1 ] + V n+1 =[V n +S n -T n+1 ] + t n =a n +W n A n+1 = a n+1 -a n T n = t n+1 -t n =A n+1 +W n+1 -W n S n W n +V n Total Response Time R n * = W n + V n + S n n-th Departure Instant to Edge Server or the Cloud d n regularity so that the service time parameter S n can be estimated accurately when the IoTGW forwards the arriving packets to Edge Servers or the Cloud. The ANTP delay D n at the IoTDs can then be chosen to be smaller than the time needed to process the packes at the IoTGW. When D n is the random variable adefined in (1), and the waiting time from a n until the packet C n is actually placed in the gateway's input queue is W n : W n = t n − a n , f or AN T P we have : Lemma 2 The successive waiting times of packets in the ANTP delay unit satisfy the relation: Proof The proof is identical to that of Lemma 1, since the departure instant of C n+1 from the ANTP delay unit is given by: t n+1 = t n + D n if a n+1 < t n + D n , and = a n+1 if a n+1 ≥ t n + D n , or a n+1 + W n+1 = a n + W n + D n if a n+1 < a n + W n + D n , and a n+1 + W n+1 = a n+1 if a n+1 ≥ a n + W n + D n ,

A. Total Response Time with ANTP
From the analysis in the previous section, the total response type of the n−th packet C n with QDTP can now be computed as where W n is given by equation (13), and V n is the waiting time in the FCFS queue that is entered by the packet after the delay in the QDTP. Defining T n+1 = t n+1 − t n , n ≥ 0 and applying Lindley's equation to the FCFS queue that is entered by each successive packet {C n }, at the instants {t n = a n + W n , n ≥ 0} so that T n+1 = A n+1 + W n+1 − W n , we obtain: QDTP does not increase the delay experienced by packets, if we can show that R * n defined in (14) is less than or equal to R n defined in (3). Since S n is an additive term in both expressions, we only need to compare the waiting time L n with W n + V n , namely: Theorem 1 If we D n ≤ S n for all n ≥ 1, then it follows that W n + V n ≤ L n . Hence the ANTP policy does not increase the total response time for each customer or packet as long as D n ≤ S n since Proof: The proof is by induction: • The base of the induction is 0 = W 1 +V 1 = 0 ≤ L 1 = 0. • The step of the induction is to assume that the statement is true for some n > 1: W n + V n ≤ L n , f or some n ≥ 1, and and prove that it is true for n + 1, i.e. we must prove that: To prove (19) we use V n ≤ L n − W n and have: There are two cases to consider, A) and B): so that using the induction step W n + V n ≤ L n , we have proved for case A) that Since V n ≥ 0 and S n ≥ D n we know that: and as a consequence: In addition, since the delay W n at the IoTD is non-negative and the total delay at IoTD plus the IoTGW (V n ) is no greater than the delay of an ordinary FIFO gateway L n , the delay and buffer queue length at the IoTGW will be reduced. This completes the proof of Theorem 1.

B. Delay and Queue Length Bounds for the IoTGW
Let us now define G n = V n + S n , the total delay incurred at the IoTGW by the n − th packet that was generated by the IoTD device at time a n , and let G = lim n→Gn when the limit exists. From Theorem 1, we know that if D n ≤ S n then: Since W 1 = L 1 = 0, if D n = S n we obviously have: As a consequence, the following follows from (20) and (21): Theorem 2: If D n = S n , and S = lim n→ S n , then G n = V n + S n ≤ L n − W n + S n ≤ S n , G ≤ S, (21) meaning that the IoTGW buffer contains at most one packet at a time, showing the effectiveness of ANTP traffic shaping.

C. ANTP in the Poisson Case
As a consequence we obtain rigorous performance estimates for the case of Poisson arrivals of rate λ using the results of Section II-B, when the service times S n are independent and identically distributed with general distribution with mean E[S n ] and squared coefficient of variation C 2 S . By Little's Law [46], B AN T P the average number of packets at steady-state in the IoTGW buffer is B AN T P ≤ λE[S n ] < 1. It can be compared with the steady-state average number B F IF O of packets in the IoTGW when the ANTP algorithm is not used and all packets arrive directly to the buffer from the IoTD without delay. B F IF O is given by the Pollaczek-Khintchine expression for the average number of packets in the IoTGW buffer acting as a a First-In-First-Out queue, leading to the figure of merit F AN T P for ANTP: and F AN T P → 1 when ρ → 1.

IV. CONCLUSIONS
The ANTP traffic shaping policy for IoT devices that transmit packets to an IoTGW has been introduced, and its stabiity conditions have been obtained. More importantly, we have shown that both QDTP and ANTP shape the traffic flowing from IoT devices to a IoT gateway by delaying packets at the IoTD without increasing the overall end-to-end packet delay.
We also show that ANTP will limit the gateway buffer occupancy to at most one packet, reducing significantly buffer queue lengths and delay at the IoTGW itself.
It will be interesting to consider how traffic streams from large numbers of independent IoTDs can interact efficiently in this framework.