Giuseppe Bianchi Layer 2 Framing HDLC (High-level Data Linl Control)
Giuseppe Bianchi HDLC Typical Layer 2 protocol Services: Framing Error detection and frame retransmission Flow control Most of current line-based L2 protocols are derived from HDLC PPP (dial-up, ADSL, …) LAP-D (ISDN) LAP-B (X.25) …
Giuseppe Bianchi Why framing? Framing received frames transmitted frames PHY: - bit oriented byte oriented FRAMES = “structured” information & control fields PHY = bit/byte streams
Giuseppe Bianchi HDLC Frame Format Flag 1 byte Address 1-n bytes Control 1-2 bytes Information (variable) FCS 2-4 bytes Flag 1 byte Each frame starts & ends with reserved flag: = 0x7e Just one flag required between consecutive frames Two consecutive flags = empty frame Just ignore flagHDLC frameflagHDLC frame flagHDLC frameflagHDLC frameflag
Giuseppe Bianchi The need for “stuffing” Flag FRAME Flag Flag FRAME Flag FRAME Flag
Giuseppe Bianchi Bit stuffing HDLC Frame delineated by flag character Six consecutive 1s Bit stuffing: prevent occurrence of more than five 1s! Transmitter inserts extra 0 after each consecutive five 1s inside the frame Receiver checks for five consecutive 1s if next bit = 0, it is removed if next two bits are 10, then flag is detected If next two bits are 11, then frame has errors
Giuseppe Bianchi Bit stuffing example Data to be sent: After stuffing and framing * * Data received After destuffing and deframing EXAMPLE: send EXAMPLE: receive
Giuseppe Bianchi Byte stuffing Byte-oriented channels? Same stiffing idea, but stuffing via control escape octes: Send (“reserved” byte) as (control escape octet) + (reserved byte)XOR( ) Extra XOR (bit 5 complemented) for improved robustness Control escape octet = 0x7d – of course NOW this is a reserved byte, too! 113F7E027D10 113F7D027D105E5D Receiver detects control escape And removes it restoring original byte as part of the frame (e.g. not as flag) See RFC 1662 for bit-stuffing over bit synchronous links (versus byte-oriented links)
Giuseppe Bianchi HDLC Frame Content Flag 1 byte Address 1-n bytes Control 1-2 bytes Information (variable) FCS 2-4 bytes Flag 1 byte Address: Receiving (secondary) station Or Transmitting (secondary) station in case of response = broadcast address Control Frame type and transmission control information FCS CRC16 or CRC32 for error detection Size of fields decided during link set-up/initialization procedure
Giuseppe Bianchi Control field Three types of frames I = Information frame S = Supervisory frame U = Unnumbered frame
Giuseppe Bianchi Information Frame N(S) # of currently transmitted frame N(R) # of next frame expected to be received i.e., ACK of all frames until N(R)-1 P/F bit For polling operation 0N(S) P/F 0 8 bit case 16 bit case N(R) P/F N(S)N(R)
Giuseppe Bianchi Supervisory Frame Control frame used to manage ACK and flow control S=RR (Receive Ready) Carries cumulative ACK up to N(R)-1 S=RNR (Receive Not Ready) Blocks sender (flow control), carries cumulative ACK as well S=REJ (Reject) Negative ACK for frame # N(R), for Go-Back-N case S=SREJ (Selective Reject) Negative ACK for frame # N(R), for Sel. Repeat case Extension: OTHER frame # to be retransmitted may be included in the frame information field 1 P/F 8 bit case 16 bit case N(R) P/F N(R) 0S 10S0000
Giuseppe Bianchi Unnumbered Frame Frames used for datalink management Initialization, Setup/release, Reset, Management and notification of malfunctions and issues Several control messages See details and examples in book Different datalink scenarios Asynchronous Balanced Mode (ABM) LAP-B Two full-duplex stations Normal Response Mode (NRM) Unbalanced (half-duplex) operation: primary station can only access link, secondary station is slave Asynchronous Response Mode (ARM) Like NRM, but secondary station may further initiate an unsolicited transmission 1 P/F M1M