0% found this document useful (0 votes)
23 views31 pages

CN-Module 5 Notes

Uploaded by

foranshika16
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views31 pages

CN-Module 5 Notes

Uploaded by

foranshika16
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 31

Computer Networks (BCS502)

MODULE 5
Course Notes
Syllabus:

Introduction to Application Layer: Introduction, Client-Server Programming, Standard Client


Server Protocols: World Wide Web and HTTP, FTP, Electronic Mail, Domain Name System
(DNS), TELNET, Secure Shell (SSH)

Textbook: Ch. 25.1-25.2, 26.1-26.6

Textbooks:

1. Behrouz A. Forouzan, Data Communications and Networking, 5th Edition, Tata


McGraw-Hill,2013.

Reference Books:

1. Larry L. Peterson and Bruce S. Davie: Computer Networks – A Systems Approach,


4th Edition, Elsevier, 2019.
2. Nader F. Mir: Computer and Communication Networks, 2nd Edition, Pearson
Education,
3. 2015.
4. William Stallings, Data and Computer Communication 10th Edition, Pearson
Education, Inc.,2014.
Computer Networks (BCS502) Module 4

CHAPTER 23: Application Layer


Application-Layer Paradigms
Traditional Paradigm: Client-Server
The service provider is an application program, called the server process; it runs
continuously, waiting for another application program, called the client process
to make a connection through the Internet and ask for service.
The server process must be running all the time; the client process is started when
the client needs to receive service.
A client is a running program that initializes the communication by sending a
request.
A server is another application program that waits for a request from a client. The
server handles the request received from a client, prepares a result, and sends the
result back to the client.
Several traditional services are still using this paradigm, including the World
Wide Web (WWW) and its vehicle HyperText Transfer Protocol (HTTP), file
transfer proto col (FTP), secure shell (SSH), e-mail, and so on.

Dept. of CSE, Vemana IT 1


Computer Networks (BCS502) Module 4

New Paradigm: Peer-to-Peer


In this paradigm, there is no need for a server process to be running all the time
and waiting for the client processes to connect.
The responsibility is shared between peers. A computer connected to the Internet
can provide service at one time and receive service at another time.
There are some new applications, such as BitTorrent, Skype, IPTV, and Internet
telephony, that use this paradigm.
Application Programming Interface
A set of instructions required for a process to communicate with another process
in terms of opening a connection, send and receive the data and close the
connection is referred to as an application programming interface (API).
An interface in programming is a set of instructions between two entities.
In this case, one of the entities is the process at the application layer and the other
is the operating system that encapsulates the first four layers of the TCP/IP
protocol suite.
The socket interface is a set of instructions that provide communication between
the application layer and the operating system. Socket interface, Transport Layer
Interface (TLI), and Stream are important API’s.

Position of the socket interface

Dept. of CSE, Vemana IT 2


Computer Networks (BCS502) Module 4

Sockets used the same way as other sources and sinks


Socket is not a physical entity, it is an abstraction. It is an object that is created
and used by the application program.
If we create two sockets, one at each end, and define the source and destination
addresses correctly, we can use the available instructions to send and receive data.
The rest is the responsibility of the operating system and the embedded TCP/IP
protocol.

Use of sockets in process-to-process communication


Socket Addresses
Since communication in the client-server paradigm is between two sockets, we
need a pair of socket addresses for communication: a local socket address and a
remote socket address.
A socket address should be a combination of an IP address and a port number.

Dept. of CSE, Vemana IT 3


Computer Networks (BCS502) Module 4

Finding Socket Addresses


Server Site
The server needs a local (server) and a remote (client) socket address for
communication.
Local Socket Address at server site
The local (server) socket address is provided by the operating system. The
operating system knows the IP address of the computer on which the server
process is running. The port number of a server process, however, needs to be
assigned.
Remote Socket Address at server site
The remote socket address for a server is the socket address of the client that
makes the connection. Since the server can serve many clients, it does not know
beforehand the remote socket address for communication.
The server can find this socket address when a client tries to connect to the server.
The client socket address, which is contained in the request packet sent to the
server, becomes the remote socket address that is used for responding to the
client.
Client site
Local Socket Address at client site
The local (client) socket address is provided by the operating system. The
operating system knows the IP address of the computer on which the client
process is running.
The port number, however, needs to be assigned from a set of integers defined by
the Internet authority and called the ephemeral (temporary) port numbers.

Dept. of CSE, Vemana IT 4


Computer Networks (BCS502) Module 4

Remote Socket Address at client site


When a client process starts, it should know the socket address of the server it
wants to connect to. Sometimes, the user who starts the client process knows
both the server port number and IP address of the computer on which the server
is running. This usually occurs in situations when we have written client and
server applications. If client does not know the Server IP address it uses another
client server application known as DNS (Domain Name Service) which takes
URL’s such as www.xyz.com or [email protected] to get the IP address of the
server. Port number will be known to client as it will be standard port numbers.

Using Services of the Transport Layer


Most standard applications have been designed to use the services of one of the
transport protocols like TCP, UDP, SCTP. When we write a new application, we
can decide which protocol we want to use.

Iterative Communication Using UDP


In UDP communication, the client and server use only one socket each. The
socket created at the server site lasts forever; the socket created at the client site
is closed (destroyed) when the client process terminates.

Dept. of CSE, Vemana IT 5


Computer Networks (BCS502) Module 4

Different clients use different sockets, but the server creates only one socket and
changes only the remote socket address each time a new client makes a
connection.

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 and the well-know port, in
which only part of the socket (the server socket address) is filled. The server then
issues a receive request command, which blocks until it receives a request from
a client.
The client process makes an active open. Creates a socket and sends the request.
The client then issues a receive command, which is blocked until a response
arrives from the server.

Dept. of CSE, Vemana IT 6


Computer Networks (BCS502) Module 4

Iterative Communication Using TCP

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

Dept. of CSE, Vemana IT 7


Computer Networks (BCS502) Module 4

World Wide Web


The WWW today is a distributed client-server service. Client using a browser can
access a service using a server. The service provided is distributed over many
locations called sites. Each site holds one or more web pages. Each web page,
however, can contain some links to other web pages in the same or other sites. A
simple web page has no links to other web pages; a composite web page has one
or more links to other web pages.

Dept. of CSE, Vemana IT 8


Computer Networks (BCS502) Module 4

Example to retrieve a document through WWW


Web Client (Browser)
Each browser usually consists of three parts: a controller, client protocols, and
interpreters.

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 later, such as HTTP or
FTP. The interpreter can be HTML, Java, or JavaScript, depending on the type of
document.
Web Server
The web page is stored at the server. Each time a request arrives, the
corresponding document is sent to the client. To improve efficiency, servers
normally store requested files in a cache in memory. A server can also become

Dept. of CSE, Vemana IT 9


Computer Networks (BCS502) Module 4

more efficient through multithreading or multiprocessing. Apache and Microsoft


Internet Information Server.
Uniform Resource Locator (URL)
We need four identifiers to define the web page.
Protocol : The first identifier is the abbreviation for the client-server program
that we need in order to access the web page. Ex: http , ftp etc.
Host : The host identifier can be the IP address of the server or the unique name
given to the server.
Port: The port, a 16-bit integer, is normally predefined for the client-server appli
cation. For example, if the HTTP protocol is used for accessing the web page, the
well-known port number is 80.
Path: The path identifies the location and the name of the file in the underlying
operating system.
Uniform Resource Locator (URL) is the combination of 4 identifiers
protocol://host:port/path

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 HyperText 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. Java Server Pages (JSP), Active Server Pages (ASP).
Active Documents

Dept. of CSE, Vemana IT 10


Computer Networks (BCS502) Module 4

For many applications, we need a program or a script to be run at the client site.
These are called active documents.
Javascript and Java applet

HyperText Transfer Protocol (HTTP)


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. HTTP uses the services of TCP, which, as discussed before, is
a connection-oriented and reliable protocol. This means that, before any
transaction between the client and the server can take place, a connection needs
to be established between them. After the transaction, the connection should be
terminated. The client and server, however, do not need to worry about errors in
messages exchanged or loss of any message, because the TCP is reliable and will
take care.
Nonpersistent versus Persistent Connections
The hypertext concept embedded in web page documents may require several
requests and responses. If the web pages, objects to be retrieved, are located on
different servers, we do not have any other choice than to create a new TCP
connection for retrieving each object.
However, if some of the objects are located on the same server, we have two
choices:
1. to retrieve each object using a new TCP connection
2. to make a TCP connection and retrieve them all.
The first method is referred to as a nonpersistent connection The second as a
persistent connection.
HTTP, prior to version 1.1, specified nonpersistent connections, while persistent
connections are the default in version 1.1, but it can be changed by the user.
Persistent Connections

Dept. of CSE, Vemana IT 11


Computer Networks (BCS502) Module 4

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.

Nonpersistent Connections
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.

Dept. of CSE, Vemana IT 12


Computer Networks (BCS502) Module 4

HTTP Message formats

Dept. of CSE, Vemana IT 13


Computer Networks (BCS502) Module 4

Request message
The first line in a request message is called a request line.
The method field defines the request types.
GET method is used to get a document from server, the body of the message is
empty. The data form values are passed as query parameters in the URL.
The HEAD method is used when the client needs only some information about
the web page from the server, such as the last time it was modified. The response
message in this case has only the header section; the body section is empty.
The PUT method allows the client to post a new web page on the server (if
permitted).
The POST method is used to send some information to the server to be added to
the web page or to modify the web page.
The TRACE method is used for debugging;
The DELETE method allows the client to delete a web page on the server if the
client has permission to do so.
The CONNECT method was originally made as a reserve method; it may be used
by proxy servers.
The OPTIONS method allows the client to ask about the prop
URL defines the address and name of the corresponding web page.
The third field, version, gives the version of the protocol; the most current version
of HTTP is 1.1.
After request line we can have zero or more request header lines.
Each header line sends additional information from the client to the server.
Each header line has a header name, a colon, a space, and a header value

Dept. of CSE, Vemana IT 14


Computer Networks (BCS502) Module 4

Response Message
The first line in a response message is called the status line.
The status code field defines the status of the request.

Status code Description

In the range of 100 Only informational.

In the 200 range Successful request.

In the 300 range Redirect the client to another URL,

In the 400 range Indicate an error at the client site.

In the 500 range Indicate an error at the server site.

The status phrase explains the status code in text form.


Cookies
Earlier websites was used for retrieving publicly available documents. A client
sends a request; a server responds.
But now Web has other functions that need to remember some information about
the clients; for storing information about clients Cookies are used.

Dept. of CSE, Vemana IT 15


Computer Networks (BCS502) Module 4

Cookies are small piece of information stored in browser


1. When a server receives a request from a client, it stores information about the
client in a file or a string. The information may include the domain name of the
client, the contents of the cookie (information the server has gathered about the
client such as name, registration number, and so on), a timestamp, and other
information depending on the implementation.
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.
Web caching and Proxy server

A proxy server is a computer that keeps copies of responses to


recent requests.
The HTTP client sends a request to the proxy server.
The proxy server checks its cache.
If the response is not stored in the cache, the proxy server sends the request to the
corresponding server.
Incoming responses are sent to the proxy server and stored for future requests
from other clients.
The proxy server reduces the load on the original server, decreases traffic, and
improves latency.

Dept. of CSE, Vemana IT 16


Computer Networks (BCS502) Module 4

However, to use the proxy server, the client must be configured to access the
proxy instead of the target server.
Proxy server acts as both server and client.
The proxy servers are normally located at the client site

File Transfer Protocol

File Transfer Protocol (FTP) is the standard protocol provided by TCP/IP for
copy ing a file from one host to another.
Two systems may use different file name conventions.
Two systems may have different ways to represent data.
Two systems may have different directory structures.
All of these problems have been solved by FTP
The control connection is made between the
control processes. The data connection is made between the data transfer
processes.
Separation of commands and data transfer makes FTP more efficient.
In control connection We need to transfer only a line of command or a line of
response at a time.

Dept. of CSE, Vemana IT 17


Computer Networks (BCS502) Module 4

The data connection, on the other hand, needs more complex rules due to the
variety of data types transferred
Port 21 is used for the control connection, and Port 20 is used for the data
connection.
Control Connection
Communication is achieved through commands and responses.

Data Connection
1. The client, not the server, issues a passive open using an ephemeral port. This
must be
done by the client because it is the client that issues the commands for
transferring files.
2. Using the PORT command the client sends this port number to the server.
3. The server receives the port number and issues an active open using the well
known port 20 and the received ephemeral port number.

Dept. of CSE, Vemana IT 18


Computer Networks (BCS502) Module 4

Communication over Data Connection


File Type
FTP can transfer one of the following file types across the data connection:
ASCII file, EBCDIC file, or image file.
Data Structure
FTP can transfer a file across the data connection using one of the following
interpretations of the structure of the data: file structure, record structure, or page
structure.
file structure - continuous stream of bytes
record structure, the file is divided into records.
page structure, the file is divided into pages.
Transmission Mode
stream mode, block mode, 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.
Each block is preceded by a 3-byte header. The first byte is called the block
descriptor; the next two bytes define the size of the block in bytes.
In Compressed code, data will be compressed.
File Transfer
File transfer occurs over the data connection under the control of the commands
sent over the control connection.
Electronic Mail
Electronic mail (or e-mail) allows users to exchange messages.
Architecture

Dept. of CSE, Vemana IT 19


Computer Networks (BCS502) Module 4

user agent (UA),


message transfer agent (MTA),
message access agent (MAA).
UA program prepares the message and send it to her mail server.
The mail server uses a queue (spool) to store messages
waiting to be sent.
Mail server has 2 agents client and server
The MTA client sends the message over the internet to Mail Server of the
recipient
MTA at receiver side receives mail. MAA pulls the message and sends it to
receiver.
User Agent
It provides service to the user to make the process of sending and receiving a
message easier.

Dept. of CSE, Vemana IT 20


Computer Networks (BCS502) Module 4

A user agent is a software package (program) that composes, reads, replies to,
and forwards messages.
It also handles local mailboxes on the user computers.
To send mail, the user, through the UA, creates mail that looks very similar to
postal mail. It has an envelope and a message.
The envelope usually contains the sender address, the receiver address, and other
information.
The message contains the header and the body.
The header of the message defines the sender, the receiver, the subject of the
message, and some other information. The body of the mes sage contains the
actual information to be read by the recipient.
Addresses

A mail handling system must use an addressing system with unique addresses.
The address consists of two parts: a local part and a domain name, separated by
an @ sign.

The local part defines the name of a special file, called the user mailbox, where
all the mail received for a user is stored for retrieval by the message access agent.
The second part of the address is the domain name.
Message Transfer Agent: SMTP
Simple Mail Transfer Protocol is an example for MTA. SMTP is a push protocol.

Dept. of CSE, Vemana IT 21


Computer Networks (BCS502) Module 4

Message Access Agent: POP and IMAP


POP and IMAP are pull protocol
POP3 (Post Office Protocol, version 3)
IMAP (Internet Mail Access Protocol)
Mail access starts with the client when the user needs to download its e-mail from
the mailbox on the mail server. The client opens a connection to the server on
TCP port 110. It then sends its user name and password to access the mailbox.
The user can then list and retrieve the mail messages, one by one. POP3 does not
allow the user to partially check the contents of the mail before downloading.
IMAP4 provides the following extra functions:
A user can check the e-mail header prior to downloading.
A user can search the contents of the e-mail for a specific string of characters
prior to downloading.
A user can partially download e-mail.
A user can create, delete, or rename mailboxes on the mail server.
A user can create a hierarchy of mailboxes in a folder for e-mail storage.
MIME
MIME transforms non-ASCII data at the sender site to NVT ASCII data and
delivers it to the client MTA to be sent through the Internet.

TELNET
TErminaL NETwork
TELNET allow a user on the client site to log into the computer at the server site
and use the services available there.

Dept. of CSE, Vemana IT 22


Computer Networks (BCS502) Module 4

We refer to these generic client/server pairs as remote logging applications.


TELNET requires a logging name and password, it is vulnerable to hacking
because it sends all data including the password in plaintext (not encrypted).
Local versus Remote Logging

When a user logs into a local system, it is called local logging.


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 operating system.
The operating system, in turn, interprets the combination of characters and
invokes the desired application program or utility.
In remote logging 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
into a universal character set called Network Virtual Terminal (NVT) characters
and delivers them to the local TCP/IP stack.

Dept. of CSE, Vemana IT 23


Computer Networks (BCS502) Module 4

The commands or text, in NVT form, travel through the Internet and arrive at the
TCP/IP stack at the remote machine.
Here the characters are delivered to the operating system and passed to the
TELNET server, which changes the characters to the corresponding characters
understandable by the remote computer.
the 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 a pseudoterminal driver, which
pretends that the characters are coming from a terminal.

Network Virtual Terminal (NVT)

If we want to access any remote computer in the world, we must first know what
type of computer we will be connected to.
TELNET solves this problem by defining a universal interface called the Network
Virtual Terminal (NVT) character set.
Via this interface, the client TELNET translates characters (data or commands)
that come from the local terminal into NVT form and delivers them to the
network.
The server TELNET, on the other hand, translates data and commands from NVT
form into the form acceptable by the remote computer.

Dept. of CSE, Vemana IT 24


Computer Networks (BCS502) Module 4

SECURE SHELL (SSH)


Secure Shell (SSH) is a secure application program that can be used today for
several purposes such as remote logging and file transfer.

SSH Transport-Layer Protocol (SSH-TRANS)


Since TCP is not a secured transport-layer protocol, SSH first uses a protocol that
creates a secured channel on top of the TCP.
This protocol provides Privacy or confidentiality of the message exchanged, Data
integrity, Server authentication, Compression of the messages.
SSH Authentication Protocol (SSH-AUTH)
After a secure channel is established between the client and the server and the
server is authenticated for the client SSH can call another procedure that can
authenticate the client for the server.
SSH Connection Protocol (SSH-CONN)
SSH-CONN takes the secure channel established by the two previous protocols
and lets the client create multiple logical channels over it.
Each channel can be used for a differ ent purpose, such as remote logging, file
transfer, and so on.
Applications of SSH

Dept. of CSE, Vemana IT 25


Computer Networks (BCS502) Module 4

• SSH for Remote Logging – PuTTy, Tectia are few examples for remote
logging
• SSH for File Transfer - Secure File Transfer Program (SFTP) is used for
file transfer.
Port Forwarding - The SSH port forwarding mechanism creates a tunnel through
which the messages belonging to other protocols (TELNET, SMTP) can travel.

Format of the SSH packet

DOMAIN NAME SYSTEM (DNS)

Dept. of CSE, Vemana IT 26


Computer Networks (BCS502) Module 4

TCP/IP protocols use the IP address, which uniquely identifies the connection of
a host to the Internet. People prefer to use names instead of numeric addresses.
Internet needs to have a directory system that can map a name to an address.
Name Space
A name space that maps each address to a unique name can be organized in two
ways: flat or hierarchical.
In a flat name space, a name is assigned to an address.
A name in this space is a sequence of characters without structure.
The main disadvantage of a flat name space is that it cannot be used in a large
system such as the Internet because it must be centrally controlled.
In a hierarchical name space, each name is made of several parts
One part defines the nature of the organization, the second part can define the
name of an organiza tion, the third part can define departments in the organization
etc. It can be decentralized.
Domain Name Space

Dept. of CSE, Vemana IT 27


Computer Networks (BCS502) Module 4

Root Server
A root server is a server whose zone consists of the whole tree.
A root server usually does not store any information about domains but delegates
its authority to other servers,
Primary and Secondary Servers
A primary server is a server that stores a file about the zone for which it is an
authority. It is responsible for creating, maintaining, and updating the zone file.
A secondary server is a server that transfers the complete information about a
zone from another server and stores the file on its local disk.
The sec ondary server neither creates nor updates the zone files. If updating is
required, it must be done by the primary server, which sends the updated version
to the secondary.
A primary server loads all information from the disk file;
The secondary server loads all information from the primary server.
Resolution
Mapping a name to an address is called name-address resolution.

Dept. of CSE, Vemana IT 28


Computer Networks (BCS502) Module 4

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 asks other servers to provide the information.
Recursive Resolution

Iterative Resolution

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.

DNS Messages

Dept. of CSE, Vemana IT 29


Computer Networks (BCS502) Module 4

Dept. of CSE, Vemana IT 30

You might also like