lecture16-distributedcpoellab/teaching/cse30341/lecture16-handouts.pdf · distributed systems &...
TRANSCRIPT
4/20/16
1
CSE30341Opera-ngSystemPrinciples
DistributedSystems&Networking
Fundamentals
CSE30341–Opera-ngSystemPrinciples 2
Overview • Adistributedsystemiscollec-onoflooselycoupledprocessors
interconnectedbyacommunica-onsnetwork
• Processorsvariouslycallednodes,computers,machines,hosts– Siteisloca-onoftheprocessor– Generallyaserverhasaresourceaclientnodeatadifferentsitewants
touse
site C
resources
site B
client
communication
site A
server
network
4/20/16
2
CSE30341–Opera-ngSystemPrinciples 3
Reasons for Distributed Systems
• Reasons for distributed systems– Resource sharing
• Sharing and printing files at remote sites• Processing information in a distributed database• Using remote specialized hardware devices
– Computation speedup – • Load sharing or job migration
– Reliability • Detect and recover from site failure, function transfer,
reintegrate failed site
CSE30341–Opera-ngSystemPrinciples 4
Types of Distributed Operating Systems
• Network Operating Systems
• Distributed Operating Systems
4/20/16
3
CSE30341–Opera-ngSystemPrinciples 5
Network-Operating Systems • Users are aware of multiplicity of machines• Access to resources of various machines is done
explicitly by:– Remote logging into the appropriate remote machine
(telnet, ssh)– Remote Desktop (Microsoft Windows)– Transferring data from remote machines to local
machines, via the File Transfer Protocol (FTP) mechanism
• Users must change paradigms – establish a session, give network-based commands– More difficult for users
CSE30341–Opera-ngSystemPrinciples 6
Distributed-Operating Systems
• Users not aware of multiplicity of machines– Access to remote resources similar to access to local
resources• Data Migration – transfer data by transferring entire
file, or transferring only those portions of the file necessary for the immediate task
• Computation Migration – transfer the computation, rather than the data, across the system– Via remote procedure calls (RPCs)– or via messaging system
4/20/16
4
CSE30341–Opera-ngSystemPrinciples 7
Distributed-Operating Systems (Cont.)
• Process Migration – execute an entire process, or parts of it, at different sites– Load balancing – distribute processes across network
to even the workload– Computation speedup – subprocesses can run
concurrently on different sites– Hardware preference – process execution may require
specialized processor– Software preference – required software may be
available at only a particular site– Data access – run process remotely, rather than
transfer all data locally
CSE30341–Opera-ngSystemPrinciples 8
Connecting Computers
• Local Area Network (LAN): laboratory/office-scale
• Metropolitan Area Network (MAN): city-scale
• Wide Area Network (WAN): world-wide (Internet -> “collection of networks”)
4/20/16
5
CSE30341–Opera-ngSystemPrinciples 9
Connecting Computers • Sites in the system can be physically connected in
a variety of ways; they are compared with respect to the following criteria:– Installation cost - How expensive is it to link the
various sites in the system?– Communication cost - How long does it take to
send a message from site A to site B?– Reliability - If a link or a site in the system fails, can
the remaining sites still communicate with each other?• The various topologies are depicted as graphs
whose nodes correspond to sites– An edge from node A to node B corresponds to a
direct connection between the two sites
CSE30341–Opera-ngSystemPrinciples 10
NetworkTopology
STAR
RING
MESH
BUS
4/20/16
6
CSE30341–Opera-ngSystemPrinciples 11
Examples• Ethernet:
– popular, relatively inexpensive, easy-to-install LAN architecture
– uses the CSMA/CD media access control – data transmission normally occurs at 100 Mbps (10Mbps in
the early forms and 10Gbps in the most recent forms) – partially described in the IEEE 802.3 specification
• Wi-Fi: – popular wireless LAN architecture – uses a modified version of the CSMA/CA protocol – partially described in the IEEE 802.11 specification
CSE30341–Opera-ngSystemPrinciples 12
Local-Area Network
LAN Switch
Firewall
Router WAN Link
LAN WAN
4/20/16
7
CSE30341–Opera-ngSystemPrinciples 13
Local-Area Network
CSE30341–Opera-ngSystemPrinciples 14
Wide-Area Network
communicationprocessor
communicationsubsystem
H
H
H
H
H
user processes
user processes
network host
network host
host operating system
host operating system
CP
CP
CPCP
4/20/16
8
CSE30341–Opera-ngSystemPrinciples 15
MediumAccessControl(MAC)
• Responsiblefordecidingwhen&howtotransmitframesoveranetwork(“channelaccessproblem”)– Ethernetbus:computersconnecttothesamewire,i.e.,twocomputerscould“talk”atthesame-me:collision!
• MACprotocolisveryimportantfor“quality”ofcommunica-ons(successfultransmissions,reliabletransmissions,highthroughput,lowlatency,fairness,…)
A CB
CSE30341–Opera-ngSystemPrinciples 16
SimultaneousTransmissions
• Simplestrategy:– Ignoreongoingcommunica-onsandjusttransmitany-me:
• largenumberofcollisions• lowthroughput
A CB
collision
4/20/16
9
CSE30341–Opera-ngSystemPrinciples 17
“Smarter”Approach
• Listenbeforeyoutalk!• CarrierSenseMulJpleAccess(CSMA)
– “Sense”(listen)carrier(“isanyoneelsetalkingrightnow?”)
– If“busy”:wait;if“idle”:transmit
A CB
Don’ttransmit
Cancollisionss-lloccur?
CSE30341–Opera-ngSystemPrinciples 18
CSMA/CD
• CD=CollisionDetec-on• How?Keeplisteningtochannelwhiletransmifng!
• Iftransmigedsignalandsensedsignaldiffer:– Collisiondetected– Aborttransmission– Jamchannel:sendrandombitsequenceto“inform”othercomputers
(a)
(b)
(c)
A B
A B
A B
A B
(d)
4/20/16
10
CSE30341–Opera-ngSystemPrinciples 19
CollisionDetec-on(Wireless)
A C D B
CSE30341–Opera-ngSystemPrinciples 20
IEEE802.11(CSMA/CA)
CTS = Clear To Send
RTS = Request To Send
D
Y
S
M
K
RTS
CTS
X
CA=CollisionAvoidance
4/20/16
11
CSE30341–Opera-ngSystemPrinciples 21
Communication Structure• Naming and name resolution - How do two
processes locate each other to communicate?
• Routing strategies - How are messages sent through the network?
• Connection strategies - How do two processes send a sequence of messages?
• Contention - The network is a shared resource, so how do we resolve conflicting demands for its use?
CSE30341–Opera-ngSystemPrinciples 22
Naming and Name Resolution
• Name systems in the network• Address messages with the process-id• Identify processes on remote systems by
<host-name, identifier> pair
• Domain name system (DNS) – specifies the naming structure of the hosts, as well as name to address resolution (Internet)
4/20/16
12
CSE30341–Opera-ngSystemPrinciples 23
DNS
Nameserver
Mailprogram
User
TCP
IP
2cs.princeton.edu
192.12.69.53
user @ cs.princeton.edu1
192.12.69.5 4
192.12.69.5 5
CSE30341–Opera-ngSystemPrinciples 24
Routing Strategies• Fixed routing - A path from A to B is specified in
advance; path changes only if a hardware failure disables it– Since the shortest path is usually chosen, communication
costs are minimized– Fixed routing cannot adapt to load changes– Ensures that messages will be delivered in the order in
which they were sent• Virtual routing- A path from A to B is fixed for the
duration of one session. Different sessions involving messages from A to B may have different paths – Partial remedy to adapting to load changes– Ensures that messages will be delivered in the order in
which they were sent
4/20/16
13
CSE30341–Opera-ngSystemPrinciples 25
Routing Strategies• Dynamic routing - The path used to send a message form
site A to site B is chosen only when a message is sent– Usually a site sends a message to another site on the link least
used at that particular time– Adapts to load changes by avoiding routing messages on heavily
used path– Messages may arrive out of order
• This problem can be remedied by appending a sequence number to each message
– Most complex to set up• Tradeoffs mean all methods are used
– UNIX provides ability to mix fixed and dynamic– Hosts may have fixed routes and gateways connecting networks
together may have dynamic routes
CSE30341–Opera-ngSystemPrinciples 26
Routing Strategies• Router is communications processor
responsible for routing messages• Must have at least 2 network connections• Maybe special purpose or just function
running on host• Checks its tables to determine where
destination host is, where to send messages– Static routing – table only changed manually– Dynamic routing – table changed via routing
protocol
4/20/16
14
CSE30341–Opera-ngSystemPrinciples 27
Routing Strategies
• Messages vary in length – simplified design breaks them into packets (or frames, or datagrams)
• Connectionless message is just one packet– Otherwise need a connection to get a multi-
packet message from source to destination
CSE30341–Opera-ngSystemPrinciples 28
Connection Strategies• Circuit switching - A permanent physical link is established
for the duration of the communication (i.e., telephone system)• Message switching - A temporary link is established for the
duration of one message transfer (i.e., post-office mailing system)
• Packet switching - Messages of variable length are divided into fixed-length packets which are sent to the destination– Each packet may take a different path through the network– The packets must be reassembled into messages as they arrive
• Circuit switching requires setup time, but incurs less overhead for shipping each message, and may waste network bandwidth– Message and packet switching require less setup time, but incur
more overhead per message
4/20/16
15
CSE30341–Opera-ngSystemPrinciples 29
ISOOSIModel
CSE30341–Opera-ngSystemPrinciples 30
Communica-onProtocol• Layer 1: Physical layer – handles the mechanical
and electrical details of the physical transmission of a bit stream
• Layer 2: Data-link layer – handles the frames, or fixed-length parts of packets, including any error detection and recovery that occurred in the physical layer
• Layer 3: Network layer – provides connections and routes packets in the communication network, including handling the address of outgoing packets, decoding the address of incoming packets, and maintaining routing information for proper response to changing load levels
4/20/16
16
CSE30341–Opera-ngSystemPrinciples 31
Communica-onProtocol• Layer 4: Transport layer – responsible for low-level network
access and for message transfer between clients, including partitioning messages into packets, maintaining packet order, controlling flow, and generating physical addresses
• Layer 5: Session layer – implements sessions, or process-to-process communications protocols
• Layer 6: Presentation layer – resolves the differences in formats among the various sites in the network, including character conversions, and half duplex/full duplex (echoing)
• Layer 7: Application layer – interacts directly with the users, deals with file transfer, remote-login protocols and electronic mail, as well as schemas for distributed databases
CSE30341–Opera-ngSystemPrinciples 32
WhatisIP,TCP,UDP?
• InternetProtocol(IP):– Takeyourmessageandslapa“header”onit(“packet”)
– What’sinaheader?• Senderaddress:112.44.44.23• Receiveraddress:147.12.68.211• Routersuseittofigureoutwhattodowithit(seenextslideforrouters)
– WhatdoesIPdo:• mostlyaddressing• usedbyrouters
DataHeader
4/20/16
17
CSE30341–Opera-ngSystemPrinciples 33
Internet+Routers• Router:linkspartsofalargernetwork
together• Rou-ngusingtables:
– “129.74”belongstoUniversityofNotreDame
– Howisthetablebuilt?• Routerstalktoeachothertoexchangewhat
theyknowabouttheworld(usingICMP=InternetControlMessageProtocol)
– Whyonlyrememberpartsofanetwork?• 32-bitaddressconsistsofnetworkaddress
andcomputeraddress• ClassA,B,Cnetworks:8/16/24bitsfor
network,restforcomputers– Example:Cnetwork127.45.20.21:127.45.20is
networkaddress,21iscomputeraddress(outof255computers)
• Rou-ngisbasedon(independent)packets!(comparephonecallvs.USPS)
CSE30341–Opera-ngSystemPrinciples 34
UDP=UserDatagramProtocol
• Slaponanotherheader• Addsmoreaddressing:“ports”
– IPaddresstellyouwhichcomputer– Portstellyouwhichapplica-ononthatcomputer– Example:awebserver“listens”torequestsonport80– Webbrowser:hgp://www.google.com:80=hgp://216.58.216.100:80
• HTTP:HyperTextTransferProtocol• :80:op-onal
– Unreliable!• Packetscangetlost;packetscanarriveoutoforder
DataUDPHeaderIPHeader
“IPData”
4/20/16
18
CSE30341–Opera-ngSystemPrinciples 35
TCP=TransmissionControlProtocol• Reliableprotocol• Addsports(justlikeUDP),butalsoprovides:
– In-orderdeliveryofpackets(usingsequencenumbers)– Reliabledelivery:usingacknowledgment(ACK)packets
– Flowcontrol:• controloftrafficbetweensenderandreceiver• receivercanthroglesendertoavoidgefngpacketstoofast• explicit:“adver-sedwindow”inACKpacket(howmanymorebytes)
– CongesJoncontrol:• controloftrafficflowintothenetwork• routerscanthroglesendertoavoidgefngtoomanypackets• implicit:watchACKs->missingACKs=routeroverload
Packet
ACK
CSE30341–Opera-ngSystemPrinciples 36
Connection Establishment
Active participant(client)
Passive participant(server)
SYN, SequenceNum =x
ACK, Acknowledgment =y+1
Acknowledgment =x+1SYN+ACK, SequenceNum=y,
4/20/16
19
CSE30341–Opera-ngSystemPrinciples 37
Connection Termination First participant Second participant
FIN, SequenceNum = x
ACK, Acknowledgment =y+1
ACK, Acknowledgment=x+1,
FIN, SequenceNum = y,
Acknowledgment = x+1
CSE30341–Opera-ngSystemPrinciples 38
UDPvsTCP• TCP:
– typicalchoiceofmostapplica-on– donotwanttolosedata,out-of-orderarrival,etc.– email,webtraffic,financialtransac-ons,etc.
• UDP:– canbe“faster”
• noflow/conges-oncontrol“slowingdown”traffic• noretransmissions• goodfor“real--me”traffic
– out-of-orderarrival:canalso“reorder”atapplica-onlevel– lossofdata:canbeacceptable
• missingframesinvideo/audiostream