Académique Documents
Professionnel Documents
Culture Documents
INTRODUCTION:
In this project, we describe the Distributed Cycle Minimization
Protocol (DCMP), a dynamic fully decentralized protocol that significantly
reduces the duplicate messages by eliminating unnecessary cycles. As
queries are transmitted through the peers, DCMP identifies the problematic
paths and attempts to break the cycles while maintaining the connectivity of
the network. In order to preserve the fault resilience and load balancing
properties of unstructured P2P systems, DCMP avoids creating a
hierarchical organization. Instead, it applies cycle elimination symmetrically
around some powerful peers to keep the average path length small.
The overall structure is constructed fast with very low
overhead. With the information collected during this process, distributed
maintenance is performed efficiently even if peers quit the system without
notification. The experimental results from our simulator and the prototype
implementation on Planet Lab confirm that DCMP significantly improves
the scalability of unstructured P2P systems without sacrificing their
desirable properties. Moreover, due to its simplicity, DCMP can be easily
implemented in various existing P2P systems and is orthogonal to the search
algorithms.
EXISTING SYSTEM
Simplicity, ease of deployment, and versatility
Unstructured network topology contains many cyclic paths
It simplifies the implementation of large ad hoc distributed
repositories of digital information.
Queries are transmitted through the cyclic path
PROPOSED SYSTEM
DCMP is dynamic fully decentralized protocol
Queries are transmitted through the peers
DCMP use message flooding to propagate queries
DCMP use the method Native Duplicate Elimination (NDE)
DCMP implements the prototype called Planet Lab
HARDWARE REQUIREMENTS
Processor/system
Pentium IV
Main memory
512 MB RAM
Cache memory
512 KB
Processor speed
600 MHz
Keyboard
101 keys
40 GB
SOFTWARE REQUIREMENTS
Operating system
Java Swing
Programming Language
Core Java
Text Editor
Note Pad
Database
SQL-Server.
SOFTWARE DESCRIPTION:
Swing application
Swing is a graphical user interface library for the Java SE platform. It is
possible to specify a different look and feel through the pluggable look and
feel system of Swing. Clones of Windows, GTK and Motif are supplied by
Sun. Apple also provides an Aqua look and feel for Mac OS X. Where prior
implementations of these looks and feels may have been considered lacking,
Swing in Java SE 6 addresses this problem by using more native widget
drawing routines of the underlying platforms.
What Is an Object?
An object is a software bundle of related state and behavior. Software
objects are often used to model the real-world objects that you find in
everyday life. This lesson explains how state and behavior are represented
within an object, introduces the concept of data encapsulation, and explains
the benefits of designing your software in this manner.
What Is a Class?
A class is a blueprint or prototype from which objects are created. This
section defines a class that models the state and behavior of a real-world
object. It intentionally focuses on the basics, showing how even a simple
class can cleanly model state and behavior.
What Is Inheritance?
Inheritance provides a powerful and natural mechanism for organizing and
structuring your software. This section explains how classes inherit state and
behavior from their superclasses, and explains how to derive one class from
another using the simple syntax provided by the Java programming
language.
What Is an Interface?
An interface is a contract between a class and the outside world. When a
class implements an interface, it promises to provide the behavior published
by that interface. This section defines a simple interface and explains the
necessary changes for any class that implements it.
What Is a Package?
A package is a namespace for organizing classes and interfaces in a logical
manner. Placing your code into packages makes large software projects
easier to manage. This section explains why this is useful, and introduces
you to the Application Programming Interface (API) provided by the Java
platform.
GUI-state models
GUI state models are interfaces that define the visual status of a GUI
control, such as whether a button is pressed or armed, or which items are
selected in a list. GUI-state models typically are relevant only in the context
Packages Used
Import java.lang: Provides classes that are fundamental to the design of the
Java programming language.
Import java.io: Provides for system input and output through data streams,
serialization and the file system.
Communication Interfaces
TCP: Transmission Control Protocol is a transport layer protocol used to
establish connections for networked hosts. It is a protocol that ensures safe
delivery of message packets by getting the acknowledgement back on
delivery.
User login
login
DB
No of nodes
Construct
network
Select file
Send to
neighbor
Selection
process
IC Message
Validate
GUID ,
DID
Receive
Message
Cut Message
nodes
Eliminate
path
Find
possible
path
Validate
GUID ,
DID
DB
login
DB
No of nodes
Construct
network
DB
Send to neighbor
neighbour
neighbour
IC msg
Validate recommendation
GUID, DID
Receive
Cut Message
Nodes
Validate N for
connection disabling
A
A
A
Find possible
path
Compare
GUID,
DID
Eliminate
path
DB
E-R Diagram
Port no
Sys. name
status
Node
name
neighbour
Cost
Node
name
delay
Node information
connection
conne
ct
Possible path
path
delay
cost
Pda
path
delay
cost
node
path
destinatio
n
Page Design
USER LOGIN
User Name
Password
Login
Clear
Peer network
Enter no of nodes
OK
Submit
Clear
Cancel
Connection
Peer Network
Enter no of nodes
Peer Name
OK
Submit
Clear
Cancel
Connection
Peer Network
Enter no of nodes
Peer Name
Source Node
Neighbor node
OK
Submit
Clear
Cancel
Connection
Peer Login
User Name
User Login
Clear
Peer A
Select File
Select File
Send
Leave
Cut Message
View
Record
Clear
Cancel
View Record
Clear
Cancel
Data Type
Node name
Var char(20)
Neighbor
Var char(20)
Cost
decimal
delay
decimal
Field
Data Type
Node name
Var char(20)
Port number
numeric
System name
Var char(20)
status
Field
Data Type
destination
Var char(20)
path
Var char(20)
Cost
Decimal
delay
Decimal
Data Type
path
Cost
Var char(20)
delay
Var char(20)
node
Var char(20)
TESTING
UNIT TESTING
INTEGRATION TESTING
ACCEPTANCE TESTING
UNIT TESTING:
Unit testing comprises the set of tests performed by an individual
programmer prior to integration of the unit into a larger system.
The situation is illustrated as follows:
Coding &debugging--->unit testing-->integration testing.
A program unit is usually small enough that the programmer who developed
it can test it in the great detail, and certainly in greater detail than will be
possible when the unit integrated into an evolving software product.
There are four categories of testing:
1.
2.
3.
4.
1.
Functional tests
Performance tests
Stress tests
Structure tests
Functional test cases involves exercising the code with nominal input
values for which the expected results are known, as well as boundary values
and special values, such as logically related inputs,1*1matrices, the identity
matrix, files of identical elements, and empty files.
2.
various parts of the unit, program throughput, response time and device
utilization by the program unit.
3. Stress tests are those tests designed to intentionally break the unit. A
great deal can be learned about the strengths and limitations of a program
by examining the manner in which the program unit breaks.
4. Structure test are concerned with exercising the internal logic of a
program and traversing particular execution paths. Some authors refer
collectively to functional,
Unit testing has the goal of discovering errors in the individual modules of
the system.
A subsystem consists of several modules that communicate with each other
through well defined interfaces normally, a subsystem implements a major
segments of the total system.
SOURCE CODE:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.net.*;
/**
* Summary description for userlogin
*
*/
this.setVisible(true);
}
private void initializeComponent()
{
userlabel.setHorizontalAlignment(SwingConstants.CENTER);
userlabel.setHorizontalTextPosition(SwingConstants.CENTER);
userlabel.setText("UserName");
jLabel3.setIcon(new ImageIcon("1.Bitmap"));
userfield.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
{
userfield_actionPerformed(e);
}
});
jPasswordField1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
{
jPasswordField1_actionPerformed(e);
}
});
userlogin.setText("userlogin");
userlogin.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
{
userlogin_actionPerformed(e);
}
});
clear.setText("Clear");
clear.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
{
clear_actionPerformed(e);
}
});
contentPane.setLayout(null);
contentPane.setBackground(new Color(125, 155, 155));
addComponent(contentPane, userlabel, 76,100,70,18);
addComponent(contentPane, jLabel3, 50,0,100,200);
//addComponent(contentPane, jLabel5, -1,203,495,31);
addComponent(contentPane, userfield, 202,100,100,25);
addComponent(contentPane, userlogin, 50,170,100,28);
addComponent(contentPane, clear, 170,170,100,28);
this.setTitle("Peer userlogin");
this.setLocation(new Point(19, 37));
this.setSize(new Dimension(400, 250));
this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
this.setResizable(false);
}
/** Add Component Without a Layout Manager (Absolute Positioning) */
private void addComponent(Container container,Component c,int x,int y,int
width,int height)
{
c.setBounds(x,y,width,height);
container.add(c);
}
private void userfield_actionPerformed(ActionEvent e)
{
System.out.println("\nuserfield_actionPerformed(ActionEvent e) called.");
// TODO: Add any handling code here
}
private void jPasswordField1_actionPerformed(ActionEvent e)
{
System.out.println("\njPasswordField1_actionPerformed(ActionEvent e)
called.");
// TODO: Add any handling code here
}
private void userlogin_actionPerformed(ActionEvent e)
{
try
{
username=userfield.getText();
System.out.println("server port:"+n);
pe1.user(username);
pe1.initializeComponent();
dispose();
}
catch (Exception e1)
{
}
System.out.println("\nuserlogin_actionPerformed(ActionEvent e)
called.");
// TODO: Add any handling code here
}
private void clear_actionPerformed(ActionEvent e)
{
System.out.println("\nclear_actionPerformed(ActionEvent e) called.");
userfield.setText("");
}
}
catch (Exception ex)
{
System.out.println("Failed loading L&F: ");
System.out.println(ex);
}
Peer network
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.sql.*;
import java.io.*;
import java.net.*;
import java.util.*;
public class peernetwork extends JFrame
{
private JPanel contentPane;
private dataconnect z;
ResultSet rs;
Connection cs;
Statement st;
Vector v,v1;
static ServerSocket sersoc;
static Socket soc;
ObjectInputStream dis;
ObjectOutputStream dos;
InputStream is;
OutputStream os;
String n="",ip="";
String a[]=new String[100];
static peernetwork m;
int portno=5000,port;
link find;
int number;
public peernetwork()throws Exception
{
super();
z = new dataconnect();
st=z.connect();
st.execute("delete nodeinformation");
st.execute("delete connection");
new peerconnect();
}
public void listen()throws Exception
{
int port=0;
dis=new ObjectInputStream(soc.getInputStream());
String request=(String)dis.readObject();
System.out.println("recived:"+request);
if(request.equals("path1"))
{
String nodes=(String)dis.readObject();
System.out.println("nodes:"+nodes);
int j=0;
rs=st.executeQuery("Select NodeName from nodeinformation");
while(rs.next())
{
a[j]=rs.getString(1);
j++;
}
st.execute("delete possiblepath");
for(int i=0;i<j;i++)
{
find= new link(nodes,a[i]);
}
v1=new Vector();
for( int i=0;i<j;i++)
{
rs=st.executeQuery("Select PortNo from nodeinformation
where Status='ON' ");
if(rs.next())
{
rs=st.executeQuery("Select path from possiblepath where
destination='"+a[i]+"' ");
while(rs.next())
{
v1.add(rs.getString(1));
}
}
}
System.out.println(" v1"+v1);
dos=new ObjectOutputStream(soc.getOutputStream());
dos.writeObject(v1);
System.out.println(" v1 size"+v1.size());
System.out.println("path:"+path);
}
System.out.println("send v1");
}
else if(request.equals("portno"))
{
String nodes=(String)dis.readObject();
System.out.println("nodes:"+nodes);
rs=st.executeQuery("Select PortNo from nodeinformation where
NodeName='"+nodes+"' ");
if(rs.next())
{
//System.out.println("p:"+rs.getString(1));
port=Integer.parseInt(rs.getString(1));
}
port=Integer.parseInt(rs.getString(1));
}
rs=st.executeQuery("Select SystemName from nodeinformation where
NodeName='"+nodes+"' ");
if(rs.next())
{
ip=rs.getString(1);
}
dos=new ObjectOutputStream(soc.getOutputStream());
String p=String.valueOf(port);
System.out.println("p:"+p);
System.out.println("ip:"+ip);
dos.writeObject(p);
dos.writeObject(ip);
System.out.println("send 1");
}
else if(request.equals("neighbours"))
{
Vector nv=new Vector();
dis=new ObjectInputStream(soc.getInputStream());
String neigh=(String)dis.readObject();
rs=st.executeQuery("Select Neighbour from Connection where
NodeName='"+neigh+"'");
while(rs.next())
{
nv.addElement(rs.getString(1));
}
dos=new ObjectOutputStream(soc.getOutputStream());
dos.writeObject(nv);
}
else if(request.equals("path"))
{
Vector nv1=new Vector();
// dis=new ObjectInputStream(soc.getInputStream());
String neigh1=(String)dis.readObject();
rs=st.executeQuery("Select Neighbour from Connection where
NodeName='"+neigh1+"'");
while(rs.next())
{
nv1.addElement(rs.getString(1));
}
dos=new ObjectOutputStream(soc.getOutputStream());
dos.writeObject(nv1);
}
else if (request.equals("exit"))
{
dis=new ObjectInputStream(soc.getInputStream());
String nn=(String)dis.readObject();
System.out.println("z:"+nn);
st.executeUpdate( "update nodeinformation set PortNo='0' where
NodeName='"+nn+"'" );
}
else if(request.equals("user"))
{
dis=new ObjectInputStream(soc.getInputStream());
System.out.println("1");
String details=(String)dis.readObject();
System.out.println("2");
String z[]=details.split("&");
System.out.println("3");
rs=st.executeQuery("Select PortNo from nodeinformation where NodeName='"+z[0]+"'
");
if(rs.next())
{
//System.out.println("p:"+rs.getString(1));
number=Integer.parseInt(rs.getString(1));
}
if(number==0)
{
st.executeUpdate( "update nodeinformation set PortNo='"+z[2]+"' where
NodeName='"+z[0]+"'" );
System.out.println("4");
st.executeUpdate( "update nodeinformation set SystemName='"+z[1]+"' where
NodeName='"+z[0]+"'" );
System.out.println("5");
}
else
{
dos=new ObjectOutputStream(soc.getOutputStream());
dos.writeObject("entered");
}
}
else
{
dos=new ObjectOutputStream(soc.getOutputStream());
portno=portno+1;
String p=String.valueOf(portno);
System.out.println("p:"+p);
dos.writeObject(p);
System.out.println("send");
}
}
//UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
}
catch (Exception ex)
{
System.out.println("Failed loading L&F: ");
System.out.println(ex);
}
}
}
Peer connect
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.sql.*;
import java.util.*;
import java.net.*;
import java.io.*;
import javax.swing.border.*;
public class peerconnect extends JFrame
{
// Variables declaration
private JLabel jLabel1;
private JLabel jLabel2;
private JLabel jLabel3;
private JLabel jLabel4,jLabel5;
public peerconnect()
{
super();
initializeComponent();
this.setVisible(true);
}
jLabel2.setText("Peer Name");
jLabel3.setText("Source Node");
jLabel4.setText("Neighbour Node");
jLabel5.setText("Enter no of Nodes");
jButton1.setText("Submit");
jButton1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
{
if(i<=n)
{
jButton1_actionPerformed(e);
if(i==n-1)
{
connect();
jLabel3.setVisible(true);
jLabel4.setVisible(true);
jComboBox1.setVisible(true);
jComboBox2.setVisible(true);
jButton1.setEnabled(false);
jTextField1.setEnabled(false);
}
i++;
}
});
jButton2.setText("Clear");
jButton2.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
{
jTextField1.setText("");
jComboBox1.setSelectedItem("Select");
jComboBox2.setSelectedItem("Select");
}
});
jButton4.setText("Ok");
jButton4.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
{
try
{
String nodecount=jTextField5.getText();
n=Integer.parseInt(nodecount);
System.out.println("n:"+n);
if(n!=0)
{
jLabel2.setVisible(true);
jTextField1.setVisible(true);
jButton1.setEnabled(true);
jTextField5.setEnabled(false);
jButton4.setEnabled(false);
}
}
catch (Exception e1)
{
JOptionPane.showMessageDialog(null,"Please
Enter Value");
}
}
});
jButton3.setText("Cancel");
jButton3.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
{
dispose();
}
});
jButton5.setText("Connection");
jButton5.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
{
jButton5_actionPerformed(e);
}
});
jLabel2.setVisible(false);
jLabel3.setVisible(false);
jLabel4.setVisible(false);
jTextField1.setVisible(false);
jComboBox1.setVisible(false);
jComboBox2.setVisible(false);
jButton1.setEnabled(false);
contentPane.setLayout(null);
panel.setLayout(null);
addComponent(contentPane,panel, -5,-5,550,400);
addComponent(panel, jLabel2, 65,100,100,25);
addComponent(panel, jLabel3, 65,150,100,25);
addComponent(panel, jLabel4, 65,200,100,25);
addComponent(panel, jTextField1, 204,100,100,25);
addComponent(panel, jComboBox1, 204,150,100,25);
addComponent(panel,jComboBox2, 203,200,100,25);
addComponent(panel, jButton1, 400,85,100,50);
addComponent(panel, jButton2, 400,120,100,50);
addComponent(panel, jButton3, 400,155,100,50);
addComponent(panel, jButton5, 400,190,100,50);
addComponent(panel, jLabel5, 65,50,100,25);
addComponent(panel,jTextField5, 203,50,100,25);
nodename = jTextField1.getText();
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
cs=DriverManager.getConnection("jdbc:odbc:dcmp");
st=cs.createStatement();
rs= st.executeQuery("select * from NodeInformation where
NodeName LIKE '"+nodename+"' "); //OR SystemName LIKE '"+sysname+"'
if(rs.next())
{
JOptionPane.showMessageDialog(this,"The given Data already Exists");
i--;
}
else
{
values('"+nodename+"','0','127.0.0.1','ON')";
st.execute(query);
JOptionPane.showMessageDialog(this,"Registration Sucess fully
Completed");
jTextField1.setText("");
}
}
catch(Exception ee)
{
JOptionPane.showMessageDialog(this,"Specify the Correct
PortNo");
System.out.println("Connectivity Error");
ee.printStackTrace();
i--;
}
}
private void jButton5_actionPerformed(ActionEvent e)
{
try
{
node = (String)jComboBox1.getSelectedItem();
des = (String)jComboBox2.getSelectedItem();
System.out.println(""+node);
System.out.println(""+des);
if(node.equals("Select")||des.equals("Select"))
{
JOptionPane.showMessageDialog(this,"Specify the Nodes");
}
else if (node.equals(des))
{
JOptionPane.showMessageDialog(this,"Specify a Valid
Neighbour");
}
else
{
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
cs=DriverManager.getConnection("jdbc:odbc:dcmp");
st=cs.createStatement();
rs= st.executeQuery("select * from Connection where NodeName
LIKE '"+node+"' AND Neighbour LIKE '"+des+"'"); //OR SystemName LIKE
'"+sysname+"'
System.out.println("1");
if(rs.next())
{
JOptionPane.showMessageDialog(this,"The given Data already Exists");
}
else
{
String query = "insert into Connection
values('"+node+"','"+des+"','1','0')";
String query1= "insert into Connection
values('"+des+"','"+node+"','1','0')";
st.executeUpdate(query);
st.executeUpdate(query1);
JOptionPane.showMessageDialog(this,"Connection Information Completed");
}
}
catch(SQLException ee)
{
JOptionPane.showMessageDialog(this,"Connectivity Error");
System.out.println("Connectivity Error");
ee.printStackTrace();
}
}
catch (Exception e3)
{
JOptionPane.showMessageDialog(this,"Exception");
e3.printStackTrace();
}
}
public Vector connect()
{
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
cs=DriverManager.getConnection("jdbc:odbc:dcmp");
st=cs.createStatement();
ResultSet rs=st.executeQuery("select NodeName from NodeInformation");
totalpeer.add("Select");
while(rs.next())
{
totalpeer.addElement(rs.getString(1).trim());
System.out.println(""+totalpeer);
}
}
cs = DriverManager.getConnection("jdbc:odbc:dcmp");
st = cs.createStatement();
}
catch (Exception e)
{
e.printStackTrace();
}
return st;
}
public void getval()
{
try
{
connect();
rs = st.executeQuery("select path,delay from possiblepath");
while(rs.next())
{
val = Double.parseDouble(rs.getString(1));
System.out.println("\t"+val);
cel = Math.ceil(val);
flo = Math.floor(val);
System.out.println("\t"+cel+"\t"+flo);
ceil[i] = cel;
floor[i] = flo;
i++;
}
try
{
rs2 = st.executeQuery("select count(*) from possiblepath");
while(rs2.next())
{
count =Integer.parseInt(rs2.getString(1));
System.out.println("\t"+count);
}
}
catch (Exception ex1)
{
ex1.printStackTrace();
}
for (i=0;i<count;i++ )
{
try
{
rs2 = st.executeQuery("select count(*) from possiblepath");
while(rs2.next())
{
check =Integer.parseInt(rs2.getString(1));
System.out.println("\t"+check);
}
}
catch (Exception ex1)
{
ex1.printStackTrace();
}
System.out.println("inside for loop"+path[i]+"\t"+ceil[i]
+"\t"+floor[i]);
if (check%2 == 0)
{
st.executeUpdate("insert into pda values ('"+path[i]
+"','"+ceil[i]+"')");
}
else
{
st.executeUpdate("insert into pda values ('"+path[i]
+"','"+floor[i]+"')");
}
}
}
catch (Exception ex)
{
ex.printStackTrace();
}
}
}
SNAP SHOTS:
CONCLUSION
In this project, we presented DCMP, a protocol for distributed cycle minimization in
broadcast-based P2P systems. DCMP preserves the networks while eliminating most of
the duplicate messages. The overhead due to control messages is minimal. This results in
reduced response time, which, in turn, increases the scalability of the system. Our
protocol is suitable for dynamic networks since it handles peer joins/departures efficiently
and is resilient to failures.
FUTURE ENHANCEMENT
Service centric multicast protocol will be used in wireless network.