IrDA Link Access Protocol
By Mike Rodbell
The specific needs of the infrared link are accommodated through a combination of extensions to the protocol data-unit formats and negotiation mechanisms.
Last month, we reviewed the general concepts and primitives used in the Infrared Data Association's (IrDA) link access protocol (LAP). The mechanisms provided by the protocol leverage the widely accepted high-level data link control (HDLC) link protocols. The specific needs of the infrared link are accommodated through a combination of extensions to the protocol data-unit formats and negotiation mechanisms. We've identified the various types of frames that are used in the protocol. With some background
information in the frames sent back and forth, you should now be prepared to make some sense out of the information exchanges involved in IrLAP.
This month, the following types of exchanges are of particular interest:
-
Selection and arbitration
of the primary station
-
Address negotiation
-
Capability negotiation
-
Sniffing
, a procedure for low-power stations to conserve power while awaiting a connection
-
Connection establishment
-
Connection-oriented information exchange
-
Connectionless information exchange.
Some of these mechanisms apply to typical HDLC communication links running in normal response mode. Others, such as address negotiation, link speed negotiation, and selection of the primary, are features that were invented by the engineers responsible for developing the IrDA standards.
Someone's gotta control this link! Who's the boss?
As a
half-duplex connection based on the polling mode features of normal response mode, one of the stations must assume the role of the primary, initiating all transactions. The primary station is typically selected as an artifact of the application roles of each of the machines participating in the conversation. The client station (or initiator, for you OSI types) typically assumes the role of the primary, initiating all conversations. Example client roles might include a laptop computer connecting to a printer.
Conversely, server applications passively listen for connections. These systems typically end up playing the role of the secondary link station, reacting to commands and requests issued by the primary station.
However, there is always an opportunity for the two stations to collide. IrDA provides mechanisms to resolve contention for the primary role through a negotiation procedure. This procedure provides a set of mechanisms where two colliding stations can negotiate for ownership of the primary station
role. To accomplish the exchange of roles, a secondary station must request the ability to operate as the primary by sending the RXCHG frame. The primary can either permit the exchange through transmitting the RXCHG frame, or alternatively, deny the request with a DXCHG frame. When an exchange acceptance is received by the secondary, it should then emit a receiver ready (RR) frame to the old primary with the control bit set. On receipt of the new primary's RR, the old primary should then revert to the
secondary mode of operation.
What happens when both stations have the same address?
To manage the IrLAP link, each station must have a unique address. To avoid the cumbersome (and frequently impossible) process of having users assign link and station addresses, IrLAP offers an automated way to ensure that both stations have unique addresses - address conflict resolution. To ensure that each station is operating with a unique address, the initiating station can send an exchange identification (XID)
command as a request to any receiving secondary stations. On receipt of the XID, the secondary station(s) then select a new address and a new timeslot in which to send their response. When more than one secondary station is listening to the primary station, they randomly select the response time slot. This time slot is indicated by the polling information received from the primary's XID frame (
Figure 1
). As you can see in Figure 1, station B selects slot 2 as the response
frame, and station C selects slot 4 to respond. On receipt of nonconflicting station addresses, the primary station (A) can proceed to establish a connection and perform subsequent operations.
Coordinating behavior: negotiation
When designing a set of protocols that are expected to provide a wide range of services, one can't always anticipate the full range of combinations that equipment will require. A good way to manage differences between the capabilities of different types of equipment is
through procedures for negotiation. When properly implemented, the negotiation procedures provide all participating stations with the information needed to identify the greatest common denominator of the stations' capabilities. In the case of IrLAP version 1.1, the following capabilities are included:
-
Baud rate
frees devices directly supporting all baud rates and provides a mechanism for two stations to determine the maximum speed at which both can reliably operate.
-
Maximum turn around time
identifies the maximum amount of time that a station is allowed to retain control of the poll/final (P/F) bit (preventing the other station from using the link).
-
Data size
is the maximum amount of data that can be accepted within an information frame. By providing this feature through negotiation, devices that do not require great deals of information transport can limit their buffer pools to smaller buffers, leaving memory for more useful purposes.
-
Window size
identifies the maximum number of unacknowledged frames that either station should have outstanding.
-
Additional beginning of frame (BOF)
characters are the number of BOFs that should be sent prior to the start of a frame. Stations that may require additional time to prepare their receivers can request longer sequences of framing characters.
-
Minimum turn around time
is the minimum amount of time either station delays prior to resuming control of
the link. Through this mechanism, transmitting stations can successfully avoid sending information prior to the receiving station's ability to enable.
-
Link disconnect/threshold time
is the amount of time after which a station that does not hear from its peer will mark the link as disconnected.
Once these parameters have been negotiated between two stations, a connection can be established, and orderly behavior is guaranteed.
When two stations are establishing a connection,
only a minimal amount of configuration is shared. To ensure that the stations are able to negotiate a full set of parameters, a minimal state of capabilities must be supported by all IrLAP implementations. These essential capabilities include the following:
- All transmissions occur at 9,600 bps.
- Asynchronous character framing is 8 data bits, with 1 start bit and 1 stop bit.
- Window size is one.
- Maximum data size is 64 octets.
- Maximum turn-around time is 500 ms.
- There are
eleven BOFs before each frame. (Previous versions of IrLAP permitted five BOFs, which may not always work.)
When all stations abide by these parameters, negotiation can be performed and station operation can be transitioned to a more efficient mode, once all negotiations have been completed.
The mechanisms used in the negotiation procedure are based on the exchange of two general types of parameters, type-0 parameters and type-1 parameters. The type-0 parameters are those in which any one of a
set of parameters are sufficient; these cases are reported as a bitmap in which the transmitting station sets the acceptable bits. Examples of type-0 parameters include data rates. For type-1 parameters, the station requires a specific value in order to operate. An example of the type-1 parameter is the maximum turn around time.
The following steps are taken to determine the type-0 parameter configuration:
- The primary sends a set-named response mode (SNRM) frame with all of the appropriate
(define-PV) field bits set.
- On receipt of the SNRM frame, the secondary calculates the common capabilities that the two stations support, and responds to the SNRM with an unsequenced acknowledgment (UA) frame, with the resulting mutually-supported feature sets.
- Of the resulting sets of parameters, the most significant bit of each parameter set is considered to be the selected capability of the referenced feature.
If either station does not support any of the parameters, they are
ignored, rather than dropping the connection. As a result, connections can proceed.
Type-1 parameter negotiation is a somewhat simpler matter. Only a single value is sent, and the receiving stations need only to verify this value. If a problem is found, the detecting station should repeat the request for the negotiation parameters until the two stations are able to settle on a desirable feature set.
When low power is critical, sniff for your neighbors
It's not unusual for IrDA applications to
involve miniaturized devices where every ýW of power is a precious commodity. IrLAP accomplishes this power conservation through a technique called "sniffing."
With these IrLAP special features in mind, let's now review the more general-purpose protocol exchanges, stolen (well, borrowed) directly from the land of HDLC.
-
Connection establishment
-
Connection-oriented information exchange
-
Connectionless information exchange.
These
exchanges directly use the standard HDLC information exchange primitives.
Connection establishment is performed under the control/ request of the primary station. When an application requires the use of an IrDA link, the IrLAP process is signaled, causing an unconnected station to emit the SNRM command. On receipt of a UA frame from the secondary station, the link is in the connected mode of operation (
Figure 2
). Subsequent transmissions occur using the I and S frames.
Referring to Figure 2 again, connection-oriented information exchange is accomplished through the exchange of I and RR frames. In the example shown in Figure 2, once the link is established, a station (B in this case) can transfer information using information frames. The sequence numbers in the frame maintain the ordering of the frames. Note that the I frames contain two types of sequence numbers: one for transmit and one to indicate the next expected receive frame. In this case, station B is sending
frames 0, 1, and 2 to station A. In sending the RR frame with receive sequence number 3, station A signals that it has successfully received all three frames from station B. On receipt of the RR, station B no longer needs to hold the frames for future retransmission. Furthermore, if station B is operating with a maximum window size of 3, it can resume transmission of any new frames that might be on its internal transmission queue. In the event that any of the frames are not successfully delivered to station
A, it can force a retransmission either through issuing a reject (REJ) frame with the sequence number of the next expected I frame or, similarly, through an RR frame with the poll bit set.
Connectionless information exchange does not provide the degree of ordering and data integrity services found with the connection-oriented transmissions. While connectionless information exchange doesn't guarantee delivery of the frames, it ensures that failed transmissions don't hang around and clog the network.
Connectionless transmissions are sent using the unsequenced information frames.
Next month, we step up a rung of the IrDA ladder into the IrDA link management protocol, or IrLMP.
Mike Rodbell is president of DG Technology, a consulting firm that specializes in the development and integration of distributed processing and communication systems. He has developed voice and data communication systems for a wide range of military and commercial systems. He holds a BSCS from Trinity College of Hartford,
CT, and an MSEE from Loyola College of Baltimore, MD. He can be reached at mrodbell@dg-tech.com or http://www.dg-tech.com.
Author's Note
Thanks to Dave Suvak of Counterpoint Systems Foundry for his assistance in negotiating some of the more unique capabilities and features of the IrDA standards. For more information on the many features and combinations of information exchanges that can be performed using IrLAP, take a look at the specification. Services such as exchanging primary
roles and handling stations that are only capable of supporting 2,400-bps operation are included. It's available from the IrDA on the Internet at http://www.irda.org.