24/11/1013-Datalink1 The Data Link Layer Role Services Functions –Framing –Encapsulation –Addressing –Connection Control –Ordered Delivery –Flow Control –Error Control
24/11/1013-Datalink2 The Role of the Data Link Layer To move data across a single physical link To offer a well defined service interface to the network layer To deal with transmission errors To regulate the flow of data across the link
24/11/1013-Datalink3 Data Link Layer Services Unacknowledged Connectionless Acknowledged Connectionless Acknowledged Connection-oriented (in order of increasing reliability)
24/11/1013-Datalink4 Data Link Layer – Main Function Framing –The receiving Data Link Layer must be able to determining the start and end of frames It can do this by: Character count Start and end bits, characters or flags Physical layer coding violations Or a combination of the above
24/11/1013-Datalink5 Asynchronous Data Transmission Asynchronous data transfer sends one character at a time, whenever it is ready for transmission. The character is preceded by a start bit and followed by a stop bit There is usually a gap between characters The start and stop bit allow the receiver to synchronise with the transmitter for the transmission of a single character Data bits 1 - Mark 0 - Space Start Bit Stop Bit
24/11/1013-Datalink6 Synchronous Data Transmission Synchronous data transmission involves the transmission of data in blocks with no gaps or start/stop bits to separate bytes of data The receiver therefore has to be synchronised at all times with the transmitter in order to make any sense of the bits being received
24/11/1013-Datalink7 Asynchronous Framing Although frames are usually regarded as blocks of multiple bytes of data, asynchronous data transfer can be thought of as the transmission of a single byte frame preceded by a start bit and followed by a stop bit to allow the receiver to synchronise with the transmitter to receive one byte Long Blocks of data can also be transmitted asynchronously as a series of asynchronous characters using asynchronous data link protocols
24/11/1013-Datalink8 Asynchronous Data Link Protocols Asynchronous data transmission was at one time very commonly used with modems but was not very suitable for applications such as file transfers due to the lack of powerful error checking A number of simple asynchronous data link protocols were developed to transfer blocks of data reliably over asynchronous links Examples are XMODEM, YMODEM, ZMODEM, BLAST and Kermit They can also be used with synchronous data links which are more common today
24/11/1013-Datalink9 Character-oriented and Bit-oriented Framing Synchronous Data Link protocols can be classified according to whether they are character-oriented or bit oriented Character-oriented protocols transmit data as a series of characters. Header fields are also a series of characters. E.g. IBM’s Binary Synchronous Communications (BSC or Bisynch = ISO’s Basic Mode) Bit oriented protocols transmit data as a series of bits (not necessarily in multiples of 8). Header fields are binary. E.g. Synchronous Data Link Control (SDLC), High-level Data Link Control (HDLC), Point-to-Point Protocol (PPP) and LAN protocols
24/11/1013-Datalink10 Frame Delimiters Character oriented protocols such as BSC use the ASCII characters SYN SYN (Synchronise) followed by SOH (Start of Header) to start a frame header, STX (Start of Text) to start the data field and ETX (End of Text) to end a frame Bit oriented protocols such as HDLC use an 8 bit flag ( ) to start and end a frame. The flag is also continuously transmitted when the link is idle to maintain synchronisation
24/11/1013-Datalink11 Data Transparency If characters or sequences of bits are used to delimit frames there is a problem if it is necessary to transmit these characters or sequence of bits within the data of the frame This is a problem of data transparency. It must be possible to transmit any combination of characters/bits Problem can be overcome with byte or bit stuffing
24/11/1013-Datalink12 Byte Stuffing With BSC, DLEs can be inserted before STX and ETX. Everything between these DLEs must be transparent BSC uses byte stuffing to provide data transparency for DLEs in the data Whenever a DLE appears in the data, the transmitter stuffs another DLE into the data Whenever the receiver sees receives two DLEs, it unstuffs one of them © Tanenbaum, Prentice Hall International
24/11/1013-Datalink13 Bit stuffing Bit oriented protocols use bit stuffing to provide data transparency so that data is not confused with flags Whenever the sender encounters 5 consecutive 1s, a 0 is stuffed into the data to make Whenever the receiver sees 5 1s followed by a 0 it unstuffs the 0 © Tanenbaum, Prentice Hall International
24/11/1013-Datalink14 Data Link Layer Standard Functions Encapsulation Addressing Connection Control Ordered Delivery Flow Control Error Control
24/11/1013-Datalink15 Encapsulation The Data Link Layer encapsulates data from the network layer (i.e. a Network Layer Packet is transmitted inside a Data Link Layer Frame) Most Data Link Layer protocols, not only have a header, but have a trailer as well. The trailer is used for error detection
24/11/1013-Datalink16 Addressing Many Data Link protocols have either been designed to work over a shared medium or can trace their origins back to terminal to host networks which used point-to- multipoint links. All Data Link protocols have an address field even when designed for use on a point to-point link
24/11/1013-Datalink17 Connection Control Some Data Link Protocols (such as HDLC, SDLC and PPP) are connection-oriented. They require a link set-up phase before data can be transferred and a link disconnection phase when data no longer needs to be sent The establishment and disconnection of the link are achieved through special frames known as supervisory frames which carry no data These protocols will guaranty the delivery of data in order and without loss or duplication
24/11/1013-Datalink18 Ordered Delivery Ordered delivery is achieved through sequence numbering of information frames and the retransmission of errored frames
24/11/1013-Datalink19 Flow Control X-on/X-off –Only used with asynchronous transmission –When receiver wants to stop transmitter it sends an X-off character (CTRL-S) and when it wants the transmitter to restart it sends X-on (CTRL-Q) Stop and Wait –Each frame must be positively acknowledged before another frame can be sent Sliding Window –The sliding window mechanism allows a number of frames (up to the maximum window size) to be transmitted without acknowledgement
24/11/1013-Datalink20 Error Control Error Detection –Vertical Redundancy Check (Parity Bit) –Longitudinal Redundancy Check –Cyclical Redundancy Check These error detection techniques will be covered in detail in a workshop For unacknowledged connectionless data link service, errored frames are simply discarded and higher layers are relied upon to retransmit data
24/11/1013-Datalink21 Error Control Error Correction Techniques –Echoplexing Used in asynchronous terminal transmission. Characters are echoed back to the user from host. Requires a full duplex link and relies on user to detect and recover from errors –Forward Error Correction Redundant bits are used to allow recovery from burst errors. Such techniques are useful where the media is very unreliable (E.g. Hamming Codes which will be covered in a workshop) –Automatic Repeat reQuest (ARQ) Idle RQ Continuous RQ –Go Back N –Selective Repeat
24/11/1013-Datalink22 IDLE RQ (Stop and Wait ARQ) BSC is an example of an Idle RQ protocol Idle RQ works in half duplex mode Transmitter will transmit the next information frame only after receipt of ACK (Acknowledgement Frame) If a frame is lost, receiver will not acknowledge it and the transmitter will retransmit it after a timeout If a frame is damaged the receiver can transmit a NAK (Negative Acknowledgement) frame If an ACK or NAK is lost, transmitter will retransmit after timeout
24/11/1013-Datalink23 IDLE RQ (Stop & Wait RQ) © Forouzan, McGraw Hill
24/11/1013-Datalink24 Continuous RQ Continuous RQ gives better performance as it uses a sliding window where the transmitter can transmit up to the window size of unacknowledged information frames An acknowledgement signals the next frame expected Continuous RQ requires a full duplex link With Go Back N, if a frame is corrupted or lost, the transmitter must retransmit all the subsequent information frames With Selective Repeat, only the corrupted or lost frame is retransmitted
24/11/1013-Datalink25 Go Back N with Damaged Frame © Forouzan, McGraw Hill
24/11/1013-Datalink26 Go Back N with Lost Frame © Forouzan, McGraw Hill
24/11/1013-Datalink27 Go Back N with Lost ACK © Forouzan, McGraw Hill
24/11/1013-Datalink28 Selective Repeat with Damaged Frame © Forouzan, McGraw Hill
24/11/1013-Datalink29 Selective Repeat Lost Frames are discovered when frames are received out of sequence and a NAK is transmitted for the missing frame. The receiver will buffer any subsequent frames and wait for the lost frame to be resent Lost ACKs and NAKs are handled in the same way as Go Back N. The data frames are retransmitted after a timeout
24/11/1013-Datalink30 Go Back N versus Selective Repeat Selective Repeat appears to be more efficient as frames are not retransmitted unnecessarily However the complexity of the code required for sorting and storing frames outweighs many of the advantages Selective Repeat is often not used in practice