BR Mini Proj
BR Mini Proj
BR Mini Proj
SCHOOL OF COMPUTING
SHANMUGHA
ARTS, SCIENCE, TECHNOLOGY & RESEARCH ACADEMY
(SASTRA UNIVERSITY)
(A University Established under section 3 of the UGC Act, 1956)
TIRUMALAISAMUDRAM
THANJAVUR – 613402
November 2009
SHANMUGHA ARTS, SCIENCE, TECHNOLOGY &
RESEARCH ACADEMY
SASTRA UNIVERSITY
(A University Established under section 3 of the UGC Act, 1956)
TIRUMALAISAMUDRAM
THANJAVUR – 613402
SCHOOL OF COMPUTING
BONAFIDE CERTIFICATE
BRINDA.R
011014025
BACHELOR OF TECHNOLOGY
IN
ACKNOWLEDGEMENT
University, Prof Dr. R. Sethuraman, for giving me this opportunity for doing this
University, Prof Dr. S.N.Srivatsava , for giving me this opportunity for doing this
project.
project.
And I finally thank my Parents and Friends for their continued support throughout
SYNOPSIS
The project Scalable position based multicast is a routing protocol which
can be used for mobile adhoc networks. Here we use position of the nodes
It doesn’t need any distribution structure for maintaining the position only
the intermediate node needs to know that. First the network is created with
the no of nodes and the position determined with the help of the weight
as the sender and all others as receivers through the shortest path.
SYSTEM CONFIGURATION
HARDWARE CONFIGURATION
Processor : PENTIUM IV
Clock Speed : 2.0 GHz
RAM : 128.0MB
Hard Disk : 20GB
SOFTWARE CONFIGURATION:
programs written in the Java language must run similarly on any supported
Web browser for Java applets Standardized libraries provide a generic way
run more slowly than programs compiled to native executables would, and
Java suffered a reputation for poor performance. This gap has been
PURPOSE:
The purpose of this project is to create a protocol that can be used for
SCOPE:
MODULES:
3. Multicast forwarding
MODULES EXPLANATION:
1. CREATION OF NODES.
network. Then the weight values corresponding to the nodes are obtained
Here the group members are formed based on an threshold weight value.
The forwarding nodes must know the direction in which they reach the
destination.
3:MULTICAST FORWARDING.
Here the packets are multicasted through the shortest path. The neighbours
each have a copy of the packet. This helps in case of emergency.We assume
CREATION OF
NODES
SCALABLE
POSITION-BASED
MULTICAST
PROTOCOL
MULTICAST GROUP
FORWARDING MANAGEMENT
CONCLUSION
SAMPLE CODE
CODING:
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.nio.charset.Charset;
import javax.swing.JButton;
import javax.swing.JEditorPane;
import javax.swing.JLabel;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JSplitPane;
import javax.swing.JTextArea;
import javax.swing.JFileChooser;
import javax.swing.JTextField;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.Statement;
public class node_create extends JFrame implements ActionListener {
JLabel l1,l2,l3,l4,l5,l6,l7,l8,l9,l10;
JLabel y1,y2,y3,y4,y5,y6,y7,y8,y9;
String nodes_sel[]=new String[100];
String wt_sel[]=new String[100];
String possible[]={"AB","AC","BD","CE","EF","DG","DH","EI"};
int i,j,n;int p1,p2,flag,p4;
int no_of_node;
Container cp=getContentPane();
Connection conn =null;Statement st =null;
node_create(int m)
{
i=1;
no_of_node=m;
try{
conn = getConnection();
st = conn.createStatement();
st = conn.createStatement();
ResultSet rs = st.executeQuery("SELECT * FROM nodes");
while(rs.next())
{
nodes_sel[i]=rs.getString(2);
wt_sel[i]=rs.getString(3);System.out.println(nodes_sel[i]
+"====="+wt_sel[i]);
i++;
}
}catch(Exception h)
{
System.out.println(no_of_node);
cp.setLayout(null);
create_nodes(m);
setDefaultCloseOperation(EXIT_ON_CLOSE);
setTitle("ROUTING");
setVisible(true);
setSize(650,700);
y2.setText("10");y3.setText("10");y4.setText("10");
cp.add(l1);cp.add(l2);cp.add(l3);cp.add(l4);cp.add(l5);
}
if(n==10)
{
//y1.setText("10");y2.setText("10");y3.setText("10");y4.setText("10");y5.setT
ext("10");y6.setText("10");y7.setText("10");y8.setText("10");y9.setText("10");
cp.add(l1);cp.add(l2);cp.add(l3);cp.add(l4);cp.add(l5);cp.add(l6);cp.add(l7);cp.add(l8)
;cp.add(l9);cp.add(l10);
cp.add(y1);cp.add(y2);cp.add(y3);cp.add(y4);cp.add(y5);cp.add(y6);cp.add(y7);cp.ad
d(y8);cp.add(y9);
}
}
return ret;
}
// draw oval
g.setColor( new Color(0,0,0));
g.drawOval(50,75,75,75);
g.drawOval(150,75,75,75);
g.drawLine(75,20,60,130);
}
public static void main(String[] args) {
// node_create g1=new node_create();
}
PROGRAM:
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.nio.charset.Charset;
import javax.swing.JButton;
import javax.swing.JEditorPane;
import javax.swing.JLabel;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JSplitPane;
import javax.swing.JTextArea;
import javax.swing.JFileChooser;
import javax.swing.JTextField;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.Statement;
public class try1 extends JFrame implements ActionListener {
JLabel l1,l2,l3,l4,l5,l6,l7,l8,l9;
JLabel y1,y2,y3,y4,y5,y6,y7,y8,y9;
String a[]={"A","B","C","D","E","F","G","H","I","J","K","L","M"};
String a_selected[]=new String[100];
int i,j,n;int p1,p2,flag,p4;
JTextField t1=new JTextField();
JTextField t3=new JTextField();
JTextField t4=new JTextField();
JButton b1=new JButton("NO");
JButton b2=new JButton("CREATE");JButton b3=new JButton("YES");JButton
b4=new JButton("CREATE NETWORK");
JLabel j1=new JLabel("From----->To:");
public node_create nc=null;
JLabel sleep=new JLabel("No Of Node:");
JLabel wt=new JLabel("Weight Value:");
JTextField t2=new JTextField();
Connection conn =null;Statement st =null;
Container cp=getContentPane();
try1()
{
p1=p2=flag=p4=0;
try{
conn = getConnection();
st = conn.createStatement();
}catch(Exception h)
{
}
setDefaultCloseOperation(EXIT_ON_CLOSE);
setTitle("ROUTING");
sleep.setBounds(20,35,140,20);
t2.setBounds(150,35,100,20);
j1.setBounds(20,70,140,20);
t1.setBounds(150,70,100,20);
t3.setBounds(260,70,100,20);b1.setBounds(330,105,60,20);
b2.setBounds(260,35,90,20);b3.setBounds(260,105,60,20);b4.setBounds(400,105,150
,20);
wt.setBounds(20,105,140,20);t4.setBounds(150,105,100,20);
//designing network
cp.setLayout(null);
//l6.setBounds(450,240,20,20);
//l7.setBounds(150,240,20,20);
//create_nodes();
setVisible(true);
b1.addActionListener(this);
b2.addActionListener(this);
b3.addActionListener(this);
b4.addActionListener(this);
cp.add(j1);
cp.add(t1);
cp.add(b1);
cp.add(sleep);
cp.add(t2);
cp.add(b2);
cp.add(t3);
cp.add(wt);
cp.add(t4);
cp.add(b3);
//add(l1);add(l2);add(l3);add(l4);add(l5);
cp.add(b4);
cp.setSize(650,700);
}
public void actionPerformed(ActionEvent e)
{
String get=e.getActionCommand();
if(get=="CREATE")
{
String h=t2.getText().toString();
n=Integer.parseInt(h);
for(i=0;i<n;i++)
{
a_selected[i]=a[i];
System.out.println(a_selected[i]);
}
getdetail(0);
}
if(get=="YES")
{
//System.out.println(a_selected.length);
try{
String text1=t1.getText();String text2=t3.getText();
String text3=text1+text2;
String wt=t4.getText();
st.executeUpdate("insert into nodes (node,node_weight ) values
('"+text3+"','"+wt+"')");
t4.setText("");
}catch(Exception hji){}
if(p2==(n))
{
System.out.print("LLLLLL"+p2);
p4++;
getdetail(p4);
}
else if(n>p2)
{
t3.setText(a_selected[p2].toString());
p2++;System.out.print("LLLLLL"+p2);
}
}
if(get=="CREATE NETWORK")
{
cp.setVisible(false);
System.out.println("LLLLLLL="+n);
nc=new node_create(n);
}
if(get=="NO")
{
if(p2==(n))
{
System.out.print("LLLLLL"+p2);
p4++;
getdetail(p4);
}
else if(n>p2)
{
t3.setText(a_selected[p2].toString());
p2++;System.out.print("LLLLLL"+p2);
MULTICAST FORWARDING:
SOURCE:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.beans.*;
import java.io.*;
import java.awt.*;
import java.util.*;
import java.net.*;
getContentPane().setLayout(new BorderLayout());
getContentPane().add("Center", setupConsole());
getContentPane().add("South", m_status);
sendPanel.setLayout(new BorderLayout());
sendPanel.add("Center", m_chatText);
sendPanel.add("West", chatSend);
chatPanel.add("North", chatLabel);
chatPanel.add("Center", cscroller2);
chatPanel.add("South", sendPanel);
try {
m_server = new ServerSocket(5000,500); //creating socket ...........
}
catch (Exception e) {
m_status.setText(""+e);
m_consoletext.append("\n"+e);
}
m_conthread = new ConThread(); //calling the thread method...................
return console;
}
public void keepSending(int i) { ///in keep sending get the message from
textbox.........
try {
for (; i < m_count; i++) {
ServerConnection con =
(ServerConnection)connectionList.get(i);
con.sendMessage("cc" + m_chatText.getText());
}
}
catch (Exception ex) {
connectionList.remove(i);
m_count--;
keepSending(i);
}
}
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.beans.*;
import java.io.*;
import java.awt.*;
import java.net.*;
public TheXClient() {
setTitle("The X Client");
m_count = 0;
m_status = new JLabel("Not Connected");
////////////////////////////////////////////////////////////////////////////////////////////////////
m_connect.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
if (m_listenthread == null)
{
Thread connector = new Thread()
{
public void run()
{
try {
m_consoletext.append("\nTrying " + m_text.getText() +
" ... ");
m_client = new
Socket(InetAddress.getByName(""), 5000);
m_input = new DataInputStream(m_client.getInputStream());
m_output = new DataOutputStream(m_client.getOutputStream());
m_connected = true;
m_listenthread = new Thread(TheXClient.this);
m_listenthread.start();
m_consoletext.append("\nStreams established ... ");
m_status.setText("Connected to " + m_text.getText());
m_connect.setEnabled(false);
}
catch (Exception e)
{
m_consoletext.append("\n" + e);
}
}
};
connector.start();
}
}
}); //////////////////////////////////////////////////////////////////////////
getContentPane().setLayout(new BorderLayout());
getContentPane().add("North", upperPanel);
getContentPane().add("Center", setupConsole());
getContentPane().add("South", m_status);
sendPanel.setLayout(new BorderLayout());
sendPanel.add("Center", m_chatText);
sendPanel.add("West", chatSend);
chatPanel.add("North", chatLabel);
chatPanel.add("Center", cscroller2);
chatPanel.add("South", sendPanel);
return console;
}
SAMPLE OUTPUTS
NODES CREATION.
GROUP FORMATION.
WEIGHT VALUES
MULTICASTING.
SENDER
MULTICASTING.
RECEIVER
CONCLUSION
It is shown that the packets are forwarded through the shortest path. sent.
This project thus implemented the multicast protocol. The network has been
created and all the modules have been finished successfully. And the group
members each receive a copy of the packet. The project is thus completed
successfully.
BIBLIOGRAPHY
WEBSITE:
WWW.WIKIPEDIA.ORG
WWW.ROSEINDIA.COM