Upload
others
View
1
Download
0
Embed Size (px)
Citation preview
9/17/14
1
Chapter 6
Physical Link
Network Transport
Application
Physical Link
Network Transport
Application
Physical Link
Physical Link
Network
Physical Link
Network
Physical Link
Network Core
Internet backbone
Global ISP Global ISP
Root DNS servers
Regional ISP
Regional ISP
Regional ISP
Mobile/cell network
Corporate/institute network
HFC or DSL
Home network
9/17/14
9/17/14
2
Physical node-to-node
bit-by-bit
Network host-to-host
Link node-to-node
frame-by-frame
101101001000100101010
Datagram
Frame
Context
9/17/14
MAC sublayer
LLC sublayer
Logical Link Control
Medium Access Control
Outline
❀ Link layer services and implementation ❀ Broadcast networks
" MAC addressing " Multiple access protocols
❀ Ethernet frame
❀ Link-Layer Devices " Bridges and Layer-2 switches " Learning and forwarding " Loop prevention and multipathing
❀ Wireless links " Broadcast limitations
9/17/14
3
Link Physical
Network Transport
Application
Link layer implementation ❀ Part of the Link layer is
implemented in a NIC (network interface card) /network adaptor " Implements MAC, and physical
layer
❀ Attaches into host’s system buses ❀ Part of the Link Layer is in system
software " Drivers in the OS provide the
bond between OS and NIC
Motherboard Bus
NIC: network interface Card
Host hardware/Firmware
controller
Physical
CPU Main memory
OS
Motherboard
Link layer services
❀ Sender: " A host, Layer 3 switch or router " Encapsulates datagram in frame " LLC:
µ Reliable delivery µ Flow control, etc.
" MAC: error checking bits
❀ Receiver " A host, Layer 3 switch or router " Extracts datagram, and passes to
upper layer at receiving side " MAC: identifies errors " LLC:
µ Acknowledgement, flow control
CPU Memory CPU Memory
Sending host/router Receiving host/router
Datagram Datagram
Datagram
frame NIC NIC
9/17/14
4
Outline
❀ Link layer services and implementation ❀ Broadcast networks
" MAC addressing " Multiple access protocols
❀ Ethernet frame
❀ Link-Layer Devices " Bridges and Layer-2 switches " Learning and forwarding " Loop prevention and multipathing
❀ Wireless links " Broadcast limitations
Broadcast Networks ❀ Bus topology from 1980 to mid 90s
" All nodes in same collision domain (can collide with each other)
" Uses coaxial cable
❀ Star topology from mid 1990s " Hub in center " All nodes in the same
collision domain " Uses twisted pair cable
Bus Topology Star Topology
Hub
9/17/14
5
Hub (or MAU) ❀ Hub: A physical-layer repeater
" Bits received in one link are broadcast to all other links at the same rate " All stations connected to a hub can collide with one another " No frame buffering
Hub/ MAU
Collision Domain
Broadcast Networks
❀ Broadcast medium " All stations receive a copy of the message sent " But most communication is intended to be only between two computers on a network
❀ To allow sender to specify destination, each station is assigned a hardware address (MAC address)
Sender Receiver
Signal propagates along the entire cable
9/17/14
6
MAC Address ❀ Example: Ethernet Addressing
" Unique 48-bit MAC address " First 24 bits is manufacturer code - assigned by IEEE " Second 24 bits are sequentially assigned and UNIQUE
" Burned in NIC ROM " Or often software configurable (such as Linksys router)
❀ Broadcast address: FF-FF-FF-FF-FF-FF – Send the frame to all adapters
MAC Addresses Each NIC/interface on LAN has unique MAC/LAN address
Broadcast address = FF-‐FF-‐FF-‐FF-‐FF-‐FF
00-‐50-‐12-‐FB-‐76-‐C9
00-‐10-‐82-‐3D-‐7F-‐A2
00-‐10-‐41-‐16-‐FE-‐24
00-‐10-‐6F-‐72-‐B8-‐5E
Broadcast Network
Frame received by all NICs. The one with MAC address matching the destination MAC address processes the frame.
NIC
9/17/14
7
Multiple Access Protocols How to coordinate access to shared link? 1. Divide the channel into pieces
" In time " In frequency
2. Take turns
" Pass a token for the right to transmit
3. Let collisions happen " … and detect and recover from them " CSMA/CD (Carrier Sense Multiple Access /Collision Detection)
6-‐slot frame
S1 S3 S5 Time S1 S3 S5
Frequency bands time
❀ Carrier sense (CS) " Listen before speaking " Nodes can distinguish between an idle and a busy link
❀ Multiple Access (MA) " Multiple transmissions " When a station is done transmitting, it can immediately start a new transmission
❀ Collision detection (CD) " Listen while transmitting " Detect simultaneous talking … and stop! " Wait for a period of time before trying to talk again!
❀ To detect collisions, compare the transmitted and received signals
CSMA/CD is Like Human Conversation…
9/17/14
8
❀ How long does it take to realize there has been a collision?
CSMA/CD and Propagation Delays
A B
Time=0
A B
Time=d-ε
A B
Time=2d
Δ = end-to-end propagation delay
A
Worst case: 2 x Δ To detect the collision, A must transmit for at least 2xΔ time.
Examples ❀ Case 1:
" Station A starts at t = 0, Station C starts at t = 1 µs; distance between two stations is 200 m, Speed = 200 m/µs, Rate = 1 Gbps, Packet size = 4000 bits. Discuss collision detection at Stations A and C.
❀ Case 2: " Station A starts at t =0, Station C starts at t = 0.5 µs; distance between two
stations is 200 m, Speed = 200 m/µs, Rate = 1 Gbps, Packet size = 500 bits. Discuss collision detection at Stations A and C.
9/17/14
9
t
x
200m
Station B
Station A
Station C
1μs 2μs 0.5μs 1.5μs 2.5μs 3.5μs 3μs 4.5μs 4μs
Collision Example 1
1000 bits sent
Speed = 200m/μs Rate = 1Gbps Packet size = 4000 bits Station A starts at t = 0, Station C starts at t = 1 μs
t
x
200m
Station B
Station A
Station C
1μs 2μs 0.5μs
A collision occurs at B 2μs after A begins transmitting and is not detectable
1.5μs 2.5μs 3.5μs 3μs 4.5μs 4μs
This collision is not detectable by A, B, or C
A collision is detected at C 2μs after A begins transmitting and is detected by C
Collision Example 1
1000 bits sent
Speed = 200m/μs Rate = 1Gbps Packet size = 4000 bits Station A starts at t = 0, Station C starts at t = 1 μs
9/17/14
10
t
x
200m
Speed = 200m/μs Rate = 1Gbps Packet size = 4000 bits
Station B
Station A
Station C
1μs 2μs 0.5μs 1.5μs 2.5μs 3.5μs 3μs 4.5μs 4μs 5μs
A collision occurs at A 3μs after A begins transmitting.
This collision is detectable by A because A is still transmitting
Collision Example 1
1000 bits sent
t
x
200m Speed = 200m/μs Rate = 1Gbps Packet size = 4000 bits
Station B
Station A
Station C
1μs 2μs 0.5μs 1.5μs 2.5μs 3.5μs 3μs 4.5μs 4μs 5μs
Using the CSMA/CD standard, A would stop transmitting
Collision Example 1
1000 bits sent
Using the CSMA/CD standard, C would stop transmitting
9/17/14
11
t
x
200m
Speed = 200m/μs Rate = 1Gbps Packet size = 500 bits A starts at t =0 C starts at t = 0.5 μs
Station B
Station A
Station C
1μs 2μs 0.5μs 1.5μs 2.5μs 3.5μs 3μs 4.5μs 4μs 5μs
Collision Example 2
500 bits sent
t
x
200m
Speed = 200m/μs Rate = 1Gbps Packet size = 500 bits
Station B
Station A
Station C
1μs 2μs 0.5μs 1.5μs 2.5μs 3.5μs 3μs 4.5μs 4μs 5μs
Near Collision
Collision Example 2
9/17/14
12
t
x
200m
Speed = 200m/μs Rate = 1Gbps Packet size = 500 bits
Station B
Station A
Station C
1μs 2μs 0.5μs 1.5μs 2.5μs 3.5μs 3μs 4.5μs 4μs 5μs
If a collision were to occur anywhere it would not be detectable because the packets are too short.
Collision Example 2
Limitations on Ethernet link length
❀ Latency depends on physical length of link ❀ Condition for CSMA/CD to work:
Transmission Time > 2Δ ❀ Imposes restrictions on Ethernet
" Minimum length of the packet: 512 bits (64 bytes) " Maximum distance between two nodes: 2500 meters
latency Δ A B
9/17/14
13
Ethernet Frame Structure
❀ Preamble: " 7 bytes with pattern 10101010 followed by one byte with pattern 10101011 " Used to synchronize receiver, sender physical layer
❀ MAC Addresses: 6 bytes " If adapter receives frame with matching destination address, accepts the frame " Otherwise, adapter discards frame
❀ Type: 2 bytes " Indicating higher layer protocol (primarily IP but others possible, e.g., Novell IPX,
AppleTalk)
❀ Frame check sequence (FCS): 4bytes, CRC-32 " Checked at receiver, if error is detected, frame is dropped
Preamble Dest. MAC addr
Src. MAC addr Type Payload FCS
8 bytes 2 bytes 46 to 1500 bytes 4 bytes 6 bytes 6 bytes
Outline
❀ Link layer services and implementation ❀ Broadcast networks
" MAC addressing " Multiple access protocols
❀ Ethernet frame
❀ Link-Layer Devices " Bridges and Layer-2 switches " Learning and forwarding " Loop prevention and multipathing
❀ Wireless links " Broadcast limitations
9/17/14
14
Link Layer Devices ❀ Bridges and Layer-2 Switches ❀ Transparent
" Hosts are unaware of presence of switches ❀ Plug-and-Play
" Self-learning " Switches do not need to be configured
Bridge Layer-2 switch
LAN Bridge ❀ Connect two computers / LANs together
" Each bridge port is connected to a hub or a computer
❀ Bridge Functions: " Learning
µ Bridge learns which staGon can be reached on each parGcular port by monitoring the source MAC addresses of all incoming frames
" Forwarding µ Forwards frames only if necessary µ Uses CSMA/CD to access the segment
where the desGnaGon staGon resides
1 2 3
4 5
6
Hub
Hub
Collision Domain
9/17/14
15
Layer 2 Switch
❀ A bridge with a hardware switch fabric " Uses an embedded
microcomputer to perform the bridging function for the hardware switch fabric
" Switch fabric permits multiple simultaneous transmissions
" Very fast internal forwarding
Controller
Input port 0 Input port 1
Input port 7
……
Output port 0 Output port 1
Output port 7
……
Switch fabric
❀ Either Store-and-forward or cut-through switch " Cut through: The switch reads only up to the frame's hardware address before
forwarding it. There is no error detection " Store and forward: The switch buffers the entire frame, and performs a checksum
on each frame before forwarding it
: closed switch
Ports (0,1) and (1,0) can send and receive simultaneously
Outline
❀ Link layer services and implementation ❀ Broadcast networks
" MAC addressing " Multiple access protocols
❀ Ethernet frame
❀ Link-Layer Devices " Bridges and Layer-2 switches " Learning and forwarding " Loop prevention and multipathing
❀ Wireless links " Broadcast limitations
9/17/14
16
1
4
2
5
3
6
1 2 3
4 5
6
Self-Learning and Forwarding ❀ Switch learns which host is
connected to which ports " When a frame received, the
switch learns the port connected to sender: incoming LAN segment
" Records sender MAC address/port pair in switch table
❀ Frame destination unknown: broadcast
❀ Destination location known: unicast
1 4
MAC addr.
Switch table
1 1 60
A A’ A A’ A A’ A A’ 1 4
4 1
4 4 60
1 4 1 4 1 4 1 4 1 4
TTL port
Multiple switches
❀ The learning process is the same but multiple switches are involved in learning the source MAC address of a frame " For example, A sends a frame to G and this frames triggers all switches to learn A’s MAC address and the
entrance port number. S2 learns that A is connected to its port 1; S1 learns that A can be reached using its port 1; and S4 learns that A can be reached using its port 4.
D
E F
S3
S1
S4
H I
G
A
B
S2
C
1 2
3
1
2 4
3 1
2
3 1 2
4
4 5
9/17/14
17
Switch MAC Port TTL
S1
A 1 60 B 1 60 C 1 60 D 1 60 E 1 60 F 1 60 G 2 60 H 2 60 I 2 60
S2
A 1 60 B 2 60 C 3 60 D 4 60 E 4 60 F 4 60 G 5 60 H 5 60 I 5 60
Switch MAC Port TTL
S3
A 4 60 B 4 60 C 4 60 D 1 60 E 2 60 F 3 60 G 4 60 H 4 60 L 4 60
S4
A 4 60 B 4 60 C 4 60 D 4 60 E 4 60 F 4 60 G 1 60 H 2 60 L 3 60
Institutional Network: Flat Switch Net
to external network
router
IP subnet
mail server
web server
Useful for small/medium business
9/17/14
18
Sniffing Attacks to Switch ❀ Each switch has a few Kbytes buffer (typically 4 KB) ❀ If switch table is filled up, old (valid) entries are wiped out ❀ Keep sending frames with random source MAC address to fill up the buffer ❀ When the valid frame comes, it will be broadcast since there is no entry
corresponding to the destination MAC address
Outline
❀ Link layer services and implementation ❀ Broadcast networks
" MAC addressing " Multiple access protocols
❀ Ethernet frame
❀ Link-Layer Devices " Bridges and Layer-2 switches " Learning and forwarding " Loop prevention and multipathing
❀ Wireless links " Broadcast limitations
9/17/14
19
Danger of Loops ❀ Bridges sometimes need to broadcast frames
" Upon receiving a frame with an unfamiliar destination " Upon receiving a frame sent to the broadcast address
❀ Broadcasting can lead to loops " e.g., if the network contains a cycle of switches (reliability)
Loop Example (1) Bridge 1 Bridge 2
Host Port Host Port
A Top A Top
Bottom
9/17/14
20
Loop Example (2) Bridge 1 Bridge 2
Host Port Host Port
A Top A Bottom
Bottom
Why redundant links? ❀ Automatic backup paths if an
existing link fails ❀ May create bridging loops ❀ Solution:
" Spanning Tree Protocol
B
FED
C
Fully connected L2 switches
Seg. 1
Seg. 2
A
9/17/14
21
STP and RSTP ❀ Spanning Tree Protocol (STP)
" A Layer 2 protocol that ensures a loop free topology for any bridged LAN " Disables the links that are not part of that tree, leaving a single active path
between any two network stations
❀ Rapid Spanning Tree Protocol (RSTP) " Provides for faster spanning tree convergence after a topology change: about 10
times faster than STP " IEEE 802.1D-2004 now incorporates RSTP and obsoletes STP
The Spanning Tree ❀ The collection of bridges in a
local area network (LAN) viewed as a graph " nodes are bridges and LAN
segments " edges are the interfaces
connecting the bridges to bridges or the segments
❀ To break loops in this graph, the bridges collectively compute a spanning tree
B
FED
C
Fully connected L2 switches
Seg. 1
Seg. 2
A
9/17/14
22
The Spanning Tree Protocol ❀ To break loops in the LAN while maintaining access to all LAN segments, the
bridges collectively compute a spanning tree " The root bridge of the spanning tree is the bridge with the smallest (lowest)
bridge ID and a configurable priority number µ A configurable priority number is controlled by administrator to pick a root bridge
" The priority is compared first and a smallest priority number of bridge is designated as the root bridge
" If priority is the same, then a smallest ID of bridge is designated as the root bridge
❀ The bridges collectively determine which bridge has the least-cost path from the network segment to the root " The bridges use special data frames called Bridge Protocol Data Units (BPDUs) to
exchange information of the form (Y, d, X) o From bridge X o Claiming Y is the root o And the cost to root is d
Steps in the Spanning Tree ❀ Initially, each switch thinks it is the root
" Switch sends a message out every interface " … identifying itself as the root with distance 0 " Example: switch X announces (X, 0, X)
❀ Switches update their view of the root " Upon receiving a message, check the root id " If the new id is smaller, start viewing that
switch as root
❀ Switches compute distance to the root " Add link cost to the distance received from a
neighbor " Identify interfaces not on a shortest path to
the root " … and exclude them from the spanning tree
A
B
FED
C
S1
S2
9/17/14
23
Example for switch D ❀ Assume for simplicity unit link costs ❀ Initially, D thinks it is the root
" Sends (D, 0, D) to B and E
❀ D hears from B " Receives (B, 0, B) message from B " … and thinks that B is the root
❀ Then D hears from E " Receives (B, 1, E) from E " And realizes this is a longer path " So, prefers its own one-hop path " And removes Iink D-E from the tree
(temporary view)
A
B
FED
C
S1
S2
Example for switch D ❀ B hears from A
" B hears (A, 0, A) from A " B starts treating A as root " And sends (A, 1, B) to neighbors
❀ D hears from B again " Receives (A, 1, B) message from B " B starts treating A as root " And sends (A, 2, B) to neighbors
❀ Final spanning tree
A
B
FED
C
S1
S2
9/17/14
24
The Spanning Tree Protocol ❀ The cost of a link is specified according to data rate
" Higher data rate link has a lower cost " STP picks the path with the smallest cost (a least-cost path)
❀ All ports of the root switch must be in forwarding mode " The port connecting to an STP path becomes the root port (RP) of the bridge
µ The root port must be set to forwarding mode
" All the other ports that are not a root port in all the switches must be placed in blocking mode, aka blocked ports (BPs) µ The rule only applies to ports that connect to other bridges or switches µ STP does not affect ports that connect to staGons or hosts and these ports remain in forwarding
mode
Switch Root Ports ❀ Traffic flows over spanning tree
edges ❀ Each switch port attached to the
spanning tree is a root port ❀ Forwarding mode:
" root ports " ports connected to hosts
❀ Remaining ports placed in blocking mode
A
B
FED
C
S1
S2
root port
root port
root port
root port
root port
9/17/14
25
RSTP Operation ❀ RSTP adds new bridge port roles in order to speed convergence following a link
failure " Root port: A forwarding port that is the best port from a non-root bridge to the root
bridge " Designated port: A forwarding port for every LAN segment
µ The port of the bridge with a least cost path to the root µ Break Ges by the lower bridge idenGfier µ Since each PC is directly connected to a switch port, the designated port for the
segment, which is the PC, is that switch port " Alternate port (in the blocking state): An alternate path to the root bridge and this
path is different than using the root port " Backup port (in the blocking state): A redundant path to a segment where
another bridge port already connects a parallel path
Example ❀ A blocked port is defined
as one that is not a designated or root port " A backup port
provides an alternate path to the root bridge and therefore can replace the root port if it fails
" A backup port provides redundant connectivity to the same segment
A
B
FED
C
root port
root port
Root port for D
root port Alternate port for D
Designated port for D
Root port for B
Designated port for B
Alternate port for B
Backup port for D
9/17/14
26
Outline
❀ Link layer services and implementation ❀ Broadcast networks
" MAC addressing " Multiple access protocols
❀ Ethernet frame
❀ Link-Layer Devices " Bridges and Layer-2 switches " Learning and forwarding " Loop prevention and multipathing
❀ Wireless links " Broadcast limitations
Wireless Links: High Bit Error Rate ❀ Decreasing signal strength
" Disperses as it travels greater distance " Attenuates as it passes through matter
9/17/14
27
Wireless Links: High Bit Error Rate
❀ Interference from other sources " Radio sources in same frequency band " E.g., 2.4 GHz wireless phone interferes with 802.11b wireless LAN " Electromagnetic noise (e.g., microwave oven)
Wireless Links: High Bit Error Rate ❀ Multi-path propagation
" Electromagnetic waves reflect off objects " Taking many paths of different lengths " Causing blurring of signal at the receiver
receiver!
transmitter!
9/17/14
28
Wireless Links: Broadcast Limitations ❀ Wired broadcast links
" E.g., Ethernet bridging, in wired LANs " All nodes receive transmissions from all other nodes
❀ Wireless broadcast: hidden terminal problem
A B
C • A and B hear each other • B and C hear each other • But, A and C do not
So, A and C are unaware of their interference at B
Wireless Links: Broadcast Limitations ❀ Wired broadcast links
" E.g., Ethernet bridging, in wired LANs " All nodes receive transmissions from all other nodes
❀ Wireless broadcast: fading over distance
A B C
A’s signal strength
space
C’s signal strength
• A and B hear each other • B and C hear each other • But, A and C do not
So, A and C are unaware of their interference at B
9/17/14
29
CSMA/CA ❀ Motivation for CSMA/CA
" Collision detection is difficult in a free space environment µ You cannot hear when you are talking
" Stations may get interference from other LANs " Hidden node problem
❀ 802.11: CSMA - listen before transmitting ❀ 802.11: Collision Avoidance (CA)
" Difficult to detect collisions when transmitting due to weak received signals (fading) " Hidden node collision
CSMA: Carrier Sense, Multiple Access ❀ Multiple access: channel is shared medium
" Station: wireless host or access point " Multiple stations may want to transmit at same time
❀ Carrier sense: sense channel before sending " Station doesn’t send when channel is busy " To prevent collisions with ongoing transfers " But, detecting ongoing transfers isn’t always possible
A B
C A B C
A’s signal strength
space
C’s signal strength
9/17/14
30
CA: Collision Avoidance, not Detection ❀ Collision detection in wired Ethernet
" Station listens while transmitting " Detects collision with other transmission " Aborts transmission and tries sending again
❀ Problem #1: cannot detect all collisions " Hidden terminal problem " Fading
❀ Problem #2: listening while sending " Strength of received signal is much smaller " Expensive to build hardware that detects collisions
❀ So, 802.11 does collision avoidance, not detection
Hidden terminal problem
❀ A and C cannot see each other, both send to B
❀ Occurs because 802.11 relies on physical carrier sensing, which is susceptible to hidden terminal problem
C B A
9/17/14
31
Virtual carrier sensing ❀ First exchange control frames before transmitting data
" Sender issues “Request to Send” (RTS) using CSMA (includes length of data) " Receiver responds with “Clear to Send” (CTS)
❀ If sender sees CTS, transmits data (of specified length)
❀ If other node sees CTS, defers transmission
❀ If other node sees RTS but not CTS, free to send
❀ RTS may still collide with each other " Since RTS is short, the wasted bandwidth is small
In reality, 802.11 MAC cannot avoid all collisions
Hidden terminal problem
❀ A and C cannot see each other, both send to B
❀ RTS/CTS can help " Both A and C would send RTS that B would see first " B only responds with one CTS (say, echoing A’s RTS) " C detects that CTS doesn’t match and won’t send
C B A
9/17/14
32
Exposed terminal problem
❀ B sending to A, C wants to send to D ❀ As C receives B’s packets, carrier sense would prevent it from sending to D, even
though wouldn’t interfere ❀ RTS/CTS can help
" C hears RTS from B, but not CTS from A " C knows its transmission will not interfere with A " C is safe to transmit to D
C B A D