0% found this document useful (0 votes)
15 views

Unit 5

Subject: Computer Network security notes

Uploaded by

Pradnya
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views

Unit 5

Subject: Computer Network security notes

Uploaded by

Pradnya
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 187

Unit - V

World Wide Web:


HTTP
Objectives
Upon completion you will be able to:

• Understand the components of a browser and a server


• Understand the function of the URL and cookies
• Understand how HTML is related to static documents
• Understand how CGI is related to dynamic documents
• Understand how Java is related to active documents
• Know how HTTP accesses data on the WWW
TCP/IP Protocol Suite 1
Introduction

 The World Wide Web(WWW) is a repository of


information linked together from points all over the
world.

 The WWW has a unique combination of flexibility,


portability, & user-friendly features that distinguish it
from other services provided by the Internet.

 In this chapter we first discuss issues related to the


Web. We then discuss a protocol, HTTP, that is used to
retrieve information from the web.

TCP/IP Protocol Suite 2


1 ARCHITECTURE of WWW

The WWW 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 as shown bellow.

3
Cont..

 The client needs to see some information it knows


belong to site A.

 It sends a request, through its browser, a program that


is designed to fetch Web documents.

 The request among other information, includes the


address of the site & the web page, called the URL.

TCP/IP Protocol Suite 4


Client(Browser)
 A variety of venders offer commercial browsers that
interpret & display a Web document.

 Each browser usually consist of three parts: a controller,


client protocol, & interpreters.

 The controller receives input from the keyboard or the


mouse & uses the client programs to access the
document.

 After the document has been accessed, the controller


uses interpreter to display document on the screen.

TCP/IP Protocol Suite 5


Cont…

 The client protocol is one protocols described previously


such as FTP or TELNET or HTTP.

 The interpreter can be HTML, java, or JavaScript,


depending upon the type document.

6
Server

 The Web page is stored at server. 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.

TCP/IP Protocol Suite 7


Uniform Resource Locator(URL)

 A client that wants to access a Web page needs the


address. To facilitate the access of documents
distributed throughout the world, HTTP uses locators.

 The uniform resource locator(URL) is standard for


specifying any kind of information on the internet.

 The URL defines four things: protocol, host computer,


port, & path as shown below.

8
Cont..
 The protocol is the client-server program used to
retrieve the document. Different protocols can retrieve a
document; among them are FTP, HTTP, & TELNET.

 The host is the computer on which the information is


located, although the name of the computer can be an
alias.

 Web pages are usually stored in computers, &


computers are given alias names that usually begin with
the characters “www”.

TCP/IP Protocol Suite 9


Cont..

 The URL can optionally contain the port number of the


server. If the port is included, it is inserted between the
host & the path, & it is separated from the host by
colon.

 Path is the pathname of file where the information is


located.

 For example:- http://www.google.com/

TCP/IP Protocol Suite 10


2 WEB DOCUMENTS
The documents in the WWW can be grouped into three broad categories:
static, dynamic, and active. The category is based on the time the
contents of the document are determined.

Static Documents

Dyanamic web page

Active Web page

TCP/IP Protocol Suite 11


Figure 4 Static document
Static document are fixed- content documents that
are created & stored in a server.

12
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 a dynamic
document.

 The server returns the output of the program or a script


as a response to the browser that requested the
document.

TCP/IP Protocol Suite 13


Common Gateway Interface(CGI)

 The Common Gateways Interface(CGI) is a technology


that creates & handles dynamic documents. CGI is a set
of standards that defines how a dynamic document is
written, how data are input to the program, & how
output result is used.

 CGI is not a new language; instead, it allows


programmers to use any of several languages such as C,
C++, Bourne shell etc.

 The only thing that CGI defines is a set of rules & terms
that the programmer must follow.
TCP/IP Protocol Suite 14
Figure 8 Dynamic document using CGI

TCP/IP Protocol Suite 15


Figure 9 Dynamic document using server-site script

TCP/IP Protocol Suite 16


Note:

Dynamic documents are sometimes


referred to as server-site dynamic
documents.

TCP/IP Protocol Suite 17


Figure 10 Active document using Java applet

TCP/IP Protocol Suite 18


Figure 11 Active document using client-site script

TCP/IP Protocol Suite 19


Note:

Active documents are sometimes


referred to as client-site dynamic
documents.

TCP/IP Protocol Suite 20


3 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.

The topics discussed in this section include:

HTTP Transaction
Persistent versus Nonpersistent Connection
Proxy Server

TCP/IP Protocol Suite 21


Note:

HTTP uses the services of TCP on


well-known port 80.

TCP/IP Protocol Suite 22


Figure 12 HTTP transaction

TCP/IP Protocol Suite 23


Figure 13 Request and response messages

TCP/IP Protocol Suite 24


Figure 14 Request and status lines

TCP/IP Protocol Suite 25


Table 1 Methods

TCP/IP Protocol Suite 26


Table 2 Status codes

TCP/IP Protocol Suite 27


Table 2 Status codes (continued)

TCP/IP Protocol Suite 28


Figure 15 Header format

TCP/IP Protocol Suite 29


Table 3 General headers

TCP/IP Protocol Suite 30


Table 4 Request headers

TCP/IP Protocol Suite 31


Table 5 Response headers

TCP/IP Protocol Suite 32


Table 6 Entity headers

TCP/IP Protocol Suite 33


Example 1

This example retrieves a document. We use the GET method to


retrieve an image with the path /usr/bin/image1. The request
line shows the method (GET), the URL, and the HTTP version
(1.1). The header has two lines that show that the client can
accept images in the GIF or JPEG format. The request does
not have a body. The response message contains the status line
and four 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 (see Figure 22.16).

See Next Slide

TCP/IP Protocol Suite 34


Figure 16 Example 1

TCP/IP Protocol Suite 35


Example 2

In this example, the client wants to send data to the server. We


use the POST method. The request line shows the method
(POST), URL, and HTTP version (1.1). There are four lines of
headers. The request body contains the input information. The
response message contains the status line and four lines of
headers. The created document, which is a CGI document, is
included as the body (see Figure 22.17).

See Next Slide

TCP/IP Protocol Suite 36


Figure 17 Example 2

TCP/IP Protocol Suite 37


Example 3

HTTP uses ASCII characters. A client can directly connect to a


server using TELNET, which logs into port 80. The next three
lines shows that the connection is successful. We then type
three lines. The first shows the request line (GET method), the
second is the header (defining the host), the third is a blank
terminating the request. The server response is seven lines
starting with the status line. The blank line at the end
terminates the server response. The file of 14230 lines is
received after the blank line (not shown here). The last line is
the output by the client.

See Next Slide


TCP/IP Protocol Suite 38
Example 3

$ telnet www.mhhe.com 80
Trying 198.45.24.104...
Connected to www.mhhe.com (198.45.24.104).
Escape character is '^]'.
GET /engcs/compsci/forouzan HTTP/1.1
From: [email protected]
HTTP/1.1 200 OK
Date: Thu, 28 Oct 2004 16:27:46 GMT
Server: Apache/1.3.9 (Unix) ApacheJServ/1.1.2 PHP/4.1.2 PHP/3.0.18
MIME-version:1.0
Content-Type: text/html
Last-modified: Friday, 15-Oct-04 02:11:31 GMT
Content-length: 14230
Connection closed by foreign host.
TCP/IP Protocol Suite 39
Note:

HTTP version 1.1 specifies a persistent


connection by default.

TCP/IP Protocol Suite 40


Unit 5 - Domain Name System: DNS

Objectives
Upon completion you will be able to:

• Understand how the DNS is organized


• Know the domains in the DNS
• Know how a name or address is resolved
• Be familiar with the query and response formats
• Understand the need for Dynamic Domain Name System ( DDNS)

41 TCP/IP Protocol Suite


1 NAME SPACE

The names assigned to machines must be unique because the addresses


are unique. A name space that maps each address to a unique name can
be organized in two ways: flat or hierarchical.

Flat Name Space :- In a flat name space, a name is assigned to an


address. A name in this space is a sequence of characters without
structure.

Hierarchical Name Space:- In a hierarchical name space, each


name is made of several parts. The first part can define nature of the
organization, the second part can define the name of an organization
, third part can define departments in the organization.

42 TCP/IP Protocol Suite


2 DOMAIN NAME SPACE

The domain name space is hierarchical in design. The names are defined
in an inverted-tree structure with the root at the top. The tree can have
128 levels: level 0 (root) to level 127.

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.

Domain Name :- Each node in the tree has a domain name. A


full domain name is sequence of labels separated by dots(.). The
last label is the label of the root (null). The domain names are
always read from the node up to the root.

43 TCP/IP Protocol Suite


Figure 1 Domain name space

Root label

Labels

44 TCP/IP Protocol Suite


Figure 2 Domain names and labels

45 TCP/IP Protocol Suite


Fully Qualified Domain Name (FQDM)

 If the label is terminated by a null string, it is called a fully qualified domain


name (FQDN).

 A FQDN is a domain name that contains the full name of a host.

 It contains all labels, from the specific to the most general, that uniquely
define the name of the host.

Partially Qualified Domain Name (PQDN):-

 If the label is not terminated by a null string, it is called a partially qualified


domain name (PQDN).

 A PQDN starts from a node, but it does not reach the root.

46 TCP/IP Protocol Suite


Figure 3 FQDN and PQDN

47 TCP/IP Protocol Suite


Figure 4 Domains
 A domain is a sub-tree of the domain name space. Note that a domain
may itself be divided into domains or sub-domains.

48 TCP/IP Protocol Suite


3 DISTRIBUTION OF NAME SPACE

It is very insufficient & also not reliable to have just one computer store
such a huge amount of information.

Hierarchy of Name Servers:-

The solution to these problems is to distribute the information among


many computers called DNS servers.

One way to do this is to divide whole space into many domains based
on the first level.

In other words, let the root stand alone & create as many domains
(sub- trees) as there are first-level nodes as shown in diagram.

49 TCP/IP Protocol Suite


Figure 5 Hierarchy of name servers

50 TCP/IP Protocol Suite


Note:

 There are 16.3 million domain name system (DNS) servers as of


2008. This is according to a news report published in Government
Computer News (GCN) on November 16, 2009. This number
represented a 39% increase in DNS servers from 2007 to 2008, and
current numbers may very well be double.

There are 13 root servers in the world


The A-root is the main DNS server
Almost all root servers are located in the USA

51 TCP/IP Protocol Suite


Root Server

 A root server is a server whose zone consist of the whole tree.

 A root server usually does not store any information about domains
but delegates its authority to other servers, keeping references to
those servers.

52 TCP/IP Protocol Suite


Zone
 Since the complete domain name hierarchy cannot be stored on
a single server, it is divided among many servers. What a server
is responsible for or has authority over is called a Zone.

 We can define a zone as a contiguous (adjacent) part of the


entire tree.

 The server makes a database called a zone file & keeps all the
information for every node under that domain.

53 TCP/IP Protocol Suite


Figure 6 Zones and domains

54 TCP/IP Protocol Suite


Primary & Secondary Servers
 A primary server is a server that stores a file about the zone
for which it is authority.

 It is responsible for creating, maintaining, & updating the zone


file. It stores the file on its local disk.

 A secondary server is server that transfers the complete


information about a zone from another server (primary or
secondary) & stores the file on its local disk.

 The secondary server neither creates nor updates the zone files.

55 TCP/IP Protocol Suite


Note:

A primary server loads all information from the disk file; the
secondary server loads all information from the primary
server. When the secondary downloads information from the
primary, it is called zone transfer.

56 TCP/IP Protocol Suite


4 DNS IN THE INTERNET

In the Internet, the domain name space (tree) is divided into three
different sections: generic domains, country domains, and the inverse
domain.

57 TCP/IP Protocol Suite


Generic Domains

 The generic domains define registered hosts according to their


generic behavior.

14 possible labels in the first level

58 TCP/IP Protocol Suite


Table 4.1 Generic domain labels

59 TCP/IP Protocol Suite


Table 4.1 Generic domain labels (Continued)

60 TCP/IP Protocol Suite


Country Domains

 The country domains section uses two-character country


abbreviations (i.e. us for United States). Second labels can be
organizational, or they can be more specific, national
designations.

 For example:- The address anza.cup.ca.us can be translated to


De Anza College in Cupertino in California in United States.

61 TCP/IP Protocol Suite


Figure 9 Country domains

62 TCP/IP Protocol Suite


Inverse Domain

 The inverse domain is used to map an address to a name.

 For Example:- If server has received a request from a client to


do a task. Server has a file that contains a list of authorized
clients IP addresses.

 Server asks its resolver to send a query to the DNS server to


map an addresses to a name to determine if the client is
authorized. This type of query is called an inverse or pointer
(PTR) query.

63 TCP/IP Protocol Suite


Cont..

 To handle a pointer query, the inverse domain is added to the


domain name space with the first level node called arpa.

 The second level is also one single node named in-addr The rest
domain defines IP addresses.

 To follow the convention of reading the domain labels from the


bottom to the top, an IP address such as 132.34.45.121 is read
as 121.45.34.132.

64 TCP/IP Protocol Suite


Figure 10 Inverse domain

First Level node

Second Level node

65 TCP/IP Protocol Suite


5 DNS MESSAGES

DNS has two types of messages: query & response.

66 TCP/IP Protocol Suite


Figure 14 Query and response messages

The DNS query message consists of a header and question


records; the DNS response message consists of a header, question
records, answer records, authoritative records, and additional
records.

67 TCP/IP Protocol Suite


Header

 Both query & response have same header format with some
fields set to zero for query messages. The header is 12 byte(96-
bit) & its format is shown bellow.

16-bit 16-bit

16-bit 16-bit

16-bit 16-bit

Figure15 Header format

68 TCP/IP Protocol Suite


Identification

 This is a 16-bit field used by the client to match the response


with the query. The client uses a different identification number
each time it sends a query.

Flags:- This is a 16-bit field consisting of the subfields shown below.

Figure 16 Flags field

69 TCP/IP Protocol Suite


Flags field

a) QR (query/ response):- This is a 1-bit subfield that defines the


type of message. If it is 0, the message is a query. If it is 1, the
message is a response.
b) OpCode:- This is a 4-bit subfield that defines the type of query or
response (0 if standard, 1 if inverse, & 2 if server status request).
c) AA (authorize answer):- This is a 1-bit subfield. When it is 1 it
means that the name sever is an authoritative server.
d) TC (truncated):- This is a 1-bit subfield. When it is 1 means that
the response was more than 512 bytes & truncated to 512.
e) RD (recursion desired):- This is a 1 bit subfield. When it set to 1
means recursive response is available.
f) Reserved :- This is a 3-bit subfield set to 000.
g) rCode:- This is 4-bit field that shows the status of the error in the
response.

70 TCP/IP Protocol Suite


Table 2 Values of rCode

71 TCP/IP Protocol Suite


Header Format Cont..
 Number of question records:- This is a 16-bit field containing
the number of queries in the question section of the message.

 Number of answer records:- This is a 16-bit field containing


the number of answer records in the answer section of the response
message.

 Number of authoritative records:- This is a 16-bit field


containing the number of authoritative records in the authoritative
section of the response message.

 Number of additional records:- This is a 16-bit field


containing the number of additional records in the additional section
of a the response message.

72 TCP/IP Protocol Suite


Response Messages
 Question Section:- This is a section consisting of one or more
question records. It is present in both query & response messages.

 Answer Section:- This is a section consisting of one or more


resources records. It is present only on the response messages
(answer from server to client) (Resource records).

 Authoritative Section:- This is a section gives information (domain


name) about one or more authoritative servers for the query.
(Resource records).

 Additional Information Section:- This section provides additional


information that may help the resolver. (Resource records).

73 TCP/IP Protocol Suite


7 TYPES OF RECORDS

As we have seen in the previous section, two types of records are used in
DNS.
The question records are used in the question section of the query and
response messages.

The resource records are used in the answer, authoritative, and


additional information sections of the response message.

74 TCP/IP Protocol Suite


Question Record

 A question record is used by the client to get information from the


server.

Figure 17 Question record format

75 TCP/IP Protocol Suite


Question record has following fields

 Query name:- This is variable-length field containing domain


name.

Figure 18 Query name format

76 TCP/IP Protocol Suite


Query type:- 16-bit field defining the type of
query.

Table 3 Types

77 TCP/IP Protocol Suite


Query class:-
 This is 16-bit field defining the specific protocol using DNS.

Table 4 Classes

78 TCP/IP Protocol Suite


Resource Record
 Each domain name (each node on the tree) is associated with a
record called resource record.

Figure 19 Resource record format


79 TCP/IP Protocol Suite
Resource record (cont..)
 Domain Name:- This is variable-length field containing the domain
name.

 Domain Type:- This field is the same as the query type field in the
question record except the last two types are not allowed.

 Domain class:- This field is the same as the query class field in the
question record.

 Time to live:- This is 32-bit field that defines number of seconds


the answer is valid. The receiver can cache the answer for this
period of time.

80 TCP/IP Protocol Suite


Cont..

 Resource data length :- This is 16-bit field defining the length of


the resource data.

 Resource data:- This is a variable-length field containing the


answer to the query (in the answer section) or the domain name of
the authoritative server (in the authoritative section) or additional
information (in the additional information section)

81 TCP/IP Protocol Suite


Example 1

A resolver sends a query message to a local server to find the


IP address for the host “chal.fhda.edu.”. We discuss the query
and response messages separately.
Figure 17.21 shows the query message sent by the resolver. The first 2 bytes
show the identifier (1333). It is used as a sequence number and relates a
response to a query. Because a resolver may even send many queries to the
same server, the identifier helps to sort responses that arrive out of order.
The next bytes contain the flags with the value of 0x0100 in hexadecimal.
In binary it is 0000000100000000, but it is more meaningful to divide it into
the fields as shown below:

QR OpCode AA TC RD RA Reserved rCode


0 0000 0 0 1 0 000 0000
82 TCP/IP Protocol Suite
Figure 17.21 Example 1: Query message

83 TCP/IP Protocol Suite


Example 1 (Continued)

The QR bit defines the message as a query. The OpCode is 0000, which
defines a standard query. The recursion desired (RD) bit is set. (Refer back
to Figure 17.16 for the flags field descriptions.) The message contains only
one question record. The domain name is 4chal4fhda3edu0. The next 2
bytes define the query type as an IP address; the last 2 bytes define the class
as the Internet.

Figure 17.22 shows the response of the server. The response is similar to the
query except that the flags are different and the number of answer records
is one. The flags value is 0x8180 in hexadecimal. In binary it is
1000000110000000, but again we divide it into fields as shown below:

QR OpCode AA TC RD RA Reserved rCode


1 0000 0 0 1 1 000 0000

84 TCP/IP Protocol Suite


Example 1 (Continued)

The QR bit defines the message as a response. The OpCode is 0000, which
defines a standard response. The recursion available (RA) and RD bits are
set. The message contains one question record and one answer record. The
question record is repeated from the query message. The answer record has
a value of 0xC00C (split in two lines), which points to the question record
instead of repeating the domain name. The next field defines the domain
type (address). The field after that defines the class (Internet). The field with
the value 12,000 is the TTL (12,000 s). The next field is the length of the
resource data, which is an IP address (153.18.8.105).

85 TCP/IP Protocol Suite


Figure 22 Example 1: Response message

86 TCP/IP Protocol Suite


Example 2

An FTP server has received a packet from an FTP client with


IP address 153.2.7.9. The FTP server wants to verify that the
FTP client is an authorized client. The FTP server can consult
a file containing the list of authorized clients. However, the file
consists only of domain names. The FTP server has only the IP
address of the requesting client, which was the source IP
address in the received IP datagram. The FTP server asks the
resolver (DNS client) to send an inverse query to a DNS server
to ask for the name of the FTP client. We discuss the query and
response messages separately.

87 TCP/IP Protocol Suite


Example 2 (Continued)

Figure 17.23 shows the query message sent from the resolver to the server.
The first 2 bytes show the identifier (0x1200). The flags value is 0x0900 in
hexadecimal. In binary it is 0000100100000000, and we divide it into fields
as shown below:

QR OpCode AA TC RD RA Reserved rCode


0 0001 0 0 1 0 000 0000

The OpCode is 0001, which defines an inverse query. The message contains
only one question record. The domain name is 19171231537in-addr4arpa.
The next 2 bytes define the query type as PTR, and the last 2 bytes define
the class as the Internet.

88 TCP/IP Protocol Suite


Figure 23 Example 2: Inverse query message

89 TCP/IP Protocol Suite


Example 2 (Continued)

Figure 17.24 shows the response. The flags value is 0x8D80 in


hexadecimal. In binary it is 1000110110000000, and we divide it into fields
as shown below:

QR OpCode AA TC RD RA Reserved rCode


1 0001 1 0 1 1 000 0000

90 TCP/IP Protocol Suite


Figure 24 Example 2: Inverse response message

91 TCP/IP Protocol Suite


Example 3

In UNIX and Windows, the nslookup utility can be used to


retrieve address/name mapping. The following shows how we
can retrieve an address when the domain name is given.

$ nslookup fhda.edu
Name: fhda.edu
Address: 153.18.8.1

The nslookup utility can also be used to retrieve the domain


name when the address is given as shown below:
$ nslookup 153.18.8.1
1.8.18.153.in-addr.arpa name = tiptoe.fhda.edu.

92 TCP/IP Protocol Suite


9 DDNS

The Dynamic Domain Name System (DDNS) updates the DNS master
file dynamically.

It handle this task by DHCP (Dynamic Host Configuration Protocol)

93 TCP/IP Protocol Suite


10 ENCAPSULATION

DNS uses UDP as the transport protocol when the size of the response
message is less than 512 bytes. If the size of the response message is
more than 512 bytes, a TCP connection is used.

In both the cases well-known port used by the server is port 53.

94 TCP/IP Protocol Suite


Note:

DNS can use the services of UDP or


TCP using the well-known port 53.

95 TCP/IP Protocol Suite


Electronic Mail:
SMTP,
Objectives
Upon completion you will be able to:

• Understand four configurations of email architecture


• Understand the functions and formats of a user agent

96
Introduction

 One of the most popular Internet service is electronic mail(email).

 At the beginning of the Internet era, the messages sent by


electronic mail were short & considered of text only;

 Today electronic mail is much more complex. It allows a message to


include text, audio & video.

 We first study the general architecture of an email


system including three main components: user
agent(UA), message transfer agent(MTA), & message
access agent(MAA).

97
1 ARCHITECTURE

First Scenario:
In the first scenario, the sender & the receiver of the email are users(or
application programs) on the same system; they are directly connected
to a shared system.

A administrator has created one mailbox for each user where the
received messages are stored.

When Alice needs to sends a message to Bob, he runs a user agent(UA)


program to prepare the message & store it in Bob’s mailbox.

Bob can retrieve & read the contents of his mailbox at his convenience
using a user agent.

98
Figure 1 First scenario

99
Note:

When the sender and the receiver of an


email are on the same system, we need only
two user agents.

100
Figure 2 Second Scenario
 In the second scenario, the sender & the receiver of the email are
users(or application program) on two different systems.

 Here we need user agents(UA) & message transfer agents (MTAs)


as shown below.

101
Cont..

 Alice needs to use user agent program to send her


message to the system at her own site.

 Bob also needs a user agent program to retrieve


messages stored in the mailbox of the system at his
site.

 Here two message transfer agents are needed; one


client & one server.

 The server needs to run all the time because it does not
know when a client will ask for connection.
102
Note:

When the sender and the receiver of an


email are on different systems, we need two
UAs and a pair of MTAs (client and server).

103
Third scenario
 In the third scenario, Alice is either connected to the system via a
point-to-point WAN- such as a dial-up modem, or a cable modem –
or he is connected to a LAN in an organization that uses one mail
server for handling emails;

 Alice still needs a user agent to prepare his message. He then needs
to send the message through the LAN or WAN.

 This can be done through a pair of message transfer agents(client &


server). Whenever Alice has a message to send, he calls the user
agent which, in turn, calls the MTA client.

 The MTA client establishes a connection with the MTA server on the
system, which is running all the time.

104
Figure 3 Third scenario

105
Note:

When the sender is connected to the mail


server via a LAN or a WAN, we need two
UAs and two pairs of MTAs (client and
server).

106
Fourth Scenario

 In the fourth & most common scenario, Bob is also


connected to his mail server by WAN or LAN.

 After the message has arrived at Bob’s mail server, Bob


needs to retrieve it. Here we need another set of client-
server agents, which we call message access
agents(MAAs).

 Bob uses an MAA client to retrieve his message. The


client sends a request to the MAA server, which is
running all the time, & requests the transfer of the
messages.
107
Figure 4 Fourth scenario

108
Fi Figure 5 Push vs. pull

Note that Bob needs another pair of client-server programs; message access
programs. This is because an MTA client-server program is push program; the
client pushes the message to the server. Bob needs a pull program. The client
needs to pull the message from the server .

109
Note:

When both sender and receiver are connected to


the mail server via a LAN or a WAN, we need two
UAs, two pairs of MTAs (client and server), and a
pair of MAAs (client and server). This is the most
common situation today .

110
Each 6-bit section is interpreted as one character according table 3

Table 3 Base64 encoding table


111
MESSAGE TRANSFER AGENT: SMTP

The actual mail transfer is done through message transfer


agents(MTAs).

To send mail, a system must have the client MTA, & to


receive mail , a system must have a server MTA.

The formal protocol that defines the MTA client & server in
the Internet is called Simple Mail Transfer Protocol (SMTP).

As we said before, two pairs of MTA client-server programs


are used in the most common situation.

TCP/IP Protocol Suite 112


Figure 13 SMTP range

SMTP is used two times, between the sender & sender’s mail server
& between the two mail servers.

SMTP simply defines how commands & responses must be sent back &
forth.

TCP/IP Protocol Suite 113


Figure 14 Commands and responses

SMTP uses commands & responses to transfer


messages between an MTA client & an MTA server.

TCP/IP Protocol Suite 114


Figure 15 Command format

Commands are sent from the client to the server. The


format of command is shown below.

It consist of a keyword followed by zero or more


arguments. SMTP defines 14 commands.

TCP/IP Protocol Suite 115


Table 4 Commands

These are mandatory; every


Implementation support these
commands
Terminate the message

Abort the current mail transaction


These are often used &
highly recommended
It requires an answer from recipient
Switch the positions of sender & recipient

These are seldom used.


Whether mail is deliver to
Recipients.

116
Responses: Responses are sent from the server to the client.

 A response is three-digit code that may be followed by additional


textual information.

 2yz(positive completion reply):- If first digit is 2, it means that


the requested command has been successfully completed & a new
command can be started.

 3yz(positive intermediate reply):- If the first digit is 3, it


means that the requested command has been accepted, but the
recipient needs some more information before completion can
occur.

TCP/IP Protocol Suite 117


Cont..

 4yz(transient negative completion reply):- if the first digit is


4, it means the requested command has been rejected, but error
condition is temporary. The command can be sent again.

 5yz(permanent negative completion reply):- if the first digit


is 5, it means the requested command has been rejected. The
command can’t be sent again.

TCP/IP Protocol Suite 118


Table 5 Responses

TCP/IP Protocol Suite 119


Table 5 Responses (Continued)

TCP/IP Protocol Suite 120


Mail Transfer Phases

There are three phases: connection establishment,


mail transfer, & connection termination.

McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000


Connection establishment

 After a client has made a TCP connection to the well-


known port 25, the SMTP server starts the connection
phase.

1. The server sends code 220 to tell client that it is ready


to receive mail. If server is not ready it sends code 421.

2. The client sends HELLO message to identify itself using


its domain name address.

3. The server responds with code 250 (request command


completed).
TCP/IP Protocol Suite 122
Figure 16 Connection establishment

TCP/IP Protocol Suite 123


Figure 17 Message transfer

124
Figure 18 Connection termination

After the message is transferred successfully, the client


terminates the connection. This phase involves two steps.

1. The client sends the QUIT command.

2. The server responds with code 221 or some appropriate code.

125
Example 1

Let us see how we can directly use SMTP to send an email and simulate the
commands and responses we described in this section. We use TELNET to
log into port 25 (the well-known port for SMTP). We then use the
commands directly to send an email. In this example,
[email protected] is sending an email to himself. The first few lines
show TELNET trying to connect to the adelphia mail server.

$ telnet mail.adelphia.net 25
Trying 68.168.78.100...
Connected to mail.adelphia.net (68.168.78.100).

After connection, we can type the SMTP commands and then receive the
responses as shown below. We have shown the commands in black and the
responses in color. Note that we have added for clarification some comment
lines, designated by the “=” sign. These lines are not part of the email
procedure.
126
Example 1 (Continued)

================== Connection Establishment ================


220 mta13.adelphia.net SMTP server ready Fri, 6 Aug 2004 . . .
HELO mail.adelphia.net
250 mta13.adelphia.net
===================== Envelope ===================
MAIL FROM: [email protected]
250 Sender <[email protected]> Ok
RCPT TO: [email protected]
250 Recipient <[email protected]> Ok
=================== Header and Body ==================
DATA
354 Ok Send data ending with <CRLF>.<CRLF>
From: Forouzan
TO: Forouzan

This is a test message


to show SMTP in action.
127
.
Example 1 (Continued)

============= Connection Termination===============


250 Message received: [email protected]
QUIT
221 mta13.adelphia.net SMTP server closing connection
Connection closed by foreign host.

128
4 MESSAGE ACCESS AGENT: POP AND IMAP

The first & second stages of mail delivery use SMTP.

However, SMTP is not involved in the third stage because


SMTP is a push protocol; it pushes the message from the
client to server.

The third stage needs a pull protocol; the client must pull
messages from server. The third stage uses a message access
agent.

Currently two message access protocols are available: Post


Office Protocol, version 3 (POP3) and Internet Mail Access
Protocol, version 4.

129
Figure 19 POP3 and IMAP4

TCP/IP Protocol Suite 130


POP 3 Post Office Protocol, version 3(POP3)

 The client POP3 software is installed on the recipient


computer; the server POP3 software is installed on the
mail server.

 Mail access starts with the client when user needs to


download its email from the mailbox on the mail server.

 The client opens the connection with the server on TCP


port 110.

 It then sends its username & password to access the


mailbox.
TCP/IP Protocol Suite 131
Figure 20 POP3

TCP/IP Protocol Suite 132


Internet Mail Access Protocol, version 4.

 IMAP is similar to POP3, but it has more features; IMAP


is more powerful & more complex than POP3.

1. A user can check the email header prior to downloading.


2. A user can search the contents of the email for a specific string of
characters prior to downloading.
3. A user can partially download email. This is especially useful if
bandwidth is limited & the email contains multimedia with high
bandwidth requirements.
4. A user can create, delete, or rename mailboxes on the mail server.
5. A user can create a hierarchy of mailboxes in a folder for email
storage.


TCP/IP Protocol Suite 133
File Transfer Protocol:
FTP
Objectives
Upon completion you will be able to:

• Understand the connections needed for FTP file transfer


• Be familiar with FTP commands and responses

TCP/IP Protocol Suite 134


1 FILE TRANSFER PROTOCOL (FTP)

Transferring files from one computer to another is one of


the most common tasks expected from networking or
internetworking environment.

File Transfer Protocol (FTP) is the standard mechanism


provided by TCP/IP for copying a file from one host to
another.

FTP differs from other client-server applications is that it


establishes two connections between the hosts. One is for
data transfer, the other for control information (commands
& response).
TCP/IP Protocol Suite 135
Note:

FTP uses the services of TCP. It needs two TCP


connections.
The well-known port 21 is used for the control
connection and the well-known port 20 for the
data connection.

TCP/IP Protocol Suite 136


Figure 1 FTP

The client has three components

The server has two components

TCP/IP Protocol Suite 137


Cont…

 The control connection is made between the control


processes. The data connection is made between the
data transfer processes.

 The control connection remains connected during the


entire interactive FTP session. The data connection is
opened & then closed for each file transferred.

TCP/IP Protocol Suite 138


Connections:-

 The two FTP connections, control & data, use different


strategies & different port numbers.

Control Connections:-

1. The server issues a passive open on well known port 21


& waits for a client.

2. The client uses an ephemeral port(42,000- 65,000) &


issues an active open.

TCP/IP Protocol Suite 139


Figure 2 Opening the control connection

TCP/IP Protocol Suite 140


Data Connections:-

 The data connection uses the well-known port 20 at the server


site. Following steps shows how FTP creates a data connection.

1. The client, not the server, issues a passive open using


an ephemeral port. (it is the client that issues the
commands for transferring files).

2. The client sends this port number to the server using


the PORT command.

3. The server receives the port number & issues an active


open using the well-known port 20 & the received
ephemeral port number.
TCP/IP Protocol Suite 141
Figure 3 Creating the data connection

TCP/IP Protocol Suite 142


Communication

 FTP has two different approaches, one for the control


connection & one for the data connection.

Communication over Control Connection:-

 FTP uses the same approach as TELNET or SMTP to


communicate across the control connection.

 It uses the NVT ASCII character set. Communication is


achieved through commands & response.

TCP/IP Protocol Suite 143


Figure 4 Using the control connection

TCP/IP Protocol Suite 144


Communication Over Data Connection

 We want to transfer files through the data connection.

 The client must define the type of file to be transferred,


the structure of the data & the transmission mode.

Figure 5 Using the data connection


TCP/IP Protocol Suite 145
FTP can Transfer one of the following file types across the data
connection.

 ASCII file:- This is the default format for transferring text


files(Each character is encoded using NVT ASCII).

 EBCDIC (Extended Binary Coded Decimal Interchange


Code) file:- If one or both ends of the connection use
EBCDIC encoding, the file can be transferred using
EBCDIC encoding.

 Image file:- The file is sent as continuous streams of bits


without any interpretation or encoding (used to transfer
binary files such as compiled programs).

TCP/IP Protocol Suite 146


Command Processing

 FTP uses control connection to establish a


communication between client control process & server
control process.

 During this communication, the commands are sent


from client to the server & the responses are sent from
the server to the client.

Figure 6 Command processing

Advanced TCP/ IP 147


Commands:-

 Which are sent from FTP client control process, in the


form of ASCII uppercase (there are six types of commands).
1. Access Commands:- These commands let the user
access the remote system.

TCP/IP Protocol Suite 148


Table 2 File management commands:- Let the user access the file system
on the remote host.

TCP/IP Protocol Suite 149


Table 3 Data formatting commands:- These commands let the user
Define the data structure , file type & transmission mode.

TCP/IP Protocol Suite 150


Table 4 Port defining commands:- These commands define the port
number for the data connection on client side.

TCP/IP Protocol Suite 151


Table 5 File transfer commands:- These commands actually let the user
Transfer files.

TCP/IP Protocol Suite 152


Table 5 File transfer commands (continued)

TCP/IP Protocol Suite 153


Table 7 Responses:- Every FTP command generate at least
one response.

First Digit:- The first digit defines the status of the command(1-5).

Second Digit:- The second digit also defines the status of the command(0-5).

Third Digit:- The third digit provides additional information.

TCP/IP Protocol Suite 154


Table 7 Responses (continued)

TCP/IP Protocol Suite 155


File Transfer:- File transfer in FTP means one of the three things

1. A file is to be copied from the server to the client. This called


retrieving a file. RETR command is used for this purpose.

2. A file is to be copied from the client to the server. This is called


storing a file. STOR command is used.

3. A list of directory or file names is to be sent from the server to the


client. This is done under supervision of the LIST command.

Figure 7 File transfer


TCP/IP Protocol Suite 156
Example 1

Figure 1 shows an example of using FTP for retrieving a list of


items in a directory.
1. After the control connection to port 21 is created, the FTP
server sends the 220 (service ready) response on the control
connection.
2. The client sends the USER command.
3. The server responds with 331 (user name is OK, password is
required).
4. The client sends the PASS command.
5. The server responds with 230 (user login is OK)

See Next Slide


TCP/IP Protocol Suite 157
Example 1 (cONTINUED)

6. The client issues a passive open on an ephemeral port for the


data connection and sends the PORT command (over the
control connection) to give this port number to the server.
7. The server does not open the connection at this time, but it
prepares itself for issuing an active open on the data
connection between port 20 (server side) and the ephemeral
port received from the client. It sends response 150 (data
connection will open shortly).
8. The client sends the LIST message.
9. Now the server responds with 125 and opens the data
connection.

See Next Slide


TCP/IP Protocol Suite 158
Example 1 (cONTINUED)

10. The server then sends the list of the files or directories (as a
file) on the data connection. When the whole list (file) is
sent, the server responds with 226 (closing data connection)
over the control connection.
11. The client now has two choices. It can use the QUIT
command to request the closing of the
control connection or it can send another command to
start another activity (and eventually open another data
connection). In our example, the client sends a QUIT
command.
12. After receiving the QUIT command, the server responds
with 221 (service closing) and then closes the control
connection.
See Next Slide
TCP/IP Protocol Suite 159
Figure 8 Example 1

TCP/IP Protocol Suite 160


Trivial File Transfer Protocol (TFTP)

 There are occasions when we need to simply copy a file


without the need for all the features of the FTP protocol.

 For Example:- When a diskless workstation or a router is


booted, we need to download the bootstrap &
configuration files.

 Here we do not need all of the sophistication provided in


FTP. We just need a protocol that quickly copies the
files. TFTP is designed for these types of file transfer.

TCP/IP Protocol Suite 161


Cont..
 TFTP can read or write a file for the client. Reading
means copying a file from the server site to the client.

 Writing means copying a file from the client site to the


server.

Note:

TFTP uses the services of UDP on the well-known


port 69.
TCP/IP Protocol Suite 162
2 TRIVIAL FILE TRANSFER PROTOCOL (TFTP)

Trivial File Transfer Protocol (TFTP) is a simple file transfer protocol


without the sophisticated features of FTP.

The topics discussed in this section include:


Messages
Connection
Data Transfer
UDP Ports
TFTP Example
TFTP Options
Security
Applications

TCP/IP Protocol Suite 163


Note:

TFTP uses the services of UDP on the well-known


port 69.

TCP/IP Protocol Suite 164


Figure 10 Message categories

TCP/IP Protocol Suite 165


Figure 11 RRQ format

TCP/IP Protocol Suite 166


Figure 12 WRQ format

TCP/IP Protocol Suite 167


Figure 13 DATA format

TCP/IP Protocol Suite 168


Figure 14 ACK format

TCP/IP Protocol Suite 169


Figure 15 ERROR format

TCP/IP Protocol Suite 170


Table 8 Error numbers and their meanings

TCP/IP Protocol Suite 171


Figure 16 Connection establishment

TCP/IP Protocol Suite 172


Figure 17 Sorcerer’s apprentice bug

TCP/IP Protocol Suite 173


Figure 18 UDP port numbers used by TFTP

TCP/IP Protocol Suite 174


Figure 19 TFTP example

TCP/IP Protocol Suite 175


Figure 20 Use of TFTP with BOOTP

TCP/IP Protocol Suite 176


TELNET

Objectives
Upon completion you will be able to:

• Understand how TELNET works


• Understand the role of NVT in a TELNET communication
• Understand TELNET option and sub-option negotiation
• Know how control characters are used
• Know the TELNET modes of operation

TCP/IP Protocol Suite 177


Introduction

 We will discuss cline-server program: TELNET. TELNET is


an abbreviation for TErminal NETwork.

 It is standard TCP/IP protocol for virtual terminal service


proposed by ISO.

TELNET enables the establishment of a connection


to a remote system in such a way that the local
terminal appears to be a terminal at the remote
system.

TCP/IP Protocol Suite 178


Note:

TELNET is a general-purpose
client-server application program.

TCP/IP Protocol Suite 179


1 CONCEPT

Time-Sharing Environment :- TELNET was designed at a


time when most operating systems, such as UNIX, were operating in
a time-sharing environment.

• In a time sharing environment, all of the processing must be done by


the central computer.

• The user can run a program, access the system resources, switch
from one program to another & so on.

Login:- To access the system, the user logs into the system with
user id or login name. The system also includes password checking to
prevent an unauthorized user from accessing the resources.

TCP/IP Protocol Suite 180


Local Login

 When a user logs into a local time-sharing system, it is called


local login.

 As a user types at a terminal or at a workstation running a


terminal emulator, the keystrokes are accepted by the terminal
driver.

 The terminal driver passes the characters to the O.S. The O.S.,
in turn, interprets the combination of characters & invokes the
desired application program or utility.

TCP/IP Protocol Suite 181


Figure 1 Local login

TCP/IP Protocol Suite 182


Remote Login

 When a user wants to access an application program or utility


located on a remote machine, he performs remote login. (Here
the TELNET client & server programs come into use.)

 The user sends the keystrokes to the terminal driver where the
local operating system accepts the characters but does not
interpret them.

 The characters are sent to the TELNET client, which


transforms the characters to a universal character set called
Network Virtual Terminal characters & delivers them to the
local TCP/ IP stack as shown.

TCP/IP Protocol Suite 183


Figure 2 Remote login

NVT

TCP/IP Protocol Suite 184


Cont..
 The commands or text, in NVT form, travel through the
Internet & arrive at the TCP/IP stack at the remote machine.

 Here the characters are delivered to the operating system &


passed to the TELNET server, which changes the characters to
the corresponding characters understandable by the remote
computer.

 However, remote operating system is not designed to receive


characters from a TELNET server: It is designed to receive
characters from a terminal driver.

 The solution is to add a piece of software called


pseudoterminal driver which pretends that the characters are
TCP/IP Protocol Suite 185
coming from a terminal.
2 NETWORK VIRTUAL TERMINAL (NVT)

Via a universal interface called the Network Virtual Terminal (NVT)


character set, the TELNET client translates characters (data or
commands) that come from the local terminal into NVT form and
delivers them to the network. The TELNET server translates data and
commands from NVT form into the form acceptable by the remote
computer.

TCP/IP Protocol Suite 186


Figure 3 Concept of NVT

TCP/IP Protocol Suite 187

You might also like