dcmp final full document
DESCRIPTION
dcmpTRANSCRIPT
DCMP: A DISTRIBUTED CYCLE MINIMIZATION
PROTOCOL FOR PEER-TO-PEER NETWORKS
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
LIMITATIONS OF THE EXITING SYSTEM
Introduce numerous duplicate messages in the system
It consume a large proportion of the bandwidth and other resources
It causes bottlenecks in the entire network.
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
ADVANTAGE OF PROPOSED SYSTEM
Preserve the fault resilience and load balancing
It avoid duplicate messages and repeated messages
It reduce number of cycle per transaction
HARDWARE REQUIREMENTS
Processor/system : Pentium IV
Main memory : 512 MB RAM
Cache memory : 512 KB
Processor speed : 600 MHz
Keyboard : 101 keys
Hard disk drive : 40 GB
SOFTWARE REQUIREMENTS
Operating system : Windows 2000 and above
Front end designing Tool : 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
of a graphical user interface (GUI). While it is often useful to develop
programs using GUI-state model separation -- particularly if multiple GUI
controls are linked to a common state (such as in a shared whiteboard
program), or if manipulating one control automatically changes the value of
another -- the use of GUI-state models is not required by Swing. It is
possible to manipulate the state of a GUI control through top-level methods
on the component, without any direct interaction with the model at all. In the
preceding table, GUI-state models in Swing are highlighted in blue.
Application-data models
An application-data model is an interface that represents some quantifiable
data that has meaning primarily in the context of the application, such as the
value of a cell in a table or the items displayed in a list. These data models
provide a very powerful programming paradigm for Swing programs that
need a clean separation between their application data/logic and their GUI.
For truly data-centric Swing components, such as JTree and JTable,
interaction with the data model is strongly recommended. Application-data
models are highlighted in red in the table presented at the beginning of this
section.
User Interface Requirements
Client: Client is the user of the system who directly interacts with the
system. In a distributed network, all clients maintain a peer-peer relationship
between each other.
GUI: Interfaces that use graphics came to be known as Graphical User
Interface (GUI). A GUI interacts with the user by showing some graphics
and asking for any inputs when needed.
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.
Import java.net: Provides the classes for implementing networking
applications.
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.
Data Flow Diagram
User login[login
DB
No of nodes
Name the nodes Construct network
Select file
Selection process
Send to neighbor
IC Message
Validate GUID , DID
Receive Message
Cut Message
nodes
Validate GUID , DID
Find possible path
Eliminate path
DB
Control Flow Diagram
user DB
No of nodes
Name the nodes
Send to neighborneighbour neighbour
Construct network
login
IC msg
Validate N for connection disabling
Validate recommendation GUID, DID
Cut Message
DB
Nodes
A A
Receive
Find possible path
Compare GUID, DID
Eliminate path
DB
A
E-R Diagram
Node information
Node name
Port noSys. name
status
connect
connection
delay
Cost neighbour
Node name
path Possible path
delay
path
destination
cost
Pda
delay
path
nodecost
Page Design
USER LOGIN
Login Clear
Password
User Name
Enter no of nodes
OK
Submit
Connection
Clear
Cancel
Peer network
Enter no of nodes
Peer Name
OK
Submit
Connection
Clear
Cancel
Peer Network
Enter no of nodes
Peer Name
OK
Submit
Connection
Clear
CancelNeighbor node
Source Node
Peer Network
User Name
User Login Clear
Peer Login
Select File
Select File
Send
Leave
View Record
Cut Message
Peer A
Clear Cancel
View Record
Clear Cancel
Data base design:
Table name : Connection
Field Data Type
Node name Var char(20)
Neighbor Var char(20)
Cost decimal
delaydecimal
Table name : node information
Field Data Type
Node name Var char(20)
Port number numeric
System name Var char(20)
status
Table name : Possible path
Field Data Type
destination Var char(20)
path Var char(20)
Cost Decimal
delayDecimal
Table name : pda
Field Data Type
path Var char (20)
Cost Var char(20)
delay Var char(20)
nodeVar 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. Functional tests
2. Performance tests
3. Stress tests
4. Structure tests
1. 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. Performance testing determines the amount of execution time spent in
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, performance an stress testing as “black box”
testing, while structure testing is refer as “white box” or “glass box”
testing.
INTEGRATION TESTING:
Bottom –up integration is the traditional strategy used to integrate
components of a software system into a functioning whole. Bottom-up
integration consists of unit testing, followed by subsystem testing, followed
by testing of the entire system.
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.
System testing is concerned with subtleties in the interfaces, decision logic,
control-flow, recovery procedures, throughput, capacity, and timing
characteristics of the entire system.
ACCEPTANCE TESTING:
Acceptance testing involves planning and execution of functional tests,
performance tests, and stress tests in order to demonstrate that the
implemented system satisfies its requirements. In addition to functional and
performance tests, stress tests are performed to determine the limitations of
the system.
Above testing’s are performed in our projects.
SOURCE CODE:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.net.*;
/**
* Summary description for userlogin
*
*/
public class userlogin extends JFrame
{
public static ServerSocket ssoc1;
public static Socket sousoc1,ss1;
// Variables declaration
private JLabel userlabel;
private JLabel jLabel2;
private JLabel jLabel3;
private JLabel jLabel4;
private JLabel jLabel5;
private JTextField userfield;
private JPasswordField jPasswordField1;
private JButton userlogin;
private JButton clear;
private JPanel contentPane;
// End of variables declaration
static system1 pe1;
public static String username="";
static int n;
public userlogin() throws Exception
{
super();
initializeComponent();
this.setVisible(true);
}
private void initializeComponent()
{
userlabel = new JLabel();
jLabel2 = new JLabel();
jLabel3 = new JLabel();
jLabel4 = new JLabel();
jLabel5 = new JLabel();
userfield = new JTextField();
jPasswordField1 = new JPasswordField();
userlogin = new JButton();
clear = new JButton();
contentPane = (JPanel)this.getContentPane();
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("");
}
public static void main(String[] args)
{
JFrame.setDefaultLookAndFeelDecorated(true);
JDialog.setDefaultLookAndFeelDecorated(true);
try
{
pe1=new system1();
new userlogin();
n=pe1.connection();
System.out.println("server port:"+n);
ssoc1=new ServerSocket(n);
while(true)
{
ss1=ssoc1.accept();
pe1.receiver();
}
}
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());
for( int i=0;i<j;i++)
{
String path= find.bestcost(4,a[i]);
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));
}
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("port"))
{
System.out.println("1");
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));
}
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");
}
}
public static void main(String[] args)
{
JFrame.setDefaultLookAndFeelDecorated(true);
JDialog.setDefaultLookAndFeelDecorated(true);
try
{
sersoc=new ServerSocket(1500);
m=new peernetwork();
while(true)
{
soc=sersoc.accept();
m.listen();
}
//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;
private JTextField jTextField1;
private JComboBox jComboBox1;
private JComboBox jComboBox2;
private JTextField jTextField5;
private JButton jButton1;
private JButton jButton2;
private JButton jButton3;
private JButton jButton4,jButton5;
private JPanel contentPane;
private JPanel panel;
public Runtime r;
int n;
int i=0;
int portno;
String nodename = "",node,des;
String sysname = "";
ResultSet rs;
Connection cs;
Statement st;
Font font = new Font("TimesRoman",Font.PLAIN,20);
public Vector totalpeer = new Vector();
// End of variables declaration
public peerconnect()
{
super();
initializeComponent();
this.setVisible(true);
}
public void initializeComponent()
{
jLabel1 = new JLabel();
jLabel2 = new JLabel();
jLabel3 = new JLabel();
jLabel4 = new JLabel();
jLabel5 = new JLabel();
panel=new JPanel();
jTextField1 = new JTextField();
jTextField5 = new JTextField();
jButton1 = new JButton();
jButton2 = new JButton();
jButton3 = new JButton();
jButton4 = new JButton();
jButton5 = new JButton();
jComboBox1 = new JComboBox(totalpeer);
jComboBox2 = new JComboBox(totalpeer);
contentPane = (JPanel)this.getContentPane();
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);
addComponent(panel, jButton4, 400,50,100,41);
panel.setBackground(new Color(120, 155, 55));
Border etched=BorderFactory.createEtchedBorder();
Border border=BorderFactory.createTitledBorder(etched,"Peer
Registration",TitledBorder.LEFT,TitledBorder.DEFAULT_JUSTIFICATION,font,Color.
blue);
panel.setBorder(border);
this.setTitle("Peer Network");
this.setLocation(new Point(100, 100));
this.setSize(new Dimension(550, 400));
this.setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
this.setResizable(false);
}
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 jButton1_actionPerformed(ActionEvent e)
{
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
{ String query = "insert into NodeInformation
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);
}
}
catch (Exception ex)
{
ex.printStackTrace();
}
return totalpeer;
}
}
Route
import java.sql.*;
import java.sql.Connection.*;
import java.net.*;
class pda
{
public Connection cs;
public Statement st;
public ResultSet rs,rs1,rs2;
double val;
double cel,flo;
int i,count = 0,check = 0;
double ceil[] = new double[10];
double floor[] = new double[10];
String path[] = new String[10];
public Statement connect() throws Exception
{
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
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.