Beruflich Dokumente
Kultur Dokumente
PD rm PD rm
Y Y
Y
Y
er
er
ABB
ABB
y
y
bu
bu
2.0
2.0
to
to
re
re
1
he
he
k
k
lic
lic
C
C
w om w om
w
w
w. w.
A B B Y Y.c A B B Y Y.c
INTRODUCTION
F T ra n sf o F T ra n sf o
PD rm PD rm
Y Y
Y
Y
er
er
ABB
ABB
y
y
bu
bu
2.0
2.0
to
to
re
re
2
he
he
k
k
lic
lic
C
C
w om w om
w
w
w. w.
A B B Y Y.c A B B Y Y.c
1. INTRODUCTION
1.1 ABOUT THE PROJECT
In our network model, there are multiple data items; each data item has a
server, and a set of clients that wish to access the data item at a given frequency. Each
node carefully chooses data items to cache in its limited memory to minimize the overall
access cost. Essentially, in this article, we develop efficient strategies to select data items
to cache at each node. In particular, we develop two algorithms a centralized
approximation algorithm, which delivers a 4approximation (2-approximation for uniform
size data items) solution, and a localized distributed algorithm, which is based on the
approximation algorithm and can handle mobility of nodes and dynamic traffic conditions.
Using simulations, we show that the distributed algorithm performs very close to the
approximation algorithm. Finally, we show through extensive experiments on ns2 [10] that
our proposed distributed algorithm performs much better than a prior approach over a
broad range of parameter values. Ours is the first work to present a distributed
implementation based on an approximation algorithm for the general problem of cache
placement of multiple data items under memory constraint.
F T ra n sf o F T ra n sf o
PD rm PD rm
Y Y
Y
Y
er
er
ABB
ABB
y
y
bu
bu
2.0
2.0
to
to
re
re
3
he
he
k
k
lic
lic
C
C
w om w om
w
w
w. w.
A B B Y Y.c A B B Y Y.c
· Network module
· Uploading the file module
· DataCaching module
Network Module
This is the module that appears like a network. In this network user can put the
hosts and the number of hosts must be less than 50 and more than 10 nodes. In this
network every host is connected to the network.
In this module the user can browse and select the data items such as files. Note that
the data item must be in text file format. Word documents also can be sent but those are
not visible in the destination node.
DataCaching module:
In this it will get all the information that is sent from source to destination nodes.
Note that while traversing the file from source and destination nodes must not be same. We
can see the transferred file in the destination host and we can also observe the transfer
history of the file in the Transfer_history text document.
F T ra n sf o F T ra n sf o
PD rm PD rm
Y Y
Y
Y
er
er
ABB
ABB
y
y
bu
bu
2.0
2.0
to
to
re
re
4
he
he
k
k
lic
lic
C
C
w om w om
w
w
w. w.
A B B Y Y.c A B B Y Y.c
LITERATURE SERVEY
F T ra n sf o F T ra n sf o
PD rm PD rm
Y Y
Y
Y
er
er
ABB
ABB
y
y
bu
bu
2.0
2.0
to
to
re
re
5
he
he
k
k
lic
lic
C
C
w om w om
w
w
w. w.
A B B Y Y.c A B B Y Y.c
2. LITERATURE SERVEY
Below, we categorize the prior work by the number of data items and network
topology. Single Data Item in General Graph. The general problem of determining optimal
cache placements in an arbitrary network topology has similarity to two problems in graph
theory, namely, facility location problem and the k-median problem. Both the problems
consider only a single facility type (data item) in the network. In the facility-location
problem, setting up a cache at a node incurs a certain fixed cost, and the goal is to
minimize the sum of total access cost and the setting-up costs of all caches without any
constraint. On the other hand, the k-median problem minimizes the total access cost under
the number constraint, that is, that at most k nodes can be selected as caches. Both
problems are NP-hard, and a number of constant-factor approximation algorithms have
been developed for each of the problems under the assumption of triangular inequality of
edge costs. Without the triangular inequality assumption, either problem is as hard as
approximating the set cover and thus cannot be approximated better unless P ¼ NP. Here,
JV j is the size of the network. In other related work, Nuggehalli et al. formulate the
caching problem in ad hoc networks as a special case of the connected facility location.
Single Data Item in Tree Topology Several papers in the literature circumvents
the hardness of the facility location and k-median problems by assuming that the network
has a tree topology. In particular, Tamir and Vigneron et al. design optimal dynamic
programming polynomial algorithms illustrating cache placement problem under memory
constraint. The k-median problem in undirected and directed trees, respectively. In other
works, Krishnan et al. consider the placement of k “transparent” caches, Kalpakis et al.
consider a cost model involving reads, writes, and storage, and Bhattacharya et al. present
a distributed algorithm for sensor networks to reduce the total power expended. All of the
above works consider only a single data time in a tree network topology. Multiple Data
Items Hara proposes three algorithms for cache placement of multiple data items in ad hoc
networks. In the first approach, each node caches the items most frequently accessed by it.
The second approach eliminates replications among neighboring nodes introduced by the
first approach. The third approach requires creation of “stable” groups to gather
neighborhood information and determine caching placements. The first two approaches are
F T ra n sf o F T ra n sf o
PD rm PD rm
Y Y
Y
Y
er
er
ABB
ABB
y
y
bu
bu
2.0
2.0
to
to
re
re
6
he
he
k
k
lic
lic
C
C
w om w om
w
w
w. w.
A B B Y Y.c A B B Y Y.c
largely localized and, hence, would fare very badly when the percentage of client nodes in
the network is low or when the access frequencies are uniform. For the third approach, it is
hard to find stable groups in ad hoc networks because of frequent failures and movements.
All the above approaches assume the knowledge of access frequencies. In extensions of the
above work, in, Hara generalizes the above approaches for push-based systems and
updates, respectively. In other related works, Xu et al. discuss placement of “transparent”
caches in tree networks. Our work on cache placement problem is most closely related to
the works by Yin and Cao and Baev and Rajaraman. Yin and Cao design and evaluate
three simple distributed caching techniques, namely, Cache Data, which caches the
passing-by data item, Cache Path, which caches the path to the nearest cache of the
passing-by data item, and Hybrid Cache, which caches the data item if its size is small
enough or, else, caches the path to the data. They use LRU policy for cache replacement.
To the best of our knowledge, the work by Yin and Cao is the only one that presents a
distributed cache placement algorithm in a multihop ad hoc network with a memory
constraint at each node. Thus, we use the algorithms in as a comparison point for our
study. Baev and Rajaraman design an approximation algorithm for the cache placement
problem with uniform size data items. For the nonuniform-size data items, they show that
there is no polynomial-time approximation unless P ¼ NP. They circumvent the
onapproximability by increasing the given node memory capacities by the size of the
largest data item and generalize their approximation algorithm. However, their approach
(as noted by themselves) is not amenable to an efficient distributed implementation.
Y
er
er
ABB
ABB
y
y
bu
bu
2.0
2.0
to
to
re
re
7
he
he
k
k
lic
lic
C
C
w om w om
w
w
w. w.
A B B Y Y.c A B B Y Y.c
2. Details on the maintenance of the nearest and second-nearest cache table entries
3. Data expiry and cache update models and more extensive simulations.
We have considered the memory capacity constraint of the network nodes and
developed efficient algorithms to determine near-optimal cache placements to maximize
reduction in overall access cost. Reduction in access cost leads to communication cost
savings and, hence, better bandwidth usage and energy savings. Our later simulation
experience with ns2 also shows that better bandwidth usage also in turn leads to less
message losses and, thus, better query success ratio. The novel contribution in our work is
the development of a 4-approximation centralized algorithm, which is naturally amenable
to a localized distributed implementation. The distributed implementation uses only local
F T ra n sf o F T ra n sf o
PD rm PD rm
Y Y
Y
Y
er
er
ABB
ABB
y
y
bu
bu
2.0
2.0
to
to
re
re
8
he
he
k
k
lic
lic
C
C
w om w om
w
w
w. w.
A B B Y Y.c A B B Y Y.c
knowledge of traffic. However, our simulations over a wide range of network and
application parameters show that the performance of the two algorithms is quite close. We
note that ours is the first work that presents a distributed implementation based on an
approximation algorithm for the problem of cache placement of multiple data items under
memory constraint. We further compare our distributed algorithm with a competitive
algorithm (Hybrid Cache) presented in the literature that has a similar goal. This
comparison uses the ns2 simulator with a complete wireless networking protocol stack
including dynamic routing. We consider a broad range of application parameters and both
stationary and mobile networks. These evaluations show that our algorithm significantly
outperforms Hybrid Cache, particularly in more challenging scenarios, such as higher
query frequency and smaller memory.
Algorithm
Y
er
er
ABB
ABB
y
y
bu
bu
2.0
2.0
to
to
re
re
9
he
he
k
k
lic
lic
C
C
w om w om
w
w
w. w.
A B B Y Y.c A B B Y Y.c
Advantages
The distributed implementation uses only local knowledge of traffic. However, our
simulations over a wide range of network and application parameters show that the
performance of the two algorithms is quite close. This is the first work that presents a
distributed implementation based on an approximation algorithm for the problem of cache
placement of multiple data items under memory constraint.
Applications
This work can be designed, implemented and evaluated in a wireless multi-hop ad hoc
instant messenger with 7 Pocket PCs fully implementing the basic features of the DSR
protocol along with a few design alternatives. It paves the way for more future work
incorporating possibly more nodes and more optimized features of the DSR Protocol. For
example, an optimized cache structure can be considered and its effect may be tested with
more nodes in the system.
F T ra n sf o F T ra n sf o
PD rm PD rm
Y Y
Y
Y
er
er
ABB
ABB
y
y
bu
bu
2.0
2.0
to
to
re
re
10
he
he
k
k
lic
lic
C
C
w om w om
w
w
w. w.
A B B Y Y.c A B B Y Y.c
SYSTEM ANALYSIS
F T ra n sf o F T ra n sf o
PD rm PD rm
Y Y
Y
Y
er
er
ABB
ABB
y
y
bu
bu
2.0
2.0
to
to
re
re
11
he
he
k
k
lic
lic
C
C
w om w om
w
w
w. w.
A B B Y Y.c A B B Y Y.c
3. SYSTEM ANALYSIS
3.1 REQUIREMENTS ANALYSIS DOCUMENT
Both the developer and the customer take an active role in requirement
analysis and specification. The customer attempts to reformulate a sometimes-
nebulous concept of software function and performance into concrete detail. The
developer acts as interrogator, consultant and problem solver. The communication
content is very high. Changes for misinterpretation of misinformation abound.
Ambiguity is probable.
F T ra n sf o F T ra n sf o
PD rm PD rm
Y Y
Y
Y
er
er
ABB
ABB
y
y
bu
bu
2.0
2.0
to
to
re
re
12
he
he
k
k
lic
lic
C
C
w om w om
w
w
w. w.
A B B Y Y.c A B B Y Y.c
Requirements analysis provides the software designer with models that can
be translated into data, architectural, interface and procedural design. Finally, the
requirement specification provides the developer and customer with the means to
access quality once software builds.
· Problem recognition
· Modeling
· Review
Once the tasks in the above areas have been accomplished, the specification
document would be developed which now forms the basis for the remaining
software engineering tasks. Keeping this in view the specification document of the
current system has been generated.
REQUIREMENTS-DETERMINATION
Y
er
er
ABB
ABB
y
y
bu
bu
2.0
2.0
to
to
re
re
13
he
he
k
k
lic
lic
C
C
w om w om
w
w
w. w.
A B B Y Y.c A B B Y Y.c
SOFTWARE REQUIREMENTS:
HARDWARE REQUIREMENTS:
· 512 MB RAM
· 40 GB Hard Disk
In the existing system efficiency is very low. Difficult to measure the size
of the memory. Accessing the latency time is very high and Bandwidth too. The
System the memory capacity constraint of the network nodes and developed
efficient algorithms to determine near-optimal cache placements to maximize
reduction in overall access cost. High in access cost leads to communication cost
savings and, hence, better bandwidth usage and energy savings. Our later
simulation experience with ns2 also shows that better bandwidth usage also in turn
leads to less message losses and, thus, better query success ratio.
F T ra n sf o F T ra n sf o
PD rm PD rm
Y Y
Y
Y
er
er
ABB
ABB
y
y
bu
bu
2.0
2.0
to
to
re
re
14
he
he
k
k
lic
lic
C
C
w om w om
w
w
w. w.
A B B Y Y.c A B B Y Y.c
Y
er
er
ABB
ABB
y
y
bu
bu
2.0
2.0
to
to
re
re
15
he
he
k
k
lic
lic
C
C
w om w om
w
w
w. w.
A B B Y Y.c A B B Y Y.c
SYSTEM DESIGN
F T ra n sf o F T ra n sf o
PD rm PD rm
Y Y
Y
Y
er
er
ABB
ABB
y
y
bu
bu
2.0
2.0
to
to
re
re
16
he
he
k
k
lic
lic
C
C
w om w om
w
w
w. w.
A B B Y Y.c A B B Y Y.c
Grady Booch, James Rumbaugh and Ivar Jacobson have collaborated to combine
the best features of their individual object oriented analysis and design methods into a
unified method the unified modeling language, the version 1.0 for the Unified Modeling
was released in January 1997 the main parts of UML are based on the Booch, OMT and
OOSE methods.
The basic building blocks in UML are things and relationships; these are combined in
different ways following different rules to create different types of diagrams. In UML
there are nine types of diagrams, below is a list and brief description of them. The more
in depth descriptions in the document, will focus on the first five diagrams in the list,
which can be seen as the most general, sometimes also referred to as the UML core
diagrams.
1. USECASE DIAGRAMS: shows a set of use cases, and how actors can use them.
2. CLASS DIAGRAMS: describes the structure of the system, divided in classes with
different connections and relationships.
5. ACTIVITY DIAGRAMS: shows the flow through a program from an defined start
point to an end point.
F T ra n sf o F T ra n sf o
PD rm PD rm
Y Y
Y
Y
er
er
ABB
ABB
y
y
bu
bu
2.0
2.0
to
to
re
re
17
he
he
k
k
lic
lic
C
C
w om w om
w
w
w. w.
A B B Y Y.c A B B Y Y.c
Use case diagrams identify functionality provided by the system, the users who interact
with the system (actors), and the association between the users and the functionality. Use Cases
used in the analysis phase of software development to articulate the high-level requirement of the
system.
ACTIVITY DIAGRAMS
Y
er
er
ABB
ABB
y
y
bu
bu
2.0
2.0
to
to
re
re
18
he
he
k
k
lic
lic
C
C
w om w om
w
w
w. w.
A B B Y Y.c A B B Y Y.c
Activity states: Activity states mark an object. The Notations for these states are
rounded Rectangles. The same notation as found in state chart diagrams.
Initial state: The initial state marks the entry point and the initial activity state. The
notation for the initial state is the same as in the state chart diagrams, a solid circle. There
can only be one initial state on a diagram.
Final state: Final states mark the end of the modeled workflow. There can be multiple
Final states on a diagram, and these states are modeled using a solid circle surrounded by
another circle.
SEQUENCE DIAGRAMS:
UML sequence diagrams are used to model the flow of control between objects. It cans
him hard to understand the overall flow in a complex system without modeling it.
Sequence diagrams model the interactions through messages between objects; it is
common to focus the model on scenarios specified by uses-cases. It is also often useful
input to the detailed class diagram to try to model the specified use cases with sequence
diagrams, necessary forgotten operations and relations are usually found.
Sequence diagrams document the interactions between classes to achieve a result, such as
a use case. Because UML is designed for object programming, this communications
between classes are known as messages. The sequence diagrams lists objects
horizontally, and time vertically, and models these messages overtime.
F T ra n sf o F T ra n sf o
PD rm PD rm
Y Y
Y
Y
er
er
ABB
ABB
y
y
bu
bu
2.0
2.0
to
to
re
re
19
he
he
k
k
lic
lic
C
C
w om w om
w
w
w. w.
A B B Y Y.c A B B Y Y.c
In a sequence diagram, classes and actors are listed as columns, with vertical lifelines
indicating the life time of the object overtime.
Object: Objects are instances of classes, and are arranged horizontally. The pictorial
representation for an object is a class (a rectangle) with the name prefixed by object
name(optional) and a semicolon.
Actor: Actor can also communicate with objects so can be listed as column. An actor is
modeled using the ubiquitous symbol, the stick figure.
Life Line: The lifetime identifies the existence of the object overtime. The notation for
the lifeline is a vertical dotted line extending from an object.
Activation: Activations, modeled as rectangular boxes on the lifetime, indicate when the
object is performing and action.
CLASS DIAGRAM:
Class diagram identify the class structure of a system, including the properties and methods of
each class. Also depicted are the various relationships that can exist between classes, such as an
inheritance relationship. The class diagram is one of the most widely used diagrams from the
UML specification.
OBJECT DIAGRAM:
Object diagram model instances of classes. This type of diagram is used to describe the
system at a particular point in time. Using this technique, we can validate the class diagram and
its multiplicity rules with real-world data, and record test scenarios. From a notation standpoint,
object diagrams borrow elements from class diagrams.
F T ra n sf o F T ra n sf o
PD rm PD rm
Y Y
Y
Y
er
er
ABB
ABB
y
y
bu
bu
2.0
2.0
to
to
re
re
20
he
he
k
k
lic
lic
C
C
w om w om
w
w
w. w.
A B B Y Y.c A B B Y Y.c
COMPONENT DIAGRAM:
Component diagrams fall under the category of an implementation diagram, a king of diagram
that models the implementation and deployment of the system. A component diagram in
particular, is used to describe the dependencies between various software components such as the
dependency between executable files and source files. This information is similar to that within
make files, which describes source code dependencies and can be used to properly compile an
application.
DEPLOYMENT DIAGRAM:
Deployment diagrams are another model in the implementation diagram category. The
deployment diagram models the hardware used in implementing a system and the association
between those hardware components. Components can also be shown on a deployment diagram
to show the location of their deployment. Deployment diagrams can also be used early on in the
design phase to document the physical architecture of a system.
USECASE DIAGRAM:
join Receive
Send Signals
Resolving address
Host Network
GetAddress Organizing
Y
er
er
ABB
ABB
y
y
bu
bu
2.0
2.0
to
to
re
re
21
he
he
k
k
lic
lic
C
C
w om w om
w
w
w. w.
A B B Y Y.c A B B Y Y.c
CLASS DIAGRAM:
LOCAL SEARCH
SENDER
destinationNode
Sender ID : int ROUTE DISCOVERY
receverID : int sender : int search()
message : string destination : int
date : string
time : string routediscovery()
NEIGHBOUR SEARCH
requestForward() destinationNode
search()
depends on
depends on
CACHE UPDATION
RECEIVER sender : int
senderID : int updatingRoute : string
message : string MESSAGE SENDING
date : string message updation()
time : string destination
length : int route
messageTransform()
F T ra n sf o F T ra n sf o
PD rm PD rm
Y Y
Y
Y
er
er
ABB
ABB
y
y
bu
bu
2.0
2.0
to
to
re
re
22
he
he
k
k
lic
lic
C
C
w om w om
w
w
w. w.
A B B Y Y.c A B B Y Y.c
SEQUENCE DIAGRAM
Y
er
er
ABB
ABB
y
y
bu
bu
2.0
2.0
to
to
re
re
23
he
he
k
k
lic
lic
C
C
w om w om
w
w
w. w.
A B B Y Y.c A B B Y Y.c
SYSTEM
IMPLEMENTATION
F T ra n sf o F T ra n sf o
PD rm PD rm
Y Y
Y
Y
er
er
ABB
ABB
y
y
bu
bu
2.0
2.0
to
to
re
re
24
he
he
k
k
lic
lic
C
C
w om w om
w
w
w. w.
A B B Y Y.c A B B Y Y.c
5.SYSTEM IMPLEMENTATION
Implementation is the stage of the project when the theoretical design is turned out into
a working system. Thus it can be considered to be the most critical stage in achieving a
successful new system and in giving the user, confidence that the new system will work
and be effective.
SOFTWARE TECHNOLOGIES
JAVA AWT
In this section, we will learn about the java .awt.*; package available with JDK.
AWT stands for Abstract Windowing Toolkit. It contains all classes to write the program
that interface between the user and different windowing toolkits. We can use the AWT
package to develop user interface objects like buttons, checkboxes, radio buttons and
menus etc. This package provides following interfaces and classes as follows:
• AWT classes form 3 categories:
Ø Graphics
• colors, fonts, images, polygons, …
• draws stuff, defines events
Ø Components
• GUI components: buttons, menus, frames (window), panel (w/o window), dialog
(window)
F T ra n sf o F T ra n sf o
PD rm PD rm
Y Y
Y
Y
er
er
ABB
ABB
y
y
bu
bu
2.0
2.0
to
to
re
re
25
he
he
k
k
lic
lic
C
C
w om w om
w
w
w. w.
A B B Y Y.c A B B Y Y.c
JAVA JFC
• Java Foundation Classes (or JFC) is a comprehensive set of graphical user interface
classes
• JFC is comprised of:
§ AWT
§ Swing – More GUI widgets based on AWT
§ Java 2D – 2D graphical routines
§ Drag and Drop
§ Accessibility APIs
SWINGS
Swing is built on top of AWT and is entirely written in Java, using AWT’s
lightweight component support. In particular, unlike AWT, the architecture of Swing
components makes it easy to customize both their appearance and behavior. Components
from AWT and Swing can be mixed, allowing us to add Swing support to existing AWT-
based programs. For example, swing components such as JSlider, JButton and JCheckbox
could be used in the same program with standard AWT labels, textfields and scrollbars.
We can subclass the existing Swing UI, model, or change listener classes without having to
reinvent the entire implementation. Swing also has the ability to replace these objects on-
the-fly.
Y
er
er
ABB
ABB
y
y
bu
bu
2.0
2.0
to
to
re
re
26
he
he
k
k
lic
lic
C
C
w om w om
w
w
w. w.
A B B Y Y.c A B B Y Y.c
The class JComponent, descended directly from Container, is the root class
for most of Swing’s user interface components.
Swing contains components that are used to build a GUI. To learn and understand these
swing programs, AWT Programming knowledge is not required.
· JPanel is Swing’s version of the AWT class Panel and uses the same
default layout, FlowLayout. JPanel is descended directly from JComponent.
· JFrame is Swing’s version of Frame and is descended directly from that
class. The components added to the frame are referred to as its contents; these are
managed by the contentPane. To add a component to a JFrame, we must use its
contentPane instead.
· JInternalFrame is confined to a visible area of a container it is placed in. It
can be iconified , maximized and layered.
· JWindow is Swing’s version of Window and is descended directly from
that class. Like Window, it uses BorderLayout by default.
F T ra n sf o F T ra n sf o
PD rm PD rm
Y Y
Y
Y
er
er
ABB
ABB
y
y
bu
bu
2.0
2.0
to
to
re
re
27
he
he
k
k
lic
lic
C
C
w om w om
w
w
w. w.
A B B Y Y.c A B B Y Y.c
Y
er
er
ABB
ABB
y
y
bu
bu
2.0
2.0
to
to
re
re
28
he
he
k
k
lic
lic
C
C
w om w om
w
w
w. w.
A B B Y Y.c A B B Y Y.c
scrolling directly, instead, the list must be associated with a scrollpane. The view
port used by the scroll pane can also have a user-defined border. JList actions are
handled using ListSelectionListener.
· JTabbedPane contains a tab that can have a tool tip and a mnemonic, and it
can display both text and an image.
· JToolbar contains a number of components whose type is usually some
kind of button which can also include separators to group related components
within the toolbar.
· FlowLayout when used arranges swing components from left to right until
there’s no more space available. Then it begins a new row below it and moves from
left to right again. Each component in a FlowLayout gets as much space as it needs
and no more.
· BorderLayout places swing components in the North, South, East, West
and center of a container. We can add horizontal and vertical gaps between the
areas.
· GridLayout is a layout manager that lays out a container’s components in a
rectangular grid. The container is divided into equal-sized rectangles, and one
component is placed in each rectangle.
· GridBagLayout is a layout manager that lays out a container’s components
in a grid of cells with each component occupying one or more cells, called its
display area. The display area aligns components vertically and horizontally,
without requiring that the components be of the same size.
· JMenubar can contain several JMenu’s. Each of the JMenu’s can contain a
series of JMenuItem ’s that we can select. Swing provides support for pull-down
and popup menus.
· Scrollable JPopupMenu is a scrollable popup menu that can be used
whenever we have so many items in a popup menu that exceeds the screen visible
height.
F T ra n sf o F T ra n sf o
PD rm PD rm
Y Y
Y
Y
er
er
ABB
ABB
y
y
bu
bu
2.0
2.0
to
to
re
re
29
he
he
k
k
lic
lic
C
C
w om w om
w
w
w. w.
A B B Y Y.c A B B Y Y.c
Y
er
er
ABB
ABB
y
y
bu
bu
2.0
2.0
to
to
re
re
30
he
he
k
k
lic
lic
C
C
w om w om
w
w
w. w.
A B B Y Y.c A B B Y Y.c
JDBC
The JDBC (Java Database Connectivity) API defines interfaces and classes
for writing database applications in Java by making database connections. Using JDBC
you can send SQL, PL/SQL statements to almost any relational database. JDBC is a Java
API for executing SQL statements and supports basic SQL functionality. It provides
RDBMS access by allowing us to embed SQL inside Java code. Because Java can run on a
thin client, applets embedded in Web pages can contain downloadable JDBC code to
enable remote database access. We can create a table, insert values into it, query the table,
retrieve results, and update the table with the help of a JDBC Program.
Although JDBC was designed specifically to provide a Java interface to
relational databases, we may find that you need to write Java code to access non-relational
databases as well.
JDBC ARCHITECTURE
Java application calls the JDBC library. JDBC loads a driver which talks to the
database. We can change database engines without changing database code.
F T ra n sf o F T ra n sf o
PD rm PD rm
Y Y
Y
Y
er
er
ABB
ABB
y
y
bu
bu
2.0
2.0
to
to
re
re
31
he
he
k
k
lic
lic
C
C
w om w om
w
w
w. w.
A B B Y Y.c A B B Y Y.c
Y
er
er
ABB
ABB
y
y
bu
bu
2.0
2.0
to
to
re
re
32
he
he
k
k
lic
lic
C
C
w om w om
w
w
w. w.
A B B Y Y.c A B B Y Y.c
JDBC URL Example:: jdbc: <subprotocol>: <subname>•Each driver has its own
subprotocol.
• Each subprotocol has its own syntax for the source. We’re using the jdbc odbc
subprotocol, so the DriverManager knows to use the
sun.jdbc.odbc.JdbcOdbcDriver.
try{
Connection
dbConnection=DriverManager.getConnection(url,”loginName”,”Password”)
}
catch( SQLException x ){
System.out.println( “Couldn’t get connection!” );
}
Y
er
er
ABB
ABB
y
y
bu
bu
2.0
2.0
to
to
re
re
33
he
he
k
k
lic
lic
C
C
w om w om
w
w
w. w.
A B B Y Y.c A B B Y Y.c
SQL
Oracle strives to comply with industry-accepted standards and participates
actively in SQL standards committees. Industry-accepted committees are the American
National Standards Institute (ANSI) and the International Organization for Standardization
(ISO), which is affiliated with the International Electrotechnical Commission (IEC). Both
ANSI and the ISO/IEC have accepted SQL as the standard language for relational
databases. When a new SQL standard is simultaneously published by these organizations,
the names of the standards conform to conventions used by the organization, but the
standards are technically identical.
Y
er
er
ABB
ABB
y
y
bu
bu
2.0
2.0
to
to
re
re
34
he
he
k
k
lic
lic
C
C
w om w om
w
w
w. w.
A B B Y Y.c A B B Y Y.c
relational database such as Oracle Database, and all SQL statements are instructions to the
database. In this SQL differs from general-purpose programming languages like C and
BASIC. Among the features of SQL are the following:
It processes sets of data as groups rather than as individual units.
It provides automatic navigation to the data.
It uses statements that are complex and powerful individually, and that therefore
stand alone. Flow-control statements were not part of SQL originally, but they are
found in the recently accepted optional part of SQL, ISO/IEC 9075-5: 1996. Flow-
control statements are commonly known as "persistent stored modules" (PSM), and
the PL/SQL extension to Oracle SQL is similar to PSM.
SQL lets you work with data at the logical level. You need to be concerned
with the implementation details only when you want to manipulate the data. For example,
to retrieve a set of rows from a table, you define a condition used to filter the rows. All
rows satisfying the condition are retrieved in a single step and can be passed as a unit to
the user, to another SQL statement, or to an application. You need not deal with the rows
one by one, nor do you have to worry about how they are physically stored or retrieved.
All SQL statements use the optimizer, a part of Oracle Database that determines the most
efficient means of accessing the specified data. Oracle also provides techniques that you
can use to make the optimizer perform its job better.
SQL provides statements for a variety of tasks, including:
Querying data
Inserting, updating, and deleting rows in a table
Creating, replacing, altering, and dropping objects
Controlling access to the database and its objects
Guaranteeing database consistency and integrity
SQL unifies all of the preceding tasks in one consistent language.
All major relational database management systems support SQL, so you can
transfer all skills you have gained with SQL from one database to another. In addition, all
programs written in SQL are portable. They can often be moved from one database to
another with very little modification.
F T ra n sf o F T ra n sf o
PD rm PD rm
Y Y
Y
Y
er
er
ABB
ABB
y
y
bu
bu
2.0
2.0
to
to
re
re
35
he
he
k
k
lic
lic
C
C
w om w om
w
w
w. w.
A B B Y Y.c A B B Y Y.c
What is Oracle?
Oracle is the name of the database management system that comes from Oracle
Corporation.
Oracle9i is the latest product released by Oracle Corporation. Unlike Oracle8i,which is
only a database management system, Oracle9i is a collection of following software
Oracle9i Application Server – Oracle9iAS
Oracle9i Database Server – Oracle9iDB
Oracle9i Developer Suite – Oracle9iDS
In simple words Oracle9i is a platform and not a simple database management system.
Oracle9iDB is the database management system that is used to store and access data.
Oracle is by far the most widely used relational database management system (RDBMS).
Oracle Corporation is second largest software company next to Microsoft.
Oracle Corporation is also into Enterprise Resource Planning (ERP). It has Oracle
Applications that includes Oracle Financials etc.
Y
er
er
ABB
ABB
y
y
bu
bu
2.0
2.0
to
to
re
re
36
he
he
k
k
lic
lic
C
C
w om w om
w
w
w. w.
A B B Y Y.c A B B Y Y.c
Oracle Instance
Oracle instance is a collection of memory structures and processed that are used to
manage oracle database. Each oracle database is to be accessed by one or more Oracle
instances. If two or more instances are accessing the same database, it is called as parallel
server architecture.
In order to start using an oracle database, we must first start Oracle instance. Oracle
instance will them open the database and make it available to users.
It is beyond the scope of this book to discuss what Oracle instance actually
contains. Please read “Oracle Concepts” manual for complete information about oracle
instance.
In nutshell every oracle installation contains at least one Oracle Instance
and one oracle database.
Hard disk
Primary Memory (RAM)
Oracle Instance
Oracle Database
Figure 2: Oracle Instance and Oracle Database.
What Is Personal Oracle?
Personal Oracle is one of the flavors of Oracle. This is not a product that is used by
production system (systems where real data is stored). This is more like a learning tool. It
runs on desktop PCs. In personal oracle, oracle instance, oracle database and client
application all run on the same machine (see figure 3).
Whereas in Oracle database server, only oracle instance and database reside on the
server and client applications run on clients.
Oracle Instance
Oracle Database
Client
It is also possible to develop an applications using Personal Oracle on you
desktop/laptop and deploy them in a client/server environment.
F T ra n sf o F T ra n sf o
PD rm PD rm
Y Y
Y
Y
er
er
ABB
ABB
y
y
bu
bu
2.0
2.0
to
to
re
re
37
he
he
k
k
lic
lic
C
C
w om w om
w
w
w. w.
A B B Y Y.c A B B Y Y.c
Starting up Database
Before we access oracle database, we must start oracle database. Starting up oracle
database means starting oracle instance and associating oracle instance with an oracle
database so that oracle instance can access the database.
The process is very length and complicated. Several steps are involved in it.But
fortunately we do not have to know all that happens when a database starts. We just need
to select an option or two to startup database.
Generally you do not have to startup database in case of Oracle Server running on
Windows NT/Windows 2000 as oracle server automatically starts in this case. However, if
you ever have to start oracle database on Windows
NT/Windows 2000, follow the steps given below:
1. Start services program using Administrative Tools -> Service in Windows/2000
or Control Panel -> Service on Windows NT.
2. If service OracleServiceOracle8i has not yet started, click on it with right button
and select start option from popup menu.
The exact name of the service depends on the name you have given to oracle instance at
the time of installing it.
Starting SQL*PLUS
Sql*plus is a tool that comes along with Oracle. It is used to issue SQL and
SQL*PLUS commands. It provides command line interface through which we can enter
SQL and SQL*PLUS command.
To start SQL*PLUS, take the steps given below:
1. Select start->programs->Oracle - Oracle8i.
Oracle8i is the name of the instance. It may be different on your system.
2. Then select Application Development -> SQL Plus.
3. When Log On dialog box is displayed, enter username, password and Host
string. Use tab key to move from one field to another. For more information about
each of these fields, see next section.
4. Click on OK.
5. If the information supplied is valid then you enter into Oracle andSQL*PLUS
will display SQL> prompt.
Username, Password and Host String
F T ra n sf o F T ra n sf o
PD rm PD rm
Y Y
Y
Y
er
er
ABB
ABB
y
y
bu
bu
2.0
2.0
to
to
re
re
38
he
he
k
k
lic
lic
C
C
w om w om
w
w
w. w.
A B B Y Y.c A B B Y Y.c
Y
er
er
ABB
ABB
y
y
bu
bu
2.0
2.0
to
to
re
re
39
he
he
k
k
lic
lic
C
C
w om w om
w
w
w. w.
A B B Y Y.c A B B Y Y.c
CODING
F T ra n sf o F T ra n sf o
PD rm PD rm
Y Y
Y
Y
er
er
ABB
ABB
y
y
bu
bu
2.0
2.0
to
to
re
re
40
he
he
k
k
lic
lic
C
C
w om w om
w
w
w. w.
A B B Y Y.c A B B Y Y.c
6. CODING:
The goal of the coding or programming phase is to translate the design of the
system produced during the design phase into code in a given programming language,
which can be executed by a computer and that performs the computation specified by the
design.
The coding phase affects both testing and maintenance. The goal of coding is not
to reduce the implementation cost but the goal should be to reduce the cost of later phases.
In other words the goal is not to simplify the job of programmer. Rather the goal should be
to simplify the job of the tester and maintainer.
Coding Approach
There are two major approaches for coding any software system. They are top-
Down approach and Bottom-up approach.
Bottom-up approach can be best suitable for developing the object oriented
systems. During system design phase to reduce the complexity, we decompose the system
into an appropriate number of subsystems, for which objects can be modeled
independently. These objects exhibit the way the subsystems perform their operations.
Once objects have been modeled they are implemented by means of coding. Even
though related to the same system as the objects are independent of each other the Bottom
up approach is more suitable for coding these objects.
Y
er
er
ABB
ABB
y
y
bu
bu
2.0
2.0
to
to
re
re
41
he
he
k
k
lic
lic
C
C
w om w om
w
w
w. w.
A B B Y Y.c A B B Y Y.c
Simulation.java
package action;
import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JSplitPane;
import javax.swing.event.MenuEvent;
import javax.swing.event.MenuListener;
public Simulation()
bar=new JMenuBar();
F T ra n sf o F T ra n sf o
PD rm PD rm
Y Y
Y
Y
er
er
ABB
ABB
y
y
bu
bu
2.0
2.0
to
to
re
re
42
he
he
k
k
lic
lic
C
C
w om w om
w
w
w. w.
A B B Y Y.c A B B Y Y.c
file=new JMenu("File");
file.setMnemonic('f');
file.addMenuListener(this);
send=new JMenuItem("Send");
send.addActionListener(this);
send.setActionCommand("send");
send.setMnemonic('s');
file.add(send);
exit=new JMenuItem("Exit");
exit.addActionListener(this);
exit.setActionCommand("Exit");
exit.setMnemonic('x');
file.add(exit);
bar.add(file);
setJMenuBar(bar);
pp=new PaintPanel();
setLayout(new BorderLayout());
spt.setDividerLocation(350);
spt.setLeftComponent(pp);
F T ra n sf o F T ra n sf o
PD rm PD rm
Y Y
Y
Y
er
er
ABB
ABB
y
y
bu
bu
2.0
2.0
to
to
re
re
43
he
he
k
k
lic
lic
C
C
w om w om
w
w
w. w.
A B B Y Y.c A B B Y Y.c
setTitle("MANET Simulator");
add(spt);
setVisible(true);
setDefaultCloseOperation(DISPOSE_ON_CLOSE);
setExtendedState (MAXIMIZED_BOTH);
new Simulation();
{
F T ra n sf o F T ra n sf o
PD rm PD rm
Y Y
Y
Y
er
er
ABB
ABB
y
y
bu
bu
2.0
2.0
to
to
re
re
44
he
he
k
k
lic
lic
C
C
w om w om
w
w
w. w.
A B B Y Y.c A B B Y Y.c
if(e.getSource().equals(exit))
System.exit(0);
if(e.getSource().equals(send))
new SenderForm();
PaintPanel.java
package action;
import java.awt.Graphics2D;
import java.awt.Point;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.RenderingHints;
import java.awt.event.MouseEvent;
import java.awt.event.MouseAdapter;
import java.util.Iterator;
import java.util.Vector;
F T ra n sf o F T ra n sf o
PD rm PD rm
Y Y
Y
Y
er
er
ABB
ABB
y
y
bu
bu
2.0
2.0
to
to
re
re
45
he
he
k
k
lic
lic
C
C
w om w om
w
w
w. w.
A B B Y Y.c A B B Y Y.c
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import java.util.Date;
String name;
int i=0;
int hostport=5000;
public PaintPanel()
addMouseListener(
new MouseAdapter()
if (i<50)
F T ra n sf o F T ra n sf o
PD rm PD rm
Y Y
Y
Y
er
er
ABB
ABB
y
y
bu
bu
2.0
2.0
to
to
re
re
46
he
he
k
k
lic
lic
C
C
w om w om
w
w
w. w.
A B B Y Y.c A B B Y Y.c
name="Host";
i++;
name=name+String.valueOf(i);
repaint();
else
);
{
F T ra n sf o F T ra n sf o
PD rm PD rm
Y Y
Y
Y
er
er
ABB
ABB
y
y
bu
bu
2.0
2.0
to
to
re
re
47
he
he
k
k
lic
lic
C
C
w om w om
w
w
w. w.
A B B Y Y.c A B B Y Y.c
Graphics2D gg = (Graphics2D) g;
gg.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
g.setColor(Color.RED);
Vector v = nt.getVector();
while (treeTraverse.hasNext())
gg.setColor(Color.RED);
gg.setColor(Color.BLACK);
}
F T ra n sf o F T ra n sf o
PD rm PD rm
Y Y
Y
Y
er
er
ABB
ABB
y
y
bu
bu
2.0
2.0
to
to
re
re
48
he
he
k
k
lic
lic
C
C
w om w om
w
w
w. w.
A B B Y Y.c A B B Y Y.c
SenderForm.java
package action;
import java.awt.GridBagLayout;
import java.awt.GridBagConstraints;
import javax.swing.JOptionPane;
import java.io.File;
import java.util.Iterator;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JButton;
import javax.swing.JFileChooser;
import javax.swing.filechooser.FileFilter;
import javax.swing.JTextField;
import javax.swing.JComboBox;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.Component;
Y
er
er
ABB
ABB
y
y
bu
bu
2.0
2.0
to
to
re
re
49
he
he
k
k
lic
lic
C
C
w om w om
w
w
w. w.
A B B Y Y.c A B B Y Y.c
int host_count;
int i=-1;
public SenderForm()
containerOBJ=PaintPanel.nt;
layout=new GridBagLayout();
setLayout(layout);
cons=new GridBagConstraints();
host_count=containerOBJ.size();
while (treeTraverse.hasNext())
i++;
F T ra n sf o F T ra n sf o
PD rm PD rm
Y Y
Y
Y
er
er
ABB
ABB
y
y
bu
bu
2.0
2.0
to
to
re
re
50
he
he
k
k
lic
lic
C
C
w om w om
w
w
w. w.
A B B Y Y.c A B B Y Y.c
source_nodes[i]=host.name;
label1.setToolTipText("Source");
cons.fill=GridBagConstraints.HORIZONTAL;
addComponent(label1,0,2,5,5);
sou=new JComboBox(source_nodes);
sou.setMaximumRowCount(5);
cons.fill=GridBagConstraints.HORIZONTAL;
addComponent(sou,0,12,5,5);
label2.setToolTipText("Destination");
cons.fill=GridBagConstraints.HORIZONTAL;
addComponent(label2,15,4,5,5);
des=new JComboBox(source_nodes);
des.setMaximumRowCount(5);
cons.fill=GridBagConstraints.HORIZONTAL;
addComponent(des,15,12,5,5);
txt1=new JTextField();
txt1.setToolTipText("TextBox");
cons.fill=GridBagConstraints.HORIZONTAL;
F T ra n sf o F T ra n sf o
PD rm PD rm
Y Y
Y
Y
er
er
ABB
ABB
y
y
bu
bu
2.0
2.0
to
to
re
re
51
he
he
k
k
lic
lic
C
C
w om w om
w
w
w. w.
A B B Y Y.c A B B Y Y.c
addComponent(txt1,20,2,5,5);
browse=new JButton("Browse");
cons.fill=GridBagConstraints.HORIZONTAL;
addComponent(browse,20,10,5,5);
browse.addActionListener(this);
submit=new JButton("Submit");
cons.fill=GridBagConstraints.HORIZONTAL;
addComponent(submit,30,2,2,2);
submit.addActionListener(this);
submit.setActionCommand("submit");
cancel=new JButton("Cancel");
cons.fill=GridBagConstraints.HORIZONTAL;
addComponent(cancel,30,10,5,5);
cancel.addActionListener(this);
cancel.setActionCommand("cancel");
setVisible(true);
setSize(400,400);
{
F T ra n sf o F T ra n sf o
PD rm PD rm
Y Y
Y
Y
er
er
ABB
ABB
y
y
bu
bu
2.0
2.0
to
to
re
re
52
he
he
k
k
lic
lic
C
C
w om w om
w
w
w. w.
A B B Y Y.c A B B Y Y.c
cons.gridx=column;
cons.gridy=row;
cons.gridwidth=width;
cons.gridheight=height;
layout.setConstraints(component, cons);
add(component);
if (ae.getSource()==browse)
chooser.setCurrentDirectory(new File("."));
chooser.setFileFilter(new FileFilter()
}
F T ra n sf o F T ra n sf o
PD rm PD rm
Y Y
Y
Y
er
er
ABB
ABB
y
y
bu
bu
2.0
2.0
to
to
re
re
53
he
he
k
k
lic
lic
C
C
w om w om
w
w
w. w.
A B B Y Y.c A B B Y Y.c
});
if (returnVal == JFileChooser.APPROVE_OPTION)
name = chooser.getSelectedFile().getPath();
txt1.setText(filename.getAbsolutePath());
if(ae.getSource().equals(cancel))
setVisible(false);
if(ae.getSource().equals(submit))
if (txt1.getText().equals(""))
}
F T ra n sf o F T ra n sf o
PD rm PD rm
Y Y
Y
Y
er
er
ABB
ABB
y
y
bu
bu
2.0
2.0
to
to
re
re
54
he
he
k
k
lic
lic
C
C
w om w om
w
w
w. w.
A B B Y Y.c A B B Y Y.c
else if (sou.getSelectedItem().equals(des.getSelectedItem()))
else if(host_count<10)
else if(host_count>50)
else
sname=(String)sou.getSelectedItem();
dname=(String)des.getSelectedItem();
try {
new TransferObject(sname,dname,txt1.getText(),bufferTransfer);
catch (Exception e) {
Y
er
er
ABB
ABB
y
y
bu
bu
2.0
2.0
to
to
re
re
55
he
he
k
k
lic
lic
C
C
w om w om
w
w
w. w.
A B B Y Y.c A B B Y Y.c
e.printStackTrace();
Host.java
package action;
/*
*/
import java.awt.Point;
import java.io.Serializable;
Y
er
er
ABB
ABB
y
y
bu
bu
2.0
2.0
to
to
re
re
56
he
he
k
k
lic
lic
C
C
w om w om
w
w
w. w.
A B B Y Y.c A B B Y Y.c
position = pos;
name = nam;
hostPort = port;
host_id=id;
new HostResponse(hostPort);
HostContainer.java
package action;
import java.io.Serializable;
import java.util.Iterator;
import java.util.Vector;
import javax.swing.JOptionPane;
/*
Y
er
er
ABB
ABB
y
y
bu
bu
2.0
2.0
to
to
re
re
57
he
he
k
k
lic
lic
C
C
w om w om
w
w
w. w.
A B B Y Y.c A B B Y Y.c
*/
public HostContainer()
hostVector.add(host);
return vector.iterator();
public Vector getVector() // to retrieve the vector which content all the hosts
Y
er
er
ABB
ABB
y
y
bu
bu
2.0
2.0
to
to
re
re
58
he
he
k
k
lic
lic
C
C
w om w om
w
w
w. w.
A B B Y Y.c A B B Y Y.c
return vector;
return hostVector.size();
HostResponse.java
package action;
import java.io.*;
import java.net.*;
import javax.swing.JOptionPane;
int port;
Thread thread;
thread=new Thread(this);
F T ra n sf o F T ra n sf o
PD rm PD rm
Y Y
Y
Y
er
er
ABB
ABB
y
y
bu
bu
2.0
2.0
to
to
re
re
59
he
he
k
k
lic
lic
C
C
w om w om
w
w
w. w.
A B B Y Y.c A B B Y Y.c
thread.start();
public HostResponse(){}
while(true)
try
ServerSocket socket;
Socket connsocket;
BufferTransfer bufferTransfer;
ObjectInputStream objectInputStream;
socket=new ServerSocket(port);// create server socket and bind with port 6789
System.out.println("Server Connected");
objectInputStream=new ObjectInputStream(connsocket.getInputStream());
{
F T ra n sf o F T ra n sf o
PD rm PD rm
Y Y
Y
Y
er
er
ABB
ABB
y
y
bu
bu
2.0
2.0
to
to
re
re
60
he
he
k
k
lic
lic
C
C
w om w om
w
w
w. w.
A B B Y Y.c A B B Y Y.c
transferObject.neighbour_node(bufferTransfer.getCurrent_host(),bufferTransfer.getDestin
ation_name(),bufferTransfer.getFilename(),bufferTransfer); //Change source and
destination and then continue
else if(bufferTransfer.getDestination_type().equals("Destination"))
writeobject.output(bufferTransfer);
bufferTransfer.getRefuse_packet_container().removeAll(bufferTransfer.getRefuse_packet
_container());
bufferTransfer.getCrossing_host_name().removeAll
(bufferTransfer.getCrossing_host_name());
bufferTransfer.getDestination_not_reachable_list().removeAll
(bufferTransfer.getDestination_not_reachable_list());
else if(bufferTransfer.getDestination_type().equals("Failure"))
writeobject.output(bufferTransfer);
}
F T ra n sf o F T ra n sf o
PD rm PD rm
Y Y
Y
Y
er
er
ABB
ABB
y
y
bu
bu
2.0
2.0
to
to
re
re
61
he
he
k
k
lic
lic
C
C
w om w om
w
w
w. w.
A B B Y Y.c A B B Y Y.c
connsocket.close();
socket.close();
catch(Exception error)
System.out.println("error in Server==>"+error);
SubHostResponse.java
package action;
import java.io.*;
import java.net.*;
Socket socket;
ObjectOutput dataout;
try
F T ra n sf o F T ra n sf o
PD rm PD rm
Y Y
Y
Y
er
er
ABB
ABB
y
y
bu
bu
2.0
2.0
to
to
re
re
62
he
he
k
k
lic
lic
C
C
w om w om
w
w
w. w.
A B B Y Y.c A B B Y Y.c
socket=new Socket("127.0.0.1",port);
// Made socket connection on the port number 6789 in the host 127.0.01
dataout=new ObjectOutputStream(socket.getOutputStream());
dataout.writeObject(bufferTransfer);
dataout.flush();
socket.close();
catch(Exception error)
System.out.println("Error in Client"+error);
}
F T ra n sf o F T ra n sf o
PD rm PD rm
Y Y
Y
Y
er
er
ABB
ABB
y
y
bu
bu
2.0
2.0
to
to
re
re
63
he
he
k
k
lic
lic
C
C
w om w om
w
w
w. w.
A B B Y Y.c A B B Y Y.c
Writeobject.java
/*
*/
package action;
import java.io.FileOutputStream;
import java.util.Date;
try
String s_line="\n--------------------------------------------------------------------";
String res_output="\nS.Name==>"+bufferTransfer.getSource_name()+"D.Name==>"
+bufferTransfer.getDestination_name();
//Assign Source and Destinatin name for write the log file
fos.write(date.getBytes());
F T ra n sf o F T ra n sf o
PD rm PD rm
Y Y
Y
Y
er
er
ABB
ABB
y
y
bu
bu
2.0
2.0
to
to
re
re
64
he
he
k
k
lic
lic
C
C
w om w om
w
w
w. w.
A B B Y Y.c A B B Y Y.c
fos.write(s_line.getBytes());
fos.write(res_output.getBytes());
fos.write(s_line.getBytes());
fos.write(bufferTransfer.getCrossing_host_name().toString().getBytes());
fos.write(s_line.getBytes());
fos.close();
catch(Exception e)
System.out.println("File Write"+e.getMessage());
TransferObject.java
package action;
import java.awt.Point;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
F T ra n sf o F T ra n sf o
PD rm PD rm
Y Y
Y
Y
er
er
ABB
ABB
y
y
bu
bu
2.0
2.0
to
to
re
re
65
he
he
k
k
lic
lic
C
C
w om w om
w
w
w. w.
A B B Y Y.c A B B Y Y.c
import java.util.Iterator;
import java.util.Vector;
import javax.swing.JOptionPane;
byte[] buffer;
FileInputStream fis;
this.bufferTransfer=bufferTransfer;
transferObject=new TransferObject();
this.sname=sname;
this.dname=dname;
this.fname=fname;
try {
F T ra n sf o F T ra n sf o
PD rm PD rm
Y Y
Y
Y
er
er
ABB
ABB
y
y
bu
bu
2.0
2.0
to
to
re
re
66
he
he
k
k
lic
lic
C
C
w om w om
w
w
w. w.
A B B Y Y.c A B B Y Y.c
buffer=new byte[fis.available()];
fis.read(buffer);
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
bufferTransfer.setBuffer(buffer);
transferObject.neighbour_node(sname,dname,fname,bufferTransfer);
public TransferObject()
{}
String sname,dname,fname,trans_node_type="";
Y
er
er
ABB
ABB
y
y
bu
bu
2.0
2.0
to
to
re
re
67
he
he
k
k
lic
lic
C
C
w om w om
w
w
w. w.
A B B Y Y.c A B B Y Y.c
String not_reach_alternate_host="None",not_reach_alternate_host_copy="None";
int not_reach_hostport = 0;
int fdt=0;
dest_reach_confirm=0;
if (host.name.equalsIgnoreCase(sname))
while (treeTraverse_dist.hasNext())
Y
er
er
ABB
ABB
y
y
bu
bu
2.0
2.0
to
to
re
re
68
he
he
k
k
lic
lic
C
C
w om w om
w
w
w. w.
A B B Y Y.c A B B Y Y.c
if((sdt>0)&&(sdt<=125)&&(!bufferTransfer.getRefuse_packet_container().contains(host.h
ost_id)) && (!bufferTransfer.getDestination_not_reachable_list().contains(host.name))&&
(!bufferTransfer.getCrossing_host_name().contains(host.name))) //Check particular
Region
current_reg_vector.add(host.name);
bufferTransfer.setRefuse_host_id(host.host_id);
//Code for Check Next iteration host are available(within next 125 Region)
while(treeTraverse_dist_next.hasNext())
next_sdt = (int)Math.sqrt(Math.pow((host.position.x-host_next.position.x), 2) +
Math.pow((host.position.y-host_next.position.y), 2)); //Find the Distance from Source and
iterate host
if((next_sdt>0)&&(next_sdt<=125)&&(!bufferTransfer.getRefuse_packet_container().cont
ains(host_next.host_id))&&(!host_next.name.equals(sname))&&(!bufferTransfer.getCross
ing_host_name().contains(host.name))) //Check particular Region
current_reg_vector_next.add(host_next.name);
}
F T ra n sf o F T ra n sf o
PD rm PD rm
Y Y
Y
Y
er
er
ABB
ABB
y
y
bu
bu
2.0
2.0
to
to
re
re
69
he
he
k
k
lic
lic
C
C
w om w om
w
w
w. w.
A B B Y Y.c A B B Y Y.c
if((region_short_node<=sdt)&&((current_reg_vector_next.size()>0)||(host.name.equals(bu
fferTransfer.getDestination_name())))&&
(!bufferTransfer.getCrossing_host_name().contains(host.name)))
region_short_node=sdt;
dest_reach_confirm++;
trans_port=host.hostPort;
current_reg_vector_next.removeAll(current_reg_vector_next);
if (current_reg_vector.contains(dname))
JOptionPane.showMessageDialog(null,"Successfully sent");
String fob="Hosts/"+dname;
f.mkdir();
Y
er
er
ABB
ABB
y
y
bu
bu
2.0
2.0
to
to
re
re
70
he
he
k
k
lic
lic
C
C
w om w om
w
w
w. w.
A B B Y Y.c A B B Y Y.c
FileOutputStream fos;
try {
fos.write(bufferTransfer.getBuffer());
//Generate output when File reach their Destination
fos.close();
catch (FileNotFoundException e) {
e.printStackTrace();
bufferTransfer.setDestination_type("Destination");
new SubHostResponse(trans_port,bufferTransfer);
else if (!region_short_node_name.equals("None"))
current_reg_vector.removeAll(current_reg_vector);
region_short_node=0;
sdt=0;
bufferTransfer.setCurrent_host(region_short_node_name);
F T ra n sf o F T ra n sf o
PD rm PD rm
Y Y
Y
Y
er
er
ABB
ABB
y
y
bu
bu
2.0
2.0
to
to
re
re
71
he
he
k
k
lic
lic
C
C
w om w om
w
w
w. w.
A B B Y Y.c A B B Y Y.c
bufferTransfer.setCross_host_name(region_short_node_name);
bufferTransfer.setDestination_type("Process");
new SubHostResponse(trans_port,bufferTransfer);
else
if (bufferTransfer.getCrossing_host_name().size()>=2)
try
if
(bufferTransfer.getCrossing_host_name().size()>=2)
bufferTransfer.setDestination_not_reach_host(bufferTransfer.getCross
ing_host_name().lastElement().toString());
trans_port=transferObject.freeup_Host(bufferTransfer.getCrossing_host_name().lastEleme
nt().toString(),bufferTransfer); //Free up surrounding host
F T ra n sf o F T ra n sf o
PD rm PD rm
Y Y
Y
Y
er
er
ABB
ABB
y
y
bu
bu
2.0
2.0
to
to
re
re
72
he
he
k
k
lic
lic
C
C
w om w om
w
w
w. w.
A B B Y Y.c A B B Y Y.c
bufferTransfer.getCrossing_host_name().remove(bufferTransfer.getCrossing_host_name().
lastElement());
bufferTransfer.setCurrent_host(bufferTransfer.getCrossing_host_name().lastElement().toS
tring()); //Set Current host name to traverse next Iteration
trans_port=transferObject.freeup_Host(bufferTransfer.getCrossing_host_name().lastEleme
nt().toString(),bufferTransfer);
bufferTransfer.getCrossing_host_name().remove(bufferTransfer.getCrossing_host_name().
lastElement()); //Remove from Taversing Host list
System.out.println("NextHost to Process(Recover)-->."+bufferTransfer.getCurrent_host());
new SubHostResponse(trans_port,bufferTransfer);
catch(Exception e)
else if (bufferTransfer.getCrossing_host_name().size()>=1)
{
F T ra n sf o F T ra n sf o
PD rm PD rm
Y Y
Y
Y
er
er
ABB
ABB
y
y
bu
bu
2.0
2.0
to
to
re
re
73
he
he
k
k
lic
lic
C
C
w om w om
w
w
w. w.
A B B Y Y.c A B B Y Y.c
bufferTransfer.setDestination_type("Failure");
else if (bufferTransfer.getCrossing_host_name().isEmpty())
bufferTransfer.setDestination_type("Failure");
else
bufferTransfer.setDestination_type("Failure");
try
while(iterator_getpoint.hasNext())
F T ra n sf o F T ra n sf o
PD rm PD rm
Y Y
Y
Y
er
er
ABB
ABB
y
y
bu
bu
2.0
2.0
to
to
re
re
74
he
he
k
k
lic
lic
C
C
w om w om
w
w
w. w.
A B B Y Y.c A B B Y Y.c
if (freeuphost_param.equals(host_next_alter_host.name))
not_reach_alternate_host_point=host_next_alter_host.position;
not_reach_hostport=host_next_alter_host.hostPort;
catch(Exception e)
try
while(treeTraverse_dist_freeup_host.hasNext())
{
F T ra n sf o F T ra n sf o
PD rm PD rm
Y Y
Y
Y
er
er
ABB
ABB
y
y
bu
bu
2.0
2.0
to
to
re
re
75
he
he
k
k
lic
lic
C
C
w om w om
w
w
w. w.
A B B Y Y.c A B B Y Y.c
fdt=(int)Math.sqrt(Math.pow((not_reach_alternate_host_point.x-ost_next_free.position.x),
2) + Math.pow((not_reach_alternate_host_point.y-host_next_free.position.y), 2));
bufferTransfer.getRefuse_packet_container().remove(host_next_free.host_id);
}
catch(Exception e)
return not_reach_hostport;
} //End function
}
F T ra n sf o F T ra n sf o
PD rm PD rm
Y Y
Y
Y
er
er
ABB
ABB
y
y
bu
bu
2.0
2.0
to
to
re
re
76
he
he
k
k
lic
lic
C
C
w om w om
w
w
w. w.
A B B Y Y.c A B B Y Y.c
BufferTransfer.java
package action;
/*
*/
import java.io.*;
import java.util.Vector;
String
source_name,destination_name,filename,destination_type,current_host,cross_host_name;
String destination_not_reach_host;
Y
er
er
ABB
ABB
y
y
bu
bu
2.0
2.0
to
to
re
re
77
he
he
k
k
lic
lic
C
C
w om w om
w
w
w. w.
A B B Y Y.c A B B Y Y.c
return crossing_host_name;
crossing_host_name.add(cross_host_name);
refuse_packet_container.add(refuse_host_id);
return refuse_packet_container;
return current_host;
}
F T ra n sf o F T ra n sf o
PD rm PD rm
Y Y
Y
Y
er
er
ABB
ABB
y
y
bu
bu
2.0
2.0
to
to
re
re
78
he
he
k
k
lic
lic
C
C
w om w om
w
w
w. w.
A B B Y Y.c A B B Y Y.c
this.current_host = current_host;
return destination_name;
this.destination_name = destination_name;
return destination_type;
this.destination_type = destination_type;
return filename;
F T ra n sf o F T ra n sf o
PD rm PD rm
Y Y
Y
Y
er
er
ABB
ABB
y
y
bu
bu
2.0
2.0
to
to
re
re
79
he
he
k
k
lic
lic
C
C
w om w om
w
w
w. w.
A B B Y Y.c A B B Y Y.c
this.filename = filename;
return source_name;
this.source_name = source_name;
return buffer;
this.buffer = buffer;
return destination_not_reachable_list;
F T ra n sf o F T ra n sf o
PD rm PD rm
Y Y
Y
Y
er
er
ABB
ABB
y
y
bu
bu
2.0
2.0
to
to
re
re
80
he
he
k
k
lic
lic
C
C
w om w om
w
w
w. w.
A B B Y Y.c A B B Y Y.c
destination_not_reachable_list.add(destination_not_reach_host);
}
F T ra n sf o F T ra n sf o
PD rm PD rm
Y Y
Y
Y
er
er
ABB
ABB
y
y
bu
bu
2.0
2.0
to
to
re
re
81
he
he
k
k
lic
lic
C
C
w om w om
w
w
w. w.
A B B Y Y.c A B B Y Y.c
SYSTEM TESTING
F T ra n sf o F T ra n sf o
PD rm PD rm
Y Y
Y
Y
er
er
ABB
ABB
y
y
bu
bu
2.0
2.0
to
to
re
re
82
he
he
k
k
lic
lic
C
C
w om w om
w
w
w. w.
A B B Y Y.c A B B Y Y.c
7. SYSTEM TESTING:
Unit testing finds the differences between the object design model and its
corresponding components. Structural testing finds differences between the system design
model and a subset of integrated subsystems. Functional testing finds differences between
the use case model and the system.
Testing Concepts
§ A component is a part of the system that can be isolated for testing. A component
can be an object, a group of objects, or one or more subsystems.
§ A fault, also called bug or defect, is a design or coding mistake that may cause
abnormal component behavior.
§ A failure is a deviation between the specification and the actual behavior. A failure
is triggered by one or more erroneous states. Not all erroneous states trigger a
failure.
F T ra n sf o F T ra n sf o
PD rm PD rm
Y Y
Y
Y
er
er
ABB
ABB
y
y
bu
bu
2.0
2.0
to
to
re
re
83
he
he
k
k
lic
lic
C
C
w om w om
w
w
w. w.
A B B Y Y.c A B B Y Y.c
§ A test case is a set of inputs and expected results that exercises a component with
the purpose of causing failures and detecting faults.
Testing Activities
Testing a large system is a complex activity and like any complex activity. It has to
be broke into smaller activities. Thus incremental testing was performed on the project i.e.,
components and subsystems of the system were tested separately before integrating them
to form the subsystem for system testing.
Unit Testing
Unit testing focuses on the building blocks of the software system that is the
objects and subsystems. There are three motivations behind focusing on
components. First unit testing reduces the complexity of overall test activities
allowing focus on smaller units of the system, second unit testing makes it easier to
pinpoint and correct faults given that few components are involved in the rest.
Third unit testing allows parallelism in the testing activities, that is each component
are involved in the test. Third unit testing allows parallelism in the testing
activities that is each component can be tested independently of one another.
Equivalence Testing: It is a black box testing technique that minimizes the number
of test cases. The possible inputs are partitioned into equivalence classes and a test
case is selected for each class. In this project, the system is divided into
equivalence classes and tested.
F T ra n sf o F T ra n sf o
PD rm PD rm
Y Y
Y
Y
er
er
ABB
ABB
y
y
bu
bu
2.0
2.0
to
to
re
re
84
he
he
k
k
lic
lic
C
C
w om w om
w
w
w. w.
A B B Y Y.c A B B Y Y.c
Boundary Testing:
Path Testing:
Integration Testing
Integration testing defects faults that have not been detected. During
unit testing by focusing on small groups on components two or more components
are integrated and tested and once tests do not reveal any new faults, additional
components are added to the group. This procedure allows testing of increasing
more complex parts on the system while keeping the location of potential faults
relatively small. I have used the following approach to implements and integrated
testing.
Top-down testing strategy unit tests the components of the top layer and
then integrated the components of the next layer down. When all components of
the new layer have been tested together, the next layer is selected. This was
repeated until all layers are combined and involved in the test. In this project, two
or more components are tested together. Here the top down approach is followed.
F T ra n sf o F T ra n sf o
PD rm PD rm
Y Y
Y
Y
er
er
ABB
ABB
y
y
bu
bu
2.0
2.0
to
to
re
re
85
he
he
k
k
lic
lic
C
C
w om w om
w
w
w. w.
A B B Y Y.c A B B Y Y.c
Validation Testing
In this project, save schedule, generate schedule tests are black box tests.
System Testing
§ System testing ensures that the complete system compiles with the functional
requirements and non-functional requirements of the system, the following are
some system testing activities.
§ Functional testing finds differences between the functional between the functional
requirements and the system. This is a black box testing technique. Test cases are
divided from the use case model.
§ Performance testing finds differences between the design and the system the design
goals are derived from the functional requirements.
§ Pilot testing the system is installed and used by a selected set of users – users
exercise the system as if it had been permanently installed.
In this project, all the components are tested together and get the required results.
F T ra n sf o F T ra n sf o
PD rm PD rm
Y Y
Y
Y
er
er
ABB
ABB
y
y
bu
bu
2.0
2.0
to
to
re
re
86
he
he
k
k
lic
lic
C
C
w om w om
w
w
w. w.
A B B Y Y.c A B B Y Y.c
TESTING
Y
er
er
ABB
ABB
y
y
bu
bu
2.0
2.0
to
to
re
re
87
he
he
k
k
lic
lic
C
C
w om w om
w
w
w. w.
A B B Y Y.c A B B Y Y.c
SAMPLE
OUTPUT SCREENS
F T ra n sf o F T ra n sf o
PD rm PD rm
Y Y
Y
Y
er
er
ABB
ABB
y
y
bu
bu
2.0
2.0
to
to
re
re
88
he
he
k
k
lic
lic
C
C
w om w om
w
w
w. w.
A B B Y Y.c A B B Y Y.c
8. OUTPUT SCREENS:
MANET Simulator:-
F T ra n sf o F T ra n sf o
PD rm PD rm
Y Y
Y
Y
er
er
ABB
ABB
y
y
bu
bu
2.0
2.0
to
to
re
re
89
he
he
k
k
lic
lic
C
C
w om w om
w
w
w. w.
A B B Y Y.c A B B Y Y.c
Browsing the data item for sending from source host to destination host
F T ra n sf o F T ra n sf o
PD rm PD rm
Y Y
Y
Y
er
er
ABB
ABB
y
y
bu
bu
2.0
2.0
to
to
re
re
90
he
he
k
k
lic
lic
C
C
w om w om
w
w
w. w.
A B B Y Y.c A B B Y Y.c
Y
er
er
ABB
ABB
y
y
bu
bu
2.0
2.0
to
to
re
re
91
he
he
k
k
lic
lic
C
C
w om w om
w
w
w. w.
A B B Y Y.c A B B Y Y.c
Y
er
er
ABB
ABB
y
y
bu
bu
2.0
2.0
to
to
re
re
92
he
he
k
k
lic
lic
C
C
w om w om
w
w
w. w.
A B B Y Y.c A B B Y Y.c
Y
er
er
ABB
ABB
y
y
bu
bu
2.0
2.0
to
to
re
re
93
he
he
k
k
lic
lic
C
C
w om w om
w
w
w. w.
A B B Y Y.c A B B Y Y.c
Y
er
er
ABB
ABB
y
y
bu
bu
2.0
2.0
to
to
re
re
94
he
he
k
k
lic
lic
C
C
w om w om
w
w
w. w.
A B B Y Y.c A B B Y Y.c
Y
er
er
ABB
ABB
y
y
bu
bu
2.0
2.0
to
to
re
re
95
he
he
k
k
lic
lic
C
C
w om w om
w
w
w. w.
A B B Y Y.c A B B Y Y.c
CONCLUSION
F T ra n sf o F T ra n sf o
PD rm PD rm
Y Y
Y
Y
er
er
ABB
ABB
y
y
bu
bu
2.0
2.0
to
to
re
re
96
he
he
k
k
lic
lic
C
C
w om w om
w
w
w. w.
A B B Y Y.c A B B Y Y.c
10. CONCLUSION:
Y
er
er
ABB
ABB
y
y
bu
bu
2.0
2.0
to
to
re
re
97
he
he
k
k
lic
lic
C
C
w om w om
w
w
w. w.
A B B Y Y.c A B B Y Y.c
BIBLIOGRAPHY
F T ra n sf o F T ra n sf o
PD rm PD rm
Y Y
Y
Y
er
er
ABB
ABB
y
y
bu
bu
2.0
2.0
to
to
re
re
98
he
he
k
k
lic
lic
C
C
w om w om
w
w
w. w.
A B B Y Y.c A B B Y Y.c
11. BIBLIOGRAPHY: