Print New Final 2

59
1 INTRODUCTION

Transcript of Print New Final 2

Page 1: Print New Final 2

8/7/2019 Print New Final 2

http://slidepdf.com/reader/full/print-new-final-2 1/59

1

INTRODUCTION

Page 2: Print New Final 2

8/7/2019 Print New Final 2

http://slidepdf.com/reader/full/print-new-final-2 2/59

2

CHAPTER 1

INTRODUCTION

PEER-TO-PEER (P2P) networks establish loosely coupled  application-

level overlays on top of the Internet to facilitate efficient sharing of vast amount

of resources. One fundamental challenge of P2P networks is to achieve efficient

resources discovery. In the literature, many P2P networks have been proposed

in an attempt to overcome this challenge. Those networks can be largely

classified into two categories, namely, structured P2P networks based on a

distributed hash table (DHT) and unstructured P2P networks based on diverse

random search  strategies (e.g., flooding)[3]. Without imposing any stringent

constraints over the network topology, unstructured P2P networks can be

constructed very efficiently and have therefore attracted far more practical use

in the Internet [1], [2] than the structured networks. Peers in unstructured

networks are often termed blind, since they are usually incapable of 

determining the possibility that their neighbor peers can satisfy any resourcequeries. An undesirable consequence of this is that the efficiency of distributed

resource discovery techniques will have to be compromised [6]. In practice,

resources shared by a peer often exhibit some statistical patterns. The

fundamental idea of this paper is that the statistical patterns over locally shared

resources of a peer can be explored to guide the distributed resource discovery

 process and therefore enhance the overall resource discovery performance in

unstructured P2P networks. Three essential research issues have been

identified and studied in this paper in order to save peers from their 

 blindness. For ease of discussion, only one important type of resources,

namely, data files, will  be considered in this paper. The first research issue

Page 3: Print New Final 2

8/7/2019 Print New Final 2

http://slidepdf.com/reader/full/print-new-final-2 3/59

3

questions the practicality of modeling users’ diverse interests. To solve this

 problem, we have introduced the user interest model (UIM) based on a general

 probabilistic modeling tool termed Condition Random Fields (CRFs) [4]. With

UIM, we are able to estimate the probability of any peer sharing a certain

resource (file) f  j upon given the fact that it shares another resource (file) f i. This

estimation further gives rise to an interest distance between any two peers. The

second research issue considers the actual exploration of users’ interests as

embodied by UIM. To address this concern, a greedy file search protocol is

 presented in this paper for fast resource discovery. Whenever a peer receives a

query for a certain file that is not available locally, it will forward the query to

one of its neighbors that have the highest probability of actually sharing that

file. The third research issue has been highlighted with the insight that the

search protocol alone is not sufficient to achieve high resource discovery

 performance. This paper proposes a routing table updating protocol to support

our search protocol through self organizing the whole P2P network into a small

world. Different from closely related research works that are also inspired by

the small-world[6] model, in order to reduce the overall communication and

 processing cost, in this paper, the updating of routing tables are driven by the

queries received  by each peer.

Page 4: Print New Final 2

8/7/2019 Print New Final 2

http://slidepdf.com/reader/full/print-new-final-2 4/59

4

SYSTEM

ANALYSIS

Page 5: Print New Final 2

8/7/2019 Print New Final 2

http://slidepdf.com/reader/full/print-new-final-2 5/59

5

CHAPTER 2

SYSTEM ANALYSIS

2.1 EXISTING SYSTEM

Peers in unstructured P2P networks to choose their neighbors and locally

shared files, using Flooding techniques. In purely unstructured P2P networks

such as blind search through flooding mechanisms is usually explored for 

resource discovery. To find a file, a peer sends out a query to its neighbors on

the overlay, until the query has traveled a certain radius. Despite its simplicity

and robustness, flooding techniques, in general, do not scale. In large networks,

the probability of a successful search may decrease dramatically without

significantly enlarging the flooding radius.

The first research issue questions the practicality of modeling

users’ diverse interests.  We have introduced the user interest model (UIM)

  based on a General probabilistic modeling tool termed Condition Random

Fields (CRFs) [4]. With UIM, we are able to estimate the probability of any peer sharing a certain resource (file) fj upon given the fact that it shares another 

resource (file) fi.

The second research issue considers the actual exploration of users’ interests as

embodied by UIM.  To address this concern, a greedy file search protocol is

 presented in this paper for fast resource discovery. Whenever a peer receives

a query for a certain file that is not available locally, it will forward the query to

one of its neighbors that has the highest probability of actually sharing that file.

The third research issue has been highlighted with the insight that the

search protocol alone is not sufficient to achieve high resource discovery.

Page 6: Print New Final 2

8/7/2019 Print New Final 2

http://slidepdf.com/reader/full/print-new-final-2 6/59

6

Deficiency of an Existing System:

Blind Search.

Future reference is not present in routing table.

Delay due to absence of Routing Updating table.

2.2 PROPOSED SYSTEM

In order to improve search performance, guided search. The key

 problem is what information is actually eligible to guide the search [5], [6].

Used interest-based locality as the general search guidance. The basic

assumption is that if a peer p0 has a particular file required by another peer p,

and then p0 is likely to have other files to be requested by p in the future.

According to previous successful queries, shortcuts from peer p to several peers

 p0 are established in order to expedite subsequent search processes.

Proposed System Features:

Guided Search.

Routing updating table.

Fast Search Technique based on UIM.

Page 7: Print New Final 2

8/7/2019 Print New Final 2

http://slidepdf.com/reader/full/print-new-final-2 7/59

7

PROBLEM

FORMULATION

Page 8: Print New Final 2

8/7/2019 Print New Final 2

http://slidepdf.com/reader/full/print-new-final-2 8/59

8

CHAPTER 3

PROBLEM FORMULATION

3.1 OBJECTIVES

A variety of techniques for locating resources (files) in P2P networks

have been devised over the last few years. Initial approaches on a centralized

architecture with designated indexing peers. Due to the single point of failure

 problem and the lack of scalability, recent research in P2P networks focuses

more on distributed search technologies. Unstructured P2P networks blind

search through flooding mechanisms is usually explored for resource discovery.

Resource search, a peer sends out a query to its neighbors on the overlay. These

neighbors, in turn, will forward the query to all of their neighbors until the

query has traveled a certain radius. Despite its simplicity and robustness,

flooding techniques, in general, do not scale. This process make a time

consume, traffic and unwanted search.

3.2 SOFTWARE REQUIREMENTS

The software requirement specification is produced at the culmination of 

the analysis task. The function and performance allocated to software as part of 

system engineering are refined by establishing a complete information

description as functional representation, a representation of system behavior, an

indication of performance requirements and design constraints, appropriate

validation criteria.

User Interface

• Swing - Swing is a set of classes that provides more powerful and flexible

components that are possible with AWT. In addition to the familiar 

Page 9: Print New Final 2

8/7/2019 Print New Final 2

http://slidepdf.com/reader/full/print-new-final-2 9/59

Page 10: Print New Final 2

8/7/2019 Print New Final 2

http://slidepdf.com/reader/full/print-new-final-2 10/59

10

- Components explained in the Swing have more capabilities than

those of AWT

 What Is Java?

Java is two things: a  programming language and a platform. 

3.3.2 Java Programming Language

Java is a high-level programming language that is all of the following:

Simple

Object-oriented

Distributed

Interpreted

Robust

Secure

Architecture-neutral

Portable

High-performance

Multithreaded

Dynamic

Java is also unusual in that each Java program is both compiled and

interpreted. With a compiler, you translate a Java program into an intermediate

language called Java byte codes--the platform-independent codes interpreted by

the Java interpreter. With an interpreter, each Java byte code instruction is

 parsed and run on the computer. Compilation happens just once; interpretation

occurs each time the program is executed. This figure illustrates how this

works.

Page 11: Print New Final 2

8/7/2019 Print New Final 2

http://slidepdf.com/reader/full/print-new-final-2 11/59

11

FIGURE 3.1-WORKING OF JAVA

Java byte codes can be considered as the machine code instructions for 

the Java Virtual Machine (Java VM). Every Java interpreter, whether it's a Java

development tool or a Web browser that can run Java applets, is an

implementation of the Java VM. The Java VM can also be implemented in

hardware.

Java byte codes help make "write once, run anywhere" possible. The Java

  program can be compiled into byte codes on any platform that has a Java

compiler. The byte codes can then be run on any implementation of the

Java VM. For example, the same Java program can run on Windows NT,

Solaris, and Macintosh.

3.3.3 Java Platform

A platform is the hardware or software environment in which a program

runs. The Java platform differs from most other platforms in that it's a software-

only platform that runs on top of other, hardware-based platforms. Most other 

 platforms are described as a combination of hardware and operating system.

The Java platform has two components:

The Java Virtual Machine (Java VM)

The Java Application Programming Interface (Java API)

Page 12: Print New Final 2

8/7/2019 Print New Final 2

http://slidepdf.com/reader/full/print-new-final-2 12/59

Page 13: Print New Final 2

8/7/2019 Print New Final 2

http://slidepdf.com/reader/full/print-new-final-2 13/59

13

The most common types of programs are probably applets  and

applications, where a Java application is a standalone program that runs directly

on the Java platform.

How does the Java API support all of these kinds of programs?

With packages of software components that provide a wide range of 

functionality. The core API is the API included in every full implementation of 

the Java platform. The core API gives you the following features:

The Essentials: Objects, strings, threads, numbers, input and output, data

structures, system properties, date and time, and so on.

Applets: The set of conventions used by Java applets.

 Networking: URLs, TCP and UDP sockets, and IP addresses.

Internationalization: Help for writing programs that can be localized for 

users worldwide. Programs can automatically adapt to specific locales

and be displayed in the appropriate language.

Security: Both low-level and high-level, including electronic signatures,

 public/private key management, access control, and certificates.

Software components: Known as JavaBeans, can plug into existing

component architectures such as Microsoft's OLE/COM/Active-X

architecture, OpenDoc, and Netscape's Live Connect.

Object serialization: Allows lightweight persistence and communication

via Remote Method Invocation (RMI).

Java Database Connectivity (JDBC): Provides uniform access to a wide

range of relational databases.

Java not only has a core API, but also standard extensions. The standard

extensions define APIs for 3D, servers, collaboration, telephony, speech,

animation, and more.

Page 14: Print New Final 2

8/7/2019 Print New Final 2

http://slidepdf.com/reader/full/print-new-final-2 14/59

14

3.4 NETWORKING BASICS

Ken Thompson and Dennis Ritchie developed UNIX in concert with the

C language at Bell Telephone Laboratories, Murray Hill, New Jersey, in 1969.

In 1978, Bill Joy was leading a project at Cal Berkeley to add many new

features to UNIX, such as virtual memory and full-screen display capabilities.

By early 1984, just as Bill was leaving to found Sun Microsystems, he shipped

4.2BSD, commonly known as Berkeley UNIX.4.2BSD came with a fast file

system, reliable signals, inter-process communication, and, most important,

networking. The networking support first found in 4.2 eventually became the de

facto standard for the Internet. Berkeley’s implementation of TCP/IP remains

the primary standard for communications with the Internet. The socket

 paradigm for inter process and network communication has also been widely

adopted outside of Berkeley.

3.4.1 Socket Overview

A network socket is a lot like an electrical socket. Various plugs around thenetwork have a standard way of delivering their payload. Anything that

understands the standard protocol can “plug in” to the socket and communicate.

Internet protocol (IP) is a low-level routing protocol that breaks data into

small packets and sends them to an address across a network, which does not

guarantee to deliver said packets to the destination.

Transmission Control Protocol (TCP) is a higher-level protocol that

manages to reliably transmit data.

User Datagram Protocol  (UDP), sits next to TCP and can be used

directly to support fast, connectionless, unreliable transport of packets.

Page 15: Print New Final 2

8/7/2019 Print New Final 2

http://slidepdf.com/reader/full/print-new-final-2 15/59

15

Client/Server

A Server is anything that has some resource that can be shared. There are

compute servers, which provide computing power; print servers, which manage

a collection of printers; disk servers, which provide networked disk space; and

web servers, which store web pages. A client  is simply any other entity that

wants to gain access to a particular server.

In Berkeley sockets, the notion of a socket allows as single computer to

serve many different clients at once, as well as serving many different types of 

information. This feat is managed by the introduction of a port, which is a

numbered socket on a particular machine. A server process is said to “listen” to

a port until a client connects to it. A server is allowed to accept multiple clients

connected to the same port number, although each session is unique. To manage

multiple client connections, a server process must be multithreaded or have

some other means of multiplexing the simultaneous I/O.

Reserved Sockets

Once connected, a higher-level protocol ensues, which is dependent on

which port you are using. TCP/IP reserves the lower, 1,024 ports for specific

 protocols. Port number 21 is for FTP, 23 is for Telnet, 25 is for e-mail, 79 is for 

finger, 80 is for HTTP, 119 is for Netnews-and the list goes on. It is up to each

 protocol to determine how a client should interact with the port.

Java and the Net

Java supports TCP/IP both by extending the already established stream

I/O interface. Java supports both the TCP and UDP protocol families. TCP is

used for reliable stream-based I/O across the network. UDP supports a simpler,

hence faster, point-to-point datagram-oriented model.

Page 16: Print New Final 2

8/7/2019 Print New Final 2

http://slidepdf.com/reader/full/print-new-final-2 16/59

16

InetAddress

The InetAddress class is used to encapsulate both the numerical IP address

and the domain name for that address. We interact with this class by using the

name of an IP host, which is more convenient and understandable than its IP

address. The InetAddress class hides the number inside. As of Java 2, version

1.4, InetAddress can handle both IPv4 and IPv6 addresses.

Factory Methods

The InetAddress class has no visible constructors. To create an

InetAddress object, we use one of the available factory methods.  Factory

methods are merely a convention whereby static methods in a class return an

instance of that class. This is done in lieu of overloading a constructor with

various parameter lists when having unique method names makes the results

much clearer.

Three commonly used InetAddress factory methods are shown here. Static

InetAddress getLocalHost ( ) throws UnknownHostException static

InetAddress getByName (String hostName) throws Unknows

HostExceptionstatic InetAddress[ ] getAllByName (String hostName) throws

UnknownHostException.

The getLocalHost ( ) method simply returns the InetAddress object that

represents the local host. The getByName ( ) method returns an InetAddress for 

a host name passed to it. If these methods are unable to resolve the host name,

they throw an UnknownHostException.

On the internet, it is common for a single name to be used to represent

several machines. In the world of web servers, this is one way to provide some

degree of scaling. The getAllByName ( ) factory method returns an array of 

InetAddresses that represent all of the addresses that a particular name resolves

Page 17: Print New Final 2

8/7/2019 Print New Final 2

http://slidepdf.com/reader/full/print-new-final-2 17/59

17

to. It will also throw an UnknownHostException if it can’t resolve the name to

at least one address. Java 2, version 1.4 also includes the factory method

getByAddress ( ), which takes an IP address and returns an InetAddress object.

Either an IPv4 or an IPv6 address can be used.

3.4.2 Instance Methods

The InetAddress class also has several other methods, which can be used on

the objects returned by the methods just discussed. Here are some of the most

commonly used.

• Boolean equals (Object other)- Returns true if this object has the same

Internet address as other.

•   byte[ ] getAddress ( )- Returns a byte array that represents the

object’s Internet address in network byte order.

• String getHostAddress ( )- Returns a string that represents the host address

associated with the InetAddress object.

String get Hostname ( )- Returns a string that represents the host nameassociated with the InetAddress object.

• Boolean isMulticastAddress ( )- Returns true if this Internet address is a

multicast address. Otherwise, it returns false.

• String to String( )- Returns a string that lists the host name and the IP

address for convenience.

Internet addresses are looked up in a series of hierarchically cached

servers. That means that your local computer might know a particular name-to-

IP-address mapping autocratically, such as for itself and nearby servers. For 

other names, it may ask a local DNS server for IP address information. If that

server doesn’t have a particular address, it can go to a remote site and ask for it.

Page 18: Print New Final 2

8/7/2019 Print New Final 2

http://slidepdf.com/reader/full/print-new-final-2 18/59

18

This can continue all the way up to the root server, called InterNIC

(internic.net).

3.4.3 TCP/IP Client Sockets

TCP/IP sockets are used to implement reliable, bidirectional, persistent,

 point-to-point and stream-based connections between hosts on the Internet. A

socket can be used to connect Java’s I/O system to other programs that may

reside either on the local machine or on any other machine on the Internet.

There are two kinds of TCP sockets in Java. One is for servers, and the

other is for clients. The Server Socket class is designed to be a “listener,” which

waits for clients to connect before doing anything. The Socket class is designed

to connect to server sockets and initiate protocol exchanges.

The creation of a Socket object implicitly establishes a connection between

the client and server. There are no methods or constructors that explicitly

expose the details of establishing that connection. Here are two constructors

used to create client sockets:

Socket (String hostName, int port) Creates a socket connecting the local

host to the named host and port; can throw an UnknownHostException or 

anIOException.

Socket (InetAddress ipAddress, int port) creates a socket using a

 preexisting InetAddress object and a port; can throw an IOException.

A socket can be examined at any time for the address and port information

associated with it, by use of the following methods:

• InetAddress getInetAddress( )- Returns the InetAddress associated with

the Socket object.

Page 19: Print New Final 2

8/7/2019 Print New Final 2

http://slidepdf.com/reader/full/print-new-final-2 19/59

19

• int get Port( )Returns the remote port to which this Socket object is

connected.

• int getLocalHost( ) Returns the local port to which this Socket object is

connected.

Once the Socket object has been created, it can also be examined to gain

access to the input and output streams associated with it. Each of these methods

can throw an IOException if the sockets have been invalidated by a loss of 

connection on the Net.

• InputStream getInputStream ( ) Returns the InputStream associated with

the invoking socket.

• Output Stream getOutputStream ( ) Returns the Output Stream associated

with the invoking socket.

3.4.4 TCP/IP Server Sockets

Java has a different socket class that must be used for creating server 

applications. The ServerSocket class is used to create servers that listen for 

either local or remote client programs to connect to them on published ports.

ServerSockets are quite different form normal Sockets.

When we create a ServerSocket, it will register itself with the system as

having an interest in client connections. The constructors for ServerSocket

reflect the port number that we wish to accept connection on and, optionally,

how long we want the queue for said port to be. The queue length tells the

system how many client connection it can leave pending before it should simply

refuse connections. The default is 50. The constructors might throw an

IOException under adverse conditions. Here are the constructors:

• ServerSocket(int port) Creates server socket on the specified port with a

queue length of 50.

Page 20: Print New Final 2

8/7/2019 Print New Final 2

http://slidepdf.com/reader/full/print-new-final-2 20/59

20

• Serversocket(int port, int maxQueue)-Creates a server socket on the

specified port with a maximum queue length of maxQueue.

• ServerSocket(int port, int maxQueue, InetAddress localAddress)-Creates a

server socket on the specified port with a maximum queue length of 

maxQueue. On a multihomed host, localAddress specifies the IP address

to which this socket binds.

• ServerSocket has a method called accept( ), which is a blocking call that

will wait for a client to initiate communications, and then return with a

normal Socket that is then used for communication with the client.

URL

The Web is a loose collection of higher-level protocols and file formats, all

unified in a web browser. One of the most important aspects of the Web is that

Tim Berners-Lee devised a scalable way to locate all of the resources of the

  Net. The Uniform Resource Locator (URL) is used to name anything and

everything reliably.

The URL  provides a reasonably intelligible form to uniquely identify or 

address information on the Internet. URLs are ubiquitous; every browser uses

them to identify information on the Web. Within Java’s network class library,

the URL class provides a simple, concise API to access information across the

Internet using URLs.

Format

Two examples of URLs are http;//www.osborne.com/ and http://

www.osborne.com:80/index.htm.

A URL specification is based on four components. The first is the protocol

to use, separated from the rest of the locator by a colon (:). Common protocols

are http, ftp, gopher, and file, although these days almost everything is being

Page 21: Print New Final 2

8/7/2019 Print New Final 2

http://slidepdf.com/reader/full/print-new-final-2 21/59

21

done via HTTP. The second component is the host name or IP address of the

host to use; this is delimited on the left by double slashes (/ /) and on the right

 by a slash (/) or optionally a colon (:) and on the right by a slash (/). The fourth

  part is the actual file path. Most HTTP servers will append a file named

index.html or index.htm to URLs that refer directly to a directory resource.

Java’s URL class has several constructors, and each can throw a

MalformedURLException. One commonly used form specifies the URL with a

string that is identical to what is displayed in a browser:

• URL(String urlSpecifier )

• URL(String protocolName, String hostName, int port, String path)

• URL(String protocolName, String hostName, String path)

• URL(URL urlObj, String urlSpecifier )

The following method returns a URLConnection object associated with the

invoking URL object. it may throw an IOException.

URLConnection openConnection( )-It returns a URLConnection object

associated with the invoking URL object. it may throw an IOException.

3.5 JDBC

In an effort to set an independent database standard API for Java, Sun

Microsystems developed Java Database Connectivity, or JDBC. JDBC offers a

generic SQL database access mechanism that provides a consistent interface to

a variety of RDBMS. This consistent interface is achieved through the use of 

“plug-in” database connectivity modules, or  drivers. If a database vendor 

wishes to have JDBC support, he or she must provide the driver for each

 platform that the database and Java run on.

To gain a wider acceptance of JDBC, Sun based JDBC’s framework on

ODBC. As you discovered earlier in this chapter, ODBC has widespread

Page 22: Print New Final 2

8/7/2019 Print New Final 2

http://slidepdf.com/reader/full/print-new-final-2 22/59

22

support on a variety of platforms. Basing JDBC on ODBC will allow vendors to

 bring JDBC drivers to market much faster than developing a completely new

connectivity solution.

JDBC Goals

Few software packages are designed without goals in mind. JDBC is one

that, because of its many goals, drove the development of the API. These goals,

in conjunction with early reviewer feedback, have finalized the JDBC class

library into a solid framework for building database applications in Java.

The goals that were set for JDBC are important. They will give you some

insight as to why certain classes and functionalities behave the way they do.

The eight design goals for JDBC are as follows:

SQLLevelAPI

The designers felt that their main goal was to define a SQL interface for 

Java. Although not the lowest database interface level possible, it is at a low

enough level for higher-level tools and APIs to be created. Conversely, it is at a

high enough level for application programmers to use it confidently. Attaining

this goal allows for future tool vendors to “generate” JDBC code and to hide

many of JDBC’s complexities from the end user.

SQLConformance

SQL syntax varies as you move from database vendor to database

vendor. In an effort to support a wide variety of vendors, JDBC will allow any

query statement to be passed through it to the underlying database driver. This

allows the connectivity module to handle non-standard functionality in a

manner that is suitable for its users.

JDBC must be implemental on top of common database interfaces 

The JDBC SQL API must “sit” on top of other common SQL level APIs.

This goal allows JDBC to use existing ODBC level drivers by the use of a

Page 23: Print New Final 2

8/7/2019 Print New Final 2

http://slidepdf.com/reader/full/print-new-final-2 23/59

23

software interface. This interface would translate JDBC calls to ODBC and vice

versa.

Provide a Java interface that is consistent with the rest of the Java system

Because of Java’s acceptance in the user community thus far, the

designers feel that they should not stray from the current design of the core Java

system.

Use strong, static typing wherever possible

Strong typing allows for more error checking to be done at compile time;

also, less error appear at runtime.

Keep the common cases simple

Because more often than not, the usual SQL calls used by the

 programmer are simple SELECT’s, INSERT’s, DELETE’s and UPDATE’s,

these queries should be simple to perform with JDBC. However, more complex

SQL statements should also be possible.

Page 24: Print New Final 2

8/7/2019 Print New Final 2

http://slidepdf.com/reader/full/print-new-final-2 24/59

24

SYSTEM DESIGN

CHAPTER 4

SYSTEM DESIGN

Page 25: Print New Final 2

8/7/2019 Print New Final 2

http://slidepdf.com/reader/full/print-new-final-2 25/59

25

4.1 DESIGN OVERVIEW

The implementation can be preceded through Socket in java but it will be

considered as peer to peer communication .For proactive routing we need

dynamic routing. So java will be more suitable for platform independence and

networking concepts. For maintaining route information we go for Sql as

database back end.

The first research issue questions the practicality of modeling users’

diverse interests. To solve this problem, we have introduced the user interest

model (UIM) based on a general probabilistic modeling tool termed Condition

Random Fields (CRFs) . With UIM, we are able to estimate the probability of 

any peer sharing a certain resource (file) f  j upon given the fact that it shares

another resource (file) f i. This estimation further gives rise to an interest

distance between any two peers.

The second research issue considers the actual exploration of users’

interests as embodied by UIM. To address this concern, a greedy file search

 protocol is presented in this paper for fast resource discovery. Whenever a peer 

receives a query for a certain file that is not available locally, it will forward the

query to one of its neighbors that have the highest probability of actually

sharing that file.

The third research issue has been highlighted with the insight that the

search protocol alone is not sufficient to achieve high resource discovery

 performance.

4.2 MODULES

•  Network Construction

• Resource Search

• Routing Table Updation

Page 26: Print New Final 2

8/7/2019 Print New Final 2

http://slidepdf.com/reader/full/print-new-final-2 26/59

26

• User Interest Model

4.2.1 Network Construction

Construct the dynamic network topology. We can add any number of 

Peers dynamically and construct the connections dynamically. Peer can easily

leave from the network, and share the resources dynamically. Uploading

 process can do the dynamic resource sharing.

4.2.2 Resource Search

Search the need resource by using the resource name. Peer search theresource using guided search method. It check the routing table if any address is

available it directly go to that peer else it search throughout the network. It

takes the resource from the available peer at the same time it takes address of 

that particular Peer and other sharing resource names.

4.2.3 Routing Table Updation

 Routing table contains the information about the past successful search

results. It contains name of the peer, address, resource name, and count of the

search. Routing table will update every possible search result. It also has the

other sharing resource names. It could help for future reference. It leads the

guided search.

4.2.4 User Interest Model

The search based on the user’s common interest. It will estimate the

user’s interest between two peers. It gives the priority for the user’s interest

Page 27: Print New Final 2

8/7/2019 Print New Final 2

http://slidepdf.com/reader/full/print-new-final-2 27/59

27

resources. It maintains the details about the particular resource in the memory in

certain time. Memory is cleared at the certain time intervals.

4.3 DATA FLOW DIAGRAM

A data flow diagram (DFD) is graphic representation of the "flow" of 

data through business functions or processes. More generally, a data flow

diagram is used for the visualization of data processing. It illustrates the

 processes, data stores, and external entities, data flows in a business or other 

system and the relationships between them

 

FIGURE 4.1-DATA FLOW DIGRAM

4.4 ARCHITECTURAL DESIGN

Routing Table

Search the peer 

Search the data

 base

Collect the filecontent

Update the other 

sharing files from

that peer name

UIM

Cache

Memory

Give the filename

Page 28: Print New Final 2

8/7/2019 Print New Final 2

http://slidepdf.com/reader/full/print-new-final-2 28/59

28

In this figure 4.2 users search the resource in the different peers using

guided search. Resources are stored in the each peer, each peer having the

routing table. Routing table is used to store the resources and searched

resources from the other peers during the search.

FIGURE 4.2- ARCHITECTURAL DESIGN DIAGRAM

4.5 CLASS DIAGRAM

Peer3

Peer2

Peer4 Peer5

Peer1

Router 

updation

table

Router 

updation

table

Router updation

table

Router 

updation

table

Router 

updation

table

Guided

Search(user )

Page 29: Print New Final 2

8/7/2019 Print New Final 2

http://slidepdf.com/reader/full/print-new-final-2 29/59

29

In this figure 4.3 peer having the peer details, file list and network and

the login table contains username, login then the peer frame contains the file,

file name to add the data on the table. Routing table contains the file name and

file visit it functions as routing table to find the information. in the peer1 send

the information to the peer frame1 and routing table the search the database and

receive the data.

+

FIGURE 4.3-CLASS DIAGRAM

4.6 SEQUENCE DIAGRAM

 peerdetails;filelist;

network;

 peer1();send();

searchdb();

receive1();

peer1

 peername;

filename;visit;

routingtable();

RouterTable();

routing table

file;

flname;desdir;

 peerframe1();adddata();

 peerframe1

username;

n;login;

login();user();

login

Page 30: Print New Final 2

8/7/2019 Print New Final 2

http://slidepdf.com/reader/full/print-new-final-2 30/59

30

In this figure 4.4, network construction process is used to login to the

 peer and communicate to the search process, which in turn communicate the

routing table for search of the file present in the routing table. Frequently

searched file details are stored in UIM. If search file is present in the UIM, peer 

collect the file from the UIM otherwise collect the file from the routing table.

FIGURE 4.4 -SEQUENCE DIAGRAM

Peer login

Search Resource

Frequent search

file details

 

From cache memory

Collecting file details

From routing tableCollecting File details

 Network 

Construction

Search Routing Table UIM

Page 31: Print New Final 2

8/7/2019 Print New Final 2

http://slidepdf.com/reader/full/print-new-final-2 31/59

31

IMPLEMENTATION

AND

TESTING

Page 32: Print New Final 2

8/7/2019 Print New Final 2

http://slidepdf.com/reader/full/print-new-final-2 32/59

32

CHAPTER 5

IMPLEMENTATION AND TESTING

5.1 IMPLEMENTATION

The implementation can be preceded through Socket in java but it will be

considered as peer to peer communication .For proactive routing we need

dynamic routing. So java will be more suitable for platform independence and

networking concepts. For maintaining route information we go for SQL Server 

as database back end.

The first research issue questions the practicality of modeling users’

diverse interests. To solve this problem, we have introduced the user interest

model (UIM) based on a general probabilistic modeling tool termed Condition

Random Fields (CRFs) .This estimation further gives rise to an interest distance

 between any two peers.

The second research issue considers the actual exploration of users’

interests as embodied by UIM. To address this concern, a greedy file search

 protocol is presented in this paper for fast resource discovery. Whenever a peer 

receives a query for a certain file that is not available locally, it will forward the

query to one of its neighbors that have the highest probability of actually

sharing that file.

The third research issue has been highlighted with the insight that the

search protocol alone is not sufficient to achieve high resource discovery performance. This paper proposes a routing table updating protocol to support

our search protocol through self organizing the whole P2P network into a small

world. Different from closely related research works that are also inspired by

the small-world model .

Page 33: Print New Final 2

8/7/2019 Print New Final 2

http://slidepdf.com/reader/full/print-new-final-2 33/59

33

5.2 TESTING

The purpose of testing is to discover errors. Testing is the process of 

trying to discover every conceivable fault or weakness in a work product. It

  provides a way to check the functionality of components, sub assemblies,

assemblies and/or a finished product it is the process of exercising software

with the intent of ensuring that the Software system meets its requirements and

user expectations and does not fail in an unacceptable manner. There are

various types of test. Each test type addresses a specific testing requirement.

5.2.1 Unit testingUnit testing involves the design of test cases that validate that the internal

 program logic is functioning properly, and that program input produces valid

outputs. All decision branches and internal code flow should be validated. It is

the testing of individual software units of the application .it is done after the

completion of an individual unit before integration. This is a structural testing,

that relies on knowledge of its construction and is invasive. Unit tests perform

 basic tests at component level and test a specific business process, application,

and/or system configuration. Unit tests ensure that each unique path of a

 business process performs accurately to the documented specifications and

contains clearly defined inputs and expected results.

5.2.2 Functional test

Functional tests provide systematic demonstrations that functions tested

are available as specified by the business and technical

requirements, system documentation, and user manuals.

Functional testing is centered on the following items:

Valid Input : identified classes of valid input must be accepted.

Page 34: Print New Final 2

8/7/2019 Print New Final 2

http://slidepdf.com/reader/full/print-new-final-2 34/59

34

Invalid Input : identified classes of invalid input must be rejected.

Functions : identified functions must be exercised.

Output : identified classes of application outputs must be exercised.

Systems/Procedures: interfacing systems or procedures must be invoked.

5.2.3 System Test

System testing ensures that the entire integrated software system meets

requirements. It tests a configuration to ensure known and predictable results.

An example of system testing is the configuration oriented system integration

test. System testing is based on process descriptions and flows, emphasizing

 pre-driven process links and integration points.

5.2.4 Performance Test

The Performance test ensures that the output be produced within the time

limits, and the time taken by the system for compiling, giving response to the

users and request being send to the system for to retrieve the results.6.2

Integration Testing Software integration testing is the incremental integration

testing of two or more integrated software components on a single platform to

 produce failures caused by interface defects.

The task of the integration test is to check that components or software

applications, e.g. components in a software system or – one step up –software

applications at the company level – interact without error.

Integration testing for Server Synchronization:

Testing the IP Address for to communicate with the other Nodes

Check the Route status in the Cache Table after the status information is

received by the Node

Page 35: Print New Final 2

8/7/2019 Print New Final 2

http://slidepdf.com/reader/full/print-new-final-2 35/59

Page 36: Print New Final 2

8/7/2019 Print New Final 2

http://slidepdf.com/reader/full/print-new-final-2 36/59

36

CONCLUSION

Page 37: Print New Final 2

8/7/2019 Print New Final 2

http://slidepdf.com/reader/full/print-new-final-2 37/59

Page 38: Print New Final 2

8/7/2019 Print New Final 2

http://slidepdf.com/reader/full/print-new-final-2 38/59

38

 be collected and applied to further test the effectiveness of our protocols. These

and other efforts will be left here as our future work.

FUTURE

ENHANCEMENTS

Page 39: Print New Final 2

8/7/2019 Print New Final 2

http://slidepdf.com/reader/full/print-new-final-2 39/59

Page 40: Print New Final 2

8/7/2019 Print New Final 2

http://slidepdf.com/reader/full/print-new-final-2 40/59

40

APPENDICES

Page 41: Print New Final 2

8/7/2019 Print New Final 2

http://slidepdf.com/reader/full/print-new-final-2 41/59

41

APPENDIX 1

SCREENSHOTS

USER LOGIN FORM

In this screenshot, the user have to give the peer id for login to the peer 

and this form is include the button clear and cancel its used to clear the entered

data in the peer id text box and to exit the login form.

FIGURE A1.1 USER LOGIN FORM

Page 42: Print New Final 2

8/7/2019 Print New Final 2

http://slidepdf.com/reader/full/print-new-final-2 42/59

42

RESOURCE SEARCHING FORM

In this resource searching for the peer name text box show the name of 

the peer, in the file name text box we have to give the name of the resource for 

search, search button is used to search the resource, clear button is used to clear.

FIGURE A1.2 RESOURCE SEARCHING FORM

Page 43: Print New Final 2

8/7/2019 Print New Final 2

http://slidepdf.com/reader/full/print-new-final-2 43/59

43

BEFORE UPDATION ROUTING TABLE

In this screenshots shows the resources name present in the login peer 

and also contain the visit count of the each resource.

FIGURE A1.3: BEFORE UPDATION ROUTING TABLE

.

Page 44: Print New Final 2

8/7/2019 Print New Final 2

http://slidepdf.com/reader/full/print-new-final-2 44/59

44

AFTER SEARCHING UPDATION ROUTING TABLE

In this screenshots shows the resources name present in the login peer 

and also shows the searched resources name and that peer name, visit count.

FIGURE A1.4: AFTER SEARCHING UPDATION ROUTING TABLE

.

Page 45: Print New Final 2

8/7/2019 Print New Final 2

http://slidepdf.com/reader/full/print-new-final-2 45/59

45

USER INTEREST ROUTING TABLE

In this screenshots shows the user interest model routing table. It contains

the peer name, file name, and total number count.

FIGURE A1.5: USER INTEREST ROUTING TABLE

Page 46: Print New Final 2

8/7/2019 Print New Final 2

http://slidepdf.com/reader/full/print-new-final-2 46/59

46

APPENDIX 2

SAMPLE CODING

//RESOURCE SEARCH

import java.sql.*;

import java.sql.Connection.*;

import java.sql.Connection;

import java.sql.DriverManager;

import java.sql.ResultSet;

import java.sql.Statement;

 public class Des extends javax.swing.JFrame {

 public Des()

{

initComponents();

}

@SuppressWarnings("unchecked")

 private void initComponents() {

 jLabel1 = new javax.swing.JLabel();

 jTextField1 = new javax.swing.JTextField();

 jButton1 = new javax.swing.JButton();

 jScrollPane1 = new javax.swing.JScrollPane();

 jTextArea1 = new javax.swing.JTextArea();

 jButton2 = new javax.swing.JButton();

Page 47: Print New Final 2

8/7/2019 Print New Final 2

http://slidepdf.com/reader/full/print-new-final-2 47/59

47

setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

addWindowFocusListener(new java.awt.event.WindowFocusListener() {

 public void windowGainedFocus(java.awt.event.WindowEvent evt) {

formWindowGainedFocus(evt);

}

 public void windowLostFocus(java.awt.event.WindowEvent evt) {

}

});

 jLabel1.setFont(new java.awt.Font("Tahoma", 1, 18));

 jLabel1.setText("Enter Search Topic");

 jButton1.setText("Search");

 jButton1.addActionListener(new java.awt.event.ActionListener() {

 public void actionPerformed(java.awt.event.ActionEvent evt) {

 jButton1ActionPerformed(evt);

}

});

 jButton1.addMouseListener(new java.awt.event.MouseAdapter() {

 public void mouseClicked(java.awt.event.MouseEvent evt) {

 jButton1MouseClicked(evt);

}

});

 jTextArea1.setColumns(20);

 jTextArea1.setRows(5);

 jTextArea1.setBorder(new javax.swing.border.MatteBorder(null));

 jTextArea1.setMargin(new java.awt.Insets(1, 1, 1, 1));

 jScrollPane1.setViewportView(jTextArea1);

Page 48: Print New Final 2

8/7/2019 Print New Final 2

http://slidepdf.com/reader/full/print-new-final-2 48/59

48

 jButton2.setText("Exit");

 jButton2.addMouseListener(new java.awt.event.MouseAdapter() {

 public void mouseClicked(java.awt.event.MouseEvent evt) {

 jButton2MouseClicked(evt);

}

});

org.jdesktop.layout.GroupLayout layout = new

org.jdesktop.layout.GroupLayout(getContentPane());

getContentPane().setLayout(layout);

layout.setHorizontalGroup(

layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)

.add(layout.createSequentialGroup()

.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)

.add(layout.createSequentialGroup()

.add(323, 323, 323)

.add(jButton2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 63,

Short.MAX_VALUE))

.add(layout.createSequentialGroup()

.add(44, 44, 44)

.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)

.add(org.jdesktop.layout.GroupLayout.TRAILING, jScrollPane1,

org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)

.add(org.jdesktop.layout.GroupLayout.TRAILING,

layout.createSequentialGroup()

.add(jTextField1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 259,

Short.MAX_VALUE)

.add(18, 18, 18)

Page 49: Print New Final 2

8/7/2019 Print New Final 2

http://slidepdf.com/reader/full/print-new-final-2 49/59

Page 50: Print New Final 2

8/7/2019 Print New Final 2

http://slidepdf.com/reader/full/print-new-final-2 50/59

50

try

{

try

{

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

}

catch (Exception e)

{

}

Connection con = DriverManager.getConnection("jdbc:odbc:Peer","sa","sa");

Statement stmt = con.createStatement();

String query = "SELECT distinct Title, contents FROM Resource where

Title='" + jTextField1.getText() + "'";

ResultSet rs = stmt.executeQuery(query);

while(rs.next())

{

 jTextArea1.setText(rs.getString("contents"));

}

String que= "insert into Serdet values(6,'4-2-2009 ','"+jTextField1.getText()

+"')";

int rs2= stmt.executeUpdate(que);

int rs1= stmt.executeUpdate("insert into resource" + " values(4,'Int

Java','sdfasgfddsds')");

}

catch (SQLException se)

{

}

Page 51: Print New Final 2

8/7/2019 Print New Final 2

http://slidepdf.com/reader/full/print-new-final-2 51/59

Page 52: Print New Final 2

8/7/2019 Print New Final 2

http://slidepdf.com/reader/full/print-new-final-2 52/59

52

RESOURCE UPDATION

import java.sql.*;

import java.sql.Connection.*;

import java.sql.Connection;

import java.sql.DriverManager;

import java.sql.ResultSet;

import java.sql.Statement;

 public class TCP extends javax.swing.JFrame {

 public TCP() {

initComponents();

}

 private void initComponents() {

 jLabel1 = new javax.swing.JLabel();

 jLabel2 = new javax.swing.JLabel();

 jLabel3 = new javax.swing.JLabel();

 jTextField1 = new javax.swing.JTextField();

 jTextField2 = new javax.swing.JTextField();

 jButton1 = new javax.swing.JButton();

 jLabel4 = new javax.swing.JLabel();

 jTextField3 = new javax.swing.JTextField();

setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

 jLabel1.setText("INSERTION");

 jLabel2.setText("Sno");

 jLabel3.setText("Title");

Page 53: Print New Final 2

8/7/2019 Print New Final 2

http://slidepdf.com/reader/full/print-new-final-2 53/59

53

 jTextField1.addActionListener(new java.awt.event.ActionListener() {

 public void actionPerformed(java.awt.event.ActionEvent evt) {

 jTextField1ActionPerformed(evt);

}

});

 jButton1.setText("ADD");

 jButton1.addActionListener(new java.awt.event.ActionListener() {

 public void actionPerformed(java.awt.event.ActionEvent evt) {

 jButton1ActionPerformed(evt);

}

});

 jButton1.addMouseListener(new java.awt.event.MouseAdapter() {

 public void mouseClicked(java.awt.event.MouseEvent evt) {

 jButton1MouseClicked(evt);

}

});

 jLabel4.setText("contents");

org.jdesktop.layout.GroupLayout layout = new

org.jdesktop.layout.GroupLayout(getContentPane());

getContentPane().setLayout(layout);

layout.setHorizontalGroup(

layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)

.add(layout.createSequentialGroup()

.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING,

false)

.add(layout.createSequentialGroup()

.add(69, 69, 69)

Page 54: Print New Final 2

8/7/2019 Print New Final 2

http://slidepdf.com/reader/full/print-new-final-2 54/59

54

.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)

.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING,

false)

.add(org.jdesktop.layout.GroupLayout.TRAILING, jLabel3,

org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,

org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)

.add(org.jdesktop.layout.GroupLayout.TRAILING, jLabel2,

org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 32, Short.MAX_VALUE))

.add(jLabel4))

.add(84, 84, 84)

.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING,

false)

.add(org.jdesktop.layout.GroupLayout.TRAILING, jTextField3)

.add(org.jdesktop.layout.GroupLayout.TRAILING, jTextField2)

.add(org.jdesktop.layout.GroupLayout.TRAILING, jTextField1,

org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 133,

Short.MAX_VALUE)

.add(jButton1)))

.add(layout.createSequentialGroup()

.add(144, 144, 144)

.add(jLabel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 74,

org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))

.addContainerGap(72, Short.MAX_VALUE))

);

layout.setVerticalGroup(

layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)

.add(layout.createSequentialGroup()

Page 55: Print New Final 2

8/7/2019 Print New Final 2

http://slidepdf.com/reader/full/print-new-final-2 55/59

55

.add(22, 22, 22)

.add(jLabel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 23,

org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)

.add(26, 26, 26)

.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)

.add(jLabel2)

.add(jTextField1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,

org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,

org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))

.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)

.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)

.add(jTextField2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,

org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,

org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)

.add(jLabel3))

.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)

.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)

.add(jTextField3, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,

org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,

org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)

.add(jLabel4))

.add(56, 56, 56)

.add(jButton1)

.addContainerGap(81, Short.MAX_VALUE))

);

 jLabel2.getAccessibleContext().setAccessibleName("Id");

 pack();

Page 56: Print New Final 2

8/7/2019 Print New Final 2

http://slidepdf.com/reader/full/print-new-final-2 56/59

56

}

 private void jTextField1ActionPerformed(java.awt.event.ActionEvent evt) {

}

 private void jButton1MouseClicked(java.awt.event.MouseEvent evt) {

try

{

try

{

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

}

catch (Exception e)

{

}

Connection con = DriverManager.getConnection("jdbc:odbc:Peer","sa","sa");

Statement stmt = con.createStatement();

String que= "insert into resource values("+jTextField1.getText()

+",'"+jTextField2.getText()+"','"+jTextField3.getText()+"')";

int rs1= stmt.executeUpdate(que);

}

catch (SQLException se)

{

}

}

 private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {

}

 public static void main(String args[]) {

 java.awt.EventQueue.invokeLater(new Runnable() {

Page 57: Print New Final 2

8/7/2019 Print New Final 2

http://slidepdf.com/reader/full/print-new-final-2 57/59

Page 58: Print New Final 2

8/7/2019 Print New Final 2

http://slidepdf.com/reader/full/print-new-final-2 58/59

58

REFERENCES

Page 59: Print New Final 2

8/7/2019 Print New Final 2

http://slidepdf.com/reader/full/print-new-final-2 59/59

59

REFERENCES

1. Adami.T.M, Best.E, and Zhu.J.J, (2002), “Stability Assessment Using

Lyapunov’s First Method,” Proc. 34th Southeastern Symp. System

Theory (SSST ’02), pp. 297-301.

2. Androutsellis-Theotokis.A and Spinellis.D, (2004),“A Survey of Peer-

to-Peer Content Distribution Technologies,” ACM Computing Surveys,

vol. 36, no. 4, pp. 335-371.

3. Cholvi.V, Felber.P.A, and Biersac.E.W, (2004),“Efficient Search in

Unstructured Peer-to-Peer Networks,” European Trans. Telecomm., vol.

15, no. 6.

4. Cohen.E, Fiat.A, and Kaplan.H, (2003), “Associative Search in Peer-to-

Peer Networks: Harnessing Latent Semantics,” Proc. IEEE INFOCOM.

5. Khambatti.M, Ryu.K, and Dasgupta.P, (2003) ,“Structuring Peer-to-Peer 

 Networks Using Interest-Based Communities,” Proc. Int’l Workshop

Databases, Information Systems and Peer-to-Peer Computing(P2PDBIS).

6. Tewari.S and Kleinrock.L, (2007), “Optimal Search Performance

Unstructured Peer-to-Peer Networks with Clustered Demands”, IEEE J.

Selected Areas in Comm., vol. 25, no. 1.