Optimization of Wi-Fi Direct average time to discovery: a global channel randomization approach

The main objective of this work is to propose concrete time reduction strategies for discovery of Wi-Fi Direct in Android. To achieve our goals, we perform a fairly general mathematical modeling of the discovery of devices using Poisson processes. Subsequently, under asymptotic invariance hypotheses of certain distributions, we derive formulas for the expected time to discovery. We provide sufficient condition for fast convergence to an invariant distribution and determine key decision parameters (jumps intensities) that minimize the average time to discovery. We also propose a predictive model for rapid evaluation of these optimal discovery parameters. Experimental tests in an emulator are also conducted to validate the theoretical results obtained. A comparative performance study is done with some optimization approaches from literature. Compared with existing methods, the improvement of the average time discovery we obtained with the proposed method is above 98.34%\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$98.34\%$$\end{document}.


Introduction
Mobile Ad Hoc Networks (MANETs) are infrastructure-free networks developed to meet the needs of a variety of applications where infrastructure-based wireless networks are difficult to deploy and maintain (Demir et al. 2017). MANETs represent a promising way to provide communication between the many mobile Optimization of Wi-Fi Direct average time to discovery: a global… mechanisms at the departure of nodes (Wi-Fi r), and facilitating interoperability between networks (Wi-Fi u).
Following Ndih et al. (2015) and references therein, 2.4 GHz band remains the most used unlicensed band in the world.
In particular, most of the Wi-Fi Direct products work with the IEEE 802.11 a/b/ g/n standards and communicate both in the 2.4 GHz and 5 GHz frequency bands (Demir et al. 2018(Demir et al. , 2017. Wi-Fi Direct uses the principle of communication grouping where one of the device plays the role of owner(GO) and the others are customers (GC) all connected to the GO (Alliance 2016).
According to its technical specification (Alliance 2016), the formation of a communication group takes place in five steps: (1) the discovery of device, (2) the discovery of services, (3) the negotiation of the role of owner, (4) the setting up of security parameters and (5) the configuration of IP addresses. Unfortunately, The implementation of Wi-Fi Direct in the Android operating system presents several limitations. There are several works done in order to improve the training procedure groups, especially at step (3) (Menegato et al. 2014;Chaki et al. 2015;Cherif et al. 2017;Jahed et al. 2016;Khan et al. 2016;Liu et al. 2016;Li et al. 2020;Shahin and Younis 2015). However, several empirical studies carried out to evaluate the Wi-Fi Direct technology on Android, show that the discovery of devices step takes more time in the group formation process presented above (Camps-Mur et al. 2013;Conti et al. 2013;Garcia-Saavedra and Serrano 2013). A long time to discovery and high latency have an impact on the quality of service, specifically those that have time transmission constraints. Connection cuts in mobile networks can also lead to high latencies. Moreover, the departure of a device from one point of access to another (handover) can lead to overall latency of the scan. Thus, reducing the time to discovery of devices and maintaining low latency during an ongoing session is a critical problem to be resolved in order to improve the quality of service.
Some works have been carried out on the study of the discovery process in order to optimize the scanning times to discover access points to which device can connect. Shin et al. suggested in Shin et al. (2004) the use of the binary mask channels to decide which channel to scan. The mask is updated when the device passes from one access point to another. It is initialized to 1 for all channels to show that all channels are to be scanned. During a passage, the device builds a new mask for the next step. This mask contains the value 1 for non-overlapping channels and those on which the response probes were received. The mask contains 0 for channels on which there is no activity during the previous scan. So only the channels marked with 1 are scanned if a response probe has not been received in these channels. The technique of mask reduced time to discovery of about 43% relative to the method described in the specification. The drawback of the mask approach is that the masks are built incrementally whenever the number of passages between access points increases. In another work in Velayos and Karlsson (2004), the aim was to reduce values of the minimum and maximum time of reception of the probes on a channel during the scan. Unfortunately, this technique does not guarantee that the process of discovery will always unfold successfully. In Castignani et al. (2011), the authors proposed an adaptive technique which suggests to randomly change the channels following two sequences (the first for non-overlapping channels and the second for 1 3 other channels), and to adapt the times on a channel according to the information collected on the previous channel. Clearly, the scanning time of the next channel is increased when an access point fails to be found on the current channel, and the scanning time is reduced otherwise. The limits of this work come mainly from the fact that the results obtained depend on the deployment of the access points and the adaptation function used. Sun et al. have analyzed the discovery process between two Wi-Fi Direct devices (Sun et al. 2016). They proposed and validated via simulations on NS-3, a model of the discovery process based on Markov chains. The latter performed a 72% reduction in Wi-Fi Direct time to discovery through the Listen approach Channel Randomization (LCR) consisting of randomly selecting the listening channel from the three non-overlapping social channels. The LCR approach focuses optimization only on listening and not on the scan. In addition, it does not take into account the implementation of Wi-Fi Direct on Android and does not give any specific recommendations for implementation.
The main objective of this work is to reduce the time to discovery of Wi-Fi Direct in Android, in order to meet the time requirements of real-time applications. In order to reach our objectives, we proceed to a Semi-Markovian modeling of the discovery process via Poisson processes whose parameters are then optimized. As Wi-Fi a/b/g are the oldest 1 , we expect them to be more prevalent among mobile device users. Moreover, Wi-Fi a/b/g present the sufficient features to study theoretically without loss of generality, the discovery problem which remains actual in more recent Wi-Fi standards. Thus, we proceed to the evaluation of our proposals by simulations on Wi-Fi a/b/g standards. The rest of the work is organized into four main sections. In Sect. 2, we review the principles and standards for discovery using Wi-Fi Direct. In Sects. 3.1 and 3.2, we propose different mathematical models for the discovery process whereas Sect. 3.3 deals with the optimization of discovery parameters through an explicit process. The parameters are calculated for some examples and simulations studies are carried on in Sect. 4. Section 5 is devoted to the conclusion and some immediate perspectives.

Discovery mechanism in Wi-Fi Direct Android
The Wi-Fi Direct device discovery procedure consists of scanning all traditional communication channels of Wi-Fi (IEEE 802.11) and the listening phase. Formally, a device that wants to discover devices in its vicinity must first scan all channels according to the algorithm used in 802.11 standards to identify peer-to-peer groups already formed IEEE (2012). If groups are found, the device will try to integrate one of the groups chosen by logging on to the owner. Otherwise, it will look for other Wi-Fi Direct devices that are in the discovery phase. In this phase, the device 1 3 Optimization of Wi-Fi Direct average time to discovery: a global… alternates between listening and searching states (Alliance 2016). In the search (or scan) state, the device randomly chooses one of the following three types of scan: • The P2P SCAN SOCIAL where only the three social channels (1, 6 and 11) are scanned; • The P2P SCAN SPECIFIC for which the scan is done on a single channel chosen randomly on all channels; • The P2P SCAN SOCIAL PLUS ONE where the scan is done on all three social channels plus an extra channel chosen at random from all the channels.
Based on the type of search, the device will scan each channel sequentially by transmitting a request probe, and waiting for to receive response probes. This waiting time depends on the Wi-Fi pilot used by the device. It can vary depending on the channels (MadWi-Fi 2 ) or can be fixed for all channels (ath5k 3 ). In the listening state, the device listens for a random time during which it can receive a request probe and send the corresponding response probe. The listening channel is chosen at random from the three social channels (1, 6 and 11) at the start of the discovery phase and remains unchanged until the end of this phase. The duration of each listening state is given by the formula: 4 with R ∈ ℕ , = 3 and = 1 respectively denoting the maximum and minimum length of the interval of times to discovery. According to the values of and , T l should be 100, 200 and 300 Time Units (TU) independently of the value of R. Two devices can be with discovered if and only if they are on an appropriate channel with one in the listening state and the other in the searching state for a time long enough to allow the "handshake". Discovery can take a relatively long time for several reasons: • The progressive scan mode can prolong the search time and prevent any synchronization; • Devices can choose busy channel or channels with poor quality and hence making it difficult to receive probes; • The Random choice of listening and searching times.

Standardized discovery parameters in Wi-Fi a/b/g
There are two ways to access media over Wi-Fi: the PCF mode (Point Coordination Function) in which access to the media is managed by a base station (the access point) and the DCF mode (Distributed Coordination Function) which allows (1) T l = ( + R modulo(( − ) + 1)) × 100 Time Units equitable access to the radio channel without any centralization of the management of access. The PCF mode is made for wireless infrastructure networks while DCF mode is used in wireless networks without a fixed infrastructure (also known as ad hoc networks). PCF mode is still used, for example, for networks deployed in companies, although DCF mode is the default in the most recent WI-Fi standards. In the DCF mode, the standards define temporal variables called IFS (Inter Frame Space) which characterizes the time elapsing between sending frames. Since the radio channel (air) is shared, the technology implements the Carrier Sense Multiple Access with Collision Avoidance (CSMA / CA) algorithm (IEEE 2012), which aims to avoid frame collisions in the channel. In order to reduce collision risks, any device wanting to start a new transmission has to systematically wait a time T DIFS corresponding Distributed Inter Frame Space (DIFS). Additionally to the DIFS, the latter will wait a time T Backoff corresponding to the backoff. T Backoff is chosen as a multiple of the time slot T Slot . The number of time slots ( N CW ) is randomly chosen according to a uniform law in an interval called Contention Window which is by default [0, CW] . CW is initially equal to CW min = 31 but is doubled after each unsuccessful transmission, until it reaches the maximum number CW max = 1023 or the transmission succeeds, resulting in a return to CW min . So the backoff time ( T Backoff ) is therefore a random number drawn between 0 and CW × T Slot , on average CW × T Slot ∕2 . As soon as an activity is detected on the channel, each inactive device stops the decrementing of their backoffs to resume it only in case of channel release (deferring period). The first equipment to reach a zero backoff emits. The emission could be a request from the local device or a response from the remote device. After receiving a response, the local device wait a time T SIFS corresponding to the Short Inter Frame Space (SIFS), before it send an acknowledgment. The effective cycle of device discovery is depicted in Fig. 1. Thus, according to the CSMA/CA algorithm, the average time to handshake in an ideal environment (without interference and without noise) is given by the following relation: where • N CW is a random number for the backoff count contained in the interval [0, CW]; • T Slot is the time slot; (2) 0 = 2T DIFS + 2T Backoff + T Req + T Resp + T SIFS + T Ack The values of T DIFS , T SIFS and T Slot depend on the mode of access distributed to the media while the values of T Req , T Resp and T Ack depend on the quality of the channel, the throughput of the used standard of Wi-Fi, and the sizes of request, response and acknowledgment packets respectively. Wi-Fi Direct relies on MAC, Physical, and device standards for accessing the media. If the device is certified by several standards, it is the most recent which will be used. In Wi-Fi a/b/g, the sizes of the request, response and acknowledgment probes are in general respectively between 37 and 76 Bytes, between 37 and 46 Bytes, and 14 Bytes. Table 1 summarizes the different values mentioned above according to Wi-Fi a/b/g.

Improvements and similarities with more recent Wi-Fi standards
As presented in Sect. 2.2, the packet transmission time in DCF mode is divided into a DIFS, a Contention Window backoff time, the data payload transmission time ( T Req or T Resp ), a SIFS and the Ack frame transmission time. In the Wi-Fi a/b/g standards the throughputs are not very high (maximum 54 Mbps) and subsequently the size of the data payload transmitted should not be high. When the data payloads are small, the overhead is relatively large and inefficient due to the multiple transmissions which limit the data throughput. Moreover, the inter-frame time is not saved.
The Wi-Fi n (IEEE 802.11n standard) aims at enabling much higher throughput to provide better wireless access support for the increasing demand of the application bandwidth requirements. Two possible methods permit to meet the requirements of high throughput: increasing data rate in the physical layer (PHY), and inceasing the efficiency in the medium access layer (MAC) (Wang and Wei 2009). Wi-Fi n provides both PHY and MAC enhancements. The maximum theoretical data rate of Wi-Fi n is 600 Mbps. The Wi-Fi n can operate both in the 2.4 and 5 GHz frequency bands and it is backward compatible with 802.11a/b/g (Ravindranath et al. 2016;Siddiqui et al. 2015). Wi-Fi n applies Multiple-Input Multiple-Output (MIMO) Time of DIFS (ms) 3.4 × 10 −2 5 × 10 −2 technique at the PHY and adopts the Orthogonal Frequency-Division Multiplexing (OFDM) modulation with 20 or 40 MHz channel bandwidth. This is not the case in Wi-Fi a/b/g which use the Single-Input Single-Output (SISO) technique. At the MAC layer, Wi-Fi n implements efficient frame aggregation and block acknowledgment mechanisms to improve throughput. The frames payloads contained in the MAC Service Data Unit (MSDU) and MAC Protocol Data Unit (MPDU) are aggregated into a single Aggregated MAC Service Data Unit (A-MSDU) and Aggregated MAC Protocol Data Unit (A-MPDU) respectively before the transmission. The block acknowledgment mechanism sends a single block Ack frame in response to multiple received frames. The aggregation and block acknowledgment mechanisms reduce the overhead and improve efficiency. The throughput is also improved since longer frames may lead to better throughput than shorter frames, and a fewer number of overhead sets are used for transmission (Perahia 2008;Ravindranath et al. 2016;Wang and Wei 2009). The Wi-Fi ac (IEEE 802.11 ac standard also called Gigabit Wi-Fi) could be seen as a lateral extension of Wi-Fi n and provides a Very High Throughput (VHT) of 7 Gbps in the 5.8 GHz frequency band. The impact of 5 GHz band at the time to discovery is at two levels. A high frequency implies a higher rate of data transfer. However, it implies a small range unlike a low frequency. It also implements aggregation and block acknowledgment mechanisms at the MAC layer but the maximum A-MSDU size and maximum A-MPDU size are increased from 7935 to 11,406 bytes (excluding overhead from security encapsulation) and 65,535 to 1,048,575 bytes, respectively (Ong et al. 2011). The Multi-User MIMO (MU-MIMO) is used and the channel bandwidth can reach 160 MHz with the OFDM modulation at the PHY (Siddiqui et al. 2015).
The Wi-Fi ax (IEEE 802.11 ax standard) was developed to improve the performances of the Wi-Fi ac protocol, which has limited uplink contention-based access (Rochim et al. 2020). The key feature of Wi-Fi ax is the adoption of an Orthogonal Frequency-Division Multiple Access (OFDMA) approach where adjacent sub-carriers are grouped together into a resource unit (RU) and a sender can choose the best RU for each particular receiver (Bankov et al. 2018;Rochim et al. 2020). This allows to serve more users with reliable and consistent data flows by providing greater network capacity, higher efficiency, better performance, reducing latency, and increasing throughput. Some other features of Wi-Fi ax are the following: the aggregation and block acknowledgment are also used , the maximum data rate can noticeably reach 9.6 Gbps, the channel bandwidth is up to 40 MHz in the 2.4 GHz frequency band and up to 160 MHz in the 5 GHz frequency band.
The Wi-Fi ay (IEEE 802.11 ay standard) was developed to improve the performances of the Wi-Fi ad protocol. Wi-Fi ay applies Multiple-Input Multiple-Output (MIMO) technique at the PHY and adopts the Orthogonal Frequency-Division Multiplexing (OFDM) modulation with channel bandwidth between 2.16 and 8.64 GHz for frequency band between 58.3 and 70.2 GHz. The theoretical data rate is between 20 and 176 Gbps.
Wi-Fi n/ac/ax/ay standards use the CSMA/CA protocol. Thus, the IFS and Contention Window values are almost the same as in the Wi-Fi a/b/g standards. The main differences comes from the mechanisms implemented at the PHY and the Optimization of Wi-Fi Direct average time to discovery: a global… aggregation principle. Since Wi-Fi ax/ay are very recent there are few studies and available data on their real performances. Table 2 summarizes specifications for Wi-Fi n/ac.
Wi-Fi n/ac/ax/ay standards allow several discovery processes in parallel (MIMO) and a shorter time to handshake 0 according to Eq. (2). Although Wi-Fi n/ac/ax/ay standards have several advantages for group forming, the problem of P2P discovery remains when there is not an existing group. The problem lies here in the difficulty of the occurrence of favorable conditions for discovery: being on the same channel, one in listening mode the other in search mode, and this for the duration 0 which changes depending on the considered standard of Wi-Fi. Thus, from a theoretical point of view, it is sufficient to restrict ourselves to the simpler Wi-Fi a/b/g standards while highlighting the impact of 0 on the optimality of the choice of the discovery procedure. This is done in the rest of the paper.

The global channel randomization (GCR) discovery
The problem is that of the discovery of two devices communicating by direct Wi-Fi. Each device has to randomly choose a listening or search channel among n channels and stay in one of these two modes for a certain (random) time. The times to discovery on the channels are subject according to their quality of these, random laws to be specified. There is discovery if one of the devices is listening and the other is in search mode, all on the same channel for a fairly "long" time according to the quality of the channel. A state of the system is then an n + 5-  • i , i = 1, … , n denotes the time required to discover each other on channel i (ie the time until first device is in listening mode whereas device two is in search mode all devices being on channel i).
In a simple way, the transition from one state to another can be modeled by a semi-Markovian process S 1 , S 2 , C 1 , C 2 , T 0 , T 1 , … , T n where T 0 is the random variable corresponding to the time spent under the configuration S 1 , S 2 , C 1 , C 2 while each other T i denotes the random variable corresponding to the time to discovery on channel i. The Markov process S 1 , S 2 , C 1 , C 2 is piecewise constant and its transition matrix P has zeros at diagonal and is time inhomogeneous. We assume that the two devices operate with independent and identically distributed choices (iid) then, the sub-processes S 1 , C 1 and S 2 , C 2 are also iid. In addition, the jump times of S i and C i can be considered independent conditionally to the time of the last jump of S i , C i . The purpose of this section is to model the discovery process in different scenarios, and in particular to express the average times to discovery based on certain decision parameters. These estimates are essentially made under asymptotic invariance assumptions of certain distributions.

Modeling of jump times
In this section, we assume that the discovery on a channel i requires in addition to the constant minimal time to handshake 0,i , a random time T i ∼ E i due to the quality of the channel (ie T i = 0,i + T i , i = 1, … , n ). This case corresponds to the general situation mentioned in the Section III.C of Sun et al. (2016) except that we consider a continuous space of time. A continuous space of time is less restrictive and more realistic. Depending on whether the minimum (or average) time to discovery 5 ("time to handshake") on a channel i is 0,i , we could intuitively envisage that the processes S j , C j jump after a random time T s j ,c j bounded below by 0,c j (ie T s j ,c j ≥ 0,c j ). We will consider the relatively simple case, where the time spent in a mode (listening or searching) is a random variable T s ∶= + E s , where E s is an exponentially distributed random variable with parameter s to be specified ( E s ) and ≥ 0 is deterministic constant to be chosen suitably. Similarly, it is assumed that the time of change of channel is a random variable T c ∶= + E c , where E c is an exponentially distributed random variable with parameter c to be specified ( E c ). Therefore, we know (see Lemma 3.1) that the time to the change in the state process Similarly, cut off from n , the time that elapses between the initial time and that of the n-th jump of S i , C i ∼ Γ n, s + c , where Γ n, s + c is the Erlang law.
It is interesting to find the law of the jump times of the process S 1 , S 2 , C 1 , C 2 . This task is easier if is 0, and the sought law is E 2 s + c . However, when > 0 it turns out to be more complex. A naive reasoning would lead to choose > 0,i to increase the probability of discovery in the event of a good configuration 1 3 Optimization of Wi-Fi Direct average time to discovery: a global… S 1 , S 2 , C 1 , C 2 . However, it is unnecessary to remain in an inadequate configuration for discovery when it occurs. Unfortunately, such configurations are possible. So, instead of fixing a strictly positive lower value for , we opt for choosing appropriate values for s and c , knowing that on average the residence time in a state will be non-zero. Let us recall the following known results that can be easily proved.
Assume that U and V are independent. Then,

Modeling the time to discovery
In this section, we are interested in the process S 1 , S 2 , C 1 , C 2 , T 0 , T 1 , … , T n , in particular the transitions of the process S 1 , S 2 , C 1 , C 2 which has 4n 2 states. Even for the three social channels, the representation of the transition matrix is quite difficult (36 states). However, thanks to the assumption = 0 , the systems S 1 , S 2 , C 1 , C 2 and S 1 , S 2 , C 1 , C 2 are independent. Almost surely, the jump times of S 1 , S 2 and C 1 , C 2 do not coincide. According to Lemma 3.1 the probability that a jump of S 1 , S 2 , C 1 , C 2 coincides with that of S 1 , S 2 is equal to s s + c .
We start by studying the transition matrix P s of S 1 , S 2 . For ordered states (0, 0) , (0, 1) , (1, 0) and (1, 1) we have Again focusing on the two ordered events S 1 = S 2 and S 1 ≠ S 2 , the transition matrix scaled down is and it has as invariant distribution 1 2 between c and s is given by Now let us study the process C 1 , C 2 which has n 2 states which can be classified in the lexicographic order defined by (a, b) ≤ (c, d) if a < c or a = c and b ≤ d . The transition matrix P c of C 1 , C 2 is of dimension n 2 × n 2 , but it can be reduced by simply checking whether or not C 1 = C 2 . If c,r denotes the distribution of the initial choice of channel by each device, then the initial probability of having C 1 = C 2 is ∑ n i=1 2 c,r (i) . Thus, we restrict ourselves to 2 × 2 transition matrix (corresponding in order to the states C 1 = C 2 and C 1 ≠ C 2 ) given by where • P c which denotes an n 2 × n 2 stochastic matrix satisfying

3
Optimization of Wi-Fi Direct average time to discovery: a global… with P c,n a zero diagonal n × n stochastic matrix describing the transitions of a process C i , i = 1, 2 (when the process S i is constant); • u 0 denotes a line vector 1 × n 2 such that • u 1 denotes a line vector 1 × n 2 such that The invariant distribution of P c,r is By observing the structures of u 0 , P c and u 1 , we notice that u 0 P c u T 1 = 1 = u 1 P c u T 0 . So the invariant distribution of P c,r is 1 n n − 1 n . An analysis of P c,r shows that it has two eigenvalues, namely 1, and 1 − c (n − 1) s + c . Thus, if we wish to accelerate convergence towards the invariant distribution 1 n n − 1 n , we must have n as small as possible (keeping in mind that n ≥ 2 ) or take c as large as possible. Indeed, the needed convergence is as faster as the absolute value of the eigenvalue 1 − c (n − 1) s + c is smaller.
Proposition 1 Let us assume that at the initial time the probabilities of having S 1 ≠ S 2 and C 1 = C 2 are 1 2 and 1 n , respectively. Assume further that the initial distribution of the choice of channel for each device is the invariant distribution c associated with the matrix P c,n .The number of jumps N necessary for a discovery after initialization follows a geometrical law Proof The result is essentially based on the invariance of the probabilities of having S 1 ≠ S 2 , having C 1 = C 2 and the probability of choosing a channel. ◻

Proposition 2
We consider the hypotheses of Proposition 1. Then the following statements hold.
(i) The conditional law of the time T that separates two jumps knowing there is no discovery is given by the density Optimization of Wi-Fi Direct average time to discovery: a global…

(ii) Conditionally to a success of discovery between two jumps, the time T which separates them follows a law having density and
Proof Let and (i) By applying Bayes rule and knowing that there is a failure of discovery with probability 1 when t < 0 + T , we have It follows that the probability density is

3
Optimization of Wi-Fi Direct average time to discovery: a global… (ii) Applying Bayes rule once more and using the fact that there is a success probability 0 when t < 0 + T , we have We deduce the density In addition, we have ◻ Under the conditions of Proposition 1, the expected value of the time to discovery is Indeed, for the calculation of the expected value of the time to discovery, we consider the average number of failures, the average time between two jumps conditional to failure as well as the average time between two jumps conditional to success. The time actually used for the discovery between two jumps being 0,i + T i , we can ignore the possible surplus of time. Thus, we do not take into account the additional time 1 2 c + s which corresponds to the average time of mode change.
Theorem 3 Assume the conditions of Proposition 1 and also suppose that ∀i = 1, … , n, 0,i = 0 , i = , c = s . Then the expected value of time to discovery is given by

3
Optimization of Wi-Fi Direct average time to discovery: a global… In addition, there is at least one value of s which guarantees the minimum value of the expected value of the time to discover.
Proof The first part of theorem follows from Proposition 1 and Eq. ( 4). Because g is continuous and lim x→{0 + ,+∞} g(x) = +∞ , we can deduce the existence of at least one global minimum of g on ℝ * + . ◻ The hypotheses of Proposition 1 are not generally satisfied at the start of the process, but they are asymptotically. Thus, the rapid convergence of the subprocesses of the choice of mode, and channel selection is an essential criterion for the usability of the results of Theorem 3.

Determination of optimal discovery parameters
We consider the case of the exclusive use of social channels. However, the formulas considered remain general for a possible application to any number n of channels. It has already been established from relation (3) that it is better to have s = c .
One of the first parts of optimization is to maximize the probability that both devices are found on the same channel by choosing in an adequate way the stochastic matrix of individual channel change P c,n . Despite the fact that the choice of the matrix P c,n does not influence the asymptotic behavior P c,r , taking into account the values 0,i ( i = 1, … , n ), it seems better to adopt Indeed, the channel with a shorter time to handshake is more attractive with regards to time for discovery. One obtains c by simply solving Once the matrix P c,n has been determined with its invariant law c , the next challenge is to minimize the average time to discovery according to (4).
Having no overview of the 0,i ( i = 1, … , n ), we will consider them all equal for the numerical implementation as in Theorem 3. We can observe that when all 0,i are equal, then c is the uniform distribution. The determination of i ( i = 1, … , n ) is done by considering the packet reception rate. The necessary number of trials allowing the reception of packet follows a geometric law with Considering the case of exclusive use of social channels, we have calculated the ranges of values of T Req , T Resp , T Ack , 0 according to the types of Wi-Fi. The results of this calculation are given according to Table 3.
Numerical results of calculations of the ranges of s and associated average theoretical time to discovery (TTD) are contained in Table 4. The optimization is done by combination of golden section method and gradient method (Karmanov 1977;Luenberger and Ye 1984). The calculations are done only for Wi-Fi a/b/g according to the data in Table 3 because they are more difficult for Wi-Fi n/ac. Indeed, smaller values of 0 correspond to bigger values of s . Thus, we will proceed later by extrapolation.   Figure 2 graphically shows the functional relation between the average time to discovery and s depending on 0 and PRR. We can observe the strictly convex nature of that relation which shows the uniqueness of a minimum average time to discovery. That time increases with respect to the time to handshake ( 0 ) while it decreases with respect to the quality of the channel (PRR). Figure 3 illustrates the dependence of the optimal value of s with respect to 0 . One observes overall that s would be a decreasing function of 0 . It means that the longer the time to handshake, the higher the frequency of change of channel.
A statistical regression analysis using R software shows with a P-value of the order of 2.689 × 10 −10 and adjusted R 2 s of around 99.36% , that the relation between s and 0 is close to the log-linear form The parameters a and b of (8) are very significant 6 ( Table 5).
The interest of an approximate model such as (8) relies on the ease of adaptation of the potential variation of 0 . Indeed, the explicit computation of s at a high frequency might require time and energy which are costly to devices with limited resources. Applying model (8) to Wi-Fi n/ac we get Table 6.
Tables 4 and 6 show that an adequate choice s leads to theoretical performances that significantly better than the one announced in the literature. According to the study (López et al. 2016), the time to discovery was difficult to predict but, the discovery and association cumulative time is around 21 seconds. The current work suggest more precisely that the time to discovery can be between 20.143 milliseconds and 0.234 seconds depending on the choice of s and the quality of the channel.

Simulation of the discovery process using OMNET++ emulator
In this section, we are interested in evaluating the solution we proposed before. Although, testbeds are very important, they have the disadvantage of being influenced by uncontrolled and probably unknown factors. This does not permits to efficiently evaluate the intrinsic contribution of the proposed solution. Thus, using the OMNET ++ emulator (Objective Modular Network Testbed in C ++), we perform simulations of the discovery process according to the GCR approach in each of the cases considered, to estimate the empirical means of times to discovery, and to make comparisons with theoretical expected values. It is also about simulating the discovery processes as implemented in the literature, to implement these same processes with the LCR proposal in Sun et al. (2016), and to make a global comparative study. The implemented protocols are given in Algorithm 1, Algorithm 2 and Algorithm 3. For each of the methods and each of the cases, we performed 1000 simulations. The averages of the times to discovery (TTD) simulations for the different types of Wi-Fi and the different characteristic times to handshake are illustrated in Fig. 4. Different scales have been used to easily display the average times to discovery (a unit of 15ms for LCR case and a unit of 40ms for the specification).
As we can observe in Fig. 4, the time to discovery increases with the time to handshake ( 0 ) and decreases with the quality of the channel (PRR). When PRR = 1 , the GCR reduces the average discovery time by 96.76% compared to the LRC, and by 98.89% compared to the specification. When PRR = 0.5 , the GCR reduces the average discovery time by 95.10% compared to the LRC, and by 98.34% compared to the specification. The comparison between the methods is also evaluated by an analysis of variance and a Tukey Honest Significant Test Differences with a 95% confidence level as displayed in Table 7.
From Table 7, no non positive value appears in the confidence intervals of the mean differences of time to discovery. This means those differences are statistically positive. As stated in Sun et al. (2016), the Listen Channel Randomization is better than the current specification with a reduction of average discovery time by 65.93% . However, the Global Channel Randomization outperforms the LCR.

Conclusion
The problem addressed in this work is that of minimizing time to discovery between two devices wishing to communicate by Wi-Fi Direct. Indeed, the time to discovery in addition to being an indicator of quality of service has an influence on energy consumption. The different Wi-Fi specifications provide a general framework for discovery protocols, but their implementations vary from one manufacturer to another. Since this variability has an impact on the time of discovery, we propose as in Sun et al. (2016) a systematic and optimal approach to discovery. The general principle is the switching of channels and the change of mode all in a random fashion. However, subject to the laws of change, we recommended the computation of the optimal parameters of these. In this paper, we adopt the formalism of Poisson processes with constant intensities for channel and mode change. We explicitly determine the expression of the average time to discovery as a function of the time to handshake and the quality of the channels. Thereafter, we showed that there exists an optimal set of parameters for the laws of mode or channel change. In particular, the change of mode must be as frequent as the change of channel. We numerically determined these parameters for some values of time to handshake contained in intervals defined according to Wi-Fi technologies. We also offered a predictive statistical model for rapid evaluation of optimal discovery parameters in the event of a change in context. Finally, a thousand of experimental tests in the OMNET ++ emulator are performed, each with our proposition (GCR), with the LCR approach in Sun et al. (2016) and that of the specification. According to the results of the statistical analysis, the GCR approach produces on average shorter discovery times, followed by the LCR method which is itself better than the specification ( 65.93% of improvement following Sun et al. 2016). Compared with the specification, the improvement of the average time discovery we obtained with the GCR method is above 98.34%.
Despite the promising results of this work, there is still a lot to do. Among other things, we should consider the more general case, in which time between successive jumps is bounded from the left by a positive number > 0 . It would also be interesting to consider the case where the intensities of changes vary over time as a function of previous discovery trials. This could improve the work in Castignani et al. (2011). Finally, the laws of choice of changes may be generalized or replaced by other laws in order to see if we obtain better performances.

Appendix A: Algorithms
Algorithm 1 : P2P discovery according to technical specification DevSet = {1, 2} /* the set of devices */ ChanSet = {1, . . . , n} /* the set of devices */ LT Set = {100, 200, 300} /* the set of listening times in T U = 1024µs */ Choose a listening channel C i ∈ ChanSet Choose the maximal scanning time T s for (i ∈ Devset) do repeat Choose uniformly randomly a maximal time of listening T l,i Try a handshake starting by listening on C i at most during T l,i if (The discovery is not achieved) then C s,i = 0 while ((The discovery is not achieved) and (C i < n)) do C s,i = C s,i + 1 Try a handshake starting by scanning on C s,i at most during T s end while end if until (The discovery happens) end for Algorithm 2 : P2P discovery according to LCR DevSet = {1, 2} /* the set of devices */ ChanSet = {1, . . . , n} /* the set of devices */ LT Set = {100, 200, 300} /* the set of listening times in T U = 1024µs */ Choose the maximal scanning time T s for (i ∈ Devset) do repeat Choose uniformly randomly a channel C i ∈ ChanSet Choose uniformly randomly a maximal time of listening T l,i Try a handshake starting by listening on C i at most during T l,i if (The discovery is not achieved) then C i = 0 while ((The discovery is not achieved) and (C i < n)) do C i = C i + 1 Try a handshake starting by scanning on C i at most during T s end while end if until (The discovery happens) end for