Chapter 5
Application Layer
Introduction to World Wide Web
The World Wide Web (WWW) is a collection of documents and other web
resources which are identified by URLs, interlinked by hypertext links, and can
be accessed and searched by browsers via the Internet.
World Wide Web is also called the Web and it was invented by Tim Berners-Lee
in 1989.
Website is a collection of web pages belonging to a particular organization.
The pages can be retrieved and viewed by using browser.
Client (Browser):
Web browser is a program, which is used to communicate with web server on
the Internet.
Each browser consists of three parts: a controller, client protocol and
interpreter.
The controller receives input from input device and use the programs to access
the documents.
After accessing the document, the controller uses one of the interpreters to
display the document on the screen.
Server:
A computer which is available for the network resources and provides service
to the other computer on request is known as server.
The web pages are stored at the server.
Server accepts a TCP connection from a client browser.
It gets the name of the file required.
Server gets the stored file. Returns the file to the client and releases the top
connection.
Uniform Resource Locater (URL)
The URL is a standard for specifying any kind of information on the Internet.
The URL consists of four parts: protocol, host computer, port and path.
The protocol is the client or server program which is used to retrieve the
document or file. The protocol can be ftp or http.
The host is the name of computer on which the information is located.
The URL can optionally contain the port number and it is separated from the
host name by a colon.
Path is the pathname of the file where the file is stored.
Non-Persistent Connection
1. Without parallel connection
2. With parallel connection
Without parallel connection Non-Persistent
Each objection takes two RTT (assuming no window limit) one for TCP connection and
other for HTTP image/text file.
Persistent connection
1. Non-Pipelined
2. Pipelined
In Non-pipeline connection we first establish connection which takes two RTT then we
send all the objects images/text files which takes 1 RTT each (TCP for each object is
not required).
In Pipelined connection 2RTT for connection establishment and then 1RTT(assuming
no window limit) for all the objects i.e. images/text.
File Transfer Protocol (FTP) in Application Layer
File Transfer Protocol(FTP) is an application layer protocol which moves files between
local and remote file systems. It runs on the top of TCP, like HTTP. To transfer a file, 2
TCP connections are used by FTP in parallel: control connection and data connection.
What is control connection?
For sending control information like user identification, password, commands to change
the remote directory, commands to retrieve and store files, etc., FTP makes use of
control connection. The control connection is initiated on port number 21.
What is data connection?
For sending the actual file, FTP makes use of data connection. A data connection is
initiated on port number 20.
FTP sends the control information out-of-band as it uses a separate control connection.
Some protocols send their request and response header lines and the data in the same
TCP connection. For this reason, they are said to send their control information in-band.
HTTP and SMTP are such examples.
FTP Session :
When a FTP session is started between a client and a server, the client initiates a
control TCP connection with the server side. The client sends control information over
this. When the server receives this, it initiates a data connection to the client side. Only
one file can be sent over one data connection. But the control connection remains
active throughout the user session. As we know HTTP is stateless i.e. it does not have
to keep track of any user state. But FTP needs to maintain a state about its user
throughout the session.
Data Structures : FTP allows three types of data structures :
1. File Structure – In file-structure there is no internal structure and the file is
considered to be a continuous sequence of data bytes.
2. Record Structure – In record-structure the file is made up of sequential records.
3. Page Structure – In page-structure the file is made up of independent indexed
pages.
FTP Commands – Some of the FTP commands are :
USER – This command sends the user identification to the server.
PASS – This command sends the user password to the server.
CWD – This command allows the user to work with a different directory or dataset for
file storage or retrieval without altering his login or accounting information.
RMD – This command causes the directory specified in the path-name to be removed
as a directory.
MKD – This command causes the directory specified in the pathname to be created as
a directory.
PWD – This command causes the name of the current working directory to be returned
in the reply.
RETR – This command causes the remote host to initiate a data connection and to
send the requested file over the data connection.
STOR – This command causes to store a file into the current directory of the remote
host.
LIST – Sends a request to display the list of all the files present in the directory.
ABOR – This command tells the server to abort the previous FTP service command and
any associated transfer of data.
QUIT – This command terminates a USER and if file transfer is not in progress, the
server closes the control connection.
FTP Replies –
Some of the FTP replies are :
200 Command okay.
530 Not logged in.
331 User name okay, need a password.
225 Data connection open; no transfer in progress.
221 Service closing control connection.
551 Requested action aborted: page type unknown.
502 Command not implemented.
503 Bad sequence of commands.
504 Command not implemented for that parameter.
Trivial File Transfer Protocol (TFTP): It is also file transfer protocol without
sophisticated features of FTP.
It is good for simple file transfers, such as during boot time.
It uses UDP as transport layer protocols. Errors in the transmission (lost packets,
checksum errors) must be handled by the TFTP server.
It uses only one connection through well-known port 69.
TFTP uses a simple lock-step protocol (each data packet needs to be
acknowledged). Thus the throughput is limited
Electronics Mail
Along with the Web, electronic mail is one of the most popular Internet applications. Just
like ordinary "snail mail," email is asynchronous – people send and read messages
when it is convenient for them, without having to coordinate with other peoples'
schedules.
In contrast with snail mail, electronic mail is fast, easy to distribute, and inexpensive.
Moreover, modern electronic mail messages can include hyperlinks, HTML formatted
text, images, sound and even video.
In this section we will examine the application-layer protocols that are at the heart of
Internet electronic mail. But before we jump into an in-depth discussion of these
protocols, let's take a bird's eye view of the Internet mail system and its key
components.
Fig. view of the Internet e-mail system.
Dynamic Host Configuration Protocol (DHCP) is an application layer protocol used to
distribute network configuration parameters, such as IP addresses, subnet masks,
default gateways, etc. to hosts on a TCP/IP network. Assigning network
parameters using DHCP reduces the amount of work of a network administrator, since
there is no need to statically configure parameters on each device.
DHCP employs a client-server architecture; a DHCP client is configured to request
network parameters from a DHCP server. A DHCP server is configured with a pool of
available IP addresses and assigns one of them to the DHCP client. Besides IP
addresses, a DHCP server can provide some additional network parameters, such as:
subnet mask
default gateway
domain name
DNS server
Here is an overview of the DHCP process:
As you can see from the picture above, a DHCP client goes through the four-step
process:
1. A DHCP client sends a broadcast packet (DHCPDiscover) to discover DHCP servers
on the network.
2. The DHCP server receives the DHCPDiscover packet and respond with
a DHCPOffer packet, offering IP addressing information to the DHCP client.
3. If there is more than one DHCP server on the network segment and the DHCP client
receives more than one DHCPOffer packets, the client will accept the first DHCPOffer
packet. The DHCP client responds by broadcasting a DHCPRequest packet,
requesting network parameters from the DHCP server.
4. The DHCP server approves the lease with a DHCPACK
(Acknowledgement) packet. The packet includes the lease duration and other
configuration information.
DHCP Allocation Methods:
o Manual Allocation: A particular IP address is pre-allocated to a single
device by an administrator. DHCP only communicates the IP address to
the device.
o Automatic Allocation: DHCP automatically assigns an IP address
permanently to a device, selecting it from a pool of available addresses.
o Dynamic Allocation: DHCP assigns an IP address from a pool of
addresses for a limited period of time chosen by the server, or until the
client tells the DHCP server that it no longer needs the address.
Dynamic Host Configuration Protocol (DHCP) Message Format
All Dynamic Host Configuration Protocol (DHCP) messages include a FIXED format section and a
VARIABLE format section. The fixed format section consists of several fields that are the same in every
Dynamic Host Configuration Protocol (DHCP) message. The variable format section in the Dynamic Host
Configuration Protocol (DHCP) contains "OPTIONS", which carry additional configuration parameters.
Dynamic Host Configuration Protocol (DHCP) Message Format
DHCP Message Description
Field
Specifies the type of the Dynamic Host Configuration Protocol (DHCP) message. Set to 1 in messages sent by a client
Operation Code
(requests) and 2 in messages sent by a server (response).
Hardware Type Specifies the network LAN architecture. For example, the ethernet type is specified when htype is set to 1.
Hardware Address Layer 2 (Data-link layer) address length (MAC address) (in bytes); defines the length of hardware address in the
Length chaddr field. For Ethernet (Most widely used LAN Standard), this value is 6.
Hops Number of relay agents that have forwarded this message.
Transaction
Used by clients to match responses from servers with previously transmitted requests.
identifier
seconds Elapsed time (in seconds) since the client began theDynamic Host Configuration Protocol (DHCP) process.
Flags Flags field is called the broadcast bit, can be set to 1 to indicate that messages to the client must be broadcast
ciaddr Client�s IP address; set by the client when the client has confirmed that its IP address is valid.
yiaddr Client�s IP address; set by the server to inform the client of the client�s IP address.
IP address of the next server for the client to use in the configuration process (for example, the server to contact for
siaddr
TFTP download of an operating system kernel).
Relay agent (gateway) IP address; filled in by the relay agent with the address of the interface through which Dynamic
giaddr
Host Configuration Protocol (DHCP) message was received.
chaddr Client�s hardware address (Layer 2 address).
sname Name of the next server for client to use in the configuration process.
Name of the file for the client to request from the next server (for example the name of the file that contains the
file
operating system for this client).