Академический Документы
Профессиональный Документы
Культура Документы
INTRODUCTION
2
CHAPTER 1
INTRODUCTION
SYSTEM
ANALYSIS
5
CHAPTER 2
SYSTEM ANALYSIS
Guided Search.
Routing updating table.
Fast Search Technique based on UIM.
7
PROBLEM
FORMULATION
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.
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.
However, Java is not just for writing cute, entertaining applets for the
World Wide Web ("Web"). Java is a general-purpose, high-level programming
language and a powerful software platform. Using the generous Java API, we
can write many types of programs.
13
How does the Java API support all of these kinds of programs?
The Essentials: Objects, strings, threads, numbers, input and output, data
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.
16
InetAddress
This can continue all the way up to the root server, called InterNIC
(internic.net).
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.
• 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
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
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
22
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.
24
SYSTEM DESIGN
CHAPTER 4
SYSTEM DESIGN
25
resources. It maintains the details about the particular resource in the memory in
certain time. Memory is cleared at the certain time intervals.
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.
Router
Peer1 updation
table
Peer3 Guided
Router Search(user Peer2 Router
updation ) updation
table
table
Peer4
Peer5
Router Router
updation updation
table table
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.
+
login
username;
n;
login;
login();
user();
peer1
peerdetails;
peerframe1
filelist;
network; file;
flname;
peer1(); desdir;
send(); peerframe1();
searchdb(); adddata();
receive1();
routing table
peername;
filename;
visit;
routingtable();
RouterTable();
Frequent search
Peer login
file details
Search Resource
IMPLEMENTATION
AND
TESTING
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 .
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.
CONCLUSION
37
CHAPTER 6
CONCLUSION
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
39
CHAPTER 7
FUTURE ENHANCEMENTS
APPENDICES
41
APPENDIX 1
SCREENSHOTS
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.
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.
In this screenshots shows the resources name present in the login peer
and also contain the visit count of the each resource.
.
44
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.
.
45
In this screenshots shows the user interest model routing table. It contains
the peer name, file name, and total number count.
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();
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) {
}
});
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)
49
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)
{
}
51
}
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
}
private void jButton2MouseClicked(java.awt.event.MouseEvent evt) {
System.exit(0);
}
private void formWindowGainedFocus(java.awt.event.WindowEvent evt) {
}
public static void main(String args[])
{
java.awt.EventQueue.invokeLater(new Runnable()
{
public void run()
{
new Des().setVisible(true);
}
};
}
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2;
private javax.swing.JLabel jLabel1;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JTextArea jTextArea1;
private javax.swing.JTextField jTextField1;
}
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");
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)
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()
55
}
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() {
57
REFERENCES
59
REFERENCES