Module5 CN MSSP Final
Module5 CN MSSP Final
COMPUTER NETWORKS[BCS502]
MODULE-5
Module-5
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
Department of Computer Science & Engineering
Contents
Introduction
Client-Server Programming
‣ FTP
‣ Electronic Mail
‣ TELNET
INTRODUCTION
The application layer provides services to the user.
Communication is provided using a logical connection, which means that the
two application layers assume that there is an imaginary direct connection
through which they can send and receive messages.
Providing Services
The application layer, however, is different from other layers in that it is the
highest layer in the suite.
The protocols in this layer do not provide services to any other protocol in the suite;
they only receive services from the protocols in the transport layer.
This means that protocols can be removed from this layer easily. New protocols can
be also added to this layer as long as the new protocols can use the services
provided by one of the transport-layer protocols.
Standard and Nonstandard Protocols
To provide smooth operation of the Internet, the protocols used in the first four
layers of the TCP/IP suite need to be standardized and documented. To be flexible,
the application-layer protocols can be both standard and nonstandard.
Department of Computer Science & Engineering
Application-Layer Paradigms
1. client-server paradigm
2. peer-to-peer paradigm
client-server paradigm
most popular paradigm
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.
some server processes that can provide a specific type of service, but there are many
clients that request service from any of these server processes.
The server process must be running all the time; the client process is started when the
client needs to receive service
For example, a telephone directory center in any area can be thought of as a server; a
subscriber that calls and asks for a specific telephone number can be thought of as a
client. The directory center must be ready and available all the time; the subscriber
can call the center for a short period when the service is needed.
Department of Computer Science & Engineering
Another problem is that there should be a service provider willing to accept the cost
and create a powerful server for a specific service.
Several traditional services are still using this paradigm, including the World Wide Web
(WWW) and its vehicle HyperText Transfer Protocol (HTTP), file transfer protocol
(FTP), secure shell (SSH), e-mail, and so on.
Department of Computer Science & Engineering
Peer-to-Peer
often abbreviated P2P paradigm
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. A computer can even provide and receive services at the
same time
One of the areas that really fits in this paradigm is the Internet telephony.
Communication by phone is indeed a peer-to-peer activity; no party needs to be running
forever waiting for the other party to call.
Another area in which the peer-to-peer paradigm can be used is when some computers
connected to the Internet have something to share with each other.
For example, if an Internet user has a file available to share with other Internet users,
there is no need for the file holder to become a server and run a server process all the
time waiting for other users to connect and retrieve the file.
peer-to-peer paradigm has been proved to be easily scalable and cost-effective in
eliminating the need for expensive servers to be running and maintained all the time
The main challenge has been security; it is more difficult to create secure
communication between distributed services than between those controlled by some
dedicated servers.
There are some new applications, such as BitTorrent, Skype, IPTV, and Internet
telephony, that use this paradigm
Department of Computer Science & Engineering
Mixed Paradigm
An application may choose to use a mixture of the two paradigms by combining
the advantages of both.
For example, a light-load client-server communication can be used to find the
address of the peer that can offer a service.
When the address of the peer is found, the actual service can be received from the
peer by using the peer-to peer paradigm
Department of Computer Science & Engineering
Client-server Programming
Application Programming Interface
If we need a process to be able to communicate with another process, we need a
new set of instructions to tell the lowest four layers of the TCP/IP suite to open the
connection, send and receive data from the other end, and close the connection.
A set of instructions of this kind is normally referred to as an application
programming interface (API).
• A computer manufacturer needs to build the first four layers of the suite in the
operating system and include an API.
• In this way, the processes running at the application layer are able to communicate
with the operating system when sending and receiving messages through the
Internet.
• Several APIs have been designed for communication. Three among them are
common: socket interface, Transport Layer Interface (TLI), and STREAM.
Department of Computer Science & Engineering
Sockets
It is an object that is created and used by the application program
Communication between a client process and a server process is communication between
two sockets, created at two ends
The client thinks that the socket is the entity that receives the request and gives the
response; the server thinks that the socket is the one that has a request and needs the
response.
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.
Department of Computer Science & Engineering
Socket Addresses
We need a pair of socket addresses for communication: a local socket address
and a remote socket address
A socket address should first define the computer on which a client or a server is
Running
Client Site
The client also needs a local (client) and a remote (server) socket address for
communication.
The local (client) socket address is also provided by the operating system. The
operating system knows the IP address of the computer on which the client is
running.
The port number is a 16-bit temporary integer that is assigned to a client process
each time the process needs to start the communication.
The port number needs to be assigned from a set of integers defined by the
Internet authority and called the ephemeral (temporary) port numbers
The operating system needs to guarantee that the new port number is not used by
any other running client process.
Department of Computer Science & Engineering
Finding the remote (server) socket address for a client needs more work. When a
client process starts, it should know the socket address of the server it wants to
connect to. We will have two situations in this case.
1. 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
and we want to test them. The programmer can provide these two pieces of
information when he runs the client program.
2. Although each standard application has a well-known port number, most of the
time, we do not know the IP address. This happens in situations such as when we
need to contact a web page, send an e-mail to a friend, copy a file from a remote
site, and so on. In these situations, the server has a name, an identifier that
uniquely defines the server process. The client process normally knows the port
number because it should be a well-known port number, but the IP address can be
obtained using another client-server application called the Domain Name System
(DNS).
Department of Computer Science & Engineering
TCP Protocol
TCP provides connection-oriented, reliable, byte-stream service. TCP requires that
two ends first create a logical connection between themselves by exchanging some
connection-establishment packets.
By numbering the bytes exchanged, the continuity of the bytes can be checked.
For example, if some bytes are lost or corrupted, the receiver can request the
resending of those bytes, which makes TCP a reliable protocol.
TCP also can provide flow control and congestion control.
One problem with the TCP protocol is that it is not message-oriented; it does not
put boundaries on the messages exchanged.
Most of the standard applications that need to send long messages and require
reliability may benefit from the service of the TCP.
Department of Computer Science & Engineering
SCTP Protocol
SCTP is normally suitable for any application that needs reliability and at the
same time needs to remain connected, even if a failure occurs in one network-
layer connection.
Department of Computer Science & Engineering
Figure shows the lifetime of the sockets in the server and client processes.
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
Department of Computer Science & Engineering
Flow Diagram
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 and the well-know port
The server then issues a receive request
command, which blocks until it receives a
request from a client.
The request is the process and the response
is sent back to the client.
The server now starts another iteration
Figure : Flow diagram for iterative UDP waiting for another request to arrive
communication
Department of Computer Science & Engineering
Client Process
The client process makes an active
open.
It creates an empty socket and then
issues the send command, which fully
fills the socket, and sends the request.
The client then issues a receive
command, which is blocked until a
response arrives from the server.
The response is then handled and the
Figure : Flow diagram for iterative UDP socket is destroyed.
communication
Department of Computer Science & Engineering
The TCP server uses two different sockets, one for connection
establishment(listen socket) and the other for data transfer(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
Department of Computer Science & Engineering
Flow Diagram
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
Concurrent Communication
A concurrent server can process several client requests at the same time. This can
be done using the available provisions in the underlying programming language.
In C, a server can create several child processes, in which a child can handle a
client.
In Java, threading allows several clients to be handled by each thread
Department of Computer Science & Engineering