Analysis of the Bluetooth device discovery protocol

Size: px
Start display at page:

Download "Analysis of the Bluetooth device discovery protocol"

Transcription

1 DOI /s Analysis of the Bluetooth device discovery protocol Goutam Chakraborty Æ Kshirasagar Naik Æ Debasish Chakraborty Æ Norio Shiratori Æ David Wei Ó Springer Science+Business Media, LLC 2008 Abstract Device discovery and connection establishment are fundamental to communication between two Bluetooth (BT) devices. In this paper, we give an analytical model of the time it takes for the master in a piconet to discover one slave. We show that, even in the absence of packet interference, the discovery time can be long in some instances. We have simulated the discovery protocol by actually implementing it to validate the analytical model. By means of simulations, we show how discovery time is affected by (i) the presence of multiple potential slaves, and (ii) A preliminary version of this paper was presented at the IEEE Vehicular Technology Conference, Fall 2004 [2]. G. Chakraborty Department of Software and Information Science, Iwate Prefectural University, Iwate, Takizawamura , Japan goutam@soft.iwate-pu.ac.jp K. Naik Department of Electrical and Computer Engineering, University of Waterloo, Waterloo, Canada N2L 3G1 knaik@swen.uwateloo.ca D. Chakraborty (&) Research Institute of Electrical Communication, Tohoku University, Sendai , Japan deba@shiratori.riec.tohoku.ac.jp N. Shiratori Research Institute of Electrical Communication, Graduate School of Information Science, Tohoku University, Sendai , Japan norio@shiratori.riec.tohoku.ac.jp D. Wei Department of Computer and Information Science, Fordham University, Bronx, NY 10458, USA wei@cis.fordham.edu changes in the maximum backoff limit. Using simulation studies we observed the effectiveness of two proposed improvements to device discovery, namely, (i) avoiding repetitions of the A and B trains before a train switch, and (ii) eliminating the idea of random backoff, or reducing the backoff limit. We show that discovery time can be reduced by avoiding repetitions of the A and B trains before a train switch. However, complete elimination of the random backoff is not a good idea, as discovery time will be too long when the number of BT devices is large. Instead, choosing a small backoff limit of slots is highly effective in reducing discovery time even in the presence of a large number (say, 50) of potential slaves. Keywords Bluetooth Device discovery Inquiry Inquiry scan 1 Introduction The initial goal of Bluetooth technology [12] was to replace cables between pairs of devices, such as a computer and a printer, a cell phone and a head-set, a laptop and a desktop, and so on. However, the Bluetooth specification has gone far beyond simple cable replacement, by detailing the concepts of piconets and scatternets. Consequently, there have been numerous innovative efforts toward applying the technology to form personal area networks and multi-hop ad hoc networks [3, 7, 8]. In Bluetooth, a piconet is a basic networking unit consisting of one master and 1 7 active slave devices. The smallest piconet consists of two devices one master and one slave. The device which initiates the process of forming a piconet is designated as the master. The process

2 followed by a master to form a two-device piconet consists of two sequential steps as explained below. (i) Inquiry: In the inquiry phase, the master invites other devices to join itself to form a piconet. Essentially, the master solicits responses from other devices. Devices willing to join a piconet respond to the master s solicitation. In the inquiry phase, the master solicits responses by transmitting a standard packet, called ID (identifier) packets, on different hop channels (i.e., on different frequencies), and listens for response packets, called FHS (frequency hopping sequence) packets, from potential slave devices. The sender of an FHS packet puts its own address and clock values in the packet. When the master receives an FHS packet, it knows what device is willing to join the master to form a piconet. However, mere response of a device with an FHS packet does not form a piconet. After receiving an FHS packet, the master executes the paging step as explained below. (ii) Paging: Having received the address and clock values of a (potential) slave device, the master communicates with the device via the paging process. During the paging process the master establishes a connection with a slave. The paging process falls outside the scope of this work. The master can repeat the inquiry process to discover more devices, and invoke the paging process to establish a connection with a newly discovered slave device. Once a connection is established between the master and a slave in a piconet, upper (application) level data are exchanged between the two devices. Thus, the inquiry and paging processes are fundamental to form a piconet. In this paper, we give an analytical model of the average time it takes for a master to discover a potential slave. To obtain a better insight into the discovery protocol, we have Fig. 1 State diagram of Bluetooth link controller [12] simulated the protocol by actually implementing the relevant frequency hopping sequences. We performed extensive simulations to study the pattern of discovery time. Specifically, we have made the following observations: (i) even when there are only two devices, namely one master and one slave, the discovery time can vary from a couple of time-slots to more than 9000 time-slots, and (ii) if device discovery is not successful within a few hundreds of time-slots, it will, more often than not, be delayed by more than 4000 time-slots. By means of simulations, we have shown how the discovery time is affected by more number of slaves and by varying the maximum backoff limit from a small value, say, 32 slots, up to the recommended value of 1023 slots. We have investigated the effectiveness of two proposal to improve the discovery time: (i) avoiding train repetitions for 256 times [15], and (ii) eliminate random backoff or reduce the backoff limit [13]. The rest of the paper is organized as follows. The device discovery protocol has been explained in detail in Sect. 2. In Sect. 3, we review the related works. An analytical model of discovery time is given in Sect. 4. In Sect. 5, we present simulation results. Two suggested improvements to the discovery protocol have been studied in Sect. 6. Finally, some concluding remarks are given in Sect Device discovery protocol The state diagram of the Bluetooth link controller [12] has been shown in Fig. 1. We have clearly identified the device discovery (inquiry) phase and the connection establishment (paging) phase by enclosing the relevant states in separate dotted boxes. In this paper, we will focus on the device discovery portion. The STANDBY state means that the device is not a part of any piconet. The CONNECTION STANDBY Connection Establishment (Paging) Device Discovery (Inquiry) Page Page Scan Inquiry Scan Inquiry Master Response Slave Response Inquiry Response CONNECTION

3 state means that the device is a part of a piconet. A device can move from its present STANDBY or CONNECTION state to the Inquiry state, if it wants to discover a new device. The device which wants to discover another device to form a piconet is designated as the master in the piconet. Similarly, a device can move from its present STANDBY or CONNECTION state to the Inquiry Scan state, if it wants to be discoverd by another device. While a device is in the process of discovering a new device it can temporarily move to the Inquiry Response state. The device which is willing to be discovered by another device (master) is designated as a slave in a piconet. The device discovery protocol consists of two parts, namely Inquiry and Inquiry Scan. A discovering device (or, master) runs the Inquiry protocol, and a device willing to be discovered (or, slave) runs the Inquiry Scan protocol. The protocol has been explained in textual form in the specification [12]. However, for the purpose of clear understanding and easy analysis, we have represented the protocols in the form of an extended finite-state machine (EFSM). A state transition in an EFSM can be represented as a six-tuple of the following form: {source state, enabling condition, input, output, action, destination state}. The enabling condition and the input determine whether or not a state transition takes place from the source state to the destination state. In a time slot, if the enabling condition evaluates to true and the baseband layer receives the specified input, then it transmits a packet specified in the output part; after transmitting the packet, the baseband layer takes some local action before transiting to the destination state. 2.1 The Inquiry protocol The EFSM model of the Inquiry protocol is shown in Fig. 2. The protocol consists of two states: STANDBY/ CONNECTION and Inquiry. Initially, a device can be in the STANDBY or the CONNECTION state. It is the Link STANDBY/ CONNECTION Condition: True 1 4 Condition: True Input: (Command from LMP) Input: (Command from LMP) Action: Start inquiryto timer Action: Stop inquiryto timer Output: (Nil) Output: (Nil) 5 Inquiry Condition: True Condition: in Tx slot 2 3 Input: inquiryto timeout Input: (Nil) Action: (Nil) Action: {} Condition: in Rx slot Output: (Nil) Output: Transmit ID packet Input: FHS packet Action: {device discovered} Output: (Nil) Fig. 2 The Inquiry protocol Manager Protocol (LMP) layer that decides when the baseband layer may initiate the Inquiry protocol. At this point, the LMP layer asks the baseband layer to enter the Inquiry state, which has been represented by transition number #1. In the action part of transition #1, the baseband layer starts a time-out (TO) timer called inquiryto. The baseband layer moves from the Inquiry state to the original STANDBY/CONNECTION state in two ways. The first way, represented by transition #4, occurs when it is asked to do so by the LMP. The second way, represented by transition #5, occurs when the inquiryto timer expires. When the device is in the Inquiry state, two kinds of state transitions occur depending on whether it is in a Tx (transmission) slot or a Rx (reception) slot, as shown in transition #2 and transition #3, respectively. In transition #2, the discovering device transmits ID packets. Transition #3 fires when the device receives an FHS packet, signaling the discovery of a device. In the action part of transition #3, the baseband layer informs the LMP of the discovery of a device, and the device continues to be in the Inquiry state. It may be noted that the discovering device does not acknowledge the reception of an FHS packet. In transitions #2 and #3, the transmit and receive frequencies of a discovering device are determined by the inquiry hopping sequence. The inquiry hopping sequence is generated by the discovering device s native clock (CLKN) and the General Inquiry Access Code (GIAC). The GIAC has the standard value x9e8b33, in the hexa-decimal notation. In the 79-hop system, the inquiry hopping sequence contains 32 distinct hop frequencies. The inquiry hopping sequence is constructed as follows. The set of 32 frequencies is partitioned into two subsets of 16 frequencies each, and two trains, namely train A and train B, are constructed from those two subsets. The two trains are permutations of the two distinct sets of 16 frequencies. Assuming that an ID packet is transmitted twice in each Tx slot, once at the beginning and a second time at the middle of a transmission time-slot, it takes eight Tx slots to transmit a whole train of 16 frequencies. Because the Tx and Rx slots are interleaved, the total length of time to cover each train is 16 slots, or 10 ms (= ls), 625 ls being the duration of a time-slot. A single train is repeated for at least N inquiry = 256 times before the other train is used. In order to collect all responses in an errorfree manner, at least four trains must be used; in other words, three train switches must take place. Therefore, the Inquiry state lasts for s (= ms). The Inquiry protocol can run concurrently with data traffic. This can be achieved by having the master transmit ID packets for a duration of T w inquiry time units in a period of T inquiry, as illustrated in Fig. 3(a). Thus, the master can support data traffic for a duration of T inquiry T w inquiry in each period of T inquiry time units. The length of T w inquiry is

4 (a) (b) T Tw_inquiry inquiry Tw_inquiryscan Tinquiryscan at least equal to the length of three train switches, as explained above, with a duration of s. 2.2 The Inquiry Scan protocol Tinquiry Tw_inquiry Tinquiryscan Tw_inquiryscan Time Time Fig. 3 (a) Inquiry peroid and Inquiry window. (b) Inquiry Scan period and Inquiry Scan window The EFSM model of the Inquiry Scan protocol is shown in Fig. 4. If a device wants to be discovered by others, then the LMP layer of the device issues a command to the baseband layer to move from its present STANDBY/ CONNECTION state to the Inquiry Scan state, which has been modeled by transition #1. In the action part, the device starts the inqrespto timer and initializes a BackoffDone flag to false. It may be noted that the Bluetooth specification does not concern itself with the detailed specification of the backoff mechanism or the relevant parameter of back-off time. However, in this paper, we explicitly specify the backoff mechanism for a clear understanding of the protocol. If the device receives an ID packet and the backoff has not been performed, then it starts an inquiry response timer irrand, as we name it, with a duration randomly set between 0 and 1023 slots, and moves to its original state; the above behavior is specified in transition #2. The device is allowed to spend irrand time slots in its STANDBY/CONNECTION state; upon expiry of the irrand timer the device moves to the Inquiry Scan state, which is shown as transition #3. After the backoff period, but before the expiry of the inqrespto timer, if the device receives a second ID packet in the Inquiry Scan state, it starts another one-slot timer we call oneslotto. After the expiry of the oneslotto it moves to the Inquiry Response state; this behavior has been modeled in transition #4. After waiting for exactly one slot in the Inquiry Response state, the device transmits an FHS packet, reinitializes the BackoffDone flag to false, and moves to the Inquiry Scan state; this behavior has been modeled in transition #5. By repeatedly executing the transitions #2, #3, #4 and #5, the device continues to discover and possibly rediscover other devices in the neighborhood. After the inqrespto timer expires, the device moves from the Inquiry Scan state to its original STANDBY/CONNECTION state, which has been shown by the transition #6. The idea behind having the responding devices wait for a random period is to avoid collision of their FHS packets. In the Inquiry Scan protocol shown in Fig. 4, a device Fig. 4 The Inquiry Scan protocol 1 CONNECTION or STANDBY Condition: BackoffDone == False Condition: True 3 Input: ID packet (Inquiry) Input: irrand timeout 2 Output: {} Output: {} Action: Start a timer irrand with a random Action: BackoffDone = True length between 0 and 1023 slots. Condition: True Input: (Command from LMP) Output: {} Action: Start inqrespto timer BackoffDone = False 6 Condition: True Inquiry Scan Input: inqrespto timeout Output: {} Action: {} 4 Condition: BackoffDone == True && inqrespto timer running Input: ID packet (Inquiry) Output: {} Action: Start a one-slot timer oneslotto Inquiry Response 5 Condition: True Input: oneslotto timeout Output: FHS packet Action: BackoffDone = False Increment phase offset in the inquiry hop sequence

5 receives ID packets in transitions #4 and #5 using the inquiry scan hopping sequence, and transmits FHS packets in transition #6 using the inquiry response hopping sequence. It is important to note that in the Inquiry Scan protocol a device uses the same 32 frequencies to scan the medium as used in the Inquiry protocol by a master. The difference is that the Inquiry Scan protocol scans the medium on the same frequency for 2048 slots. After 2048 slots, a different scan frequency is chosen for another 2048 slots, and so on. The Inquiry Scan protocol can run concurrently with data traffic. This can be achieved by having a slave scan for ID packets for a duration of T w inquiryscan time units in a period of T inquiryscan time units as illustrated in Fig. 3(b). Thus, the slave can support data traffic for a duration of T inquiryscan T w inquiryscan time units in each period of T inquiryscan time units. The length of T w inquiryscan is at least 16 slots. In this paper, we will analyze the discovery time by considering that the master and the slave are fully dedicated to device discovery. Therefore, we assume that T w inquiry ¼ T inquiry and T w inquiryscan ¼ T inquiryscan. Trivially, the discovery time will be more in the absence of the above assumption. 2.3 Combined behavior of Inquiry and Inquiry Scan protocols The combined behavior of the Inquiry and Inquiry Scan protocols is shown in Fig. 5 in the form of a message sequence chart. The master s behavior running the Inquiry MASTER SIDE Standby state Inquiry state Time Device discovered Inquiry by sending ID packets at fast hop (Start of discovery process) SLAVE SIDE Standby state Slow Hopping Inquiry Scan STANDBY state Random backoff in the range [0, 1023] slots InquiryScan state Inquiry Scan state Slow Hopping Inquiry Scan Inquiry response state Fig. 5 Combined behavior of Inquiry and Inquiry Scan protocols protocol has been shown on the left hand side, whereas a potential slave runs the Inquiry Scan protocol on the right hand side. For simplicity, we assume that, initially, both the master and the potential slave are in their STANDBY states. Next, the master moves into the Inquiry state, and the slave moves into the Inquiry Scan state these two moves are independently performed. It is also assumed that a slave enters its Inquiry Scan state no later than the master entering the Inquiry state. In the absence of this assumption, the difference in time between the instant when a slave enters the Inquiry Scan state and the instant when the master enters the Inquiry state becomes a part of the discovery time. However, incorporating this time gap into discovery time is not a fair way to evaluate the protocol. The above assumption ensures that we start measuring discovery time once the master is in its Inquiry state and a slave is in its Inquiry Scan state. As soon as the master enters the Inquiry state, it starts transmitting ID packets twice per slot. The master is said to have discovered a device when it receives an FHS packet from another device. Thus, as shown in Fig. 5, we define discovery time as follows. Definition 2.1 Discovery time is defined as the time interval between the instant when the master enters the Inquiry state and the instant when it receives an FHS packet from another device. First, we explain how the master transmits ID packets on different hop frequencies, and how a slave hops on different frequencies to scan for ID packets. It is essential to understand the two hopping schemes in order to give a model to calculate discovery time. For simplicity, we discuss the case in which there is one master and one potential slave, as shown in Fig. 6(a). A device willing to be discovered, called a scanning device, scans the medium for ID packets with frequencies hopping very slowly a scanning frequency that changes once every 2048 slots (1.28 s). In Fig. 6(b), we show how the hopping frequencies of the master and a slave change. Let us denote the set of 16 A-train frequencies as A ¼fa 1 ; a 2 ; a 16 g}, and the set of 16 B-train frequencies as B ¼fb 1 ; b 2 ; b 16 g. The slow-hopping Inquiry Scanner frequencies are a permutation of the 32 frequencies of A [ B: In Fig. 6(b), frequencies f 0, f 1,, f 31 denote an arbitrary permutation sequence of the elements of A [ B. An Inquirer repeatedly transmits ID packets on the A-train and B-train frequencies as follows: the A-train is repeated for 256 times, followed by a repetition of the B-train for 256 times, followed by a repetition of the A-train for 256 times, and so on. Let A? represent the repetition of the A-train for 256 times. Similarly, B? represents the repetition of the B-train for 256 times. Thus, the

6 Fig. 6 State transition for device discovery: timing diagram (a) transmit receive timeslot T R timeslot x x T x R x T x Inquirer Inquiry scanner (b) Inquirer random backoff R x R x R x R x Α + Β + Α slots 4096 slots 4096 slots one time slot FHS packet t Inquiry scanner f f 1 f 2 f 3 f slots 2048 slots individual length of A? and B? is 2.56 s (= 625 ls ). In terms of behavior, there is no difference between A? and B?, except in their frequency components. On the other hand, an Inquiry Scanner scans the medium for an ID packet on a single frequency f i (f i [ A [ B) for 2048 slots (= 1.28 s). The scanning frequency changes every 2048 slots. At this moment, it is important to introduce the concept of phase difference between an Inquirer and an Inquiry Scanner, and its impact on device discovery time. If an A? or a B? train of the Inquirer and a new frequency scanning interval of an Inquiry Scanner begin at the same time instant, we say that the processes of inquiry and inquiry scan are synchronized. Otherwise, there is a phase difference. We denote the phase difference by Dt, as shown in Fig. 6(b). Here, the scanning frequency f 0 started Dt time before A? train. For convenience, we let Dt = k*s, where k is an integer and s is the length of one slot (= 625 ls). The range of possible values for k will be discussed in Sect. 4. We identify the notion of phase difference because the discovery time is a function of phase difference. It will be clear from the following discussion that restricting k to only integer values does not affect the computation of discovery time. 3 Related research Delay analysis of the device discovery protocol and proposals to modify the protocol to reduce the delay have generated much interest [1, 5, 6, 9, 10, 11, 13 15]. Zaruba and Gupta [15] simplify the analysis of the discovery protocol by assuming that none of the trains A or B is repeated before a train switch. In other words, an A-train is immediately followed by a B-train, followed by an A-train and so on. They do not repeat a train for 256 times before switching, as it has been specified. Jiang, Lin and Tseng [5] model the elapsed time from the instant a slave starts inquiry scan to the instant it successfully receives an ID packet from the master. It is assumed that there is a master device performing the inquiry procedure. Thus, the focus of their work is on the average time to receive an ID packet by a slave. They propose three techniques to improve this delay, namely, (i) halve the T inquiry and T w inquiry intervals, (ii) use a dual Inquiry Scan scheme, and (iii) use a combination of both. In the dual Inquiry Scan scheme, for every T inquiryscan period, the slave performs inquiry scan on two frequencies each for a duration of T w inquiryscan. However, to be precise, device discovery time needs to be measured from the viewpoint of a master. That is, it is more useful to find out how much time it takes a master to discover a slave, assuming that the slave is performing the inquiry scan procedure no later than when the master initiates its inquiry protocol. Connection establishment between two mutually unknown devices takes 5.76 s in a typical case and as long as 23 s in the worst case [1, 4]. Thus, for Bluetooth technology to be useful in a mobile environment, where two devices may not stay within each other s radio range for long, there is a need to speed up the discovery time. Welsh, Murphy and Frantz [13] proposed three possible changes to the Bluetooth specification in order to reduce the discovery time. Their proposals are: (i) eliminate or decrease the random backoff delay in the Inquiry Scan protocol, (ii) use a single frequency train instead of two A and B in the Inquiry protocol, and (iii) combine the first two approaches. The reader may note that the second proposal above is the same as the proposal made by Zaruba and Gupta [15] in their analysis of the discovery protocol.

7 Woodings, et al. [14] proposed to bypass the uncertainty in device discovery by using a direct IrDA channel between devices that could potentially establish a connection between them. A master device obtains the details, such as device address and native clock values, of a slave via a connection over an IrDA channel. Once the master obtains the details of the slave, it initiates the paging protocol. Salonidis, Bhagwat and Tassiulas [10] have shown that device discovery time can be reduced by having devices alternate between two roles, namely, a discoverer and one willing to be discovered. In other words, a device alternatingly runs the Inquiry protocol and the Inquiry Scan protocol. For better effectiveness of this scheme, a device executes those protocols for random durations, rather than follow a periodic scheme. 4 Analysis of discovery time In this section, we will present an analytical model of discovery time as depicted in Fig. 5. The different components of this time can be found on the slave side in Fig. 5. Discovery time has four components as explained below. T ID1 : This is the average time taken by a slave to receive the first ID. This time is measured from the instant the master starts transmitting ID packets to the instant when a slave receives an ID. T b : This is the average of the random backoff time after the slave receives the first ID packet. T ID2 : This is the average time taken by the slave to receive a second ID. This time is measured from the instant the slave comes out of its random backoff to the instant when it receives an ID. 1-slot: This is the 1-slot wait by the slave between receiving a second ID and transmitting an FHS packet. We will ignore this 1-slot component from further consideration. Therefore, discovery time, denoted by T, is expressed as follows: T ¼ T ID1 þ T b þ T ID2 : ð1þ The Bluetooth specification states that a random backoff interval be uniformly chosen from the range [0, 1023] slots. Thus, the average value of T b is 512 slots. There is a similarity between T ID1 and T ID2. Both these intervals are associated with the same condition. For T ID1 we have assumed that a slave enters its Inquiry Scan state no later than the master entering the Inquiry state. Essentially, this assumption implies that by the time the master starts transmitting ID packets, a slave has already begun, or just begins, scanning the medium to receive an ID packet. The reader may observe that the same condition holds when a slave returns from its STANDBY state to the Inquiry Scan state at the end of its random backoff as depicted in Fig. 4 and 5. This is because the master continues transmitting ID packets in its transmit slots, without knowing a state change in a slave. The slave starts scanning the medium for an ID packet as soon as it returns to Inquiry Scan. We measure T ID2 from the instant a slave enters Inquiry Scan for a second time to when it receives a second ID. Thus, T ID1 and T ID2 can be computed in the same way. Consequently, we can rewrite Eq. 1 as, T ¼ 2 T ID þ T b ; ð2þ where T ID = T ID1 = T ID2 represents the average time taken by a slave to receive an ID packet from the instant the master is transmitting ID packets and the slave is scanning the medium. Thus, to give an expression for T, we need to compute T ID. Next, we discuss how the value of k (phase difference, as defined in Sect. 2) affects the discovery time, and how k plays an important role in determining the delay. Let F ¼ A [ B be the set of 32 frequencies used in the discovery protocol. The members of F are denoted by f i, where 1 B i B 31. A slave scans the medium on the same frequency, say f i, for 2048 slots. Since a slave scans the medium on the same frequency for 2048 slots and the length of each of A? and B? is 4096 slots, the possible range of phase difference is [0, 2046] slots, i.e., 0 B k B Moreover, we consider only the even values of k in the range [0, 2046]. This is because the master transmits ID packets in its Tx slots, which are followed by the Rx slots to receive an FHS packet. To show the impact of the value of k on discovery time, we first consider values of k between 0 and 16. If k = 0, as shown in Fig. 7(a), a slave scans the medium on two different frequencies during the period when the master transmits ID packets using A? frequencies. Then the slave would not be able to receive ID packets if f 0, f 1 62 A: On the other hand, if k [ 0, a slave scans the medium on three different frequencies during the period when the master transmits ID packets using A? frequencies. This is evident from Figs. 8 and 9. Consequently, the probability of a slave being able to receive an ID packet is higher. We identify another important value of k, namely, k = 16, as follows. Suppose that there is no match during f 0 and f 1, because both f 0 and f 1 62 A. When the scan frequency changes to f 2, as shown in Fig. 9, and if f 2 [ A, there will be an immediate match within the 16 consecutive time slots. On the other hand, if f 2 62 A, subsequently there will be a definite match of f 2 with a B train frequency as f 2 [ A [ B. When 0 B k B 14, the probability of such a match

8 Fig. 7 Detailed computation of discovery time for k = 0 (a) (b) during the f 2 scanning frequency becomes less and less as k takes smaller values in the range [2, 14]. A similar argument can be used to show that the two ranges of k, namely [2, 14] and [2034, 2046], lead to similar discovery times. Therefore, to compute T ID, we need to consider four distinct ranges of k as follows: (i) k = 0 (ii) 2 B k B 14 (iii) 16 B k B 2032 (iv) 2034 B k B 2046 As noted above, cases (ii) and (iv) lead to similar delay behavior. In the following, we give a model of T ID for each of the three cases. It may be noted that this delay behavior is for one master and one slave. When the number of potential slave devices is increased, the delay would be longer due to collision of FHS packets. Due to the conditional dependence of the delay on k, and because the values of k for individual slaves are independent variables, deriving an analytical model for multiple slaves becomes difficult. However, we have obatined simulation results for more than one slaves in Sect Discovery time for k = 0 Computation of T ID for k = 0 has been explained using a tree structure in Fig. 7. The scan frequencies f 0, f 1,, f 31 at the Inquiry Scanner is a permutation of all the 32

9 Fig. 8 Delay analysis when k takes a value in the closed range [2, 14] (a) (b) frequencies in the set F. We give an estimation of T ID using the tree structure showing possible delays and their corresponding probabilities, as shown in Fig. 7(b). If f 0 [ A, for which the probability is 16/32, the delay lies between 0.5 and 15 slots with equal probabilities. Thus, the average delay is about 7.5 slots. The probability of the event f 0 [ A and the corresponding delay have been shown on the left branch from the root. If f 0 62 A; no ID will be received for at least 2048 time slots before the frequency changes to f 1. Estimation of the delay will depend on the next frequency f 1. Thus, on the right branch of the root we record the probability of f 0 [ B (same as f 0 62 A) as 16/32, and the delay is denoted as d 0.Iff 1 [ A, for which the probability is 16/31, an ID will be received due to a matching scanning frequency, and the corresponding delay will be ? 7.5. This probability and the delay have been shown in the second row, left box. A similar case may happen with f 2, f 3, If a match occurs on f i, the corresponding delay will be i ? 7.5, and these have been shown in the left branch boxes. On the other hand, if f 1 [ B, the Inquiry Scanner will not receive an ID packet until f 1 changes to f 2. The probability of f 1 [ B is 15/31, and the estimation of the delay will depend upon the next frequency f 2. Thus, in the second row right-hand box we record the probability of f 1 [ B as 15/31, and the delay as d 1. All the possible situations of receiving or not receiving an ID packet have been shown with their probabilities and delays in the boxes in Fig. 7(b). On the right-hand side box at level 31, the probability of f 31 [ A is 1.0 and the delay is denoted by g.

10 Fig. 9 The delay for the case when 16 B k B 2032 (a) (b) An expression for T ID for k = 0, denoted by T ID, k=0, can be obtained by combining the probabilities and delays recorded in the boxes in Fig. 7. Thus, we have the following expressions. T ID;ðk¼0Þ ¼ :5 þ d 0 d 0 ¼ 16 ð2048 þ 7:5Þþ d 1 d 1 ¼ d 2 ¼... ð þ 7:5Þþ16 30 d 2 where the general expression for d i is, 16 bði þ 3Þ=4c2 d i ¼ ðði þ 1Þ2048 þ 7:5Þ ð32 iþ ð32 iþ ð16 bði þ 3Þ=4c2Þ þ d iþ1 ; ð32 iþ where 0 i 30 and d 31 ¼ g: One may note that the estimated value of g is T ID,k=0,but the probability of occurrence of the event is negligibly small. T ID,k=0 is computed by successive approximation. Initially, we set g = 0 and successively modify g with the value of T ID,k=0 obtained from the previous iteration. T ID,k=0 stabilized after two iterations. 4.2 Average delay when 2 B k B 14 The frequency matching scenario between a master running the Inquiry protocol and a potential slave running the Inquiry Scan protocol when k takes a value in the closed range [2, 14] has been described in Fig. 8. The scanning frequencies have been denoted by f i,0b i B 31. The tree structure shown in Fig. 8(b) is obtained using an argument similar to the one used to construct the tree shown in Fig. 7(b). However, there is a difference in Fig. 7(b) and Fig. 8(b). For example, in the tree shown in Fig. 7(b), each node has at most two child

11 nodes, whereas it is at most three in Fig. 8(b). This is due to the fact that when i is even in f i, the span of f i covers both A-train and B-train of frequencies A-train partially and B-train completely. Following the argument in Sect. 4.1, it is easy to see how the boxes (i.e. nodes), shown in level 0 and level 1, can be obtained. Here, level i means boxes terminated on a branch of f i [ A or f i [ B. For example, the probability of f 0 [ A is 16/ 32 and the delay is approximately 7.5 slots. We represent this information in the left node of level 0. On the other hand, the probability of f 0 [ B is 16/32, and the delay, denoted by d 0 in Fig. 8, depends on the subsequent scanning frequencies. The value of d 0 is computed using the part of the tree rooted at the right node of level 0. With a similar argument the probabilities of events at level 1 are obtained. However, the situation is different at level 2, where there are three distinct possibilities. This time, the scanner s tuning frequency f 2 overlaps with the A? train for k slots and with the B? train for k slots. Thus, the probability of f 2 [ B is 14/30, and the corresponding delay is k? k? 7.5 = ? 7.5 slots. The probability of f 2 [ A is 16/30. The probability of a frequency match between the Inquirer and an Inquiry Scanner with f 2 [ A is (16/30) 9 (k/16) and the corresponding delay is k? k/2. On the other hand, the probability of no frequency match between the Inquirer and an Inquiry Scanner with f 2 [ A is (16/ 30) 9 ((16-k)/16) and the corresponding delay d 2 depends on the subtree rooted at this node. These three different situations have been represented by three nodes at level 2 of Fig. 8(b). Using a similar argument, we can complete the tree shown in Fig. 8(b), and an expression for T ID for 2 B k B 14 is given below. T ID;ð2k14Þ ¼ :5þ16 32 d 0 d 0 ¼ 16 ð2048 k þ7:5þþ d 1 d 1 ¼ ð22048þ7:5þ þ k 16 þ ð16 kþ d 2 16 d 2 ¼ d 3 ¼ k 2 ð32048 kþ7:5þþ where the general expression for d i is, d 3 d i ¼ 16 i ðði þ 1Þ2048 k þ 7:5Þ 31 i þ 1 16 i d iþ1 ; where i ¼ 0ori is even: 31 i d i ¼ 15 i ðði þ 1Þ2048 þ 7:5Þ 31 i þ 1 15 i k ði þ 1Þ2048 k 31 i 16 2 þ 1 15 i 16 k d iþ1 ; where i is odd: 31 i 16 The average delay depends on the value of k, and it decreases as k increases. 4.3 Average delay when 16 B k B 2032 The frequency matching scenario in the case of 16 B k B 2032 has been shown in Fig. 9. The tree showing the probabilities of frequency matching and delay computation is obtained using an argument similar to the one in Sect In this case, there will be a definite match by the time a potential slave scans on f 2. This is because by the time the slave completes scanning the medium on frequency f 2 for at most (k? 16) slots, it will have covered all the A- train and B-train of frequencies transmitted by the Inquirer. Thus, the delay T ID is given by the following expression. T ID;ð16 k 2032Þ ¼ :5 þ ð2048 k þ 7:5Þþ ð þ 7:5Þþ ð k þ 7:5Þ The average value thus depends on k, and when averaged over all k between 2032 to 16, it is 1142 timeslots. 4.4 Average delay when 2034 B k B 2046 The frequency matching scenario when 2034 B k B 2046 is similar to the scenario for 2 B k B 14 as shown in Fig. 10. Here, k 0 = k takes values from 14 to 2. A 0 is the set of first k 0 frequencies of the A-train. The branches show the conditions, and the boxes give the probabilities and corresponding delays. The expression for T ID for 2034 B k B 2046 is given below.

12 Fig. 10 Delay analysis when k takes a value in the closed range [2034, 2046] (a) (b) T ID;ð2034 k 2046Þ ¼ k0 32 k0 32 k0 þ d d 0 ¼ ðk0 þ 7:5Þþ d 1 d 1 ¼ ð2048 þ k0 þ 7:5Þ þ 14 k þ k þ k0 d d 2 ¼ ð þ k0 þ 7:5Þþ d 3 d 3 ¼...; where the general expression for d i is, d i ¼ 16 i1:5 ði2048þk 0 þ7:5þ 31 i þ 1 16 i1:5 d iþ1 ; where i ¼ 0ori is even: 31 i d i ¼ 17 i ði 2048 þ k 0 þ 7:5Þ 31 i þ 1 17 i k 0 ði þ 1Þ2048 þ k0 31 i 17 i 2 þ 1 17 i 1 k0 d iþ1 ; where i is odd: 31 i 17 i 4.5 An expression for T ID Now we obtain an expression for T ID by combining the expressions for T ID, (k=0), T ID, (2B k B 14), T ID, (16B k B 2032) and T ID, (2034 B k B 2046). The expression for T ID is,

13 T ID ¼ T ID;ðk¼0Þ þ X14 T ID;ð2 k 14Þ k¼2 þ X2032 T ID;ð16 k 2032Þ k¼16 þ X2046 k¼2034 T ID;ð2034 k 2046Þ :! ð3þ To get an expression for the discovery time, as given in Eq. 1, we need to substitute T ID obtained from Eq. 3. As the constituent terms of the above Eq. 3 are in recursive form, we calculated the value of T ID using numerical method. 5 Simulation result We have developed a Bluetooth simulator to study the performance of the device discovery protocol. We implemented the frequency hopping kernel box specified in Chapter 11 of the Bluetooth specification [12]. In Sect. 4, we obtained an analytical model of discovery time by considering the phase difference in four distinct blocks, namely, k = 0, 2 B k B 14, 16 B k B 2032, and 2034 B k B To verify that discovery time can be studied in terms of those four blocks of k values, we performed distinct experiments. The idea behind performing experiments is this: There are 1024 distinct values of k, and we wanted each value of k to appear for an average of 30 times. In the discovery protocol, the phase value depends upon the native clocks of the two devices taking part in the discovery process. We observed that each k value appears between 10 and 70 instances in the total number of experiments. In the experiments, we had two devices one master and one slave. For each of the four blocks of k values, we compute their average discovery time and the result has been shown in Fig. 11. As analyzed in Sect. 4, the average delays in the four blocks of k values, namely, k = 0, 2 B k B 14, 16 B k B 2032 and 2034 B k B 2046, are very distinct. The distribution of delay is uniform within each of the four blocks, but it varies from block to block as predicted in Sect. 4. We wanted to compare the analytical model of discovery time with data obtained from simulation studies. Using the expression for T ID given in Eq. 3, we computed T ID to be 1169 slots. When the random backoff range is [0, 1023], the average value of random backoff is 512 slots. Thus, the average discovery time, when there is just one inquiry scanner, is computed to be T ¼ þ 512 ¼ 2850 slots. The average device discovery time obtained from simulations is compared with the theoretical value in Fig. 12. Their small difference is due to non-uniform distribution of experiments with different k-values. We also show the distribution of discovery time in Fig. 12 by sorting the experiments on the basis of their delays. Figure 12 shows that there is a probability of almost 0.5 that device discovery can be much higher than the average value. We observed in Sect. 4 that discovery delay is a function of k. Moreover, the delay distribution is in the form of a recursive function, and not in close form. Using the same line of approach, and aiming similar accuracy, it is not possible to deal the case for multiple slaves. Two different sets of experiments were performed with one master and multiple slaves as explained below. 1. There is one master, the maximum backoff limit is fixed, and the number of potential slaves is varied. In this experiment we measure the average total time taken to discover all the known potential slaves. This allows us to observe the effect of collision of FHS packets on discovery time. We show the result of the experiments in Fig. 13. Each data point in Fig. 13 has been obtained from 1000 independent experiments. By independent experiments we mean an experiment Average discovery delay in each region (in slots) Regions of phase values Fig. 11 The impact of phase difference on discovery time Discovery delay in individual experiments (in slots) Theoretical average delay Simulated average delay Individual experiments (sorted according to delay) x 10 4 Fig. 12 Distribution of discovery time

14 Average total delay in device discovery (in slots) o : Backoff limit = 1023 slots x : Backoff limit = 767 slots + : Backoff limit = 511 slots : Backoff limit = 255 slots Number of Bluetooth enabled devices in a cluster be reduced. In Fig. 14 we show how discovery time varies when the backoff limit is increased. If the number of potential slave devices is very small, say 3 4, it is possible to make the backoff limit very small, say 100 slots. However, for a large number of potential slaves, a small backoff limit cannot prevent collision of FHS packets. There is a threshold backoff time below which the average delay is very long. Thus, the backoff limit needs to be more than the threshold as shown in Fig. 14. Even for a large number of devices, say 50, a backoff limit of 300 slots is a good choice. Fig. 13 Average total delay in device discovery as a function of total number of devices (one device is a master and the rest are potential slaves) begins with a new set of values of the device addresses and their native clocks. In real applications, a user may have to discover all the devices before selecting one to activate the desired service. Thus, knowing the distribution of the average total time to discover multiple devices is useful. 2. There is one master, the number of potential slaves is fixed, and the maximum backoff limit is varied. This experiment allows us to observe the effect of backoff time on device discovery. The idea of backoff has been introduced to reduce the probability of collision of FHS packets from two or more devices. However, backoff time adds to the discovery delay. Some researchers [13] have proposed to keep it smaller, or even eliminate the idea of backoff. Thus, it is interesting to know to what extent backoff time can 6 Improvement of discovery time In order to reduce discovery time, there has been a proposal to avoid the 256-time repetitions of the individual trains [13, 15]. The proposal suggests to use the sequence ABAB, instead of the sequence A? B? A? B?. However, the impact of the proposal on discovery time has not been studied in detail. To observe how the proposal affects discovery time, we further investigated the delay behavior through simulations, and the results are shown in Figs. 15 and 16. In Fig. 15, we show how discovery time varies with increasing number of potential slaves for the two cases of inquiry sequence, namely, A? B? A? B? and ABAB, for different fixed values of the backoff limit. In Fig. 16 we show how discovery time varies with increasing backoff limit for the two cases of inquiry sequences, namely, A? B? A? B? and ABAB, for different number of potential slaves. Figures 15 and 16 clearly demonstrate that it is more effective to apply the sequence ABAB instead of A? B? A? B?. Average total delay in device discovery (in slots) x o : Number of devices = 5 + : Number of devices = 15 x : Number of devices = 25 * : Numer of devices = Backoff limit in slots Fig. 14 Average total delay in device discovery as a function of backoff limit Average total delay in device discovery (in slots) Upper set of 4 curves: A and B trains are repeated for 256 times each. o : Backoff limit = 1023 slots x : Backoff limit = 767 slots + : Backoff limit = 511 slots * : Backoff limit = 255 slots Lower set of 4 curves: A and B trains are repeated for 1 time each Number of Bluetooth enabled devices in a cluster Fig. 15 Average total delay in device discovery as a function of total number of devices (one device is a master and the rest are potential slaves)

15 Average total delay in device discovery (in slots) 3 x o : Number of devices = 5 + : Number of devices = 15 x : Number of devices = 25 * : Numer of devices = 50 Upper set of 4 curves: A and B trains are repeated for 256 times each. Lower set of 4 curves: A and B trains are repeated for 1 time each Backoff limit in slots Fig. 16 Average total delay in device discovery as a function of backoff limit There is another proposal to improve discovery time by eliminating or reducing the random backoff time. However, it is clear from Fig. 14 and Fig. 16 that it is not a good idea to completely eliminate random backoff. Instead, a small backoff limit of slots can be used even for an environment with a large number (say, 50) of potential slaves. 7 Discussion and conclusion In this paper, we analyzed Bluetooth device discovery time and compared it with simulation results. We performed a large number of experiments to obtain insights into the distribution of discovery time. We observed that discovery time suffers from high variance. It can be as low as few slots to as high as thousands of slots. By performing additional simulations we observed how the total discovery time varies with the number of potential slaves when the backoff limit is constant. We also observed how the total discovery time varies with the backoff limit when the number of potential slaves is constant. With a very small value of backoff limit, discovery time can be too long, if there are more than 10 potential slaves in the same area. By performing additional simulations we observed the effectiveness of two proposed improvements to device discovery. Specifically, it is useful to avoid repetitions of A and B trains before a train switch. On the other hand, complete elimination of the concept of random backoff is not a good idea because discovery time will be too long. As a recommendation, choosing a small backoff limit of slots is highly effective in reducing discovery time even if there is a large number (say, 50) of potential slaves in the same region. Acknowledgements This work was partially supported by the Ministry of Education, Culture, Sports, Science and Technology, Grants-in-Aid for Scientific Research, and and Ministry of Internal Affairs and Communications in Japan, SCOPE project( ). References 1. Busboom, A., Herwono, I., Schuba, M., & Zavagli, G. (2002). Unambiguous device identification and fast connection setup in Bluetooth. In Proceedings of European Wireless 2002, Florence, Italy. 2. Chakraborty, G., Naik, K., Chakraborty, D., Shiratori, N., & Wei, D. (2004). Delay analysis and improvement of the device discovery protocol in Bluetooth. In IEEE Vehicular Technology Conference, Fall 2004, Los Angeles, USA. 3. Conti, A., Dardari, D., Pasolini, G., & Andrisano, O. (2003). Bluetooth and ieee b coexistence: Analytical performance evaluation in fading channels. IEEE Journal on Selected Areas in Communications, 21(2), Haartsen, J. (1998). The universal radio interface for ad hoc, wireless connectivity. Ericsson Review, 3, Jiang, J.-R., Lin, B.-R., & Tseng, Y.-C. (2004). Analysis of Bluetooth device discovery and some speedup mechanisms. Journal of the Institute of Electrical Engineering, 11(4), Kim, C., Ma, J., & Lee, J. (2001). A random inquiry procedure using Bluetooth. In Proceedings of International Conference on Communications and Computing, Las Vegas. 7. Liu, Y., Lee, M. J., & Saadawi, T. N. (2003). A Bluetooth scatternet-route structure for multihop ad hoc networks. IEEE Journal on Selected Areas in Communications, 21(2), Misic, J., & Misic, V. B. (2003). Bridges of Bluetooth county: Topologies, scheduling and performance. IEEE Journal on Selected Areas in Communications, 21(2), Murphy, P., Welsh, E., & Frantz, J. P. (2002). Using Bluetooth for short-term ad hoc connections between moving vehicles: A feasibility study. In Proceedings of IEEE Vehicular Technology Conference, Spring 2002, pp Salonidis, T., Bhagwat, P., & Tassiulas, L. (2000). Proximity awareness and fast connection establishment in Bluetooth. In Proc. of Mobile and Ad Hoc Networking and Computing (MobiHoc), Boston, pp Siegemund, F., & Rohs, M. (2002). Rendezvous layer protocols for Bluetooth-enabled smart devices. In Proceedings of International Conference on Architectures of Computing Systems, Karlsruhe, Germany, pp The Bluetooth Special Interest Group. Baseband specification version Welsh, E., Murphy, P., & Frantz, J. P. (2002). Improving connection times for Bluetooth devices in mobile environment. In Proceedings of International Conference on Fundamentals of Electronics, Communications, and Computer Science. 14. Woodings, R., & Joos, D., Clifton, T., & Knutson, C. D. (2002). Rendezvous layer protocols for Bluetooth-enabled smart devices. In Proceedings of 3rd Annual Wireless Communication and Networking Conference (WCNC), pp Zaruba, G.V., & Gupta, V. (2004). Simplified Bluetooth device discovery analysis and simulation. In Proceedings of the 37th Hawaii International Conference on System Sciences, 2004.

16 Author Biographies Goutam Chakraborty received his Ph.D. in 1993 from Tohoku University, Japan. Presently he is Professor and head of the Intelligent Informatics Laboratory, Department of Software and Information Science, Iwate Prefectural University, Japan. His main research interests are Soft computing algorithms to solve pattern recognition, prediction, scheduling and optimization problems, and problems in wired and wireless networks. Norio Shiratori received his doctoral degree from Tohoku University, Japan in Presently he is a professor and vice director of Research Institute of Electrical Communication, Tohoku University. He has been engaged in research related to symbiotic computing paradigms between human and Information Technology. He was the recipient of IPSJ Memorial Prize Wining paper award in 1985, Telecommunication Advancement Foundation Incorporation award in 1991, best paper award of ICOIN-9 in 1994, IPSJ best paper award in 1997, and many others. He is a fellow of IEEE, IPSJ and IEICE. Sagar Naik received the B.S. and M.Tech. degrees from Sambalpur University, Sambalpur, India and the Indian Institute of Technology, Kharagpur, respectively, the M.Math. degree in Computer Science from the University of Waterloo, Waterloo, Canada and the Ph.D. degree in Electrical and Computer Engineering from Concordia University, Montreal, QC, Canada. He was a faculty member with the University of Aizu, Aizu, Japan, and Carleton University, Ottawa, ON, Canada. At present he is an Associate Professor in the Department of Electrical and Computer Engineering, University of Waterloo. His research interest are in the areas of testing communication protocols, smart antenna-based MAC protocols for wireless LAN and optical networks, mobile computing, data access in wireless networks, power-conscious software systems for portable devices and coexistence of and Bluetooth technologies. David Wei received his Ph.D. degree in Computer and Information Science from the University of Pennsylvania in He is currently Professor of Computer and Information Science at Fordham University, Bronx, NY. From May 1993 to August 1997, he was on the Faculty of the School of Computer Science and Engineering, University of Aizu, Japan, as an Associate Professor and the a Professor. He has authored and co-authored more than 60 technical papers in the areas of distributed and parallel processing, wireless networks and mobile computing, and optical networks in various archival journals and conference proceedings. He is a lead guest editor of IEEE Journal on Selected Areas in Communications for the special issue on Mobile Computing and Networking. Currently, Dr. Wei focuses his research effort on mobile computing and wireless networks. Debasish Chakraborty received his doctoral degree from the Graduate School of Information Science, Tohoku University, Japan in Previously he was a Telecommunication Advancement (TAO) research fellow and a National Institute of Information and Communication Technology (NiCT) foreign researcher at Tohoku Research Center. Now he is working as a visiting Associate Professor in Research Institute of Electrical Communication, Tohoku University. His main research interests are multicast routing algorithm, QoS, Internet traffic analysis, and wireless and ad hoc networking.