McGraw-Hill©The McGraw-Hill Companies, Inc. Chapter 5 Data Link Layer.

57
McGraw-Hill ©The McGraw-Hill Companies, Inc. Chapter 5 Data Link Layer

Transcript of McGraw-Hill©The McGraw-Hill Companies, Inc. Chapter 5 Data Link Layer.

Page 1: McGraw-Hill©The McGraw-Hill Companies, Inc. Chapter 5 Data Link Layer.

McGraw-Hill ©The McGraw-Hill Companies, Inc.

Chapter 5

Data LinkLayer

Page 2: McGraw-Hill©The McGraw-Hill Companies, Inc. Chapter 5 Data Link Layer.

McGraw-Hill ©The McGraw-Hill Companies, Inc.

Understand the functions of the data link layer.Understand the functions of the data link layer.

Understand the concept of the hop-to-hop delivery compared toUnderstand the concept of the hop-to-hop delivery compared tohost-to-host delivery and application-to-application delivery.host-to-host delivery and application-to-application delivery.

Understand the concept of access method and define differentUnderstand the concept of access method and define differentaccess methods used in LANs and WANs .access methods used in LANs and WANs .

After reading this chapter, the reader should After reading this chapter, the reader should be able to:be able to:

OOBJECTIVESBJECTIVES

Understand the addressing mechanism used in the data link Understand the addressing mechanism used in the data link layer and how network layer addresses are mapped to datalayer and how network layer addresses are mapped to datalayer addresses. layer addresses.

Understand how error control is handled at the data link layer.Understand how error control is handled at the data link layer.

Page 3: McGraw-Hill©The McGraw-Hill Companies, Inc. Chapter 5 Data Link Layer.

McGraw-Hill ©The McGraw-Hill Companies, Inc.

DUTIES OF THEDUTIES OF THEDATA LINK LAYERDATA LINK LAYER

DUTIES OF THEDUTIES OF THEDATA LINK LAYERDATA LINK LAYER

5.15.1

Page 4: McGraw-Hill©The McGraw-Hill Companies, Inc. Chapter 5 Data Link Layer.

McGraw-Hill ©The McGraw-Hill Companies, Inc.

Figure 5-1

Data link layer in the Internet model

Page 5: McGraw-Hill©The McGraw-Hill Companies, Inc. Chapter 5 Data Link Layer.

McGraw-Hill ©The McGraw-Hill Companies, Inc.

Figure 5-2 Data-link layer duties

Page 6: McGraw-Hill©The McGraw-Hill Companies, Inc. Chapter 5 Data Link Layer.

McGraw-Hill ©The McGraw-Hill Companies, Inc.

HOP-TO-HOPHOP-TO-HOPDELIVERYDELIVERY

HOP-TO-HOPHOP-TO-HOPDELIVERYDELIVERY

5.25.2

Page 7: McGraw-Hill©The McGraw-Hill Companies, Inc. Chapter 5 Data Link Layer.

McGraw-Hill ©The McGraw-Hill Companies, Inc.

Figure 5-3

Hop-to-hop delivery

Transport layer :application program to application programNetwork layer : host to host delivery (source to destination)Datalink layer : hop to hop

Page 8: McGraw-Hill©The McGraw-Hill Companies, Inc. Chapter 5 Data Link Layer.

McGraw-Hill ©The McGraw-Hill Companies, Inc.

PACKETIZINGPACKETIZINGPACKETIZINGPACKETIZING

5.35.3

Page 9: McGraw-Hill©The McGraw-Hill Companies, Inc. Chapter 5 Data Link Layer.

McGraw-Hill ©The McGraw-Hill Companies, Inc.

packetizing

• Different protocols have different names for the packet at the data link layer

• Most LANs (ethernet) refer to the packet as frames.

• ATM WAN refers to a packet as a cell• A header and trailer are usually added to a packet

received from the network layer– Header : length of the data, addressing information…– Trailer : error detection

Page 10: McGraw-Hill©The McGraw-Hill Companies, Inc. Chapter 5 Data Link Layer.

McGraw-Hill ©The McGraw-Hill Companies, Inc.

ADDRESSINGADDRESSINGADDRESSINGADDRESSING

5.45.4

Page 11: McGraw-Hill©The McGraw-Hill Companies, Inc. Chapter 5 Data Link Layer.

McGraw-Hill ©The McGraw-Hill Companies, Inc.

Technical Focus:Technical Focus: Addresses in Local Area NetworksAddresses in Local Area Networks

The physical address for most computers on local area networks is imprinted on the network card that is installed in the computer.If the user or network manager changes the network card(because of a failure, for example), the physical address of the computer is changed. In most cases, changingthe network card requires reconfiguration of the computer.

Page 12: McGraw-Hill©The McGraw-Hill Companies, Inc. Chapter 5 Data Link Layer.

McGraw-Hill ©The McGraw-Hill Companies, Inc.

Addressing

• The data link layer addresses are called physical addresses or MAC addresses and are used to find the address of the next hop in the hop to hop delivery

• The physical address used by a LAN is totally different from that used by a WAN

• A LAN address is 6 bytes (48 bits) long• A WAN address is usually longer

Page 13: McGraw-Hill©The McGraw-Hill Companies, Inc. Chapter 5 Data Link Layer.

McGraw-Hill ©The McGraw-Hill Companies, Inc.

ARP (address resolution protocol)

• Mapping the logical address (IP address) to the physical address (MAC address) dynamically.

• Anytime a host or a router needs to find the physical address of another host or router on its network, it sends an ARP query packet.

• The packet includes the physical and IP addresses of the sender and the IP address of the receiver.

• Because the sender does not know the physical address of the receiver, this query is broadcast over the network.

Page 14: McGraw-Hill©The McGraw-Hill Companies, Inc. Chapter 5 Data Link Layer.

McGraw-Hill ©The McGraw-Hill Companies, Inc.

Figure 5-4

ARP operation

Page 15: McGraw-Hill©The McGraw-Hill Companies, Inc. Chapter 5 Data Link Layer.

McGraw-Hill ©The McGraw-Hill Companies, Inc.

ERROR CONTROLERROR CONTROLERROR CONTROLERROR CONTROL

5.55.5

Page 16: McGraw-Hill©The McGraw-Hill Companies, Inc. Chapter 5 Data Link Layer.

McGraw-Hill ©The McGraw-Hill Companies, Inc.

Error control

• In data communication, errors are inevitable

• Using better equipment and more reliable transmission media may reduce the frequency of occurrence. But it can never eliminate errors.

• Detect and correct errors

Page 17: McGraw-Hill©The McGraw-Hill Companies, Inc. Chapter 5 Data Link Layer.

McGraw-Hill ©The McGraw-Hill Companies, Inc.

Data can be corrupted during Data can be corrupted during transmission. For reliable transmission. For reliable

communication, errors must be communication, errors must be prevented, or detected and corrected.prevented, or detected and corrected.

Note:Note:

Page 18: McGraw-Hill©The McGraw-Hill Companies, Inc. Chapter 5 Data Link Layer.

McGraw-Hill ©The McGraw-Hill Companies, Inc.

Source of errors

• White noise : – due to the heat; is constant by nature

• Impulse noise– It is a surprise signal that suddenly affects the medium

– Can not be predicted

– Effect of impulse noise depends on the speed of data transmission

• Crosstalk – It is the effect of one medium on another

Page 19: McGraw-Hill©The McGraw-Hill Companies, Inc. Chapter 5 Data Link Layer.

McGraw-Hill ©The McGraw-Hill Companies, Inc.

Source of errors

• Echo– We have echo when a sending device receives some of the

energy it has sent

• Jitter– It is the result of a change in the signal when it passes

through an electronic device

• Attenuation – A signal may become too weak if it travels a lon distance

• Distortion– Harmonics are combined at the receiver, the signal is not

exactly the one sent by sender

Page 20: McGraw-Hill©The McGraw-Hill Companies, Inc. Chapter 5 Data Link Layer.

McGraw-Hill ©The McGraw-Hill Companies, Inc.

In a single-bit error, only 1 bit in the data unit has changed.

Note:Note:

Page 21: McGraw-Hill©The McGraw-Hill Companies, Inc. Chapter 5 Data Link Layer.

McGraw-Hill ©The McGraw-Hill Companies, Inc.

Figure 5-5

Single-bit error

ASCII STX : start of textASCII LF : line feed

Page 22: McGraw-Hill©The McGraw-Hill Companies, Inc. Chapter 5 Data Link Layer.

McGraw-Hill ©The McGraw-Hill Companies, Inc.

A burst error means that two or more A burst error means that two or more bits in the data unit have changed.bits in the data unit have changed.

Note:Note:

Page 23: McGraw-Hill©The McGraw-Hill Companies, Inc. Chapter 5 Data Link Layer.

McGraw-Hill ©The McGraw-Hill Companies, Inc.

Figure 5-6

Burst error of length five

The errors not necessarily occur in consecutive bits.The length of the burst is measured from the first corrupted bit to the last corrupted bitSome bits in between may not have been corrupted

Page 24: McGraw-Hill©The McGraw-Hill Companies, Inc. Chapter 5 Data Link Layer.

McGraw-Hill ©The McGraw-Hill Companies, Inc.

Error prevention

• White noise : reduce the ambient temperture

• Crosstalk : twist or shield the cable

• Attenuation : repeaters

• Errors are inevitable, for accuracy we need to detect and correct errors

Page 25: McGraw-Hill©The McGraw-Hill Companies, Inc. Chapter 5 Data Link Layer.

McGraw-Hill ©The McGraw-Hill Companies, Inc.

Error detection uses the concept of Error detection uses the concept of redundancy, which means adding redundancy, which means adding

extra bits for detecting errors at the extra bits for detecting errors at the destination.destination.

Note:Note:

Page 26: McGraw-Hill©The McGraw-Hill Companies, Inc. Chapter 5 Data Link Layer.

McGraw-Hill ©The McGraw-Hill Companies, Inc.

Figure 5-7

Redundancy

Page 27: McGraw-Hill©The McGraw-Hill Companies, Inc. Chapter 5 Data Link Layer.

McGraw-Hill ©The McGraw-Hill Companies, Inc.

Figure 5-8

Detection methods

Vertical redundancy checkLongitudinal redundancy check

cyclic redundancy check

Page 28: McGraw-Hill©The McGraw-Hill Companies, Inc. Chapter 5 Data Link Layer.

McGraw-Hill ©The McGraw-Hill Companies, Inc.

In vertical redundancy check (VRC), a In vertical redundancy check (VRC), a parity bit is added to every data unit so parity bit is added to every data unit so

that the total number of 1s becomes that the total number of 1s becomes even.even.

Note:Note:

Most common and last expensive mechanism for error detection.Often called parity check.A redundant bit (parity bit) is added to make the number of 1s even.

Page 29: McGraw-Hill©The McGraw-Hill Companies, Inc. Chapter 5 Data Link Layer.

McGraw-Hill ©The McGraw-Hill Companies, Inc.

Figure 5-9

Even parity VRC concept

Page 30: McGraw-Hill©The McGraw-Hill Companies, Inc. Chapter 5 Data Link Layer.

McGraw-Hill ©The McGraw-Hill Companies, Inc.

Figure 5-10 LRCLongitudinal redundancy check

Calculate the parity bit for each column and create a new column

New column

Page 31: McGraw-Hill©The McGraw-Hill Companies, Inc. Chapter 5 Data Link Layer.

McGraw-Hill ©The McGraw-Hill Companies, Inc.

In longitudinal redundancy check In longitudinal redundancy check (LRC), a block of bits is divided into (LRC), a block of bits is divided into rows and a redundant row of bits is rows and a redundant row of bits is

added to the whole block. added to the whole block.

Note:Note:

Page 32: McGraw-Hill©The McGraw-Hill Companies, Inc. Chapter 5 Data Link Layer.

McGraw-Hill ©The McGraw-Hill Companies, Inc.

Figure 5-11

CRCCyclic redundancy check

Most powerful redundancy check.Based on binary division rather than binary addition.CRC remainder is appended to the end of the data.

Page 33: McGraw-Hill©The McGraw-Hill Companies, Inc. Chapter 5 Data Link Layer.

McGraw-Hill ©The McGraw-Hill Companies, Inc.

Error correction• Once the data are detected, the receiver has

3 choice :– Simply discard the data– Discard the data but request a retransmission– Correct the data

• Data correction is select when the data packet is very small and we need the accurcy but can not wait for retransmission

• Very difficult to achieve if there are more than a few bits in error.

Page 34: McGraw-Hill©The McGraw-Hill Companies, Inc. Chapter 5 Data Link Layer.

McGraw-Hill ©The McGraw-Hill Companies, Inc.

Error correction using retransmission

• If the sender has not received positive news in due time, the frame is retransmitted.– The frame is damage :

• The receiver send a negative acknowledgement

• The receiver does not send an acknowledgement

– The acknowledgement is lost

• There are two protocols for retransmission :– Stop and wait automatic repeat request

– Sliding window automatic repeat request

Page 35: McGraw-Hill©The McGraw-Hill Companies, Inc. Chapter 5 Data Link Layer.

McGraw-Hill ©The McGraw-Hill Companies, Inc.

Figure 5-12

Stop and wait ARQ

Only the fate of one frame at any moment is unknownAfter sending a frame the sender stops and waits before the next frame is sent

Page 36: McGraw-Hill©The McGraw-Hill Companies, Inc. Chapter 5 Data Link Layer.

McGraw-Hill ©The McGraw-Hill Companies, Inc.

Technical Focus:Technical Focus: Procedure for Stop-And-Wait ARQProcedure for Stop-And-Wait ARQ

The sending device keeps a copy of the last frame transmitteduntil it receives an acknowledgment for that frame

Both data frames and ACK frames are numbered 0 and 1 alternately. A data 0 frame is acknowledgedby an ACK 1 frame.

If an error is discovered in a data frame, a negative acknowledgment (NAK) frame is returned.

If an expected acknowledgment is not received within an allotted time period, the sender assumes that the last data frame was lost in transit and sends it again.

Page 37: McGraw-Hill©The McGraw-Hill Companies, Inc. Chapter 5 Data Link Layer.

McGraw-Hill ©The McGraw-Hill Companies, Inc.

Figure 5-13

Sliding-window ARQ

Page 38: McGraw-Hill©The McGraw-Hill Companies, Inc. Chapter 5 Data Link Layer.

McGraw-Hill ©The McGraw-Hill Companies, Inc.

Technical Focus:Technical Focus: Procedure for Sliding-Window ARQProcedure for Sliding-Window ARQ

The sending device keeps copies of all transmitted frames until they have been acknowledged.

In addition to ACK frames, a receiver can return a NAK frameif the data have been received damaged. The NAK frametells the sender to retransmit a damaged frame.

Like stop-and-wait ARQ, the sending device in sliding-windowARQ is equipped with a timer to enable it to handle lost acknowledgments.

Page 39: McGraw-Hill©The McGraw-Hill Companies, Inc. Chapter 5 Data Link Layer.

McGraw-Hill ©The McGraw-Hill Companies, Inc.

FLOW CONTROLFLOW CONTROLFLOW CONTROLFLOW CONTROL

5.65.6

Page 40: McGraw-Hill©The McGraw-Hill Companies, Inc. Chapter 5 Data Link Layer.

McGraw-Hill ©The McGraw-Hill Companies, Inc.

Flow control refers to a set of Flow control refers to a set of procedures used to restrict the amount procedures used to restrict the amount

of data the sender can send before of data the sender can send before waiting for acknowledgment.waiting for acknowledgment.

Note:Note:

Buffer : the rate of transmission is faster than check and process , for this reason, each receiving device has a blockof memory called buffer, reserved for storing incoming datauntil they are processed.If the buffer begins to fill up, the receiver must tell the sender to halt transmission until it is once again able to receive.

Page 41: McGraw-Hill©The McGraw-Hill Companies, Inc. Chapter 5 Data Link Layer.

McGraw-Hill ©The McGraw-Hill Companies, Inc.

MEDIUM ACCESSMEDIUM ACCESSCONTROLCONTROL

MEDIUM ACCESSMEDIUM ACCESSCONTROLCONTROL

5.15.1

Page 42: McGraw-Hill©The McGraw-Hill Companies, Inc. Chapter 5 Data Link Layer.

McGraw-Hill ©The McGraw-Hill Companies, Inc.

Figure 5-14

Medium access methods

Page 43: McGraw-Hill©The McGraw-Hill Companies, Inc. Chapter 5 Data Link Layer.

McGraw-Hill ©The McGraw-Hill Companies, Inc.

Figure 5-15

Select

The select procedure is used whenever the primary has something to sent.The select procedure has priority over the poll procedure

Know ifthe secondary is ready to accept the data

Page 44: McGraw-Hill©The McGraw-Hill Companies, Inc. Chapter 5 Data Link Layer.

McGraw-Hill ©The McGraw-Hill Companies, Inc.

Figure 5-16

Poll

Page 45: McGraw-Hill©The McGraw-Hill Companies, Inc. Chapter 5 Data Link Layer.

McGraw-Hill ©The McGraw-Hill Companies, Inc.

The poll/select method is mostly used The poll/select method is mostly used in time-sharing systems when a central in time-sharing systems when a central

computer is used to control other computer is used to control other computers.computers.

Note:Note:

Page 46: McGraw-Hill©The McGraw-Hill Companies, Inc. Chapter 5 Data Link Layer.

McGraw-Hill ©The McGraw-Hill Companies, Inc.

Token passing

• In the token passing method, the permit is passed from one computer to another.

• Stations are arranged around a physical or logical ring

• Permit is a small frame called token.

• If a station needs to send data, it waits for the token and captures it.

• After capturing the token, the station send one or more frames.

Page 47: McGraw-Hill©The McGraw-Hill Companies, Inc. Chapter 5 Data Link Layer.

McGraw-Hill ©The McGraw-Hill Companies, Inc.

Figure 5-17

Token passing network

Page 48: McGraw-Hill©The McGraw-Hill Companies, Inc. Chapter 5 Data Link Layer.

McGraw-Hill ©The McGraw-Hill Companies, Inc.

Random access

• The station checks to make sure the medium is idle.(carrier sense)

• If the medium is idle, the station can send data.

• There is still a potential for collision.to detect collision and send the data again, the station needs to continue monitoring the medium.

Page 49: McGraw-Hill©The McGraw-Hill Companies, Inc. Chapter 5 Data Link Layer.

McGraw-Hill ©The McGraw-Hill Companies, Inc.

CSMA/CD• Carrier sense multiple access with collision

detection.• Check the level of energy in the medium to tell the

idleness of the medium.• Frame from a distant station might be undetectable• If the stations discovered a collision(a very high

level of energy), they know that their frames have been destroyed

• To minimize the risk of collision, two stations each wait a random amount of time

Page 50: McGraw-Hill©The McGraw-Hill Companies, Inc. Chapter 5 Data Link Layer.

McGraw-Hill ©The McGraw-Hill Companies, Inc.

CSMA/CA

• Collision is avoided by sending a special frame to tell other stations how long it is usuing the medium before sending data.

• If it receives no objection from any other station, it means that it can send data

Page 51: McGraw-Hill©The McGraw-Hill Companies, Inc. Chapter 5 Data Link Layer.

McGraw-Hill ©The McGraw-Hill Companies, Inc.

Token passing is used mostly by local Token passing is used mostly by local area networks (LANs). We discuss area networks (LANs). We discuss

LANs in Chapter 9.LANs in Chapter 9.

Note:Note:

Page 52: McGraw-Hill©The McGraw-Hill Companies, Inc. Chapter 5 Data Link Layer.

McGraw-Hill ©The McGraw-Hill Companies, Inc.

CSMA/CD is used in the Ethernet CSMA/CD is used in the Ethernet LAN discussed in Chapter 9.LAN discussed in Chapter 9.

Note:Note:

Page 53: McGraw-Hill©The McGraw-Hill Companies, Inc. Chapter 5 Data Link Layer.

McGraw-Hill ©The McGraw-Hill Companies, Inc.

CSMA/CA is used in the wireless CSMA/CA is used in the wireless LANs discussed in Chapter 10.LANs discussed in Chapter 10.

Note:Note:

Page 54: McGraw-Hill©The McGraw-Hill Companies, Inc. Chapter 5 Data Link Layer.

McGraw-Hill ©The McGraw-Hill Companies, Inc.

DATA LINK DATA LINK PROTOCOLSPROTOCOLSDATA LINK DATA LINK PROTOCOLSPROTOCOLS

5.85.8

Page 55: McGraw-Hill©The McGraw-Hill Companies, Inc. Chapter 5 Data Link Layer.

McGraw-Hill ©The McGraw-Hill Companies, Inc.

A data link protocol is a set of A data link protocol is a set of specifications used to implement the specifications used to implement the

data link layer. data link layer.

Note:Note:

Page 56: McGraw-Hill©The McGraw-Hill Companies, Inc. Chapter 5 Data Link Layer.

McGraw-Hill ©The McGraw-Hill Companies, Inc.

In a character-oriented protocol, the In a character-oriented protocol, the frame is interpreted as a series of frame is interpreted as a series of

characters. In a bit-oriented protocol, characters. In a bit-oriented protocol, the frame or packet is interpreted as a the frame or packet is interpreted as a

series of bits.series of bits.

Note:Note:

Page 57: McGraw-Hill©The McGraw-Hill Companies, Inc. Chapter 5 Data Link Layer.

McGraw-Hill ©The McGraw-Hill Companies, Inc.

All bit-oriented protocols are relatedAll bit-oriented protocols are relatedto high-level data link controlto high-level data link control

(HDLC), (HDLC), a bit-oriented protocol.a bit-oriented protocol.

Note:Note: