75
1 Chapter 4 Data Link Layer Framing Error control Flow control Multiplexing Link Maintenance Security

Chapter 4

Embed Size (px)

DESCRIPTION

4th pp

Citation preview

  • Chapter 4 Data Link LayerFramingError controlFlow controlMultiplexingLink MaintenanceSecurity

  • ServicesTransfers frames across direct connectionsDirectly connected (can be wireless), wire-likeLosses & errors, but no out-of-sequence framesMore detailed servicesFraming (bits frames)Error control (protection from impairment)Flow controlMultiplexingLink MaintenanceSecurity: Authentication & Encryption

  • Data Link ProtocolsExamplesPPPHDLCEthernet LANIEEE 802.11 (WiFi) LAN

  • Framing (Chapter 5.4 in Leon-Garcia)

  • FramingBit stream - framesFrame boundaries can be determined using:Character CountsControl CharactersFraming BitsFraming by illegal code

  • Control CharactersWhat about transmission of data (including non-printable characters)?Introduce DLE (data link escape) = 0x10 DLE STX (DLE ETX) used to indicate beginning (end) of frame Insert extra DLE in front of occurrence of DLE STX (DLE ETX) in frameAll DLEs occur in pairs except at frame boundaries.Transmission of printable characters using ASCIIOctets with HEX value < 0x20 are nonprintableUse control characters: STX (start of text) = 0x02; ETX (end of text) = 0x03.

  • Bit StuffingFrame delineated by flag characterHDLC uses bit stuffing to prevent occurrence of flag 01111110 inside the frame Transmitter inserts extra 0 after each consecutive five 1s inside the frameReceiver checks for five consecutive 1sif next bit = 0, it is removedif next two bits are 10, then flag is detectedIf next two bits are 11, then frame has errors

  • Example: Bit stuffing

  • Example: Framing in EthernetEthernet complies to standard IEEE 802.3An illegal manchester coding is used for framing.A character count is also included in the header.All frames have an integral number of bytes. If not, the frame is considered to be received in error.

  • Error Control Coding(Chapter 3.9 in Leon-Garcia)

  • Error ControlTwo approachesForward error correction (FEC)Error detection & retransmission (ARQ)Add redundancy (admit only codewords with a certain pattern)Blindspot: when channel transforms a codeword into another codeword(n,k) block codeThere are capacity-achieving codesUsually with somewhat high complexity;When bandwidth is abundant it suffices to use simpler codes.

  • Single Parity Checkn=k+1All codewords have even # of 1sAll error patterns that change an odd number of bits are detectableOthers undetectableRedundancy: overhead = 1/(k + 1)

  • ExampleInformation (7 bits): (0, 1, 0, 1, 1, 0, 0)

  • Probability of ErrorExample: Evaluate above for n = 6, p = 0.01P[error detection failure]= P[undetectable error pattern] = P[all error patterns with even number of 1s]= p2(1 p)n-2 + p4(1 p)n-4 + P[undetectable error] = 0.0014

  • Two-Dimensional Parity Check

  • Error-detecting capability1, 2, or 3 errors can always be detected; Not all patterns >4 errors can be detected

  • Hamming CodesClass of linear block codesCapable of correcting all single-error patternsFor each m > 2, there is a (2m1, n-m) Hamming code

  • m = 3 Hamming CodeInformation bits are b1, b2, b3, b4Parity checks (binary addition/multiplication)Linearity24 = 16 codewordsb5 = b1 + b3 + b4 b6 = b1 + b2 + b4b7 = + b2 + b3 + b4

  • Hamming (7,4) code

  • Parity Check EquationsRearrange parity check equations:All codewords must satisfy these equationsNote: each nonzero 3-tuple appears once as a column in check matrix HIn matrix form:0 = b1 + b3 + b4 + b5 0 = b1 + b2 + b4 + b60 = + b2 + b3 + b4 + b7

  • Hamming Code: Error Detection

  • Minimum distanceUndetectable error pattern must have 3 or more bitsAt least 3 bits must be changed to convert one codeword into another codewordSet of n-tuples within distance 1 of b1Set of n-tuples within distance 1 of b2Spheres of distance 1 around each codeword do not overlapIf a single error occurs, the resulting n-tuple will be in a unique sphere around the original codewordDistance 3

  • General Hamming CodesFor m > 2, the Hamming code is obtained through the check matrix H:Each nonzero m-tuple appears once as a columnThe resulting code corrects all single errors

    P[undetectable error]= P[ error is a codeword] (# of codewords with dmin) x pdmin

    Animated example http://www.systems.caltech.edu/EE/Faculty/rjm/SAMPLE_20040708.html

  • Hamming Codes: Error-correctionCompute syndrome: s = HR = H (b + e) = Hb + He = He If s = 0, then the receiver accepts R as the transmitted codeword, find the corresponding k-bit messageIf s is nonzero, then an error is detectedHamming decoder assumes a single error has occurredEach single-bit error pattern has a unique syndromeThe receiver matches the syndrome to a single-bit error pattern and corrects the appropriate bit

  • Hamming Codes: Performance Assume bit errors occur independent of each other and with probability p

  • Other Error Control CodesGood practical codes for error detection:Internet Check SumsCRC Polynomial CodesThey can detect the vast majority of errors.

    Good codes for error correction:Turbo codesLow-density parity-check (LDPC) codes

  • Internet ChecksumSeveral Internet protocols (e.g. IP, TCP, UDP) use check bits to detect errors in the header A checksum is calculated for header contents and included in a special field. Treating each 16-bit word in data as an integer, findx = b0 + b1 + b2+ ...+ bL-1 modulo 216-1The checksum is then given by: bL = - x modulo 216-1Thus, the headers satisfy the following pattern: 0 = b0 + b1 + b2+ ...+ bL-1 + bL modulo 216-1

  • Polynomial CodesConvenient mathematical formulation of codingPolynomials as codewordsImplemented using shift-register circuitsCalled cyclic redundancy check (CRC) codesExcellent for detecting burst errors

  • Automatic Repeat Request (ARQ) (Chapter 5 in Leon-Garcia)

  • Peer-to-Peer ProtocolsEach layer provides a service to the layer above.It does so by executing a peer-to-peer protocol.The protocol uses the the services of the layer below.n 1n 1nnn + 1n + 1

  • Service ModelsThe service model specifies the manner in which information is transferred.Connection-orientedConnectionless

  • Connection-OrientedConnection setupMessage transferConnection releaseExample: TCP, PPP

  • Connectionless Transfer ServiceNo setupEach message sent independentlyMust provide all address information per messageSimple & quickExample: UDP, IPn + 1 peer processsendn + 1 peer processreceiveSDULayer n connectionless service

  • Automatic Repeat Request (ARQ)Purpose: To pass to the receiver every frame correctly, only once, in order. Bad things can happen: Error, arbitrary delay, out-of-order arrival, or loss. Aim at very high reliability.Assume if frames arrive, they arrive in-order for now. We save the out-of-order problem for later.Basic elements:Error-detecting codeACKs (positive acknowledgments)NAKs (negative acknowledgments)Timeout mechanism

  • Stop-and-Wait ARQPacketError-freepacketInformation frameControl frameTransmitterReceiverTimer set after each frame transmissionTransmit a frame, wait for ACK

  • Need for Sequence NumbersIn cases (a) & (b) the transmitting station A acts the same wayBut in case (b) the receiving station B accepts frame 1 twiceQuestion: How is the receiver to know the second frame is also frame 1?Need a sequence number: Slast=SN of most recent transmitted frame.

  • Sequence NumbersThe transmitting station misinterprets duplicate ACKsQuestion: How is the receiver to know second ACK is for frame 0?(c) Premature Time-outNeed SN in ACK: Rnext=SN of next frame expected by the receiver.Implicitly acknowledges receipt of all prior frames.What if ACK only if Slast=Rnext?

  • How many bits for SN?1-Bit SN Suffices

  • Finite State Machine

  • S/W Efficiency

  • S/W Transmission Timeframetf timebits/info framechannel transmission ratebits/ACK frame

  • Efficiency on Error-free channelOverhead bits (header, CRC)Effect offrame overheadEffect ofACK frameEffect ofDelay-Bandwidth ProductEffective transmission rate:Transmission efficiency:

  • Delay-Bandwidth Productnf=10,000 bits, na=no=200 bitsS/W inefficient for very high speeds or long delays

  • Average Transmission NumberProposition: Let Pf be the frame error probability. Then the average number of transmissions per successful frame is 1/ (1Pf ).Proof: The number of transmissions to first correct arrival has geometric distribution.

    E.g., if 1-in-10 gets through, then in average 10 tries to success.

  • Efficiency in Channel with ErrorsEffect of frame lossIf bit-error-rate is p, thenAssuming time-out is equal to t0 (it should be larger)

  • Go-Back-NA sliding-window protocol.Keep channel busy by continuing to send framesAllow a window of up to Ws outstanding framesIf ACK for oldest frame arrives before window is exhausted, we can continue transmittingIf window is exhausted, pull back and retransmit all outstanding frames

  • Go-Back-N ARQFrame transmission are pipelined to keep the channel busyFrame with errors and subsequent out-of-sequence frames are ignored

  • Choose Window Size > RTT

  • Go-Back-N with TimeoutProblem with Go-Back-N as presented:If frame is lost and source does not have frame to send, then window will not be exhausted and recovery will not commenceUse a timeout with each frameWhen timeout expires, resend all outstanding frames

  • Go-Back-N Transmitter & ReceiverReceiver will only accepterror-free frame with SN Rnext.

    When the frame arrives Rnext is incremented by 1, so the receive window slides forward by 1.

  • Maximum Window Size Ws = 2m-1Example: M = 22 = 4, Go-Back 4 is not good.Example: Go-Back-3 is good.

  • ACK Piggybacking in Bidirectional GBNIn bi-directional communication, ACKs are often piggybacked on data frames to reduce overhead.

  • Choice of Timeout & Window SizeTimeout value should allow for:2 Tprop + TprocA frame begins transmission right before the first frame arrives TfNext frame carries the ACK, Tf (piggy-back)Thus, timeout > 2 Tprop + 2 Tf + TprocWs should be large enough to keep channel busy for Tout

  • Efficiency of Go-Back-N if channel is error-free and Ws is large enough to keep channel busyAssume Pf frame loss probability, time to deliver a frame is:tf if first attempt succeedsTf + Wstf /(1-Pf) otherwise go back Ws and try again

    Delay-bandwidth product determines Ws

  • Improvement over Go-Back-N?Go-Back-N repeats multiple frames when a few errors or losses occurHow about retransmitting only an individual frame?Selective Repeat ARQTimeout pinpoints individual frameReceiver maintains a window of acceptable SNError-free, but out-of-sequence frames with SN within the receive window are buffered Arrival of Rnext causes window to slide forward by 1 or more NAK causes retransmission of oldest un-acked frame

  • Selective Repeat ARQ

  • Selective Repeat ARQ

  • Send & Receive WindowsTransmitterReceiver

  • What size Ws and Wr allowed?Example: M=22=4, Ws=3, Wr=3

  • Ws + Wr = 2m is maximum allowedExample: M=22=4, Ws=2, Wr=2

  • Why Ws + Wr = 2m worksThe number of bits, m, is enough to label all outstanding frames.Usually, Ws = Wr = 2m-1012Ws-12m-1Slastsendwindow012Ws +Wr-12m-1RnextreceivewindowWs

  • Efficiency of Selective Repeat# of transmissions required to deliver a frame is:tf / (1-Pf)

  • Example: Impact Bit Error Rate on Selective RepeatGBN >> S&W for large delay-bandwidth product GBN becomes inefficient as error rate increases SR is the best. Efficiency drops as error rate increases nf=10,000 bits, na=no=200 bitsp = 0, 10-6, 10-5, 10-4 and R = 1 Mbps & 100 ms 1 Mbps x 100 ms = 100000 bits = 10 frames Use Ws = 11

  • Comparison of ARQ EfficienciesSelective-Repeat:Go-Back-N:Stop-and-Wait:Assume na, no
  • ARQ Efficiencies

  • Standard Data Link Layer Protocols:PPP & HDLC (Chapter 5.5-6 in Leon-Garcia)

  • DLLPhysicallayerData linklayerNetworklayerPacketFramePhysicallayerData linklayerNetworklayer

  • PPP: Point-to-Point ProtocolA data link layer protocol.Encapsulating IP packets over point-to-point links.Router-router;Dial-up to router (PC to Internet service provider (ISP))Functions:Provides Framing and Error DetectionLink Control ProtocolsSet up, configure, testing, maintain, terminate;Authentication: Password Authentication Protocol, etc.Network Control ProtocolsConfigure network layer protocolsE.g., IP, IPX (Novell), Appletalk

  • PPP Frame Format Can support multiple network protocols simultaneously Specifies what kind of packet is contained in the payload

  • High-Level Data Link Control (HDLC)Bit-oriented data link control Derived from IBM Synchronous Data Link Control (SDLC)

  • HDLC Data Transfer ModesNormal Response ModeUsed in polling multidrop linesAsynchronous Balanced ModeUsed in full-duplex point-to-point linksMode is selected during connection establishment

  • HDLC Frame FormatControl field gives HDLC its functionalityCodes in fields have specific meanings and uses Flag: delineate frame boundariesAddress: identify secondary station (1 or more octets)Control: purpose & functions of frame (1 or 2 octets)Information: user data; length not standardizedFrame Check Sequence: 16- or 32-bit CRC

  • Control Field FormatS: Supervisory Function BitsN(R): Receive Sequence NumberN(S): Send Sequence NumberM: Unnumbered Function Bits P/F: Poll/final bit used in interaction between primary and secondaryNote: The information frames and supervisory frames allow HDLC to implement Stop-and-Wait, Go-Back-N, and Selective Repeat ARQ.Note: The unnumbered frames implement control functions.

  • Example: HDLC Using PollingA polls BRR=receive readyB sends 3 infoframesA rejects fr1A polls CC nothing to sendA polls B, requestsselective retrans. fr1B resends fr1Then fr 3 & 4A send info fr0to B, ACKs up to 4N(R)N(S)N(R)Address of secondary

  • HDLC Flow ControlFlow control prevents transmitter from overrunning receiver buffers.Receiver can control flow by delaying acknowledgement messages.Receiver can also use supervisory frames to explicitly control transmitterReceive Not Ready (RNR) & Receive Ready (RR)