The document summarizes key aspects of the data link layer. It discusses how the data link layer provides a well-defined interface to the network layer, deals with frame transmission and errors, and regulates frame flow. It also describes common data link layer functions like framing, error detection, flow control, and link management. Finally, it discusses different data link protocols and how they handle issues like channel access, error handling, and window flow control.
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
Networking lecture 4 Data Link Layer by Mamun sir
1. Computer Networks
Data Link Layer
By
Md. Abdullah al mamun
Sr. Lecturer
2. Data Link Layer
• Provides a well-defined service interface to the
network layer.
• Determines how the bits of the physical layer
are grouped into frames (framing).
• Deals with transmission errors (CRC and ARQ).
• Regulates the flow of frames.
• Performs general link layer management.
Data Link Layer 2
3. Data Link Layer: Introduction
“link”
Terminology:
• Hosts and routers/ bridges/
switches are nodes
• Communication channels that
connect adjacent nodes along
communication path are links, e.g.:
– Wired links
– Wireless links
– LANs
• 2-PDU is a frame, encapsulates
datagram
Data-link layer has the responsibility of
transferring datagram from one node
to adjacent node over a link
3
4. Data Link Layer Services (1)
• Datagram transferred by different link protocols over
different links:
– Ethernet, FDDI,802.11, etc
– Different protocols different services
• Framing, link access:
– Encapsulate datagram into frame, adding header, trailer
– Channel access if shared medium
– Physical addresses used in frame headers to identify source,
destination
• Reliable delivery between adjacent nodes
– Rarely used on low bit error link (e.g., fiber)
– Essential in links with high error rates
• e.g., wireless
4
5. Link Layer Services (2)
• Flow Control:
– Pacing between adjacent sending and receiving nodes
• Error Detection:
– Errors are caused by signal attenuation, noise.
– Receiver detects presence of errors
• Either signals sender for retransmission or drops frame
• Error Correction:
– Receiver identifies and corrects bit error(s) without resorting to
retransmission
– Recovery depends on the encoding scheme
• Half-duplex and full-duplex
– Half duplex nodes at both ends of link can transmit, but not at
same time
5
6. Adaptors Communicating
datagram
link layer protocol
sending receiving
node node
frame frame
adapter adapter
• Link layer implemented in • Receiving side
network “adapter” – Looks for errors, flow control,
– Ethernet card, PCMCI card, etc
802.11 card, … – Extracts datagram, passes to
• Sending side: receiving node
– Encapsulates datagram in a • Adapter is semi-
frame
– Adds error checking bits, flow autonomous link & physical
control, etc. layers
6
7. Error Detection
• EDC: Error Detection and Correction bits (redundancy)
• D: Data protected by error checking,
– May include header fields
• Note: Error detection not 100% reliable!
– Depends on the encoding
– Larger EDC better error detection/correction capabilities
• Plus more overhead!
7
8. Parity Checking
Single Bit Parity: Two Dimensional Bit Parity:
Detect single bit errors Detect and correct single bit errors
0 0
8
9. CRC: Cyclic Redundancy Check
• View data bits, D, as a binary number
• Choose r+1 bit pattern (generator), G
• Goal: Choose r CRC bits, R, such that
– <D,R> exactly divisible by G (modulo 2)
– Receiver knows G, divides <D,R> by G.
• If non-zero remainder error detected
• CRC can detect all burst errors less than r+1 bits
• Very practical, e.g., ATM, HDCL
9
10. CRC Example
Want:
D.2r XOR R = nG
D.2r = nG XOR R
Divide D.2r by G & take
the remainder R
10
11. Packets Packets
(a) Data link Data link
Layer Frames Layer
A B
Physical Physical
Layer Layer
(b)
12 3 21 12 3 21
Medium
2
A B 1
1 Physical layer entity
3 Network layer entity
2 Data link layer entity
Figure 5.2
Data Link Layer 11
18. Sliding Window Protocols
[Tanenbaum]
• Must be able to transmit data in both
directions.
• Choices for utilization of the reverse channel:
– mix DATA frames with ACK frames.
– Piggyback the ACK
• Receiver waits for DATA traffic in the opposite direction.
• Use the ACK field in the frame header to send sequence
number of frame being ACKed.
– better use of the channel capacity.
Data Link Layer 18
19. Sliding Window Protocols
• ACKs introduce a new issue – how long does
receiver wait before sending ONLY an ACK
frame.
We need an ACKTimer!!
sender timeout period needs to set longer.
• The protocol must deal with the premature
timeout problem and be “robust” under
pathological conditions.
Data Link Layer 19
20. Sliding Window Protocols
Each outbound frame must contain a sequence number. With n
bits for the sequence number field, maxseq = 2**n - 1 and
the numbers range from 0 to maxseq.
Sliding window :: sender has a window of frames and maintains a
list of consecutive sequence numbers for frames that it is
permitted to send without waiting for ACKs.
receiver has a window that is a list of frame sequence numbers it
is permitted to accept.
Note – sending and receiving windows do NOT have to be the
same size.
Windows can be fixed size or dynamically growing and shrinking.
Data Link Layer 20
21. Sliding Window Protocols
• Host is oblivious, message order at transport level
is maintained.
sender’s window :: frames sent but not yet ACKed.
– new packets from the Host cause the upper
edge inside sender window to be incremented.
– ACKed frames from the receiver cause the
lower edge inside window to be incremented.
• All frames in the sender’s window must be saved
for possible retransmission and we need one
timer per frame in the window.
Data Link Layer 21
22. Sliding Window Protocols
• If the maximum sender window size is B,
the sender needs B buffers.
• If the sender window gets full (i.e., reaches
its maximum window size, the protocol
must shut off the Host (the network layer)
until buffers become available.
• receiver window
Frames received with sequence numbers outside
the receiver window are not accepted.
Data Link Layer 22
23. Sliding Window Protocols
receiver window
– Frames received with sequence numbers
outside the receiver window are not accepted.
– The receiver window size is normally static.
The set of acceptable sequence numbers is
rotated as “acceptable” frames arrive.
a receiver window size = 1 the protocol
only accepts frames in order.
There is referred to as Go Back N.
Data Link Layer 23
24. Standard Ways to ACK
1. ACK sequence number indicates the
last frame successfully received.
2. ACK sequence number indicates the
next frame the receiver expects to
receive.
Both of these can be strictly individual
ACKs or represent cumulative ACKing.
Cumulative ACKing is the most common
technique.
Data Link Layer 24
28. Multiple Access Links and Protocols
• Link types:
– Point-to-point, e.g.:
• PPP for dial-up access
• Point-to-point link between Ethernet switch and host
– Broadcast (shared wire or medium), e.g.:
• traditional Ethernet
• 802.11 wireless LAN
28
29. Multiple Access Protocols
• Single shared broadcast channel
• Simultaneous transmissions interference
only one node can send successfully at a time
• Multiple access protocol:
A distributed algorithm that determines how nodes
share channel, i.e., determine when node can
transmit.
• Note: Communication about channel sharing must
use channel itself!
29
30. Protocol Requirements
• Assume broadcast channel of R bps
• Requirements:
– When one node wants to transmit, it can send at rate R.
– When M nodes want to transmit, each can send at average
rate R/M
– Fully decentralized:
• no special node to coordinate transmissions
• no synchronization of clocks, slots
– Simple
cheap to implement
30
31. Taxonomy of MAC Protocols
• Channel Partitioning
– Divide channel into smaller “pieces”
• time slots
• frequency
• code
– Allocate piece to node for exclusive use
• Random Access
– Channel not divided, allow collisions
– Handle collisions
• Turn-taking
– Tightly coordinate shared access to avoid collisions
31
32. Channel Partitioning: TDMA
• TDMA: Time Division Multiple Access
– Slice bandwidth into time slots
– Each station gets fixed length slot (length = packet
transmission time) in each round
– Unused slots go idle
• Example:
– 6-station LAN,
– 1,3,4 have pkt, slots 2,5,6 idle:
32
33. Channel Partitioning: FDMA
• FDMA: Frequency Division Multiple Access
– Channel spectrum divided into frequency bands
– Each station assigned fixed frequency band
– Unused transmission time in frequency bands go idle
• Example:
– 6-station LAN,
– 1,3,4 have pkt, frequency bands 2,5,6 idle
frequency bands
33
34. Channel Partitioning: CDMA
• Used mostly in wireless broadcast channels
– cellular, satellite, etc
• CDMA: Code Division Multiple Access)
– All users share same frequency, but
– each user has own “chipping” sequence (code) to encode data
– Allows multiple users to transmit simultaneously with minimal
interference
• Encoding:
– signal = (original data) X (chipping sequence)
• Decoding:
– inner-product of encoded signal and chipping sequence
34
37. Random Access Protocols
• When node has packet to send:
– Transmits at full channel data rate R
– with no a priori coordination among nodes
• Two or more transmitting nodes collision
• Random access MAC protocol specifies:
– How to detect collisions
– How to recover from collisions
• e.g., via delayed retransmissions
• Examples of random access MAC protocols:
– Slotted ALOHA
– ALOHA
– CSMA, CSMA/CD, CSMA/CA
37
38. Slotted ALOHA (1)
Operation
Assumptions • When node obtains fresh
• All frames same size frame, it transmits in next
• Time is divided into equal slot
size slots == time to • No collision node can
transmit 1 frame send new frame in next
• Nodes start to transmit slot
frames only at beginning of
slots • Collision, node retransmits
frame in each subsequent
• Nodes are synchronized
slot with probability p until
• If 2 or more nodes transmit
success
in slot, all nodes detect
collision
38
39. Slotted ALOHA (2)
Pros Cons
• Single active node can • Collisions wasted slots
continuously transmit at full • Idle slots
rate of channel
• Nodes may be able to detect
• Decentralized:
collision in less than time to
– only slots in nodes need to be
in sync transmit packet
• Simple
39
40. Slotted ALOHA Efficiency
Efficiency:long-run • Max efficiency:
fraction of successful Find p* that maximizes
slots given many nodes
Np(1-p)N-1
with many frames to send
• For many nodes:
Analysis:
• Suppose N nodes with many
frames to send, each transmits in
lim Np * 1 p * 1 / e
N
slot with probability p
• Probability that 1st node has
success in a slot:
p(1-p)N-1 At best: channel used
At
• Probability that any node has a
success for useful transmissions
Np(1-p)N-1 ~37% of time!
40
41. Pure (Unslotted) ALOHA
• Same as slotted but no synchronization:
– When frame first arrives transmit immediately
Collision probability increases!
Efficiency = 1/(2e)
41
42. CSMA: Carrier Sense Multiple Access
• CSMA:
– Listen before transmit:
• If channel sensed idle: transmit entire frame
• If channel sensed busy, defer transmission
• Human analogy
– Don’t interrupt others!
42
43. CSMA Collisions
• Collisions can still occur:
– propagation delay means
two nodes may not hear each
other’s transmission
• On collision:
– entire packet transmission
time wasted
• Collision probability
– depends on propagation
delay
43
44. CSMA/CD (Collision Detection)
• CSMA/CD: Carrier sensing, deferral as in CSMA
– Collisions detected within short time
– Colliding transmissions aborted
• Collision detection:
– On wired LANs:
• measure signal strengths,
• compare transmitted & received signals
– On wireless LANs:
• receiver shut off while transmitting
• Human analogy:
– the polite conversationalist
44
46. Turn-Taking MAC Protocols
• Channel partitioning:
– High load efficiently and fair
– Low load inefficient
• 1/N bandwidth allocated even if only 1 active node!
• Random access:
– Low load efficient
• single node can fully utilize channel
– High load inefficient
• collision overhead
• Turn-taking protocols:
Look for best of both worlds!
46
47. “Taking Turns” MAC protocols
Polling: Token passing:
• Designated “master” Control token passed from
node one node to next sequentially.
• Master node invites Concerns:
“slave” nodes to Token overhead
transmit
Latency
– Round robin
Single point of failure (token)
– Max frames
• Concerns:
– Polling overhead
– Latency
– Single point of failure
47
48. Summary of MAC Protocols
• Sharing of shared media:
– Channel (static) partitioning
• by time, frequency, code
• TDMA, FDMA, CDMA
– Random (dynamic) partitioning
• carrier sensing: collision detection
• easy in wire technologies,harder in wireless
• ALOHA, S-ALOHA, CSMA, CSMA/CD
• CSMA/CD used in Ethernet
– Turn-Taking
• polling from a central site
• token passing
48