Transcript Networks

Network Input & Output
CS-502 Operating Systems
Spring 2006
CS502 Spring 2006
Networks
1
Computer Networks
• Much more than can be covered in this course
• CS 513, CS 577
• Outline
• Protocol Stack
• Kinds of network connections
• Socket interface
• Textbook: Networking is spread out over multiple
chapters.
• Distributed Computing
• I/O Devices
• Memory Management
– Buffer allocation
• Real Time OS
CS502 Spring 2006
Networks
2
Computer C
Process j
Computer A
The Network
Process 1
Computer B
Process i
CS502 Spring 2006
Networks
3
Network Goal
• Allow activities on multiple computer
systems to communicate with each other
• Shared memory (or data)
• Message passing
• Remote Procedure Call
• Create abstractions that make these
(relatively) transparent
CS502 Spring 2006
Networks
4
Principal Abstraction – Socket
• Originally created in BSD Unix
• Subsequently in most OS’s
• Allows opening a connection between two
processes across network
CS502 Spring 2006
Networks
5
Network Stack
• 1983 – Open System Interconnection (OSI) 7 layer
Reference Model
– Working group of the International Standards
Organization (ISO)
– Defines seven layers
• Describe how applications
– Running upon network-aware devices
• Communicate with each other
– Most day-to-day protocols
• work on a slightly modified layer system
• E.g. TCP/ IP uses a 6-rather than a 7-layer model
CS502 Spring 2006
Networks
6
Network Stack (continued)
• Arrived at 7 layer model
–
–
–
–
Software architecture
Created where a different layer of abstraction is needed
Well defined function
Layer chosen
• with international standards being defined
– Boundaries chosen
• minimize information flow across interfaces
– Number of layers:
• Large enough
– Distinct functions need not be thrown together
– In the same layer out of necessity
• Small enough
– Architecture does not become unwieldy
CS502 Spring 2006
Networks
7
The OSI 7-layer model (in a nutshell)
Application
Layer
Presentation
Layer
Session
Layer
Transport
Layer
Network
Layer
Data Link
Layer
Physical
Layer
CS502 Spring 2006
Networks
8
The OSI 7-layer model (continued)
Application
Layer
Presentation
Layer
Session
Layer
Transport
Layer
Network
Layer
Data Link
Layer
Physical
Layer
CS502 Spring 2006
• Layer 1 – Physical Layer
– Defines the physical and electrical
characteristics of the network.
• Transmitting of raw bits over the communication
channel
• Layer 2 – Data Link Layer
– Take the raw transmission facility and
transform it into a line that appears free of
errors to layer 3.
• Error correcting coding (e.g. FEC)
• Rate Control (Slow device not overrun by high
speed device)
Networks
9
The OSI 7-layer model (continued)
Application
Layer
Presentation
Layer
Session
Layer
Transport
Layer
Network
Layer
Data Link
Layer
Physical
Layer
CS502 Spring 2006
• Layer 3 – Network Layer
–
–
–
–
Controlling the operation of the subnet
How packets are routed
Congestion Control
Accounting function (billing)
• Network Statistics
– Example - IP layer (IPv4, IPv6)
• Differences between v4, v6 source/destination
addressing
– V4 – 32 bit addressing
– V6 – 128 bit addressing
Networks
10
The OSI 7-layer model (continued)
Application
Layer
Presentation
Layer
Session
Layer
Transport
Layer
Network
Layer
Data Link
Layer
• Layer 4 – Transport Layer
Physical
Layer
CS502 Spring 2006
– Accept data from layer 5
• Split it up into smaller units if need be
• Passes these to the network layer
• Ensures that the packets all arrive correctly at the
destination
• Isolates layer 5 from changes in the underlying
hardware
– Type of service to provide
• Reliable or unreliable delivery
– True end-to-end layer
– Example - TCP or UDP
Networks
11
The OSI 7-layer model (continued)
Application
Layer
Presentation
Layer
Session
Layer
Transport
Layer
Network
Layer
Data Link
Layer
Physical
Layer
CS502 Spring 2006
• Layer 5 - Session Layer
– Allows users on different machines to establish
sessions between them
– Example SSL, RTP
• Layer 6 – Presentation Layer
– Performs certain functions that are requested
sufficiently often to warrant finding a general
solution for them rather than letting each user
solve the problem
– Example – encoding data
• Layer 7 – Application Layer
– User layer protocol, multiple protocols required
– Example – http, ftp, smtp
Networks
12
Example of OSI Model
Sending
Process
Application
Layer
Presentation
Layer
Session
Layer
Transport
Layer
Network
Layer
Data Link
Layer
Physical
Layer
CS502 Spring 2006
Receiving
Process
Data
AH
PH
Data
SH
TH
NH
DH
Application
Layer
Presentation
Layer
Session
Layer
Transport
Layer
Network
Layer
Data Link
Layer
Data
Data
Data
Data
Data
DT
Physical
Layer
Bits
Networks
13
TCP/IP – a subset
Application
Layer
Presentation
Layer
Session
Layer
Transport
Layer
Network
Layer
Data Link
Layer
HTTP, DNS, Telnet,
SMTP, FTP, SSH, etc.
Not Defined
Not Defined
TCP-UDP
IP
Device
Physical
Layer
CS502 Spring 2006
Hardware
Networks
14
Some Terms
• Packet:
– A unit of communication at Data Link layer
• IP Address:
– A four-part “number” used by Network Layer to route a
packet from one computer to another
• Port:
– A 16-bit number used within one computer to identify
who/where to send packet to
• Well-known port:
– A port with number < 1024, used by agreement for
standard services (telnet, ftp, smtp, pop, etc.)
CS502 Spring 2006
Networks
15
More Terms
• Socket:
– End point of a communication
– Usually used in pairs, one for each direction
– Comprises [IP Address: Port #]
• Connection:
– A logical linkage between pairs of sockets at
two endpoints for purposes of a particular
communication between those endpoints
CS502 Spring 2006
Networks
16
Establishing a Connection
• Process a on machine m creates a socket
• OS assigns a new port number q to that socket
• Process a attempts to open a connection to machine n:p
• p is a well-known port
• Process b on machine n is listening on p
• Receives request from m:q
• Process b forks/spawns a process/thread c to talk with m:q,
then resumes listening
• Thread/process c
• Creates a new socket r for this connection
• Replies to m:q with return address n:r
• a and c continue to communicate over this pair of sockets
until they are finished.
CS502 Spring 2006
Networks
17
Reliable Connections
• Transport layer partitions messages into packets
• TCP – Transmission Control Protocol
• Sequence number of current packet
• Sequence number of last packet received correctly
• Receiver keeps track of seq. # of packets
• Reassembles in right order
• Notify sender of missing, broken packets
• Sender keeps copy of each packet until receipt
acknowledged
• Retransmits packets if no acknowledgement
CS502 Spring 2006
Networks
18
Connection-less communication
• UDP – User Datagram Protocol
– Used when a certain number of errors can be
tolerated
CS502 Spring 2006
Networks
19
Next time
• Will assign Project 4 – a simple HTTP
server and web client
– Using sockets
CS502 Spring 2006
Networks
20