0% found this document useful (0 votes)
25 views

Module II

Uploaded by

Keshav Mishra
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views

Module II

Uploaded by

Keshav Mishra
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 69

Module-2

Data Link
Layer
Contents
 The Data link layer:
 Design issues of DLL
 Error detection and correction
 Elementary data link protocols
 Sliding window protocols

 The medium access control sublayer:


 The channel allocation problem
 Multiple access protocols
DATA LINK LAYER DESIGN ISSUES
(Node-to-Node)
 Physical Layer delivers bits of information to and from Data
Link layer
The functions of Data Link Layer :
1.Provides a well-defined service interface to the NL.
2.Dealing with transmission errors.
3.Regulating the flow of data so that slow receivers are not swamped by
fast senders.

Frame start, addr,


ED, F-stop bits
Type of data, Quality control
DATA LINK LAYER DESIGN ISSUES

1. Services Provided to the Network Layer


2. Framing
3. Error Control(EC)
4. Flow Control(FC)
1.Services Provided to the Network Layer

 The principal service is transferring data from the network layer on the source
machine to the network layer on the destination machine.
 @ src m/c is an entity(a process), in the NL that sends bits to the DL for
transmission to the dest.
 The DL offer various services:
1. Unacknowledged connectionless service: No logical connection b/w src & dst,
Lost pkt no recovery.
2. Acknowledged connectionless service(Wifi). No logical connection, Timer, Used
in Unreliable channel.
3. Acknowledged connection-oriented service. Connection setup before transfer-3
phase
2. Framing:
(Way for a sender to transmit set of bits that are meaningful to receiver)

 DL breaks up the bit stream into discrete frames, computes


checksum for each frame, and include the checksum in the frame
when it is transmitted.
 When a frame arrives at the destination, the checksum is
recomputed. If computed checksum is different from the frame
contained, the DL knows that an error has occurred and takes
steps to deal with it.
 Framing methods:
a) Byte Count(Character Count)
b) Flag bytes with byte stuffing
c) Flag bits with bit stuffing
d) Physical layer coding violations
a) Byte count(Character Count):
b) Flag bytes with byte stuffing(Character Stuffing)
 Each frame start & end with special byte-Flag byte
 If already flag byte occurs in the frame ,stuff extra escape
byte(ESC)
Byte stuffing(Character Stuffing)
c) Flag bits with bit stuffing
Bit stuffing
d) Physical layer coding violations:
 This method used for n/w in which encoding on physical medium
contains some redundancy(no longer needed & not useful).
 LAN Encode: Each bit of data is represented with two bit.
3.Error Control(EC)

 If the sender receives a positive ack ,it knows the frame has
arrived safely.
 On the other hand, a negative ack means that something has
gone wrong and the frame must be transmitted again.
 But certain frames can go missing due to the introduction of
noise in the signal.
 If ack lost, Timer event, Duplication of pkt, Sequence no.
4.Flow Control(FC)

 Sender should send the data at the same speed as the receiver is
capable of receiving. Otherwise receiver will loose couple of
frames.

 Two approaches are commonly used.


1. Feedback-based FC- To info sender when it should send next
frame.
2. Rate-based FC- The protocol has a built-in mechanism that limits
the rate at which senders may transmit data, without using
feedback from the receiver
ERROR DETECTION AND CORRECTION

 Two basic strategies for dealing with errors. Both add


redundant info to the data that is sent.
1. Forward Error Correction When the receiver detects error in
the data received, it executes error-correcting code, which helps
to correct error & auto-recover.
2. Backward Error Correction When the receiver detects an error
in the data received, it requests back the sender to retransmit
the data unit.
ERROR DETECTION

1. Parity
2. Checksum
3. Cyclic Redundancy Checks (CRCs)
PARITY METHOD
(Single bit error)

 A single parity bit is appended to the data.


 The parity bit is chosen so that the number of bits in the codeword is even or
odd.
 Even parity for asynchronous Transmission
 Odd parity for synchronous Transmission (Continuous)
Ex 3. Both agree with EVEN parity
Transmitted data: 10011010 4
Received data : 11011010 5

Now an error will be detected, since the no. of ones received are
ODD
------------------------------------------------------------------------------
Ex 4. Transmitted data : 10011010->4
Received data : 01011010 ->4
The received data is wrong even though the no. of ones are EVEN.
Since two bits are inverted error can’t be detected.
CHECKSUM

Invert
The structure of encoder and decoder
Cyclic Redundancy Checks (CRCs)
Error Correction
Hamming Distance: The number of differences
between the corresponding bits (same size) of
two words, d(x, y).
It can be found using XOR operation on the two
words and counting the number of 1s in the
result.
 Ex: d(000, 011) is 2 because 000 011 is 011 (two
1s).
Ex: d(10101, 11110) is 3 because 10101 11110 is
01011 (three 1s).
 Hamming Code: Single Bit Error
 Even Parity
Elementary Data Link Protocols
Protocols in DLL perform : framing, error
control and flow control.
Framing is the process of dividing bit - streams
from physical layer into data frames(few hundred to
a few thousand bytes).
Unrestricted Simplex Protocol
Following assumptions are made
 Data transmission is simplex i.e. transmitted in one direction
only.
 Both transmitting and receiving network layers are ready.
 Processing time is ignored.
 Infinite buffer space is available.
 An error free channel.

This is an unrealistic protocol, nickname “Utopia(an imagined place)”


Simplex Stop and Wait Protocol
The following assumptions are made
a. Error free channel.
b. Data transmission simplex.

Transmitter waits for Δt time for an Ack this


protocol is called stop and wait protocol.
Simplex Protocol for a noisy channel
1. Lost Data pkt 2. lost ack, 3. delayed ack
Distinguish a frame and a duplicate ,Sequence no(0 or 1)
stop-and-wait operation
sender receiver
first packet bit transmitted, t = 0
last packet bit transmitted, t = L / R

first packet bit arrives


RTT last packet bit arrives, send ACK

ACK arrives, send next


packet, t = RTT + L / R

U L/R .008
sender = = = 0.00027
RTT + L / R 30.008
Practically data is transmitted in both directions. This can be achieved by full duplex
transmission. ‘forward(data) ‘ and ‘reverse(ack)’ channel. In both cases, the reverse channel is
almost wasted. To overcome this problem a technique called piggy backing is used.
Pipelining: increased utilization
sender receiver
first packet bit transmitted, t = 0
last bit transmitted, t = L / R

first packet bit arrives


RTT last packet bit arrives, send ACK
last bit of 2nd packet arrives, send ACK
last bit of 3rd packet arrives, send ACK
ACK arrives, send next
packet, t = RTT + L / R
3-packet pipelining increases
utilization by a factor of 3!

U 3L / R .0024
sender = = = 0.00081
RTT + L / R 30.008
Go-Back-N(GBN)
(Reliable transmission)

• k-bit seq # in pkt header


• “window” of up to N, consecutive unack’ed pkts allowed

 ACK(n): ACKs all pkts up to, including seq # n -


“cumulative ACK”
 may receive duplicate ACKs (see receiver)
 timer for oldest in-flight pkt
 timeout(n): retransmit packet n and all higher seq
# pkts in window
Transport Layer
GBN in action
sender window (N=4) sender receiver
012345678 send pkt0
012345678 send pkt1
send pkt2 receive pkt0, send ack0
012345678
send pkt3 Xloss receive pkt1, send ack1
012345678
(wait)
receive pkt3, discard,
012345678 rcv ack0, send pkt4 (re)send ack1
012345678 rcv ack1, send pkt5 receive pkt4, discard,
(re)send ack1
ignore duplicate ACK receive pkt5, discard,
(re)send ack1
pkt 2 timeout
012345678 send pkt2
012345678 send pkt3
012345678 send pkt4 rcv pkt2, deliver, send ack2
012345678 send pkt5 rcv pkt3, deliver, send ack3
rcv pkt4, deliver, send ack4
rcv pkt5, deliver, send ack5
Selective repeat

• receiver individually acknowledges all


correctly received pkts
– buffers pkts, as needed, for eventual in-order
delivery to upper layer
• sender only resends pkts for which ACK
not received
– sender timer for each unACKed pkt
• sender window
– N consecutive seq #’s
– limits seq #s of sent, unACKed pkts 3-38
Selective repeat: sender, receiver windows
Selective repeat
sender receiver
data from above: pkt n in [rcvbase,
rcvbase+N-1]
 if next available seq # in window, send pkt ACK(n)
 send
 out-of-order: buffer
timeout(n):  in-order: deliver (also
 resend pkt n, restart timer deliver buffered, in-
ACK(n) in [sendbase,sendbase+N]: order pkts), advance
window to next not-
 mark pkt n as received yet-received pkt
 if n smallest unACKed pkt, advancepkt n inbase
window to next
[rcvbase-
unACKed seq # N,rcvbase-1]
 ACK(n)

otherwise:
 ignore
Selective repeat in action
sender window (N=4) sender receiver
012345678 send pkt0
012345678 send pkt1
send pkt2 receive pkt0, send ack0
012345678
send pkt3 Xloss receive pkt1, send ack1
012345678
(wait)
receive pkt3, buffer,
012345678 rcv ack0, send pkt4 send ack3
012345678 rcv ack1, send pkt5 receive pkt4, buffer,
send ack4
record ack3 arrived receive pkt5, buffer,
send ack5
pkt 2 timeout
012345678 send pkt2
012345678 record ack4 arrived
012345678 rcv pkt2; deliver pkt2,
record ack5 arrived
012345678 pkt3, pkt4, pkt5; send ack2

Q: what happens when ack2 arrives?


MEDIUM ACCESS CONTROL (MAC)
Network Link can be categories in to two ways
The Channel Allocation problem
 Static channel allocation: LAN, MAN
i) FDM
ii) TDM

Guard bands
Assumptions for Dynamic Channel Allocation
Cellular

 Independent Traffic: ‘N’ stations(PC, telephone)


 Single Channel: Single channel for all nodes
 Observable Collisions
 Continuous or Slotted Time
 Carrier Sense or No Carrier Sense
Multiple Access Protocols
i) Pure ALOHA & Slotted ALOHA
ii) CSMA
iii) CSMA/CA
iv) CSMA/CD
i) Advocates of Linux Open-source
Hawaii Association: ALOHA
 1970,Norman Abramson- University of Hawaii.
 Idea: Let user transmit whenever they have data
to be sent.
 Collision: If two station wants to access channel
@same time.
 Used: Wireless LAN
 Types: Pure and Slotted
Pure ALOHA-Original ALOHA
 Each station Sends a frame whenever it has a frame to send & wait for ack.
 Collision: If two stations wants to send
 Waiting time is random (Back-off time)
 Efficiency of ALOHA:

 Performance/Throughput
Slotted ALOHA
1972, Robert
 Time is divided into timeslots.
 Sending of data allowed only at the beginning of the slot “discrete”
 Throughput:
 Throughput VS offered traffic for ALOHA system
Carrier Sense Multiple Access(CSMA)
 Idea: Stations listen for a carrier(Idle or Busy).
 Propagation Delay: It should be less.

(not continuously)

Channel is inactive, it sends a frame


with a P probability.
If the data is not transmitted, it waits
for a (q = 1-p probability) random time
and resumes the frame with the next
(1-Persistent + Non-persistent) time slot.
Carrier Sense Multiple Access/ Collision Detection (CSMA/ CD)

 Senses channel, if the channel is idle, it transmits a frame to check


whether the transmission was successful.
 If the frame is successfully received, the station sends another
frame. If any collision is detected in the CSMA/CD, the station
sends a jam/ stop signal to the shared channel to terminate data
transmission.
 After that, it waits for a random time before sending a frame to a
channel.
Collision-Free Protocols

1. Bit-Map Protocol (Reservation protocols)


2. Token Passing
3. Binary Countdown protocol
1. Bit-Map Protocol (Reservation Protocol)
 There are ‘N’ slots. Node ‘j’ may declare that it has a frame
to send by inserting 1 in slot j.
 Each node has knowledge of who wants to send a frame.
 Channel Efficiency : low load d/(d+N) d= data bits
N=no. of stations
: high load d/(d+1)

Broadcast msg
2. Token Passing
 It allows stations to transmit frames in
a predefined order.
 It circulate a small message(token),
among stations, granting permission to
send frames.
 Frames are transmitted in the direction
of the token, circulating around the
ring.
 After sending a frame, each station
must wait for all stations to send the
token and frames in one cycle.
1. Token Ring (IEEE 802.5) popular in the 1980s as an
alternative to classic Ethernet.
2. FDDI (Fiber Distributed Data Interface) in the 1990s,
a faster token ring, was surpassed by switched
Ethernet.
3. RPR (Resilient Packet Ring) defined as IEEE 802.17 in
the 2000s for metropolitan area rings used by ISPs.
3.Binary Countdown Protocol
 Bit map does not scale well to network for more stations.
 To avoid conflict uses arbitration rule: As soon as station sees that a
higher-order bit position ->0 in its address, has been overwritten
with a 1,gives up.

Channel efficiency
d/(d + log N), where
d is the address
length and N is the
number of stations.
3. Binary Countdown Protocol
A more efficient alternative to the basic bit-map
protocol and token passing for networks with many
stations.

A B C D E F G H I J

0001 0010 0011 0100 0101 0110 0111 1000 1001 1010

Multiple stations (e.g., 0010, 0100, 1001, 1010)


compete for the channel.
B 0010 • In the first bit time,
D 0100 transmissions are 0, 0, 1, and 1,
resulting in an ORed 1.
I 1001 • Stations 0010 and 0100 give up
J 1010 as they see the 1, indicating
higher-numbered stations
competing.
3. Binary Countdown Protocol
Stations 1001 and 1010 continue the bidding
process until a winner emerges (e.g., station
1010).
B 0010 • Stations 1001 and 1010 continue
the bidding process until a
D 0100
winner emerges (e.g., station
I 1001 1010). i.e J
J 1010
• Higher-numbered stations have
a higher priority than lower-
numbered stations.
Limited-Contention Protocols

 Aim to achieve low delay at low load


and improved channel efficiency at
high load.
 Proposes combining the advantages of
both contention and collision-free
protocols.
 Adaptive Tree Walk Protocol
Adaptive Tree Walk Protocol

“Stations are conceptualized as leaves


of a binary tree”
 During World War II, the U.S. Army
tested soldiers for syphilis using a
binary tree approach.
 Blood samples from “N” soldiers were
mixed in a test tube, and the testing
process recursively narrowed down the
infected soldiers.
Adaptive Tree Walk Protocol

1. Treat every stations as the


leaf of a binary tree
2. first slot (after successful
transmission), all stations
can try to get the slot(under
the root node).
3. If no conflict, fine.
4. Else, in case of conflict, only
nodes under a subtree get to
try for the next one. (depth
first search)
Slot-0 : C*, E*, F*, H* (all nodes under node 0 can try which are going to
send), conflict
Slot-1 : C* (all nodes under node 1 can try}, C sends
Slot-2 : E*, F*, H*(all nodes under node 2 can try}, conflict
Slot-3 : E*, F* (all nodes under node 5 can try to send), conflict
Slot-4 : E* (all nodes under E can try), E sends
Slot-5 : F* (all nodes under F can try), F sends
Wireless LAN Protocols(802.11)
 Wireless LAN: communicating via radio waves
and operate as broadcast channels, differing from
wired LANs.
 Access Points (APs) : wired networks to the wireless client .
 Provides megabit/sec bandwidths, up to 600 Mbps.

Detection of Collisions in Wireless LANs:


 Ack used post-transmission to identify
collisions and other errors.

Challenges in Coverage Regions:


• In practice, coverage regions are irregular due to
environmental factors like walls and obstacles.
Hidden Terminal Problem

 The hidden terminal problem is


characterized by a station not
being able to detect a potential
competitor for the medium
because the competitor is too
far away.
 This problem can lead to
collisions and wasted BW in
WLANs.
 In WLANs, interference
detection at the receiver is
crucial.
 Solution : Multiple Access
Collision Avoidance(MACA)
protocol.
Exposed Terminal Problem

 Consider the scenario where B is transmitting to A


while, at the same time, C wants to transmit to D
(Fig. 4-11(b)).
 If C senses the medium and hears a transmission, it
might falsely conclude that it cannot send to D
(dashed line).
 The actual interference would only occur between B
and C, where neither of the intended receivers is
located.
 The problem of deferral due to incorrect sensing,
wasting bandwidth, is known as the exposed terminal
problem.
MACA (Multiple Access with Collision
Avoidance)
 Developed by Karn in 1990.
 To in WLANs, hidden terminal problem and exposed
terminal problem.
RTS (Request To Send) Frame:
• A initiates communication by sending an RTS to B
• The RTS frame is a short frame (30 bytes) containing
the length of the data frame.
CTS (Clear To Send) Frame:
• B responds with a CTS

The MACA protocol. (a) A sending an RTS to B.


(b) B responding with a CTS to A.

You might also like