Académique Documents
Professionnel Documents
Culture Documents
4 Definitions:
a) Send
For sending the message from source to the destination
b) Leave
c) Disconnect the client
d) Join
Connects client to server
e) Quit
Closes the client interface
1.3 References:
a) Java 7 The Complete Reference by Herbert Schildt
b) Head First Java OReilly
c) Black Book Dr. R. Nageswara Rao
1. Overview
The rest of this SRS document describes the various system requirements, interfaces,
features and functionalities in detail.
2.4 Hardware Interface:
a) Client Side
(1) Processor: Pentium II at 500 MHz
(2) Ram: 64 MB
(3) Disk Space: 2 MB
b) Server Side
(1) Processor: Pentium III at 1 GHz
(2) Ram: 512 MB
(3) Disk Space: 3 MB
2.5 Communication Interfaces:
a) Client on Internet will be using UDP Protocol.
b) Client on intranet will be using UDP protocol
d) Linux
2.5 Operations:
a) Message passing between client and server
b) Communication between multiple clients.
3 Specific requirements
This section contains the software requirements to a level of detail sufficient to
enable designers to design the system, and testers to test the system.
3.1 External Interface Requirement:
Reliable
Available
Secure
3.6 Security:
Users will have to enter correct username, role and password in order to send message.
3.7 Maintainability:
The application will be designed in a maintainable manner. It will be easy to incorporate
new requirements in the individual modules.
3.8 Portability:
The application will be easily portable on any windows-based system.
3.9 Logical Database Requirement:
None
3.10 Other Requirements:
None
Read a local port to set the server running on as a command line argument.
Create a socket and accept chat packets on the local port.
Create a thread to handle each packet which arrives at the server:
o Parse the packet and decide what to do with it
o Send the resulting packet to one client or broadcast to all clients
Close the sockets if an exception occurs.
Correctly terminate the threads.
After the sockets are closed, connect more clients without re-starting the chat
server.
Complete each of these tasks for multiple concurrent users.
Each of these tasks was implemented entirely in Java, and can be run on any machine
which supports Java.
Implementation
After the sockets are closed, connect more clients without re-starting the proxy:
Once the server is started it will continually listen for new connections on the port
it is listening to. Therefore, if one connection is ended, thereby closing the sockets
and terminating the threads, the chat server will still be active, listening for more
users to connect. It does not need to be restarted in order to be connected to by
more clients, because it runs independently, with or without users currently using
it.
text area is the one that the messages will get presented to the user on. The Run()
method of the Thread Class is overwritten, and does the parsing of the incoming
message.
You've already been introduced to the Java Virtual Machine; it's the base for the Java
platform and is ported onto various hardware-based platforms.
The API is a large collection of ready-made software components that provide many
useful capabilities. It is grouped into libraries of related classes and interfaces; these
libraries are known as packages. The next section, What Can Java Technology
Do? highlights some of the functionality provided by the API.
Development Tools: The development tools provide everything you'll need for
compiling, running, monitoring, debugging, and documenting your applications.
As a new developer, the main tools you'll be using are the javac compiler,
the java launcher, and the javadoc documentation tool.
Application Programming Interface (API): The API provides the core
functionality of the Java programming language. It offers a wide array of useful
8
classes ready for use in your own applications. It spans everything from basic
objects, to networking and security, to XML generation and database access, and
more. The core API is very large; to get an overview of what it contains, consult
the Java SE Development Kit 6 (JDK 6) documentation.
Deployment Technologies: The JDK software provides standard mechanisms
such as the Java Web Start software and Java Plug-In software for deploying your
applications to end users.
User Interface Toolkits: The Swing and Java 2D toolkits make it possible to
create sophisticated Graphical User Interfaces (GUIs).
Integration Libraries: Integration libraries such as the Java IDL API, JDBC
API, Java Naming and Directory Interface (JNDI) API, Java RMI, and Java
Remote Method Invocation over Internet Inter-ORB Protocol Technology (Java
RMI-IIOP Technology) enable database access and manipulation of remote
objects.
required on the both end for reassembling them. In the sending end, stack breaks
the flow of the data and sends the data in the form of packets, on the receiving
end, the stack reassemble the data from packets to flowing form.
TCP has 20 bytes of overhead while UDP has only 8 bytes of overhead.
Times can be established in TCP protocol in sending the data, because the data
packets goes one after one in the sequence form and each packets takes a specific
time period, whereas no times period can be established in the UDP protocol case,
because the data transmits in non-sequence form.
UDP transmit the data according to the generation of data, which is produced by
the bandwidth of the Internet, if there is any obstacle in the network it could be
lost due to the overflowing of data in the router. On the other hand TCP has a
cognition control mechanism that indicates the senders about the congestion and it
tolerate the transmitting process for some times.
IN spite of being so many demerits, UDP is very useful in some circumstances, especially
in speed and network management. Its speed is faster than TCP protocol. UDP transports
the data periodically and with no guarantee. So the updated data can be send after a
certain period, which not only recovers the lost data but also it updates network. While in
the TCP it is very difficult to recover the lost data at the congestion stage. It is also not
suitable to carry network management due to its transmitting methodology.
UDP Client in Java
The User Datagram Protocol (UDP) is a transport protocol that supports Network
Application. It layered on just below the Session and sits above the IP(Internet
Protocol) in open system interconnection model (OSI). This protocol is similar to TCP
(transmission control protocol) that is used in client/ server programs like
videoconference systems expect UDP is connection less.
User Datagram Protocol transports the data between the computers in the form of data
packets, but it does not track the data and never shows the confirmation report.
UDP and TCP both are used to transport the data but there are some differences in it.
UDP never track the data, so never shows the confirmation report, while TCP
track the data and show confirmation report, after receiving, if the data losses
anywhere it resends that particular data.
10
UDP transport the data in the form of Data packets, whereas TCP transport the
data in long stream. It flows continuous. To make in the form of packets stack is
required on the both end for reassembling them. In the sending end, stack breaks
the flow of the data and sends the data in the form of packets, on the receiving
end, the stack reassemble the data from packets to flowing form.
TCP has 20 bytes of overhead while UDP has only 8 bytes of overhead.
Times can be established in TCP protocol in sending the data, because the data
packets goes one after one in the sequence form and each packets takes a specific
time period, whereas no times period can be established in the UDP protocol case,
because the data transmits in non-sequence form.
UDP transmit the data according to the generation of data, which is produced by
the bandwidth of the Internet, if there is any obstacle in the network it could be
lost due to the overflowing of data in the router. On the other hand TCP has a
cognition control mechanism that indicates the senders about the congestion and it
tolerate the transmitting process for some times.
IN spite of being so many demerits, UDP is very useful in some circumstances, especially
in speed and network management. Its speed is faster than TCP protocol. UDP transports
the data periodically and with no guarantee. So the updated data can be send after a
certain period, which not only recovers the lost data but also it updates network. While in
the TCP it is very difficult to recover the lost data at the congestion stage. It is also not
suitable to carry network management due to its transmitting methodology.
11
It helps in delivering messages from the source host to the ultimate destination as a
postcard; small but not with a guarantee of delivery but TCP works like a telephone by
verifying the destination address. Usually UDP is used to deliver a small amount of data
to a large number of recipient at one set period of time. So it low over heading and
multitasking capacity stands it ahead than TCP.
The Datagram
The datagram is an unite of packet or packet for transfer in the TCP/IP network. Each
datagram packet has data with source and destination address.
Description of program:
When you will run the program then a layout will appear on the screen that contains two
buttons 'Start' and 'Stop' with a text area, where you receive your messages. The messages
can be received only on that time when the UDP server is started. Whenever the UDP
server is stopped then you can't be sent any message by the UDP client. If UDP server is
started then it display the the message "Server is started" in the text area otherwise it
shows "Server is stopped" or no any message in the text area.
Description of code:
Thread():
Thread is a constructor of Thread class. The Thread class extends the Object and
implements theRunnable. It creates a new thread object. Where you require, the
executing of program continuously you can be used thread.
thread.start():
This method starts the thread for executing the program. The run() method is called
automatically when the start() method is execute.
thread.interrupted():
The above method interrupts the thread that means breaking the thread for some time. If
you want to start the thread again you can start it.
DatagramSocket(int port):
DatagramSocket is the constructor of DatagramSocket class. This class extends Object.
12
It creates the datagram socket and takes only integer port number. This socket binds the
specified port number where the messages is send on the local host machine.
append(String str):
This method is used to insert or append given the string in it.
DatagramPacket(byte[] buffer, int buffer_length):
This constructor provided by the DatagramPacket class. This class extends the Object
and imports the java.net.*. It constructs a DatagramPacket to the receiving packet length.
It takes the buffer size and buffer length. Where the connectionless services are provided
by the user then use it.
receive(DatagramPacket packet):
The datagram packet received by this method from the specified socket.
InetAddress:
This class extends the Object and implements the Serializable. It displays the IP
address.
getAddress():
Above method returns the IP address of the object of InetAddress class, where the
datagram packet can be send or receive.
getPort():
This method returns the port number of the host machine. Where the datagram packets
can be send or receive.
socket.close():
This method closes the datagram socket that means you can not be received any
messages.
13
Description of program:
When you will run the program then appears a graphical layout on the screen. Which has
destination IP (Internet protocol) address (localhost or 127.0.0.1), destination port
number (8080), a text area and a 'Send' command button. All information or messages are
written by client in a text area after that you clicked on the 'Send' button then messages to
be send into the UDP server and it also sends a message to UDP client in the text area.
Therefore UDP client can identify that your sending information are received or not by
the UDP server.
14
1. Unicast: This method solves network traffic problems to deliver messages from one
host to another. Here, data can be delivered to one specific destination IP (Internet
Protocol) address that means only one sender sends data and another receives at a time.
So, you can say that this is one-to-one data delivering method like: walky-talky and
telephone or mobile phone. These equipments provide the facility of transferring data
only one user at a time. If one user uses this then another is not accessed.
The unicast method is not efficient for network traffic problem because it supports oneto-one transmission that consumes more time and provides slow processing for deliver
data from one user to another.
2. Multicast: In this method, you can transmit data or messages to all destination host
machines, which has been interested an appropriate multicast group. The sender
generates only one data stream but it delivered to all destination hosts. It supports one-tomany data delivering networks. Multicast delivers a data or information simultaneously
to all interested destination hosts machines. The multicast methodology are used in case
of teleconferencing and videoconferencing. The teleconferencing and videoconferencing
machines transmit data simultaneously to all interested parties present in the same group.
Multicast provides the best features to unicast and broadcast because, here neither carries
the burden of data to delivering all hosts nor miss-utilize the entire network. Users are
joined in the multicast groups to follows an appropriate standards like: IP Multicast and
Mbone.
In case of addressing and classifying the entire network, multicast is placed in a class 'D'
IP address and which has addresses space 224.0.0.0 to 239.255.255.255.
3. Broadcast: It provides better facility to solve a network traffic problems than unicast.
In broadcast, the server generates only one data stream but it can be delivered to all
destination host whether interested or not. Here transmitting data or packets to be
received by every host machine on entire network that means you send data or messages
to multiple host at a time or simultaneously. It uses in the e-mail systems and some fax
system. In case of e-mail and fax system, you give more than one addresses in place of
address and send it then all destination receive this message simultaneously.
This data delivering process is fast but a network carries more burden in delivering. So,
the values of network resources are worst and miss-utilize the entire network. Ethernet
15
and IPv4 are used to represent the broadcast address and packet but IPv6 does not support
directed broadcasts or local broadcasts.
Multicast Server in Java
This section introduces how to receive and send the IP packet by the multicast server and
provides the functionality of multicast server through program. A brief description is
given bellow.
Description of program:
Here, a graphical layout appears on the screen when program runs that has two command
buttons 'Start' and 'Stop'. First time 'Start' button is enable and another is disable. When
you click 'Start' button, the multicast server functions but button is disable, and the
message "Server is started" is displayed in text area. If you want to stop the server then
click on the 'Stop' button then multicast server resume its function with a message that
"Server is stopped". The multicast server receives requests or messages from multicast
client, which has the port number '5000' and IP(Internate Protocol) number ('224.0.0.0',
'235.0.0.1', '235.255.0.1', '224.0.255.1'). The server also sends same message to all
multicast clients that are interested for this group otherwise don't perform these works.
Description of code:
MulticastSocket(int port):
This is the constructor of MulticastSocket class. This class imports from import
java.net.* package and extends the DatagramSocket that can be used for sending or
receiving the multicast IP packets. It is same as DatagramSocket (UDP) and provides an
extra facility to joining 'groups' of multicast hosts on the Internet. The above constructor
constructs multicast socket. It takes integer type port number to bound it.
DatagramPacket(byte[] buf, int length, InetAddress address, int port):
DatagramPacket is a constructor of DatagramPacket class. This class extends the Object
and imports form import java.net.* package that can be used for delivering the
connectionless packet so packet delivering is not guarantee at the destination host. This
constructor creates a datagram packet and delivers or transfers packet length to specified
port number at the specified host.
16
17
A program uses an output stream to write data to a destination, one item at time:
Interfaces: These are abstract data types that represent collections. Interfaces
allow collections to be manipulated independently of the details of their
representation. In object-oriented languages, interfaces generally form a
hierarchy.
Implementations: These are the concrete implementations of the collection
interfaces. In essence, they are reusable data structures.
Algorithms: These are the methods that perform useful computations, such as
searching and sorting, on objects that implement collection interfaces. The
algorithms are said to be polymorphic: that is, the same method can be used on
many different implementations of the appropriate collection interface. In
essence, algorithms are reusable functionality.
18
Apart from the Java Collections Framework, the best-known examples of collections
frameworks are the C++ Standard Template Library (STL) and Smalltalk's collection
hierarchy. Historically, collections frameworks have been quite complex, which gave
them a reputation for having a steep learning curve. We believe that the Java Collections
Framework breaks with this tradition, as you will learn for yourself in this chapter.
Benefits of the Java Collections Framework
The Java Collections Framework provides the following benefits:
What is Swing?
To create a Java program with a graphical user interface (GUI), you'll want to
learn about Swing.
The Swing toolkit includes a rich set of components for building GUIs and adding
interactivity to Java applications. Swing includes all the components you would
19
expect from a modern toolkit: table controls, list controls, tree controls, buttons,
and labels.
Swing is far from a simple component toolkit, however. It includes rich undo
support, a highly customizable text package, integrated internationalization and
accessibility support. To truly leverage the cross-platform capabilities of the Java
platform, Swing supports numerous look and feels, including the ability to create
your own look and feel. The ability to create a custom look and feel is made
easier with Synth, a look and feel specifically designed to be customized. Swing
wouldn't be a component toolkit without the basic user interface primitives such
as drag and drop, event handling, customizable painting, and window
management.
Swing is part of the Java Foundation Classes (JFC). The JFC also include other
features important to a GUI program, such as the ability to add rich graphics
functionality and the ability to create a program that can work in different
languages and by users with different input devices.
The following list shows some of the features that Swing and the Java Foundation
Classes provide.
Swing GUI Components
o The Swing toolkit includes a rich array of components: from basic
components, such as buttons and check boxes, to rich and complex
components, such as tables and text. Even deceptively simple components,
such as text fields, offer sophisticated functionality, such as formatted text
input or password field behavior. There are file browsers and dialogs to
suit most needs, and if not, customization is possible. If none of Swing's
provided components are exactly what you need, you can leverage the
basic Swing component functionality to create your own.
Java 2D API
To make your application stand out; convey information visually; or add
figures, images, or animation to your GUI, you'll want to use the Java 2D
API. Because Swing is built on the 2D package, it's trivial to make use of
2D within Swing components. Adding images, drop shadows, compositing
it's easy with Java 2D.
Pluggable Look-and-Feel Support
o Any program that uses Swing components has a choice of look and feel.
The JFC classes shipped by Sun and Apple provide a look and feel that
matches that of the platform. The Synth package allows you to create your
own look and feel. The GTK+ look and feel makes hundreds of existing
look and feels available to Swing programs.
o A program can specify the look and feel of the platform it is running on, or
it can specify to always use the Java look and feel, and without
recompiling, it will just work. Or, you can ignore the issue and let the UI
manager sort it out.
Data Transfer
Data transfer, via cut, copy, paste, and drag and drop, is essential to almost
any application. Support for data transfer is built into Swing and works
20
Part 5 Testing:
The goal of testing is to locate system errors before installation these system errors can
take different forms including the coding errors that reduce system efficiency. For this
21
reason a systematic testing procedure has been adopted which covers all functions, even
the ones that are certain to work. The following are the testing approaches are used:
1. Black box testing
2. White box testing
3. User interface testing
4. Functionality testing
5. Load Testing
22
Tester: H.M.
Value Entered:
NA
NA
Expected Result: A test conducted to check if the user is able to navigate from main page to
any action within three mouse clicks for all the features offered.
Observed Result : The programmer was able to navigate from main page to any action
within three mouse clicks
Tester: H.M.
23
Test Objective: Test conducted to record the time taken for each client-interface to load.
Data Field:
Value Entered:
N/A
Mouse clicks.
Expected Result: The Client-Interface takes a very minimum time of two seconds to load.
Observed Result: The observed result was same as the expected result.
Tester: H.M.
Test Objective: Test conducted to record the response time of the system.
24
Data Field:
Value Entered:
Send.
Mouse clicks.
Expected Result: The results are expected to appear within two seconds of clicking the
mouse. This applies to a very large message.
Observed Result: The observed result was same as the expected result.
Tester: H.M.
Test Objective: Test conducted to crosscheck the headings in Client Interface for userfriendly names.
25
Data Field:
Value Entered:
Machine:port
User Name
Mouse clicks
Join Chat
Message
Mouse clicks.
Send.
Expected Result: The column names for each input are expected to be meaning-full defining
the functionality. This enable the users to understand the various the functionality of various
fields.
Observed Result: The observed result was same as the expected result.
Tester: H.M.
Test Objective: Test conducted to explain the format of entry in each data field for the users
26
Data Field:
Value Entered:
Machine:port
User Name
Mouse clicks
Join Chat
Message
Mouse clicks.
Send.
Expected Result: The interface is expected to balance the requirement of both the novice
and experienced users by displaying the format for entry of data in all the products.
Observed Result: The interface developed by the team displayed the format for entry of data
in each field.
Tester: H.M.
Test Objective: Test conducted to crosscheck between user experience and the interface
developed.
27
Data Field:
Value Entered:
Machine:port
User Name
Mouse clicks
Join Chat
Message
Mouse clicks.
Send.
Expected Result: The interface is expected to balance the requirement of both the novice
and experienced users.
Observed Result: The observed result was same as the expected result.
4. Functionality Testing:
Test for - all the features of the chat-system interface used for submitting or
getting text information from users involved in chat.
Check all the features:
System has been tested for functionalities such as
1. Client connection with the server
2. Private message to specific user logged on chat system.
3. Public message to al users logged on to the chat system
28
After testing all above stated features were found working properly.
Test User Interface:
The Client Interface is the integral part of Chat System. It is used to get
information from users and to keep interaction with them. So following tests has
been performed:
1. First check all the validations on each field.
2. Check for the default values of fields.
3. Wrong inputs to the fields in the forms.
System has been tested for validation as to start chatting client must supply valid
name & port of the Chat server to connect and start communication. Client is also
required to supply valid user name to start private chat.
5. Load testing
General
Description:
This test ensures that the chat server can handle the
maximum number of chat clients that the application
advertises (i.e. 15 successful connections).
Data Files:
None.
Web sites:
http://java.sun.com
http://www.sourceforge.net/projects/jasperreports
http://ireport.sourceforge.net/index.html
http://javasoft.com/
http://javaworld.com/
Books:
a) Java 7 The Complete Reference by Herbert Schildt
b) Head First Java OReilly
c) Black Book Dr. R. Nageswara Rao
29
30
31