9-HDLC-new

Embed Size (px)

Citation preview

  • 8/12/2019 9-HDLC-new

    1/38

  • 8/12/2019 9-HDLC-new

    2/38

    Data Link Protocols

    Directly connected, wire-like Losses & errors, but no out-of-

    sequence frames

    Applications: Direct Links;LANs; Connections acrossWANs

    Data Links Services Framing

    Error control

    Flow control

    Multiplexing

    Link Maintenance

    Security: Authentication &Encryption

    Examples

    PPP

    HDLC

    Ethernet LAN

    IEEE 802.11 (Wi Fi) LAN

    Data link

    layer

    Physical

    layer

    Physical

    layer

    Data link

    layerA B

    Packets Packets

    Frames

  • 8/12/2019 9-HDLC-new

    3/38

    Framing

  • 8/12/2019 9-HDLC-new

    4/38

    Framing

    Mapping stream ofphysical layer bits into

    frames

    Mapping frames into

    bit stream

    Frame boundaries can

    be determined using:

    Character Counts Control Characters

    Flags

    CRC Checks

    0

    110110111

    Framing

    received

    frames

    0111110101

    transmitted

    frames

  • 8/12/2019 9-HDLC-new

    5/38

    Data to be sent

    A DLE B ETX DLE STX E

    After stuffing and framing

    DLE DLE B ETX DLE DLE STXDLE STX A E DLE ETX

    Character-Oriented Framing

    Frames consist of integer number of bytes Asynchronous transmission systems using ASCII to transmit printable

    characters

    Octets with HEX value

  • 8/12/2019 9-HDLC-new

    6/38

    Byte stuffing is the process of adding 1 extra byte

    whenever there is a flag or escape character in the text.

    Note

  • 8/12/2019 9-HDLC-new

    7/38

    Bit stuffing is the process of adding one extra 0 whenever

    five consecutive 1s follow a 0 in the data, so that the

    receiver does not mistakethe pattern 01111110 for a flag.

    Note

  • 8/12/2019 9-HDLC-new

    8/38

    Framing & Bit Stuffing

    Frame delineated by flag character HDLC uses bit stuffingto prevent occurrence of flag

    01111110 inside the frame

    Transmitter inserts extra 0 after each consecutive

    five 1s insidethe 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

    Flag FlagAddress Control Information FCS

    HDLC frame

    any number of bits

  • 8/12/2019 9-HDLC-new

    9/38

    11.9

    Figure 11.4 Bit stuffing and unstuffing

  • 8/12/2019 9-HDLC-new

    10/38

    0110111111111100

    Data to be sent

    After stuffing and framing

    0111111001101111101111100001111110

    (a)

    *000111011111-11111-110*

    Data received

    After destuffing and deframing

    01111110000111011111011111011001111110

    (b)

    Example: Bit stuffing & de-

    stuffing

  • 8/12/2019 9-HDLC-new

    11/38

    PPP Frame

    PPP uses similar frame structure as HDLC, except

    Protocol type field

    Payload contains an integernumber of bytes

    PPP uses the same flag, but uses byte stuffing

    Problems with PPP byte stuffing

    Size of frame varies unpredictably due to byte insertion

    Malicious users can inflate bandwidth by inserting 7D & 7E

    Flag FlagAddress Control Information CRCProtocol01111110 011111101111111 00000011

    Unnumbered

    frame

    Specifies what kind of packet is contained in the

    payload, e.g., LCP, NCP, IP, OSI CLNP, IPX

    All stations are to

    accept the frame

    integer # of bytes

  • 8/12/2019 9-HDLC-new

    12/38

    PPP is character-oriented version of HDLC Flag is 0x7E (01111110)

    Control escape 0x7D (01111101)

    Any occurrence of flag or control escape inside of frame isreplaced with 0x7D followed by

    original octet XORed with 0x20 (00100000)

    Byte-Stuffing in PPP

    Data to be sent

    41 7D 42 7E 50 70 46

    After stuffing and framing

    5D 42 7D 5E 50 70 467E 41 7D 7E

  • 8/12/2019 9-HDLC-new

    13/38

    Receiver removes flags.

    In the frame, when it comes across a control

    character ( 7D),it is immediately dropped and

    the next octet is Ex-Or ed with 0x20 and theresult is the data byte.

  • 8/12/2019 9-HDLC-new

    14/38

    High -Level Data Lin k Con tro l

  • 8/12/2019 9-HDLC-new

    15/38

    High-Level Data Link Control

    (HDLC)

    Bit-oriented data link control

    Derived from IBM Synchronous Data Link

    Control (SDLC)

    Related to Link Access Procedure Balanced(LAPB)

    LAPD in ISDN

    LAPM in cellular telephone signaling

  • 8/12/2019 9-HDLC-new

    16/38

    Physical

    layer

    Data link

    layerData link

    layer

    Network

    layer

    DLSDU DLSDU

    Network

    layer

    Physical

    layer

    DLPDU

    NLPDU

    Packet

    Frame

    DLSAP DLSAP

  • 8/12/2019 9-HDLC-new

    17/38

    Normal Response Mode

    Used in polling multidrop lines

    Asynchronous Balanced Mode

    Used in full-duplex point-to-point links

    HDLC Data Transfer Modes

    Primary

    Commands

    Responses

    Secondary Secondary Secondary

    Primary

    Secondary

    Commands Responses

    Primary

    Secondary

    CommandsResponses

    Mode is selected during connection establishment

  • 8/12/2019 9-HDLC-new

    18/38

    HDLC Frame Format

    Control field gives HDLC its functionality

    Codes in fields have specific meanings and uses Flag: delineate frame boundaries

    Address: identify secondarystation (1 or more octets) In ABM mode, a station can act as primary or secondary so

    address changes accordingly

    Control: purpose & functions of frame (1 or 2 octets) Information: contains user data; length not standardized, but

    implementations impose maximum

    Frame Check Sequence: 16- or 32-bit CRC

    Flag FlagAddress Control Information FCS

  • 8/12/2019 9-HDLC-new

    19/38

  • 8/12/2019 9-HDLC-new

    20/38

    Control Field Format

    0 N(S) N(R)P/F

    1 2-4 5 6-8

    Information Frame

    N(R)P/F

    Supervisory Frame

    1 0 S S

    Unnumbered Frame

    P/F1 1 M M M M M

    S: Supervisory Function Bits

    N(R): Receive Sequence Number

    N(S): Send Sequence Number

    M: Unnumbered Function Bits

    P/F: Poll/final bit used in interactionbetween primary and secondary

  • 8/12/2019 9-HDLC-new

    21/38

    Information frames

    Each I-frame contains sequence number N(S)

    Positive ACK piggybacked

    N(R)=Sequence number of nextframe expected

    acknowledges all frames up to and including N(R)-1

    3 or 7 bit sequence numbering

    Maximum window sizes 7 or 127

    Poll/Final Bit

    NRM: Primary polls station by setting P=1; Secondary

    sets F=1 in lastI-frame in response

    Primaries and secondaries always interact viapairedP/F

    bits

  • 8/12/2019 9-HDLC-new

    22/38

  • 8/12/2019 9-HDLC-new

    23/38

    Control Field Format

    0 N(S) N(R)P/F

    1 2-4 5 6-8

    Information Frame

    N(R)P/F

    Supervisory Frame

    1 0 S S

    Unnumbered Frame

    P/F1 1 M M M M M

    S: Supervisory Function Bits

    N(R): Receive Sequence Number

    N(S): Send Sequence Number

    M: Unnumbered Function Bits

    P/F: Poll/final bit used in interactionbetween primary and secondary

  • 8/12/2019 9-HDLC-new

    24/38

    Supervisory frames

    Used for error (ACK, NAK) and flow control (Dont Send): Receive Ready(RR), SS=00

    ACKs frames up to N(R)-1 when piggyback not available

    REJECT(REJ), SS=01

    Negative ACK indicating N(R) is first frame not receivedcorrectly. Transmitter must resend N(R) and later frames

    Receive Not Ready(RNR), SS=10 ACKs frame N(R)-1 & requests that no more I-frames be sent

    Selective REJECT(SREJ), SS=11 Negative ACK for N(R) requesting that N(R) be selectively

    retransmitted

  • 8/12/2019 9-HDLC-new

    25/38

    Control Field Format

    0 N(S) N(R)P/F

    1 2-4 5 6-8

    Information Frame

    N(R)P/F

    Supervisory Frame

    1 0 S S

    Unnumbered Frame

    P/F1 1 M M M M M

    S: Supervisory Function Bits

    N(R): Receive Sequence Number

    N(S): Send Sequence Number

    M: Unnumbered Function Bits

    P/F: Poll/final bit used in interactionbetween primary and secondary

  • 8/12/2019 9-HDLC-new

    26/38

    Unnumbered Frames

    Setting of Modes: SABM: Set Asynchronous Balanced Mode

    UA: acknowledges acceptance of mode setting commands

    DISC: terminates logical link connectio

    Information Transfer between stations

    UI: Unnumbered information

    Recovery used when normal error/flow control fails

    FRMR: frame with correct FCS but impossible semantics

    RSET: indicates sending station is resetting sequence

    numbers

    XID: exchange station id and characteristics

  • 8/12/2019 9-HDLC-new

    27/38

    11.27

    Table 11.1 U-frame control command and response

    Example 11 9

  • 8/12/2019 9-HDLC-new

    28/38

    11.28

    Figure 11.29 shows how U-frames can be used for

    connection establishment and connection release. Node A

    asks for a connection with a set asynchronous balanced

    mode (SABM) frame; node B gives a positive response with

    an unnumbered acknowledgment (UA) frame. After thesetwo exchanges, data can be transferred between the two

    nodes (not shown in the figure). After data transfer, node A

    sends a DISC (disconnect) frame to release the connection;

    it is confirmed by node B responding with a UA(unnumbered acknowledgment).

    Example 11.9

    C ti E t bli h t &

  • 8/12/2019 9-HDLC-new

    29/38

    Connection Establishment &

    Release

    Supervisory frames used to establish and releasedata link connection

    In HDLC

    Set Asynchronous Balanced Mode (SABM)

    Disconnect (DISC)

    Unnumbered Acknowledgment (UA)

    SABM UAUA DISCData

    transfer

  • 8/12/2019 9-HDLC-new

    30/38

    11.30

    Figure 11.29 Example of connection and disconnection

    Example: HDLC using NRM

  • 8/12/2019 9-HDLC-new

    31/38

    Primary A Secondaries B, C

    B, RR, 0, P

    B, I, 0, 0

    B, I, 1, 0B, I, 2, 0,F

    X

    B, SREJ, 1C, RR, 0, P

    C, RR, 0, F

    B, SREJ, 1,P

    B, I, 1, 0B, I, 3, 0B, I, 4, 0, F

    B, I, 0, 5

    Time

    Example: HDLC using NRM

    (polling)

    A polls B

    B sends 3 info

    frames

    A rejects fr1A polls C

    C has no

    Infmn. frames

    to sendA polls B,

    requests

    selective

    retrans. of fr1B resends fr1

    Then fr 3 & 4

    A send info fr0

    to B, ACKs up to 4

    N(R)

    N(S) N(R)

    Address of secondary

    Frame Exchange using

  • 8/12/2019 9-HDLC-new

    32/38

    Combined Station A Combined Station B

    B, I, 0, 0 A, I, 0, 0

    B, I, 1, 0

    B, I, 2, 1

    A, I, 1, 1

    A, I, 2, 1

    X

    B, REJ, 1B, I, 3, 2

    B, I, 4, 3

    B, I, 1, 3

    B, I, 2, 4

    B, I, 3, 4

    A, I, 3, 1

    B, RR, 2

    B, RR, 3

    Frame Exchange using

    Asynchronous Balanced Mode

    A sends 5

    frames to

    B.

    B ACKs fr0

    B rejects

    fr2

    A goes

    back totxing fr1 to

    fr4.B ACKs

    fr1

    B ACKs

    fr2

    Example 11 10

  • 8/12/2019 9-HDLC-new

    33/38

    Figure 11.30 shows an exchange using piggybacking. Node

    A begins the exchange of information with anI-frame numbered 0 followed by another I-frame numbered

    1. Node B piggybacks its acknowledgment of both frames

    onto an I-frame of its own. Node Bs first

    I-frame is also numbered 0 [N(S) field] and contains a 2 inits N(R) field, acknowledging the receipt of As frames 1

    and 0 and indicating that it expects frame 2 to arrive next.

    Node B transmits its second and third I-frames (numbered

    1 and 2) before accepting further frames from node A.

    Example 11.10

    Example 11 10 (continued)

  • 8/12/2019 9-HDLC-new

    34/38

    Its N(R) information, therefore, has not changed: B frames

    1 and 2 indicate that node B is still expecting Asframe 2 to

    arrive next. Node A has sent all its data. Therefore, it

    cannot piggyback an acknowledgment onto an I-frame and

    sends an S-frame instead. The RR code indicates that A isstill ready to receive. The number 3 in the N(R) field tells B

    that frames 0, 1, and 2 have all been accepted and that A is

    now expecting frame number 3.

    Example 11.10 (continued)

  • 8/12/2019 9-HDLC-new

    35/38

    11.35

    Figure 11.30 Example of piggybacking without error

    Example 11 11

  • 8/12/2019 9-HDLC-new

    36/38

    Figure 11.31 shows an exchange in which a frame is lost.

    Node B sends three data frames (0, 1, and 2), but frame 1 is

    lost. When node A receives frame 2, it discards it and sends

    a REJ frame for frame 1. Note that the protocol being used

    is Go-Back-N with the special use of an REJ frame as aNAK frame. The NAK frame does two things here: It

    confirms the receipt of frame 0 and declares that frame 1

    and any following frames must be resent. Node B, after

    receiving the REJ frame, resends frames 1 and 2. Node Aacknowledges the receipt by sending an RR frame (ACK)

    with acknowledgment number 3.

    Example 11.11

  • 8/12/2019 9-HDLC-new

    37/38

    Figure 11.31 Example of piggybacking with error

  • 8/12/2019 9-HDLC-new

    38/38

    I3 I4 I5 I6RNR5 RR6

    Flow Control

    Flow control is required to prevent transmitter fromoverrunning receiver buffers

    Receiver can control flow by delayingacknowledgement messages

    Receiver can also use supervisory frames toexplicitly control transmitter Receive Not Ready (RNR) & Receive Ready (RR)