cs162 operating systems and systems programming lecture 13 packet switching march 7, 2011 ion stoica...

53
CS162 Operating Systems and Systems Programming Lecture 13 Packet Switching March 7, 2011 Ion Stoica http://inst.eecs.berkeley.edu/~cs162

Upload: miles-dawson

Post on 12-Jan-2016

219 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: CS162 Operating Systems and Systems Programming Lecture 13 Packet Switching March 7, 2011 Ion Stoica cs162

CS162Operating Systems andSystems Programming

Lecture 13

Packet Switching

March 7, 2011

Ion Stoica

http://inst.eecs.berkeley.edu/~cs162

Page 2: CS162 Operating Systems and Systems Programming Lecture 13 Packet Switching March 7, 2011 Ion Stoica cs162

Lec 13.23/7 Ion Stoica CS162 ©UCB Spring 2011

Goals for Today

• Communication network taxonomy– Circuit switching

– Packet switching

• Statistical multiplexing

Note: Some slides and/or pictures in the following areadapted from notes by Vern Paxson, and Randy Katz.

Page 3: CS162 Operating Systems and Systems Programming Lecture 13 Packet Switching March 7, 2011 Ion Stoica cs162

What Global (non-digital) Communication Network Do You

Use Every Day?

Roughly speaking, how does it work?

Page 4: CS162 Operating Systems and Systems Programming Lecture 13 Packet Switching March 7, 2011 Ion Stoica cs162

Lec 13.43/7 Ion Stoica CS162 ©UCB Spring 2011

Postal System

• Write address• Put stamp• Close envelop

Drop letter

Take letter to local post office

• Verify postage• “Route” letter

Take letter to destination’s postal office

Check destination address

Take letter to destination• Check address

• Open envelope

Page 5: CS162 Operating Systems and Systems Programming Lecture 13 Packet Switching March 7, 2011 Ion Stoica cs162

What’s Another Such Network That You Use Every Day?

Page 6: CS162 Operating Systems and Systems Programming Lecture 13 Packet Switching March 7, 2011 Ion Stoica cs162

Lec 13.63/7 Ion Stoica CS162 ©UCB Spring 2011

Examples of Other Information Networks

Fire signalsSending messages by birds

Page 7: CS162 Operating Systems and Systems Programming Lecture 13 Packet Switching March 7, 2011 Ion Stoica cs162

Lec 13.73/7 Ion Stoica CS162 ©UCB Spring 2011

Other Network Examples

Page 8: CS162 Operating Systems and Systems Programming Lecture 13 Packet Switching March 7, 2011 Ion Stoica cs162

Lec 13.83/7 Ion Stoica CS162 ©UCB Spring 2011

• Communication networks can be classified based on the way in which the nodes exchange information:

Taxonomy of Communication Networks

Communication Network

Page 9: CS162 Operating Systems and Systems Programming Lecture 13 Packet Switching March 7, 2011 Ion Stoica cs162

Lec 13.93/7 Ion Stoica CS162 ©UCB Spring 2011

• Communication networks can be classified based on the way in which the nodes exchange information:

Taxonomy of Communication Networks

Communication Network

BroadcastCommunication

Network

Page 10: CS162 Operating Systems and Systems Programming Lecture 13 Packet Switching March 7, 2011 Ion Stoica cs162

Lec 13.103/7 Ion Stoica CS162 ©UCB Spring 2011

• Information transmitted by any node is received by every other node in the network

– Examples?– Usually in LANs (Local Area Networks)

» E.g., Ethernet (classical), WiFi» E.g., lecture!

• What problems does this raise?• Problem #1: limited range• Problem #2: privacy of communication• Problem #3: coordinating access to the shared

communication medium (Multiple Access Problem)

Broadcast Communication Networks

Page 11: CS162 Operating Systems and Systems Programming Lecture 13 Packet Switching March 7, 2011 Ion Stoica cs162

Lec 13.113/7 Ion Stoica CS162 ©UCB Spring 2011

• Communication networks can be classified based on the way in which the nodes exchange information:

Taxonomy of Communication Networks

Communication Network

SwitchedCommunication

Network

BroadcastCommunication

Network

Page 12: CS162 Operating Systems and Systems Programming Lecture 13 Packet Switching March 7, 2011 Ion Stoica cs162

Lec 13.123/7 Ion Stoica CS162 ©UCB Spring 2011

• Information transmitted along a path of intermediary nodes (“routers” or “switches”)

• Basic issue: how the routers figure out the next hop along the path

Switched Communication Networks

Page 13: CS162 Operating Systems and Systems Programming Lecture 13 Packet Switching March 7, 2011 Ion Stoica cs162

Lec 13.133/7 Ion Stoica CS162 ©UCB Spring 2011

• Communication networks can be classified based on the way in which the nodes exchange information:

Taxonomy of Communication Networks

Communication Network

SwitchedCommunication

Network

BroadcastCommunication

Network

Circuit-Switched

Communication Network

Page 14: CS162 Operating Systems and Systems Programming Lecture 13 Packet Switching March 7, 2011 Ion Stoica cs162

Lec 13.143/7 Ion Stoica CS162 ©UCB Spring 2011

Circuit Switching (e.g., Phone Network)

• Establish: source creates circuit to destination– Nodes along the path store connection info

– Nodes generally reserve resources for the connection

– If circuit not available: “Busy signal”

• Transfer: source sends data over the circuit– No destination address, since nodes know path

• Teardown: source tears down circuit when done

Page 15: CS162 Operating Systems and Systems Programming Lecture 13 Packet Switching March 7, 2011 Ion Stoica cs162

Lec 13.153/7 Ion Stoica CS162 ©UCB Spring 2011

Circuit Switching

• Node (switch) in a circuit switching network

incoming links outgoing linksNode

How does the node connect the incoming link to the outgoing?

Page 16: CS162 Operating Systems and Systems Programming Lecture 13 Packet Switching March 7, 2011 Ion Stoica cs162

Lec 13.163/7 Ion Stoica CS162 ©UCB Spring 2011

Telephone Network

• Alexander Graham Bell– 1876: Demonstrates the telephone at US

Centenary Exhibition in Philadelphia

Page 17: CS162 Operating Systems and Systems Programming Lecture 13 Packet Switching March 7, 2011 Ion Stoica cs162

Lec 13.173/7 Ion Stoica CS162 ©UCB Spring 2011 17

Circuit Switching With Human Operator

Page 18: CS162 Operating Systems and Systems Programming Lecture 13 Packet Switching March 7, 2011 Ion Stoica cs162

Lec 13.183/7 Ion Stoica CS162 ©UCB Spring 2011

Telephone Network

• Almon Brown Strowger (1839 - 1902)– 1889: Invents the “girl-less, cuss-less” telephone

system -- the mechanical switching system

Page 19: CS162 Operating Systems and Systems Programming Lecture 13 Packet Switching March 7, 2011 Ion Stoica cs162

Lec 13.193/7 Ion Stoica CS162 ©UCB Spring 2011

Timing in Circuit Switching

Host 1 Host 2Switch 1 Switch 2

time

Page 20: CS162 Operating Systems and Systems Programming Lecture 13 Packet Switching March 7, 2011 Ion Stoica cs162

Lec 13.203/7 Ion Stoica CS162 ©UCB Spring 2011

Timing in Circuit Switching

Circuit Establishment

Host 1 Host 2Switch 1 Switch 2

propagation delay between Host 1 and Switch1

time

Page 21: CS162 Operating Systems and Systems Programming Lecture 13 Packet Switching March 7, 2011 Ion Stoica cs162

Lec 13.213/7 Ion Stoica CS162 ©UCB Spring 2011

Timing in Circuit Switching

Circuit Establishment

Host 1 Host 2Switch 1 Switch 2

propagation delay between Host 1 and Switch1

Transmission delay

time

Page 22: CS162 Operating Systems and Systems Programming Lecture 13 Packet Switching March 7, 2011 Ion Stoica cs162

Lec 13.223/7 Ion Stoica CS162 ©UCB Spring 2011

Timing in Circuit Switching

Circuit Establishment

Host 1 Host 2Switch 1 Switch 2

propagation delay between Host 1 and Switch1

Transmission delay

time

Page 23: CS162 Operating Systems and Systems Programming Lecture 13 Packet Switching March 7, 2011 Ion Stoica cs162

Lec 13.233/7 Ion Stoica CS162 ©UCB Spring 2011

Timing in Circuit Switching

Circuit Establishment

Host 1 Host 2Switch 1 Switch 2

propagation delay between Host 1 and Switch1

propagation delay between Host 1 and Host 2

Transmission delay

time

Page 24: CS162 Operating Systems and Systems Programming Lecture 13 Packet Switching March 7, 2011 Ion Stoica cs162

Lec 13.243/7 Ion Stoica CS162 ©UCB Spring 2011

Timing in Circuit Switching

Information

Circuit Establishment

Transfer

Host 1 Host 2Switch 1 Switch 2

propagation delay between Host 1 and Switch1

propagation delay between Host 1 and Host 2

Transmission delay

time

Page 25: CS162 Operating Systems and Systems Programming Lecture 13 Packet Switching March 7, 2011 Ion Stoica cs162

Lec 13.253/7 Ion Stoica CS162 ©UCB Spring 2011

Timing in Circuit Switching

Information

Circuit Establishment

Transfer

Circuit Teardown

Host 1 Host 2Switch 1 Switch 2

propagation delay between Host 1 and Switch1

propagation delay between Host 1 and Host 2

Transmission delay

time

Page 26: CS162 Operating Systems and Systems Programming Lecture 13 Packet Switching March 7, 2011 Ion Stoica cs162

Lec 13.263/7 Ion Stoica CS162 ©UCB Spring 2011

Circuit Switching

• Node (switch) in a circuit switching network

incoming links outgoing linksNode

How do the black and red circuits share the outgoing link?

Page 27: CS162 Operating Systems and Systems Programming Lecture 13 Packet Switching March 7, 2011 Ion Stoica cs162

Lec 13.273/7 Ion Stoica CS162 ©UCB Spring 2011

Circuit Switching: Multiplexing a Link

• Time-division– Each circuit allocated

certain time slots

• Frequency-division– Each circuit allocated

certain frequencies

timefr

equ

ency

time

Page 28: CS162 Operating Systems and Systems Programming Lecture 13 Packet Switching March 7, 2011 Ion Stoica cs162

Lec 13.283/7 Ion Stoica CS162 ©UCB Spring 2011

Time-Division Multiplexing/Demultiplexing

• Time divided into frames; frames into slots

• Relative slot position inside a frame determines to which circuit data belongs

– E.g., slot 0 belongs to red circuit

• Requires synchronization between sender and receiver—surprisingly non-trivial!

• In case of non-permanent circuits– Need to dynamically bind a slot to a circuit

– How to do this?

• If sender does not send data the circuit’s capacity is lost!

Frames

0 1 2 3 4 5 0 1 2 3 4 5Slots =

Page 29: CS162 Operating Systems and Systems Programming Lecture 13 Packet Switching March 7, 2011 Ion Stoica cs162

Lec 13.293/7 Ion Stoica CS162 ©UCB Spring 2011

Administrivia

• Midterm next lecture:– Wednesday, March 9th – Closed book, one page cheat sheet (both sides)

• Midterm Topics: Everything up to last lecture (excluding “Introduction to Networking”), March 2nd

• Review session: Today 6-8pm (306 Soda Hall)

Page 30: CS162 Operating Systems and Systems Programming Lecture 13 Packet Switching March 7, 2011 Ion Stoica cs162

Lec 13.303/7 Ion Stoica CS162 ©UCB Spring 2011

5min Break

Page 31: CS162 Operating Systems and Systems Programming Lecture 13 Packet Switching March 7, 2011 Ion Stoica cs162

Lec 13.313/7 Ion Stoica CS162 ©UCB Spring 2011

• Communication networks can be classified based on the way in which the nodes exchange information:

Taxonomy of Communication Networks

Communication Network

SwitchedCommunication

Network

BroadcastCommunication

Network

Circuit-Switched

Communication Network

Packet-Switched

Communication Network

Page 32: CS162 Operating Systems and Systems Programming Lecture 13 Packet Switching March 7, 2011 Ion Stoica cs162

Lec 13.323/7 Ion Stoica CS162 ©UCB Spring 2011

Packet Switching

• Data sent as chunks of formatted bit-sequences (Packets)

• Packets have following structure:

» Header and Trailer carry control information (e.g., destination address, checksum)

• Each packet traverses the network from node to node along some path (routing) based on header info

• Usually, once a node receives the entire packet, it stores it (hopefully briefly) and then forwards it to the next node (Store-and-Forward Networks)

Header Data Trailer (sometimes)

Page 33: CS162 Operating Systems and Systems Programming Lecture 13 Packet Switching March 7, 2011 Ion Stoica cs162

Lec 13.333/7 Ion Stoica CS162 ©UCB Spring 2011

Packet Switching

• Node in a packet switching network

incoming links outgoing linksNode

Memory

Page 34: CS162 Operating Systems and Systems Programming Lecture 13 Packet Switching March 7, 2011 Ion Stoica cs162

Lec 13.343/7 Ion Stoica CS162 ©UCB Spring 2011

Packet Switching: Multiplexing/Demultiplexing

• Data from any flow can be transmitted at any given time

– Single flow can use the entire link capacity if it is alone

• How to tell them apart?– Use meta-data (header) to describe data

• Note: for packet switching we use flow (instead of circuit) to denote packets sent by a sender to a receiver

Page 35: CS162 Operating Systems and Systems Programming Lecture 13 Packet Switching March 7, 2011 Ion Stoica cs162

Lec 13.353/7 Ion Stoica CS162 ©UCB Spring 2011

• Communication networks can be classified based on the way in which the nodes exchange information:

Taxonomy of Communication Networks

Communication Network

SwitchedCommunication

Network

BroadcastCommunication

Network

Circuit-Switched

Communication Network

Packet-Switched

Communication Network

Datagram Network

Page 36: CS162 Operating Systems and Systems Programming Lecture 13 Packet Switching March 7, 2011 Ion Stoica cs162

Lec 13.363/7 Ion Stoica CS162 ©UCB Spring 2011

Datagram Packet Switching

• Each packet is independently switched– Each packet header contains full destination address

• No resources are pre-allocated (reserved) in advance

• Leverages “statistical multiplexing” (or stat-muxing)– Essentially: “chances are good that packets from different

flows won’t all arrive at the same time, so we can get by without enough capacity for all of them at their peak transmission rate”

– Assuming independence of traffic sources, can compute probability that there is enough capacity

• Example: IP networks; postal system

Page 37: CS162 Operating Systems and Systems Programming Lecture 13 Packet Switching March 7, 2011 Ion Stoica cs162

Lec 13.373/7 Ion Stoica CS162 ©UCB Spring 2011

Statistical Multiplexing

• Use trivial time-driven simulation to illustrate statistical multiplexing

• Probabilistically generate the bandwidth of a flow at each time unit, e.g.,

– With probability 0.2, bandwidth is 6

– With probability 0.8, bandwidth is 1

• Average bandwidth, avg=0.2*6 + 0.8*1 = 2

• peak/avg = 6/2 = 3

Page 38: CS162 Operating Systems and Systems Programming Lecture 13 Packet Switching March 7, 2011 Ion Stoica cs162

Lec 13.383/7 Ion Stoica CS162 ©UCB Spring 2011

One Flow

01234567

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20

Time

Ba

nd

wid

th

peak=6

avg=2

peak / avg = 3

Page 39: CS162 Operating Systems and Systems Programming Lecture 13 Packet Switching March 7, 2011 Ion Stoica cs162

Lec 13.393/7 Ion Stoica CS162 ©UCB Spring 2011

Two Flows

0

2

4

6

8

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20

Time

Ba

nd

wid

th

agg_peak=7

agg_avg=3.75

agg_peak / agg_avg = 7/3.75 = 1.86(agg_avg = average of aggregate bandwidth)(agg_peak=maximum value of aggregate bandwidth)

Page 40: CS162 Operating Systems and Systems Programming Lecture 13 Packet Switching March 7, 2011 Ion Stoica cs162

Lec 13.403/7 Ion Stoica CS162 ©UCB Spring 2011

50 Flows

0

50

100

150

1 3 5 7 9 11 13 15 17 19

Time

Ban

dwid

th

agg_peak=135agg_avg=105.25

agg_peak / agg_avg = 7/3.75 = 135/105.25 = 1.28

Page 41: CS162 Operating Systems and Systems Programming Lecture 13 Packet Switching March 7, 2011 Ion Stoica cs162

Lec 13.413/7 Ion Stoica CS162 ©UCB Spring 2011

Statistical Multiplexing (cont’d)

• As number of flows increases, agg_peak/agg_avg decreases

– For 1000 flows, peak/avg = 2125/2009=1.057

• Q: What does this mean?

• A: Multiplexing a large enough number of flows “eliminates” burstiness

– Use average bandwidth to provision capacity, instead of peak bandwidth

– E.g., For 1000 flows» Average of aggregate bandwidth = 2,000

» Sum of bandwidth peaks = 6,000

Page 42: CS162 Operating Systems and Systems Programming Lecture 13 Packet Switching March 7, 2011 Ion Stoica cs162

Lec 13.423/7 Ion Stoica CS162 ©UCB Spring 2011

Timing of Datagram Packet Switching

Packet 1

Host 1 Host 2Node 1 Node 2

propagationdelay betweenHost 1 and Node 1

Page 43: CS162 Operating Systems and Systems Programming Lecture 13 Packet Switching March 7, 2011 Ion Stoica cs162

Lec 13.433/7 Ion Stoica CS162 ©UCB Spring 2011

Timing of Datagram Packet Switching

Packet 1

Host 1 Host 2Node 1 Node 2

propagationdelay betweenHost 1 and Node 1

transmission time of Packet 1at Host 1

Page 44: CS162 Operating Systems and Systems Programming Lecture 13 Packet Switching March 7, 2011 Ion Stoica cs162

Lec 13.443/7 Ion Stoica CS162 ©UCB Spring 2011

Packet 1

Packet 1

Timing of Datagram Packet Switching

Packet 1 processing

delay of Packet 1 at Node 2

Host 1 Host 2Node 1 Node 2

propagationdelay betweenHost 1 and Node 1

transmission time of Packet 1at Host 1

Page 45: CS162 Operating Systems and Systems Programming Lecture 13 Packet Switching March 7, 2011 Ion Stoica cs162

Lec 13.453/7 Ion Stoica CS162 ©UCB Spring 2011

Packet 1

Packet 2

Packet 3

Packet 1

Packet 2

Packet 3

Timing of Datagram Packet Switching

Packet 1

Packet 2

Packet 3

processing

delay of Packet 1 at Node 2

Host 1 Host 2Node 1 Node 2

propagationdelay betweenHost 1 and Node 1

transmission time of Packet 1at Host 1

Page 46: CS162 Operating Systems and Systems Programming Lecture 13 Packet Switching March 7, 2011 Ion Stoica cs162

Lec 13.463/7 Ion Stoica CS162 ©UCB Spring 2011

Datagram Packet Switching

Host A

Host BHost E

Host D

Host C

Node 1 Node 2

Node 3

Node 4

Node 5

Node 6 Node 7

Page 47: CS162 Operating Systems and Systems Programming Lecture 13 Packet Switching March 7, 2011 Ion Stoica cs162

Lec 13.473/7 Ion Stoica CS162 ©UCB Spring 2011

Datagram Packet Switching

Host A

Host BHost E

Host D

Host C

Node 1 Node 2

Node 3

Node 4

Node 5

Node 6 Node 7

Page 48: CS162 Operating Systems and Systems Programming Lecture 13 Packet Switching March 7, 2011 Ion Stoica cs162

Lec 13.483/7 Ion Stoica CS162 ©UCB Spring 2011

Datagram Packet Switching

Host A

Host BHost E

Host D

Host C

Node 1 Node 2

Node 3

Node 4

Node 5

Node 6 Node 7

Page 49: CS162 Operating Systems and Systems Programming Lecture 13 Packet Switching March 7, 2011 Ion Stoica cs162

Lec 13.493/7 Ion Stoica CS162 ©UCB Spring 2011

• Communication networks can be classified based on the way in which the nodes exchange information:

Taxonomy of Communication Networks

Communication Network

SwitchedCommunication

Network

BroadcastCommunication

Network

Circuit-Switched

Communication Network

Packet-Switched

Communication Network

Datagram Network

Virtual Circuit Network

A hybrid of circuits and packets; headers include a

“circuit identifier” established during a setup phase

Page 50: CS162 Operating Systems and Systems Programming Lecture 13 Packet Switching March 7, 2011 Ion Stoica cs162

Lec 13.503/7 Ion Stoica CS162 ©UCB Spring 2011

Advantages of Circuit Switching

• Guaranteed bandwidth – Predictable communication performance

• Simple abstraction– Reliable communication channel between hosts

– No worries about lost or out-of-order packets

• Simple forwarding – Forwarding based on time slot or frequency

– No need to inspect a packet header

• Low per-packet overhead– Forwarding based on time slot or frequency

– No IP (and TCP/UDP) header on each packet

Page 51: CS162 Operating Systems and Systems Programming Lecture 13 Packet Switching March 7, 2011 Ion Stoica cs162

Lec 13.513/7 Ion Stoica CS162 ©UCB Spring 2011

Disadvantages of Circuit Switching

• Wasted bandwidth– Bursty traffic leads to idle connection during silent period

– Unable to achieve gains from “statistical multiplexing”

• Blocked connections– Connection refused when resources are not sufficient

– Unable to offer “okay” service to everybody

• Connection set-up delay – No communication until the connection is set up

– Unable to avoid extra latency for small data transfers

• Network state– Network nodes must store per-connection information

– Unable to avoid per-connection storage and state

– This makes failures more disruptive!

Page 52: CS162 Operating Systems and Systems Programming Lecture 13 Packet Switching March 7, 2011 Ion Stoica cs162

Lec 13.523/7 Ion Stoica CS162 ©UCB Spring 2011

Packet-Switching vs. Circuit-Switching

• Critical advantage of packet-switching over circuit switching: Exploitation of statistical multiplexing

• Another: since routers don’t know about individual flows, when a router or link fails, it’s: Easy to fail over to a different path

• A third: easier for different parties to link their networks together because they’re not promising to reserve resources for one another

• However, packet-switching must handle congestion:– More complex routers– Harder to provide good network services (e.g., delay and

bandwidth guarantees)

Page 53: CS162 Operating Systems and Systems Programming Lecture 13 Packet Switching March 7, 2011 Ion Stoica cs162

Lec 13.533/7 Ion Stoica CS162 ©UCB Spring 2011

Summary

• Packet switching:– Store and forward: a packet is stored at routers before

being forwarded

– Each packet can take a different path

– No resource reservation: leverage statistical multiplexing

• Circuit switching:– Set-up path in advance

– Reserve resources for each connection

• Statistically multiplexing:– Peak aggregate bandwidth much lower than sum of the

peak of individual connections