- ShareStudies.com

Download Report

Transcript - ShareStudies.com

Link Layer
1
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
Services
• Framing, link access (MAC protocols), addressing (not with IP)
• Reliable delivery between adjacent nodes (RDT can be on Link layer)
Especially for high error rates (wireless)
• Flow control (adjacent nodes)
• Error detection /correction (retransmission / correction)
• Half-duplex / full-duplex communication (can nodes on both ends of a link
transmit at the same time?)
2
Where is the link layer implemented?
• in each and every host
• link layer implemented in “adaptor” (aka network interface card
NIC)
– Ethernet card, PCMCI card, 802.11 card
– implements link, physical layer
• attaches into host’s system buses
• combination of hardware, software, firmware
 sending side
 receiving side
 encapsulates datagram in frame
 looks for errors, rdt, flow
control, etc
 adds error checking bits, rdt,
flow control, etc.
 extracts datagram, passes to
upper layer
3
Link layer
• Datagram transferred by different link protocols over different
links:
e.g., Ethernet on first link, Frame Relay on intermediate links, 802.11 wireless
on last link
• Each DLL protocol provides different services : reliable/unreliable
• Main features
– Error detection
– Multiple Access links and protocols (sharing bandwidth)
• Collisions: Node receives 2 or more signals concurrently
• Collision detection
– Aloha/ Slotted Aloha
– CSMA,: Carrier Sense Multiple Access
• CSMA/CD: Collision Detection (Ethernet)
• SMA/CA: Collision Avoidance (Wi fi)
4
Error Detection and Correction
• Data protected by error checking, may include header fields
• EDC = Error Detection and Correction bits (redundancy)
• Error detection not 100% reliable!
• protocol may miss some errors, but rarely
• larger EDC field yields better detection and correction
•Parity Checking: number of ones in data
•Checksum: You remember how
•Cyclic Redundancy Check (CRC)
Want:
D.2r XOR R = nG
equivalently:
D.2r = nG XOR R
equivalently:
if we divide D.2r by G, want
remainder R
5
Multiple Access Links and Protocols
Two types of “links”:
• point-to-point: point-to-point link between Ethernet switch and host
• Broadcast: Ethernet / HFC / 802.11 wireless LAN
Protocols
• Single shared broadcast channel: collision on simultaneous
transimission
• Multiple Access Protocol
– Distributed algorithm to determine rules for sharing channels: when a node
can transmit over a channel
– Problem: communication about channel sharing uses the channel itself (one
channel)
– Channel with Rate R: one node can use all R; M nodes have R/M each
– No central dispatcher node to schedule transmission, no clocks, no
synchronization
6
MAC Protocols
• Three main classes
– Channel partitioning
• TDMA: time slots for each node (pkt transmission time)
• FDMA: Channel spectrum partitioned into bands
• CDMA: Each pair would use a different code
– Random Access
• Allow collisions (hope for the least)
– Each node attempts to transmit at full rate
– No coordination prior to transmission
• Implement recovery policy
– Detect collision
– Recover from collision
• ALOHA, Slotted ALOHA, CSMA, CSMA/CD, CSMA/CA
– Taking Turns
• Nodes take turns (could lead to starvation)
7
Slotted ALOHA
Assumptions:
• All frames are L bits
• Time divided into equal L/R slots
• Nodes transmit only at beginning of slots
• Nodes are synchronized to know beginning of slots
• Collision is known to all nodes
Operation:
Node obtains fresh frame  transmits in next slot
– no collision: node can send new frame in next slot
– collision: node retransmits frame in each subsequent slot with
probability p until success
8
Slotted ALOHA
• Pros
– single active node can continuously transmit at full rate
– highly decentralized: only slots in nodes need synchronization
– Simple to implement
• Cons
– collisions, wasting slots, idle slots
– collision detection can take more time than transmitting packet
– clock synchronization
• Efficiency
–
–
–
–
–
N nodes (each transmits in a slot with prob. p)
One node is successful in a slot = p(1-p)N-1
Any node is successful: f = Np(1-p)N-1
Max. Efficiency: what is p so that f is maximum
Realistic: f = 37%
9
Unslotted ALOHA
• Simpler, no synchronization
• When frame arrives, transmit immediately
Do not wait beginning of a slot
• Collision probability increases:
frame sent at t0 collides with other frames sent in [t0-1,t0+1]
• Success probability (rate): 18%
10
CSMA (Carrier Sense Multiple Access)
• Listen before transmit:
– If channel is idle: transmit entire frame
– If channel is busy, delay transmission
• Collisions can still occur:
– propagation delay means two nodes may not hear
each other’s transmission
– entire packet transmission time wasted
– role of distance & propagation delay in determining
collision probability
11
Summary of MAC protocols
• channel partitioning, by time, frequency or code
– Time Division, Frequency Division
• random access (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 central site, token passing
– Bluetooth, FDDI, IBM Token Ring
Link Layer Addressing
MAC (or LAN or physical or Ethernet) address:
– function: get frame from one interface to another
physically-connected interface (same network)
– 48 bit MAC address (for most LANs)
• burned in NIC ROM, also sometimes software settable
– Each adapter has a unique address
– Broadcast: FF-FF-FF-FF-FF-FF
– Address allocation managed by IEEE
Each manufacturer buys a portion of address space
13
Address Resolution Protocol (LAN)
• How to translate IP address into MAC address
• Each IP node (host or router) has an ARP table
– IP/MAC mapping for some nodes
• <IP, MAC, TTL>
• TTL: time to live of mapping (20 min)
– Nodes with no entries in ARP
• Broadcast ARP query with destination IP address
• Destination receives ARP with own IP  replies with own
MAC to source MAC (unicast)
• Source caches mapping for a TTL
– Nodes manage their ARP tables without intervention
from administrator
14
Addressing: Routing to another LAN
•
•
•
•
•
•
•
•
A creates IP 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 NIC sends frame
R’s NIC 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
88-B2-2F-54-1A-0F
74-29-9C-E8-FF-55
A
E6-E9-00-17-BB-4B
111.111.111.111
222.222.222.220
111.111.111.110
111.111.111.112
222.222.222.221
1A-23-F9-CD-06-9B
R
222.222.222.222
B
49-BD-D2-C7-56-2A
CC-49-DE-D0-AB-7D
15
Ethernet
• Previously bus topology
– Hub based All nodes in same collision domain
• Star topology
– Active switch in center
– Could also be a Hub
• Physical layer device; Broadcast every frame to all nodes
• Frame structure
– Preamble: 7 bytes with patterns pattern 10101010 followed
by one byte with pattern 10101011; used to synchronize
receiver, sender clock rates
– Type: higher layer protocol
– CRC: error detection
16
Ethernet
• Connectionless: no handshaking
• Unreliable
– No guarantee of delivery
• Frame with no matching MAC address  discarded
• Frame with errors  discarded
– No reassembly of data fragments
• If higher layer protocols do not regroup packets,
application sees gap in packets
• TCP compensates
17
Ethernet CSMA/CD
• NIC receives datagram from IP layer, creates frame
• NIC senses the channel
– If idle: start transmission
– If busy: wait until channel becomes free, then transmit
• No collision during transmission  success
• Collision detected: abort transmission and send jam signal
• After aborting: exponential back-off (random selection of
a delay based on history of collisions -- called bit time)
return to sensing
18
Ethernet CSMA/CD
• Jam signal: broadcast knowledge about collision
• Exponential backoff
– Wait: K*512 *bit time
• where K is chosen randomly from {0, 1, 2, …, 2m -1}
• Bit time: time to transmit one bit
– Example: @ 10Mbps
• Bit time: 0.1 microsec
• After 1 collision K is taken from {0, 1} ( 1 = 21 – 1)
– 50% probability:
» K = 0  no delay (after jam , sense)
» K= 1  wait 1*512*0.1 = 51.2 microsec
• After 10 collisions: K is in {0, 1, 2, …, 1023}
Probability changes and wait changes
19
CSMA/CD Efficiency
efficiency 
1
1  5t prop /ttrans
• Tprop = max prop delay between 2 nodes in LAN
• ttrans = time to transmit max-size frame
• efficiency goes to 1
– as tprop goes to 0
– as ttrans goes to infinity
• better performance than ALOHA: simple, cheap, and
decentralized
20
Hub
Physical-layer repeater:
– bits coming from one link go out all other links at
the same rate
– All nodes connected to one hub can collide
– no frame buffering
– no CSMA/CD at hub: adapters detect collisions
twisted pair
hub
21
Switch
• Link layer device
– stores and forwards Ethernet frames
– examines frame header and selectively forwards frame
based on MAC destination address
– uses CSMA/CD to access link: when frame is to be
forwarded on link
• transparent
– hosts are unaware of presence of switches
• plug-and-play, self-learning
– do not need to be configured
– Learns which hosts are reachable on which interfaces
(switch table: indexed using MAC destination address)
22
Switches vs. Routers
• both store-and-forward devices
– routers: network layer devices (examine network layer headers)
– switches are link layer devices
• routers maintain routing tables, implement routing
algorithms
• switches maintain switch tables, implement filtering,
learning algorithms
23