BR Mini Proj

Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 35

SCALABLE POSITION BASED MULTICAST FOR

MOBILE ADHOC NETWORKS

Mini project report submitted in partial fulfillment for the


requirement of award of
B.Tech Degree in Information and Communication Technology
By
BRINDA.R
011014025

Under the Guidance of


Mr.B.THAMOTHARAN
Assistant professor

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

This is to certify that the Mini Project entitled


SCALABLE POSITION BASED MULTICAST FOR
MOBILE ADHOC NETWORKS
is a work done by

BRINDA.R
011014025
BACHELOR OF TECHNOLOGY
IN

INFORMATION AND COMMUNICATION TECHNOLOGY OF


SASTRA UNIVERSITY , Thanjavur during the year 2008-2009

Internal Guide Dean, School of computing

Submitted for the university examination held on:


Internal Examiner External Examiner

ACKNOWLEDGEMENT

I would like to deliver my sincere thanks to the Vice Chancellor of SASTRA

University, Prof Dr. R. Sethuraman, for giving me this opportunity for doing this

Mini project as a part of the university program.

I would also like to deliver my sincere thanks to the Registrar of SASTRA

University, Prof Dr. S.N.Srivatsava , for giving me this opportunity for doing this

Mini project as a part of the university program.

I would also like to thank Prof. P. Kalyanaraman, Dean, School of Computing

and Prof Dr .K . S. Ravichandran, Head of the Department, Information &

Communication Technology, for their support and assistance for my mini

project.

I would also like to thank my project guide, Mr.B.Thamotharan

School of Computing, for his guidance in the successful completion of this

project.

I also extend my gratefulness to my Reviewers whose constant support in the

completion of the mini project.

And I finally thank my Parents and Friends for their continued support throughout

the course of my mini project.


CONTENTS

S.NO NAME OF THE TOPIC PAGE NO


1. SYNOPSIS 05
2. SYSTEM CONFIGURATION 06
3. OVERVIEW OF PROJECT PLATFORM 07
4. PROJECT DESCRIPTION 08
5. SYSTEM FLOW DIAGRAMS 11
6. SAMPLE CODE 12
7. SAMPLE OUTPUT(SNAPSHOTS) 25
8. CONCLUSION 29
9. BIBLIOGRAPHY 30

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

and group membership scheme to forward packets to multiple destinations.

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

values. Then it is multicasted to multiple destinations considering one node

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:

Operating System : WINDOWS X P


Programming Language : JAVA (JDK1.6)

OVERVIEW OF PROJECT PLATFORM


JAVA PLATFORM

One characteristic of Java is portability, which means that computer

programs written in the Java language must run similarly on any supported

hardware/operating-system platform. This is achieved by compiling the Java

language code to an intermediate representation Called java byte code,

instead of directly to platform-specific machine code. Java byte code

instructions are analogous to machine code, but are intended to be

interpreted by a virtual machine (VM) written specifically for the host

hardware. End users commonly use a Java Runtime Environment (JRE)

installed on their own machine for standalone Java applications, or in a

Web browser for Java applets Standardized libraries provide a generic way

to access host-specific features such as graphics, threading and

networking. A major benefit of using byte code is porting. However, the

overhead of interpretation means that interpreted programs almost always

run more slowly than programs compiled to native executables would, and

Java suffered a reputation for poor performance. This gap has been

narrowed by a number of optimization techniques introduced in the more

recent JVM implementations. The important feature JAVA EXCEPTION is

thrown whenever an exception occurs. The JAVA GUI(graphic user

interface) is also implemented.


PROJECT DESCRIPTION

PURPOSE:
The purpose of this project is to create a protocol that can be used for

forwarding packets in mobile adhoc networks. Position of the nodes and

formation of the group is calculated first and then multicasting is done.

SCOPE:

The scope of the project is to explain the implementation of the SCALABLE

POSTION BASED MULTICAST PROTOCOL in such a way that packet

transfer is done in a secured and reliable way through the shortest

MODULES:

1. Creation of the nodes.

2. Formation of group members.

3. Multicast forwarding
MODULES EXPLANATION:

1. CREATION OF NODES.

In this module we create the nodes which are to be present in the

network. Then the weight values corresponding to the nodes are obtained

and stored in the database.

2: FORMATION OF GROUP MEMBERS.

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

one node as the sender and all others as receivers


SYSTEM FLOW DIAGRAM.

CREATION OF
NODES

SCALABLE
POSITION-BASED
MULTICAST
PROTOCOL

MULTICAST GROUP
FORWARDING MANAGEMENT

CONCLUSION
SAMPLE CODE

CODING:

1.CREATION OF NODES AND GROUP MEMBERS

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);

public void actionPerformed(ActionEvent e)


{
}

public void create_nodes(int n)


{
l1=new JLabel();l2=new JLabel();l3=new JLabel();l4=new JLabel();l5=new
JLabel();
l6=new JLabel();l7=new JLabel();l8=new JLabel();l9=new JLabel();l10=new
JLabel();
y1=new JLabel();y2=new JLabel();y3=new JLabel();y4=new JLabel();y5=new
JLabel();y6=new JLabel();
y7=new JLabel();y8=new JLabel();y9=new JLabel();
l1.setBounds(300,50,20,20);l1.setText("A");y1.setBounds(200,75,20,20);
l2.setBounds(160,150,20,20);l2.setText("B");y2.setBounds(375,75,20,20);
l3.setBounds(450,150,20,20);l3.setText("C");y3.setBounds(140,200,20,20);
l4.setBounds(160,250,20,20);l4.setText("D");y4.setBounds(470,200,20,20);
l5.setBounds(450,250,20,20);l5.setText("E");y5.setBounds(520,270,20,20);
l6.setBounds(550,350,20,20);l6.setText("F");y6.setBounds(90,300,20,20);
l7.setBounds(60,400,20,20);l7.setText("G");y7.setBounds(210,320,20,20);
l8.setBounds(200,400,20,20);l8.setText("H");y8.setBounds(370,320,20,20);
l9.setBounds(370,400,20,20);l9.setText("I");y9.setBounds(330,450,20,20);
l10.setBounds(350,500,20,20);l10.setText("J");
if(n==5)
{
for(int j=1;j<i;j++)
{
int h=assign_wt(nodes_sel[j]);
System.out.println("H="+h);
if(h==1)
{}
if(h==2)
{}
if(h==3)
{}
if(h==4)
{}
if(h==5)
{}
if(h==6)
{}
if(h==7)
{}
if(h==8)
{}
if(h==9)
{}
}

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);
}
}

public int assign_wt(String par1)


{
int ret=0;
System.out.println(par1);
for(int j=0;j<i;j++)
{
if(par1==possible[j])
{
ret=j;
System.out.println("POSITION"+j);
}
}

return ret;
}

private static Connection getConnection() throws Exception {


String driver = "sun.jdbc.odbc.JdbcOdbcDriver";
String url = "jdbc:odbc:database";
String username = "";
String password = "";
Class.forName(driver);
return DriverManager.getConnection(url, username, password);
}

public void paint(Graphics g)


{

// call superclass version of method paint


super.paint( g );

// 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);

public void create_nodes()


{

l1=new JLabel();l2=new JLabel();l3=new JLabel();l4=new JLabel();l5=new


JLabel();
l1.setBounds(300,200,20,20);l1.setText("A");
l2.setBounds(160,300,20,20);l2.setText("B");
l3.setBounds(450,300,20,20);l3.setText("C");
l4.setBounds(160,400,20,20);l4.setText("D");
l5.setBounds(450,400,20,20);l5.setText("E");
cp.add(l1);cp.add(l2);cp.add(l3);cp.add(l4);cp.add(l5);
}

private static Connection getConnection() throws Exception {


String driver = "sun.jdbc.odbc.JdbcOdbcDriver";
String url = "jdbc:odbc:database";
String username = "";
String password = "";
Class.forName(driver);
return DriverManager.getConnection(url, username, password);
}
public void getdetail(int p3)
{
System.out.println("P3="+p3);
t2.setEnabled(false);b2.setEnabled(false);
if(p3+1!=n)
{
t1.setText(a_selected[p3].toString());
System.out.println(a_selected[p3].toString());
t3.setText(a_selected[p3+1].toString());
System.out.println(a_selected[p3+1].toString());
p2=p3+2;
}
else
{
t1.setEnabled(false);t3.setEnabled(false);
b1.setEnabled(false);b3.setEnabled(false);
t4.setEnabled(false);
}
}

public static void main(String[] args) {


try1 g=new try1();

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.*;

public class MyXServerAdvanced extends JFrame implements ActionListener {

private ArrayList connectionList = new ArrayList();


protected JLabel m_status;
protected JTextArea m_consoletext, m_consolechat;
protected JTextField m_chatText;

protected static int m_count;


protected static ConThread m_conthread;
protected static ServerSocket m_server;
protected static Socket m_client;
public MyXServerAdvanced() {
setTitle("The X Server");
m_count = 0; /// m_count into constructor method..........
m_status = new JLabel("No Client");
JScrollPane scroller = new JScrollPane();

getContentPane().setLayout(new BorderLayout());
getContentPane().add("Center", setupConsole());
getContentPane().add("South", m_status);

Dimension dim = getToolkit().getScreenSize();


setSize(520,350);
setLocation(dim.width/2-getWidth()/3, dim.height/2-getHeight()/2);

WindowListener l = new WindowAdapter() {


public void windowClosing(WindowEvent e) { System.exit(0); }
};
addWindowListener(l);
setVisible(true);
}

public JInternalFrame setupConsole() { // copy the socket coding


from here..............
JInternalFrame console = new JInternalFrame ("The X Server",
false, false, false, false);
console.setBounds(2, 2, 500, 300);
console.setVisible(true);

JPanel chatPanel = new JPanel();


JLabel chatLabel = new JLabel(" CHAT ");
chatPanel.setLayout(new BorderLayout());

m_consoletext = new JTextArea();


m_consoletext.setPreferredSize(new Dimension(500, 50));
m_consoletext.setLineWrap(true);
m_consoletext.setText("Server Started.\nWaiting for client ...");
m_consoletext.setEditable(false);

m_consolechat = new JTextArea();


m_consolechat.setLineWrap(true);
m_consolechat.setEditable(false);

m_chatText = new JTextField();


m_chatText.addActionListener(this);

JButton chatSend = new JButton("Send");


chatSend.addActionListener(this); //here the button event
JPanel sendPanel = new JPanel();

sendPanel.setLayout(new BorderLayout());
sendPanel.add("Center", m_chatText);
sendPanel.add("West", chatSend);

JScrollPane cscroller1 = new JScrollPane(m_consoletext);


JScrollPane cscroller2 = new JScrollPane(m_consolechat);

chatPanel.add("North", chatLabel);
chatPanel.add("Center", cscroller2);
chatPanel.add("South", sendPanel);

JSplitPane splitter = new JSplitPane(JSplitPane.VERTICAL_SPLIT,


true, cscroller1, chatPanel);
console.getContentPane().add(splitter);

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 processMessage(String s) {


if (s.startsWith("cc")) {
m_consolechat.append("CLIENT: " + s.substring(2) + "\n");
m_consolechat.setCaretPosition(m_consolechat.getText().length());
}
}

public void actionPerformed(ActionEvent e) {


int i = 0;
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);
}
m_consolechat.append("SERVER: " + m_chatText.getText() + "\n");
m_chatText.setText("");
}

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);
}
}

class ConThread extends Thread {


ConThread() { start(); }
public void run() {
while (true) {
try {
m_client = m_server.accept();
ServerConnection newCon = new ServerConnection(m_client,
new DataInputStream(m_client.getInputStream()),
new DataOutputStream(m_client.getOutputStream()),"CLIENT" + m_count++);
connectionList.add(newCon);
m_consoletext.append("\nStreams established ... \nClient Connected from: " +
m_client.getInetAddress());
m_status.setText("New Client Connected from: " +
m_client.getInetAddress());
}
catch (Exception e) {
m_status.setText("" + e);
m_consoletext.append("\n" + e);
}
}
}
}

class ServerConnection extends Thread {

protected String TAG;


protected Socket m_clients;
protected Thread m_listenthread;
protected DataInputStream m_input;
protected DataOutputStream m_output;
ServerConnection(Socket sock, DataInputStream in, DataOutputStream
out, String tag) {
m_clients = sock;
m_input = in;
m_output = out;
m_listenthread = new Thread(ServerConnection.this);
m_listenthread.start();
TAG = tag;
}

public void run() {


while (true) {
try {
String s = m_input.readUTF();
if (s.startsWith("cc")) {
m_consolechat.append(TAG + ": " + s.substring(2) + "\n");
m_consolechat.setCaretPosition(m_consolechat.getText().length());
}
}
catch (Exception e) { m_status.setText("" + e); }
}
}

public void sendMessage(String s) throws Exception


{
m_output.writeUTF(s);
}

public static void main(String[] args) { new MyXServerAdvanced(); }


}
RECEIVER CODE:

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.beans.*;
import java.io.*;
import java.awt.*;
import java.net.*;

public class TheXClient extends JFrame implements Runnable {

protected int m_count;


protected JButton m_connect;
protected JTextArea m_consoletext, m_consolechat;
protected JTextField m_text, m_chatText;;
protected boolean m_connected;
protected JLabel m_status;
protected DataInputStream m_input;
protected DataOutputStream m_output;
protected Socket m_client;
protected Thread m_listenthread;

public TheXClient() {
setTitle("The X Client");
m_count = 0;
m_status = new JLabel("Not Connected");

m_connect = new JButton("Connect");

////////////////////////////////////////////////////////////////////////////////////////////////////
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();
}
}
}); //////////////////////////////////////////////////////////////////////////

JPanel XPanel = new JPanel();


XPanel.setLayout(new BorderLayout());
JLabel h1 = new JLabel("Connect to: ", SwingConstants.CENTER);
m_text = new JTextField(15);
XPanel.add("North", h1);
XPanel.add("Center", m_text);
XPanel.add("East", m_connect);

JPanel upperPanel = new JPanel();


upperPanel.setLayout(new BorderLayout());
upperPanel.add("Center", XPanel);

getContentPane().setLayout(new BorderLayout());
getContentPane().add("North", upperPanel);
getContentPane().add("Center", setupConsole());
getContentPane().add("South", m_status);

Dimension dim = getToolkit().getScreenSize();


setSize(520,400);
setLocation(dim.width/2-getWidth()/3, dim.height/2-getHeight()/2);
WindowListener l = new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
};
addWindowListener(l);
setVisible(true);
}

public JInternalFrame setupConsole() {


JInternalFrame console = new JInternalFrame ("The X Client",
false, false, false, false) {
int TAG = m_count;
public String toString() {
return "" + TAG;
}
};
console.setBounds(2, 2, 500, 300);
console.setVisible(true);

JPanel chatPanel = new JPanel();


JLabel chatLabel = new JLabel(" CHAT ");
chatPanel.setLayout(new BorderLayout());

m_consoletext = new JTextArea();


m_consoletext.setPreferredSize(new Dimension(500, 50));
m_consoletext.setLineWrap(true);
m_consoletext.setText("Client Started ...");
m_consoletext.setEditable(false);

m_consolechat = new JTextArea();


m_consolechat.setLineWrap(true);
m_consolechat.setEditable(false);

m_chatText = new JTextField();


m_chatText.addActionListener(new ChatAdapter());

JButton chatSend = new JButton("Send");//////////////////////////////////


chatSend.addActionListener(new ChatAdapter());////////////////////////////////////

JPanel sendPanel = new JPanel();

sendPanel.setLayout(new BorderLayout());
sendPanel.add("Center", m_chatText);
sendPanel.add("West", chatSend);

JScrollPane cscroller1 = new JScrollPane(m_consoletext);


JScrollPane cscroller2 = new JScrollPane(m_consolechat);

chatPanel.add("North", chatLabel);
chatPanel.add("Center", cscroller2);
chatPanel.add("South", sendPanel);

JSplitPane splitter = new JSplitPane(JSplitPane.VERTICAL_SPLIT,


true, cscroller1, chatPanel);
console.getContentPane().add(splitter);

return console;
}

public void run() {


while (m_connected) {
try {
processMessage(m_input.readUTF());
}
catch (Exception e) {
m_consoletext.append("\n" + e);
m_connected = false;
}
}
}

public void processMessage(String s) {


if (s.startsWith("cc")) {
m_consolechat.append("SERVER: " + s.substring(2) + "\n");
m_consolechat.setCaretPosition(m_consolechat.getText().length());
}
else
System.out.println("well .. i can't imagine why im here");
}

public void sendMessage(String s) {


try {
if (m_output != null)
m_output.writeUTF(s);
}
catch (Exception e) {}
}

public static void main(String[] args) {


new TheXClient();
}

class ChatAdapter implements ActionListener


{
public void actionPerformed (ActionEvent e) {
sendMessage("cc" + m_chatText.getText());
m_consolechat.append("Client: " + m_chatText.getText() + "\n");
m_chatText.setText("");
}
}
}

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

1. Transier and Maltz. Position based multicast


networks. In Proceedings of MOBICOM, pages 139{150,
July 2001.
2. [1] David F. Bantz and Fr´ed´eric J. Bauchot. Wireless LAN design
alternatives. IEEE Network, 8(2):43–53,
March/April 1994.
[2] Vaduvur Bharghavan, Alan Demers, Scott Shenker, and Lixia Zhang.
MACAW: A media access protocol for
wireless LAN’s. In Proceedings of the SIGCOMM ’94 Conference on
Communications Architectures, Protocols
and Applications, pages 212–225, August 1994.
[3] Robert T. Braden, editor. Requirements for Internet hosts—
communication layers. Internet Request For
Comments RFC 1122, October 1989.
[4] Roy C. Dixon and Daniel A. Pitt. Addressing, bridging, and source
routing. IEEE Network, 2(1):25–32, January
1988.
[5] Deborah Estrin, Daniel Zappala, Tony Li, Yakov Rekhter, and Kannan
Varadhan. Source Demand Routing:
Packet format and forwarding specification (version 1

WEBSITE:
WWW.WIKIPEDIA.ORG

WWW.ROSEINDIA.COM

You might also like