Lecture Focus:

49
Lecture Focus: Data Communications and Networking Data Link Layer Media Access Control (MAC) Lecture 23 CSCS 311

description

Lecture Focus:. Data Link Layer Media Access Control ( MAC ). CSCS 311. Data Communications and Networking. Lecture 23. Media Access Control. Two sub-layers of data link layer: The upper sub-layer is responsible for data link control - PowerPoint PPT Presentation

Transcript of Lecture Focus:

Page 1: Lecture Focus:

Lecture Focus:

Data Communications and Networking

Data Link Layer Media Access Control (MAC)

Lecture 23

CSCS 311

Page 2: Lecture Focus:

Data Link Layer

Media Access Control

Two sub-layers of data link layer:

The upper sub-layer is responsible for data link control The lower sub-layer is responsible for resolving

access to the shared media.

If the channel is dedicated, we do not need the lower sub-layer.

Data Link Control

Media Access Control

Page 3: Lecture Focus:

Media Access Control

The upper sub-layer responsible for flow and error control is called the logical link control (LLC) layer.

The lower sub-layer mostly responsible for multiple access resolution is called the media access control (MAC) layer.

When nodes or stations are connected and use a common link, called a multipoint or broadcast link, we need a multiple-access protocol to coordinate access to the link. Speaking example.

Page 4: Lecture Focus:

Media Access Control

PROTOCOLS

ALOHA

Page 5: Lecture Focus:

Media Access Control

PROTOCOLS

RANDOM ACCESS (or contention methods ) Superiority

No controller Permission Decision and state of the medium

Idle or busy Transmission

Transmission right

Page 6: Lecture Focus:

Media Access Control

PROTOCOLS

RANDOM ACCESS: WHY? Two features give this method its name.

1. Transmission: A. Non-scheduledB. Random

2. No rules for transmissionA. Which station should send next?B. Stations compete to access the medium

Contention methods

Page 7: Lecture Focus:

Media Access Control PROTOCOLS

Access conflict-collision Frames destruction or modification

To avoid access conflict or to resolve it when it happens, each station follows a procedure that answers the following questions:

RANDOM ACCESS

When can the station access the medium? What can the station do if the medium is busy? How can the station determine the success or failure

of the transmission? What can the station do if there is an access conflict?

Page 8: Lecture Focus:

Media Access Control PROTOCOLS

RANDOM ACCESS

ALOHA protocol: Based on simple procedure called multiple access (MA). The method was improved with the addition of a procedure that

forces the station to sense the medium before transmitting. This was called carrier sense multiple access.

This method later evolved into two parallel methods: Carrier sense multiple access with collision detection

(CSMA/CD) Carrier sense multiple access with collision avoidance

(CSMA/CA).

CSMA/CD tells the station what to do when a collision is detected.

CSMA/CA tries to avoid the collision.

Page 9: Lecture Focus:

Media Access Control PROTOCOLS

RANDOM ACCESS

Evolution of random-access methods

MultipleAccess

Carrier Sense Multiple Accesswith

Collision DetectionCarrier Sense Multiple Access

Carrier Sense Multiple Accesswith

Collision Avoidance

Page 10: Lecture Focus:

Media Access Control PROTOCOLS

RANDOM ACCESS

ALOHA It was the earliest random access method developed at

the University of Hawaii in early 1970. Basic Objective:

Transmit at any time Users can transmit when they have data to send

There are potential collisions in random access. Medium is shared between the stations without any

controlling body and any coordination between the stations.

When a station sends data, another station may attempt to do so at the same time.

The data from the two stations collide and become garbled.

Page 11: Lecture Focus:

Media Access Control PROTOCOLS

RANDOM ACCESS

Pure ALOHA The original ALOHA protocol is called pure ALOHA.

The idea is that each station sends a frame whenever it has a frame to send.

Since there is only one channel to share, there is the possibility of collision between frames from different stations.

Page 12: Lecture Focus:

Media Access Control PROTOCOLS

RANDOM ACCESS

Frame collisions in a pure ALOHA network

Page 13: Lecture Focus:

Media Access Control PROTOCOLS

RANDOM ACCESS

Frame collisions in a pure ALOHA network

4 stations contending with one another for access to the shared channel.

Each station sends two frames: total 8 frames on the shared medium. Some of these frames collide because multiple frames are in

contention for the shared channel Only two frames survive: frame 1.1 and frame 3.2

Even if one bit of a frame coexists on the channel with one bit from another frame, there is a collision and both will be destroyed.

We need to resend the frames that have been destroyed during transmission.

Page 14: Lecture Focus:

Media Access Control PROTOCOLS

RANDOM ACCESS

Frame collisions in a pure ALOHA network

The pure ALOHA protocol relies on acknowledgments from the receiver:

When a station sends a frame, it expects the receiver to send an acknowledgment.

If the acknowledgment does not arrive after a time-out period, the station assumes that the frame (or the acknowledgment) has been destroyed and resends the frame.

Page 15: Lecture Focus:

Media Access Control PROTOCOLS

RANDOM ACCESS

Frame collisions in a pure ALOHA network

A collision involves two or more stations.

If all these stations try to resend their frames after the time-out, the frames will collide again.

Pure ALOHA dictates that when the time-out period passes, each station waits a random amount of time before resending its frame.

The randomness will help avoid more collisions. This time is called the back-off time TB.

Page 16: Lecture Focus:

Media Access Control PROTOCOLS

RANDOM ACCESS

Frame collisions in a pure ALOHA network

Pure ALOHA has a second method to prevent congesting the channel with retransmitted frames.

After a maximum number of retransmission attempts Kmax, a station must give up and try later.

Figure below shows the procedure for pure ALOHA based on the above strategy.

Page 17: Lecture Focus:

Media Access Control PROTOCOLS

RANDOM ACCESS

Procedure for ALOHA Protocol

Page 18: Lecture Focus:

Media Access Control PROTOCOLS

RANDOM ACCESS Procedure for ALOHA Protocol

Wait fortime-out time

Page 19: Lecture Focus:

Media Access Control PROTOCOLS

RANDOM ACCESS Procedure for ALOHA Protocol

Time-out period = Maximum possible round-trip propagation delay

= Twice the amount of time required to send a frame between the two most widely separated stations (2 x Tp).

The back-off time TB is a random value that normally depends on K (the number of attempted unsuccessful transmissions). The formula for TB depends on the implementation. One common formula is the binary exponential back-off.

In this method, for each retransmission, a multiplier in the range 0 to 2K - 1 is randomly chosen and multiplied by Tp (maximum propagation time) or Tfr (the average time required to send out a frame) to find TB.

The range of the random numbers increases after each collision. The value of Kmax is usually chosen as 15.

Page 20: Lecture Focus:

Media Access Control PROTOCOLS

RANDOM ACCESS Procedure for ALOHA Protocol

Example:The stations on an ALOHA network are a maximum of 600 km apart. If signals propagate at 3 x 108 m/s, find values of Tp and TB.

Solution:Speed = Distance / Time Time = Distance / Speed

Tp = (600 x 103) / (3 x 108) = (6 x 105) / (3 x 108) = 2 / 103 = 2 ms.

Now we can find the value of TB for different values of K.A. For K = 1, the range is {0, 1}. The station needs to generate a random

number with a value of 0 or 1. This means that TB is either 0ms (0 x 2) or 2ms (1 x 2), based on the outcome of the random variable.

B. For K =2, the range is {0, 1, 2, 3}. This means that TB can be 0, 2, 4, or 6 ms, based on the outcome of the random variable.

C. For K =3, the range is {0,1,2,3,4,5,6,7}. This means that TB can be 0,2,4, ... , 14 ms, based on the outcome of the random variable.

D. d. We need to mention that if K > 10, it is normally set to 10.

Page 21: Lecture Focus:

Media Access Control PROTOCOLS

RANDOM ACCESS

Slotted ALOHA

In Pure ALOHA, there is no rule that defines when the station can send. So is the reason for so many collisions.

The first refinement of pure ALOHA is provided by the introduction of time slots.

A station may send soon after another station has started or soon before another station has finished.

Page 22: Lecture Focus:

Media Access Control PROTOCOLS

RANDOM ACCESS

Slotted ALOHA

Slotted ALOHA was invented to improve the efficiency of pure ALOHA.

In slotted ALOHA we divide the time into slots of Tfr s and force the station to send only at the beginning of the time slot. Each slot corresponds to one frame.

All the senders have to be synchronized, transmission can only start at the beginning of a time slot. Senders must agree on time slots. i.e synchronization

However, access is not coordinated.

Figure below shows an example of frame collisions in slotted ALOHA.

Page 23: Lecture Focus:

Media Access Control PROTOCOLS

RANDOM ACCESS

Slotted ALOHA

Frame 1.1 Frame 1.2

Frame 2.2

Frame 4.1

Frame 3.1

Frame 2.1

Frame 4.2

Frame 3.2

Station 1

Station 4

Station 3

Station 2

Slot 1 Slot 3Slot 2 Slot 5Slot 4 Slot 6

Time

Time

Time

Time

CollisionDuration

CollisionDuration

Page 24: Lecture Focus:

Media Access Control PROTOCOLS

RANDOM ACCESS

Slotted ALOHA

A station is allowed to send only at the beginning of the synchronized time slot. If a station misses this moment, it must wait until the beginning of the next time slot.

This means that the station which started at the beginning of this slot has already finished sending its frame.

There is still the possibility of collision if two stations try to send at the beginning of the same time slot.

Page 25: Lecture Focus:

Media Access Control PROTOCOLS

RANDOM ACCESS

Carrier Sense Multiple Access (CSMA)

One improvement to the basic ALOHA is sensing the carrier before sending data.

Sensing the carrier and sending the data only if the carrier is idle decreases the probability of a collision.

To minimize the chance of collision and, therefore, increase the performance, the CSMA method was developed.

The chance of collision can be reduced if a station senses the medium before trying to use it.

CSMA requires that each station first listen to the medium (or check the state of the medium) before sending.

“Sense before transmit" OR "listen before talk“.

CSMA can reduce the possibility of collision, but it cannot eliminate it.

Page 26: Lecture Focus:

Media Access Control PROTOCOLS

RANDOM ACCESS

Carrier Sense Multiple Access (CSMA)

Page 27: Lecture Focus:

Media Access Control PROTOCOLS

RANDOM ACCESS

Carrier Sense Multiple Access (CSMA)

The possibility of collision still exists because of propagation delay; when a station sends a frame, it still takes time (although very short) for the first bit to reach every station and for every station to sense it.

A station may sense the medium and find it idle, only because the first bit sent by another station has not yet been received.

At time t1, station A senses the medium and finds it idle, so it sends a frame.

At time t2 (t2> t1), station Z senses the medium and finds it idle because, at this time, the first bits from station A have not reached station Z.

Station Z also sends a frame. The two signals collide and both frames are destroyed.

Page 28: Lecture Focus:

Media Access Control PROTOCOLS

RANDOM ACCESS: Carrier Sense Multiple Access (CSMA)

Variants of CSMA

CSMA/CD

CSMA/CA1-Persistent

P-Persistent

Non-Persistent

EY-NPMA

CSMA

Page 29: Lecture Focus:

Media Access Control PROTOCOLS

RANDOM ACCESS: Carrier Sense Multiple Access (CSMA)

Persistent Strategies

What should a station do if the channel is busy? What should a station do if the channel is idle?

Three methods have been devised to answer these questions: The 1-persistent method, The non-persistent method The p-persistent method.

Persistent Strategies1-Persistent

p-Persistent

Non-Persistent

Persistent

Page 30: Lecture Focus:

Media Access Control PROTOCOLS

RANDOM ACCESS: Carrier Sense Multiple Access (CSMA)

Persistent Strategies 1-Persistent

The 1-persistent method is simple and straightforward.

In this method, after the station finds the line idle, it sends its frame immediately (with probability 1).

This method has the highest chance of collision: Two or more stations may find the

line idle. They send their frames

immediately.

Page 31: Lecture Focus:

Media Access Control PROTOCOLS

RANDOM ACCESS: Carrier Sense Multiple Access (CSMA)

Persistent Strategies 1-Persistent

Figure below shows the behavior of 1-persistence method when a station finds a channel busy.

Continuously sense

Sense and transmit

Busy

Time

Need to transmit

Page 32: Lecture Focus:

Media Access Control PROTOCOLS

RANDOM ACCESS: Carrier Sense Multiple Access (CSMA)

Persistent Strategies 1-Persistent

A continuously senses

Senses and transmit

Busy Time

Station A needs to transmit

Senses and transmit Station B needs to transmit

B continuously senses

Collision

Collision: This method has the highest chance of collision: Two or more stations may find the line idle. They send their frames immediately.

Page 33: Lecture Focus:

Media Access Control PROTOCOLS

RANDOM ACCESS: Carrier Sense Multiple Access (CSMA)

Persistent Strategies Non-Persistent

A station that has a frame to send senses the line.

If the line is idle, it sends immediately. If the line is busy, it waits a random amount of time and then

senses the line

Page 34: Lecture Focus:

Media Access Control PROTOCOLS

RANDOM ACCESS: Carrier Sense Multiple Access (CSMA)

Persistent Strategies Non-Persistent

Collision: This approach reduces the chance of collision:

It is unlikely that two or more stations will wait the same amount of time and retry to send simultaneously.

Efficiency: This method reduces the efficiency of the network because medium

remains idle when there may be stations with frames to send.

Page 35: Lecture Focus:

Media Access Control PROTOCOLS

RANDOM ACCESS: Carrier Sense Multiple Access (CSMA)

Persistent Strategies Non-Persistent

Figure below shows the behavior of Non-Persistence method when a station finds a channel busy.

Sense and transmit

Busy

Time

Need to transmit

Sense

WaitSense

Wait

Page 36: Lecture Focus:

Media Access Control PROTOCOLS

RANDOM ACCESS: Carrier Sense Multiple Access (CSMA)

Persistent Strategies p-Persistent

This method is used if the channel has time slots with a slot duration equal to or greater than the maximum propagation time.

This approach combines the advantages of the other two strategies. It reduces the chance of collision and improves efficiency.

After the station finds the line idle, it follows these steps:

1. With probability p, the station sends its frame.

2. With probability q = 1 - p, the station waits for the beginning of the next time slot and checks the line again.a. If the line is idle, it goes to step 1.b. If the line is busy, it acts as though a collision has occurred

and uses the back-off procedure.

Page 37: Lecture Focus:

Media Access Control PROTOCOLS

RANDOM ACCESS: Carrier Sense Multiple Access (CSMA)

Persistent Strategies p-Persistent

Page 38: Lecture Focus:

Media Access Control PROTOCOLS

RANDOM ACCESS: Carrier Sense Multiple Access (CSMA)

Persistent Strategies p-Persistent

Continuously sense

Transmit

Busy

Time

Need to transmit

Time slot Time slot Time slot

Probability outcome does not allow transmission

Page 39: Lecture Focus:

Media Access Control PROTOCOLS

RANDOM ACCESS: Carrier Sense Multiple Access (CSMA)

EY-NPMAElimination Yield – Non Preemptive Multiple Access

Here priority schemes can be included to assure preference of certain stations with more important data.

Page 40: Lecture Focus:

Media Access Control PROTOCOLS

RANDOM ACCESS: Carrier Sense Multiple Access (CSMA)

Carrier Sense Multiple Access with Collision Detection (CSMA / CD)

The CSMA method does not specify the procedure following a collision.

Carrier Sense Multiple Access with Collision Detection (CSMA/CD) augments the algorithm to handle the collision.

In this method, a station monitors the medium after it sends a frame to see if the transmission was successful. If so, the station is finished. If there is a collision, the frame is sent again.

Page 41: Lecture Focus:

Media Access Control PROTOCOLS

RANDOM ACCESS: Carrier Sense Multiple Access (CSMA)

Carrier Sense Multiple Access with Collision Detection (CSMA / CD)

Page 42: Lecture Focus:

Media Access Control PROTOCOLS

RANDOM ACCESS: Carrier Sense Multiple Access (CSMA)

Carrier Sense Multiple Access with Collision Detection (CSMA / CD)

Let us look at the first bits transmitted by the two stations involved in the collision.

Although each station continues to send bits in the frame until it detects the collision, we show what happens as the first bits collide.

In above figure, stations A and C are involved in the collision.

Page 43: Lecture Focus:

Media Access Control PROTOCOLS

RANDOM ACCESS: Carrier Sense Multiple Access (CSMA)

Carrier Sense Multiple Access with Collision Detection (CSMA / CD)

At time t1, station A has executed its persistence procedure and starts sending the bits of its frame.

At time t2, station C has not yet sensed the first bit sent by A. Station C executes its persistence procedure and starts sending the bits in its frame, which propagate both to the left and to the right.

The collision occurs sometime after time t2.

Station C detects a collision at time t3 when it receives the first bit of A’s frame. Station C immediately (or after a short time, but we assume immediately) aborts transmission.

Station A detects collision at time t4 when it receives the first bit of C's frame; it also immediately aborts transmission.

At time t4, the transmission of A’s frame, though incomplete, is aborted.

At time t3, the transmission of C's frame, though incomplete, is aborted.

Page 44: Lecture Focus:

Media Access Control PROTOCOLS

RANDOM ACCESS: Carrier Sense Multiple Access (CSMA)

CSMA / CD PROCEDURE

Page 45: Lecture Focus:

Media Access Control PROTOCOLS

RANDOM ACCESS: Carrier Sense Multiple Access (CSMA)

CSMA / CD PROCEDURE

Page 46: Lecture Focus:

Media Access Control PROTOCOLS

RANDOM ACCESS: CSMA / CD PROCEDURE

Page 47: Lecture Focus:

Media Access Control PROTOCOLS

RANDOM ACCESS: Carrier Sense Multiple Access (CSMA)

CSMA / CD PROCEDURE

CSMA/CD procedure is similar to the one for the ALOHA protocol, but there are differences.

We need to sense the channel before we start sending the frame by using one of the persistence processes.

In ALOHA, we first transmit the entire frame and then wait for an acknowledgment.

In CSMA/CD, transmission and collision detection is a continuous process. We do not send the entire frame and then look for a collision. The station transmits and receives continuously and simultaneously (using two different ports). We use a loop to show that transmission is a continuous process. We constantly monitor in order to detect one of two conditions: either transmission is finished or a collision is detected. Either of these events stops transmission. When we come out of the loop, if a collision has not been detected, it means that transmission is complete; the entire frame is transmitted. Otherwise, a collision has occurred.

We send a short jamming signal that enforces the collision in case other stations have not yet sensed the collision.

Page 48: Lecture Focus:

Media Access Control PROTOCOLS

RANDOM ACCESS: CSMA / CD PROCEDURE

Energy Level We can say that the level of energy in a channel can have three

values: zero, normal, and abnormal. At the zero level, the channel is idle. At the normal level, a station has successfully captured the channel

and is sending its frame. At the abnormal level, there is a collision and the level of the energy is

twice the normal level. A station that has a frame to send or is sending a frame needs to

monitor the energy level to determine if the channel is idle, busy, or in collision mode.

Page 49: Lecture Focus:

Media Access Control PROTOCOLS

RANDOM ACCESS

CSMA / CASelf Study