CNS - Unit 5 (Application Layer) - Model Answers
CNS - Unit 5 (Application Layer) - Model Answers
Application layer: client server /peer to peer / Connectionless iterative server , Connection-
oriented concurrent server / sockets
Application layer: enables the user, whether human or software, to access the network.
• It provides user interfaces and support for services such as electronic mail, file access and
transfer, access to system resources, surfing the world wide web, and network
management.
• A user at a local site wants to receive a service from a computer at a remote site
Two approaches : client server & Peer to peer
An iterative server can process only one request at a time; it receives a request, processes it, and
sends the response to the requestor before it handles another request. A concurrent server, on the
other hand, can process many requests at the same time and thus can share its time between
many requests
• Connectionless iterative server
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. Thus, a Web page can be simple or
composite. A simple Web page has no link 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 pages are written using HTML and web pages are transferred from web site to client
browser using HTTP.
Hypertext and Hypermedia
Hypertext :means creating documents that refer to other documents. In a hypertext document, a
part of text can be defined as a link to another document. When a hypertext is viewed with a
browser, the link can be clicked to retrieve the other document.
Hypermedia is a term applied to document that contains links to documents containing text ,
graphics, video, or audio.
Web Client (Browser)
Lot of vendors offer commercial browsers that interpret and display a Web document, and all of
them use nearly the same architecture.
Eg (Internet Explorer, chrome, edge & Firefox )
Each browser usually consists of three parts: a controller, client protocol, 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
described previously such as FTP, or TELNET, or HTTP .
The interpreter can be HTML, Java, or JavaScript, depending on the type of document
Web Server
The Web pages are stored at the server. Each time a client request arrives, the corresponding
document is sent to the client.
Eg of Web servers : Apache HTTP ,Apache tomcat , Microsoft Internet Information Server
(IIS) , lighttpd , Jagsaw , NGINX ,
URL
Uniform Resource Locator (URL)
A client that wants to access a Web page needs the file name and the address of that Web page.
To facilitate the access of documents distributed throughout the world, HTTP uses uniform
resource locator (URL)
URL is a standard locator for specifying any kind of information on the Internet. The URL
defines four things: protocol, host computer, port, and path
The protocol is the client-server application program used to retrieve the document. Many
different protocols can retrieve a document; among them are Gopher, FTP, HTTP, News, and
TELNET. The most common today is HTTP.
The host is the domain name of the computer on which the information is located. Web pages
are usually stored in computers, and computers are given domain name
aliases that usually begin with the characters ―www‖. But This is not mandatory, as the host can
have any domain name.
The URL can optionally contain the port number of the server
Path is the pathname of the file where the information is located. path can contain slashes which
separate the directories from the subdirectories and files. In other words, the path defines the
complete file name where the document is stored in the directory system.
Types of web documents & technologies to create web documents
Type of webpage Need to be declared at the time of creation of webpage.
1. Static documents
are fixed-content documents that are created and stored in a server. The client can get a copy of
the document only . We can can change document at server , client can’t change it &
Document is displayed by client browser
Static documents are prepared using one of the several languages: Hypertext Markup Language
(HTML), Extensible Markup Language (XML), Extensible Style Language (XSL), and Extended
Hypertext Markup Language (XHTML)
2. Dynamic Documents
A dynamic document is created by a Web server whenever a client 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 output 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.
Example : retrieval of the time and date from a server. ( every time the server process has to
execute to send response)
dynamic documents are prepared using CGI
Scripting Technologies for Dynamic Documents
The problem with CGI technology is the inefficiency that results if part of the dynamic document
that is to be created is fixed and not changing from request to request
Eg : in a web apge which is displaying cost & quantity of various items. Here items name can
remain fixed. Only stock & cost can change
items name Stock Cost per unit
If we use CGI, the program must create an entire document each time a request is made.
The solution is to create a file containing the fixed part of the document using HTML and embed
a script, a source code, that can be run by the server to provide the stock & cost.
most common scripting languages are:
• Hypertext Preprocessor (PHP), which uses the Perl language;
• Java Server Pages (JSP), which uses the Java language for scripting;
• Active Server Pages (ASP), a Microsoft product, which uses Visual Basic language for
scripting;
• ColdFusion, which embeds SQL database queries in the HTML document.
3. Active Documents
For some applications, we need a program or a script to be run at the client site. These are called
active documents.
For example, suppose we want to run a program that creates animated graphics on the screen or
a program that interacts with the user.
The program definitely needs to be run at the client site where the animation or interaction takes
place. When a browser requests an active document, the server sends a copy of the document or
a script. The document is then run at the client (browser) site.
Java Applets
One way to create an active document is to use Java applets. Java is a combination of a high-
level programming language, a run-time environment, and a class library that allows a
programmer to write an active document (an applet) and a browser to run it. It can also be a
stand-alone program that doesn’t use a browser
An applet is a program written in Java on the server. It is compiled and ready to be run. The
document is in bytecode (binary) format. The client process (browser) creates
an instance of this applet and runs it. A Java applet can be run by the browser in two ways. In the
first method, the browser can directly request the Java applet program in the URL and receive
the applet in binary form. In the second method, the browser can
retrieve and run an HTML file that has embedded the address of the applet as a tag.
JavaScript
The idea of scripts in dynamic documents can also be used for active documents. If the active
part of the document is small, it can be written in a scripting language; then it can be interpreted
and run by the client at the same time. The script is in source code (text) and not in binary form.
The scripting technology used in this case is usually JavaScript.
JavaScript, which bears a small resemblance to Java, is a very high level scripting language
developed for this purpose.
Although HTTP uses the services of TCP, HTTP itself is a stateless protocol, which means that
the server does not keep information about the client. The client initializes the transaction by
sending a request. The server replies by sending a response.
A request message ( sent by clent) : consists of a request line, a header, and sometimes a body.
Request line consists of
URL, as discussed earlier is the address and name of corresponding Web page.
The third field, version, gives the version of the protocol; the most current version of HTTP is
3.0
Header Lines In Request Message
After the request line, we can have zero or more request header lines.
example retrieves a document. GET method to retrieve an image with the path /usr/bin/image1.
HTTP version (1.1). client can accept images in GIF and JPEG format. The request does not
have a body.
The response message contains the status line and 4 lines of header. The header lines define the
date, server, MIME version, and length of the document. The body of the document follows the
header
Cookies
A cookie is information saved by your web browser. When you visit a website, the site may
place a cookie on your web browser so it can recognize your device in the future. If you return to
that site later on, it can read that cookie to remember you from your last visit and keep track of
you over time.
Since the data in cookies doesn't change, cookies themselves aren't harmful. They can't infect
computers with viruses or other malware. However, some cyber attacks can hijack cookies and
enable access to your browsing sessions. The danger lies in their ability to track individuals'
browsing histories.
Accepting cookies will give you the best user experience on the website, while declining cookies
could potentially interfere with your use of the site. For example, online shopping. Cookies
enable the site to keep track of all of the items that you've placed in your cart while you continue
to browse.
Cookies are text files with small pieces of data — like a username and password — that are used
to identify your computer as you use a computer network. Specific cookies known as HTTP
cookies are used to identify specific users and improve your web browsing experience.
Data stored in a cookie is created by the server upon your connection. This data is labeled with
an ID unique to you and your computer.
When the cookie is exchanged between your computer and the network server, the server reads
the ID and knows what information to specifically serve to you.
DNS steps:
Steps
1. The user passes the host name eg google.com to the file transfer client.
2. The file transfer client passes the host name to the DNS client.
3. each computer, knows the address of one DNS server. The DNS client sends a message
to a DNS server with a query
4. The DNS server responds with the IP address of the desired file transfer server.
5. The DNS client 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.
Label
Each node in the tree has a label, which is a string with a maximum of 63 characters. The root
label is a null string (empty string). DNS requires that children of a node (nodes that branch
from the same node) have different labels, which guarantees the uniqueness of the domain
names
Domain
A domain is a subtree of the domain name space. The name of the domain is the name of the
node at the top of the subtree. Figure shows some domains. Note that a
domain may itself be divided into domains (or subdomains )
The information contained in the domain name space must be stored. the information is stored
among many computers called DNS servers. we have a hierarchy of servers in the same way
that we have a hierarchy of names
1. Generic domains
• the first level in the generic domains section allows 14 possible labels.
• These labels describe the organization types as listed in next slide
2. Country domains
Name of the country abbreviated in two-character
Eg : .in .us . fr .nz etc
3. Inverse Domain
The inverse domain is used to map an address to a name.
Domain name registration
new domains added to DNS ,through a registrar, which is a commercial entity by ICANN. A
registrar first verifies that the requested domain name is unique and then enters it into the DNS
database. For assigning domain name, a fee is charged.
When both sender and receiver are connected to the two different mail servers via a LAN or a
WAN, we need two User agents UAs, two pairs of MTAs (client and server), and a pair of
MAAs (client and server). This is the most common situation today
• Format of an e-mail
Format of an e-mail
Email address format
The local part for a particular user it is the name of a special file, i.e. the user mailbox
domain name : An organization usually selects one or more hosts to receive and send e-mail;
they are sometimes called mail servers or exchangers.
Limitation of email
Electronic mail has a simple structure. Its simplicity, however It can send messages only in NVT
7-bit ASCII format.
For example, it cannot be used for languages that are not supported by 7-bit ASCII characters
(such as,, Hebrew, Russian, Chinese, and Japanese , marathi ).
Also, it cannot be used to send binary files or video or audio data.
Solution:
Multipurpose Internet Mail Extensions (MIME) is a supplementary protocol that allows non-
ASCII data to be sent through e-mail.
is a supplementary protocol that allows non-ASCII data to be sent through e-mail. Because
Electronic mail can send messages only in NVT 7-bit ASCII format.
For example, it cannot be used for languages that are not supported by 7-bit ASCII characters
(such as,, Hebrew, Russian, Chinese, and Japanese , marathi ).
Also, it cannot be used to send binary files or video or audio data.
MIME transforms non-ASCII data at the sender site to NVT ASCII data and delivers them to the
client MTA to be sent through the Internet. The message at the receiving side is transformed
back to the original data.
MIME defines five headers that can be added to the original e-mail header section to define the
transformation parameters:
1. MIME-Version
2. Content-Type
3. Content-Transfer-Encoding
4. Content-Id
5. Content-Description
Message transfer
• Connection termination
MESSAGE ACCESS AGENT: POP AND IMAP
The first and the second stages of mail delivery use SMTP. However, SMTP is not involved in
the third stage because SMTP is a push protocol.
the third stage needs a pull protocol; the client must pull messages from the server. The third
stage uses a message access agent.
two message access protocols are available: POP3 , IMAP4
POP3 IMAP4
Mail access Agent Mail access Agent
simple and limited in functionality more complex & More functionality
It does not allow the user to organize her mail on A user can create, delete, or rename
the server; the user cannot have different folders mailboxes on the mail server.
on the server A user can create a hierarchy of mailboxes
in a folder for e-mail storage.
A user can partially download e-mail. This is
especially useful if bandwidth is limited and
A user can not partially download e-mail.
the e-mail contains multimedia with high
bandwidth requirements.
does not allow the user to partially check the does not allow the user to partially check the
contents of the mail before downloading contents of the mail before downloading
A user can check the e-mail header before A user can check the e-mail header before
downloading. downloading.
A user can not search the contents of the e-mail A user can search the contents of the e-mail
for a specific string of characters before for a specific string of characters before
downloading downloading
Case I
the sender, uses a traditional mail server;, the receiver, has an account on a Web-based server.
• Mail transfer from Alice’s browser to her mail server is done through SMTP. The
transfer of the message from the sending mail server to the receiving mail server is still
through SMTP.
• However, the message from the receiving server (the web server) to receiver browser is
done through HTTP, instead of using POP3 or IMAP4. When receiver needs to retrieve
his e-mails, he sends a request HTTP message to the website (Hotmail, for example). The
website sends a form to be filled in by receiver, which includes the log-in name and the
password. If the log-in name and password match, the list of e-mails is transferred from
the Web server to receiver browser in HTML format. Now receiver can browse through
his received e-mails and then, using more HTTP transactions, can get his e-mails one by
one
Case II
both sender and receiver use Web servers, but not necessarily the same server. ( eg sender using
gmail.com receiver using yahoo.com)
• Sender sends an HTTP request message to her Web server using the name and address
of receiver’s mailbox as the URL. The server at the sender site passes the message to the
SMTP client and sends it to the server at the receiver site using SMTP protocol.
• receiver retrieves the message using HTTP transactions. However, the message from the
server at the sender site to the server at the receiver site still takes place using SMTP
protocol.
Why is it required:
Every node connected to a network , must have an IP address . It can be assigned either manually
or automatically . Manual assigning of IP to every node is tedious . So it is automated by using
DHCP.
1. Dynamic allocation
A network administrator sets a range of IP addresses in DHCP server, . The IP addresses are
given on lease for a time period. Devices release their IP addresses when their DHCP leases
expire and then request a renewal from the DHCP server if they are staying online. The DHCP
server may assign a new address rather than renewing an old one.
2. Automatic allocation
The DHCP server permanently assigns an IP address to a requesting client from a range defined
by an administrator. This is like dynamic allocation, but the DHCP server keeps a table of past IP
address assignments, so that it can preferentially assign to a client the same IP address that the
client previously had.
3. static allocation
This method is also called static DHCP allocation/ fixed address allocation/reservation,
and MAC/IP address binding. Devices such as web servers and switches are assigned
permanent IP addresses.
4. Manual
In this mapping the IP addresses to physical addresses needs to be manually configured. This
means that every time there is a change in a physical or IP address, the administrator needs to
manually enter the changes.
Thus DHCP provides static and dynamic address allocation that can be manual or
automatic.
In DHCP, the client is one which requests for IP address and the DHCP server assigns IP
address. To get IP address from DHCP server, the client uses UDP protocol.
DHCP port number for DHCP server is 67 and for the DHCP client is 68.
Client & server exchange mainly 4 DHCP messages in order to make a connection, also called
DORA process, but there are total 8 DHCP messages in the process.
Other messages
DHCP negative acknowledgement message –
Whenever a DHCP server receives a request for IP address that is invalid according to the
scopes that is configured with, it send DHCP Nak message to client. Eg-when the server
has no IP address unused or the pool is empty, then this message is sent by the server to
client.
DHCP decline –
If DHCP client determines the offered configuration parameters are different or invalid, it
sends DHCP decline message to the server .When there is a reply to the gratuitous ARP
by any host to the client, the client sends DHCP decline message to the server showing
the offered IP address is already in use.
DHCP release –
A DHCP client sends DHCP release packet to server to release IP address and cancel any
remaining lease time.
DHCP inform –
If a client address has obtained IP address manually then the client uses a DHCP inform
to obtain other local configuration parameters, such as domain name. In reply to the dhcp
inform message, DHCP server generates DHCP ack message with local configuration
suitable for the client without allocating a new IP address. This DHCP ack message is
unicast to the client.
To get IP address from DHCP server, the client uses UDP protocol
DHCP port number for DHCP server is 67 and for the DHCP client is 68.