Module 5 First Half
Module 5 First Half
Providing Services
● The Internet was originally designed for the purpose: to provide service to users around the
world. The layered architecture of the TCP/IP protocol suite, however, makes the Internet more
flexible than other communication networks such as postal or telephone networks.
● Each layer in the suite was originally made up of one or more protocols, but new protocols can be
added or some protocols can be removed or replaced by the Internet authorities. However, if a
protocol is added to each layer, it should be designed in such a way that it uses the services
provided by one of the protocols at the lower layer. If a protocol is removed from a layer, care
should be taken to change the protocol at the next higher layer that supposedly uses the services of
the removed protocol.
● The application layer 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.
● Since the application layer is the only layer that provides services to the Internet user, the flexibility
of the application layer allows new application protocols to be easily added to the Internet, which
has been occurring during the lifetime of the Internet. When the Internet was created, only a few
application protocols were available to the users; today we cannot give a number for these
protocols because new ones are being added constantly.
Standard Application-Layer Protocols
● There are several application-layer protocols that have been standardized and documented by the
Internet authority, and we are using them in our daily interaction with the Internet. 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.
● In the case of these application protocols, we should know what types of services they provide, how
they work, and the options that we can use with these applications, and so on.
● 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 you can write two programs
that provide service to the user by interacting with the transport layer.
● It is the creation of a nonstandard (proprietary) protocol, which does not even need the approval of
the Internet authorities if privately used, that has made the Internet so popular worldwide.
● 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.
● What is needed is to write programs, in one of the computer languages that use the available
services provided by the transport-layer protocols.
Application-Layer Paradigms
● To use the Internet we need two application programs to interact with each other
o one running on a computer somewhere in the world
o the other running on another computer somewhere else in the world.
● The two programs need to send messages to each other through the Internet infrastructure.
● Two paradigms have been developed during the lifetime of the Internet:
o the client-server paradigm
o the peer-to-peer paradigm.
Traditional Paradigm: Client-Server
● The traditional paradigm is called the client-server paradigm. In this 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.
● There are normally 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.
● Although the
communication in the
client-server paradigm is
between two application
programs, the role of each
program is totally different.
In other words, we cannot
run a client program as a
server program or vice
versa.
● Figure shows an example of
a client-server
communication in which three clients to receive the services
communicate with one server provided by this
server.
● One problem with this paradigm is that the concentration of the communication load is on the
server, which means the server should be a powerful computer. Even a powerful computer may
become overwhelmed if a large number of clients try to connect to the server at the same time.
● Another problem is that there should be a service provider willing to accept the cost and create a
powerful server for a specific service, which means the service must always return some type of
income for the server in order to encourage such an arrangement. 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.
New Paradigm: Peer-to-Peer
● A new paradigm, called the peer-to-peer paradigm (P2P paradigm) has emerged to respond to the
needs of some new
applications. 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 shows an example
of communication in this paradigm.
● 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 be used is when some
paradigm can
computers connected to the Internet have something to share with each other
● Although the 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, there are
also some challenges.
● 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.
● The other challenge is applicability; it appears that not all applications can use this new paradigm.
For example, not many Internet users are ready to become involved, if one day the Web can be
implemented as a peer-to-peer service. There are some new applications, such as BitTorrent,
Skype, IPTV, and Internet telephony that use this paradigm.
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-topeer paradigm.
-----------------------------------------------------------------------------------------------------------------------------------------------------
CLIENT-SERVER PROGRAMMING
Topics covered
● Application Programming Interface
● Using Services of the Transport Layer
● Iterative Communication Using UDP
● Iterative Communication Using TCP
● Concurrent Communication
-----------------------------------------------------------------------------------------------------------------------------
● In a client-server paradigm, communication at the application layer is between two running
application programs called processes: a client and a server.
● 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. This definition of a server implies that a server must be running when a request from a
client arrives, but the client needs to be run only when it is needed.
● We need to be careful that the server program is started before we start running the client
program. The lifetime of a server is infinite: it should be started and run forever, waiting for the
clients.
● The lifetime of a client is finite: it normally sends a finite number of requests to the corresponding
server, receives the responses, and stops.
Application Programming Interface
(Sockets - Socket Addresses - Finding Socket Addresses - Server Site - Client Site)
How can a client process communicate with a server process?
● 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).
● 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.
● 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 messages through the
sending and receiving Internet.
● Several APIs
have been
designed for
communicatio
n. Three
among them
are common:
socket
interface,
Transport
Layer Interface
(TLI), and
STREAM.
computer in the Internet is Internet version. uniquely defined by its IP address, a 32-bit integer
in the current
● Several client or server processes may be running at
the same time on a computer, which means that we
need another identifier to define the specific client or
server involved in the communication. An application
program can be defined by a port number, a 16-bit integer. This means that a socket address
should be a combination of an IP address and a port number as shown in Figure.
● Since a socket defines the end-point of the communication, we can say that a socket is identified by
a pair of socket addresses, a local and a remote.
Finding Socket Addresses - Server Site
● How can a client or a server find a pair of socket addresses for communication? The situation is
different for each site.
● The server needs a local (server) and a remote (client) socket address for communication.
● Local Socket Address: 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. 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. When a server starts running, it knows the local socket address.
● Remote Socket Address: 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. In
other words, although the local socket address for a server is fixed and used during its lifetime, the
remote socket address is changed in each interaction with a different client.
Finding Socket Addresses - Client Site
● The client also needs a local (client) and a remote (server) socket address for communication.
● Local Socket Address: 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, however, 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, however, needs to be assigned from a
set of integers defined by the Internet authority and called the ephemeral (temporary) port
numbers. The operating system, however, needs to guarantee that the new port number is not
used by any other running client process. The operating system needs to remember the port
number to be able to redirect the response received from the server process to the client process
that sent the request.
● Remote Socket Address: Finding the remote (server) socket address for a client, however, 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. For example, write
some simple client and server programs and we test them using this approach. In this
BCS502 COMPUTER NETWORKS III Year – V Sem (2024-25 ODD)
situation, 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. Examples of
these identifiers are URLs, such as www.xxx.yyy, or e-mail addresses, such as [email protected].
The client process should now change this identifier (name) to the corresponding server socket
address. 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).
-----------------------------------------------------------------------------------------------------------------------------
Using Services of the Transport Layer
● A pair of processes provide services to the users of the Internet, human or programs.
● A pair of processes need to use the services provided by the transport layer for communication
because there is no physical communication at the application layer.
● There are three common transport-layer protocols in the TCP/IP suite: UDP, TCP, and SCTP. Most
standard applications have been designed to use the services of one of these protocols.
● When we write a new application, we can decide which protocol we want to use. The choice of the
transport layer protocol seriously affects the capability of the application processes.
UDP Protocol
● UDP provides connectionless, unreliable, datagram service. Connectionless service means that
there is no logical connection between the two ends exchanging messages. Each message is an
independent entity encapsulated in a datagram. UDP does not see any relation (connection)
between consequent datagrams coming from the same source and going to the same destination.
● 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.
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. This phase, which is sometimes called handshaking, establishes some parameters between
the two ends, including the size of the data packets to be exchanged, the size of buffers to be used
for holding the chunks of data until the whole message arrives, and so on.
● After the handshaking process, the two ends can send chunks of data in segments in each direction.
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.
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 byte-stream 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.
-----------------------------------------------------------------------------------------------------------------------------
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. When the server is handling
the request from a client, the requests from other clients, and even other requests from the same
client, need to be queued at the server site and wait for the server to be freed.
● The received and queued requests are handled in the first-in, first-out fashion. In this section, we
discuss iterative communication using UDP.
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. 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. This is logical, because the
server does know its own socket address, but does not know the socket addresses of the clients
who need its services; it needs to wait for
the client to connect before part of the socket filling this
address.
Flow Diagram