data link layer - tu berlin · rnetwork-layer address rused to get datagram to destination network...

31
Data link layer Goals: r Principles behind data link layer services m Error detection, correction m Sharing a broadcast channel: Multiple access m Link layer addressing m Reliable data transfer, flow control: Done! r Example link layer technology: Ethernet

Upload: others

Post on 14-Aug-2020

7 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Data link layer - TU Berlin · rNetwork-layer address rUsed to get datagram to destination network (recall IP network definition) MAC (or LAN or physical or Ethernet) address: rData

Data link layer

Goals:r Principles behind data link layer services

m Error detection, correctionm Sharing a broadcast channel: Multiple accessm Link layer addressingm Reliable data transfer, flow control: Done!

r Example link layer technology: Ethernet

Page 2: Data link layer - TU Berlin · rNetwork-layer address rUsed to get datagram to destination network (recall IP network definition) MAC (or LAN or physical or Ethernet) address: rData

Link layer services

Framing and link accessm Encapsulate datagram: Frame adds header, trailerm Channel access – if shared mediumm Frame headers use ‘physical addresses’ = “MAC”

to identify source and destination• Different from IP address!

Reliable delivery (between adjacent nodes)m Seldom used on low bit error links

(fiber optic, co-axial cable and some twisted pairs) m Sometimes used on high error rate links

(e.g., wireless links)

Page 3: Data link layer - TU Berlin · rNetwork-layer address rUsed to get datagram to destination network (recall IP network definition) MAC (or LAN or physical or Ethernet) address: rData

Link layer services (2.)

Flow Controlm Pacing between sending and receiving nodes

Error Detectionm Errors are caused by signal attenuation and noise. m Receiver detects presence of errors

signals sender for retrans. or drops frame

Error Correctionm Receiver identifies and corrects bit error(s) without

resorting to retransmission

Half-duplex and full-duplexm With half duplex, nodes at both ends of link can

transmit, but not at same time

Page 4: Data link layer - TU Berlin · rNetwork-layer address rUsed to get datagram to destination network (recall IP network definition) MAC (or LAN or physical or Ethernet) address: rData

Multiple access links / protocolsTwo types of “links”:r Point-to-point

m PPP for dial-up accessm Point-to-point link between Ethernet switch and host

r Broadcast (shared wire or medium)m Traditional Ethernetm Upstream HFCm 802.11 wireless LAN

Page 5: Data link layer - TU Berlin · rNetwork-layer address rUsed to get datagram to destination network (recall IP network definition) MAC (or LAN or physical or Ethernet) address: rData

MAC protocols: Three broad classes

r Channel Partitioningm Divide channel into smaller “pieces”

(time slots, frequency)m Allocate piece to node for exclusive use

r Random Accessm Allow collisionsm “Recover” from collisions

r “Taking turns”m Tightly coordinate shared access to avoid collisions

Goal: Efficient, fair, simple, decentralized

Page 6: Data link layer - TU Berlin · rNetwork-layer address rUsed to get datagram to destination network (recall IP network definition) MAC (or LAN or physical or Ethernet) address: rData

Addresses

IP address (32-bit): r Network-layer addressr Used to get datagram to destination network (recall IP

network definition)

MAC (or LAN or physical or Ethernet) address: r Data link-layer addressr Used to get datagram from one interface to another

physically-connected interface (same network)r 48 bit MAC address (for most LANs)

burned in the adapter ROM

Page 7: Data link layer - TU Berlin · rNetwork-layer address rUsed to get datagram to destination network (recall IP network definition) MAC (or LAN or physical or Ethernet) address: rData

Addresses (2.)Each adapter on LAN has unique LAN address

Broadcast address =FF-FF-FF-FF-FF-FF

= adapter

1A-2F-BB-76-09-AD

58-23-D7-FA-20-B0

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

71-65-F7-2B-08-53

LAN(wired orwireless)

Page 8: Data link layer - TU Berlin · rNetwork-layer address rUsed to get datagram to destination network (recall IP network definition) MAC (or LAN or physical or Ethernet) address: rData

Addresses (3.)

rMAC address allocation administered by IEEErManufacturer buys portion of MAC address space

(to assure uniqueness)r Analogy:mMAC address: Like Social Security Numberm IP address: Like postal address

r MAC flat address ð portability m Can move LAN card from one LAN to another

r IP hierarchical address NOT portablem Depends on network to which one attaches

Page 9: Data link layer - TU Berlin · rNetwork-layer address rUsed to get datagram to destination network (recall IP network definition) MAC (or LAN or physical or Ethernet) address: rData

Example

223.1.1.1

223.1.1.2

223.1.1.3

223.1.1.4 223.1.2.9

223.1.2.2

223.1.2.1

223.1.3.2223.1.3.1

223.1.3.27

A

BE

Starting at A, given IP datagram addressed to B:

r Look up net. address of B, find B on same net. as A

r Link layer send datagram to B inside link-layer frame

B’s MACaddr

A’s MACaddr

A’s IPaddr

B’s IPaddr

IP payload

datagramframe

frame source,dest address

datagram source,dest address

Page 10: Data link layer - TU Berlin · rNetwork-layer address rUsed to get datagram to destination network (recall IP network definition) MAC (or LAN or physical or Ethernet) address: rData

ARP: Address Resolution Protocol

r Each IP node (Host, Router) on LAN has ARP table

r ARP Table: IP/MAC address mappings for some LAN nodes< IP address; MAC address; TTL>

m TTL (Time To Live): time after which address mapping will be forgotten (typically 20 min)

Question: how to determineMAC address of Bknowing B’s IP address?

1A-2F-BB-76-09-AD

58-23-D7-FA-20-B0

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

71-65-F7-2B-08-53

LAN

237.196.7.23

237.196.7.78

237.196.7.14

237.196.7.88

Page 11: Data link layer - TU Berlin · rNetwork-layer address rUsed to get datagram to destination network (recall IP network definition) MAC (or LAN or physical or Ethernet) address: rData

ARP Protocol: Same LAN (Network)

r A wants to send datagram to B, and B’s MAC address not in A’s ARP table.

r A broadcasts ARP query packet, containing B's IP address m Dest MAC address =

FF-FF-FF-FF-FF-FFm All machines on LAN

receive ARP queryr B receives ARP packet,

replies to A with its (B's) MAC addressm Frame sent to A’s MAC

address (unicast)

r A caches (saves) IP-to-MAC address pair in its ARP table until information becomes old (times out) m Soft state: information that

times out (goes away) unless refreshed

r ARP is “plug-and-play”:m Nodes create their ARP

tables without intervention from net administrator

Page 12: Data link layer - TU Berlin · rNetwork-layer address rUsed to get datagram to destination network (recall IP network definition) MAC (or LAN or physical or Ethernet) address: rData

Ethernet

“Dominant” LAN technology: r Cheap $20 for 100Mbs!r First widely used LAN technologyr Simpler, cheaper than token LANs and ATMr Kept up with speed race: 10 Mbps – 10 Gbpsr Shared medium

Metcalfe’s Etheretsketch

Page 13: Data link layer - TU Berlin · rNetwork-layer address rUsed to get datagram to destination network (recall IP network definition) MAC (or LAN or physical or Ethernet) address: rData

Unreliable, connectionless service

r Connectionless:No handshaking between sending and receiving adapter.

r Unreliable:Receiving adapter does not send ACKs or NACKs to sending adapterm Stream of datagrams passed to network layer can have gapsm Gaps will be filled if app is using TCPm Otherwise, app will see the gaps

Page 14: Data link layer - TU Berlin · rNetwork-layer address rUsed to get datagram to destination network (recall IP network definition) MAC (or LAN or physical or Ethernet) address: rData

Ethernet uses CSMA/CD

r No slotsr Adapter does not transmit if

it senses that some other adapter is transmitting, that is: carrier sense

r Transmitting adapter aborts when it senses that another adapter is transmitting, that is: collision detection

r Before attempting a retransmission, adapter waits a random time, that is: random access

Page 15: Data link layer - TU Berlin · rNetwork-layer address rUsed to get datagram to destination network (recall IP network definition) MAC (or LAN or physical or Ethernet) address: rData

Ethernet CSMA/CD algorithm

1. Adaptor receives datagram from net layer & creates frame

2. If adapter senses channel idle, it starts to transmit frame. If it senses channel busy, waits until channel idle and then transmits

3. If adapter transmits entire frame without detecting another transmission, the adapter is done with frame!

4. If adapter detects another transmission while transmitting, aborts and sends jam signal

5. After aborting, adapter enters exponential backoff: After the m-thcollision, adapter chooses aK at random from {0,1,2,…,2m-1}. Adapter waits K · 512 bit times and returns to Step 2

Page 16: Data link layer - TU Berlin · rNetwork-layer address rUsed to get datagram to destination network (recall IP network definition) MAC (or LAN or physical or Ethernet) address: rData

Interconnecting LANs

Q: Why not just one big LAN? r All stations must share bandwidth r Limited cable lengthr Large “collision domain” (can collide with many stations)r Limited number of stations

Page 17: Data link layer - TU Berlin · rNetwork-layer address rUsed to get datagram to destination network (recall IP network definition) MAC (or LAN or physical or Ethernet) address: rData

Interconnecting with hubsr Physical Layer devices:

Essentially repeaters operating at bit levels: Repeat received bits on one interface to all other interfaces

rHubs can be arranged in a hierarchy (or multi-tier design), with backbone hub at its top

hub hub hub

hub

Page 18: Data link layer - TU Berlin · rNetwork-layer address rUsed to get datagram to destination network (recall IP network definition) MAC (or LAN or physical or Ethernet) address: rData

Hubs (2.)

r Each connected LAN referred to as LAN segmentr Hubs do not isolate collision domains: Node may collide

with any node residing at any segment in LAN r Hub Advantagesm Simple, inexpensive devicemMulti-tier provides graceful degradation: portions of

the LAN continue to operate if one hub malfunctionsm Extends maximum distance between node pairs

(100m per Hub)

Page 19: Data link layer - TU Berlin · rNetwork-layer address rUsed to get datagram to destination network (recall IP network definition) MAC (or LAN or physical or Ethernet) address: rData

Bridges (switches)

r Link Layer devicesm Stores and forwards Ethernet framesm Examines frame header and selectively forwards

frame based on MAC dst addressmWhen frame is to be forwarded on segment, uses

CSMA/CD to access segmentð Bridge isolates collision domains: It buffers frames

Page 20: Data link layer - TU Berlin · rNetwork-layer address rUsed to get datagram to destination network (recall IP network definition) MAC (or LAN or physical or Ethernet) address: rData

Bridges/switch: Advantages

rHigher total max throughputr No limit on number of nodes r No limit on geographical coverager Can connect different Ethernet types (store and

forward)r Transparent: Hosts do not need to change LAN

adaptersr Plug-and-play, self-learning

m Switches do not need to be configured

Page 21: Data link layer - TU Berlin · rNetwork-layer address rUsed to get datagram to destination network (recall IP network definition) MAC (or LAN or physical or Ethernet) address: rData

Bridges/switch: Forwarding

r Forwarding: m To which LAN segment should a frame be forwarded?m Looks like a routing problem

hub hubhub

switch

Page 22: Data link layer - TU Berlin · rNetwork-layer address rUsed to get datagram to destination network (recall IP network definition) MAC (or LAN or physical or Ethernet) address: rData

Bridges/switch: Self learning

r A bridge/switch has a bridge/switch tabler Entry in table m (MAC Address, Interface, Time Stamp)m Stale entries in table dropped (TTL can be 60 min)

r Bridge learns which hosts can be reached through which interfacesmWhen frame received, switch “learns” location of

sender: Incoming LAN segmentm Records sender/location pair in bridge table

Page 23: Data link layer - TU Berlin · rNetwork-layer address rUsed to get datagram to destination network (recall IP network definition) MAC (or LAN or physical or Ethernet) address: rData

Bridges/switch: Filtering/forwarding

When switch receives a frame:

Index switch table using MAC dest addressif entry found for destination

then{if dest on segment from which frame arrived

then drop the frameelse forward the frame on interface indicated

}else flood forward on all but the interface

on which the frame arrived

Page 24: Data link layer - TU Berlin · rNetwork-layer address rUsed to get datagram to destination network (recall IP network definition) MAC (or LAN or physical or Ethernet) address: rData

Switch: Traffic isolationr Switch installation breaks subnet into LAN segments

r Switch filters packets:m Same-LAN-segment frames not usually forwarded

onto other LAN segmentsm Segments become separate collision domains

hub hub hub

switch

collision domain collision domain

collision domain

Page 25: Data link layer - TU Berlin · rNetwork-layer address rUsed to get datagram to destination network (recall IP network definition) MAC (or LAN or physical or Ethernet) address: rData

Redundant networks

r Network with multiple paths m Alternate path for each source, destination pair

r Advantagem Increased reliabilitym Single network failure OKmMore opportunities for load distribution

rDisadvantagem Added complexity

Page 26: Data link layer - TU Berlin · rNetwork-layer address rUsed to get datagram to destination network (recall IP network definition) MAC (or LAN or physical or Ethernet) address: rData

Bridges spanning tree

r Avoid cyclesm Frames may multiply and forwarded forever

rOrganize bridges into spanning tree m Disable a subset of interfaces

Disabled

Page 27: Data link layer - TU Berlin · rNetwork-layer address rUsed to get datagram to destination network (recall IP network definition) MAC (or LAN or physical or Ethernet) address: rData

Bridges vs. Routersr Both store-and-forward devices

m Routers: Network layer devices (examine network layer headers)

m Bridges/switches: Link layer devices

r Use tablesm Routers: Routing tables via routing algorithmsm Bridges: Filtering tables via filtering, learning,

spanning tree algorithm

Page 28: Data link layer - TU Berlin · rNetwork-layer address rUsed to get datagram to destination network (recall IP network definition) MAC (or LAN or physical or Ethernet) address: rData

Bridges + and -

+ Simple operationLow processing bandwidth

- Restricted topologies: Spanning tree to avoid cycles

- Single broadcast domainNo protection from broadcast storms(broadcasts will be forwarded by bridge)

Page 29: Data link layer - TU Berlin · rNetwork-layer address rUsed to get datagram to destination network (recall IP network definition) MAC (or LAN or physical or Ethernet) address: rData

Routers + and -

+ Arbitrary topologies Limited cycling (TTL and good routing protocols)

+ Firewalls protection Against broadcast storms

- Complex operationRequire IP address configuration (not plug and play)Require higher processing bandwidth

Page 30: Data link layer - TU Berlin · rNetwork-layer address rUsed to get datagram to destination network (recall IP network definition) MAC (or LAN or physical or Ethernet) address: rData

Routers vs. Bridges

r Bridgesm Good in small networks (few hundred hosts)

r Routersm Good in large networks (thousands of hosts)

r Layer 3 switchm Bridge + router (but usually limited routing table!)

Page 31: Data link layer - TU Berlin · rNetwork-layer address rUsed to get datagram to destination network (recall IP network definition) MAC (or LAN or physical or Ethernet) address: rData

Summary/comparison

hubs routers switches

traffic isolation

no yes yes

plug & play yes no yes

optimal routing

no yes no

cut through

yes no yes