Modelling and Optimising TinyTP over IrDA Stacks

TinyTP is the IrDA transport layer protocol for indoor infrared communications. For the ﬁrst time, this paper presents a mathematical model for TinyTP over the IrDA protocol stacks taking into account the presence of bit errors. Based on this model, we carry out a comprehensive optimisation study to improve system performance at the transport layer. Four major parameters are optimised for maximum throughput including TinyTP receiver window, IrLAP window and frame size, as well as IrLAP turnaround time. Equations are derived for the optimum IrLAP window and frame sizes. Numerical results show that the sys-tem throughput is signiﬁcantly improved by implementing the optimised parameters. The major contribution of this work is the modelling of TinyTP including the low-layer protocols and optimisation of the overall throughput by appropriate parameter selection.


INTRODUCTION
Indoor infrared data communications, based on the Infrared Data Association (IrDA) standards, have become widely available on a large number of portable devices ranging from mobile phones and digital cameras to laptops and printers [1].Infrared communication is an excellent choice for effective, inexpensive and high-speed short-range wireless communications.The low-level IrDA protocols including physical (IrPHY) [2,3], link access (IrLAP) [4], and link management (IrLMP) protocols [5] are adopted as industry standards and implemented on the products.Tiny transport protocol (TinyTP) is an optional IrDA layer, whereas it is so important and widely implemented that it is generally considered a required layer [6].
In [7], an IrLAP model is presented as the first significant work on the IrDA link layer.Subsequently, many link layer performance evaluations and improvements have also been undertaken recently to address different infrared link issues including the impact on link throughput of device processing speed [8] and future increase in data rates [9].All the previous publications focus on link layer perfor-This is an open-access article distributed under the Creative Commons Attribution License, which permits unrestricted use, distribution, and reproduction in any medium, provided the original work is properly cited.mance by assuming data always available of infinite size and a single application ready to transmit.However, upper layers (e.g., TinyTP) in practice offer finite-size packets to the link layer at specific time periods due to protocol behaviour and limited buffer size.TinyTP also allows multiple applications to operate the IrDA link concurrently.It is therefore of interest to examine the system throughput at TinyTP level.
The rest of this paper is organised as follows.First, we briefly describe the IrDA protocol stacks.Then, the details of TinyTP functionality are described.We subsequently develop a mathematical model for TinyTP which allows derivation of throughput taking into account the lower IrDA protocol stack.The TinyTP receiver window size and the IrLAP window and frame sizes are optimised for the maximum system throughput for any given bit error rate (BER).Finally, the suitable IrLAP turnaround time is investigated for 16 Mbps links.

IrDA PROTOCOL STACKS
The IrDA protocol stack illustrated in Figure 1 is the layered set of protocols particularly aimed at point-to-point infrared communications and the applications needed in that environment.A brief description of the IrDA protocol stack is as follows.

IrDA physical layer
The IrDA physical layer defines a directed half-duplex serial infrared communications link established through free space to facilitate point-to-point communication.Framing data such as beginning-and end-of-frame flags (BOFs and EOFs), and cyclic redundancy checks (CRCs) are also considered to be part of the physical layer.Transceivers with data rates of 4 and 16 Mbps have a 6-byte physical header for each IrLAP frame [2,3].

IrDA link access protocol
IrLAP is the link access layer and it is based on the high-level data link control (HDLC) protocol.By using mechanisms including retransmission, low-level flow control and error detection, IrLAP provides reliable data transfer.IrLAP transmits data in the form of frames with maximum length of l LAP and organises the transmission using go-back-N (GBN) error recovery.As the physical layer defines a half duplex link, IrLAP manages the transmission by assigning primary and secondary stations.The primary station initiates transfers to the secondary station and manages the link.When the primary completes the transmission of a window size N, information (I-) frames that can be sent before link turnaround, it then sets the poll (P) bit in the last I-frame to signal link turnaround and request the acknowledgement from the secondary.Once P bit is set, the secondary can start sending data.It changes P bit to 0 to turnaround the link when it finishes transmission.Referring to standards [3,4], the window size and frame size range from 1 to 127 and from 128 bit to 16384 bit, respectively, IrLAP adds a 3-byte header to each frame.

IrDA link management protocol
IrLMP provides support for multiple software applications or entities to operate independently and concurrently, sharing the single link provided by IrLAP between the transceivers [5].To realise the multiplexing, IrLMP assigns each application a unique link service access point (LSAP) address.IrLMP delivers upper-layer data segments based on the first-in first-out (FIFO) queuing [5].We assume that the multiple application channels equally share the infrared link in this paper.After the connection initialisation, IrLMP adds a 2-byte header to the upper-layer packet providing the LSAP address for the sender and receiver.

TinyTP
TinyTP (TTP) is a light transport protocol serving as a flow control mechanism to work with IrLMP [6].Even though Ir-LAP provides reliable data transfer, TinyTP is still important to ensure the end-to-end data delivery for the application.This is due to the possible deadlock problem of multiplexed channels introduced by IrLMP multiplexer (LM-MUX).Reliance on IrLAP to provide flow control for a multiplexed channel can result in deadlocks if the consumption of data from one multiplexed channel is dependent on data flowing in an adjacent multiplexed channel.Conversely, if inbound data on a multiplexed channel cannot be consumed and the underlying IrLAP connection cannot be flow controlled due to the possibility of deadlock, inbound data (freshly arrived or buffered) must be discarded in the event of buffer exhaustion.Unfortunately, this reduces the reliable delivery service provided by IrLAP to a best-effort delivery service provided by LM-MUX.To overcome this problem TinyTP provides two functions: (i) segmentation and reassembly; (ii) flow control on a per-LMP-connection (per-channel) basis.
For TinyTP, the entire data packet from upper layers can be segmented and reassembled in service data units (SDUs).The maximum SDU size is negotiated at the TinyTP/IrLMP connection establishment.One SDU has to fit within one Ir-LAP frame.Maximum TinyTP SDU size l TTP therefore has to satisfy the condition l TTP ≤ l LAP − l LMP − l TTP , where l LMP and l TTP stand for the headers of IrLMP and TinyTP.In this paper, we consider the challenge of having large application files to transmit.To make TinyTP efficient, we assume l TTP is set at its maximum value l TTP = l LAP − l LMP − l TTP .
To perform flow control, TinyTP maintains a value of receiver window (w) for each TinyTP channel.The value of w is decided by the TinyTP buffer size of the communication peer.The sender will send SDU if w > 0 and subtract w by 1.Therefore, each TinyTP application can send maximum w SDU without receiving acknowledgement but it has to stop while w = 0. w is updated by the TinyTP acknowledgement from its peer.We assume every TinyTP application has the same value of w in this paper.
Each TinyTP service access point (TTPSAP) is accessible through one and only one LSAP of LM-MUX.A TTP-SAP is identified by the address of the LSAP (provided in IrLMP header) through which it is accessed.After TinyTP   Time for TinyTP to process the received segments and prepare the acknowledgement s connection initialisation, TinyTP adds 1 byte of header carrying information including its own buffer size and the segmentation status.A flow chart of the data transmission with multiple TinyTP connections is provided in Figure 2.

MATHEMATICAL MODELLING
The mathematical model assumes large application files (e.g., mp3, movie clip) to be sent from the primary to the secondary.TinyTP segments therefore are always at the maximum size (l TTP = l LAP − l LMP − l TTP ) to accommodate the ap-plication data.The "connected" TinyTP segments (excluding the connection establishment and termination segments) are considered in the derivation.Therefore, IrLMP and TinyTP have fixed headers of 2 bytes and 1 byte, respectively.We make use of Table 1 for symbol details.

IrLAP modelling
Correct IrLAP frame transmissions following an erroneous frame transmission in the same IrLAP window are considered out of sequence and have to be retransmitted (GBN).Based on the IrLAP model given in [7], in this section, we will derive the average time to successfully transmit one Ir-LAP window at a given BER.Due to the small size of the IrLAP supervision (S-) and acknowledgement (ack-) frames, we consider the IrLAP windows to be transmission error free.
According to the IrLAP standard [4], IrLAP link parameters t s , t I , t ack , p, and t Fout are defined as follows: Both supervision and ack-frame have the same length which is the same as the physical and IrLAP header.If the last frame of the window is in error which causes P-bit loss, neither primary nor secondary is able to send data.F-timer t Fout is the final bit timer used by the primary to limit the time it waits for a frame from the secondary.After t Fout has expired, the primary will send a supervision frame to the secondary acknowledging the link turnaround.Figure 3 illustrates the Ir-LAP operation in detail.
The average time to successfully transmit one IrLAP window consists of the time for frame transmissions, acknowledgements and retransmissions, as well as delays for reversing the link t ta and timer time outs t Fout .As shown in Figure 3, the average time to transmit one IrLAP window with length of A frames is given as follows: ( The probability of having error/errors in an IrLAP window with A frames is Due to the small value of p, p 1 can be approximated as While error/errors occur in transmitting the IrLAP window with probability p 1 , due to the randomness of error occurrence, it is sufficient to assume that on average the error occurs in the middle of the window, and a retransmission will trigger to recover the error with window length of 0.5A.If further error/errors occur in the retransmission with probability of p 2 = p 1 (1 − (1 − p) 0.5A ) ≈ 0.5A 2 p 2 , another retransmission window is needed with window length of half the previous, that is, 0.25A, and so on.When the retransmission window is less than 1, we consider the whole window has been successfully transmitted.By including the first window transmission and all the retransmissions, the average time to successfully transmit the IrLAP window is given: where X is an integer representing the number of retransmissions (X = log 2 A ). X satisfies the length of the retransmission window to be no less than 1 (1/2 X • A ≤ 1).

Derivation of TinyTP throughput
Before deriving TinyTP throughput, we first discuss two TinyTP parameters T ack and T ta .According to the standard [6], TinyTP acknowledgement needs only to provide the updated secondary receiver window size.Therefore, the secondary simply sends the TinyTP header l TTP as the TinyTP ack.By including the headers of the other layers, the transmission time of the TinyTP acknowledgement is given by The time to hold the TinyTP segments in the buffer (T ta ) is the time from passing the IrLAP frames to IrLMP to the time the TinyTP gets acknowledgement ready at the secondary.As shown in Figure 2, T ta includes the time to process and strip the headers all the way up to TinyTP, the time to process the TinyTP segments and drain the TinyTP buffer, as well as preparing TinyTP ack and adding the headers of other layers.For different applications, the time to process the TinyTP segments (T p ) is different.In this paper, we assume that the IrDA device uses 8-bit processor and each 8-bit data takes average 2-CPU cycles.As T p is the major factor of T ta , we assume that T ta ≈ T p : where A is the incoming IrLAP window size and v is the processor speed in Hz.When a TinyTP receiver window size w is allocated for each B TinyTP connections, the IrDA receiver has to assign a TinyTP buffer with size of B × w × l TTP .Given the fact that memory is highly constrained for resource-limited wireless device, such devices often cannot afford large memory size for TinyTP.For a given maximum IrLAP window size N, three possible scenarios by implementing different receiver window size are investigated as follows, where B denotes the number of TinyTP connections.We assume the TinyTP connections equally share the link as IrLMP delivers data based on FIFO queuing.

Bw ≤ N
The TinyTP transmission model is illustrated in Figure 4 by mapping TinyTP segments into IrLAP frames.In Figure 4, parameters w = 2, B = 2, and N ≥ 4 are employed which satisfy Bw ≤ N. The IrLAP window will be always less than four due to the w constraint.As the time to prepare the TinyTP acknowledgement packet T ta depends on the CPU speed of the receiver, it is normally much longer than IrDA link turnaround t ta and the time to transmit the IrLAP ack packet.Thus, it is sufficient to assume T ta > t ta + t ack .After IrLAP successfully delivers the IrLAP frames, the secondary has to wait T ta before the TinyTP acks get ready.Since two TinyTP connections are considered, the secondary needs to send two TinyTP acks.Then, following the same routine another window will be sent from the primary.Therefore, we only need to consider one window transmission for the TinyTP throughput derivation.
As shown in Figure 4, and using (5), the average time for one TinyTP window transmission T 1 is given by where w is the receiver window size and B is the number of TinyTP connections.The TinyTP throughput which is defined as information bits per second is

N < Bw < 2N
The TinyTP transmission model is illustrated in Figure 5.In Figure 5, w = 3, N = 4, and B = 2 are used, which satisfy N < Bw < 2N.The first TinyTP window has 4 segments and makes use of maximum IrLAP window length.Since the secondary is fed by 4 TinyTP segments and has no time to process, the secondary will send 2 TinyTP acks to give the information of available buffer size for each application.In this case, the secondary acknowledges the primary with w1 = w2 = 1 (available buffer size subtracted from the in-    coming segments, 3−2 = 1).The primary is then able to send 2 segments in the second window.Assuming the 4 TinyTP segments of the last window have been processed and consumed, each of the receiver window equals to 2 (3 − 1 = 2).
The secondary then acknowledges with w1 = w2 = 2.As the same process will be repeated, we only need to consider two window transmissions for deriving the TinyTP throughput.The average transmission times for the first and the second IrLAP windows is With the aid of Figure 5 and by using (5), the average time for one TinyTP window transmission T 2 is TinyTP throughput is

Bw ≥ 2N
The TinyTP transmission model in this case is illustrated in Figure 6.In Figure 6, w = 5, N = 4, and B = 2 are used, which satisfy Bw ≥ 2N.The first TinyTP window has 4 segments which make use of maximum IrLAP window length.The secondary acknowledges with w1 = w2 = 3 (available buffer size subtracted from the incoming segments, 5 − 2 = 3).The primary is then allowed to send another 4 segments in the second window.Assuming the TinyTP segments of last window have been processed and consumed, the secondary then acknowledges with w1 = w2 = 3 (5 − 2 = 3), and so on.Therefore, we only need to consider one window transmission for deriving the TinyTP throughput.
From Figure 6, each of the IrLAP windows has a length of N. The average transmission time for the first and the second IrLAP windows is The TinyTP throughput is given by TinyTP throughput efficiency (TPE) is given by

TinyTP THROUGHPUT ANALYSIS
Equations ( 9), (12), and ( 14) reveal the parameters TinyTP throughput depends on.In this section, in order to provide a suitable design guideline for IrDA devices, we carry out an inclusive throughput analysis.We compare the throughput by implementing different TinyTP buffer sizes for various BERs.Subsequently, we examine the effect of IrLAP turnaround time on the throughput.Finally, we investigate the effect of the processor speed.

Effect of TinyTP receiver window size (w)
In Figure 7, TinyTP TPEs are compared by implementing different receiver window sizes w.We fix the maximum Ir-LAP window and frame size at N = 20 and l = 16 kbit, respectively.The following parameters are used for this figure: C = 16 Mbps, v = 10 MHz, t ta = 10 −4 second, and B = 2. Unless otherwise specified, the same values of C, v, t ta , and B are implemented throughout this paper.The throughput efficiencies are plotted against the BER in the range of 10 −5 to 10 −8 .
As shown in Figure 7, all of the three TPE deteriorate with the increase in the BER.In the case of w = 15 and 30, the system obtains much better TPEs than when w = 5 especially for low BER (TPE > 0.8).The TPE for w = 30 is slightly better than for w = 15.The graph shows that the system achieves the best throughput for any BER by using a receiver window size at least twice the maximum IrLAP window size (Bw ≥ 2N ).However, a good TinyTP throughput level is also reached by using w = 15 (N < Bw < 2N).Therefore, a receiver window size in the range of N < Bw < 2N obtains good system performance as well as requiring relatively smaller buffer size.

Effect of IrLAP window size (N) and frame size (l)
In Figure 8, TinyTP TPEs are compared by implementing different IrLAP windows and frame sizes.The TinyTP receiver window size is set to w = 20.Throughput efficiency is plotted against the BER in the range of 10 −5 to 10 −8 .All the TPE curves decrease with the increasing BER.The system achieves better TPE by using large frame size (l = 16 Kbit) at low BER, however, at the high BER, the system obtains better TPE by implementing small frame size (l = 2 Kbit).For the same window size, the crossing points of the two curves that represent different frame size l implying a better throughput may be achieved by appropriately adjusting of window and frame sizes.

Effect of processor speed (v)
We assume here that the TinyTP segments in the previous window have been processed for the case of N < Bw < 2N and Bw ≥ 2N.This assumption holds true when the extreme condition T ta ≤ 3t ta + 2t ack + BT ack + t I is satisfied.To fulfill this condition, processor speed has to be at least as fast as CNl TTP /4(3Ct ta + 2Ct ack + CBT ack + l LAP ).For instance, for a 1− Mbps IrDA link with N = 4, l LAP = 16 kbit, t ta = 10 −3 s, and B = 2, processor speed v has to be at least 0.8 MHz to satisfy the condition.If v < CNl TTP /4(3Ct ta + 2Ct ack + CBT ack + l LAP ), TinyTP throughput will be deteriorated due to the extra time needed to wait for the TinyTP segment processing.Based on our TinyTP model, Figure 9 shows the effect of processing speed when Bw ≤ N. We obtain the result by using the following parameters: N = 20, l = 16 Kbit, and w = 5.The TPEs are plotted in three different BERs against the processor speed in the range of 10 5 to 10 8 Hz.All three TPE curves increase with the processor speed until saturation for v > 10 7 Hz = 10 MHz.Because T ta becomes larger than t ta + t ack when v > 10 MHz, the secondary will wait for t ta + t ack instead of T ta before sending the TinyTP acks.Therefore, the processor speed will not benefit from the system throughput when v > 10 MHz.However, the TPE increases significantly with the processor speed up to 10 MHz.Therefore, v = 10 MHz is a suitable processing speed for the 16 Mbps IrDA links.

Optimum TinyTP receiver window size w
As shown in Figure 7, the system achieves its best performance when Bw ≥ 2N because it takes full advantage of the IrLAP maximum window size.However, the system will reach the same throughput as Bw = 2N when Bw > 2N.Because the throughput is also constrained by the IrLAP window size N, it will not be improved by a receiver window size larger than 2N.Therefore, a receiver window size of w = 2N can always achieve the best throughput even only one TinyTP connection is running.As shown in Figure 7, good TinyTP throughput is also obtained by using a receiver window size of N < Bw < 2N.For the memory scarce devices, in order to improve system performance and resource requirement, TinyTP can use a receiver window size in the range of N < Bw < 2N, as this range achieves good throughput as well as requiring relatively small buffer size.

Optimum IrLAP window size N and frame size l LAP
As shown in Figure 8, if IrLAP window and frame sizes can be optimised, we can achieve better throughput at the TinyTP level.In [10,11], optimisation equations of the IrLAP parameters are presented to maximise the IrLAP throughput.However, when considering TinyTP performance optimisation, due to the constraint of receiver window size, the optimisations at IrLAP level are not suitable for TinyTP.In order to maximise the TinyTP throughput for any given receiver window size and BER, IrLAP parameters are optimised in this section.In situations where it is convenient to optimise only one variable, either N or l LAP , we obtain maximum TinyTP throughput by using optimum values for l LAP or N, respectively.However the best TinyTP throughput would be obtained when both N and l LAP are simultaneously optimised with BER.

Optimum window or frame size for maximum
TinyTP throughput Because each TinyTP connection cannot send more than w segments before receiving an acknowledgement, IrLAP window size always equals Bw, as shown in Figure 4. Therefore, in this case, we only need to optimise IrLAP frame size l LAP for a fixed N with value of Bw.By calculating ∂D/∂l LAP = 0 for (9), which is a function of l LAP , the optimum value of l LAP for any fixed N is derived.After some calculations and careful approximations, the optimum equation for l LAP is derived: (16)

N < Bw < 2N
In this case, both N and l LAP are adjustable.N is limited in the range from N to 2N.It is possible to maximise throughput by fixing either N or l LAP and optimising the other.By taking ∂D/∂N = 0 for (12), the optimum value of N for any fixed l LAP is derived.Also, for fixed N, optimum l LAP value is derived by taking the derivative of D, ∂D/∂l LAP = 0.After some calculus and approximations, the optimum equations for N and l LAP are given by By using the same approach as given above, optimum equations for N and l LAP are given by where l = l PHY + l LAP .

Simultaneous optimum window and frame size for maximum TinyTP throughput
In this case, both window and frame size can be simultaneously adjusted.
In order to examine the accuracy of the optimum equations derived in this section, we compare the results obtained from the equations with the results obtained from exact numerical methods.In Figure 10, the overall TPE is plotted against BER in the range from 10 −5 to 10 −8 by implementing the simultaneously optimised N and l.The corresponding optimised IrLAP window and frame size used are plotted in Figure 11.
As shown in Figure 11, the optimum frame sizes l opt are fixed at 16 Kbit in the low BER and then drop down significantly with the increasing BER.The exact and equation approaches for the optimum values have only small differences.For all of the three cases, the curves representing two different approaches follow the same shape and are very close to each other.The optimum window sizes N opt have exactly the same values of 20 for either exact or using the equation results when N < Bw < 2N.N opt also shows very good agreement for Bw ≥ 2N, especially in the low BER.
In Figure 10, the throughput efficiencies gradually decrease when the BER increases.Comparing the optimum TPE results obtained from the equations with results obtained from exact numerical methods, they show very good agreement for all three cases.Moreover, the system always acquires its optimum throughput in the case of Bw > 2N.Therefore, for a given size of TinyTP receiver window, N opt should always satisfy the condition Bw > 2N and be calculated from (19) and (22) for the corresponding BER.A comparison between Figures 8 and 10 shows that optimisations of IrLAP window and frame size are necessary since the performance is significantly improved at TinyTP level when the optimum values are used.

Optimum IrLAP turnaround time
In order to examine the effect of IrLAP turnaround time, optimum N and l are considered.As shown in the previous section, N opt should always satisfy the condition Bw > 2N for  the maximum throughput.Therefore, we only need to consider the case of Bw > 2N.In Figure 12, TinyTP TPEs are plotted against IrLAP turnaround time in the range of 10 −5 to 10 −2 second.The TPEs are compared by implementing three different BERs.The receiver window size is fixed at 20.As shown in Figure 12, the TPEs for low BER are better than in the high BER for the same IrLAP turnaround time.With t ta in the range of t ta < 10 −4 s = 0.1 millisecond, the three TPEs only increase slightly.However, the TPEs decrease significantly when t ta increases above 0.1 millisecond.By considering the system performance and hardware requirement tradeoff, it can be seen that an IrLAP turnaround time at the level of 10 −4 second is a suitable parameter for the 16-Mbit IrDA links.

CONCLUSIONS
In this paper, we derive a comprehensive model for the IrDA TinyTP performance in the presence of BER by considering multiple IrLMP connections and taking the underlying IrDA protocol stacks into account.Based on the model, the throughput efficiencies are compared by implementing different receiver window size, and IrLAP window and frame sizes.The results show that the system always achieves its best performance when Bw ≥ 2N and can be maximised by optimising IrLAP window and frame sizes for any given BER.Subsequently, an inclusive study for parameter optimisations is carried out for the system.Several optimisation equations for IrLAP window and frame sizes are derived and later validated in the simulations.Finally, the effect of IrLAP turnaround time on the throughput is examined.An IrLAP turnaround time of the order in 10 −4 second is a suitable parameter for 16− Mbps links.By comparing the results, we can see that significant improvements on the throughput are achieved by applying the optimised parameters.

Figure 3 :
Figure 3: (a) Error-free transmission of an IrLAP window, (b) retransmission frames due to error frame at frame 3, and (c) retransmitted frames and F-timer delay due to frame error at I=3 and I=7 (P-bit lost).

Figure 7 :
Figure 7: Overall TinyTP throughput efficiency comparison using different receiver window sizes w.Overall TinyTP throughput is the aggregate throughput of B channels, and IrLAP window N = 20.

Table 1 :
Parameters used in the modelling.
The maximum possible throughput performance can be achieved.In order to derive optimum N and l values, first we fix l LAP to derive optimum N by taking ∂D/∂N = 0.Then, the derived optimum N equation (l LAP dependent) is substituted into the throughput equation.Throughput D becomes a function of frame size l LAP for optimum N values.By taking ∂D/∂l LAP = 0, optimum l LAP equation is derived.This essentially derives the conditions for ∂D b /∂N = ∂D b /∂l LAP = 0. Finally, by substituting optimum l LAP equation back to optimum N equation (l LAP dependent), we can derive the optimum equation N.6.2.2.1.Bw ≤ NAs described in Section 6.2.1.1,IrLAP window size is fixed at Bw. Therefore, only IrLAP frame size l LAP is needed to optimise for throughput which is given in (16).