The ISDN Data Link Layer is specified by the ITU Q-series documents Q.920 through Q.923. All of the signaling on the D channel is defined in the Q.921 spec.
Link Access Protocol - D channel (LAP-D) is the Layer 2 protocol used. This is almost identical to the X.25 LAP-B protocol.
Here is the structure of a LAP-D frame:
Flag
Address
Control
Information
CRC
Flag
Flag (1 octet) - This is always 7E16 (0111 11102)
Address (2 octets)
1
2
3
4
5
6
7
8
SAPI (6 bits)
C/R
EA0
TEI (7 bits)
EA1
SAPI (Service access point identifier), 6-bits (see below)
C/R (Command/Response) bit indicates if the frame is a command or a response
EA0 (Address Extension) bit indicates whether this is the final octet of the address or not
TEI (Terminal Endpoint Identifier) 7-bit device identifier (see below)
EA1 (Address Extension) bit, same as EA0
Control (2 octets) - The frame level control field indicates the frame type (Information, Supervisory, or Unnumbered) and sequence numbers (N(r) and N(s)) as required.
Information - Layer 3 protocol information and User data
CRC (2 octets) - Cyclic Redundancy Check is a low-level test for bit errors on the user data.
Flag (1 octet) - This is always 7E16 (0111 11102)
The Service Access Point Identifier (SAPI) is a 6-bit field that identifies the point where Layer 2 provides a service to Layer 3.
See the following table:
SAPI
Description
0
Call control procedures
1
Packet Mode using Q.931 call procedures
16
Packet Mode communications procedures
32-47
Reserved for national use
63
Management Procedures
Others
Reserved for Future Use
Terminal Endpoint Identifiers (TEIs) are unique IDs given to each device (TE) on an ISDN S/T bus. This identifier can be dynamic; the value may be assigned statically when the TE is installed, or dynamically when activated.
TEI
Description
0-63
Fixed TEI assignments
64-126
Dynamic TEI assignment (assigned by the switch)
127
Broadcast to all devices
The Layer 2 establishment process is very similar to the X.25 LAP-B setup, if you are familiar with it.
At this point, the connection is ready for a Layer 3 setup.