CN - Unit 5 Notes
CN - Unit 5 Notes
Mainly HTTP is used to access the data on the World Wide Web. HTTP
functions as a combination of FTP and SMTP.
HTTP is similar to SMTP because the data transferred between the client
and the server look like SMTP messages. Also, the format of the messages
is controlled by Multipurpose Internet Mail Extensions (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).SMTP messages are stored and forwarded, but HTTP
messages are delivered immediately.
HTTP Transaction
Figure 16.4shows the HTTP transaction between the client and
server. Though HTTP uses the services of TCP, HTTP itself is a stateless
protocol. The client initializes the transaction by sending a request
message to the server. The server replies by sending a response to the
client.
Messages: formats of the request and response messages are similar; both
are shown in Figure 16.5. A request message consists of a request line,a
header, and sometimes a body whereas a response message consists of a
status line, a header, and sometimes a body.
Fields of Request Line and Status Line: There is one common field in
both is HTTP version
Request type: used in request message and are categorized into
methods as shown in Table 16.1
URL: Uniform Resource Locator.
HTTP version: current version of HTTP is 1.1.
Status code: used in response message and consists of 3 digits –
codes in 100 range are informational, codes in 200 range indicate
successful request, codes in 300 range redirect the client to another
URL, codes in 400 range indicate an error at client and codes in
500 range indicate error at server site. Most common codes are
shown in Table 16.2.
Status phrase: used in the response message. It explains the status
code in text form. Table 16.2 also provides the status phrase for
each code.
Body: present in both request and response message and contains the
document to be send or received.
Example 16.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 16.7).
16.3 FTP
File Type: FTP can transfer one of the following types across the data
connection.
• ASCII FILE is a default format (7bit ASCII encoding)
• EBCDIC FILE is used by IBM (EBCDIC encoding)
• IMAGE FILE is the default format for transferring binary file, it is
sent as continuous streams of bits without any encoding.
Email Architecture
When both sender and receiver are connected to their mail servers
via a LAN or a WAN, we need two UAs and two pair of MTAs (client and
server), and pair of MAAs (client and server). This is the most common
email architecture used today. (See Figure 16.11)
Sending Mail: for sending mail, the user, through the UA, creates mail
that looks very similar to postal mail. It has an envelope (sender and
receiver address) and a message; where message contains header (defines
sender, receiver, and subject of the message) and body (actual information
to be read by recipient).
Receiving Mail: When a user receives mail, UA informs to the user with a
notice and if the user is ready to read the mail. A list is displayed in which
each line contains a summary of the information about a particular
message in the mailbox.
SMTP Commands: commands are sent from the client to the server.
SMTP defines 14 different commands. Out of these, first five are
mandatory; every implementation must support these five commands.
Next three are often used and highly recommended. Last six are seldom
used. (See Table 16.7)
Table 16.7: SMTP Commands
Responses: Responses are sent from the SMTP server to the SMTP client.
A response is a 3 digit code that may be followed by additional textual
information. Table 16.8 shows some of the response codes.
Mail Transfer: Transfer of a mail message occurs in three phases:
connection establishment, mail transfer, and connection termination.
POP3 has two modes: the delete mode and the keep mode. In the
delete mode, after each retrieval, the mail is deleted from the mailbox. In
the keep mode, the mail remains in the mailbox after retrieval. The delete
mode is normally used when the user is working at his permanent
computer and can save and organize the received mails after reading or
replying. The keep mode is normally used when the user accesses his mail
away from her primary computer. The mail is read but kept in the system
for later retrieval and organizing.
Figure 16.16: POP3 exchange of Commands and Responses
Name Space
Internet is divided into over 200 top level domains. Each
domain is divided into sub-domains, which are further partitioned. All
domains can be represented by a tree. The leaves of the tree represent
domains that have no sub-domains (but contain machines). A leaf domain
may contain a single host or represent a company and contain thousands of
hosts. Top level domains could be generic and country domains as shown
in the Figure 16.24.
Figure 16.24: Domain Name space
Resolver
A host that needs to map a name to an address or an address to a
name calls a DNS client called as resolver. The resolve accesses the
closest DNS server with a mapping request.
Recursive Resolution
The client (resolver) can ask for a recursive answer from a name
server. This means that the resolver expects the server to supply the final
answer. If the server is the authority for the domain name, it checks its
database and responds. If the server is not the authority, it sends the
request to another server (the parent usually) and waits for the response. If
the parent is the authority, it responds; otherwise, it sends the query to yet
another server. When the query is finally resolved, the response travels
back until it finally reaches the requesting client (see Figure 16.28).
Iterative Resolution
If the client does not ask for a recursive answer, the mapping can
be done iteratively. If the server is an authority for the name, it sends the
answer. If it is not, it returns (to the client) the IP address of the server that
it thinks can resolve the query. The client is responsible for repeating the
query to this second server. If the newly addressed server can resolve the
problem, it answers the query with the IP address; otherwise, it returns the
IP address of a new server to the client. Now the client must repeat the
query to the third server. This process is called iterative because the client
repeats the same query to multiple servers (see Figure 16.29).
Caching
Each time a server receives a query for a name that is not in its
domain, it needs to search its database for a server IP address. Reduction
of this search time would increase efficiency. DNS handles this with a
mechanism called caching. When a server asks for a mapping from
another server and receives the response, it stores this information in its
cache memory before sending it to the client. If the same or another client
asks for the same mapping, it can check its cache memory and resolve the
problem. However, to inform the client that the response is coming from
the cache memory and not from an authoritative source, the server marks
the response as unauthoritative.
DNS Messages
DNS has two types of messages: query and response. Both of them
have the same format. The query message consists of a header and
question records whereas the response message consists of a header,
question records, answer records, authoritative records, and additional
records (see Figure 16.30).
Header: Both query and response messages have the same header format
with some fields set to zero for the query messages. The header is 12 bytes
and its format is shown in Figure 16.31.
Resource Record
Each domain name is associated with a record called as resource record.
The DNS server database consists of resource records. Resource records
are also what is returned by the server to the client. Figure 16.32 shows the
format of are source record.
Resource Record types: there are eight types of DNS records as shown in
the Table 16.11.
• Start of Authority (SOA): SOA record provides the name of the
primary source of information about the name server’s zone, the e-
mail address of its administrator, a unique serial number and various
flags and timeouts.