Download as pdf or txt
Download as pdf or txt
You are on page 1of 16

MULTI-THREADED CLIENT SERVER

FINAL PROJECT

PROJECT REPORT
OPERATING SYSTEM (CSE2005)

Submitted by:
SAI PRATHAP REDDY 18BCE0111
C.GOWTHAM 18BCE0099
T. ADITHYA REDDY 18BCE0045
E.PHANEENDRA KUMAR REDDY 18BEC0061

SLOT – F1
FACULTY: PROF. NAGARAJA RAO.A
Abstract:

This project is based on the concept of Distributed File-sharing Systems. A server has
specifically been designed to be the file store for a number of clients attached to a local
area network. In particular, these personal machines (clients) have a very limited
amount of memory with which to interface to the file server. The filing system supports
a hierarchical directory structure. Both the operations and communication protocol
supported by the file server are chosen to make a client access to the files simple.
Special attention is given for maintaining priority among the clients. Various aspects of
the implementation have been executed to ensure the optimized functioning of the
server system.

Keywords:
Multithreading

A technique by which a single set of code can be used by several processors at


different stages of execution.

Client
A client is a requesting program or user in a client-server relationship.
Server
The computer handling the request and sending back the HTML file is a server.

Socket

Socket is an end point of communication between two systems on a network. It is a


combination of IP address and port on one system.
So, on each system a socket exists for a process interacting with the socket on other
system over the network.
A combination of local socket and the socket at the remote system is also known a
„Four tuple‟ or „4-tuple

Types of network communication

• OSI
• TCP/IP
• While OSI is more of a theoretical model, the TCP/IP networking model is
the most popular and widely used.
• the communication over the network in TCP/IP model takes place in form
of a client server architecture
• client begins the communication and server follows up and a connection is
established.
• The Transmission Control Protocol (TCP) is one of the main protocols of
the Internet protocol suite.
• It originated in the initial network implementation in which it
complemented the Internet Protocol (IP). Therefore, the entire suite is
commonly referred to as TCP/IP

RELATED WORKS:
Many of the researchers proposed many methods:

Mehmet Aksit and Lodewijk Bergmans et al, in his paper “Composing Multiple-Client-
MultipleServer Synchronization” at TRESE project at University of Twente presents that object-
oriented concurrent languages must not only support a single-server model, but cooperatively
synchronizing servers as well. This paper first classifies multi-server synchronization in five
categories. The intention here is to define a framework for evaluating current approaches and
identifying the requirements for designing new languages. In addition, this paper presents a
composable multi-server synchronization technique, adopting the concept of composition-filters.

Yaoping Ruan, Vivek S Pai, Erich Nahum, John M Tracey at ACM SIGMETRICS
Performance evaluation review proposed paper “Evaluating the impact of simultaneous
multithreading on network servers using real hardware” the performance of simultaneous
multithreading (SMT) for network servers using actual hardware, multiple network server applications,
and several workloads. Using three versions of the Intel Xeon processor with Hyper-Threading, we
perform macroscopic analysis as well as microarchitectural measurements to understand the origins of
the performance bottlenecks for SMT processors in these environments and performance models yield
much more optimistic -benefits for SMT than we observe.

Josep Oriol Fit´o , Jordi Guitart proposed “Analyzing the Performance of a Multithreaded
Application Server and its Limitations in a Multiprocessor Environment” present an in-depth
study of the performance of an application server in a multiprocessor environment which process
representative workloads of nowadays.
.
Ms.Rupilaa V.M., Ms.Sangeetha M., Mr.Sathya Seelan K., Mr.Vadivel R. et al in their
International Journal on Recent and Innovation Trends in Computing and Communication proposed
“TCP Concurrent Echo Program using Fork and Thread” explained In networking, client-server
model plays a vital role in exchanging information between processes. Client-server model
predominantly relies on socket programming. Sockets allow communication between processes on
same or different machines. Servers in the client-server model are of two types- Iterative and
Concurrent. This paper describes about the elementary socket function for TCP client/server.

Joshua A. Redstone, Susan J. Eggers and Henry M. Levy et al Proceedings of the 9th International
Conference on Architectural Support for Programming Languages and Operating Systems, November
2000 presents the first analysis of operating system execution on a simultaneous multithreaded (SMT)
processor. SMT is a latency-tolerant CPU architecture that executes multiple instructions from
multiple threads each cycle. The ability to issue instructions from different threads provides better
utilization of execution resources by converting thread-level parallelism into instruction-level
parallelism.

Nima Kaveh and Wolfgang Emmerich et al proposed Deadlock Detection in Distributed Object
Systems The behaviour of a distributed system is largely determined by the use of synchronization
primitives and threading policies of the underlying middleware.
PROPOSED METHOD/ALGORITHM

CLIENT:

/* ---------- INITIALIZING VARIABLES ----------- */

• client server are two file descriptors.


• These two variables store the values returned by the socket system call and the accept
system call.
• portNum is for storing port number on which the accepts connections.
• isExit is bool variable which will be used to end the loop.
• The server reads characters from the socket connection into a dynamic variable (buffer).
• A sock addr_in is a structure containing an internet address. This structure is already
defined in netinet/in.h, so we don't need to declare it again.

DEFINITION:
struct sockaddr_in
{
short sin_family; u_short sin_port;
struct in_addr sin_addr; char
sin_zero[8]
};
1. serv_addr will contain the address of the server.
2. socklen_t is an intr type of width of at least 32 bits.

/* ---------- ESTABLISHING SOCKET CONNECTION ----------*/


/* --------------- socket() function ------------------*/ /*
The socket() function creates a new socket.
It takes 3 arguments,
• AF_INET: address domain of the socket.
• SOCK_STREAM: Type of socket. a stream socket in which characters are read in a continuous
stream (TCP)
• Third is a protocol argument: should always be 0. The OS will choose the most appropiate
protocol.
• This will return a small integer and is used for all references to this socket. If the socket call
fails, it returns -1.

/* ------------- LISTENING CALL ------------- */ /* ---------


------- listen()----------------- */
The listen system call allows the process to listen on the socket for connections. The program will
be stay idle here if there are no incoming connections. The first argument is the socket file
descriptor, and the second is the size for the number of clients.
the number of connections that the server can handle while the process is handling a particular
connection.
The maximum size permitted by most systems is 5.

/* ------------- ACCEPTING CLIENTS -------------- */


/* ----------------- listen() ------------------- */

The accept() system call causes the process to block until a client connects to the server. Thus, it wakes
up the process when a connection from a client has been successfully established.
It returns a new file descriptor, and all communication on this connection should be done using the
new file descriptor.

The second argument is a reference pointer to the address of the client on the other end of the
connection, and the third argument is the size of this structure.
*/
/*

SERVER:

/* ---------- INITIALIZING VARIABLES ----------- */

• client is a file descriptor to store the values returned by the socket system call and the accept
system call.
• portNum is for storing port number on which the accepts connections.
• isExit is bool variable which will be used to end the loop
• The client reads characters from the socket connection into a dynamic variable (buffer).
A sockaddr_in is a structure containing an internet address. This structure is already defined in
netinet/in.h, so we don't need to declare it again.

/* ---------- ESTABLISHING SOCKET CONNECTION ---------- */


/* --------------- socket() function ------------------ */
/*The socket() function creates a new socket. It takes 3 arguments,
a. AF_INET: address domain of the socket.
b. SOCK_STREAM: Type of socket. a stream socket
in which characters are read in a continuous stream
(TCP)

c.
Third is a protocol argument: should always be 0. The OS will
choose the most appropiate protocol.
This will return a small integer and is used for all references
to this socket. If the socket call fails, it returns -1.
*/
/*
The variable serv_addr is a structure of
sockaddr_in. sin_family contains a code for the
address family.
It should always be set to AF_INET.
htons() converts the port number from host byte
order to a port number in network byte order.
*/

/* ---------- CONNECTING THE SOCKET ----------- */


/* ---------------- connect() -----------------*/
/*
The connect function is called by the client to
establish a connection to the server. It takes
three arguments, the socket file descriptor, the
address of the host to which it wants to
connect (including the port number), and the
size of this address.
/*-------------FORKING THE PROCESS ------------- */
/*----------------fork() --------------------- */

The fork() system call will be used to create multiple clients that will interact with the
server.
It returns a unique pid value for each clients or child process or request thus helps in
connecting to server individually.

/* ---------------- CLOSE CALL -------------- */


/* ----------------- close() ---------------- */*
Once the server presses # to end the connection,
the loop will break and it will close the server
socket connection and the client connection
RESULT AND DISCUSSION
From the above project, a multithreaded client server system is successfully established. With the use
of operating system concepts like creating processes using fork() and a little of networking concepts
like socket programming is shown that when different clients are requesting the server for interaction,
the server create many child processes which handles the request of different clients accessing the
server. Thus, a system is created in which clients and servers are connected to a common network.
SERVER CODE:
SERVER OUTPUT:
CLIENT CODE:
CLIENT 1:

CLIENT 2:
CLIENT 3 :

CONCLUSION
Client/server program for concurrent server using fork and thread is implemented and show along
with the execution. Synchronization problem exist with threads which can be overcome by using
mutex and condition variables. The advantage of implementing this methods are the central
management of server. Also this is good for server administrator because they only have to be in
one place and can solve all the problems in one place as well. The configuration is simple to setup.
Moreover it takes less time to troubleshoot because troubleshooting takes place at one physical
server. The major problems that occurs due to this server client model is that all the resources are
located on one server , this creates a single point of failure. It means that if anything should happen
to the server such as a crashed hard drive that is not recoverable, then all the resources that were
once hosted on that server will no longer be available.

CURRENT APPLICATIONS OF CLIENT SERVER MODEL


Banking: Based on Internet personal banking. Consequently,the typical requests of an online bank
were simulated, such as login/logout, bank balance inquiry,money transfers, look at and modify the
user profile,etc. All of these requests are based on SSL. Since in the first (and mandatory) transaction
an SSL connection is established, all the above mentioned requests are based on SSL. Furthermore, the
possible operations include both POST and GET HTTP methods.

E-commerce, based on the workload characteristics of an e-commerce site. It was designed to


simulate a Web server that sells computer systems; this includes allowing users to search,
browse,customize, and purchase products. In fact, a customer visiting the emulated site passes through
three distinct phases. The first is when the customer browses the website, looking for a product. The
second is the customization phase, were the end user customizes the desired product. Finally, if the
customer wants to check out or buy the product, then he must use requests based on SSL
The Future of Client/Server Systems

The single-system image is a reality. In the future, cheap and powerful workstation technology will be
available to everyone—with truly distributed applications using processing power wherever it is
available and providing information wherever it is needed. In the future, information will be available
for use by owners and authorized users, without the constant need for professional systems developers
and their complex programming languages. The future will bring information captured at its source
and available immediately to authorized users.

The future will provide information from data in its original form: image, video, audio, graphics,
document, spreadsheet, or structured data, without the need to be aware of specific software for each
form. Successful organizations of the future—those that are market-driven and competitive—will be
ones using client/server as an enabling technology to add recognized value to their product or service.

References:
[1] Computer Networking: Top-Down Approach – Jim Kurose
[2] Advanced Concepts in Operating Systems - Mukesh Singhal, Niranjan G. Shivaratri
[3] Online Sources – Wikipedia, GeekForGeeks, Stack Overflow, etc.
[4] Alizar B, Gabhane P, Gampawar A, Naraswani A,’File Transfer Protocol Client: by using
multithreding’,E-ISSN: 2249-3999,Volume2,issue 1,2012
[5] “Composing Multiple-Client-Multiple-Server Synchronization” by Mehmet Aksit and Lodewijk Bergmans
at TRESE project at University of Twente
[6] “Evaluating the impact of simultaneous multithreading on network servers using real hardware” by
Yaoping Ruan, Vivek S Pai, Erich Nahum, John M Tracey at ACM SIGMETRICS Performance
[7] Josep Oriol Fit´o , Jordi Guitart “Analyzing the Performance of a Multithreaded Application Server and its
Limitations in a Multiprocessor Environment”
[8] Ms.Rupilaa V.M., Ms.Sangeetha M., Mr.Sathya Seelan K., Mr.Vadivel R. et al in their International Journal
on Recent and Innovation Trends in Computing and Communication proposed “TCP Concurrent Echo
Program using Fork and Thread”
[9] Joshua A. Redstone, Susan J. Eggers and Henry M. Levy et al Proceedings of the 9th International
Conference on Architectural Support for Programming Languages and Operating Systems, November 2000
[10] Nima Kaveh and Wolfgang Emmerich “Deadlock Detection in Distributed Object Systems”

You might also like