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

Lecture-2012-15 - Datalink-Layer - Part 1

Uploaded by

Luan Ruçi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
113 views

Lecture-2012-15 - Datalink-Layer - Part 1

Uploaded by

Luan Ruçi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 49

Chapter 5: The Data Link

Layer
Our goals: Overview:
 understand principles  link layer services
behind data link layer  error detection, correction
services:
 multiple access protocols
 error detection,
correction and LANs
 sharing a broadcast  link layer addressing, ARP
channel: multiple access  specific link layer
 link layer addressing technologies:
 reliable data transfer,  Ethernet
flow control: done!
 hubs, bridges, switches
 instantiation and
 IEEE 802.11 LANs
implementation of
various link layer
 PPP
technologies

5: DataLink Layer 1
Link Layer: setting the context
Different link-layer protocols on the
different links in the path
• Ethernet
Node: Host/Router
• Link-layer WAN protocol
• PPP

Network Layer: End-to-End job of moving transport-layer segments from source host to
destination host
Link-Layer Protocol: Node-to-Node job of moving network-layer datagrams over a single-
2
link in the path 5: DataLink Layer
Link Layer: setting the context
 two physically connected devices:
 host-router, router-router, host-host

 unit of data: frame

M application
Ht M transport
Hn Ht M network data link network
protocol
Hl Hn Ht M link link Hl Hn Ht M
physical physical frame
phys. link

adapter card
5: DataLink Layer 3
Link Layer Services Parallels transport layer
services
 Framing, link access:
 encapsulate datagram into frame, adding header, trailer
 implement channel access if shared medium,
 ‘physical addresses’ used in frame headers to identify
source, destination
Catch the error on the link
• different from IP address! where it occurs
 Reliable delivery between two physically
connected devices: Mechanisms: Seq.Nos,
 we learned how to do this already (chapter 3)! Timers, ACKs
 seldom used on low bit error link (fiber, some twisted
pair)
 wireless links: high error rates
• Q: why both link-level and end-end reliability?

5: DataLink Layer 4
Link Layer Services (more)
 Flow Control:
 pacing between sender and receivers
 Error Detection: More sophisticated; hardware-implemented
 errors caused by signal attenuation &
electromagnetic noise.
 Sender sets error-detection bits in the
frame; receiver detects presence of errors:
• signals sender for retransmission or drops frame
 Error Correction:
 receiveridentifies and corrects bit error(s)
without resorting to retransmission

5: DataLink Layer 5
Link Layer: Implementation
Network Interface Card
 implemented in adapter (NIC)
 e.g., PCMCIA card, Ethernet card
 typically includes: RAM, DSP chips, host bus
interface, and link interface

M application
Ht M transport
Hn Ht M network data link network
protocol
Hl Hn Ht M link link Hl Hn Ht M
physical physical frame
phys. link

adapter card 6
5: DataLink Layer
Error Detection
EDC= Error Detection and Correction bits (redundancy)
D = Data protected by error checking, may include header
fields

• Error detection not 100% reliable!


• protocol may miss some errors, but rarely
• larger EDC field yields better detection and correction,
but incurs larger overhead

5: DataLink Layer 7
Immediate error
correction at the receiver
Parity Checking (Forward Error
Correction) or FEC

Single Bit Parity: Two Dimensional Bit Parity:


Detect single bit Detect and correct single bit errors
errors

Even Parity Scheme


Odd Parity Scheme

Commonly used in 0 0
Audio storage &
playback devices

5: DataLink Layer 8
Software-implemented; requires
relatively little packet overhead but
Internet checksum weaker protection against errors as
compared to CRC

Goal: detect errors (e.g., flipped bits) in


transmitted segment (note: used at transport
layer only)
Sender: Receiver:
 treat segment contents  compute checksum of
as sequence of 16-bit received segment
integers  check if computed
 checksum: 1's checksum equals
complement of the sum checksum field value:
of segment contents  NO - error detected
 sender puts checksum  YES - no error detected.
value into UDP But maybe errors
checksum field nonetheless? More later
….
TCP & UDP computes Internet checksum over all fields 9
5: DataLink Layer
Check summing: Cyclic Redundancy
Check
Based on CRC codes, also known as polynomial codes
 view data bits, D, as a binary number
 choose r+1 bit pattern (generator), G with leftmost
bit=1
 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!
 can detect all burst errors less than r+1 bits
 widely used in practice (ATM, HDCL)

Multiplication by 2k is the same as bitpattern << k


5: DataLink Layer 10
Given: D=101110, d=6, G=1001, r=3
CRC Example Output: transmitted=101110011

Done in modulo-2 arithmetic without carries in addition or borrows in subtraction (XOR)

1011
0101
1110
Want:
D.2r XOR R = nG
equivalently:
D.2r = nG XOR R
equivalently:
if we divide D.2r by
G, want reminder R

D
R = remainder[
.2r
]
G We are interested only in the
remainder. 11
5: DataLink Layer
END OF SESSION

5: DataLink Layer 12
Multiple Access Links and Protocols

Two types of network links:


 Point-to-point link (single wire, e.g. PPP,
SLIP)
 Broadcast link (shared wire or wireless
medium; e.g, Ethernet, Wavelan, etc.)

5: DataLink Layer 13
Multiple Access protocols (MAC)
Regulates node transmission over shared broadcast channel
 single shared communication channel
 two or more simultaneous transmissions by nodes:
interference
 only one node can send successfully at a time
 multiple access protocol:
 distributed algorithm that determines how stations share
channel, i.e., determines when the station can transmit
 communication about channel sharing must use channel
itself!
 what to look for in multiple access protocols:

• synchronous or asynchronous
• information needed about other stations
• robustness (e.g., to channel errors)
• performance 14
5: DataLink Layer
MAC Protocols: a taxonomy
Three broad classes:
 Channel Partitioning Protocols
 divide channel into smaller pieces (time slots,
frequency bands, multiple access codes)
 allocate piece to node for exclusive use
 Random Access Protocols
 allowcollisions
 recover from collisions
 Taking turns Protocols
 tightly coordinate shared access to avoid collisions

Animation
5: DataLink Layer 15
MAC Protocols
Goal: efficient, fair, simple, decentralized

DESIRABLE CHARACTERISTICS
For a broadcast channel of R bps:
• For only one sending node: throughput = R bps
• For M sending nodes: throughput = R/M bps
-not instantaneous transmission rate, but average transmission rate of
R/M bps over some suitably defined time interval

• Decentralized
• Simple, inexpensive to implement
5: DataLink Layer 16
Channel Partitioning MAC protocols:
TDMA
Divide time into Frames, and
TDMA: Time Division Multiple Access further divide Frames into N time
 access to channel in rounds slots
 each station gets fixed length slot (length = pkt trans
time) in each round
 Drawback: unused slots go idle
 example: 6-station LAN, 1,3,4 have pkt, slots 2,5,6 idle

 TDM (Time Division Multiplexing): channel divided into N


time slots, one per user
 Advantages: eliminates collision; perfectly fair; dedicated
transmission rate of R/N
 Disadvantage: inefficient with low duty cycle users and at
light load.

5: DataLink Layer 17
See more slides
Channel Partitioning MAC protocols:
FDMA: Frequency Division Multiple Access

channel spectrum divided into frequency bands


 each station assigned fixed frequency band
 Drawback:
 Unused transmission time in frequency bands go idle
 Node is limited to a bandwidth of R/N, even when all the other nodes
are idle at the time
 example: 6-station LAN, 1,3,4 have pkt, frequency bands 2,5,6 idle
 FDM (Frequency Division Multiplexing): frequency subdivided.
time
frequency bands

Divide channel of R bps


into different Frequencies See more slides
(each with R/N), and assign
each Frequency to one of the
nodes N

5: DataLink Layer 18
TDM & FDM
Suppose that a channel supports N nodes, with transmission rate of R
bps

DRAWBACKS
• A NODE is limited to a bandwidth of R/N when it is the only node
with packets to send

• (Only for TDM) A NODE must always wait for its turn in the
transmission sequence, even when it is the only node with a packet to
send

5: DataLink Layer 19
Random Access protocols
 When node has packet to send
 transmit at full rate (R) of channel
 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 and CSMA/CD
5: DataLink Layer 20
CSMA:
(Carrier Sense Multiple Access)
CSMA: listen before transmit:
 If channel sensed idle: transmit entire pkt
 If channel sensed busy, defer transmission
 Persistent CSMA: retry immediately with probability p
when channel becomes idle (may cause instability)
 Non-persistent CSMA: retry after random time interval
 human analogy: don't interrupt others!

RULES:
•Listen before speaking (carrier sensing)
Animation • If someone else begins talking at the same
time, stop talking (collision detection)
5: DataLink Layer 21
Channel propagation
CSMA collisions delay
4 nodes attached to a linear broadcast
spatial layout of nodes along ethernet
bus; Horizontal axis shows position of
each node in space

collisions can
occur:
propagation delay
means
two nodes may not
yet
collision:
hear each other's
entire packet
transmission
transmission
time wasted D senses the channel is
idle at t1
note:
role of distance and
propagation delay in
determining collision
prob.
5: DataLink Layer 22
CSMA/CD (Collision Detection)
CSMA/CD: carrier sensing, deferral as in CSMA
 collisions detected within short time
 colliding transmissions aborted, reducing
channel wastage
 persistent or non-persistent retransmission

 collision detection:
 easy in wired LANs: measure signal strengths,
compare transmitted, received signals
 difficult in wireless LANs: receiver shut off while
transmitting
 human analogy: the polite conversation

5: DataLink Layer 23
CSMA/CD collision detection

4 nodes attached to a
linear broadcast bus

5: DataLink Layer 24
Slotted Aloha

 time is divided into equal sized slots (= pkt trans.


time)
 node with new arriving pkt: transmit at beginning
of next slot
 if collision: retransmit pkt in future slots with
probability p, until successful.

Success (S), Collision (C), Empty (E)


slots 25
5: DataLink Layer
Slotted Aloha efficiency
Q: what is max fraction of slots that
are successful?
A: Suppose N stations have packets to
send
 each transmits in slot with probability p
 prob. successful transmission S is:

At its best: channel


by single node: S= p (1-p) (N-1)
use for successful
by any of N nodes transmissions is 37%
of the time!
S = Prob (only one transmits)
= N p (1-p)(N-1)
… choosing optimum
Find p that maximizes p as n -> infinity ...
the expression

Maximum Efficiency of Protocol


= 1/e = .37 as N -> infinity 5: DataLink Layer 26
e.g. For a network with 100 Mbps Slotted ALOHA system, the successful throughput < 37Mbps.
Slotted ALOHA

Pros Cons
• single active node can • collisions, wasting slots
continuously transmit at • idle slots
full rate of channel • nodes may not be able to
• highly decentralized: only detect collision in less
slots in nodes need to be than time to transmit
packet
in sync
• clock synchronization
• simple
5: DataLink Layer 27
Pure (unslotted) ALOHA
FULLY DECENTRALIZED PROTOCOL
 unslotted Aloha: simpler, no synchronization
 If pkt needs transmission:
 sends immediately without waiting for the beginning
of slot
 If there’s a collision after transmission:
 Retransmit frame with probability p

Else Wait for next transmission time


 Collision probability increases:
 pkt sent at t collide with other pkts sent in [t -1,
0 0
t0+1]

5: DataLink Layer 28
Pure Aloha (cont.)
P(success by given node) = P(node transmits a frame) .
P(no other node transmits in [t0-
1,t0] .
P(no other node transmits in [t0,
t0+1]
= p . (1-p)(N-1) . (1-p)(N-1)
P(success by any of N nodes) = N p . (1-p) 2(N-1)
0.4
… choosing optimum p as n -> infinity ...
S = throughput =

(success rate)

0.3 = 1/(2e) = .18 protocol constrains


Slotted Aloha
0.2 effective channel
“goodput”

throughput!
0.1
Pure Aloha

0.5 1.0 1.5 2.0


G = offered load = Np
5: DataLink Layer 29
Channel Partitioning (CDMA)

CDMA (Code Division Multiple Access)


 Sender: sends encoded data bits simultaneously
 Receiver: assigned a unique code (i.e. code set
partitioning)
 Has been used by military; now used mostly in wireless
broadcast channels (cellular, satellite,etc)
 all users share same frequency, but each user has own
''chipping'' sequence (i.e., code) to encode data
 encoded signal = (original data) X (chipping sequence)
 decoding: inner-product of encoded signal and chipping
sequence
 Advantage: allows multiple users to coexist and
transmit simultaneously with minimal interference (if
codes are orthogonal)
5: DataLink Layer 30
CDMA Encode/Decode

M mini slots
are assigned
to each data
bit

5: DataLink Layer 31
CDMA: two-sender interference

Assumption: interfering
bit signals are additive

5: DataLink Layer 32
Taking Turns MAC protocols

channel partitioning MAC protocols:


 share channel efficiently at high load
 inefficient at low load: delay in channel
access, R/N bandwidth allocated even if only
1 active node!
Random access MAC protocols
 efficient at low load: single node can fully
utilize channel
 high load: collision overhead

taking turns protocols


look for best of both worlds!
5: DataLink Layer 33
Taking Turns MAC protocols
Polling: Token passing:
 master node  control token passed

invites slave nodes from one node to next


to transmit in turn sequentially.
 Request to Send,  token message

Clear to Send  concerns:


msgs  token overhead
 concerns:  latency
 polling overhead
 single point of failure
(token)
 latency
 single point of e.g. FDDI, IEEE 802.5
failure (master)
Animation
5: DataLink Layer 34
Reservation-based protocols
Distributed Polling:
 time divided into slots
 begins with N short reservation slots
 reservation slot time equal to channel end-end
propagation delay
 station with message to send posts reservation
 reservation seen by all stations
 after slot reservation, message transmissions are ordered

by known priority
 Nodes can transmit only up to a max number of frames

5: DataLink Layer 35
Summary of MAC protocols

 What do you do with a shared media?


 Channel Partitioning, by time, frequency or
code
• Time Division,Code Division, Frequency Division
 Random partitioning (dynamic),
• ALOHA, S-ALOHA, CSMA, CSMA/CD
• carrier sensing: easy in some technologies (wire),
hard in others (wireless)
• CSMA/CD used in Ethernet
 Taking Turns
• polling from a central site, token passing

5: DataLink Layer 36
END OF SESSION

5: DataLink Layer 37
LAN technologies
Data link layer so far:
 services, error detection/correction, multiple
access
Next: LAN technologies
 addressing
 Ethernet
 hubs,bridges, switches
 802.11

5: DataLink Layer 38
LAN Addresses and ARP
Recall
32-bit IP address:
 network-layer address
 used to get datagram to destination network
(recall IP network definition)
LAN or Media Access Control (MAC) or
physical address:
 used to get datagram from one interface to
another physically-connected interface (same
network)
 48 bit MAC address (for most LANs)
burned in the adapter ROM
5: DataLink Layer 39
LAN Addresses and ARP
Each adapter on LAN has unique LAN address

5: DataLink Layer 40
LAN Address (more)
 MAC address allocation administered by IEEE
 manufacturer buys portion of MAC address
space (to assure uniqueness)
 Analogy:
(a) MAC address: like Social Security
Number
(b) IP address: like postal address
 MAC flat address => portability
 can move LAN card from one LAN to another
 IP hierarchical address NOT portable
 depends on network to which one attach to

5: DataLink Layer 41
Recall earlier routing discussion
Starting at A, given IP A 223.1.1.1
datagram addressed to
223.1.2.1
B: 223.1.1.2
 look up net. address of B, 223.1.1.4 223.1.2.9
B
find B on same net. as A 223.1.2.2
 link layer send datagram to B
223.1.1.3 223.1.3.27 E

inside link-layer frame 223.1.3.1 223.1.3.2

frame source, dest


address datagram source, dest address

A’s MAC B’s MAC A’s IP B’s IP


IP payload
addr addr addr addr

datagram
frame
5: DataLink Layer 42
ARP:
Address Resolution Protocol
Question: how to determine  Each IP node (Host,
MAC address of B Router) on LAN has an
given B's IP address? ARP module, table
 ARP Table: IP/MAC
address mappings for
some LAN nodes
< IP address; MAC address;
TTL>
< ………………………….. >
 TTL (Time To Live): time
after which address
mapping will be
forgotten (typically 20
min)
We have an example later Layer
5: DataLink 43
ARP protocol
We have an example later
 A knows B's IP address, wants to learn physical
address of B
 A broadcasts ARP query pkt, containing B's IP
address
 all machines on LAN receive ARP query
 B receives ARP packet, replies to A with its
(B's) physical layer address
 A caches (saves) IP-to-physical address pairs
until information becomes old (times out)
 soft state: information that times out (goes
away) unless refreshed

5: DataLink Layer 44
Routing to another LAN
routing from A to B via R

 In the routing table at source Host, A finds router


111.111.111.110
 In ARP table at source, find MAC address E6-E9-00-17-BB-
4B, etc

R
B

5: DataLink Layer 45
 A creates IP packet with source A, destination B
 A uses ARP to get R's physical layer address for
111.111.111.110
 A creates Ethernet frame with R's physical address as
dest, Ethernet frame contains A-to-B IP datagram
 A's data link layer sends Ethernet frame
 R's data link layer receives Ethernet frame
 R removes IP datagram from Ethernet frame, sees its
destined to B
 R uses ARP to get B's physical layer address
 R creates frame containing A-to-B IP datagram sends to B

R
B
5: DataLink Layer 46
DHCP: Dynamic Host Configuration
Protocol
Goal: allow host to dynamically obtain its IP address from
network server when it joins network
Can renew its lease on address in use
Allows reuse of addresses (only hold address while connected and “on”
Support for mobile users who want to join network (more shortly)
DHCP overview:
 host broadcasts “DHCP discover” msg
 DHCP server responds with “DHCP offer” msg
 host requests IP address: “DHCP request” msg
 DHCP server sends address: “DHCP ack” msg

5: DataLink Layer 47
DHCP client-server scenario

A DHCP 223.1.2.1
223.1.1.1
server
223.1.1.2
223.1.1.4 223.1.2.9
B
223.1.2.2 arriving DHCP
223.1.1.3 223.1.3.27 E client needs
address in this
223.1.3.1 223.1.3.2
network

5: DataLink Layer 48
DHCP client-server scenario
DHCP server: 223.1.2.5 arriving
DHCP discover
client
src : 0.0.0.0, 68
dest.: 255.255.255.255,67
yiaddr: 0.0.0.0
transaction ID: 654

DHCP offer
src: 223.1.2.5, 67
dest: 255.255.255.255, 68
yiaddrr: 223.1.2.4
transaction ID: 654
Lifetime: 3600 secs
DHCP request
src: 0.0.0.0, 68
dest:: 255.255.255.255, 67
yiaddrr: 223.1.2.4
transaction ID: 655
time Lifetime: 3600 secs

DHCP ACK
src: 223.1.2.5, 67
dest: 255.255.255.255, 68
yiaddrr: 223.1.2.4
transaction ID: 655
Lifetime: 3600 secs

5: DataLink Layer 49

You might also like