TRIVIAL FILE TRANSFER
PROTOCOL (TFTP)
McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000
Introduction
Many times, we need to simply copy a file w/o
the need for all the features of the FTP. E.g.
when a diskless workstation or a router is booted, it
is required to download the bootstrap &
configuration files. Here all the features of FTP are
not required.
Trivial File Transfer Protocol (TFTP) is designed for
these types of file transfer. It is so simple that, it
can fit into ROM of a diskless workstation & can be
used at bootstrap time.
It requires only IP & UDP. But it has no security. It
can read or write a file for the client.
TFTP uses the service of UDP on the well-known
port 69.
TCP/IP Protocol Suite 2
TFTP Message
TCP/IP Protocol Suite 3
TFTP Message ….
There are five types of TFTP message – RRQ, WRQ,
DATA, ACK and ERROR as shown in next figure.
1) The RRQ message is used by the client to establish a
connection for reading data from the server.
2) The WRQ message is used by the client to establish a
connection for writing a data to the server.
3) The DATA message is used by the client or the server
to send blocks of data.
4) The acknowledge (ACK) message is used by the client
or the server to acknowledge the receipt of a data
block.
5) The ERROR message is used by the client or the
server when a connection cannot be established or
when there is a problem during data transmission. It
can be sent as a negative response to RRQ or WRQ.
TCP/IP Protocol Suite 4
Connection
TFTP uses UDP services. There is no provision for
connection establishment or termination in UDP, it
transfers each block of data being encapsulated in
an independent user datagram.
But in TFTP we need connection for the blocks of
data being transferred if they all belong to the
same file. It uses RRQ, WRQ, and ACK & ERROR
message to establish connection.
It uses the data message with a block of data of
less than 512 bytes (0 – 511) to terminate
connection.
Connection Establishment & Termination
Connection establishment for reading and writing
files is
TCP/IP Protocol different as shown in next figure.
Suite 5
TCP/IP Protocol Suite 6
Reading – TFTP send RRQ message which contains
name of the file & transmission mode. If the sever
can transfer the file, it responds positively with
DATA message. If there is any problem, server
responds negatively by sending an ERROR message.
Writing – In this case, TFTP uses WRQ message
mentioning the name of the file & transmission
mode. If the server can accept a copy of the file, it
responds positively with an ACK message & in case
of problem, it responds negatively with an ERROR
message.
After the entire file is transferred, the connection
must be terminated. As TFTP does not have a
special message for termination, it is accomplished
by sending the last block of data which is less than
512 bytes.
TCP/IP Protocol Suite 7
Data Transfer
It is in between the connection establishment &
termination. TFTP uses the service of UDP, which
is unreliable.
The file is divided into blocks of data in which
each block except the last one is exactly 512
bytes long. TFTP can transfer data in ASCII or
binary format.
As UDP doesn’t have flow & error control
mechanism, TFTP has to create it.
TCP/IP Protocol Suite 8
UDP Ports
With UDP, the server process issues a passive
open on the well-known port 69 & waits for the
client process.
A client actively opens a connection using an
ephemeral port. It is done through RRQ or WRQ
message.
The server actively opens a connection using a
new ephemeral port received from the client as
the destination port. It sends DATA or ACK or
ERROR message using these ports.
This frees the well-known port 69 for use by other
clients. It is shown in figure.
TCP/IP Protocol Suite 9
TCP/IP Protocol Suite 10
HTTP
McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000
Introduction
The WWW today is a distributed client-server
service, in which a client using a browser can
access a service using a server.
However, 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 (simple) or other sites
(composite). Each Web page is a file with a name
and address.
TCP/IP Protocol Suite 12
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 other textual document or
documents containing graphics, video, or audio.
Web Client (Browser)
A variety of vendors offer commercial browsers
that interpret and display a Web document, and all
of them use nearly the same architecture. Each
browser usually consists of three parts: a
controller, client protocol, and interpreters.
TCP/IP Protocol Suite 13
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.
TCP/IP Protocol Suite 14
Web Server
The Web page is stored at the server. Each time a
client request arrives, the corresponding
document is sent to the client. Some popular Web
servers include Apache and Microsoft Internet
Information Server.
Uniform Resource Locator (URL)
A client that wants to access a Web page needs
the file name and the address. To facilitate the
access of documents distributed throughout the
world, HTTP uses locators. The uniform resource
locator (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.
TCP/IP Protocol Suite 15
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 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”. This is not
mandatory, however, as the host can have any domain
name.
The URL can optionally contain the port number of the
server. If the port is included, it is inserted between the host
and the path, and it is separated from the host by a colon.
Path is the pathname of the file where the information is
located. Note that the path can itself contain slashes that, in
the UNIX operating system, 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.
16
HTTP
The Hypertext Transfer Protocol (HTTP) is a protocol
used mainly to access data on the World Wide Web.
HTTP functions like a combination of FTP and SMTP.
It is similar to FTP because it transfers files and uses
the services of TCP. However, it is much simpler
than FTP because it uses only one TCP connection.
There is no separate control connection; only data
are transferred between the client and the server.
HTTP is like SMTP because the data transferred
between the client and the server look like SMTP
messages. In addition, the format of the messages
is controlled by MIME-like headers. Unlike SMTP, the
HTTP messages are not destined to be read by
humans; they are read and interpreted by the HTTP
server and HTTP client (browser).
TCP/IP Protocol Suite 17
SMTP messages are stored and forwarded, but HTTP
messages are delivered immediately. The
commands from the client to the server are
embedded in a request message. The contents of
the requested file or other information are
embedded in a response message.
HTTP uses the services of TCP on well-known port
80.
HTTP Transaction
Figure next, illustrates the HTTP transaction between
the client and server. 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.
TCP/IP Protocol Suite 18
TCP/IP Protocol Suite 19
Persistence
HTTP, prior to version 1.1, specified a nonpersistent
connection, while a persistent connection is the default in
version 1.1.
Nonpersistent Connection
In a nonpersistent connection, one TCP connection is
made for each request/response. The following lists the
steps in this strategy:
1. The client opens a TCP connection and sends a request.
2. The server sends the response and closes the
connection.
3. The client reads the data until it encounters an end-of-
file marker; it then closes the connection.
In this strategy, if a file contains link to N different
pictures in different files (all located on the same server),
the connection must be opened and closed N + 1 times.
TCP/IP Protocol Suite 20
The nonpersistent strategy imposes high overhead on
the server because the server needs N + 1 different
buffers and requires a slow start procedure each time
a connection is opened.
Figure shows an example of a nonpersistent
connection. The client needs to access a file that
contains two links to images. The text file and images
are located on the same server.
21
TCP/IP Protocol Suite 22
Persistent Connection
HTTP version 1.1 specifies a persistent connection by
default.
In a persistent connection, the server leaves the
connection open for more requests after sending a
response. The server can close the connection at the
request of a client or if a time-out has been reached.
The sender usually sends the length of the data with each
response. However, there are some occasions when the
sender does not know the length of the data. This is the
case when a document is created dynamically or actively.
In these cases, the server informs the client that the
length is not known and closes the connection after
sending the data so the client knows that the end of the
data has been reached.
Figure next shows the same scenario as in previous
example using persistent connection.
23
24