Documentos de Académico
Documentos de Profesional
Documentos de Cultura
25/08/2011
Content
Client-Server Architecture Peer-to-Peer Architecture (P2P) Pipe-and-Filter Architecture Event Driven Programming Application Layers Open Systems Interconnection (OSI) Model TCP/IP Internet Model
25/08/2011
25/08/2011
Client-Server Architecture
Server Client request Internet responds
The Client asks for a service from the Server. The Server sends back the responds to the client.
25/08/2011
Client-Server Architecture
One part acts as the Server and the other as Client The Server programs starts and provides first some services to connect via a communication channel The Client program asks for services from the Server More than one Client can communicate with the same Server at the same time Clients are mostly browser (Internet Explorer, Firefox, Netscape) Browsers interact with the Server using protocols (a set of instructions) Protocols define the right transfer of data requested by a browser and provide by a Server Protocols are for example HTTP, FTP, SMTP, et.
25/08/2011 Client Server Programming for Applications 4
25/08/2011
Client-Server Architecture
The ideal Client-Server system is independent of the used operating system Client-Server systems can grow or shrink Horizontally: by adding/removing Clients Vertically: by larger/faster Servers or Multi-Servers
25/08/2011
Client-Server Architecture
Centralized Systems
A host computer (mainframe) is responsible for all processes like input, output, data storage and retrieval Clients can be on the same or separate machines Requests are send over a network or local Used in the past (1970s)
Distributed Systems
A number of computers (PCs, workstations) are responsible for all processes Distributed physically Connected through a network Used nowadays
Cooperative Systems
Like distributed but resources are shared transparent for the users
25/08/2011 Client Server Programming for Applications 6
25/08/2011
Client-Server Architecture
Centralized Systems
Printer Client Program
Clients
File Client Program
Internet
Connection
General Server
Client-Server Architecture
Distributed Systems
Printer Client Program
Clients
File Client Program
Mail Server
File Server
Print Server
Internet
Connection
25/08/2011
25/08/2011
Client-Server Architecture
Advantages of Distributed Systems The work load is distributed on different machines low cost increase of performance Remote access for some services Distributing data minimize loss Easier to implement due to the separation of Client and Server functions Disadvantage Centralized data increase the reliability
25/08/2011 Client Server Programming for Applications 9
Client-Server Architecture
Example The Server starts The Server waits (listen) for the Clients Client starts running Clients performs some operations (for example connecting to the Server) The Server accepts the connection (if willing) The Client sends a request to the Server The Server waits for the request from the Client The Server does the necessary actions The Server responds to the Client This interaction can be continued until one of them shuts down
25/08/2011 Client Server Programming for Applications 10
25/08/2011
Client-Server Architecture
:Server listen connect accept connection send request responds close connection :Client
25/08/2011
11
Client-Server Architecture
Example 2: The WWW The Client is a Web Browser (for example Internet Explorer, Firefox, Opera) A User starts the Web Browser User asks for display web contents The Server is a Web Server (for example Apache Web Server, IIS) The Server listens to incoming requests The Server provides services for the Client (displaying web content) The Server runs infinitely Client terminates when service is complete
25/08/2011 Client Server Programming for Applications 12
25/08/2011
Client-Server Architecture
Model 1: Static Web-Pages
Static Web-Pages do not change until they are modified by their developer
Displays the content of the file Request for a Web Page
25/08/2011
13
Client-Server Architecture
Model 1: Static Web-Pages Browser takes the URL and embeds it inside a HTTP request Browser sends the HTTP request to the Server Server receives the HTTP request and finds the requested HTML file Server sends back the file and closes the connection Browser interprets the HTML command Browser displays the page content and invokes helper applications (like xview, audio, etc.)
25/08/2011
14
25/08/2011
Client-Server Architecture
Model 2: Dynamic Web-Pages
More work for the Server Requests are for example searches Content of the dynamic web pages depends on the request For example CGI programs
Displays the data Requests for a Web Page
Server Locates the program that processes the request and sends the data to the Server; Server sends back the data to the Browser
25/08/2011 Client Server Programming for Applications 15
Client-Server Architecture
Model 2: Dynamic Web-Pages Browser collects the data and specifies a POST method Server receives the request and searches for the POST method Server starts the CGI program The CGI program reads the environment variables, receives the message body, does some work (database access, etc.) and returns back the result via output pipe Server sends back the result to the Web Browser
25/08/2011
16
25/08/2011
Client-Server Architecture
Model 3: Server Side Scripting Dynamic response due to Server side technologies Easier to maintain web pages Mostly Server side code is embedded in HTML documents Code not visible for Clients Examples
Active Server Pages (ASP) Hypertext Pre-processor (PHP) Java Server Pages (JSP) Server Side Includes (SSI) Java Applets
Displays the file
Server Locates the file; Execute the embedded scripts; Server sends back the final formatted file to the browser
25/08/2011
17
Client-Server Architecture
Model 3: Server Side Scripting Example: Java Applet Browser requests for a Java Applet Browser initiates a separate network connection to down load the Java Applet in the Web Page Server calls and sends the Java Applet Browser loads the Java Applet into the Client and executes it Afterwards it deletes the Java Applet
25/08/2011
18
25/08/2011
10
25/08/2011
25/08/2011
22
11
25/08/2011
12
25/08/2011
Pipe-and-Filter Architecture
Pipe-and-Filter Architecture consists of arbitrary number of components An event starts a sequence of processing steps Each step performs a specific function The components (filter) transforming/filtering the data Several filter working at the same time Each filter can have any number of input and output pipes Filters can run as different threads or on different machines The data are passed to other components using pipes The pipes are the connectors Each pipe has a certain role in the filter process
25/08/2011 Client Server Programming for Applications 25
Pipe-and-Filter Architecture
Pipes are usually a data buffer to store the data and it should be possible to add and remove pipes at runtime on each filter The data source can be a text file, a keyboard input or a consecutive data input The destination (sink) can be a file, database or a computer screen Simple architecture Examples UNIX programs Compiler; filtering, parsing, analysis and generating program code
25/08/2011 Client Server Programming for Applications 26
13
25/08/2011
Pipe-and-Filter Architecture
Filters
Source
Pipe
Filter
Pipe
Filter
Pipe
Filter
Pipe
Sink
25/08/2011
27
Pipe-and-Filter Architecture
Example: Unix shell The pipe symbol is | cat takes input data without displaying them grep finds text within a file sort sorts the input data > cat in.txt | grep something | sort > out.txt
in.txt
Pipe
grep
Pipe
sort
Pipe
out.txt
25/08/2011
28
14
25/08/2011
Pipe-and-Filter Architecture
Advantages Useful if many transformation needed Flexible and robust Splitting tasks in smaller sequences which can be performed independently Easy to use filters in different order or extend them Disadvantages Buffer overflow if a filter needs all data to proceed (sorting) Possible deadlocks Needs of specific data types (e.g. characters) complicates the process and slows it down
25/08/2011 Client Server Programming for Applications 29
15
25/08/2011
25/08/2011
32
16
25/08/2011
Event Consumer
Invokes event handler of registered event consumer
Event Source
Event Object
Event occurs
25/08/2011
33
25/08/2011
34
17
25/08/2011
Application Layers
In the most application architectures the functions are split into modules Each module/layer
has a distinct functionality provides high level services to other modules deploys low level services provides by other modules hides the details of the low level service implementation
Advantages
Reducing the complexity in large programs Reusability of modules Portability across multi-platforms Abstraction
25/08/2011 Client Server Programming for Applications 35
Application Layers
Examples Open Systems Interconnection (OSI) for computer network protocols Computer Architecture Open GL graphics drawing library Stream of bytes models (file I/O, sockets)
25/08/2011
36
18
25/08/2011
Application Layers
Computer Architecture
Operating System Kernel Assembler Firmware Hardware
25/08/2011
37
Application Layers
Example: Bank Money transfer
Sender Fills in the payment form Higher Layer Receiver The receiver can withdraw the money from his account The money is transferred to the receiver account The money is received by the bank computer system
The payment form is insert Middle Layer into the computer system The money is transferred from Lower Layer the bank computer system to the receiver bank system The money is transferred from the source to the destination bank
25/08/2011
38
19
25/08/2011
Application Layers
The functionalities of a network operation system are organized by using different layers called Protocol Stack This stack describes how information is transferred from on software application in one computer through a network to another software application in another computer There are two common connection protocol models: Open Systems Interconnection (OSI) Model TCP/IP Internet Model
25/08/2011
39
25/08/2011
40
20
25/08/2011
25/08/2011
41
21
25/08/2011
Transport Layer
Transmission of messages Offers a unit access to the upper layers Guarantees a Quality of Services Error Control for end-to-end Flow Control for end-to-end Protocols: TCP, UDP, SCTP
25/08/2011 Client Server Programming for Applications 44
22
25/08/2011
Presentation Layer
Translation of message format between different operating systems (ASCII, EBCDIC, Unicode) Offers a syntactical correct data transfer Additional task like Compression and Encryption
Application Layer
Highest layer Access to the network Obtains services like mail service, file transfer, www, remote login, chatting, etc. Protocols: SMTP, HTTP, NFS, FTP, Telnet
25/08/2011 Client Server Programming for Applications 45
25/08/2011
46
23
25/08/2011
25/08/2011
47
25/08/2011
48
24
25/08/2011
Client 2
Application Transport Network Data Link Physical Network Data Link Physical Network Data Link Physical
49
Resources
Computer Science Program, The University of Texas, Dallas Wikipedia; www.wikipedia.com http://eaipatterns.com/PipesAndFilters.html www.webdevelopersnotes.com http://c2.com/cgi/wiki?EventDrivenProgramming http://www.exforsys.com/tutorials/client-server/peer-to-peer-andclient-queue-client-architecture.html
25/08/2011
50
25
25/08/2011
Any questions?
25/08/2011
51
26