Upload
jody-ford
View
213
Download
0
Tags:
Embed Size (px)
Citation preview
Spring 2004
What is an OS? Machine/resource manager.
Physical Devices
MicroarchitectureInstruction Set Architecture
Operating System
Compilers, Editors, etc.
Hardware
Application programs
Spring 2004
OS as extended machine… Top-down view. Layer of software that hides hardware. Provides programmer easier
instructions. E.g., read block from file.
(Part of) the OS runs in supervisor (privileged) mode: can execute priviledged instructions (e.g., access to physical decices through drivers).
Spring 2004
OS as resource manager Bottom-up view. Provides orderly and controlled
allocation of resources. Provides (“concurrent”) programs
(fair) access to resources (processor, disk, printer).
Time (e.g., CPU) and space (e.g., memory) multiplexing.
Spring 2004
First generation: 1945-1955 Vacuum tubes: machines took
whole rooms! Machine language programming
(plugboard wiring). No OS.
Spring 2004
Second generation: 1955-1965
Transistors made computers commercially viable.
Builders, operators, users. Mainframes: multimillion dollar
machines. Punch cards, input and output
tapes. Batch systems.
Spring 2004
Third generation: 1965-1980
ICs. Multiprogramming.
Machine shared by “concurrent” programs. Memory partitions hold multiple jobs.
Timesharing. Multiprogramming still batch processing:
scientific computation and commercial data processing.
Cheap terminals: interactive use. Interactive service + batch processing.
Spring 2004
Fourth generation: 1980-… High-scale circuit integration. Computer miniaturization. Mainframes -> minicomputers ->
microcomputers or PCs. PC OSs: CP/M, DOS, MS-DOS. GUI-based OSs: UNIX-based, MS
Windows-based, MAC OS, …
Spring 2004
Modern OSs Mainframe OSs: IBM’s OS/390,
DEC’s VMS. Server OSs: Solaris, FreeBSD, etc. PC OS: Linux, MacOS, Windows… Real-time OSs: VxWorks. Embedded OSs: Linux, PalmOS,
Windows CE Smart card OSs
Spring 2004
Processes Process: program in execution.
Address space: memory usable by program (text, data, stack).
State: registers. OS uses process table to keep
track of processes. Processes can create other (child)
processes.
Spring 2004
Inter-Process Communication (IPC) Shared memory.
Processes communicate/synchronize through a shared data item.
Message passing. Processes communicate via
messages.
Spring 2004
Shared Memory Processes must access shared data
in a mutual exclusive way. Primitives:
Semaphores: Dijkstra(1965) P(S) and V(S) operations. Atomic (indivisible) operations.
(Conditional) Critical Regions Monitors
Spring 2004
Message Passing Processes
communicate/synchronize by sending/receiving messages.
Primitives: Send(message), receive(message).
Issues: Synchronous versus asynchronous. Reliable versus unreliable.
Spring 2004
Distributed Shared Memory Sharing data among computers
that don’t share physical memory. DSM provides shared memory
abstraction. Read- and write-like primitives.
Needs message passing to convey updates among physically disjoint processing elements.
Spring 2004
Deadlocks Shared data/resource may lead to
deadlock: processes get “stuck”. Example: v is using r1 and
requests r2; w is using r2 and requests r1.
v w
Spring 2004
Memory Management Share memory among several
processes. Monoprogramming: memory sharing
between OS and program (embedded OSs).
Multiprogramming: multiple processes (partially or totally) in memory. Swapping. Virtual memory: paging.
Spring 2004
I/O OS I/O subsystem manages I/O devices.
Device-dependent (device drivers) or independent.
File system: File as an abstraction. Basic operations: create, delete, read, write.
Hierarchical file systems. Dynamically attach tree branches (e.g., mount system call in UNIX).
Access control: permissions.
Spring 2004
System Calls Interface between OS and user program: set
of system calls. E.g., access a file, create a process, etc.
Like making a special procedure call. System calls executed by kernel. Calling program pushes parameters onto stack;
calls library; library routine (same name as system call) executes TRAP, switching to kernel mode; OS handles call; returns control to library; library returns to user program.
Example system calls for file system open, close, read, write, mkdir, rmdir.
Spring 2004
System CallsUser-level process
Kernel
Physical machine
System callto access physical resources
System call: implemented by hardware interrupt (trap) which puts processor in supervisor mode and kernel addressspace; executes kernel-supplied handler routine (device driver)executing with interrupts disabled.
Spring 2004
Kernels Executes in supervisor mode.
Privilege to access machine’s physical resources.
User-level process: executes in “user” mode. Restricted access to resources. Address space boundary restrictions.
Spring 2004
Kernel Functions Memory management.
Address space allocation. Memory protection.
Process management. Process creation, deletion. Scheduling.
Resource management. Device drivers/handlers.
Spring 2004
Kernel and Distributed Systems Inter-process communication: RPC,
MP, DSM. Distributed (Networked) File
systems. Some parts may run as user-level
and some as kernel processes.
Spring 2004
What are protocols? Set of rules governing communication
between network elements (applications, hosts, routers).
Protocols define: Format and order of messages. Actions taken on receipt of a
message. Protocols are hard to design
We need design guidelines!
Spring 2004
Protocol stack
Host Host
Application
Transport
Network
Link
User A User BTeleconferencing
Layering: technique to simplify complex systems
Peers
Spring 2004
Layering Characteristics Each layer relies on services from
layer below and exports services to layer above.
Interface defines interaction, Hides implementation - layers can
change without disturbing other layers (black box).
Spring 2004
OSI Model: 7 Protocol Layers
Physical: how to transmit bits Data link: how to transmit frames Network: how to route packets hop2hop Transport: how to send packets end2end Session: how to tie flows together Presentation: byte ordering, security Application: everything else!
Spring 2004
Layering Functionality Reliability Flow control Fragmentation Multiplexing Connection setup (handshaking) Addressing/naming (locating
peers)
Spring 2004
Example: Transport layer First end-to-end layer. End-to-end state. May provide reliability, flow and
congestion control.
Spring 2004
Example: Network Layer Point-to-point communication. Network and host addressing. Routing.
Spring 2004
Internetworking Interconnection of 2 or more
networks forming an internetwork, or internet. LANs, MANs, and WANs.
Different networks mean different protocols. TCP/IP, IBM’s SNA, DEC’s DECnet,
ATM, Novell and AppleTalk.
Spring 2004
TCP/IP
• TCP/IP is the most widely used internetworking protocol suite– Initially funded through ARPA.– Picked up by NSF.– Used in the Internet.
• Other internetworking protocols exist but are less used– Example: AppleTalk, X.25, etc.
Spring 2004
The Internet Protocol: IP Glues Internet together. Common network-layer protocol
spoken by all Internet participating networks.
Best effort datagram service: No reliability guarantees. No ordering guarantees.
Spring 2004
IP (cont’d)
• IP is responsible for datagram routing.• Important: each datagram is routed
independently!– Two different datagrams from same source to same
destination can take different routes!– Why?– Implications?
Spring 2004
IP (cont’d)
• IP provides a best effort delivery mechanism– Does not guarantee to prevent duplicate
datagrams, delayed and out-of-order delivery, corruption of data or datagram loss
• Reliable delivery is provided by the transport layer, not the network layer (IP)
• Network layer (IP) can detect and report errors without actually fixing them
Spring 2004
The Internet Protocol
Router Router
Host Host
Application
Transport
Network
IP IPIP IP
Network
Spring 2004
Datagrams Transport layer breaks data
streams into datagrams which are transmitted over Internet, possibly being fragmented.
When all datagram fragments arrive at destination, reassembled by network layer and delivered to transport layer at destination host.
Spring 2004
IP Datagram Format IP datagram consists of header and
data (or payload). Header:
20-byte fixed (mandatory) part. Variable length optional part.
Spring 2004
IP Versions IPv4: IP version 4.
Current, predominant version. 32-bit long addresses.
IPv6: IP version 6. Evolution of IPv4. Longer addresses (16-byte long).
Spring 2004
Encapsulation
• Each datagram is encapsulated within a data link layer frame– The whole datagram is placed in the data area of
the frame.– The data link layer addresses for source and
destination included in the frame header.
Spring 2004
Encapsulation Across Multiple Hops
• Each router in the path from source to destination:– Decapsulates datagram from incoming frame.– Forwards datagram - determines next hop.– Encapsulate datagram in outgoing frame.
Spring 2004
Maximum Transfer Unit
• Each data link layer technology specifies the maximum size of a frame.– Called the Maximum Transfer Unit (MTU).
• Ethernet: 1,500 bytes.• Token Ring: 2048 or 4096 bytes.
• What happens when large packet wants to travel through network with smaller MTU?• Maximum payloads (data portion of datagram)
range from 48 bytes (ATM cells) to 64Kbytes (IP packets).
Spring 2004
Fragmentation
• Another solution (used by IP): fragmentation.• Gateways break packets into fragments to fit the
network’s MTU; each sent as separate datagram.• Gateway on the other side have to reassemble
fragments into original datagram.
Spring 2004
Keeping Track of Fragments
Fragments must be numbered so that original data stream can be reconstructed.
Define elementary fragment size that can pass through every network.
When packet fragmented, all pieces equal to elementary fragment size, except last one (may be smaller).
Datagram may contain several fragments.
Spring 2004
Universal Addressing
• One key aspect of internetworks is unique addresses.
• Sending host puts destination internetworking address in the packet.
• Destination addresses can be interpreted by any intermediate router/gateway.
• Router/gateway examines address and forwards packet on to the destination.
Spring 2004
IP Addresses• Each machine on the Internet has a unique IP address.• The IP address is different from the “physical” /“MAC”
address.– The “physical address” is the address of a computer
(actually, of a NIC) in the LAN.• It is only know within the LAN.
– The IP address is a universal address.
– When a packet arrives in a LAN, there needs to be a conversion from IP to MAC address (local “address resolution”).
Spring 2004
IP Addresses (cont’d)
• An IP address is represented by a binary number with 32 bits (in IPv4).– Meaning that there are around 4 billion
addresses.– Often IP addresses are represented in “dotted
decimal”, such as 128.114.144.4.• Each group of numbers can go from 0 to 255.
Spring 2004
IP Address Organization
• Each IP address is divided into a prefix and a suffix– Prefix identifies network to which computers
are attached.– Suffix identifies computers within that
network.
Spring 2004
Network and Host Numbers
• Every network in a TCP/IP internet is assigned a unique network number.
• Each host on a specific network is assigned a host address that is unique within that network.
• Host’s IP address is the combination of the network number (prefix) and host address (suffix).
• Assignment of network numbers must be coordinated globally; assignment of host addresses can be managed locally.
Spring 2004
IP Address Format
• IP address are 32 bits long.• There are different classes of addresses,
corresponding to different subdivisions of the 32 bits into prefix and suffix.– Some address classes have large prefix, small
suffix.• Many such networks, few hosts per network.
– Other address classes have small prefix, large suffix.
• Few such networks, many hosts per network.
Spring 2004
IP Address Format (cont’d)• How can we recognize to which class an IP
address belongs to?– Look at the first 4 bits!
Spring 2004
IP Address Format (cont’d)
• Class A, B and C are primary classes.– Used for ordinary addressing.
• Class D is used for multicast, which is a limited form of broadcast.– Internet hosts join a multicast group.– Packets are delivered to all members of the
group.– Routers manage delivery of single packets
from source to all members of multicast group.
• Class E is reserved.
Spring 2004
IP Addresses (cont’d)
• Another way to determine the address class is by looking at the first group of numbers in the dotted decimal notation
Spring 2004
Understanding IP Addresses
• Examples:– 10.0.0.37 (class A)
– 128.10.0.1 (class B)
– 192.5.48.3 (class C)
Spring 2004
IP addresses: how to get one?
• ICANN (Internet Corporation for Assigned Names and Numbers) coordinate IP address assignment.
• How does host get its IP address in the network? 2 possibilities:– 1: Hard-coded by system administrator in a file
inside the host.– 2: DHCP: “Dynamic Host Configuration Protocol”
• Dynamically get address: “plug-and-play”.
Spring 2004
DHCP
• DHCP allows a computer to join a new network and automatically obtain an IP address The network administrator establishes a pool of addresses for DHCP to assign.
• When a computer boots, it broadcasts a DHCP request to which a server sends a DHCP reply.
Spring 2004
DHCP (Cont’d)• DHCP allows non-mobile computers that run
server software to be assigned a permanent address (won’t change when the computer reboots).– The permanent address actually needs to be
re-negotiated after a certain period of time.
Spring 2004
The Internet Transport Protocols: TCP and UDP UDP: user datagram protocol (RFC
768). Connection-less protocol.
TCP: transmission control protocol (RFCs 793, 1122, 1323). Connection-oriented protocol.
Spring 2004
UDP Provides connection-less, unreliable
service. No delivery guarantees. No ordering guarantees. No duplicate detection.
Low overhead. No connection establishment/teardown.
Suitable for short-lived connections. Example: client-server applications.
Spring 2004
TCP Reliable end-to-end communication. TCP transport entity:
Runs on machine that supports TCP. Interfaces to the IP layer. Manages TCP streams.
Accepts user data, breaks it down and sends it as separate IP datagrams.
At receiver, reconstructs original byte stream from IP datagrams.
Spring 2004
TCP Reliability Reliable delivery.
ACKs. Timeouts and retransmissions.
Ordered delivery.
Spring 2004
TCP Service Model 1 Obtained by creating TCP end points.
Example: UNIX sockets. Socket number or address: IP address + 16-
bit port number (TSAP). Multiple connections can terminate at same
socket. Connections identified by socket ids at both
ends. Port numbers below 1024: well-known ports
reserved for standard services. List of well-known ports in RFC 1700.
Spring 2004
TCP Service Model 2 TCP connections are full-duplex
and point-to-point. Byte stream (not message
stream). Message boundaries are not
preserved e2e. A B C D
4 512-byte segments sent asseparate IP datagrams
A B C D
2048 bytes of data deliveredto application in single READ
Spring 2004
TCP Byte Stream When application passes data to TCP, it
may send it immediately or buffer it. Sometimes application wants to send
data immediately. Example: interactive applications. Use PUSH flag to force transmission. TCP could still bundle PUSH data together
(e.g., if it cannot transmit it right away). URGENT flag.
Also forces TCP to transmit at once.
Spring 2004
TCP Protocol Overview 1 TCP’s TPDU: segment.
20-byte header + options. Data.
TCP entity decides the size of segment. 2 limits: 64KByte IP payload and MTU. Segments that are too large are
fragmented. More overhead by addition of IP header.
Spring 2004
TCP Protocol Overview 2 Sequence numbers.
Reliability, ordering, and flow control. Assigned to every byte. 32-bit sequence numbers.
Spring 2004
TCP Connection Setup 3-way handshake.
Host 1 Host 2SYN (SEQ=x)
SYN(SEQ=y,ACK=x+1)
(SEQ=x+1, ACK=y+1)
Spring 2004
TCP Connection Release 2 Graceful release:
Each side of the connection released independently.
Either side send TCP segment with FIN=1. When FIN acknowledged, that direction is shut down
for data. Connection released when both sides shut down.
4 segments: 1 FIN and 1 ACK for each direction; 1st. ACK+2nd. FIN combined.
Spring 2004
TCP Connection Release 3 Timers to avoid 2-army problem.
If response to FIN not received within 2*MSL (maximum segment lifetime), FIN sender releases connection.
After connection released, TCP waits for 2*MSL (e.g., 120 sec) to ensure all old segments have aged.
Spring 2004
TCP Transmission Sender process initiates connection. Once connection established, TCP
can start sending data. Sender writes bytes to TCP stream. TCP sender breaks byte stream into
segments. Each byte assigned sequence number. Segment sent and timer started.
Spring 2004
TCP Transmission (cont’d) If timer expires, retransmit segment.
After retransmitting segment for maximum number of times, assumes connection is dead and closes it.
If user aborts connection, sending TCP flushes its buffers and sends RESET segment.
Receiving TCP decides when to pass received data to upper layer.
Spring 2004
TCP Flow Control Sliding window.
Receiver’s advertised window. Size of advertised window related to
receiver’s buffer space. Sender can send data up to receiver’s
advertised window.
Spring 2004
TCP Flow Control: Example2K;SEQ=0
ACK=2048; WIN=2048
2K; SEQ=2048
ACK=4096; WIN=0
ACK=4096; WIN=2048
1K; SEQ=4096
App. writes 2K of data
4K
2K
0
App. reads 2K of data
2K
1K
App. does 3K write
Senderblocked
Sendermay send upto 2K
Spring 2004
TCP Flow Control: Observations TCP sender not required to
transmit data as soon as it comes in from application. Example: when first 2KB of data
comes in, could wait for more data since window is 4KB.
Receiver not required to send ACKs as soon as possible. Wait for data so ACK is piggybacked.
Spring 2004
Congestion Control Why do it at the transport layer?
Real fix to congestion is to slow down sender.
Use law of “conservation of packets”. Keep number of packets in the network
constant. Don’t inject new packet until old one leaves.
Congestion indicator: packet loss.
Spring 2004
TCP Congestion Control Like, flow control, also window
based. Sender keeps congestion window
(cwin). Each sender keeps 2 windows:
receiver’s advertised window and congestion window.
Number of bytes that may be sent is min(advertised window, cwin).
Spring 2004
TCP Congestion Control (cont’d) Slow start [Jacobson 1988]:
Connection’s congestion window starts at 1 segment.
If segment ACKed before time out, cwin=cwin+1.
As ACKs come in, current cwin is increased by 1.
Exponential increase.
Spring 2004
TCP Congestion Control (cont’d) Congestion Avoidance:
Third parameter: threshold. Initially set to 64KB. If timeout, threshold=cwin/2 and
cwin=1. Re-enters slow-start until
cwin=threshold. Then, cwin grows linearly until it
reaches receiver’s advertised window.
Spring 2004
TCP Retransmission Timer When segment sent,
retransmission timer starts. If segment ACKed, timer stops. If time out, segment retransmitted
and timer starts again.
Spring 2004
How to set timer? Based on round-trip time: time
between a segment is sent and ACK comes back.
If timer is too short, unnecessary retransmissions.
If timer is too long, long retransmission delay.
Spring 2004
Jacobson’s Algorithm 1 Determining the round-trip time:
TCP keeps RTT variable. When segment sent, TCP measures
how long it takes to get ACK back (M). RTT = alpha*RTT + (1-alpha)M. alpha: smoothing factor; determines
weight given to previous estimate. Typically, alpha=7/8.
Spring 2004
Jacobson’s Algorithm 2 Determining timeout value:
Measure RTT variation, or |RTT-M|. Keeps smoothed value of cumulative
variation D=alpha*D+(1-alpha)|RTT-M|.
Alpha may or may not be the same as value used to smooth RTT.
Timeout = RTT+4*D.
Spring 2004
File Transfer
Sharing remote files: “on-line” access versus “file transfer”.
“On-line” access transparent access to shared files, e.g., distributed file system.
Sharing through file transfer: user copies file then operates on it.
Spring 2004
The Web WWW, or the world-wide web is a
resource discovery service. Resource space is organized
hierarchically, and resources are linked to one another according to some relation.
Hypertext organization: link “granularity”; allows links within documents.
Graphical user interface.
Spring 2004
The Client Side Users perceive the Web as a vast
collection of information. Page is the Web’s information transfer unit. Each page may contain links to other
pages. Users follow links by clicking on them which
takes them to the corresponding page. This process can go on indefinetly,
traversing several pages located in different places.
Spring 2004
The Browser Program running on client that retrieves
and displays pages. Interacts with server of page. Interprets commands and displays page.
Examples: Mosaic, Netscape’s Navigator and Communicator, Microsoft Internet Explorer.
Other features: back, forward, bookmark, caching, handle multimedia objects.
Spring 2004
Domain Name System (DNS) Basic function: translation of
names (ASCII strings) to network (IP) addresses and vice-versa.
Example: zephyr.isi.edu <-> 128.9.160.160
Spring 2004
How is it used? Client-server model.
Client DNS (running on client hosts), or resolver.
Application calls resolver with name. Resolver contacts local DNS server
(using UDP) passing the name. Server returns corresponding IP
address.
Spring 2004
Name Resolution 1 Application wants to resolve name. Resolver sends query to local name server.
Resolver configured with list of local name servers.
Select servers in round-robin fashion. If name is local, local name server returns
matching authoritative RRs. Authoritative RR comes from authority
managing the RR and is always correct. Cached RRs may be out of date.
Spring 2004
Name Resolution 2 If information not available locally
(not even cached), local NS will have to ask someone else. It asks the server of the top-level
domain of the name requested.
Spring 2004
Electronic Mail Non-interactive.
Deferred mail (e.g., destination temporarily unavailable).
Spooling: Message delivery as background
activity. Mail spool: temporary storage area
for outgoing mail.
Spring 2004
Mail system
Userinterface
Usersends mail
Userreads mail
Outgoingmailspool
Mailboxes incomingmail
Client(send)
Server(receive)
TCPconnection(outgoing)
TCPconnection(incoming)
Spring 2004
Observations When user sends mail, message
stored is system spool area. Client transfer runs on background. Initiates transfer to remote
machine. If transfer succeeds, local copy of
message removed; otherwise, tries again later (30 min) for a maximum interval (3 days).
Spring 2004
Telnet basic operation When user invokes telnet, telnet client
on user machine establishes TCP connection to specified server.
TCP connection established; user’s keystrokes sent to remote machine.
Telnet server sends back response, echoed on user’s terminal.
Telnet server can accept multiple concurrent connections.