Professional Documents
Culture Documents
By
Akhil Khandelwal
Ankur Mahajan
Karthik Rajagopal
Sachin Prakash
Page 1 of 61
TABLE OF CONTENTS
REQUIREMENT ANALYSIS
Abstract 3
Introduction 4
Purpose
Scope
Overall Description 5
Product Perspective
Product Functions
Constraints
Software Environment 7
Description of Technologies Used 9
SYSTEM DESIGN
Basic Architecture 22
Dataflow Diagrams 23
Flowcharts 26
Sequence Diagrams 31
IMPLEMENTATION
Screenshots 36
For Command Line Interface 37
For Graphical User Interface 49
Bibliography 59
Conclusion 60
Future Enhancements 61
Page 2 of 61
ABSTRACT
Threads are often called lightweight processes that run in the same address
space. Multithreading is a technique that allows parallel execution of multiple
threads. The enables file transfer between client and server with the help of
POSIX (Portable Operating System Interface for Computer Environments)
threads. Since threads are very small as compared to the processes, thread
creation is relatively cheap in terms of CPU costs.
Page 3 of 61
INTRODUCTION
1. PURPOSE
2. SCOPE
MUFSYS shall comprise of modules for both the client and the server. It shall
be a secure system that will provide a username and password protected
access. Multithreading will make the system more efficient since it reduces
the overhead that would otherwise be required for separate processes.
The system will run on mostly all Linux distributions and on Windows.
Page 4 of 61
OVERALL DESCRIPTION
1. PRODUCT PERSPECTIVE
Page 5 of 61
1.4 Memory Constraints
2. PRODUCT FUNCTIONS
The system will require user authentication prior to any file transactions.
3. USER CHARACTERISTICS
The user should be comfortable with the English language. Although help will
be available on all the services, but a basic knowledge of the Linux operating
system is required to become the system administrator.
Page 6 of 61
4. CONSTRAINTS
Page 7 of 61
SOFTWARE ENVIRONMENT
OPERATING SYSTEM
The operating systems used were Redhat Linux Fedora Core 4 and
Windows XP Professional. The server runs on Linux or Windows and can
support both Linux and Windows clients. Being cross-platform in Windows
and linux is one of the prime features of MUFSYS.
LANGUAGE USED
The GNU C language has been used for coding the server as well as the
client. GNU C was used for implementing Linux Socket Programming.
TOOLS USED
Trolltech Qt Designer has been used for designing the GUI for Linux
clients. Qt comes in-built on Linux platforms and uses C++ as its base. It as
poetable on other platforms such as Windows as well and that makes it a
good choice for GUI design.
Microsoft Visual C++ has been used to create the client–side executable
files for creating a command-line interface. Winsock sockets are used for
implementing sockets in a windows environment.
Page 8 of 61
DESCRIPTION OF TECHNOLOGIES USED
Several years ago, networking involved a dedicated serial line from one
computer to another. No other computers shared the same circuit and UNIX
used UUCP (UNIX-to-UNIX File Copy) to move files around. As transmission
technology improved, the concept of sharing the transmission lines became
feasible. This meant that each computer needed to identify itself uniquely
and take turns transmitting. At times, computers transmit simultaneously,
causing a packet collision. Today, the hardware and low level drivers handle
such issues as collision and retransmission. The socket API (Application
Programming Interface) provides the programmers a conduit to send and
receive packets.
Before any communication can take place between the client and the server,
a socket needs to be created. The client program must follow the following
steps to connect to the server. Each client interfaces with the system by
making several calls in succession. The steps needed are:-
1. Create the socket by using the socket() system call. One also has to
choose the network domain (Eg. Internet) and the socket type
(stream). One also optionally set other socket options.
2. Bind to address/port i.e., specify IP addresses from where to accept
connections. Otherwise the operating system assumes any IP address
and random port number.
3. Connect to peer/server. This step establishes a bidirectional channel
between the two programs. Skipping these steps leads to a
connectionless channel.
4. Limit the channel to either sending or receiving.
5. Send/receive messages.
6. Close the connection. Long running programs may use up all available
file-descriptors if defunct connections are not closed.
Page 9 of 61
The following schematic diagram presents an outline of the successive
steps that need to be followed.
Socket()
bind()
connect()
read() write()
close()
The TCP/IP protocol suite uses standard IP addresses that are 32 bit (4
byte) long. The standard format for IP addresses is [0-255]- [0-255]- [0-
255]- [0-255] for example 168.192.50.149. TCP/IP considers data as a
collection of packets. Each packet consists of the data, the originator
address, and the destination address. Each layer adds its own signature and
wrapper data which is removed by the corresponding receiving layer. Every
computer connected to the network has an IP address which uniquely
identifies the computer on the network. TCP/IP takes the addressing system
Page 10 of
61
one step further by the concept of ports. A port is a logical abstraction and
does not have a physical form. A socket can be considered to be a named
port, i.e. a combination of IP address and the port number.
sockfd is the listening socket descriptor. Mostly, addr will usually be a pointer
to a local struct sockaddr_in. This is where the information about the
incoming connection goes (and with it one can determine
which host is calling and from which port). addrlen is a local integer variable
that should be set to sizeof(struct sockaddr_in) before its address is passed
to accept(). Accept will not put more than that
many bytes into addr. If it puts fewer in, it will change the value of addrlen
to reflect that. Accept() returns -1 and sets errno if an error occurs.
int send(int sockfd, const void *msg, int len, int flags);
Page 11 of
61
sockfd is the socket descriptor where one intends to send the data. msg is a
pointer to the data one wants to send, and len is the length of that data in
bytes.
int recv(int sockfd, void *buf, int len, unsigned int flags);
sockfd is the socket descriptor to read from, buf is the buffer to read the
information into, len is the maximum length of the buffer. recv() returns the
number of bytes actually read into the buffer, or -1 on error (with errno set,
accordingly.) recv() returning a value of 0 indicates that the remote site has
closed the connection.
close(sockfd);
This will prevent any more reads and writes to the socket. Anyone
attempting to read or write the socket on the remote end will receive an
error.
Page 12 of
61
THREADS
Threads use and exist within these process resources, yet are able to be
scheduled by the operating system and run as independent entities
largely because they duplicate only the bare essential resources that
enable them to exist as executable code. This independent flow of control
is accomplished because a thread maintains its own:
o Stack pointer
o Registers
o Scheduling properties (such as policy or priority)
o Set of pending and blocked signals
o Thread specific data.
Page 13 of
61
o Duplicates only the essential resources it needs to be
independently schedulable
o May share the process resources with other threads that act
equally independently (and dependently)
o Dies if the parent process dies - or something similar
o Is "lightweight" because most of the overhead has already been
accomplished through the creation of its process.
PTHREADS
In order to take full advantage of the capabilities provided by threads, a
standardized programming interface was required. For UNIX systems, this
interface has been specified by the IEEE POSIX 1003.1c standard (1995).
Implementations which adhere to this standard are referred to as POSIX
threads, or Pthreads. Most hardware vendors now offer Pthreads in addition
to their proprietary API's.
ADVANTAGES OF PTHREADS
Page 14 of
61
o Priority/real-time scheduling: tasks which are more important
can be scheduled to supersede or interrupt lower priority tasks.
o Asynchronous event handling: tasks which service events of
indeterminate frequency and duration can be interleaved. For
example, a web server can both transfer data from previous
requests and manage the arrival of new requests.
• Tasks that may be suitable for threading include tasks that:
o Block for potentially long waits
o Use many CPU cycles
o Must respond to asynchronous events
o Are of lesser or greater importance than other tasks
o Are able to be performed in parallel with other tasks
• One must be careful if ones application uses libraries or other objects
that don't explicitly guarantee thread-safeness. When in doubt,
assume that they are not thread-safe until proven otherwise.
Page 15 of
61
functions to set/query thread attributes (joinable, scheduling
etc.)
o Mutexes: The second class of functions deal with
synchronization, called a "mutex", which is an abbreviation for
"mutual exclusion". Mutex functions provide for creating,
destroying, locking and unlocking mutexes. They are also
supplemented by mutex attribute functions that set or modify
attributes associated with mutexes.
o Condition variables: The third class of functions address
communications between threads that share a mutex. They are
based upon programmer specified conditions. This class includes
functions to create, destroy, wait and signal based upon
specified variable values. Functions to set/query condition
variable attributes are also included.
• Naming conventions: All identifiers in the threads library begin with
pthread_
pthread_mutex_ Mutexes
Page 16 of
61
Creating Threads
Thread Attributes
Terminating Threads
Page 17 of
61
• If main() finishes before the threads it has created, and exits with
pthread_exit(), the other threads will continue to execute. Otherwise,
they will be automatically terminated when main() finishes.
• The programmer may optionally specify a termination status, which is
stored as a void pointer for any thread that may join the calling
thread.
• Cleanup: the pthread_exit() routine does not close files; any files
opened inside the thread will remain open after the thread is
terminated.
• Discussion: In subroutines that execute to completion normally, one
can often dispense with calling pthread_exit() - unless, of course, one
wants to pass a return code back. However, in main(), there is a
definite problem if main() completes before the threads it spawned. If
one does not call pthread_exit() explicitly, when main() completes, the
process (and all threads) will be terminated. By calling pthread_exit()
in main(), the process and all of its threads will be kept alive even
though all of the code in main() has been executed.
Page 18 of
61
TROLLTECH QT GUI DESIGNER
Qt software was chosen for developing the graphical user interface for
MUFSYS. Qt is a comprehensive C++ application development framework. It
includes a class library and tools for cross-platform development.
Qt is a comprehensive development framework that includes an extensive
array of features, capabilities and tools that enable development of high-
performance, cross-platform rich-client and server-side applications.
The Qt Class Library is a growing library of over 400 C++ classes, which
encapsulates all infrastructure needed for end-to-end application
development. The elegant Qt API includes a mature object model, a rich set
of collection classes, and functionality for GUI programming, layout, database
programming, networking, XML, internationalization, OpenGL integration etc.
Qt Designer is a powerful GUI layout and forms builder, enabling rapid
development of high-performance user interfaces with native look and feel
across all supported platforms.
Qt Linguist is a set of tools designed to smooth the internationalization
workflow. Using Qt Linguist, development teams can outsource the
translation of applications to non-technical translators, increasing accuracy
and greatly speeding the localization process.
Qt Assistant is a fully customizable, redistributable help file/documentation
browser that can be shipped with Qt-based applications. With Qt Assistant,
development teams significantly speed the documentation process.
Qt is the leading framework for native cross-platform application
development. The Qt API and tools are consistent across all supported
platforms, enabling developers to learn one API and perform truly platform-
independent application development and deployment. Using Qt,
development teams can create native applications for all major operating
systems - from all major development platforms.
Qt is available for the following platforms:
Qt/Windows (Microsoft Windows XP, 2000, NT 4, Me/98)
Qt/Mac (Mac OS X)
Qt/X11 (Linux, Solaris, HP-UX, IRIX, AIX, etc.)
Page 19 of
61
project. This makes it easy to switch between forms with a single
mouse click.
Qt Designer reads and writes .ui files, e.g. form.ui. The user interface
compiler, uic, creates both a header file, e.g. form.h, and an implementation
file, e.g. form.cpp, from the .ui file. The application code in main.cpp
#includes form.h. Typically main.cpp is used to instantiate the QApplication
object and start off the event loop.
The following diagram shows schematic interaction between various
components of Qt project components:-
Page 20 of
61
MICROSOFT VISUAL C++
Microsoft VC++ was used to design the client side executable file for
Windows-based clients. In order to be able to use POSIX threads in the code,
we are required to link the pthread library into the VC++ environment.
Page 21 of
61
BASIC ARCHITECTURE
Page 22 of
61
DATAFLOW
DATAFLOW DIAGRAMS
Page 23 of
61
CONTEXT DIAGRAM
Administrator
Username
Password
File transfer/
File retrieval retrieval
/transfer
Page 24 of
61
LEVEL 1 DFD
Administrator
Usernames and
passwords
Data Store
GUI
MODULE
Command
handling
Authentication
module
Server Client
File transfer
module File
Service retrieval/
Response Transfer
Page 25 of
61
FLOWCHARTS
Page 26 of
61
CLIENT
AUTHENTICATION
Start
Client enters
username and
password
Yes
Stop
Page 27 of
61
COMMAND HANDLING FOR CLIENT
Start
Command received
from client
Yes
Command received
from client
More clients?
Yes
No
Stop
Page 28 of
61
FILE RETRIEVAL BY CLIENT
Start
Client enters
source and
destination file
names
Yes
Stop
Page 29 of
61
FILE SEND BY CLIENT
Start
Client receives
filename
Stop
Page 30 of
61
SEQUENCE DIAGRAMS
Page 31 of
61
USER AUTHENTICATION
1.Username and
password
2. User info
passed
4.success or 3. result of
access denied Checking
Page 32 of
61
GETTING A FILE
6. calculate
file size and
5. source and destination
packets
filenames
7. Start time
8. File packets
9. End time
Page 33 of
61
PUTTING A FILE
6.
calc.file
5. source and destination
size
filenames
7. Start time
8. File packets
9. End time
Page 34 of
61
GENERAL SERVICES
6. help details
9. close conn
7. command: bye 8. command id
Page 35 of
61
SCREENSHOTS
Page 36 of
61
SCREEN SHOTS
FOR THE COMMAND LINE INTERFACE
Page 37 of
61
PROMPT SCREEN
The following is the first screen that the client will see
when he/she logs in using the command line interface. It
consists of a client prompt from where the user can use
various commands to access the full power of MUFSYS
software.
Page 38 of
61
SERVER SCREEN
The following is the screen for the server. Server can keep
track of the clients who access the system and what all
services they use. A lot of useful information such as the
IP address of the connecting client, the connection date ,
day, etc. are displayed. The server can easily monitor
clients on the system and can either fulfill the clients
request or can even terminate the client’s connection.
Page 39 of
61
OPEN COMMAND
Page 40 of
61
MONITORING ON SERVER
Page 41 of
61
CONNECTION DENIED SCREEN
Page 42 of
61
SCREEN FOR SERVER’S FILE LIST
Page 43 of
61
LOCAL FILE LIST SCREEN
The following screen shows that the client can also view
the files present locally:-
Page 44 of
61
HELP SCREEN
There are certain features for which the client does not have
to be an authenticated user. This means that any user can
avail of certain features without having a password protected
account. These features include commands such as help which
provides a basic introduction about the available features.
Page 45 of
61
FILE RETRIEVAL SCREEN
Page 46 of
61
FILE TRANSFER SCREEN
The client-side user can also put files on the server by using
the put command. This command also requires the user to
enter the source and the destination file names. The command
also displays the time the file transfer started as well as the
time when the file transfer completed.
Page 47 of
61
SESSION TERMINATION SCREEN
Finally the client can terminate the session using the bye
command.
Page 48 of
61
SCREEN SHOTS FOR THE GRAPHICAL USER
INTERFACE (GUI)
Page 49 of
61
SPLASH SCREEN
Page 50 of
61
LOGIN WINDOW
Page 51 of
61
OPTION MENU
Select Option
Page 52 of
61
The following screens show some other commands available.
Some of the commands are list, get, send, help etc.
Get File
Page 53 of
61
The following screen shows the list of file available on the
client as well as the file sizes.
List Of Files
Page 54 of
61
FILE RETRIEVAL MODULE
Page 55 of
61
Page 56 of
61
FILE TRANSMISSION MODULE
Page 57 of
61
HELP SCREEN
The following screen shows the help screen after the user
clicks on the help button. Such features make MUFSYS all
the more user friendly.
Page 58 of
61
BIBLIOGRAPHY
www.microsoft.com/msdn
www.trolltech.com
www.qtcenter.org
Page 59 of
61
CONCLUSION
Both the client and the server have been tested for sending
as well as receiving files.
Page 60 of
61
FUTURE SCOPE
Page 61 of
61