Chapter 5- Application Layer-Client Server Paradigm (1)
Chapter 5- Application Layer-Client Server Paradigm (1)
• The Web today is a repository of information in which the documents, called Web
pages, are distributed all over the world and related documents are linked together.
• Distribution allows the growth of the Web. Each web server in the world can add a
new web page to the repository and announce it to all Internet users without
overloading a few servers.
• Linking allows one web page to refer to another web page stored in another server
somewhere else in the world. The linking of web pages was achieved using a
concept called hypertext.
Architecture
• The WWW today is a distributed client-server service.
• The service provided is distributed over many locations
called sites.
• Each site holds one or more documents, referred to as
web pages.
• Each web page can contain some links to other web
pages in the same or other sites.
• A simple web page has no links to other web pages.
• A composite web page has one or more links to other web
pages. Each web page is a file with a name and address.
Web Client (Browser):
consists of three parts: a controller, client protocols, and interpreters.
• The controller receives input from the keyboard or the mouse and
uses the client programs to access the document.
• After the document has been accessed, the controller uses one of the
interpreters to display the document on the screen.
• The client protocol can be one of the protocols (such as HTTP or FTP).
• The interpreter can be HTML, Java, or JavaScript, depending on the
type of document.
• Some commercial browsers include Internet Explorer, Netscape
Navigator, and Firefox.
Web Server :
• The web page is stored at the server. Each time a request arrives, the
corresponding document is sent to the client.
• To improve efficiency, servers normally store requested files in a cache in
memory; memory is faster to access than disk.
• Some popular web servers include Apache and Microsoft Internet
Information Server.
Uniform Resource Locator (URL)
Web Page – unique identifier - four identifiers: host, port, and path, protocol.
Protocol: HTTP or FTP
Host: IP address / Domain name
Port – HTTP 80
Path: The path identifies the location and the name of the file in the underlying operating
system
protocol://host/path Used most of the time
protocol://host:port/path Used when port number is needed
Web Documents: The documents in the WWW can be
grouped as
static, dynamic, and active.
Static documents are fixed-content documents that are created and stored in a server. The
client can get a copy of the document only.
• The contents in the server can be changed, but the user cannot change them.
• When a client accesses the document, a copy of the document is sent. The user can then
use a browser to see the document.
• Static documents are prepared using one of the several languages:
Hypertext Markup Language (HTML)
Extensible Markup Language (XML),
Extensible Style Language (XSL), and
Extensible Hypertext Markup Language (XHTML).
Dynamic Documents :A dynamic document is created by a web server whenever a browser
requests the document.
• When a request arrives, the web server runs an application program or a script that
creates the dynamic document.
• The server returns the result of the program or script as a response to the browser that
requested the document.
Simple example of a dynamic document
• The retrieval of the time and date from a server. Time and date are
kinds of information that are dynamic in that they change from
moment to moment.
• The client can ask the server to run a program such as the date
program in UNIX and send the result of the program to the client.
• Common Gateway Interface (CGI) used earlier, Now JSP, ASP.
Active Documents: For many applications, we need a program or a script to
be run at the client site. These are called active documents.
Java Applets (bytecode format), Javascripts
Cookies
• Websites are being used as electronic stores that allow users to browse through the store,
select wanted items, put them in an electronic cart, and pay at the end with a credit card.
• Some websites need to allow access to registered clients only.
• Some websites are used as portals: the user selects the web pages he wants to see.
• Some websites are just advertising agency.
Creating and Storing Cookies
1. When a server receives a request from a client, it stores information about the client in a
file or a string. The information may include the domain name of the client, the contents of
the cookie (information the server has gathered about the client such as name, registration
number, and so on), a timestamp, and other information depending on the implementation.
2. The server includes the cookie in the response that it sends to the client.
3. When the client receives the response, the browser stores the cookie in the cookie
directory, which is sorted by the server domain name.
Web Caching: Proxy Server
• The client, not the server, issues a passive open using an ephemeral port.
This must be done by the client because it is the client that issues the
commands for transferring files.
• The client sends this port number to the server using the PORT
command.
• The server receives the port number and issues an active open using the
well-known port 20 and the received ephemeral port number.
Communication over Data
Connection
• The purpose and implementation of the data connection are different from
those of the control connection.
• The client must define the type of file to be transferred, the structure of the
data, and the transmission mode.
• Before sending the file through the data connection, we prepare for
transmission through the control connection.
• File transfer occurs over the data connection under the control of the commands sent over
the control connection.
• File transfer in FTP means one of three things: retrieving a file (server to client), storing a
file (client to server), and directory listing (server to client).
• Although FTP requires a password, the password is sent in plaintext (unencrypted), which
means it can be intercepted and used by an attacker.
• The data transfer connection also transfers data in plaintext, which is insecure.
• To be secure, one can add a Secure Socket Layer between the FTP application layer and the
Electronic Mail
• Electronic mail (or e-mail) allows users to exchange messages.
How is E-mail different from HTTP and FTP??
• In an application such as HTTP or FTP, the server program is running all the time, waiting for a
request from a client.
• When the request arrives, the server provides the service. There is a request and there is a
response.
• In the case of electronic mail, the situation is different;
• E-mail is considered a one-way transaction.
• Neither feasible nor practical to keep running a server to receive a mail.
• Hence, the idea of client/server programming should be implemented in another way: using some
intermediate computers (servers).
• The users run only client programs when they want and the intermediate servers apply the
client/server paradigm.
• In a common scenario, both sender and receiver are connected over LAN or
WAN to two mail servers.
• The administrator has created one mailbox for each user where the received
messages are stored.
• A mailbox is part of a server hard drive, a special file with permission
restrictions. Only the owner of the mailbox has access to it.
• The administrator has also created a queue (spool) to store messages waiting
to be sent.
• The sender and receiver three different agents: a User Agent (UA), a Mail
Transfer Agent (MTA), and a Message Access Agent (MAA).
The electronic mail system needs two UAs, two pairs of MTAs (client and server), and a
pair of MAAs (client and server).
When sender wants to send a mail:
• The sender runs a UA program to prepare the message and send it to
sender’s mail server.
• The mail server at sender’s site uses a queue (spool) to store messages
waiting to be sent.
• The message, however, needs to be sent through the Internet from sender’s
site to receiver’s site using an MTA.
• Here two message transfer agents are needed: one client and one server.
• The server needs to run all the time but the client may be triggered by the
system when there is a message in the queue to be sent.
• The UA at the receiver’s site allows to read the received message. Receiver
later uses an MAA client to retrieve the message from an MAA server
running on the second server.
User Agent
• UA is a software package (program) that composes, reads, replies to, and
forwards messages.
• It also handles local mailboxes on the user computers.
• There are two types of user agents: command-driven and GUI-based.
Command Driven:
Normally accepts a one character command from the keyboard to perform its
task. Example, a user can type the character r, at the command prompt, to
reply to the sender of the message, or type the character R to reply to the
sender and all recipients. Examples: mail, pine, and elm.
GUI Based:
Allows the user to interact with the software by using both the keyboard and
the mouse. They have graphical components such as icons, menu bars, and
windows that make the services easy to access. Example: Eudora and Outlook
Sending Mail
• To send mail, the user, through the UA, creates a mail which has an envelope and
a message.
• The envelope usually contains the sender address, the receiver address, and other
information.
• The message contains the header and the body.
• The header of the message defines the sender, the receiver, the subject of the
message, and some other information.
• The body of the message contains the actual information to be read by the
recipient.
Receiving Mail
• The user agent is triggered by the user (or a timer). If a user has mail,
the UA informs the user with a notice.
• If the user is ready to read the mail, a list is displayed in which each line
contains a summary of the information about a particular message in
the mailbox.
• The summary usually includes the sender mail address, the subject, and
the time the mail was sent or received.
• The user can select any of the messages and display its contents on the
screen.
Addresses
The address consists of two parts: a local part and a domain name,
separated by an @ sign.
The local part defines the name of a special file, called the user mailbox,
where all the mail received for a user is stored for retrieval by the
message access agent.
The second part of the address is the domain name.
An organization usually selects one or more hosts to receive and send e-
mail; they are sometimes called mail servers or exchangers.
The domain name assigned to each mail exchanger either comes from the
DNS database or is a logical name
Message Transfer Agent: SMTP
• The formal protocol that defines the MTA client and server in the
Internet is called Simple Mail Transfer Protocol (SMTP).
• SMTP is used two times, between the sender and the sender’s mail
server and between the two mail servers.
Commands and Responses
• SMTP uses commands and responses to transfer messages between an
MTA client and an MTA server.
• The command is from an MTA client to an MTA server; the response is
from an MTA server to the MTA client.
• Each command or reply is terminated by a two character (carriage
return and line feed) end-of-line token.
Responses