Title: Operating Systems CMPSCI 377 Networks
1Operating SystemsCMPSCI 377Networks
- Emery Berger and Mark Corner
- University of Massachusetts Amherst
2Networks and OS
- Networks and OS are strongly linked
- Want to know about networking guts?
- Take 453
- Concentrate on OS abstractions
- Multiple layers of abstraction accessible
- Pick the simplest one
- Pick the one with the functionality you need
- Raw, TCP, simple socket, RPC, RMI , etc.
3Hardware Reality
- Many kinds of networks
- Ethernet, FDDI, Cable, DSL, ATM
- Only delivery locally
- Multiple hops to get to destination
- Destination named by MAC address
- Small Messages
- Machine to Machine communication
- Unordered, unreliable, insecure
4Abstractions Provided by OS
- Network/device independence
- Routing to final destination (not the OS)
- Destinations have readable names
- Large messages
- Process-Process communication
- Ordered, reliable
- Streams of bytes or even function calls
- Security
- More (distributed file systems, shared mem)
5Communication Protocols
- Protocol agreed-upon rules for communication
- Protocol stack layers that comprise networking
software - Each layer N provides service to layer N1
6Abstraction and Protocol Layers
NFS
HTTP
Ssh
SMTP
RPC
TCP
UDP
IP
ATM
Ethernet
7UDP
- User Datagram Protocol
- Not much of an abstraction
- Lossy, unordered, individual messages
- Why use this?
8TCP
- Transmission Control Protocol
- Lowest layer typically used by systems
- Provides
- Reliability
- Ordering
- Byte Stream
- no message boundaries!
- Remember reality
- Losses, reordering, individual messages
9Process to Process
- Process to process communications
- Reality is machine to net to net to machine
- Machines have addresses
- Typically IP addresses
- Port
- endpoint sub address
- Think apartment building is IP
- Apartment number is port number
- How do I know the right port number?
10Sockets
- Standard API for network programming
- Duplex communication (2-way)
- OS Abstraction for a connection
- Can configure sockets to use UDP or TCP
- UDP best for lossy communication
- Pings, video, audio, other multimedia
- Sends datagrams (packets)
- TCP most stuff
- Sends reliable stream of bytes
11Socket communication
- Sockets (in TCP) send stream of bytes
- Multiple sends may be combinedinto one received
message - To send multiple application-level messages, must
have application level protocol - E.g., 4-bytes message type, 4-bytes message
length, plus message
12Client-side using sockets
- Creates socket
- int fd socket (AF_INET, SOCK_STREAM, 0)
- Converts hostname to IP address
- getaddrinfo (name, portStr, NULL, portNum)
- Connects to host
- connect (fd, addr, len) // from getaddrinfo
- Once connected, can send or recv
- send (fd, data, amount, 0)
- recv (fd, buf, len, 0)
13Server-side using sockets
- As before
- Create socket as before
- Convert hostname to IP address with getaddrinfo
- getaddrinfo (name, portStr, hint, addrinfo)
- Binds socket to address
- bind (fd, addr, len) // from getaddrinfo
- Listens for connection
- listen (fd, 1) // number of waiting msgs
- Accepts connection ) new socket
- int newfd accept (fd, addr, len)
- Why does this return a socket number?
14Exercise
- Lamest web server ever
- Wait for connections on localhost port 80
- Read message until first newline (\n)
- Send lthtmlgtltbodygtHello worldlt/bodygtlt/htmlgt
- Use
- int fd socket (AF_INET, SOCK_STREAM, 0)
- getaddrinfo (name, portStr, hint, addrinfo)
- bind (fd, addr, addrlen)
- int v listen (fd, 1)
- int newfd accept (fd, addr, len)
15Systems Patterns
- Two dominant forms of building systems
- Client-Server (ie. web server and client)
- Peer-to-peer (ie. BitTorrent)
- Not completely distinct
- Google is which?
- More generally Distributed Systems
16Distributed Systems
- Physically separate processors connected by one
or more communication links - no shared clock or memory
- Most systems today distributed in some way
- email, file servers, printers, remote backup,
web..
P2
P1
P4
P3
17Parallel vs. Distributed Systems
- Tightly coupled parallel processing
- Processors share clock, memory, run one OS
- Frequent communication
- Loosely coupled distributed computing
- Each processor has own memory, runs independent
OS - Infrequent communication
18Advantages
- Resource sharing
- Computational speedup
- Reliability
- Communication
- Close to some physical resource
19Advantages
- Resource sharing
- Resources need not be replicated
- Shared files
- Expensive (scarce) resources can be shared
- Poster-size color laser printers
- Present same environment to user
- Keeping files on file server
20Advantages, continued
- Computational speedup
- n processors n times computational power
- SETI_at_home
- Problems must be decomposable
- Trivial embarrassingly parallel
- Coordination communication required between
cooperating processes - Synchronization
- Exchange of results
21Advantages, continued
- Reliability
- Replication of resources provides fault tolerance
- One node crashes, user works on another one
- Performance degradation but system available
- Must avoid single point of failure
- Single, centralized component of system
- Example central file servers
22Advantages, continued
- Communication
- Users/processes on different systems can
communicate - Mail, transaction processing systems like
airlines banks, www
23Abstractions for Building
- RPC Remote Procedure Call
- Lots of systems built on this
- Children RMI, CORBA, DCOM
- Programmer doesnt see socket
- Sees blocking function call
- Difficult to get right when things fail
- Lockups, etc.
24AJAX
- Asynchronous JavaScript and XML
- Ie. google maps
- Move data asynchronously
- Ask for data, when it shows up, great.
- Interact with data locally
- Multiple data sources, display is fast
25The End
26Networks
- Goal Efficient, correct, robust message passing
between two separate nodes - Local area network (LAN) nodes in single
building, fast reliable (Ethernet) - Media twisted-pair, coax, fiber
- Bandwidth 10-1,000MB/s
- Wide area network (WAN) nodes across large
geographic area (Internet) - Media fiber, microwave links, satellite channels
- Bandwidth 1.544MB/s (T1), 45 MB/s (T3)
27Principles of Net Communication
- Data broken into packets ( 1Kb)
- Basic unit of transfer
- Computers routers control packet flow
- Road analogy
- Packets cars
- Network roads
- Computer traffic lights (intersection)
- Too many packets on shared link/node traffic jam
28Traditional Layers
- Application layer applications that use the net
- Presentation layer data format
conversion(big/little endian) - Session layer implements communication
strategy(e.g., RPC) - Transport layer reliable end-to-end
communication - Network layer routing congestion control
- Data link control layer reliable point-to-point
communication over unreliable channel - Physical layer electrical/optical signaling
across wire
29TCP/IP Protocol Stack
- Internet standard protocol stack
- TCP reliable protocol packets received in
order - UDP (user datagram protocol) unreliable
- No guarantee of delivery
30Packet Format
- All info needed to recreate original message
- Packets may arrive out of order
- need sequence number
- Data segment contains headers for higher protocol
layers application data
31Network Topologies
- Connection of nodes impacts
- Maximum average communication time
- Fault tolerance
- Expense
- Two basic topologies
- Bus (for LANs)
- Point-to-point
32Bus Network Topologies
- Bus nodes connect to common network
- Linear bus single shared link
- Nodes connect directly to each other via bus
- Inexpensive (linear in of nodes)
- Tolerant of node failures
- Ethernet LAN
33Bus Network Topologies
- Ring bus single shared circular link
- Same technology tradeoffs as linear bus
34Point-to-Point Network Topologies
- Fully-connected
- Each message takes one hop
- Node failure no effect on communication with
others - Expensive impractical for WANs
35Point-to-Point Network Topologies
- Fully-connected
- Each message takes one hop
- Node failure no effect on communication with
others - Expensive impractical for WANs
36Point-to-Point Network Topologies
- Fully-connected
- Each message takes one hop
- Node failure no effect on communication with
others - Expensive impractical for WANs
37Point-to-Point Network Topologies
- Fully-connected
- Each message takes one hop
- Node failure no effect on communication with
others - Expensive impractical for WANs
38Point-to-Point Network Topologies
2
3
1
4
- Partially connected
- Links between some, but not all nodes
- Less expensive, less tolerant to failures
- Single node failure can partition network
- Several hops requires routing
39Point-to-Point Network Topologies
I want to goto Node 4!
2
3
1
4
- Partially connected
- Links between some, but not all nodes
- Less expensive, less tolerant to failures
- Single node failure can partition network
- Several hops requires routing
40Point-to-Point Network Topologies
I want to goto Node 4!
2
3
1
4
- Partially connected
- Links between some, but not all nodes
- Less expensive, less tolerant to failures
- Single node failure can partition network
- Several hops requires routing
41Point-to-Point Network Topologies
- Tree structure network hierarchy
- Messages fast between direct descendants
- Max message cost?
- Not failure tolerant
- Any interior node fails network partitioned
42Point-to-Point Network Topologies
- Star network all nodes connect to central node
- Each message takes how many hops?
- Not failure tolerant
- Inexpensive sometimes used for LANs
43Point-to-Point Network Topologies
- One-directional ring
- Given n nodes, max hops?
- Inexpensive
- Fault-tolerant?
44Point-to-Point Network Topologies
- Bi-directional ring
- Given n nodes, max hops?
- Inexpensive
- Fault-tolerant? One node? Two?
45Point-to-Point Network Topologies
- Doubly-connected ring nodes connected to
neighbors one more distant - Given n nodes, max hops?
- Fault-tolerant?
- More expensive