networks & communication (continued)

22
Networks & Commun ication CS-502 Fall 2007 1 Networks & Communication (continued) CS-502 Operating Systems (Slides include materials from Operating System Concepts, 7 th ed., by Silbershatz, Galvin, & Gagne, Modern Operating Systems, 2 nd ed., by Tanenbaum, and Distributed Systems: Principles & Paradigms, 2 nd ed. By Tanenbaum and Van Steen)

Upload: reginald-ethelbert

Post on 01-Jan-2016

37 views

Category:

Documents


1 download

DESCRIPTION

Networks & Communication (continued). CS-502 Operating Systems - PowerPoint PPT Presentation

TRANSCRIPT

Networks & Communication

CS-502 Fall 2007 1

Networks & Communication(continued)

CS-502Operating Systems

(Slides include materials from Operating System Concepts, 7th ed., by Silbershatz, Galvin, & Gagne, Modern Operating Systems, 2nd ed., by Tanenbaum, and Distributed Systems: Principles & Paradigms, 2nd

ed. By Tanenbaum and Van Steen)

Networks & Communication

CS-502 Fall 2007 2

Principal Abstraction – Socket

• Originally created in BSD Unix• Now, part of most operating systems

• Allows opening a connection between two processes across network

• Connection: – a serial conversation between two end points

• e.g., processes, threads, tasks on different machines– organized as a sequence of messages or datagrams– distinct from all other connections

• One of the four principal abstractions provided by most modern operating systems

Networks & Communication

CS-502 Fall 2007 3

Definition — Protocol

• Formal set of rules that govern the formats, contents, and meanings of messages from computer to computer, process to process, etc.

• Must be agreed to by all parties to a communication

• May be defined in terms of other protocols

Networks & Communication

CS-502 Fall 2007 4

The OSI 7-layer model(in a nutshell)

Physical Layer

Data LinkLayer

NetworkLayer

TransportLayer

SessionLayer

PresentationLayer

ApplicationLayer

Silbershatz, §§16.6-16.7

Networks & Communication

CS-502 Fall 2007 5

Annotated OSI 7-Layer Stack

Silbershatz, page 630

Networks & Communication

CS-502 Fall 2007 6

Summary — OSI 7-layer model

Physical Layer

Data LinkLayer

NetworkLayer

TransportLayer

SessionLayer

PresentationLayer

ApplicationLayer

SendingProcess

Physical Layer

Data LinkLayer

NetworkLayer

TransportLayer

SessionLayer

PresentationLayer

ApplicationLayer

ReceivingProcess

Bits

DH Data DT

NH Data

TH Data

SH Data

PH Data

AH Data

Data

Networks & Communication

CS-502 Fall 2007 7

Circular Definition

• Socket:– End point of a connection– 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

– i.e., a serial conversation between endpoints• Usually two-way

Networks & Communication

CS-502 Fall 2007 8

Connection

• The backbone of most message-oriented communication protocols

• Each party retains knowledge of the other• Each party retains information about state of the

other (vis a vis the protocol itself)• Each party “knows” if connection is broken• …

• Note: some popular protocols are “connection-less” – one side retains no state information about other side

Networks & Communication

CS-502 Fall 2007 9

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 a process or spawns a thread c to talk with m:q, then resumes listening on p

• 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.

Networks & Communication

CS-502 Fall 2007 10

Typical Client-Server Connection

• Create socket • On server side

• Bind • I.e., connect socket to port # (usually well-known port)

• Listen• Sit and wait for a communication to come in

• Accept• Create new socket for purpose of responding to this caller

Networks & Communication

CS-502 Fall 2007 11

Notes

• Responder to request for connection does not have to be the original server machine

• Delegate workload to other server systems

• Systems often include a connection ID as part of request to open connection

• Unique or randomly chosen• Reduces spoofing of server responses

• Unix/Linux will not re-use a socket # within 30 seconds

• To avoid confusion between old connection and new

Networks & Communication

CS-502 Fall 2007 12

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 sequence # 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

• Window defines how many packet buffers to maintain for efficient transmission

• Allows many packets in “flight”

Networks & Communication

CS-502 Fall 2007 13

Reliable Connections (continued)

Packet i

Packet i+1

Packet i+2

Packet i+3

Packet i+k

time

rec’d i

Networks & Communication

CS-502 Fall 2007 14

Reliable Connections (continued)

Packet i

Packet i+1

Packet i+2

Packet i+3

Packet i+k

time

rec’d i

rec’d i

Networks & Communication

CS-502 Fall 2007 15

Reliable Connections (continued)

Packet i

Packet i+1

Packet i+2

Packet i+3

Packet i+k

time

rec’d i

rec’d i

rec’d i+2

Networks & Communication

CS-502 Fall 2007 16

Reliable Connections (continued)

Packet i

Packet i+1

Packet i+2

Packet i+3

Packet i+k

time

rec’d i

rec’d i

rec’d i+2

rec’d i+2

lost

Networks & Communication

CS-502 Fall 2007 17

Reliable Connections (continued)

• If acknowledgement received for packet i• Delete from buffer all packets i

• If no acknowledgement received within a reasonable time for packet k

• Retransmit from buffer all packets k

• Result• Recovers from loss of packets• Recovers from loss of acknowledgements• Works well for reasonably reliable internet• Doesn’t work so well for noisy, unreliable networks

Networks & Communication

CS-502 Fall 2007 18

Reminder

• How do we know if a packet is received correctly?

• Cyclic Redundancy Check (CRC)– Polynomial computed from packet header and

body– Usually 16 or 32 bits, computed by hardware

– Appended to message– Recomputed on reception, compared with

transmitted CRC– Equal packet received correctly

Networks & Communication

CS-502 Fall 2007 19

Examples of Connection-based Protocols

• Telnet (virtual terminal)– 2-way communication by character stream– Line-by-line organization

• SMTP (Simple Mail Transport Protocol)– For sending mail– Layered on top of telnet protocol

• POP (Post Office Protocol)– For receiving your mail– Layered on top of telnet protocol

• FTP (File Transfer Protocol)– For transmitting ASCII or binary files– Binary data transmission not layered on telnet protocol

• …

Networks & Communication

CS-502 Fall 2007 20

Connection-less communication

• Some communication protocols don’t need the overhead of reliable connections– When some number of errors can be tolerated– Where recovery from those errors is easy

• UDP – User Datagram Protocol– The internet connection-less protocol (layer 4)– Breaks messages into packets

• Reassembles at destination

– Messages delivered completely or not at all– Does not send acknowledgement of correct receipt

Networks & Communication

CS-502 Fall 2007 21

Examples

• HTTP (HyperText Transport Protocol)– Web server responds directly to requests– If client does not get response, retries request

• NFS (Network File System)– For access to files on servers as if they are local– If client does not get response, retries request

• RPC (Remote Procedure Call)– Next topic

• …

Networks & Communication

CS-502 Fall 2007 22

Summary

• Socket, connection

• Network stack, 7-layer model

• Establishing a connection

• Reliable transmission

• Reading assignment– Silbershatz Chapter 16