CPSC441

DATA LINK LAYER Logical Link Sublayer

Jan 5, 1998

CMPN 369

Page 1

OSI
Application Presentation Session Transport Network Datalink Physical

Asynchronous

Synchronous .

(b) Actual communication. .Services Provided to Network Layer (a) Virtual communication.

Responsibility of Data Link Layer: PROVIDE SERVICE TO NETWORK LAYER OSI Application LOGICAL LINK sublayer Presentation Session Transport Network Data Link Physical Framing Error control Flow control MEDIA ACCESS sublayer Transmission/reception of frames .

By convention. . we'll use the term ``frames'' when discussing DLL packets. Note that frames are nothing more than ``packets'' or ``messages''.Data Link Layer (DLL) OSI Application Presentation Session Transport Network Data Link Physical Framing Group the physical layer bit stream into units called frames.

Data Link Layer (DLL) OSI Application Presentation Session Transport Network Datalink Physical Flow Control Prevent a fast sender from overwhelming a slower receiver. a supercomputer can easily generate data faster than a PC can consume it. . For example.

Data Link Layer (DLL) OSI Application Presentation Session Transport Network Data Link Physical Error Control Sender checksums the frame and sends checksum together with data. . The checksum allows the receiver to determine when a frame has been damaged in transit.

Data Link Layer (DLL) OSI Application Presentation Session Transport Network Data link Physical Error Control Receiver recomputes the checksum and compares it with the received value. . If they differ. an error has occurred and the frame is discarded.

DLL  Type of service – Unacknowledged connectionless • No attempt to recover lost frame • Suited for low error rate networks or for fault tolerant applications such as voice – Acknowledged connectionless • Each frame is acknowledged by the receiver • Suited for unreliable channels – Acknowledged connection-oriented • Ensures that – All frames are received – Each is received exactly once The service is accomplished using SIMPLEX. HALF DUPLEX OR FULL DUPLEX channels. .

Types of Services .

how can the receiver recognize the start and end of a frame? Four methods: • 1. Bit Stuffing 3. Pulse encoding . Length Count 2.Framing: Translates the physical layer's raw bit stream into discrete units called frames RECEIVER … Frame #2 SENDER Frame #n Frame #1 • How can the receiver detect frame boundaries? That is. Character stuffing 4.

Frames could be: • 1. Byte count (Decnet) 2. Generic Framing Procedure 5. Byte stuffing (SDLC) 3.5) . Bit stuffing (HDLC) 4. Fixed length (ATM) • 2. Manchester Encoding(802. Variable length Variable length frames: 1.

.Framing  Length Count Make the first field in the frame's header be the length of the frame. That way the receiver knows how big the current frame is and can determine where the next frame ends.

. the receiver will think that the frame contains fewer (or more) bits than it actually does. the receiver will have difficulty resynchronizing to the start of a new frame. If the bits in the count become corrupted during transmission. This technique is not used anymore. Although checksum will detect the incorrect frames.Framing  Length Count: Disadvantage Receiver loses synchronization when bits become garbled. since better techniques are available.

Framing  Length Count .

A frame consists of everything between two delimiters. For instance. use the 4-bit sequence of 0111 to delimit consecutive frames. 0111 frame 0111 Problem: What happens if the reserved delimiter happens to appear in the frame itself? If we don't remove it from the data. the receiver will think that the incoming frame is actually two smaller frames! .Framing  Bit Stuffing Use reserved bit patterns to indicate the start and end of a frame.

but recognizes the 0111 sequence as the end of the frame. append a zero bit after each pair of 1's in the data..g. . after every occurrence of two consecutive 1's insert 0. the receiver converts two consecutive 1's followed by a 0 into two 1's. E. Likewise. This prevents 3 consecutive 1's from ever appearing in the frame. Solution: Use bit stuffing. Within the frame.Framing  Bit Stuffing Use reserved bit patterns to indicate the start and end of a frame.

(b) The data as they appear on the line. . (c) The data as they are stored in receiver’s memory after destuffing.Framing – bit stuffing Bit stuffing (a) The original data.

Framing – byte stuffing .

Generic Framing Procedure (GFP) (See Communication Networks by Alberto Garcia) New standard for framing cHEX and tHEX fields provide CRC based error checking for the preceding fields .

4 standard uses this approach. .Framing  Manchester encoding In Manchester encoding. and 0-bits by low-high sequences. 1-bits are represented by a high-low sequence. The IEEE 802. The start/end of a frame could be represented by the signal low-low or high-high. for instance. The advantage of Manchester encoding is that no extra bandwidth is required as in bit-stuffing.

0 is represented by positive going edge Require twice the bandwidth .Manchester Encoding 1 is represented by negative going edge.

two types of error can occur: Lost frame: the frame fails to arrive at the receiver. This may be due to a noise burst destroying the frame beyond recognition Damaged frame: A recognizable frame arrives at the receiver but some bits are in error .Error Control SENDER Frame #n … Frame #2 Frame #1 RECEIVER When data is sent as a sequence of frames.

Error Control Error control is concerned with insuring that all frames are eventually delivered (possibly in order) to a destination. This is nothing more than a hint to the sender so that it can retransmit a frame right away without waiting for a timer to expire. the receiver also returns a negative acknowledgment (NACK) for incorrectly-received frames. How? Three items are required: (1) Acknowledgements Typically. . reliable delivery is achieved using the ``acknowledgments with retransmission'' paradigm. In some systems. whereby the receiver returns a special acknowledgment (ACK) frame to the sender indicating the correct receipt of a frame.

fails to solicit an ACK or NACK. and as a result. What happens if an ACK or NACK becomes lost? Retransmission timers are used to resend frames that don't produce an ACK. If the timer goes off. When sending a frame. How? Three items are required: (2) Timers One problem that simple ACK/NACK schemes fail to address is recovering from a frame that is lost. retransmit the frame. . schedule a timer to expire at some time after the ACK should have been returned.Error Control Error control is concerned with insuring that all frames are eventually delivered (possibly in order) to a destination.

How? Three items are required: (3) Sequence Numbers Retransmissions introduce the possibility of duplicate frames.Error Control Error control is concerned with insuring that all frames are eventually delivered (possibly in order) to a destination. so that a receiver can distinguish between new frames and old copies. add sequence numbers to each frame. To suppress duplicates. .

Each bit transmitted has a probability of being changed. They are often caused by faults in . then some of the transmitted bits will either change from 0 to 1 or from 1 to 0.Data Errors • When data is transmitted over a cable or a channel. • Random errors change bits unpredictably. These errors are often caused by thermal noise. • Burst errors change a number of bits in succession. • If errors do occur. there is always a chance that some of the bits will be changed (corrupted) due to noise. signal distortion or attenuation.

Errors and Error Effect Original Waterfall Image: .

bit error rate=0.1 .Errors and Error Effect Waterfall Image: every tenth bit in error.

5 .Errors and Error Effect Waterfall Image: every other bit in error bit error rate =0.

Parity Testing .

if two bits are changed then there will still be an even number of 1s. ¯ Similarly. then an error must have occurred. if odd parity is being used but there are an even number of 1s. then an error must have occurred. • One drawback with parity testing is that if two errors occur in the same character they will not be detected. ¯ This is because if there were an even number of 1s originally. ¯ If even parity is being used but there are an odd number of 1s.Parity Testing • The receiving device can work out if a bit has been corrupted in a character by counting the number of 1s in the character and parity bit. .

Block Parity Testing .

.

.

. we will know which character and which column it has occurred in.Block Parity Testing • Now if an error occurs. Char 1: 0 1 1 0 1 1 0 1 2: 1 1 1 0 1 1 1 0 3: 0 1 1 1 0 1 0 1 4: 1 1 1 0 0 0 1 1 5: 0 0 0 1 0 1 1 0 Parity byte: 1 0 1 1 1 1 0 0 • Not only have we detected the error. but we can also correct a single bit error it by simply changing it.

¯ A checksum is usually restricted to a certain number of bits (typically 16). 47. ¯ For example. We would transmit 121. • If any errors occur during transmission then checksum for the received data will differ from the transmitted checksum. . If the checksum is longer than this then only the lower 16 bits will be transmitted. 29.Checksum Testing • Another way of checking for errors to to use a checksum. This is a number calculated from the data and sent along with the data. if the data is 121. 29 and 47 then the checksum is 214. 17. • A simple checksum can be calculated by adding all the data together. 17. 214.

• Essentially the data is regarded as being one very long binary number. • Place holder digits are added onto the end and it is divided by a generator polynomial using modulo 2 division. The remainder at the end of this division is the CRC. . it is extremely unlikely that any errors will go undetected. If a CRC is used. in practice calculating a CRC is easy and can be implemented in hardware.Cyclic Redundancy Code • A Cyclic Redundancy Code (CRC) is a more sophisticated type of checksum. • Although the technique may sound a little complicated.

There are other techniques that can correct more errors.Error Correcting Codes • Rather than just detecting an error. ¯ CDs use error correcting codes to ensure high quality sound reproduction even if the CD is slightly damaged. . sometimes it is useful to be able to correct an error as well. ¯ Deep space probes use error correcting codes because it would take too long to retransmit data. • We have already seen that we can correct a single error in a block parity check.

Error-Detecting Codes .

then buffer over flow will occur Flow control is a technique for preventing the sender from overwhelming the receiver with data Flow control protocols enable the receiver to inform the sender when it is able to receive data . while the data is being processed If the sender sends data faster than the receiver can process it.Flow Control SENDER Frame #n … Frame #2 Frame #1 RECEIVER Buffer A receiver reserves some buffer space for storing data from a sender.

.

Stop-and-Wait Protocol Performance t prop Propagation delay: • defined as the delay between transmission and receipt of packets between hosts • can be used to estimate timeout period t frame  Frame transmission time  Total delay (ignoring ACK transmission time): tack Acknowledgment transmission time TD TD  2t prop  t frame .

Stop-and-Wait Protocol Performance Of this time. Therefore. the efficiency or utilization is: U t frame TD  t frame 2t prop  t frame t prop t frame If we define a: a then 1 U 1  2a . only tframe is actually spent transmitting data.

Example #1 A channel has a bit rate of 4 Kbps and a propagation delay of 20 ms. For what range of frame sizes does the stopand wait protocol give an efficiency of 50 %? .

For what range of frame sizes does the stopand wait protocol give an efficiency of 50 %? R  4 Kbps t prop  20 ms L ? U t t frame frame  2t prop   0.5  t t frame frame  2t prop  t frame  2t prop  2  20 ms  40 ms L  R  t frame  4 103  40 103  160 Thus for frame sizes L 160 bits.Example #1 A channel has a bit rate of 4 Kbps and a Solution: propagation delay of 20 ms. the stopandwait protocol gives an efficiency of 50 % .

Example #2 There are 200 computers in a lab They are attached to a network with R = 10 Mbps of length d = 1500 m. The transmitted packets are L = 800 bits long •The propagation speed is V = 2 108 m/sec How many packets can each computer send per second? .

1875 R 10 Mbps 10  10 6 rpacket     12500 packets / sec L 800 800 rpacket  rpacket  U  12500  0.84 1  2a 1  2  0.Example #2 Solution: d V Rd 107  1500 a    0.5 packets / sec .84  10500 packets / sec The packet transmission rate per computer is: 10500 packets / sec 200 computers  52.09375 8 L R LV 800  2  10  1 1 1 U    0.09375 1.

.

the range of sequence numbers is usually 0 to 2k-1 where k is the number of bits used. This will be enough for a sliding window protocol with window size 1. ¯ We do not want to have sequence numbers that are too large because that would waste valuable bandwidth. ¯ For example.• Sequence numbers usually occupy a field with a limited number of bits in the frame format. we could have a 1-bit sequence number. ¯ Because sequence numbers occupy a whole number of bits. .

Sliding Window Protocol .

Sliding Windows Protocol
Here is what happens if we have a 3-bit sequence number and a window size of 1 on both sender and receiver:
No Frame to send
7 6 0 1 6

Got Frame 0 to send
7 0 1

Waiting for Frame 0 ACK
7 6 0 1

Got ACK for Frame 0
7 6 0 1

5 4 3

2

5 4 3

2

5 4 3

2

5 4 3

2

Sending Frame
7 6 0 1 6 7 0 1 6 7

Sending ACK
0 1 6 7 0 1

5
4 3

2

5
4 3

2

5 4 3

2

5 4 3

2

Waiting for Frame 0

Getting Frame 0

Got Frame 0, Waiting for Frame 1

Waiting for Frame 1

Sliding Window Protocol
• The receiver acknowledges the frames by sending an acknowledgment with the sequence number S of the next frame expected • The sequence number indicates that the receiver has received all frames upto S1 • This way multiple frames can be acknowl edged together

Sliding Window Summary
S • liding window is best known algorithm in networking F • irst role is to enable reliable delivery of packets ¯ Timeouts and acknowledgements S • econd role is to enable in order delivery of packets ¯ Receiver doesn’t pass data up to app until it has packets in order T • hird role is to enable flow control ¯ Prevents server from overflowing receiver’s buffer

Of course. we will have no choice but to send back a separate acknowledgement frame. data will usually flow in both directions. it makes sense to piggyback acknowledgements on these frames. if no frames are due to be sent back.  Header Host A Header ACK Data Host B Data If frames are travelling in both directions anyway. .Duplex Communication The protocols we have seen so far just send data in one direction. Of course. This saves the overhead involved in sending a separate frame just to carry an acknowledgement.

Out of 520msec. the receiver will receive the whole frame 270msec later. data is only being sent for 20msec. The acknowledgement will take a further 250msec to get back. link na The round-trip delay is 500msec Down (that’s half a second). Only 20/520 = 4% of the link’s capacity is being utilised. . Link If we used a 1-bit sliding Ground window protocol to send Station 1000-bit frames.Long Transit Delays  Imagine a link that uses a geo-stationary satellite: Satelli te Up Anten The data rate is 50-kbps.

 Rather than just allowing one outstanding frame (like the one-bit sliding window protocol does) we can allow up to 26 outstanding frames (enough to fill the 520msec round-trip delay period).Pipelining Rather than wasting so much channel capacity. up to 26 frames and acknowledgements can be in transit at any time. The real question is: “What happens when a frame is damaged during transit?” . a 5-bit (0-31) sequence number would be most suitable. a protocol can be designed to send enough frames to keep the link working at full capacity. The sliding window of the sender need only be enlarged to 26. With a sliding window size of 26. To accommodate this.

Timeout interval 0 1 2 3 4 5 2 3 4 5 6 7 Ack 0 Ack 1 Ack 2 Ack 3 Ack 4 0 1 E D D D 2 3 4 time The above time sequence diagram shows what happens when an erroneous frame (E) is received. All following frames are discarded (D) until the new copy of the erroneous frame is received. The sender will then retransmit the damage frame and all the frames that follow it.  Eventually the sender will realise it has not received an acknowledgement for the damage frame within the timeout period.Go Back n One approach is to discard the damage frame and all the frames that follow it. .

To implement the go back n.  Packets must be passed up to the Network Layer in the order in which they were sent by the Network Layer in the source host. different from the sliding window of the sender).e. the receiver will only accept the frame with the next expected frame sequence number.  With a sliding window size of 1. the next expected frame sequence number remains the same. the sliding window of the receiver is set to 1 (i. Only one packet needs to be stored at a time since the frames will always arrive in the correct order.Go Back n The main advantage of go back n is that the receiver only needs to maintain enough buffer space for one frame at a time. When a frame is damaged. .

 The receiver must have enough buffer space available to potentially store all the outstanding frames from the receiver.  If a link is particularly noisy.Selective Repeat Go back n can waste a lot of link capacity by re-sending frames that arrived perfectly the first time. . Undamaged frames are stored until they can be passed (in the correct order) to the Network Layer. Much less of the link’s capacity is wasted since only the damaged frames are retransmitted and the rest of the time the link can carry useful data. only those frames that are damaged are re-sent. this waste can significantly reduce the link’s throughput. With selective repeat.

. This means that the Data Link Layer is responsible for ordering them before sending the packets they contain to the Network Layer. Timeout interval 0 1 2 3 4 5 2 6 7 8 9 10 Ack 0 Ack 1 Ack 1 Ack 1 Ack 1 Ack 5 Ack 6 Ack 7 0 1 E 3 4 5 2 6 7 time The selective repeat protocol can be implemented by setting the receiver sliding window size to more than 1 (usually it is set to the same size as the sender’s sliding window).Selective Repeat Frames may arrive at the destination out of order.

High-Level Data Link Control Frame format for bit-oriented protocols. .

The Data Link Layer in the Internet A home personal computer acting as an internet host. .

PPP – Point to Point Protocol .

PPP – Point to Point Protocol .

.PPP – Point to Point Protocol (3) The LCP frame types.

Sign up to vote on this title
UsefulNot useful