Presentation is loading. Please wait.

Presentation is loading. Please wait.

CS 453 Computer Networks Lecture 9 Layer 2 – Data Link Layer.

Similar presentations


Presentation on theme: "CS 453 Computer Networks Lecture 9 Layer 2 – Data Link Layer."— Presentation transcript:

1 CS 453 Computer Networks Lecture 9 Layer 2 – Data Link Layer

2 Topics Introduction to the Data Link Layer Data Link Layer functionality Data Link Layer functionality Data framing Data framing Error correction and detection Error correction and detection Flow control Flow control

3 Remember Layer 1 In the Physical layer we were concerned with Physical connectivity – wires, fiber, lasers, etc. Physical connectivity – wires, fiber, lasers, etc. Pushing bit – causing bits to traverse the physical medium Pushing bit – causing bits to traverse the physical medium So, is that enough

4 Remembering Layer 1 Obviously, No. While we can build a physical infrastructure, we still have a number of problems Given a stream of incoming bit, how do we know where a given parcel of data starts and stops Given a stream of incoming bit, how do we know where a given parcel of data starts and stops How do we detect errors in the bit stream How do we detect errors in the bit stream What do we do about errors if we detect them What do we do about errors if we detect them …and other issues …and other issues

5 Data Link Layer While Layer 1 is responsible for delivering bit… Layer 2 – Data Link Layer – is, generally speaking, responsible for delivering bit streams… In some recognizable/usable form In some recognizable/usable form … and relatively cleanly … and relatively cleanly Layer 2 – to establish a logical channel that is “wirelike”

6 Data Link Layer On the source end of the link, the data link layer takes data from the network layer takes data from the network layer Packages it for “shipping” Packages it for “shipping” Hands it off to the physical layer for transmission Hands it off to the physical layer for transmission On the receiving end, the data link layer takes the incoming data from the physical layer takes the incoming data from the physical layer Checks it for errors Checks it for errors “Unpackages” it “Unpackages” it Hands it off to the network layer on the receiving machine Hands it off to the network layer on the receiving machine

7 Data Link Layer Data Link Layer functions Provide services to the Network Layer and the Physical Layer Provide services to the Network Layer and the Physical Layer Provide a service interface to the Network Layer and Physical Layer Provide a service interface to the Network Layer and Physical Layer Handle data errors Handle data errors Manage data traffic flow Manage data traffic flow

8 Data Link Layer Usually responsible for media access control (MAC) If you have a shared media how does a send/receiver get access and use of the media If you have a shared media how does a send/receiver get access and use of the media In competition with other senders/receivers In competition with other senders/receivers Can’t be done in a free-for-all fashion Can’t be done in a free-for-all fashion Must be arbitrated in an orderly manner Must be arbitrated in an orderly manner

9 Data Link Layer Data Link Layer services Unacknowledged connectionless service Unacknowledged connectionless service Data transmitted toward receiver No steps to establish connection (logical channel) No steps to establish connection (logical channel) No acknowledgement from receiver No acknowledgement from receiver If errors or lost frames – sender never knows If errors or lost frames – sender never knows Maybe good for low error media Real-time data transmission Can’t retransmit – late data can’t be used, better to drop the frame Can’t retransmit – late data can’t be used, better to drop the frame Sort of like sending a letter in regular mail No inherent acknowledgment No inherent acknowledgment

10 Data Link Layer Data Link Layer services Acknowledged connectionless service Acknowledged connectionless service No connection (logical channel) established between sender and receiver, but After transmission receiver sends an acknowledgement – received-good or received- bad If received-bad can retransmit If received-bad can retransmit Sort of like registered mail – return receipt

11 Data Link Layer Flow control Acknowledged Connect-oriented service Acknowledged Connect-oriented service Connection between sender and receiver before data transmission started (logical channel or logical circuit) All transmissions acknowledged Wide area network (WAN) links Sort of like a phone call or a fax transmission Sort of like a phone call or a fax transmission

12 Data Link Layer Flow control Note in acknowledged services we said Note in acknowledged services we said That the receive can send a received-good or a received-bad acknowledgement, but… That the receive can send a received-good or a received-bad acknowledgement, but… What if the sender never receives an acknowledgement? What if the sender never receives an acknowledgement? If sender is stuck waiting for an acknowledgement, but the acknowledgement is lost, all communications is deadlocked If sender is stuck waiting for an acknowledgement, but the acknowledgement is lost, all communications is deadlocked Solution: sender sets clock on each transmitted frame Solution: sender sets clock on each transmitted frame If now acknowledgement when clock runs out – Time-out error

13 Data Link Layer Framing In the physical layer we have bits flowing from one machine, across a physical transmission medium and pouring into another machine In the physical layer we have bits flowing from one machine, across a physical transmission medium and pouring into another machine …but how does the receiving machine know where one unit of data starts and where it stops? Where does one end and the next one start. At the physical layer level its just a continuous or non continuous flow of bits …but how does the receiving machine know where one unit of data starts and where it stops? Where does one end and the next one start. At the physical layer level its just a continuous or non continuous flow of bits

14 Data Link Layer Framing The data link layer structures data streams from the network layer (on the sending end) in frames The data link layer structures data streams from the network layer (on the sending end) in frames And, extracts the data from the frames on the receiving end… and hands it to the network layer And, extracts the data from the frames on the receiving end… and hands it to the network layer Can’t count on clocks to resolve data boundaries Can’t count on clocks to resolve data boundaries Build frames Build frames

15 Data Link Layer Frames are generally data packages composed of A header or a header/trailer combination A header or a header/trailer combination The data from/for the network layer The data from/for the network layer The data is referred to as the payload The data is referred to as the payload Data HeaderTrailer Data HeaderTrailer

16 Data Link Layer Four ways to make frames Byte Count Byte Count First byte of a frame always hold the count of the number of bytes in the frame that follows it. Receiving data link layer gets incoming data – reads number in first byte and extracts that number of bytes from the frame Next incoming byte must be a frame byte count

17 Data Link Layer Frames Bytes counts – some serious problems Bytes counts – some serious problems What if there is an error in the byte count of a frame Suppose the frame byte count = 5… a one bit error could make that value 7 Now the data link layer sees 7 as the byte count and extracts 7 bytes from the frame It believes the next bytes is a byte count (it isn’t) and uses it to read the next N bytes Data link layer has lost synchronization and there is no way to get it back

18 Data Link Layer Framing Flag bytes Flag bytes Add a special flag byte to the beginning of the frame (header). When the data link layer sees that flag byte that is the beginning of the frame When it sees the next flag byte, that is the beginning of the next frame …but what if the flag byte occurs naturally in the data stream? …use a special escape byte in front of the accidental “flag byte” Using the escape byte is called “byte stuffing”

19 Data Link Layer Framing Start/Stop flags with bit stuffing Start/Stop flags with bit stuffing Start and end frame with same special bit sequence Start and end frame with same special bit sequence When the sender data link layer sees the flag bit sequence in the data stream, it stuffs it with 0 bit. When the sender data link layer sees the flag bit sequence in the data stream, it stuffs it with 0 bit. When the receiver data link layer sees the flag bit sequence with a 0 at the end, it strips the 0 bit and considers the rest data When the receiver data link layer sees the flag bit sequence with a 0 at the end, it strips the 0 bit and considers the rest data

20 Data Link Layer Framing Special data encoding Special data encoding Represent each bit in the data stream with a special code 0 = 01 0 = 01 1 = 10 1 = 10 00 and 11 then used for frame flags 00 and 11 then used for frame flags

21 Data Link Layer Data Link Layer is responsible for Error detection and error correction Error detection and error correction In designing the Data Link Layer you can- Add a minimal amount of redundancy to you’re the data and detect errors but not correct Add a minimal amount of redundancy to you’re the data and detect errors but not correct Add considerable redundancy to your data and correct errors Add considerable redundancy to your data and correct errors

22 Data Link Layer Error correction is more expensive than error detection in terms of bandwidth bandwidth Computationally Computationally Fiber optics transmissions are relatively error free More effective – detect and retransmit More effective – detect and retransmit Wireless media tend to have high error rates If clean data depended on retransmission, large percentage of data would be retransmitted – not efficient If clean data depended on retransmission, large percentage of data would be retransmitted – not efficient More efficient – add error correction code to transmitted data More efficient – add error correction code to transmitted data Let receiver detect and correct bad data, up to a point

23 Data Link Layer Flow control We have no inherent constraints on how much data can flow across a data link and how fast We have no inherent constraints on how much data can flow across a data link and how fast How do you keep a data sender from overrunning a receiver with too much data too fast? How do you keep a data sender from overrunning a receiver with too much data too fast?

24 Data Link Layer Flow control Feedback flow control – Feedback flow control – Negoitated/collaborative flow control Sender can only send when it have permission from receiver Sender transmits a request-to-send Sender transmits a request-to-send Receiver replies with ok-to-send or not-ok-to-send Receiver replies with ok-to-send or not-ok-to-send Sender transmits fixed quantity of data, etc… Sender transmits fixed quantity of data, etc… Receiver grants “license” to sender Receiver sends “ok to send n frames” Receiver sends “ok to send n frames” Sender transmits n frames Sender transmits n frames Sender waits for next “ok to send” Sender waits for next “ok to send”

25 Data Link Layer Flow control Rate base flow control Rate base flow control Data flow is controlled by a built in mechanism Like clock Like clock Data rate limited to something less than the medium and receiver can handle Data rate limited to something less than the medium and receiver can handle No conversation between sender and receiver No conversation between sender and receiver

26


Download ppt "CS 453 Computer Networks Lecture 9 Layer 2 – Data Link Layer."

Similar presentations


Ads by Google