Vous êtes sur la page 1sur 58

PRICIPLES OF TELECOMMUNICATION AND PACKET NETWORKS MSc MODULE

EEM.ptn 2007-08
Lecture Component: The Link Layer Lectures 6-8
Prof. George Pavlou Centre for Communication Systems Research http://www.ee.surrey.ac.uk/CCSR/Networks/ G.Pavlou@surrey.ac.uk Tel: 01483 689480

A3.2

DATA TRANSMISSION TECHNIQUES

A3.3

LINK LEVEL FRAMING


The Physical Layer provides a digital serial transmission capability i.e. a raw bit stream. Link-level protocols need to exchange data link messages called frames. We need an unambiguous way of delimiting frames transmitted using the bit stream physical layer service. The process is called Framing and it is an important aspect of the Data Link Layer.

A3.4

COMMUNICATION MODES

Simplex: Data transmitted in one direction only e.g. temperature sensor output in an industrial plant. Half duplex: Data transmitted between communicating parties in both directions but not at the same time. (Full) Duplex: Both communicating parties may transmit and receive at the same time. In all cases, the destination computer needs to detect the following: start of each bit. start and end of each byte (character) . start and end of each data link level frame (message). A frame is a block of data comprising several characters.

A3.5

CHARACTER CODING

There are two types of messages exchanged between communication parties: control: special data to overcome transmission errors. information: user data. Alphanumeric characters need to be translated into a machine code i.e. a binary representation. There are two major standards for character encoding : Extended Binary Coded Decimal Interchange Code(EBCDIC). American Standards Committee for Information Interchange (ASCII), similar to International Alphabet Number 5 (IA5) which is an ITU standard. Both encoding standards have: control characters such as STX (Start of Text), ETX (End of Text), SYN (Synchronisation), etc. printable characters such as numbers and alphabets.
A3.6

ASCII AND EBCDIC Examples


Printable characters A B a b ASCII (7 bits) 41 42 61 62 EBCDIC (8 bits) C1 C2 81 82

Control characters STX (Start Of Text) ETX (End Of Text) DLE (Data Link Escape) SYN

ASCII (7 bits) 02 03 10 16

EBCDIC (8 bits) 02 03 10 32

A3.7

ASYNCHRONOUS FRAMING

Suitable for data generated at random such as a user typing from a keyboard; transmission line is idle for long periods and the two ends operate asynchronously. Each byte is treated independently. Receiver tries to keep synchronisation per character. Character synchronisation is achieved using one start and one or more stop bits, which delimit the 8 character bits. The receiver samples the middle of each bit, the transmitter must transmit at the same rate the receiver samples. Not good for large frames due to the inefficiency of the per-character synchronisation overhead: 8 / (8+2) = 80% at best.

A3.8

ASYNCHRONOUS FRAMING (contd)

8-bit character
1 2 2 4 5 6 7 8

Asynchronous transmission basics

Start bit

bit sampling
A3.9

Stop bit

SYNCHRONOUS FRAMING

Suitable for high speed data transmissions. Complete frames of several characters are transmitted as a continuous string. Receiver tries to keep synchronisation per frame. It is synchronous because some pattern is always being transmitted between successive frames or before the start of each frame so that the receiver gets synchronised. There are two types of framing: Byte-oriented and Bit-oriented. Byte-oriented framing is the older of the two methods, imposes more overheads and is gradually fading from use in favour of bit-oriented framing.

A3.10

BYTE-ORIENTED FRAMING

The SYN (Synchronisation) character is sent continuously between frames. Frame synchronisation for byte-oriented framing: for text frames: Using control characters such as STX (Start Of Text) and ETX (End Of Text). for binary frames: insert DLE (Data Link Escape) before STX and ETX. character stuffing is achieved by substituting every DLE pattern in the frame with DLE-DLE at the transmitter and removing the extra DLE at the receiver. Closely tied to 8-bit characters, not general enough.

A3.11

BYTE-ORIENTED FRAMING (contd)


Data to transmit
SYN STX ETX SYN SYN

Frame

DLE

Data to transmit

SYN DLE

STX

DLE

DLE

DLE

ETX

SYN SYN

Byte-stuffed Frame

transmission order

A3.12

BIT-ORIENTED FRAMING

In idle periods between frames, the receiver searches for the flag bit pattern (01111110). This is typically preceded by a number of idle bytes (01111111) for the receiver to gain synchronisation. Frames are delimited by the flag pattern, which denotes both the start and end of frame. Bit stuffing is achieved by inserting a 0 after 5 consecutive 1s at the transmitter and removing this 0 at the receiver: if after 5 1s there is a 0, it is the result of bit-stuffing and it is discarded by the receiver. if it is a 1 followed by a 0, then the last 8 bits constitute a flag. Allows arbitrary number of bits in a frame (not just multiple of 8) and supports character sets with any number of bits per character

A3.13

SYNCHRONISATION OVERHEADS: EXAMPLE


Find the additional number of bits required to transmit a message (frame) consisting of 1000 characters (8-bits each) over a data link using the following transmission modes: a) Asynchronous: With one start bit and one stop bit per character and a single start-of frame and end-of-frame characters per message. b) Synchronous byte-oriented: With two synchronisation characters and a single start-of-frame / end-of-frame character per message. c) Synchronous bit-oriented Answer: a) Extra number of bits per character = 1+1 = 2 bits Total additional bits required = (2*1000) + 2*(2+8) = 2020 bits b) 4*8=32 bits (DLE/STX and DLE/ETX) c) 2*8=16 bits (only two FLAG bytes)
A3.14

ERROR DETECTION (1)

Transmission is error prone: Bit Error Rate (BER): the probability that a single bit is corrupted e.g. 10-3 means 1 bit in 103. Forward Error Control: redundant information is transmitted so that the receiver can both detect and correct the error.
This is better for high BER links (e.g. wireless) and exhibits high frame overhead.

Feedback Error Control: less redundant information is transmitted, receiver can detect the error and discard / request retransmission.

A3.15

ERROR DETECTION (2)

In character-based asynchronous transmission, the parity bit method is used (add an extra bit per character for even / odd parity). can only detect odd number of bit errors. For block-oriented synchronous transmission, a checksum is used known as Frame Check Sequence (FCS) or Cyclic Redundancy Check (CRC). Based on polynomial codes, a generator polynomial of R bits (typically 16 or 32) will detect: all single-bit, double-bit and odd number of bit errors. All error bursts < R and most error bursts >= R. Easy to implement in hardware.

A3.16

DATA LINK PROTOCOL BASICS

A3.17

THE DATA LINK LAYER IN THE OSI REFERENCE MODEL


Application Process

Application Presentation Session Transport Network Data Link Physical

A3.18

INTRODUCTION

Transmission modes: connection oriented, reliable (virtual circuit like). connectionless, unreliable. Link layer functions for the reliable, connection-oriented service: error control, i.e. error detection and correction. flow control, so that the transmitter does not flood the receiver with information the latter cannot handle. Similar functions may be also found in the Network and Transport layers.

A3.19

TYPICAL DATA LINK FRAME FORMAT


Header

Data

Checksum

Data Link frames contain a header, data and a checksum at the end in order to enable the receiver to detect transmission errors. The header contains various pieces of Protocol Control Information (PCI): frame type, sequence numbers, etc. The data part carries the payload i.e. the information the data link service user wishes to transfer. The length of the header and checksum reduce the effective bandwidth, so they should be as small as possible. There exist frames with no data part, used entirely for control purposes e.g. acknowledgment frames.
A3.20

AUTOMATIC REPEAT REQUEST


Receiver checks received frame for errors and provides a positive or (in some modes) negative acknowledgment. This form of automatic error error control is known as Automatic Repeat reQuest (ARQ). There are two ARQ types: idle (or stop-and-wait) RQ, used mostly for characteroriented transmissions (e.g. modem protocols). continuous RQ, used for bit-oriented transmissions which characterise more general data link protocols.

A3.21

IDLE (STOP-AND-WAIT) RQ

Terminology: information frames are called I-frames and acknowledgment frames are called ACK-frames. data source is called transmitter or primary and data destination is called receiver or secondary. Operation: transmitter sends I-frames and waits for acknowledgment from receiver. timers are used to check on transmission failure for I-frames. wait time equals the time I-frame takes to be received and processed by the receiver and acknowledgment to be sent back - time-out should be slightly larger than this time. sequence numbers are used to mark both I-frames and acknowledgments.
A3.22

IDLE (STOP-AND-WAIT) RQ (contd)

Two potential schemes of implementing retransmissions: implicit retransmissions: the receiver sends an ACK (acknowledgment) message only for correct I-frames and does nothing for I-frames received in error. explicit retransmission: in addition, the receiver sends NAK (negative acknowledgment) for I-frames in error. In the implicit retransmission scheme, the transmitter will eventually resend after a time out. In the Idle RQ scheme, the transmitter can only have one Iframe outstanding, hence the terms idle / stop-and-wait.

A3.23

IMPLICIT RETRANSMISSION
Timer started Timer stopped Transmitter I(N)
I(N)

I(N+1)

I(N+2)
ACK(N+1)

ACK(N)

I(N+1)

Correct N I-Frame

Receiver

I(N) Timer started

I(N+1) Timer expired

Transmitter

I(N)

I(N)

I(N+1)

I(N)

I(N)

ACK(N)

Corrupted N I-Frame

Receiver

I(N)

I(N)

A3.24

EXPLICIT RETRANSMISSION
Timer started Timer restarted Timer stopped

Transmitter

I(N)

I(N)

I(N+1)

I(N)

NAK(N)

I(N)

ACK(N)

Receiver

I(N)

I(N)

A3.25

IDLE RQ FRAME (PDU) FORMAT


SOH N(S) STX I-frame content ETX BCC I-frame format
SOH: Start of Header N(S) send sequence number N(R) receive sequence number

ACK N(R) BCC ACK-frame format NAK N(R) BCC NAK-frame format
STX: Start Of Text ETX: End Of Text BCC: Block Check Character
A3.26

LINK UTILISATION
Efficiency of utilisation U can be defined as U= Tx/Tt Tx= (Number of bits in a frame) / (Bit rate), i.e. the frame transmission time. Tt is equal to Tx plus any time the transmitter spends waiting for acknowledgments. In practice processing and acknowledgment transmission times are negligible compared with propagation delay, so: Tt = Tx + 2Tp where 2Tp represents I-frame and ACK-frame propagation delays. Therefore, U = Tx / (Tx + 2Tp) => U = 1/(1+2a) where a = Tp / Tx The coupling ratio a is typically: a << 1 for LANs and a >> 1 for WANs

A3.27

LINK UTILISATION: EXAMPLE 1


1000-bit frame to be transmitted using idle RQ protocol. Assuming the velocity of propagation is 2 *108 m/s in cable and 3 *108 m/s in vacuum, determine the link utilisation for a data rate of 1 Mbps for the following transmission media: i) A twisted pair cable 1 km in length. ii) A leased line 200 km in length. iii) A satellite link of 36 000 km. Answer: Tx= (Number of bits in a frame) / (Bit rate) = 103 / 106 = 10-3 s Tp = Distance/ Velocity, a = Tp / Tx and U = 1 / (1+2a) i) Tp = 5 * 10-6 , a = 5 * 10-3, hence U = 1 ii) Tp = 10-3 , a = 1, hence U = 0.33 iii) Tp = 0.24, a = 240, hence U = 0.002
A3.28

LINK UTILISATION: EXAMPLE 2


1000-bit frame to be transmitted using idle RQ protocol. Assuming the velocity of propagation is 2 *108 m/s, determine the link utilisation for a twisted pair cable 1 km in length: i) For a data rate of 1 Kbps. ii) For a data rate of 100 Mbps. Answer: Tx= (Number of bits in a frame) / (Bit rate) Tp = Distance/ Velocity, a = Tp / Tx and U = 1 / (1+2a) i) Tx = 1, Tp = 5 * 10-6 , a = 5 * 10-6 , hence U = 1 ii) Tx = 10-5, Tp = 5 * 10-6, a = 0.5, hence U = 0.5

A3.29

LINK UTILISATION WITH ERRORS


Assuming a Bit Error Rate (BER) of the link P, the probability to receive a frame of Ni bits in error is: Pf = 1-(1-P)Ni = Ni P (approx.) if Ni P << 1 It can be proved that the number of original transmission plus retransmissions required per frame is: Nr = 1 / (1- Pf) Utilisation is as for error-free RQ but divided by the number of retransmissions per frame: U = (1 / (1+2a)) / (1 / (1- Pf)) => U = (1- Pf) / (1 + 2a)

A3.30

LINK UTILISATION (IDLE RQ CONCLUSIONS)

Link efficiency is affected by the: link delay (propagation velocity and distance). line speed i.e. bit data rate. Bit Error Rate (BER).

A3.31

A3.32

CONTINUOUS RQ

A3.33

CONTINUOUS RQ(1)

Link utilisation is better than idle RQ. Operation: transmitter sends I-frames continuously without waiting for acknowledgment from receiver. transmitter keeps a copy of transmitted I-frames for retransmission in case of failure. In duplex links, a commonly used technique is piggybacking where acknowledgments are tagged to the end of I-frames. There are two types of continuous RQ: Selective-repeat. Go-back-N.

A3.34

CONTINUOUS RQ(2)

Transmitter Primary

I(N)

I(N+1)

I(N+2)

I(N+3)

I(N+4)
ACK(N+2)

ACK(N+1) I(N) ACK(N)

ACK(N+3)

Receiver

I(N)

I(N+1)

I(N+2)

I(N+3)

I(N+4)

A3.35

SELECTIVE-REPEAT (1)

Selective repeat has better utilisation than Go-back-N and can be used in links with high BER e.g. radio links. It can operate with implicit or explicit negative acknowledgments in the notes we cover only the implicit acknowledgment case. The transmitter discovers missing ACK-frames from subsequent ones and retransmits the corresponding I-frames. Possibility for receiving duplicate frames when an ACK-frame is corrupted. The loss of an I-frame is detected only after the next I-frame is correctly received, which requires a continuous stream of I-frames. The transmitter needs to set a timer for an I-frame so that in case it is corrupted and there are no more I-frames to send, it is retransmitted after the time-out.

A3.36

SELECTIVE-REPEAT (2): CORRUPTED I-FRAME

Primary Transmitter

I(N)

I(N+1)

I(N+2)

I(N+3)

I(N+4)

I(N+1)

I(N+5)

I(N)

ACK(N)

ACK(N+2)

ACK(N+1)

Receiver

I(N)

I(N+1)

I(N+2)

I(N+3)

I(N+4)

I(N+1)

I(N+5)

A3.37

SELECTIVE-REPEAT(3): CORRUPTED ACK-FRAME


Primary Transmitter I(N) I(N+1) I(N+2) I(N+3) I(N+4) I(N) I(N+4) I(N+5)

I(N)

ACK(N)

ACK(N+1)

ACK(N+2)

ACK(N)

ACK(N+4)

ACK(N+3)

Receiver

I(N)

I(N+1)

I(N+2)

I(N+3)

I(N)

I(N+4)

I(N+5)

Duplicate, ignored

A3.38

GO-BACK-N (1)

In case of error, the transmitter retransmits all frames already sent starting from the one in error. In comparison with selective repeat, it is simpler and reduces the buffer size on the receiver side but it is less efficient. trades simplicity for efficiency in error recovery. Operation: Assume that I-frame N+1 is corrupted. Receiver will return NAK-frame for N+1 I-frame. A NAK-frame is also known as Selective Reject. Transmitter will know about corruption after N+X frames. It will then retransmit these frames, starting from N+1. The receiver uses a timer so that it retransmits a NAK-frame in case it is corrupted.
A3.39

GO-BACK-N (2): CORRUPTED I-FRAME

Transmitter Primary

I(N)

I(N+1)

I(N+2)

I(N+3)

I(N+4)

I(N+1)

I(N+2)

I(N+3)

I(N)

ACK(N)

NAK(N+1)

ACK(N+1)

Receiver

I(N)

I(N+1)

I(N+2)

I(N+3)

I(N+4)

I(N+1)

I(N+2)

Frames discarded

A3.40

GO-BACK-N (3): CORRUPTED ACK-FRAME


Transmitter Primary I(N) I(N+1) I(N+2) I(N+3) I(N+4) I(N+5) I(N+6)

I(N)

ACK(N)

ACK(N+1)

ACK(N+2)

ACK(N+4)

ACK(N+5)

ACK(N+3)

Receiver

I(N)

I(N+1)

I(N+2)

I(N+3)

I(N+4)

I(N+5)

I(N+6)

A3.41

FLOW CONTROL

Flow control is needed to regulate traffic if the transmitter is faster then the receiver. An agreed window size determines the maximum number of unacknowledged frames. Sliding window: receiver stops acknowledging received messages. sender notices the built up of unacknowledged messages so it stops. the window slides forward as acknowledgments are received and more frames are transmitted. Window size impacts efficiency and relates also to the available buffer storage in both sender and receiver.

A3.42

FLOW CONTROL USING SLIDING WINDOW

Transmitter Primary

I(N)

I(N+1)

I(N+2)

I(N+3)

I(N+4)

I(N+5)

I(N+6)

Frames already acknowledged

Frames waiting to be acknowledged Send window size = 3

Frames waiting to be sent

Protocol Idle RQ Selective repeat Go-back-N

Send Window 1 K K

Receive window 1 K 1

A3.43

LINK MANAGEMENT
Source application L_CONNECT.request Source link layer Destination link layer Destination application SETUP-frame L_CONNECT.indication UA-frame L_CONNECT.confirm

L_DATA.request I-frame L_DATA.indication ACK-frame

L_DISCONNECT.request DISC-frame L_DISCONNECT.indication

UA-frame L_DISCONNECT.confirm

A3.44

LINK UTILISATION
Recall that for Idle RQ utilisation U can be defined as U= Tx/Tt => U = Tx / (Tx + 2Tp) => U = 1/(1+2a) where a = Tp / Tx For Continuous RQ with sliding window size K: U = K / (1+2a) if K < 1+2a, or U=1 if K >= (1+2a) In the latter case, we fill the pipeline.

A3.45

LINK UTILISATION: (CONTINUOUS RQ EXAMPLE)


Q)1000-bit frame to be transmitted using continuous RQ protocol. Assuming the velocity of propagation is 2*108 m/s in cable and 3 *108 m/s in vacuum, determine the link utilisation for the following transmission media: i) A 10 km link of 200 Mbps with a send window of K=7. ii) A satellite link of 36 000 km of 1 Mbps with a send window of K = 127. Answer: Tp = S / V, a = Tx / Tp and U = K/(1+2a) i) Tp = 5*10-5 , Tx = 1000 / (200*10+6) = 5*10-6, a = 10, For K = 7 (K< 1+2a=21), U = 7 / (1+20) = 0.33 ii) Tp = 0.24, Tx = 10 -3 , a = 240 For K = 127 (K< 1+2a=481), U = 127 / (1+480) = 0.26
A3.46

LINK UTILISATION WITH ERRORS: SELECTIVE REPEAT


In case of the Selective Repeat scheme, utilisation in case of errors is reduced by the number of retransmissions required per frame. It is reminded that the number of retransmissions per frame are Nr = 1 / (1- Pf) where Pf is the probability of receiving a frame in error. As such, the link utilisation is: U = (K / (1+2a)) / (1 / (1- Pf)) = K (1- Pf) / (1+2a) if K < 1+2a, or U = 1 - Pf if K >= 1+2a
Note: when K >= 1+2a we substitute K = 1+2a since bigger values of K do not increase utilisation i.e. the pipeline is full.

A3.47

LINK UTILISATION WITH ERRORS: GO-BACK-N


In case of the Go-Back-N scheme, each error means that K frames should be retransmitted. It can be proved that the number of retransmissions per frame in this scheme are: Nr = ( 1 + Pf (K-1) ) / (1- Pf) As such, the link utilisation is: U = K (1- Pf) / ( (1+2a)(1 + Pf (K-1)) ) if K < 1+2a, or U = (1 - Pf ) / ( 1 + Pf (K-1) ) if K >= (1+2a)

A3.48

USES OF ARQ PROTOCOLS IN HIGHER LAYERS ADAPTIVE WINDOW SIZE

Similar protocols are also used end-to-end, i.e. in the computers/hosts, in the Network and Transport layers for connection-oriented reliable protocols In the Network layer, ARQ-based flow control through sliding window is used per Virtual Circuit (VC see later) e.g X.25 In the Transport layer, ARQ-based error and flow control is used per Transport Connection (e.g. TCP, TP4) In these cases, the window size may be adaptive for congestion control reasons, e.g. as in TCP In this case, the sender starts from a window size of 1 packet and increases it exponentially with positive acks (2, 4, 8, 16, ) until the maximum size (i.e. receivers capacity is reached) slow start Packet loss across the network is mainly due to congestion (buffer overflow), in which case the maximum window size is set to the current size and a slow start phase begins again From the current maximum size (threshold), there is a linear only increase until the absolute maximum size i.e. the receivers capacity In this way, the sending entity helps de-congesting the network

A3.49

TCP ADAPTIVE WINDOW MECHANISM SLOW START ALGORITHM


44 40 36 32 28 24 20 16 12 8 4 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24

Timeout Threshold

Congestion window (kbytes)

New threshold

Transmission number
A3.50

DATA LINK LAYER PROTOCOLS

A3.51

LINK LAYER PROTOCOL IMPLEMENTATIONS


Character-oriented protocols with idle RQ are used for low bit rates e.g. Kermit and X-modem. Bit oriented protocols with continuous RQ are used for high bit rates and long distance communications. The key protocol is the ISO High-level Data Link Control (HDLC). Variations of HDLC are used in: X.25 WANs use a version called LAPB. LANs use a version called LLC2. ISDN signalling uses a version called LAPD. GSM signalling uses a modified LAPD called LAPDm. Modems use a version called LAPM. Internet point-to-point lines use PPP.

A3.52

HDLC VARIATIONS
HDLC

LAPB (X.25)

LLC2 (LANs)

LAPD (ISDN)

LAPDm (GSM)

LAPM (V.42)

PPP (many)

A3.53

HDLC (1)

High-level Data Link Control (HDLC) is the most common bitoriented link protocol in use. It has its origins in IBMs Synchronous Data Link Control (SDLC). Terminology: primary (transmitter) frames are called commands. secondary (receiver) frames are called responses. unbalanced configuration where one machine will be primary and the other will be secondary. balanced configuration where both machines are both primary and secondary.

A3.54

HDLC (2)

HDLC Modes of operation: Normal Response Mode (NRM): secondary transmits only if polled by the primary (unbalanced configuration). Asynchronous Response Mode (ARM): secondary is allowed to transmit asynchronously to the primary (unbalanced configuration) Asynchronous Balanced Mode (ABM): used for duplex links and mainly in PSDN networks. Each station performs both primary and secondary functions.

A3.55

HDLC FRAME FORMAT


Start-offramedelimiter Frame Check Sequence 0 to N Information 16/32 FCS End-offramedelimiter

frame header

8 Flag

8/16 Address

8/16 Control

8 Flag

Flag = 01111110 FCS = X16+X12+X5+1 Address: single, group or broadcast

A3.56

HDLC FRAME TYPES (1)


The control field in the frame header determines the frame type. Unnumbered frames (i.e. no sequence number): Used to setup and release connections. Also, used to set NRM, ARM and ABM modes of operation. Information Frames: Used to carry user information and piggy-backed acknowledgments in ABM and ARM modes. The sequence number range is 0-7 for normal frames and 0-127 for extended frames. Supervisory Frames: Used for error control such as Reject (REJ) for Go-back -N and Selective Reject (SREJ) for selective-repeat operation. Also, used for flow control such as Receiver Ready (RR) and Receiver Not Ready (RNR). Data transparency is achieved by using the flag field and bit stuffing.

A3.57

HDLC FRAME TYPES (2)


Information frames. Supervisory frames - RR, RNR, REJ, SREJ. Unnumbered commands: Set Asynchronous Response Mode (Extended) - SARM(E). Set Normal Response Mode (Extended) - SNRM(E). Set Asynchronous Balanced Mode (Extended) - SABM(E). Reset - RSET. Frame Reject - FRMR. Disconnect - DISC. Unnumbered responses: Unnumbered Acknowledgment - UA. Command Reject - CDMR. Frame Reject - FRMR. Disconnect Mode - DM.
A3.58

Vous aimerez peut-être aussi