Sie sind auf Seite 1von 8

CPSC 826 Application-Layer Protocols

application
Internetworking Overview transport
network
 Application-layer protocols define: link
physical
Client/Server Computing & » The types of messages exchanged
» The syntax and semantics of
Socket Programming messages
local ISP
» The rules for when and how
messages are sent
Michele Weigle
Department of Computer Science  Public protocols (defined in RFCs) regional ISP
Clemson University » HTTP, FTP, SMTP, POP, IMAP,
DNS
mweigle@cs.clemson.edu
September 1, 2004  Proprietary protocols
» RealAudio, RealVideo
» IP telephony
http://www.cs.clemson.edu/~mweigle/courses/cpsc826 company
» … network
1 2

Network Working Group


Request for Comments: 2616
R. Fielding
J. Gettys
UC Irvine
Compaq/W3C Application-Layer Protocols
Obsoletes: 2068 J. Mogul Compaq application
Category: Standards Track H. Frystyk
Outline transport
W3C/MIT network
L. Masinter Xerox link
June 1999 P. Leach  The architecture of distributed systems
Microsoft
physical
T. Berners-Lee W3C/MIT
» Client/Server computing
» P2P computing
Hypertext Transfer Protocol -- HTTP/1.1 » Hybrid (Client/Server and P2P) systems local ISP

Abstract  The programming model used in


constructing distributed systems
The Hypertext Transfer Protocol (HTTP) is an application-level regional ISP
protocol for distributed, collaborative, hypermedia information » Socket programming
systems. It is a generic, stateless, protocol which can be used for
many tasks beyond its use for hypertext, such as name servers and  Example client/server systems and
distributed object management systems, through extension of its their application-level protocols
request methods, error codes and headers [47]. A feature of HTTP is
the typing and negotiation of data representation, allowing systems » The World-Wide Web (HTTP)
to be built independently of the data being transferred.
» Reliable file transfer (FTP)
HTTP has been in use by the World-Wide Web global information » E-mail (SMTP & POP)
initiative since 1990. This specification defines the protocol company
referred to as "HTTP/1.1", and is an update to RFC 2068 [33]. » Internet Domain Name System (DNS) network
3 4
Application-Layer Protocols Application-Layer Protocols
application application
Outline transport
Outline transport
network network
 Example client/server systems and link  Example P2P systems and link
their application-level protocols physical their application-level protocols physical
» The World-Wide Web (HTTP) » Gnutella
» Reliable file transfer (FTP) » Napster (hybrid)
local ISP local ISP
» E-mail (SMTP & POP) » KaZaA
» Internet Domain Name System (DNS)
 Protocol design issues: regional ISP regional ISP
» In-band v. out-of-band control signaling
» Push v. pull protocols
» Persistent v. non-persistent connections
 Client/server service architectures
» Contacted server responds versus forwards
request company company
network network
5 6

Application-Layer Protocols Application-Layer Protocols


Client-Server Architecture Pure P2P Architecture

local ISP Server:  No always-on server


local ISP
» always-on host  Arbitrary end systems
» permanent IP address directly communicate
regional ISP » server farms for scaling Peers are intermittently
 regional ISP
connected and change IP
Clients: addresses
» communicate with server  Example: Gnutella
» may be intermittently
connected Highly scalable
company » may have dynamic IP company
network
addresses network
But difficult to manage
» do not communicate
directly with each other
7 8
Application-Layer Protocols Application-Layer Protocols
Hybrid of Client-Server and P2P Transport Services

Napster Data loss Bandwidth


» File transfer P2P  Some apps (e.g., audio) can  Some apps (e.g.,
» File search centralized: tolerate some loss
 Peers register content at central server multimedia) require
 Other apps (e.g., file transfer, minimum amount of
 Peers query same central server to locate content
telnet) require 100% reliable bandwidth to be
data transfer
Instant messaging “effective”
» Chatting between two users is P2P  Other apps (“elastic
» Presence detection/location centralized: Timing apps”) make use of
 User registers its IP address with central server when it comes online  Some apps (e.g., Internet whatever bandwidth they
 User contacts central server to find IP addresses of buddies telephony, interactive get
games) require low delay
to be “effective”

9 10

Internet Applications Internet Transport Protocols


Transport Service Requirements Services Provided

 TCP service:  UDP service:


Application Data loss Bandwidth Time Sensitive » connection-oriented: setup » unreliable data transfer
required between client, between sending and
file transfer no loss elastic no server receiving process
e-mail no loss elastic no » does not provide:
» reliable transport between
Web documents no loss elastic no connection setup,
real-time audio/video
sending and receiving
loss-tolerant audio: 5kbps-1Mbps yes, 100’s msec reliability, flow control,
process
video:10kbps-5Mbps congestion control, timing,
stored audio/video loss-tolerant same as above yes, few secs » flow control: sender won’t
overwhelm receiver or minimum bandwidth
interactive games loss-tolerant few kbps up yes, 100’s msec guarantees
instant messaging no loss elastic yes and no » congestion control: throttle
sender when network
overloaded Why bother? Why is
» does not provide: timing, there a UDP?
minimum bandwidth
guarantees
11 12
Internet Applications The Application Layer
application
Application and Transport Protocols The client-server paradigm transport
network Client
 Typical network application has link
Application Underlying physical
Application layer protocol transport protocol two pieces: client and server
local ISP
e-mail SMTP [RFC 2821] TCP
 Client:
remote terminal access Telnet [RFC 854] TCP » Initiates contact with server reply
Web HTTP [RFC 2616] TCP (“speaks first”)
FTP [RFC 959] regional ISP
file transfer TCP » Requests service from server
streaming multimedia proprietary TCP or UDP request
(e.g. RealNetworks) » For Web, client is implemented in
Internet telephony proprietary browser; for e-mail, in mail reader
(e.g., Dialpad) typically UDP
 Server:
» Provides requested service to client company application
» “Always” running network transport
» May also include a “client interface” network
Server link
physical
13 14

Client/Server Paradigm Client/Server Paradigm


Socket programming Socket-programming using TCP
socket  A socket is an application created, OS-controlled
 Sockets are the fundamental interface into which an application can both send
a host-local, application
building block for created/released, OS-controlled and receive messages to and from another
client/server systems interface into which an application
application process can both » A “door” between application processes and end-to-end
 Sockets are created and send and receive messages transport protocols
managed by applications to/from another (remote or local)
application process
» Strong analogies with files
controlled by controlled by
application process process application
 Two types of transport services developer
socket socket
developer
are available via the socket API: controlled by TCP with TCP with controlled by
» UDP sockets: unreliable, datagram-oriented communications operating buffers, buffers, operating
system variables Internet variables system
» TCP sockets: reliable, stream-oriented communications
Host Host
(end system) (end system)
15 16
Socket-programming using TCP Socket-programming using TCP
TCP socket programming model Network addressing for sockets

 A TCP socket provides a reliable bi-directional  Sockets are addressed using an IP address and port
number
communications channel from one process to another
» A “pair of pipes” abstraction

process process
socket
Local port numbers socket
(e.g., 6500)
Process Process TCP with TCP with
Internet buffers, buffers,
write bytes read variables variables
socket socket Internet addresses of hosts
read bytes write
End System (e.g., 130.127.48.4) End System
Host Host Internet domain
(end system) (end system) name of host DNS
e.g., access.cs.clemson.edu
17 18

Socket-programming using TCP Socket-programming using TCP


Socket programming in Java Socket creation in the client-server model

Client Internet Server


socket
write bytes read
socket socket
3- dsh
ha

read write
w ak

bytes
n

ay e

Client
process
 Client creates a local TCP  When the client creates a socket, “welcoming”
process ake socket socket
socket specifying the host and the client’s TCP establishes ay handsh
TCP 3-w
port number of server process connection to server’s TCP client bytes
» Java resolves host names to IP  When contacted by a client, socket socket connection
socket socket
addresses using DNS server creates a new socket for host or bytes
 Client contacts server server process to communicate server Internet
» Server process must be running with client Server
» Server must have created socket
» This allows the server to talk with Client
that “welcomes” client’s contact
multiple clients
19 20
Socket-programming using TCP Socket programming with TCP Example
Simple client-server example Client structure

inFromServer
 Client reads from standard input

outToServer
(inFromUser stream), writes to
Client Server server via a socket (outToServer
stdin welcoming stream)
client socket socket
socket socket  Server reads line from a socket
connection
stdout socket socket
 Server converts line to uppercase and
writes back to client client socket
 The client reads a line of text from standard input and
sends the text to the server via a socket  Client reads from socket, (2) (3)

 The server receives the line of text from the client and (inFromServer stream) prints
converts the line of characters to all uppercase modified line to standard output Standard Client
output Process
(4)
 The server sends the converted line back to the client
 The client receives the converted text and writes it to Standard
inFromUser
input
standard output 21
(1)
22

Socket programming with TCP Example Socket programming with TCP Example
Client/server TCP socket interaction in Java Java client
import java.io.*;
Server (running on torpedo1.cs.clemson.edu) import java.net.*;
class TCPClient {
create socket for incoming public static void main(String argv[]) throws Exception
request (port=6789)
{
welcomeSocket = new ServerSocket(...)
Client (running on shadow1.cs...) String sentence;
String modifiedSentence;
wait for incoming TCP create socket,
connection request connection setup connect to torpedo1.cs.clemson.edu,
port=6789 // Create (buffered) input stream using standard input
connectionSocket = clientSocket = new Socket(...)
welcomeSocket.accept() BufferedReader inFromUser = new BufferedReader(
new InputStreamReader(System.in));
write request using
read request from
connectionSocket clientSocket System.out.println("Client ready for input");

write reply to read reply from // Create client socket with connection to server at port 6789
connectionSocket program flow
clientSocket

Socket clientSocket = new Socket("torpedo1.cs.clemson.edu", 6789);


close data flow
close
connectionSocket
clientSocket
23 24
Socket programming with TCP Example Socket programming with TCP Example
Java client II Java server
// Create output stream attached to socket import java.io.*;
DataOutputStream outToServer = new DataOutputStream( import java.net.*;
clientSocket.getOutputStream()); class TCPServer {
public static void main(String argv[]) throws Exception
// Create (buffered) input stream attached to socket {
BufferedReader inFromServer = new BufferedReader( String clientSentence;
new InputStreamReader( String capitalizedSentence;
clientSocket.getInputStream()));
// Write line to server // Create “welcoming” socket using port 6789
outToServer.writeBytes(sentence + '\n'); ServerSocket welcomeSocket = new ServerSocket(6789);

// Read line from server System.out.println("Server Ready for Connection");


modifiedSentence = inFromServer.readLine();
// While loop to handle arbitrary sequence of clients making requests
System.out.println("FROM SERVER: " + modifiedSentence); while(true) {
clientSocket.close();
// Waits for some client to connect and creates new socket for connection
} // end main Socket connectionSocket = welcomeSocket.accept();
} // end class
System.out.println("Client Made Connection");
25 26

Socket programming with TCP


Example Socket programming with TCP Example
Java server II Client/server TCP socket interaction in Java
// Create (buffered) input stream attached to connection socket
BufferedReader inFromClient = new BufferedReader( Server (running on torpedo1.cs.clemson.edu)
new InputStreamReader(
connectionSocket.getInputStream())); create socket for incoming
// Create output stream attached to connection socket request (port=6789)
welcomeSocket = new ServerSocket(...)
DataOutputStream outToClient = new DataOutputStream( Client (running on shadow1.cs...)
connectionSocket.getOutputStream());
// Read input line from socket wait for incoming TCP create socket,
connection request connection setup connect to torpedo1.cs.clemson.edu,
clientSentence = inFromClient.readLine(); port=6789
connectionSocket = clientSocket = new Socket(...)
welcomeSocket.accept()
System.out.println("Client sent: " + clientSentence);
capitalizedSentence = clientSentence.toUpperCase() + '\n'; write request using
read request from
connectionSocket clientSocket
// Write output line to socket
outToClient.writeBytes(capitalizedSentence);
connectionSocket.close(); write reply to read reply from
connectionSocket program flow
clientSocket
} // end while; loop back to accept a new client connection
close data flow
} // end main close
connectionSocket
} // end class clientSocket
27 28
Socket-programming using UDP Socket programming with UDP Example
UDP socket programming model Client/server UDP socket interaction in Java

 A UDP socket provides an unreliable bi-directional Server (running on torpedo1.cs.clemson.edu) Client


communication channel from one process to another
create socket,
» A “datagram” abstraction create socket for incoming
clientSocket = new
request (port=9876)
serverSocket = new DatagramSocket()
DatagramSocket()

create address
(torpedo1.cs.clemson.edu, port = 9876)
read request from and send datagram using
serverSocket clientSocket
Process Internet Process
write bytes read read reply from
socket socket write reply to
read bytes write serverSocket
clientSocket
specifying client IP address program flow
and port number
close
Host Host clientSocket data flow
(end system) (end system)
29 30

Das könnte Ihnen auch gefallen