UNIT II DATA-LINK LAYER & MEDIA ACCESS · 5 POINT-TO-POINT PROTOCOL (PPP) One of the most common...

23
UNIT II DATA-LINK LAYER & MEDIA ACCESS 1. LINK-LAYER ADDRESSING A link-layer address is sometimes called a link address, sometimes a physical address and sometimes a MAC address. When a datagram passes from the network layer to the data- link layer, the datagram will be encapsulated in a frame and two data-link addresses are added to the frame header. These two addresses are changed every time the frame moves from one link to another. IP addresses and link-layer addresses in a small internet Each frame carries the same datagram with the same source and destination IP addresses (N1 and N8), but the link- layer addresses of the frame change from link to link. In link 1, the link-layer addresses are L1 and L2. In link 2, they are L4 and L5. In link 3, they are L7 and L8. Note that For IP addresses, the source address comes before the destination address; for link-layer addresses, the destination address comes before the source. Some link-layer protocols define three types of addresses: Unicast: Each host or each interface of a router is assigned a unicast address. Unicasting means one-to-one communication. A frame with a unicast address destination is destined only for one entity in the link. Multicast: one-to-many communication. However, the jurisdiction is local (inside the link).

Transcript of UNIT II DATA-LINK LAYER & MEDIA ACCESS · 5 POINT-TO-POINT PROTOCOL (PPP) One of the most common...

Page 1: UNIT II DATA-LINK LAYER & MEDIA ACCESS · 5 POINT-TO-POINT PROTOCOL (PPP) One of the most common protocols for point-to-point access is the Point-to-Point Protocol (PPP). Today, millions

UNIT II DATA-LINK LAYER & MEDIA ACCESS

1. LINK-LAYER ADDRESSING

A link-layer address is sometimes called a link address, sometimes a physical address and

sometimes a MAC address.

When a datagram passes from the network layer to the data- link layer, the datagram will be

encapsulated in a frame and two data-link addresses are added to the frame header. These two

addresses are changed every time the frame moves from one link to another.

IP addresses and link-layer addresses in a small internet

Each frame carries the same datagram with the same source and destination IP addresses (N1 and

N8), but the link- layer addresses of the frame change from link to link. In link 1, the link-layer

addresses are L1 and L2. In link 2, they are L4 and L5. In link 3, they are L7 and L8. Note that

For IP addresses, the source address comes before the destination address; for link-layer

addresses, the destination address comes before the source.

Some link-layer protocols define three types of addresses:

• Unicast: Each host or each interface of a router is assigned a unicast

address. Unicasting means one-to-one communication. A frame with a

unicast address destination is destined only for one entity in the link.

• Multicast: one-to-many communication. However, the jurisdiction is local

(inside the link).

Page 2: UNIT II DATA-LINK LAYER & MEDIA ACCESS · 5 POINT-TO-POINT PROTOCOL (PPP) One of the most common protocols for point-to-point access is the Point-to-Point Protocol (PPP). Today, millions

• Broadcast: one-to-all communication. A frame with a destination

broadcast address is sent to all entities in the link.

the unicast link-layer addresses in the most common LAN, Ethernet, are 48 bits (six

bytes) that are presented as 12 hexadecimal digits separated by colons; for example, the

following is a link- layer address of a computer. The second digit needs to be an odd

number.

A3:34:45:11:92:F1

The following shows a multicast address:

The second digit, however, needs to be an even number in hexadecimal.

A2:34:45:11:92:F1

The following shows a broadcast address:

FF:FF:FF:FF:FF:FF

All 1s, that are presented as 12 hexadecimal digits separated by colons

2. DLC SERVICES

The data link control (DLC) deals with procedures for communication between two adjacent

nodes—node-to-node communication—no matter whether the link is dedicated or broadcast.

Services or functions:

1. framing

2. flow control

3. error control.

Framing

The data link layer needs to pack bits into frames, so that each frame is distinguishable from

another.

Frame Size

• Frames can be of fixed or variable size.

• In fixed-size framing, there is no need for defining the boundaries of the frames; the size

itself can be used as a delimiter. An example of this type of framing is the ATM WAN,

which uses frames of fixed size called cells.

• variable-size framing, prevalent in local-area networks.

• In variable-size framing, we need a way to define the end of one frame and the beginning

of the next.

Page 3: UNIT II DATA-LINK LAYER & MEDIA ACCESS · 5 POINT-TO-POINT PROTOCOL (PPP) One of the most common protocols for point-to-point access is the Point-to-Point Protocol (PPP). Today, millions

Two approaches:

1. character-oriented approach

2. bit-oriented approach.

A frame in a character-oriented protocol

Byte stuffing and unstuffing

• In byte stuffing (or character stuffing), a special byte is added to the

data section of the frame when there is a character with the same

pattern as the flag.

• The data section is stuffed with an extra byte. This byte is usually called the escape character (ESC) and has a predefined bit pattern.

• Whenever the receiver encounters the ESC character, it removes it

from the data section and treats the next character as data, not as

a delimiting flag.

A frame in a bit-oriented protocol

Bit stuffing is the process of adding one extra 0 whenever five consecutive 1s follow a 0 in the

data, so that the receiver does not mistake the pattern 0111110 for a flag

Page 4: UNIT II DATA-LINK LAYER & MEDIA ACCESS · 5 POINT-TO-POINT PROTOCOL (PPP) One of the most common protocols for point-to-point access is the Point-to-Point Protocol (PPP). Today, millions

Bit stuffing and unstuffing

Flow control at the data-link layer

• One of the solutions is normally to use two buffers; one at sending data-link layer and the other at the receiving data-link layer.

• A buffer is a set of memory locations that can hold packets at the sender and receiver.

• The flow control communication can occur by sending signals from the consumer to the producer. When the buffer of the receiving data-link layer is full, it informs the sending data-link layer to stop pushing frames.

Error control in the data link layer

◼ Error control in the data link layer is based on automatic repeat request,

which is the retransmission of data.

◼ Error control at the data-link layer is normally very simple and implemented using one of the following two methods.

Page 5: UNIT II DATA-LINK LAYER & MEDIA ACCESS · 5 POINT-TO-POINT PROTOCOL (PPP) One of the most common protocols for point-to-point access is the Point-to-Point Protocol (PPP). Today, millions

◼ In both methods, a CRC is added to the frame header by the sender and checked by the receiver.

◼ In the first method, if the frame is corrupted, it is silently discarded; if it is not corrupted, the packet is delivered to the network layer. This method is used mostly in wired LANs such as Ethernet.

◼ In the second method, if the frame is corrupted, it is silently discarded; if it is not corrupted, an acknowledgment is sent (for the purpose of both flow and error control) to the sender.

3. DATA-LINK LAYER PROTOCOLS

Let us first assume we have an ideal channel in which no frames are lost, duplicated, or

corrupted. We introduce two protocols for this type of channel

1. Simplest Protocol

2. Stop-and-Wait Protocol

◼ The behavior of a data-link-layer protocol can be better shown as a finite state machine

(FSM).

◼ An FSM is thought of as a machine with a finite number of states.

◼ We have used rounded-corner rectangles to show states, colored text to show events, and

regular black text to show actions. A horizontal line is used to separate the event from the

actions, although later we replace the horizontal line with a slash. The arrow shows the

movement to the next state.

Page 6: UNIT II DATA-LINK LAYER & MEDIA ACCESS · 5 POINT-TO-POINT PROTOCOL (PPP) One of the most common protocols for point-to-point access is the Point-to-Point Protocol (PPP). Today, millions

◼ The sender sends a sequence of frames without even thinking about the receiver.

◼ To send three frames, three events occur at the sender site and three events at the

receiver site.

Note that the data frames are shown by tilted boxes; the height of the box defines the

transmission time difference between the first bit and the last bit in the frame.

Stop-and-Wait Protocol

Sender States

• The sender is initially in the ready state, but it can move between the ready and blocking

state.

• Ready State. When the sender is in this state, it is only waiting for a packet from the

network layer. If a packet comes from the network layer, the sender creates a frame,

saves a copy of the frame, starts the only timer and sends the frame.

• The sender then moves to the blocking state.

• Blocking State. When the sender is in this state, three events can occur:

o If a time-out occurs, the sender resends the saved copy of the

frame and restarts the timer.

o If a corrupted ACK arrives, it is discarded.

o If an error-free ACK arrives, the sender stops the timer and

discards the saved copy of the frame. It then moves to the ready

state.

Page 7: UNIT II DATA-LINK LAYER & MEDIA ACCESS · 5 POINT-TO-POINT PROTOCOL (PPP) One of the most common protocols for point-to-point access is the Point-to-Point Protocol (PPP). Today, millions

Receiver states

The receiver is always in the ready state. Two events may occur:

1. If an error-free frame arrives, the message in the frame is

delivered to the network layer and an ACK is sent.

2. If a corrupted frame arrives, the frame is discarded.

◼ To correct duplicate packets we need to add sequence numbers to the data frames and

acknowledgment numbers to the ACK frames.

◼ Numbering in this case is very simple. Sequence numbers are 0, 1, 0, 1, 0, 1, . . . ; the

acknowledgment numbers can also be 1, 0, 1, 0, 1, 0, …

◼ In other words, the sequence numbers start with 0, the acknowledgment numbers start

Page 8: UNIT II DATA-LINK LAYER & MEDIA ACCESS · 5 POINT-TO-POINT PROTOCOL (PPP) One of the most common protocols for point-to-point access is the Point-to-Point Protocol (PPP). Today, millions

with 1.

◼ An acknowledgment number always defines the sequence number of the next frame to

receive.

◼ Figure shows how adding sequence numbers and acknowledgment numbers can prevent

duplicates. The first frame is sent and acknowledged. The second frame is sent, but lost.

After time-out, it is resent. The third frame is sent and acknowledged, but the

acknowledgment is lost. The frame is resent.

Flow diagram

4 HDLC

• High-level Data Link Control – protocol supporting half-duplex and full-duplex

communication over point-to-point and multipoint links

• Relationship between two devices involved in an exchange

• Defines who controls the link

Two modes:

– Normal response mode (NRM)

– Asynchronous balanced mode (ABM)

Normal Response Mode

• Refers to standard primary-secondary relationships

• Used for all exchanges in unbalanced configurations

• Primary can issues commands

• Secondary must have permission from primary before responding or sending data

Page 9: UNIT II DATA-LINK LAYER & MEDIA ACCESS · 5 POINT-TO-POINT PROTOCOL (PPP) One of the most common protocols for point-to-point access is the Point-to-Point Protocol (PPP). Today, millions

Asynchronous Balanced Mode

• All stations are equal

• Stations in point-to-point configurations act as both primary and secondary

HDLC Frames

• Three types; each functions as an envelope to transmit a specific type of message

• Information frames (I-frames) – transports user data and control info relating to user data

• Supervisory frames (S-frames) – used to transport control info for data link layer flow

and error controls

• Unnumbered frames (U-frames) – used for system mgmt and link mgmt

• Flag field. This field contains synchronization pattern 01111110, which identifies both

the beginning and the end of a frame.

• Address field. This field contains the address of the secondary station. If a primary

station created the frame, it contains a to address. If a secondary station creates the frame,

it contains a from address.

• Control field. The control field is one or two bytes used for flow and error control.

• Information field. The information field contains the user’s data from the network layer

or management information.

• FCS field. The frame check sequence (FCS) is the HDLC error detection field. It can

contain either a 2- or 4-byte CRC.

Page 10: UNIT II DATA-LINK LAYER & MEDIA ACCESS · 5 POINT-TO-POINT PROTOCOL (PPP) One of the most common protocols for point-to-point access is the Point-to-Point Protocol (PPP). Today, millions

Control field format for the different frame types

• Figure shows how U-frames can be used for connection establishment and connection

release.

• Node A asks for a connection with a set asynchronous balanced mode (SABM) frame;

• node B gives a positive response with an unnumbered acknowledgment (UA) frame.

• After these two exchanges, data can be transferred between the two nodes

• After data transfer, node A sends a DISC (disconnect) frame to release the connection; it

is confirmed by node B responding with a UA (unnumbered acknowledgment).

Example of connection and disconnection

Page 11: UNIT II DATA-LINK LAYER & MEDIA ACCESS · 5 POINT-TO-POINT PROTOCOL (PPP) One of the most common protocols for point-to-point access is the Point-to-Point Protocol (PPP). Today, millions

5 POINT-TO-POINT PROTOCOL (PPP) One of the most common protocols for point-to-point access is the Point-to-Point

Protocol (PPP). Today, millions of Internet users who need to connect their home

computers to the server of an Internet service provider use PPP. PPP Defines

– Frame format

– Negotiate and establish exchange of data

– Encapsulation of network layer data

– Authentication

PPP Data Frame

• Flag: delimiter (framing)

• Address: does nothing (only one option)

• Control: does nothing; No flow control. Error control is also limited to error detection.

• Protocol: upper layer protocol to which frame delivered (eg, IP, PPP-LCP, IPCP, etc)

• info: upper layer data being carried

• check: cyclic redundancy check for error detection

PPP – Transition States

• Idle, Establishing, Authenticating, Networking, Terminating

Page 12: UNIT II DATA-LINK LAYER & MEDIA ACCESS · 5 POINT-TO-POINT PROTOCOL (PPP) One of the most common protocols for point-to-point access is the Point-to-Point Protocol (PPP). Today, millions

PPP – Stack

• Three Protocols

– Link Control protocol

– Authentication protocol, and

– Network Control protocol

PPP – Link Control Protocol

• LCP Responsibilities

– Establishing, Maintaining, Configuring, and Terminating Links

– Payload: Code, ID, Length, Information Fields

Page 13: UNIT II DATA-LINK LAYER & MEDIA ACCESS · 5 POINT-TO-POINT PROTOCOL (PPP) One of the most common protocols for point-to-point access is the Point-to-Point Protocol (PPP). Today, millions

Authentication Protocols

• Password Authentication Protocols (PAP)

– User sends ID (user name), and Password

– System checks the validity: accept, or reject

• Challenge Handshake Authentication Protocols (CHAP)

– System send a challenge packet

– The user applies a predefined function, and reply the challenge packet

– The system does the same to see if the same result can be obtained: accept or

reject

PAP

CHAP

Page 14: UNIT II DATA-LINK LAYER & MEDIA ACCESS · 5 POINT-TO-POINT PROTOCOL (PPP) One of the most common protocols for point-to-point access is the Point-to-Point Protocol (PPP). Today, millions

• Let us go through the phases followed by a network layer packet as it is transmitted

through a PPP connection. Figure shows the steps. For simplicity, we assume

unidirectional movement of data from the user site to the system site (such as sending an

e-mail through an ISP).

• The first two frames show link establishment. We have chosen two options (not shown in

the figure): using PAP for authentication and suppressing the address control fields.

Frames 3 and 4 are for authentication. Frames 5 and 6 establish the network layer

connection using IPCP.

• The next several frames show that some IP packets are encapsulated in the PPP frame.

The system (receiver) may have been running several network layer protocols, but it

knows that the incoming data must be delivered to the IP protocol because the NCP

protocol used before the data transfer was IPCP.

• After data transfer, the user then terminates the data link connection, which is

acknowledged by the system. Of course the user or the system could have chosen to

terminate the network layer IPCP and keep the data link layer running if it wanted to run

another NCP protocol.

Page 15: UNIT II DATA-LINK LAYER & MEDIA ACCESS · 5 POINT-TO-POINT PROTOCOL (PPP) One of the most common protocols for point-to-point access is the Point-to-Point Protocol (PPP). Today, millions

6. MAC When nodes or stations are connected and use a common link, called a multipoint or

Page 16: UNIT II DATA-LINK LAYER & MEDIA ACCESS · 5 POINT-TO-POINT PROTOCOL (PPP) One of the most common protocols for point-to-point access is the Point-to-Point Protocol (PPP). Today, millions

broadcast link, we need a multiple-access protocol to coordinate access to the link. Many protocols have been

devised to handle access to a shared link. All of these protocols belong to a sublayer in the data-link layer called

media access control (MAC)

Taxonomy of multiple-access protocols (MAC)

• Random Access Protocol: In this, all stations have same superiority that is no station has

more priority than another station.

• Any station can send data depending on medium’s state( idle or busy).

It has two features:

• There is no fixed time for sending data

• There is no fixed sequence of stations sending data

• Aloha is based on the principle that if you have data to send, send it. If there is a

collision then the protocol resends the data at a latter time. This leads to degraded channel

utilization since multiple nodes may transmit at the same time. An improvement of this

protocol is the slotted Aloha,

• Slotted Aloha is an extension of basic Aloha in which time is divided into discrete time

slots. A node can only transmit at the beginning of these time slots. This helps in

reducing collisions.

• CSMA This stands for Carrier Sense Multiple Access. In CSMA, before transmitting,

nodes listen for other traffic on the same shared medium. If they sense another node is

transmitting, they withhold their transmission. Once the other node's transmission has

finished, the waiting node may proceed to transmit. However, this still leaves a

probability that multiple nodes may sense the channel idle and start transmitting

simultaneously.

• CSMA/CD CSMA with Collision Detection (CD) refers to the ability of the node to

detect collision . When this happens, the transmitting node immediately stops its

transmission. It then calculates a random backoff time t, after which it tries to re-transmit

its frame. Since multiple nodes each choose a different t, this technique helps sort the

problem of collisions. This protocol is used in 802.3 networks.

• CSMA/CA Wireless networks do not employ CSMA/CD but employ CSMA/CA

(Collision Avoidance). The reason is that in the former the collision is detected at the

transmitter. However in wireless networks, it is important to detect collisions at the

receiver side due to the hidden node problem

Page 17: UNIT II DATA-LINK LAYER & MEDIA ACCESS · 5 POINT-TO-POINT PROTOCOL (PPP) One of the most common protocols for point-to-point access is the Point-to-Point Protocol (PPP). Today, millions

CSMA/CD (Collision Detection)

▪ CSMA (all previous methods) has an inefficiency:

▪ If a collision has occurred, the channel is unstable until colliding packets have

been fully transmitted

▪ CSMA/CD (Carrier Sense Multiple Access with Collision

Detection) overcomes this as follows:

▪ While transmitting, the sender is listening to medium for collisions.

▪ Sender stops transmission if collision has occurred reducing channel wastage .

CSMA/CD is Widely used for bus topology LANs (IEEE 802.3, Ethernet).

Flow diagram for three persistence methods

• Use one of the CSMA persistence algorithm

(non-persistent, 1-persistent, p-persistent) for transmission

• If a collision is detected by a station during its transmission then it should do the

following:

– Abort transmission and

– Transmit a jam signal (48 bit) to notify other stations of collision so that they

will discard the transmitted frame also to make sure that the collision signal

will stay until detected by the furthest station

– After sending the jam signal, backoff (wait) for a random amount of time, then

– Transmit the frame again

Page 18: UNIT II DATA-LINK LAYER & MEDIA ACCESS · 5 POINT-TO-POINT PROTOCOL (PPP) One of the most common protocols for point-to-point access is the Point-to-Point Protocol (PPP). Today, millions

Flow diagram for the CSMA/CD

CSMA/CA

• Carrier sense multiple access with collision avoidance (CSMA/CA) was invented for

wireless networks. Collisions are avoided through the use of CSMA/CA’s three

strategies:

1. interframe space,

2. contention window

3. acknowledgments

• When an idle channel is found, the station does not send immediately. It waits for a

period of time called the interframe space or IFS. Even though the channel may appear

idle when it is sensed, a distant station may have already started transmitting

• Contention Window. The contention window is an amount of time divided into slots. A

station that is ready to send chooses a random number of slots as its wait time.

• The positive acknowledgment and the time-out timer can help guarantee that the

receiver has received the frame.

Page 19: UNIT II DATA-LINK LAYER & MEDIA ACCESS · 5 POINT-TO-POINT PROTOCOL (PPP) One of the most common protocols for point-to-point access is the Point-to-Point Protocol (PPP). Today, millions

Flow diagram of CSMA/CA

Controlled Access or Scheduling

• In controlled access, the stations consult one another to find which station has the right to

send. A station cannot send unless it has been authorized by other stations

• Provides in order access to shared medium so that every station has chance to transfer

• Eliminates collision completely

• Three methods for controlled access:

– Reservation

– Polling

– Token Passing

Page 20: UNIT II DATA-LINK LAYER & MEDIA ACCESS · 5 POINT-TO-POINT PROTOCOL (PPP) One of the most common protocols for point-to-point access is the Point-to-Point Protocol (PPP). Today, millions

Token passing

• In CSMA/CD and CSMA/CA the chances of collisions are there. As the number of hosts

in the network increases, the chances of collisions also will become more. In token

passing, when a host want to transmit data, it should hold the token, which is an empty

packet. The token is circling the network in a very high speed. If any workstation wants

to send data, it should wait for the token. When the token has reached the workstation,

the workstation can take the token from the network, fill it with data, mark the token as

being used and place the token back to the network.

Page 21: UNIT II DATA-LINK LAYER & MEDIA ACCESS · 5 POINT-TO-POINT PROTOCOL (PPP) One of the most common protocols for point-to-point access is the Point-to-Point Protocol (PPP). Today, millions

Token-passing procedure

CHANNELIZATION

• Channelization is a multiple-access method in which the available bandwidth of a link

is shared in time, frequency, or through code, between different stations.

1. Frequency-Division Multiple Access (FDMA)

2. Time-Division Multiple Access (TDMA)

3. Code-Division Multiple Access (CDMA)

FDMA

• FDMA: Frequency Division Multiple Access:

– Transmission medium is divided into M separate frequency bands

advantages of FDMA

➨It allocates dedicated frequencies to different stations. Moreover there are separate bands for

both uplink and downlink. Hence stations transmit and receive continuously at their allocated

frequencies.

➨It is very simple to implement with respect to hardware resources.

➨FDMA is efficient when constant traffic is required to be managed with less number of user

population.

disadvantages of FDMA

➨In FDMA, frequencies are allocated permanently and hence spectrum will be wasted when

stations are not transmitting or receiving.

➨Network and spectrum planning is cumbersome and time consuming.

➨It uses guard bands to prevent interference. This wastes frequency resources.

Page 22: UNIT II DATA-LINK LAYER & MEDIA ACCESS · 5 POINT-TO-POINT PROTOCOL (PPP) One of the most common protocols for point-to-point access is the Point-to-Point Protocol (PPP). Today, millions

• TDMA: Time Division Multiple Access

– The entire bandwidth capacity is a single channel with its capacity shared in time

between M stations

– A node must always wait for its turn until its slot time arrives even when it is the

only node with frames to send

Advantages:

• The operational costs of TDMA networks are lower compare to traditional FDMA

network.

➨The different types of traffic e.g. voice, data and video are transmitted using TDMA

technique as this require different data rates which can be easily achieved using

allocation of multiple time slots.

• disadvantages of TDMA

➨Network and spectrum planning require more efforts.

Page 23: UNIT II DATA-LINK LAYER & MEDIA ACCESS · 5 POINT-TO-POINT PROTOCOL (PPP) One of the most common protocols for point-to-point access is the Point-to-Point Protocol (PPP). Today, millions

◼ CDMA: Code Division Multiple Access

◼ In CDMA, one channel carries all transmissions simultaneously

◼ Each station codes its data signal by a specific codes before transmission

◼ The stations receivers use these codes to recover the data for the desired station

Advantages:

1. The CDMA does not require any synchronization.

2. It has more number of users can share the same bandwidth.

3. Due to code word allocated to each user, interference is reduced.

4. Efficient practical utilization of fixed frequency spectrum.

Disadvantages:

1. The system is more complicated.

2. As the number of users increases, the overall quality of services decreases.