0% found this document useful (0 votes)
27 views32 pages

Module5 CN MSSP Final

Computer Networks 5th sem CSE

Uploaded by

sushan1624
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)
27 views32 pages

Module5 CN MSSP Final

Computer Networks 5th sem CSE

Uploaded by

sushan1624
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/ 32

Department of Computer Science & Engineering

COMPUTER NETWORKS[BCS502]

Dr. M S Sunitha Patel


Associate Professor
Dept. of Computer Science & Engineering
ATMECE, Mysuru
Department of Computer Science & Engineering

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

 Standard Client-Server Protocols:

‣ World Wide Web and HTTP

‣ FTP

‣ Electronic Mail

‣ Domain Name System (DNS)

‣ TELNET

‣ Secure Shell (SSH)


Department of Computer Science & Engineering

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.

 Logical connection takes place between the


application layer of a computer at Sky
Research and the application layer of a
server at Scientific Books.
 The communication at the application layer
is logical, not physical.
 Alice and Bob assume that there is a two-
way logical channel between them through
which they can send and receive messages.
Department of Computer Science & Engineering

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

Standard Application-Layer Protocols


 Each standard protocol is a pair of computer programs that interact with the user and
the transport layer to provide a specific service to the user.
 The study of these protocols enables a network manager to easily solve the problems
that may occur when using these protocols.
 The deep understanding of how these protocols work will also give us some ideas
about how to create new nonstandard protocols.
Nonstandard Application-Layer Protocols
 A programmer can create a nonstandard application-layer program if she can write two
programs that provide service to the user by interacting with the transport layer.
 A private company can create a new customized application protocol to communicate
with all of its offices around the world using the services provided by the first four
layers of the TCP/IP protocol suite without using any of the standard application
programs.
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

 Figure shows an example of a


client-server communication in
which three clients communicate
with one server to receive the
services provided by this server.
 One problem with this paradigm
is that the concentration of the
communication load is on the
shoulder of the server, which
means the server should be a
Figure : Example of a client-server paradigm powerful computer.

 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

Figure :Example of a peer-to-peer paradigm


Department of Computer Science & Engineering

 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

Figure : Use of sockets in process-to-process communication

 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

Finding Socket Addresses


Server Site
 The server needs a local (server) and a remote (client) socket address for
communication.
 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.
Department of Computer Science & Engineering

 The port number of a server process needs to be assigned.


‣ If the server process is a standard one defined by the Internet authority, a port
number is already assigned to it.
‣ For example, the assigned port number for a Hypertext Transfer Protocol
(HTTP) is the integer 80, which cannot be used by any other process.
‣ If the server process is not standard, the designer of the server process can
choose a port number, in the range defined by the Internet authority, and assign
it to the process.
 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.
 The remote socket address is changed in each interaction with a different client.
Department of Computer Science & Engineering

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

Using Services of the Transport Layer


UDP Protocol
 UDP provides connectionless, unreliable, datagram service.
 UDP is not a reliable protocol. Although it may check that the data is not
corrupted during the transmission, it does not ask the sender to resend the
corrupted or lost datagram.
 For some applications, UDP has an advantage: it is message-oriented. It gives
boundaries to the messages exchanged.
 An application program may be designed to use UDP if it is sending small
messages and the simplicity and speed is more important for the application
than reliability.
 For example, some management and multimedia applications fit in this
category.
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 provides a service which is a combination of the two other protocols.

 Like TCP, SCTP provides a connection-oriented, reliable service, but it is not


bytestream oriented.

 It is a message-oriented protocol like UDP.

 In addition, SCTP can provide multi-stream service by providing multiple


network-layer connections.

 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

Iterative Communication Using UDP


 Communication between a client program and a server program can occur
iteratively or concurrently.
 Although several client programs can access the same server program at the same
time, the server program can be designed to respond iteratively or concurrently.
 An iterative server can process one client request at a time; it receives a request,
processes it, and sends the response to the requestor before handling another
request.
Sockets Used for 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
Department of Computer Science & Engineering

Figure : Sockets for UDP communication

 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

 There are multiple clients, but only one


server.
 Each client is served in each iteration of the
loop in the server.
 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.
 The diagram also shows the status of the
socket after each
Figure : Flow diagram for iterative UDP  action.
communication
Department of Computer Science & Engineering

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

Iterative Communication Using TCP


Sockets Used in TCP

 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

Figure : Sockets used in TCP communication


Department of Computer Science & Engineering

Flow Diagram

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

Figure : Flow diagram for iterative TCP


communication
Department of Computer Science & Engineering

 The TCP server process creates a


socket and binds it, but these two
commands create the 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, completing the
connection phase, and putting them
in the waiting list to be served.
 The server process now starts a loop
and serves the clients one by one.

Figure : Flow diagram for iterative TCP


communication
Department of Computer Science & Engineering

 In each iteration, the server process


issues the accept procedure that
removes one client from the waiting
list of the connected clients for
serving.
 If the list is empty, the accept
procedure blocks until there is a
client to be served.
 When the accept procedure returns,
it creates a new socket for data
transfer. The server process now
uses the client socket address
obtained during the connection
establishment to fill the remote
socket address field in the newly
created socket. At this time the
Figure : Flow diagram for iterative TCP client and server can exchange data.
communication
Department of Computer Science & Engineering

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

You might also like