Module-5 Application Layer
Module-5 Application Layer
Introduction
Client-Server Programming
‣ FTP
‣ Electronic Mail
‣ Domain Name System (DNS)
‣ TELNET
‣ Secure Shell (SSH)
Another problem is that there should be a service provider willing to accept the cost
and create a powerful server for a specific service.
Several traditional services are still using this paradigm, including the World Wide Web
(WWW) and its vehicle HyperText Transfer Protocol (HTTP), file transfer protocol
(FTP), secure shell (SSH), e-mail, and so on.
The client thinks that the socket is the entity that receives the request and gives the
response; the server thinks that the socket is the one that has a request and needs the
response.
If we create two sockets, one at each end, and define the source and destination addresses
correctly, we can use the available instructions to send and receive data.
The rest is the responsibility of the operating system and the embedded TCP/IP protocol.
Department of CSE- Data Science 12
Socket Addresses
We need a pair of socket addresses for communication: a local socket address
and a remote socket address
A socket address should first define the computer on which a client or a server is
Running
Figure shows the lifetime of the sockets in the server and client processes.
Different clients use different sockets, but the server creates only one socket and
changes only the remote socket address each time a new client makes a
connection
Concurrent Communication
A concurrent server can process several client requests at the same time. This can
be done using the available provisions in the underlying programming language.
In C, a server can create several child processes, in which a child can handle a
client.
In Java, threading allows several clients to be handled by each thread
The main document and the image are stored in two separate files (file A and file B) in the same site; the
referenced text file (file C) is stored in another site. Since we are dealing with three different files, we
need three transactions if we want to see the whole document.
The first transaction (request/response) retrieves a copy of the main document (file A), which has
references (pointers) to the second and third files.
When a copy of the main document is retrieved and browsed, the user can click on the reference to the
image to invoke the second transaction and retrieve a copy of the image (file B).
If the user needs to see the contents of the referenced text file, she can click on its reference (pointer)
invoking the third transaction and retrieving a copy of file C.
The file A, file B, and file C are independent web pages, each with independent names and addresses.
Department of CSE- Data Science 32
Web Client (Browser)
A variety of vendors offer commercial browsers that interpret and display a web page,
and all of them use nearly the same architecture.
Each browser usually 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.
Department of CSE- Data Science 33
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 a disk.
A server can also become more efficient through multithreading or
multiprocessing. In this case, a server can answer more than one request at a
time.
Some popular web servers include Apache and Microsoft Internet Information
Server.
Uniform Resource Locator (URL)
A web page, as a file, needs to have a unique identifier to distinguish it from
other
web pages. To define a web page, we need three identifiers: host, port, and path.
Web Documents
• The documents in the WWW can be grouped into three broad categories: static, dynamic,
and active.
Static Documents
Static documents are fixed-content documents that are created and stored in a server.
The contents of the file are determined when the file is created, not when it is used.
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 several languages: HyperText Markup
Language (HTML), Extensible Markup Language (XML), Extensible Style Language
(XSL), and Extensible Hypertext Markup Language (XHTML).
Department of CSE- Data Science 36
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.
Because a fresh document is created for each request, the contents of a dynamic
document may vary from one request to another.
A very simple example of a dynamic document is the retrieval of the time and date
from a server.
Common Gateway Interface (CGI) was used to retrieve a dynamic document in the
past, today’s options include one of the scripting languages such as Java Server Pages
(JSP), which uses the Java language for scripting, or Active Server Pages (ASP), a
Microsoft product that uses Visual Basic language for scripting, or ColdFusion, which
embeds queries in a Structured Query Language (SQL) database in the HTML
document.
The first section in the request message is called the request line; the first section
in the response message is called the status line.
The second field, URL, was discussed earlier in the chapter. It defines the address
and name of the corresponding web page.
The third field, version, gives the version of the protocol; the most current version
of HTTP is 1.1.
Department of CSE- Data Science 43
After the request line, we can have zero or more request header lines.
Each header line sends additional information from the client to the server.
For example, the client can request that the document be sent in a special format.
Each header line has a header name, a colon, a space, and a header value
The value field defines the values associated with each header name.
The body can be present in a request message. Usually, it contains the comment to be sent or
the file to be published on the website when the method is PUT or POST
The body contains the document to be sent from the server to the client. The body is
present unless the response is an error message
FTP
File Transfer Protocol (FTP) is the standard protocol provided by TCP/IP for copying
a file from one host to another.
Although transferring files from one system to another seems simple and
straightforward, some problems must be dealt with first.
For example, two systems may use different file name conventions.
Two systems may have different ways to represent data.
Two systems may have different directory structures.
All of these problems have been solved by FTP in a very simple and elegant approach.
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.
Figure: POP3
MIME Headers
MIME defines five headers which can be added to the original e-mail header section to
define the transformation parameters:
Content-ID This header uniquely identifies the whole message in a multiple message
environment.
Content-Description This header defines whether the body is image, audio, or video.
E-Mail Security
e-mail exchanges can be secured using two application-layer securities designed in
particular for e-mail systems.
Two of these protocols are Pretty Good Privacy (PGP) and Secure/Multipurpose
Internet Mail Extensions (S/MIME),
NVT uses two sets of characters, one for data and one for control. Both are 8-bit bytes
as shown in Figure.
For data, NVT normally uses what is called NVT ASCII. This is an 8-bit character set
in which the seven lowest order bits are the same as US ASCII and the highest order
bit is 0.
To send control characters between computers (from client to server or vice versa),
NVT uses an 8-bit character set in which the highest order bit is set to 1.
The length field defines the length of the packet but does not include the
padding.
One to eight bytes of padding is added to the packet to make the attack on the
security provision more difficult.
The cyclic redundancy check (CRC) field is used for error detection.
The type field designates the type of the packet used in different SSH protocols.
The data field is the data transferred by the packet in different protocols
Figure 26.28 shows how TCP/IP uses a DNS client and a DNS server to map a name to
an address.
A user wants to use a file transfer client to access the corresponding file transfer
server running on a remote host.
The user knows only the file transfer server name, such as afilesource.com. However,
the TCP/IP suite needs the IP address of the file transfer server to make the
connection.
1. The user passes the host name to the file transfer client.
2. The file transfer client passes the host name to the DNS client.
3. Each computer, after being booted, knows the address of one DNS server. The DNS
client sends a message to a DNS server with a query that gives the file transfer
server name using the known IP address of the DNS server.
4. The DNS server responds with the IP address of the desired file transfer server.
5. The DNS server passes the IP address to the file transfer client.
6. The file transfer client now uses the received IP address to access the file transfer
server.
Figure : Domains
Generic Domains
- The generic domains define registered hosts according to their generic behavior.
- Each node in the tree defines a domain, which is an index to the domain name
space database
The address uci.ca.us. can be translated to University of California, Irvine, in the state
of California in the United States.
Iterative Resolution
To register, the organization needs to give the name of its server and the IP address of
the server.
For example, a new commercial organization named wonderful with a server named
ws and IP address 200.200.200.5 needs to give the following information to one of the
registrars: