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

9_Data_Link_Layer

Uploaded by

muproductions002
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

9_Data_Link_Layer

Uploaded by

muproductions002
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 42

Data Link Layer

5-1
Link Layer
 Introduction and  Hubs and switches
services
 Error detection and
correction
 Multiple access
protocols
 Link-Layer
Addressing
 Ethernet

5: DataLink Layer 5-2


Link Layer: Introduction “link”
Some terminology:
 hosts and routers are nodes
 communication channels
that connect adjacent nodes
along communication path
are links
 wired links
 wireless links
 LANs
 layer-2 packet is a frame,
encapsulates datagram

data-link layer has responsibility of


transferring datagram from one node
to adjacent node over a link
5: DataLink Layer 5-3
Link Layer Services
 Framing, link access:
 encapsulate datagram into frame, adding header,
trailer
 channel access if shared medium
 “MAC” addresses used in frame headers to identify
source, dest
• different from IP address!
 Reliable delivery between adjacent nodes
 we learned how to do this already
 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 5-4
Link Layer Services (more)
 Flow Control:
 pacing between adjacent sending and receiving nodes

 Error Detection:
 errors caused by signal attenuation, noise.
 receiver detects presence of errors:

• signals sender for retransmission or drops frame


 Error Correction:
 receiver identifies and corrects bit error(s) without
resorting to retransmission
 Half-duplex and full-duplex
 with half duplex, nodes at both ends of link can
transmit, but not at same time
5: DataLink Layer 5-5
Adaptors Communicating
datagram
link layer protocol rcving
sending node
node
frame frame
adapter adapter

 link layer implemented  receiving side


in “adaptor” (NIC)  looks for errors, rdt, flow
 Ethernet card, PCMCI card, control, etc
802.11 card  extracts datagram,
 sending side: passes to rcving node
 encapsulates datagram in
 link & physical layers
a frame
 adds error checking bits,
rdt, flow control, etc.

5: DataLink Layer 5-6


Link Layer
 Introduction and  Hubs and switches
services  PPP
 Error detection and  Link Virtualization:
correction ATM
 Multiple access
protocols
 Link-Layer
Addressing
 Ethernet

5: DataLink Layer 5-7


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

5: DataLink Layer 5-8


Error Detection Schemes
 Parity Bit
 Internet Checksum
 CRC

5: DataLink Layer 5-9


Checksumming: 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!
 can detect all burst errors less than r+1 bits
 widely used in practice (Ethernet, 802.11 WiFi, ATM)

DataLink Layer 10
CRC - Sender
 Steps
 T(x) = M(x) by xk (zero extending)
 Find remainder, R(x), from T(x)/C(x)
 P(x) = T(x) – R(x)  M(x) followed by R(x)
 Example
 M(x) = 10011010 = x7  x4  x3  x
 C(x) = 1101 = x3  x2  1
 T(x) = 10011010000
 R(x) = 101
 P(x) = 10011010101
CRC - Receiver
 Receive Polynomial P(x) + E(x)
 E(x) represents errors
 E(x) = 0, implies no errors

 Divide (P(x) + E(x)) by C(x)


 If result = 0, either
• No errors (E(x) = 0, and P(x) is evenly divisible by
C(x))
• (P(x) + E(x)) is exactly divisible by C(x), error will
not be detected
CRC – Example Encoding

C(x) = x3  x2  1 = 1101 Generator


M(x) = x7  x4  x3  x = 10011010 Message

1101 10011010000 Message plus


1101 k zeros
k + 1 bit 1001
check 1101
sequence c, 1000
equivalent to 1101 Result:
a degree-k 1011
polynomial 1101 Transmit
1100
1101
message
1000 followed by
Remainder 1101 remainder:
m mod c 101
10011010101
CRC – Example Decoding –
No Errors
C(x) = x3  x2  1 = 1101 Generator
P(x) = x10  x7  x6  x4  x2  1 = 10011010101 Received Messa

1101 10011010101 Received


1101 message, no
k + 1 bit 1001 errors
check 1101
sequence c, 1000
equivalent to 1101 Result:
a degree-k 1011
polynomial 1101 CRC test is
1100 passed
1101
1101
Remainder 1101

m mod c 0
CRC – Example Decoding –
with Errors
C(x) = x3  x2  1 = 1101 Generator
P(x) = x10  x7  x5  x4  x2  1 = 10010110101 Received Messa

1101 10010110101 Received


1101 message
k + 1 bit 1000 Two bit errors
check 1101
sequence c, 1011
equivalent to 1101 Result:
a degree-k 1101
polynomial 1101 CRC test failed
0101

Remainder
m mod c
Link Layer
 Introduction and
services
 Error detection and
correction
 Multiple access
protocols
 Link-Layer
Addressing

5: DataLink Layer 5-16


MAC Protocols: a taxonomy
Three broad classes:
 Channel Partitioning
 divide channel into smaller “pieces” (time slots,
frequency, code)
 allocate piece to node for exclusive(limited) 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

5: DataLink Layer 5-17


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

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


one per user; inefficient with low duty cycle users and at light load.
 FDM (Frequency Division Multiplexing): frequency subdivided.

5: DataLink Layer 5-18


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

time
frequency bands

 TDM (Time Division Multiplexing): channel divided into N time slots, one
per user; inefficient with low duty cycle users and at light load.
 FDM (Frequency Division Multiplexing): frequency subdivided.

5: DataLink Layer 5-19


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
5: DataLink Layer 5-20
Pure (unslotted) ALOHA
 unslotted Aloha: simpler, no synchronization
 when frame first arrives
 transmit immediately

5: DataLink Layer 5-21


Slotted ALOHA
Assumptions Operation
 all frames same size  when node obtains fresh
 time is divided into frame, it transmits in
equal size slots, time to next slot
transmit 1 frame  no collision, node can
 nodes start to transmit send new frame in next
frames only at slot
beginning of slots  if collision, node
 nodes are synchronized
retransmits frame in
 if 2 or more nodes each subsequent slot
transmit in slot, all with prob. p until
nodes detect collision success
5: DataLink Layer 5-22
Slotted ALOHA

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

5: DataLink Layer 5-24


CSMA collisions spatial layout of nodes

collisions can still


occur:
propagation delay -
two nodes may not hear
each other’s transmission
collision:
entire packet
transmission
time wasted
note:
role of distance & propagation
delay in determining collision
probability

5: DataLink Layer 5-25


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: receiver shut off while
transmitting

5: DataLink Layer 5-26


CSMA/CD collision detection

5: DataLink Layer 5-27


Ethernet uses CSMA/CD
 No slots  Before attempting a
 adapter doesn’t retransmission,
transmit if it senses adapter waits a
that some other random time, that is,
adapter is transmitting, random access
that is, carrier sense
 transmitting adapter
aborts when it senses
that another adapter is
transmitting, that is,
collision detection

5: DataLink Layer 5-28


Ethernet CSMA/CD algorithm
1. Adaptor receives 4. If adapter detects another
datagram from net layer & transmission while
creates frame transmitting, aborts and
2. If adapter senses channel sends jam signal
idle, it starts to transmit 5. After aborting, adapter
frame. If it senses channel enters exponential
busy, waits until channel backoff: after the mth
idle and then transmits collision, adapter chooses
3. If adapter transmits entire a K at random from
frame without detecting {0,1,2,…,2m-1}. Adapter
another transmission, the waits K·512 bit times and
adapter is done with frame returns to Step 2
!

5: DataLink Layer 5-29


Ethernet’s CSMA/CD (more)
Jam Signal: make sure all Exponential Backoff:
other transmitters are  Goal: adapt retransmission
aware of collision; 48 bits attempts to estimated
Bit time: .1 microsec for 10 current load
 heavy load: random wait
Mbps Ethernet ;
for K=1023, wait time is will be longer
 first collision: choose K
about 50 msec
from {0,1}; delay is K· 512
bit transmission times
 after second collision:
choose K from {0,1,2,3}…
 after ten collisions, choose
K from {0,1,2,3,4,…,1023}

5: DataLink Layer 5-30


“Taking Turns” MAC
protocols
Polling: Token passing:
 master node  control token passed

“invites” slave from one node to next


nodes to transmit sequentially.
in turn  token message
 concerns:  concerns:
 polling overhead  token overhead
 latency  latency
 single point of  single point of failure
failure (master) (token)

5: DataLink Layer 5-31


Summary of MAC protocols
 What do you do with a shared media?
 Channel Partitioning, by time, frequency or
code
• Time 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
• CSMA/CA used in 802.11
 Taking Turns
• polling from a central site, token passing
5: DataLink Layer 5-32
LAN technologies
Data link layer so far:
 services, error detection/correction, multiple
access
Next: LAN technologies
 addressing
 Ethernet
 hubs, switches
 PPP

5: DataLink Layer 5-33


Link Layer
 Introduction and
services
 Error detection and
correction
 Multiple access
protocols
 Link-Layer
Addressing

5: DataLink Layer 5-34


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 frame 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 5-35
ARP Introduction
 low level network protocol
 operates at Layer 2 of the OSI model which
is usually implemented in the device
drivers of network operating systems.
 used by the Internet Protocol (IP),
specifically IPv4, to map IP network
addresses to the hardware addresses used
by a data link protocol.
 ARP packets are one of the most frequent
packets found on a local area network
Operation of ARP
hostname
hostname
resolver (1) FTP
IP addr (2 Establish connection
) with IP address
TCP
(3 Send IP datagram
) to IP address
(4) IP
(5) ARP
(6) (8) (9)
Ethernet driver
ARP request (Ethernet broadcast)

Ethernet driver Ethernet driver

ARP (7)ARP IP

TCP
ARP OPERATION

1. Get IP address of target.


2. Create a request ARP message
– Fill sender physical address
– Fill sender IP address
– Fill target IP address
– Target physical address is filled with 0
3. The message is passed to the data link layer
where it is encapsulated in a frame.
– Source address: physical address of the sender.
– Destination address: broadcast address.
ARP OPERATION

4. Every host or router on the LAN receives the


frame.
– All stations pass it to ARP.
– All machines except the one targeted drop the
packet.
5. The target machine replies with an ARP
message that contains its physical address.
– A unicast message.
6. The sender receives the reply message and
knows the physical address of the target
machine.
LAN Addresses and ARP
Each adapter on LAN has unique LAN address

1A-2F-BB-76-09-AD Broadcast address =


FF-FF-FF-FF-FF-FF

LAN
(wired or = adapter
wireless)
71-65-F7-2B-08-53
58-23-D7-FA-20-B0

0C-C4-11-6F-E3-98

5: DataLink Layer 5-40


Routing to another LAN
walkthrough: send datagram from A to B via R
assume A know’s B IP address

R
 Two ARP tables in router R, one for each IP network (LAN)
B
 In routing table at source Host, find router 111.111.111.110
 In ARP table at source, find MAC address E6-E9-00-17-BB-4B, etc

5: DataLink Layer 5-41


 A creates datagram with source A, destination B
 A uses ARP to get R’s MAC address for 111.111.111.110
 A creates link-layer frame with R's MAC address as dest,
frame contains A-to-B IP datagram
 A’s adapter sends frame
 R’s adapter receives frame
 R removes IP datagram from Ethernet frame, sees its
destined to B
 R uses ARP to get B’s MAC address
 R creates frame containing A-to-B IP datagram sends to B

R
B

5: DataLink Layer 5-42

You might also like