module-5-notes
module-5-notes
Flow Diagram
Figure 25.9 shows a simplified flow diagram for iterative
communication. There are multiple clients, but only one server.
Each client is served in each iteration of the loop in the server.
Note that there is no connection establishment or connection
termination. Each client sends a single datagram and receives a
single datagram. In other words, if a client wants to send two
datagrams, it is considered as two clients for the server. The
second datagram needs to wait for its turn.
Server Process
The server makes a passive open, in which it becomes ready for
the communication, but it waits until a client process makes the
connection. It creates an empty socket. It then binds the socket to
the server. The server then issues a receive request command,
which blocks until it receives a request from a client. After it
receives a request from client, server sends the response to
client. The server now starts another iteration waiting for another
request to arrive (an infinite loop).
Client Process
The client process makes an active open. In other words, it starts
a connection. It creates an empty socket and then issues the
send command. The client then issues a receive command,
which is blocked until a response arrives from the server. The
response is then handled and the socket is destroyed.
25.2.4 Iterative Communication Using TCP
TCP is a connection-oriented protocol. Before sending or
receiving data, a connection needs to be established between the
client and the server. After the connection is established, the two
parties can send and receive chunks of data as long as they have
data
Sockets Used in TCP
The TCP server uses two different sockets, one for connection
establishment and the other for data transfer. We call the first one
the listen socket and the second the socket. The reason for
having two types of sockets is to separate the connection phase
from the data exchange phase. A server uses a listen socket to
listen for a new client trying to establish connection. After the
connection is established, the server creates a socket to
exchange data with the client and finally to terminate the
connection. The client uses only one socket for both connection
establishment and data exchange
Flow Diagram
Figure 25.11 shows a simplified flow diagram for iterative
communication using TCP. There are multiple clients, but only
one server. Each client is served in each iteration of the loop.
Server Process
In Figure 25.11, the TCP server process, creates a listen socket
to be used only for the connection establishment phase. The
server process then calls the listen procedure, to allow the
operating system to start accepting the clients. The server
process now starts a loop and serves the clients one by one. In
each iteration, the server process issues the accept procedure
that removes one client from the waiting list of the connected
clients for serving.
Client Process
The client flow diagram is almost similar to the UDP version
except that the client data-transfer box needs to be defined for
each specific case.
25.2.5 Concurrent Communication
A concurrent server can process several client requests at the
same time.
Example:
The URL http://www.mhhe.com/compsci/forouzan/ defines the
web page. The string www.mhhe.com is the name of the
computer in the McGraw-Hill company. The path is
compsci/forouzan/.
Web Documents
The documents in the WWW can be grouped into three broad
categories: static, dynamic, and active.
Static Documents - Static documents are fixed-content
documents that are created and stored in a server. The client can
get a copy of the document only. Static documents are prepared
using one of several languages: Hyper Text Markup Language
(HTML), Extensible Markup Language (XML), Extensible Style
Language (XSL), and Extensible Hypertext Markup Language
(XHTML).
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 the dynamic document. The server returns the
result 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.
A very simple example of a dynamic document is the retrieval of
the time and date from a server.
Eg - scripting languages such as Java Server Pages (JSP) or
Active Server Pages (ASP)
Active Documents –
Some applications require a program or a script to be run at the
client site for interaction with the user. These are called active
documents. When a browser requests an active document, the
server sends a copy of the script. The document is then run at the
client (browser) site. Eg: Java applets and javascripts.
26.1.2 HyperText Transfer Protocol (HTTP)
The HyperText Transfer Protocol (HTTP) is used to define how
the client-server programs can be written to retrieve web pages
from the Web. An HTTP client sends a request; an HTTP server
returns a response. The server uses the port number 80; the
client uses a temporary port number. HTTP uses the services of
TCP.
Nonpersistent versus Persistent Connections
Generally, the hypertext concept require several requests and
responses.
In a nonpersistent connection, one TCP connection is made for
each request/response
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 and closes the connection.
Example 26.3: The client needs to access a file that contains one
link to an image. The text file and image are located on the same
server. Here we need two connections.
If the transaction involves retrieving 10 or 20 objects, the round
trip times spent for these handshakes add up to a big overhead.
Conditional Request
A client can add a condition in its request. In this case, the server
will send the requested web page if the condition is met or inform
the client otherwise. One of the most common conditions
imposed by the client is the time and date the web page is
modified. The client can send the header line If-Modified-Since
with the request to tell the server that it needs the page only if it is
modified after a certain point in time.
Cookies
The World Wide Web was originally designed as a stateless
entity. A client sends a request; a server responds. Their
relationship is over.
Today the Web has other functions that need to remember some
information about the clients; eg: Some websites need to allow
access to registered clients only.
For these purposes, the cookie mechanism was devised.
Creating and Storing Cookies
1. When a server receives a request from a client, it stores
information about the client in a file or a string.
2. The server includes the cookie in the response that it sends to
the client.
3. When the client receives the response, the browser stores the
cookie in the cookie directory.
When a client sends a request to a server, the browser looks in
the cookie directory to see if it can find a cookie sent by that
server. If found, the cookie is included in the request. When the
server receives the request, it knows that this is an old client, not
a new one.
Example 26.8
Assume a shopper wants to buy a toy from an electronic store
named BestToys. The shopper browser (client) sends a request
to the BestToys server. The server creates an empty shopping
cart (a list) for the client and assigns an ID to the cart (for
example, 12343). The server then sends a response message,
which contains the images of all toys available, with a link under
each toy. The client displays the images and stores the cookie
value in a file named BestToys. Now the shopper selects one of
the toys and clicks on it. The client sends a request, but includes
the ID 12343 in the Cookie header line. When the server receives
the request and checks the header, it finds the value 12343 as
the cookie. The server knows that the customer is not new; it
searches for a shopping cart with ID 12343. The shopping cart
(list) is opened and the selected toy is inserted in the list. The
server now sends another response to the shopper to tell her the
total price and ask her to provide payment. The shopper provides
information about her credit card and sends a new request with
the ID 12343 as the cookie value. When the request arrives at the
server, it again sees the ID 12343, and accepts the order and the
payment and sends a confirmation in a response.
Cache Update
HTTP does not provide security. HTTP over the Secure Socket
Layer referred to as HTTPS provides security.
26.2 FTP
File Transfer Protocol (FTP) is the standard protocol provided by
TCP/IP for copying a file from one host to another.
The client has three components: the user interface, the client
control process, and the client data transfer process. The server
has two components: the server control process and the server
data transfer process. The control connection is made between
the control processes. The data connection is made between the
data transfer processes.
File Type
FTP can transfer one of the following file types across the data
connection: ASCII file, EBCDIC file, or image file.
Data Structure
The following data structures are supported - file structure, record
structure, or page structure
[The file structure format (used by default) has no structure. It is a
continuous stream of bytes. In the record structure, the file is
divided into records. This can be used only with text files. In the
page structure, the file is divided into pages, with each page
having a page number and a page header]
Transmission Mode
Three transmission modes: stream mode, block mode, or
compressed mode.
The stream mode is the default mode; data are delivered from
FTP to TCP as a continuous stream of bytes. In the block mode,
data can be delivered from FTP to TCP in blocks.
The FTP protocol was designed when security was not a big
issue. To be secure, one can add a Secure Socket Layer
between the FTP application layer and the TCP layer. In this case
FTP is called SSL-FTP.
Alice and Bob use three different agents: a user agent (UA), a
message transfer agent (MTA), and a message access agent
(MAA). When Alice needs to send a message to Bob, she runs a
UA program to prepare the message and send it to her mail
server. The message, however, needs to be sent through the
Internet from Alice’s site to Bob’s site using an MTA. Bob later
uses an MAA client to retrieve the message from an MAA server
running on the second server
Mail format - The header of the message defines the sender, the
receiver, the subject of the message, and some other information.
The body of the message contains the actual information to be
read by the recipient.
2. Message Transfer
After connection has been established between the SMTP client
and server, a single message between a sender and one or more
recipients can be exchanged. This phase involves eight steps.
The client sends the MAIL FROM message to introduce the
sender of the message.
The server responds with code 250 (Request command
completed)
The client sends s the mail address of the recipient.
The server responds with code 250
The client sends the DATA message to initialize the message
transfer.
The server responds with code 354 (Start mail input)
The client sends the contents of the message in consecutive
lines.
The server responds with code 250 (OK) after receiving all the
lines and end of mail command
MIME
Electronic mail cannot be used for languages other than English
(such as French, German, Hebrew, Russian, Chinese, and
Japanese). Also, it cannot be used to send binary files or video or
audio data.
Multipurpose Internet Mail Extensions (MIME) is a supplementary
protocol that allows non-ASCII data to be sent through e-mail.
MIME as a set of software functions that transforms non-ASCII
data to ASCII data and vice versa, as shown in Figure 26.18.
26.4 TELNET
TELNET, which is an abbreviation for TErminaL NETwork, is one
of the remote logging protocols.
Because of the security issues, the use of TELNET has
diminished, and Secure Shell (SSH) is more commonly used.
Although TELNET is almost replaced by SSH, we briefly discuss
TELNET here for two reasons:
1. The simple plaintext architecture of TELNET allows us to
explain the issues and challenges related to the concept of
remote logging, which is also used in SSH.
2. Network administrators often use TELNET for diagnostic and
debugging purposes.
26.5.2 Applications
SSH for Remote Logging - Several free and commercial
applications use SSH for remote logging. Among them, we can
mention PuTTy, by Simon Tatham, which is a client SSH program
that can be used for remote logging.
Putty is used to connect to remote computers using protocols like
SSH, Telnet, and more.
SSH for File Transfer - One of the application programs that is
built on top of SSH for file transfer is the Secure File Transfer
Program (sftp). The sftp application program uses one of the
channels provided by the SSH to transfer files.
The length field defines the length of the packet. One to eight
bytes of padding is added to the packet to make the security
attack more difficult. The cyclic redundancy check (CRC) field is
used for error detection. The type field designates the type of the
packet used in different SSH protocols. The data field is the data
transferred by the packet in different protocols.
26.6.3 Resolution
Mapping a name to an address is called name-address
resolution.
A host that needs to map an address to a name or a name to an
address calls a DNS client called a resolver. The resolver
accesses the closest DNS server with a mapping request. If the
server has the information, it satisfies the resolver; otherwise, it
either refers the resolver to other servers or asks other servers to
provide the information. After the resolver receives the mapping,
delivers the result to the process that requested it. A resolution
can be either recursive or iterative.
Recursive Resolution
For example, assume some.anet.com needs to find the IP
address of another host named engineering.mcgraw-hill.com to
send a message to.
The application program on the source host calls the DNS
resolver (client) to find the IP address of the destination host. The
resolver, which does not know this address, sends the query to
the local DNS server running at the Anet ISP site (event 1).
It sends the query to a root DNS server (event 2). Root server will
send the query to the correct top-level-domain server, i.e., com
server (event 3). The query is forwarded to the local DNS server
in the McGraw-Hill company (for example, dns.mcgraw-hill.com)
(event 4). This knows the IP address. The IP address is now sent
back to the top-level DNS server (event 5), then back to the root
server (event 6), then back to the ISP DNS server, which may
cache it for the future queries (event 7), and finally back to the
source host (event 8).
Iterative Resolution
In iterative resolution, each server that does not know the
mapping sends the IP address of the next server back to the one
that requested it.
Explain each event.
26.6.4 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. Using cache memory
increases efficiency and reduces search time. Next, if the same
or another client asks for the same mapping, it can check its
cache memory and resolve the problem. However, it informs the
client that the response is coming from the cache memory and
not from an authoritative source, the server marks the response
as unauthoritative.
Caching speeds up resolution, but it can also be problematic. If a
server caches a mapping for a long time, the information may
become outdated. To counter this, the authoritative server always
adds information to the mapping called time to live (TTL). It
defines the time in seconds that the receiving server can cache
the information. After that time, the mapping is invalid and any
query must be sent again to the authoritative server. The cache
memory must be searched periodically and those mappings with
an expired TTL must be deleted.
26.6.5 Resource Records
A DNS server stores a database of resource records. A resource
record is a 5-tuple structure, as shown below:
(Domain Name, Type, Class, TTL, Value)
The domain name field is what identifies the resource record. The
value defines the information kept about the domain name. The
TTL defines the number of seconds for which the information is
valid. The class defines the type of network. class IN means
Internet.
Eg:
(from DNS Message — How to Read Query and Response
Message | by Carson | Medium)
Encapsulation
DNS can use either UDP or TCP.
DNS used port 53.
UDP is used 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.
26.6.7 Registrars
How are new domains added to DNS? This is done through a
registrar.
A registrar first verifies that the requested domain name is unique
and then enters it into the DNS database. A fee is charged.
For example, a new commercial organization needs to give the
following information to one of the registrars for registering its
domain:
26.6.8 DDNS
In DNS, when there is a change, such as adding a new host,
removing a host, or changing an IP address, the DNS master file
must be updated dynamically. The Dynamic Domain Name
System (DDNS) is used for this purpose.