You are on page 1of 33

Link layer

Link Layer 5-1


Multiple access links, protocols
two types of “links”:
 point-to-point
 PPP for dial-up access
 point-to-point link between Ethernet switch, host
 broadcast (shared wire or medium)
 old-fashioned Ethernet
 upstream HFC
 802.11 wireless LAN

shared wire (e.g., shared RF shared RF humans at a


cabled Ethernet) (e.g., 802.11 WiFi) (satellite) cocktail party
(shared air, acoustical)

Link Layer 5-2


Multiple access protocols
 single shared broadcast channel
 two or more simultaneous transmissions by nodes:
interference
 collision if node receives two or more signals at the same
time

multiple access protocol


 distributed algorithm that determines how nodes share
channel, i.e., determine when node can transmit
 communication about channel sharing must use channel itself!
 no out-of-band channel for coordination

Link Layer 5-3


An ideal multiple access protocol
given: broadcast channel of rate R bps

1. when one node wants to transmit, it can send at rate R.


2. when M nodes want to transmit, each can send at average
rate R/M
3. fully decentralized:
• no special node to coordinate transmissions
• no synchronization of clocks, slots
4. simple

Link Layer 5-4


MAC protocols: taxonomy
three broad classes:
 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
 “recover” from collisions
 “taking turns”
 nodes take turns, but nodes with more to send can take longer
turns

Link Layer 5-5


Channel partitioning MAC protocols: TDMA
TDMA: time division multiple access
 access to channel in "rounds"
 each station gets fixed length slot (length = pkt
trans time) in each round
 unused slots go idle
 example: 6-station LAN, 1,3,4 have pkt, slots
2,5,6 idle

6-slot 6-slot
frame frame
1 3 4 1 3 4

Link Layer 5-6


Channel partitioning MAC protocols: 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

FDM cable

Link Layer 5-7


Random access protocols
 when node has packet to send
 transmit at full channel data rate R.
 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

Link Layer 5-8


Slotted ALOHA
assumptions: operation:
 all frames same size  when node obtains fresh
 time divided into equal size frame, transmits in next slot
slots (time to transmit 1  if no collision: node can send
frame) new frame in next slot
 nodes start to transmit  if collision: node retransmits
only slot beginning frame in each subsequent
 nodes are synchronized slot with prob. p until
 if 2 or more nodes transmit success
in slot, all nodes detect
collision

Link Layer 5-9


Slotted ALOHA
node 1 1 1 1 1

node 2 2 2 2

node 3 3 3 3

C E C S E C E S S

Pros: Cons:
 single active node can  collisions, wasting slots
continuously transmit at  idle slots
full rate of channel
 nodes may be able to
 highly decentralized: only detect collision in less
slots in nodes need to be
in sync than time to transmit
packet
 simple
 clock synchronization
Link Layer 5-10
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!

Link Layer 5-11


CSMA collisions spatial layout of nodes

 collisions can still occur:


propagation delay means
two nodes may not hear
each other’s
transmission
 collision: entire packet
transmission time
wasted
 distance & propagation
delay play role in in
determining collision
probability

Link Layer 5-12


CSMA/CD (collision detection)
CSMA/CD: carrier sensing, deferral as in CSMA
 collisions detected within short time
 colliding transmissions aborted, reducing channel wastage
 collision detection:
 easy in wired LANs: measure signal strengths, compare
transmitted, received signals
 difficult in wireless LANs: received signal strength
overwhelmed by local transmission strength
 human analogy: the polite conversationalist

Link Layer 5-13


CSMA/CD (collision detection)
spatial layout of nodes

Link Layer 5-14


CSMA/CD efficiency
 Tprop = max prop delay between 2 nodes in LAN
 ttrans = time to transmit max-size frame

1
efficiency 
1  5t prop /ttrans
 efficiency goes to 1
 as tprop goes to 0
 as ttrans goes to infinity
 better performance than ALOHA: and simple, cheap,
decentralized!

Link Layer 5-15


“Taking turns” MAC protocols
channel partitioning MAC protocols:
 share channel efficiently and fairly at high load
 inefficient at low load: delay in channel access, 1/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!

Link Layer 5-16


“Taking turns” MAC protocols
polling:
 master node “invites”
slave nodes to transmit data
in turn poll
 typically used with
“dumb” slave devices master
data

slaves

Link Layer 5-17


“Taking turns” MAC protocols
token passing:
T
 control token passed
from one node to next
sequentially.
 token message (nothing
 concerns: to send)
 token overhead T
 latency
 single point of failure
(token)

data
Link Layer 5-18
Ethernet switch
 link-layer device: takes an active role
 store, forward Ethernet frames
 examine incoming frame’s MAC address,
selectively forward frame to one-or-more
outgoing links when frame is to be forwarded on
segment, uses CSMA/CD to access segment
 transparent
 hosts are unaware of presence of switches
 plug-and-play, self-learning
 switches do not need to be configured

Link Layer 5-19


Switch forwarding table

Q: how does switch know A’ A


reachable via interface 4, B’ B
reachable via interface 5? C’

 A: each switch has a switch 6 1 2


table, each entry:
5 4 3
 (MAC address of host, interface to
reach host, time stamp) B’ C

 looks like a routing table!


A’
Q: how are entries created, switch with six interfaces
maintained in switch table? (1,2,3,4,5,6)
 something like a routing protocol?

Link Layer 5-20


Switches vs. routers
application
transport
both are store-and-forward:
datagram network
 routers: network-layer frame link
devices (examine network- physical link frame
layer headers) physical
 switches: link-layer devices
(examine link-layer switch
headers)
network datagram
both have forwarding tables: link frame
physical
 routers: compute tables
using routing algorithms, IP application
addresses transport
 switches: learn forwarding network
table using flooding, link
learning, MAC addresses physical

Link Layer 5-21


MAC Addresses and ARP
 32-bit IP address:
 network-layer address
 used to get datagram to destination IP subnet
 MAC (or LAN or physical or Ethernet) 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
 Why do we need both MAC and IP addresses?
 It then allows the machines you have physically connected at home to
also logically connect to computers on the internet. Again,
this is simplified, but is easier to understand. So again, IP Addresses
are logical and route-able addresses. ... And that's why
computers have both MAC Addresses and IP Addresses.
Analogy
 In company, each person has a company-wide ID
number (like IP address)
 In company, person also has a local office number
in a building
 Paychecks are made out to ID numbers
 For delivery, also need to know office number
Address Resolution
 Problem
 Router knows that destination host is on its subnet
based on the IP address of an arriving packet
 Does not know the destination host’s subnet
address, so cannot deliver the packet across the
subnet

Destination Host
128.171.17.13
Subnet
subnet address?
Address Resolution Protocol
(ARP)
 Router creates an ARP Request message to be
sent to all hosts on the subnet.
 Address resolution protocol message asks “Who
has IP address 128.171.17.13?”
 Passes ARP request to data link layer process for
delivery

Subnet

ARP Request
Address Resolution Protocol
(ARP)
 Data link process of router broadcasts the ARP
Request message to all hosts on the subnet.
 On a LAN, MAC address of 48 ones tells all stations
to pay attention to the frame

Subnet

ARP Request
Address Resolution Protocol
(ARP)
 Host with IP address 128.171.17.13 responds
 Internet process creates an ARP response message
 Contains the destination host’s subnet address (48-
bit MAC address on a LAN)

ARP Response

Subnet
Address Resolution Protocol
(ARP)
 Router delivers the IP packet to the destination
host
 Places the IP packet in the subnet frame
 Puts the destination host’s subnet address in the
destination address field of the frame

Deliver IP Packet
within a subnet frame

Subnet
Address Resolution Protocol
 ARP Requests and Responses are sent between
the internet layer processes on the router and
the destination host

ARP
Router Request Destination Host

Internet Internet
Process Process
ARP
Response
Address Resolution Protocol
 However, the data link processes deliver these
ARP packets
 Router broadcasts the ARP Request
 Destination host sends ARP response to the
subnet source address found in the broadcast
frame

Router Destination Host

Internet Internet
Process Broadcast ARP Request Process

Data Link Data Link


Process Process
Direct ARP Response
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 IP subnet to which node is attached
ARP: Address Resolution Protocol

Question: how to determine  Each IP node (Host,


MAC address of B Router) on LAN has
knowing B’s IP address? ARP table
 ARP Table: IP/MAC
237.196.7.78
address mappings for
1A-2F-BB-76-09-AD
some LAN nodes
237.196.7.23
237.196.7.14
< IP address; MAC address; TTL>
 TTL (Time To Live):
LAN time after which address
71-65-F7-2B-08-53 mapping will be
58-23-D7-FA-20-B0
forgotten (typically 20
min)
0C-C4-11-6F-E3-98
237.196.7.88
ARP protocol: Same LAN (network)

 A wants to send datagram to B,


and B’s MAC address not in A’s  A caches (saves) IP-to-MAC
ARP table. address pair in its ARP table
 A broadcasts ARP query until information becomes
packet, containing B's IP old (times out)
address  soft state:
 Dest MAC address = information that
FF-FF-FF-FF-FF-FF times out (goes
 all machines on LAN away) unless
receive ARP query refreshed
 B receives ARP packet, replies  ARP is “plug-and-
to A with its (B's) MAC play”:
address
 frame sent to A’s MAC  nodes create their
address (unicast) ARP tables without
intervention from
net administrator

You might also like