Академический Документы
Профессиональный Документы
Культура Документы
Maximizing the Number of Broadcast Operations in Random Geometric Ad Hoc Wireless Networks
Page 1
CHAPTER 1
INTRODUCTION
1.1.
GENERAL
The main goal of our project is to send the data from the server to the nodes by packet format in broadcasting manner, so through this broadcasting we can transfer the full data to the node and can avoid the data loss in transmitting.
1.2. OBJECTIVE The main objective of our project is to reduce the data loss at transmission and send the data to the client in effective manner. 1.3 EXISTING SYSTEM In static ad hoc wireless networks, nodes have the ability to vary their transmission ranges (and thus, their energy consumption) in order to provide good network connectivity and low energy consumption at the same time. More precisely, the transmission ranges determine a (directed) communication graph over the set V of nodes. Indeed, a node v, with range r, can transmit to another node w if and only if w belongs to the disk of radius r centered in v. The transmission range of a node depends, in turn, on the energy power supplied to the node. In particular, the power Pv required by a node v to correctly transmit data to another station w must satisfy the inequality .
Maximizing the Number of Broadcast Operations in Random Geometric Ad Hoc Wireless Networks
Page 2
Maximizing the Number of Broadcast Operations in Random Geometric Ad Hoc Wireless Networks
Page 3
Reference paper:A. Ephremides, G.D. Nguyen, and J.E. Wieselthier, On the Construction of Energy-Efficient Broadcast and Multicast Trees in Wireless Networks,
Description:The wireless networking environment presents formidable challenges to the study of broadcasting and multicasting problems. After addressing the characteristics of wireless networks
that distinguish them from wired networks, algorithm is developed for tree construction in infrastructure less, all-wireless applications. The Broadcast Incremental Power Algorithm had been developed and adapted it to multicast and broadcast operations. This algorithm exploits the broadcast nature of the wireless communication environment, and addresses the need for energy-efficient operation. In this paper, some of the fundamental issues associated with energy-efficient broadcasting and multicasting in infrastructure less wireless networks had been identified. It had presented a crucial difference between wired and wireless networks In particular, the Broadcast Incremental Power (BIP) Algorithm, which exploits the wireless multicast advantage, provides better performance than the other algorithms.
Reference paper:I. Kang and R. Poovendran, Maximizing Network Lifetime of Wireless Broadcast Ad Hoc Networks,
Description:This paper describes the problem of energy-efficient broadcast routing over wireless static adhoc network where host mobility is not involved. We define the lifetime of a network as the duration of time until the first node failure due to battery depletion. We provide a globally optimal solution to the problem of maximizing a static network lifetime through a graph theoretic approach. We also provide extensive comparative simulation studies. The objective in this paper is to construct a broadcast routing tree rooted at the source node with the longest possible lifetime. In broadcast routing, a message originating from the source node should reach every destination node. The lifetime of a network is defined as the duration of time until the first node failure due to battery exhaustion.
Maximizing the Number of Broadcast Operations in Random Geometric Ad Hoc Wireless Networks
Page 4
CHAPTER 3
REQUIREMENTS ENGINEERING
3.1 GENERAL
Using this requirements the here in this paper we send the message to the client through the pivot node after scheduling.
The hardware requirements may serve as the basis for a contract for the implementation of the system and should therefore be a complete and consistent specification of the whole system. They are used by software engineers as the starting point for the system design. It should what the system do and not how it should be implemented.
: : : : : : :
PENTIUM IV 2.6 GHz,Intel Core 2 Duo. 512 MB DD RAM 15 COLOR 40 GB LG 52X STANDARD 102 KEYS 3 BUTTONS
Page 5
Maximizing the Number of Broadcast Operations in Random Geometric Ad Hoc Wireless Networks
1.3SOFTWARE REQUIREMENTS
The software requirements document is the specification of the system. It should include both a definition and a specification of requirements. It is a set of what the system should do rather than how it should do it. The software requirements provide a basis for creating the software requirements specification. It is useful in estimating cost, planning team activities, performing tasks and tracking the teams and tracking the teams progress throughout the development activity.
FRONT END
JSP
BACK END
SQL SERVER
Maximizing the Number of Broadcast Operations in Random Geometric Ad Hoc Wireless Networks
Page 6
Maximizing the Number of Broadcast Operations in Random Geometric Ad Hoc Wireless Networks
Page 7
CHAPTER 2
2.3 METHODOLOGIES
Methodologies are the process of sending the requested resources and task from client to the server through the chargeable node.
Maximizing the Number of Broadcast Operations in Random Geometric Ad Hoc Wireless Networks
Page 8
The following are the 5 modules involves in Maximizing broadcast in the network
MODULES: User interface Network Creation Server implementation Pivot node implementation Broadcast Scheduling algorithm
MODULE DESCRIPTION:
User Interface
In this module we create a user page using GUI, which will be the media to Connect user with the server and through which client can able to give request to the server and server can send the response to the client, through this module we can establish the communication between client and server. Before client creation we check the user credential her by login page, we receive the username and password by the user and we will check in the database is that user have the credential or not to give request to the server. Here also we can add new user through user registration by taking all the important details like users name, gender, username, password, address, email id, phone no from the user.
Network creation:
In this module we designed a network where we can create all client, server and how many node we want we can create dynamically. Through client we can give a request, server can receive the request from the client, process the request and send the result to the client and nodes are the media to send result to the client from the server. Here we can see the travelling of the data from node to node and node to client.
Maximizing the Number of Broadcast Operations in Random Geometric Ad Hoc Wireless Networks
Page 9
Server implementation:
In this module we have to create a server through which we can receive the request from client. As well as we should able to perform some task from the server such as browse file, file content, node information, needed energy information, available node etc.
Maximizing the Number of Broadcast Operations in Random Geometric Ad Hoc Wireless Networks
Page 10
1.3.1
MODULE DIAGRAM:
Maximizing the Number of Broadcast Operations in Random Geometric Ad Hoc Wireless Networks
Page 11
Maximizing the Number of Broadcast Operations in Random Geometric Ad Hoc Wireless Networks
Page 12
2.4 CONCLUSION
In this paper, we provided efficient solutions for the MAXLIFETIME problem on random sets. Further interesting future studies should address other basic operations such as the gossiping operation which is known to be NP-hard as well . A more technical problem, left open by our work, is the study of MAX LIFETIME when _ contains more than one positive value smaller than the connectivity threshold CTn of random geometric graphs. This case seems to be very hard since it concerns the size and the structure of the connected components of such random graphs under the connectivity threshold .Finally, we emphasize that after the presentation of the conference version of this work, a new protocol for MIN ENERGY BROADCAST has been given in. This new protocol is inspired by ours and achieves provably good performances on random-grid instances yielded by nonuniform node distributions.
Maximizing the Number of Broadcast Operations in Random Geometric Ad Hoc Wireless Networks
Page 13
CHAPTER 3
REQUIREMENTS ENGINEERING
3.1 GENERAL
Using this requirements the here in this paper we send the message to the client through the pivot node after scheduling.
The hardware requirements may serve as the basis for a contract for the implementation of the system and should therefore be a complete and consistent specification of the whole system. They are used by software engineers as the starting point for the system design. It should what the system do and not how it should be implemented.
: : : : : : :
PENTIUM IV 2.6 GHz,Intel Core 2 Duo. 512 MB DD RAM 15 COLOR 40 GB LG 52X STANDARD 102 KEYS 3 BUTTONS
Page 14
Maximizing the Number of Broadcast Operations in Random Geometric Ad Hoc Wireless Networks
1.4SOFTWARE REQUIREMENTS
The software requirements document is the specification of the system. It should include both a definition and a specification of requirements. It is a set of what the system should do rather than how it should do it. The software requirements provide a basis for creating the software requirements specification. It is useful in estimating cost, planning team activities, performing tasks and tracking the teams and tracking the teams progress throughout the development activity.
FRONT END
JSP
BACK END
SQL SERVER
Maximizing the Number of Broadcast Operations in Random Geometric Ad Hoc Wireless Networks
Page 15
CHAPTER 4
DESIGN ENGINEERING
4.1 GENERAL
Design Engineering deals with the various UML [Unified Modeling language] diagrams for the implementation of project. Design is a meaningful engineering representation of a thing that is to be built. Software design is a process through which the requirements are translated into representation of the software. Design is the place where quality is rendered in software engineering. Design is the means to accurately translate customer requirements into finished product
In the below diagram seven use cases are depicted. They are used to search result using CST methods.
Maximizing the Number of Broadcast Operations in Random Geometric Ad Hoc Wireless Networks
Page 16
Register
Update
Login
Administrator
Connect sends/receives response Receive messages Pivot node Sends message Server
Receives data
Conversion of data
user/client
A class diagram in the UML is a type of static structure diagram that describes the structure of a system by showing the systems classes, their attributes, and the relationships between the classes. Private visibility hides information from anything outside the class partition. Public visibility allows all other classes to view the marked information. Protected visibility allows child classes to access information they inherited from a parent class.
Maximizing the Number of Broadcast Operations in Random Geometric Ad Hoc Wireless Networks
Page 17
The following Activity diagram shows how the Maximizing broadcast in network working flows.
Maximizing the Number of Broadcast Operations in Random Geometric Ad Hoc Wireless Networks
Page 18
A sequence diagram in UML is a kind of interaction diagram that shows how processes operate with one another and in what order. It is a construct of a message sequence chart. Sequence diagrams are sometimes called Event-trace diagrams, event scenarios, and timing diagrams. The below diagram shows the sequence flow of the Maximizing broadcast in the network
Maximizing the Number of Broadcast Operations in Random Geometric Ad Hoc Wireless Networks
Page 19
:User
:Administrator
:Server
:Pivot node
:Client
Login
4.6 COLLABORATION DIAGRAM A collaboration diagram show the objects and relationships involved in an interaction, and the sequence of messages exchanged among the objects during the interaction. The collaboration diagram can be a decomposition of a class, class diagram, or part of a class diagram. it can be the decomposition of a use case, use case diagram, or part of a use case diagram.
Maximizing the Number of Broadcast Operations in Random Geometric Ad Hoc Wireless Networks
Page 20
The collaboration diagram shows messages being sent between classes and object (instances). A diagram is created for each system operation that relates to the current development cycle (iteration).
6:
2: 3: :Serv er
A data flow diagram (DFD) is a graphical representation of the flow of data through an information system. It differs from the flowchart as it shows the data flow instead of the control flow of the program. A data flow diagram can also be used for the visualization of data processing. The DFD is designed to show how a system is divided into smaller portions and to highlight the flow of data between those parts.
Maximizing the Number of Broadcast Operations in Random Geometric Ad Hoc Wireless Networks
Page 21
4.11 CONCLUSION
From the above represented various UML diagrams it makes the developer and the designer of the project to easily understand the various implementations that has been carried out in the project.
Maximizing the Number of Broadcast Operations in Random Geometric Ad Hoc Wireless Networks
Page 22
CHAPTER 5
DEVELOPMENT TOOLS
5.1 GENERAL
This chapter is about the software language and the tools used in the development of the project. The platform used here is JAVA. The Primary languages are JAVA,J2EE and J2ME. In this project J2EE is chosen for implementation.
Maximizing the Number of Broadcast Operations in Random Geometric Ad Hoc Wireless Networks
Page 23
5.2.2 OBJECTIVES OF JAVA To see places of Java in Action in our daily life, explore java.com.
Write software on one platform and run it on virtually any other platform Create programs to run within a Web browser and Web services Develop server-side applications for online forums, stores, polls, HTML forms processing, and more
Combine applications or services using the Java language to create highly customized applications or services
Write powerful and efficient applications for mobile phones, remote processors, low-cost consumer products, and practically any other device with a digital heartbeat
Maximizing the Number of Broadcast Operations in Random Geometric Ad Hoc Wireless Networks
Page 24
1. Inheritance :It is the process of creating the new classes and using the behavior of the existing classes by extending them just to reuse the existing code and adding addition a features as needed. 2. Encapsulation: It is the mechanism of combining the information and providing the abstraction. 3. Polymorphism: As the name suggest one name multiple form, Polymorphism is the way of providing the different functionality by the functions having the same name based on the signatures of the methods. 4. Dynamic binding: Sometimes we don't have the knowledge of objects about their specific types while writing our code. It is the way of providing the maximum functionality to a program about the specific type at runtime.
Maximizing the Number of Broadcast Operations in Random Geometric Ad Hoc Wireless Networks
Page 25
framework for creating dynamic web content on the server using HTML, and XML templates, and Java code, which is secure, fast, and independent of server platforms. JSP has been built on top of the Servlet API and utilizes Servlet semantics. JSP has become the preferred request handler and response mechanism. Although JSP technology is going to be a powerful successor to basic Servlets, they have an evolutionary relationship and can be used in a cooperative and complementary manner. Servlets are powerful and sometimes they are a bit cumbersome when it comes to generating complex HTML. Most servlets contain a little code that handles application logic and a lot more code that handles output formatting. This can make it difficult to separate and reuse portions of the code when a different output format is needed. For these reasons, web application developers turn towards JSP as their preferred servlet environment.
Page 26
information they view, remembering their past transactions or frequent search keywords are all important in providing feedback and interaction from what is otherwise a fairly one-sided conversation. Apart from these general needs for a business-oriented web site, the necessity for new technologies to create robust, dynamic and compact server-side web applications has been realized. The main characteristics of today's dynamic web server applications are as follows: 1. Serve HTML and XML, and stream data to the web client 2. Separate presentation, logic and data 3. Interface to databases, other Java applications, CORBA, directory and mail services 4. Make use of application server middleware to provide transactional support. 5. Track client sessions.
Page 27
This definitely reduces development time apart from the At development time, JSPs are very different from Servlets, however, they are precompiled into Servlets at run time and executed by a JSP engine which is installed on a Web-enabled application server such as BEA Web Logic and IBM Web Sphere.
5.3Servlets
Earlier in client- server computing, each application had its own client program and it worked as a user interface and need to be installed on each user's personal computer. Most web applications use HTML/XHTML that are mostly supported by all the browsers and web pages are displayed to the client as static documents. A web page can merely displays static content and it also lets the user navigate through the content, but a web application provides a more interactive experience. Any computer running Servlets or JSP needs to have a container. A container is nothing but a piece of software responsible for loading, executing and unloading the Servlets and JSP. While servlets can be used to extend the functionality of any Java- enabled server. They are mostly used to extend web servers, and are efficient replacement for CGI scripts. CGI was one of the earliest and most prominent server side dynamic content solutions, so before going forward it is very important to know the difference between CGI and the Servlets.
5.4Java Servlets
Java Servlet is a generic server extension that means a java class can be loaded dynamically to expand the functionality of a server. Servlets are used with web servers and run inside a Java Virtual Machine (JVM) on the server so these are safe and portable. Unlike applets they do not require support for java in the web browser. Unlike CGI, servlets don't use multiple processes to handle separate request. Servets can be handled by separate threads within the same process. Servlets are also portable and platform independent.
Maximizing the Number of Broadcast Operations in Random Geometric Ad Hoc Wireless Networks
Page 28
A web server is the combination of computer and the program installed on it. Web server interacts with the client through a web browser. It delivers the web pages to the client and to an application by using the web browser and the HTTP protocols respectively. The define the web server as the package of large number of programs installed on a computer connected to Internet or intranet for downloading the requested files using File Transfer Protocol, serving e-mail and building and publishing web pages. A web server works on a client server model.
5.5 Conclusion
JSP and Servlets are gaining rapid acceptance as means to provide dynamic content on the Internet. With full access to the Java platform, running from the server in a secure manner, the application possibilities are almost limitless. When JSPs are used with Enterprise JavaBeans technology, e-commerce and database resources can be further enhanced to meet an enterprise's needs for web applications providing secure transactions in an open platform. J2EE technology as a whole makes it easy to develop, deploy and use web server applications instead of mingling with other technologies such as CGI and ASP. There are many tools for facilitating quick web software development and to easily convert existing server-side technologies to JSP and Servlets.
Maximizing the Number of Broadcast Operations in Random Geometric Ad Hoc Wireless Networks
Page 29
CHAPTER 6
IMPLEMENTATION
6.1 GENERAL
This chapter describes the implementation of searched based application. It deals with the source code for main view point for Maximizing broadcast in the network. 6.2 IMPLEMENTAION OF MAXIMIZING BROADCAST IN THE NETWORK.
Login.java:
/* * To change this template, choose Tools | Templates * and open the template in the editor. */
package client;
Page 30
/** This method is called from within the constructor to * initialize the form. * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code"> private void initComponents() {
jProgressBar2 = new javax.swing.JProgressBar(); jPanel1 = new javax.swing.JPanel(); jPanel2 = new javax.swing.JPanel(); password = new javax.swing.JLabel(); username1 = new javax.swing.JLabel(); Tx1 = new javax.swing.JTextField(); pbar = new javax.swing.JProgressBar(); SUBMIT = new javax.swing.JLabel(); EXIT = new javax.swing.JLabel(); username2 = new javax.swing.JLabel();
Maximizing the Number of Broadcast Operations in Random Geometric Ad Hoc Wireless Networks
Page 31
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jPanel2.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.Bev elBorder.RAISED, new java.awt.Color(0, 0, 0), new java.awt.Color(0, 0, 0), new java.awt.Color(51, 51, 51), new java.awt.Color(0, 0, 0))); jPanel2.setLayout(null);
password.setBackground(new java.awt.Color(102, 102, 102)); password.setFont(new java.awt.Font("Script MT Bold", 1, 24)); password.setForeground(new java.awt.Color(255, 255, 204)); password.setText("PASSWORD"); jPanel2.add(password); password.setBounds(30, 180, 177, 40);
username1.setBackground(new java.awt.Color(102, 102, 102)); username1.setFont(new java.awt.Font("Script MT Bold", 1, 36)); username1.setForeground(new java.awt.Color(255, 255, 255)); username1.setText("LOGIN"); jPanel2.add(username1); username1.setBounds(150, 10, 150, 50);
Maximizing the Number of Broadcast Operations in Random Geometric Ad Hoc Wireless Networks
Page 32
Tx1.setBackground(new java.awt.Color(102, 102, 102)); Tx1.setFont(new java.awt.Font("Jokerman", 1, 24)); Tx1.setForeground(new java.awt.Color(255, 153, 102)); Tx1.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(255, 255, 255), 2, true)); jPanel2.add(Tx1); Tx1.setBounds(210, 90, 200, 40);
pbar.setBackground(new java.awt.Color(0, 0, 0)); pbar.setForeground(new java.awt.Color(255, 153, 0)); pbar.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(255, 153, 0), 1, true)); pbar.setBorderPainted(false); pbar.setDebugGraphicsOptions(javax.swing.DebugGraphics.NONE_OPTION); pbar.setDoubleBuffered(true); pbar.setFocusCycleRoot(true); pbar.setFocusTraversalPolicyProvider(true); pbar.setOpaque(true); pbar.setString("LOGIN IS IN PROGRESS"); jPanel2.add(pbar); pbar.setBounds(60, 400, 400, 30);
SUBMIT.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Images/submit.jpg"))); // NOI18N SUBMIT.setText("jLabel1"); SUBMIT.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { SUBMITMouseClicked(evt); } }); jPanel2.add(SUBMIT);
Maximizing the Number of Broadcast Operations in Random Geometric Ad Hoc Wireless Networks
Page 33
EXIT.setBackground(new java.awt.Color(0, 0, 0)); EXIT.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Images/cancel1.jpg"))); // NOI18N EXIT.setText("jLabel2"); EXIT.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { EXITMouseClicked(evt); } }); jPanel2.add(EXIT); EXIT.setBounds(350, 250, 130, 140);
username2.setBackground(new java.awt.Color(102, 102, 102)); username2.setFont(new java.awt.Font("Script MT Bold", 1, 24)); username2.setForeground(new java.awt.Color(255, 255, 204)); username2.setText("USER NAME"); jPanel2.add(username2); username2.setBounds(20, 90, 177, 40);
jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Images/s.jpg"))); // NOI18N jLabel1.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { jLabel1MouseClicked(evt); } }); jPanel2.add(jLabel1); jLabel1.setBounds(220, 270, 100, 100);
Maximizing the Number of Broadcast Operations in Random Geometric Ad Hoc Wireless Networks
Page 34
Tx2.setBackground(new java.awt.Color(102, 102, 102)); Tx2.setFont(new java.awt.Font("Jokerman", 1, 24)); jPanel2.add(Tx2); Tx2.setBounds(210, 190, 200, 40);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, 889, Short.MAX_VALUE) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 453, javax.swing.GroupLayout.PREFERRED_SIZE) );
private void SUBMITMouseClicked(java.awt.event.MouseEvent evt) { // TODO add your handling code here: new NEW();
Maximizing the Number of Broadcast Operations in Random Geometric Ad Hoc Wireless Networks
Page 35
private void EXITMouseClicked(java.awt.event.MouseEvent evt) { // TODO add your handling code here: }
private void jLabel1MouseClicked(java.awt.event.MouseEvent evt) { // TODO add your handling code here: client(); }
/** * @param args the command line arguments */ public static void main(String args[]) { java.awt.EventQueue.invokeLater(new Runnable() { public void run() { LOGIN l=new LOGIN(); l.setVisible(true);
} }); }
// Variables declaration - do not modify private javax.swing.JLabel EXIT; private javax.swing.JLabel SUBMIT; private javax.swing.JTextField Tx1; private javax.swing.JPasswordField Tx2; private javax.swing.JLabel jLabel1; private javax.swing.JPanel jPanel1; private javax.swing.JPanel jPanel2;
Maximizing the Number of Broadcast Operations in Random Geometric Ad Hoc Wireless Networks
Page 36
private javax.swing.JProgressBar jProgressBar2; private javax.swing.JLabel password; private javax.swing.JProgressBar pbar; private javax.swing.JLabel username1; private javax.swing.JLabel username2; // End of variables declaration
Thread t;
private void loginvalid() { Map mp=Dbconnect.Db().loginVal(); // Return the Client Name & Password System.out.println(mp); //String args[]=Tx1.getText().trim(); String TName=Tx1.getText().trim(); String TPass=Tx2.getText().trim(); boolean CName=mp.containsKey(TName); boolean CPass=mp.containsValue(TPass); if(CName && CPass) // If it is True Login to client Page { Progress pp=new Progress(0,100); pp.IN(); JOptionPane.showMessageDialog(rootPane, "Login Successfully"); this.dispose(); String s[]={TName}; CLIENTHOME_1.main(s);
} else {
Maximizing the Number of Broadcast Operations in Random Geometric Ad Hoc Wireless Networks
Page 37
class Progress { int min; int max; public Progress(int MIN,int MAX) { min=MIN; max=MAX; pbar.setMinimum(min); pbar.setMaximum(max); pbar.setIndeterminate(true); pbar.setStringPainted(true); } public void Update(int n) { pbar.setValue(n); }
Maximizing the Number of Broadcast Operations in Random Geometric Ad Hoc Wireless Networks
Page 38
public void IN() { try { pbar.setVisible(true); for(int i=min;i<=max;i++) { final int per=i; SwingUtilities.invokeLater(new Runnable(){ public void run() { Update(per); } }); java.lang.Thread.sleep(25); } pbar.setVisible(false); } catch(Exception e) { e.printStackTrace(); } } }
class NEW implements Runnable { Thread tt; public NEW() { tt=new Thread(this);
Maximizing the Number of Broadcast Operations in Random Geometric Ad Hoc Wireless Networks
Page 39
DBConnect.java
/* * To change this template, choose Tools | Templates * and open the template in the editor. */
package DBPackage;
Page 40
import java.sql.Statement; import java.util.HashMap; import java.util.Map; import java.util.List; import java.util.ArrayList;
public class Dbconnect { private static final Dbconnect DbInstance= new Dbconnect(); private Connection con; private Statement st,st1,st2,st4; private ResultSet rs,rs1,rs2; private PreparedStatement ps,ps1,ps2; private Dbconnect() { } public Connection connect()throws Exception { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); con=DriverManager.getConnection("Jdbc:Odbc:Replica"); return con; } public static Dbconnect Db() { return DbInstance; }
Page 41
try { st=Dbconnect.Db().connect().createStatement(); // Getting the Database Connection & Creating Statement rs=st.executeQuery("select UserName,Password from Login1"); // Checking Validity
Register.java
/* * To change this template, choose Tools | Templates * and open the template in the editor. */
/*
Maximizing the Number of Broadcast Operations in Random Geometric Ad Hoc Wireless Networks
Page 42
package client;
/** This method is called from within the constructor to * initialize the form. * WARNING: Do NOT modify this code. The content of this method is
Maximizing the Number of Broadcast Operations in Random Geometric Ad Hoc Wireless Networks
Page 43
* always regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GENBEGIN:initComponents private void initComponents() {
jPanel1 = new javax.swing.JPanel(); username1 = new javax.swing.JLabel(); jPanel4 = new javax.swing.JPanel(); username4 = new javax.swing.JLabel(); RT1 = new javax.swing.JTextField(); RT4 = new javax.swing.JTextField(); password1 = new javax.swing.JLabel(); password2 = new javax.swing.JLabel(); password3 = new javax.swing.JLabel(); password4 = new javax.swing.JLabel(); RC1 = new javax.swing.JTextField(); RP2 = new javax.swing.JPasswordField(); RP1 = new javax.swing.JPasswordField(); jLabel1 = new javax.swing.JLabel(); jLabel2 = new javax.swing.JLabel(); jLabel3 = new javax.swing.JLabel(); jLabel4 = new javax.swing.JLabel();
Maximizing the Number of Broadcast Operations in Random Geometric Ad Hoc Wireless Networks
Page 44
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jPanel1.setBackground(new java.awt.Color(0, 0, 0)); jPanel1.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(204, 255, 255), 2, true)); jPanel1.setForeground(new java.awt.Color(255, 255, 255)); jPanel1.setLayout(null);
username1.setBackground(new java.awt.Color(102, 102, 102)); username1.setFont(new java.awt.Font("Script MT Bold", 1, 36)); username1.setForeground(new java.awt.Color(255, 255, 255)); username1.setText("Client Registration Page"); jPanel1.add(username1); username1.setBounds(390, 10, 460, 60);
username4.setBackground(new java.awt.Color(102, 102, 102)); username4.setFont(new java.awt.Font("Script MT Bold", 1, 24)); username4.setForeground(new java.awt.Color(0, 255, 255)); username4.setText("Client Name"); jPanel4.add(username4); username4.setBounds(70, 30, 177, 40);
Maximizing the Number of Broadcast Operations in Random Geometric Ad Hoc Wireless Networks
Page 45
RT1.setFont(new java.awt.Font("Jokerman", 1, 24)); // NOI18N RT1.setForeground(new java.awt.Color(255, 153, 102)); RT1.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(255, 255, 255), 2, true)); jPanel4.add(RT1); RT1.setBounds(260, 30, 200, 40);
RT4.setFont(new java.awt.Font("Jokerman", 1, 24)); RT4.setForeground(new java.awt.Color(255, 153, 102)); RT4.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(255, 255, 255), 2, true)); jPanel4.add(RT4); RT4.setBounds(260, 340, 200, 40);
password1.setBackground(new java.awt.Color(102, 102, 102)); password1.setFont(new java.awt.Font("Script MT Bold", 1, 24)); password1.setForeground(new java.awt.Color(0, 255, 255)); password1.setText("ReTypePassword"); jPanel4.add(password1); password1.setBounds(30, 190, 210, 40);
password2.setBackground(new java.awt.Color(102, 102, 102)); password2.setFont(new java.awt.Font("Script MT Bold", 1, 24)); password2.setForeground(new java.awt.Color(0, 255, 255)); password2.setText("Gender"); jPanel4.add(password2);
Maximizing the Number of Broadcast Operations in Random Geometric Ad Hoc Wireless Networks
Page 46
password3.setBackground(new java.awt.Color(102, 102, 102)); password3.setFont(new java.awt.Font("Script MT Bold", 1, 24)); password3.setForeground(new java.awt.Color(0, 255, 255)); password3.setText("Address"); jPanel4.add(password3); password3.setBounds(70, 340, 160, 40);
password4.setBackground(new java.awt.Color(102, 102, 102)); password4.setFont(new java.awt.Font("Script MT Bold", 1, 24)); password4.setForeground(new java.awt.Color(0, 255, 255)); password4.setText("Password"); jPanel4.add(password4); password4.setBounds(70, 110, 160, 40);
RC1.setFont(new java.awt.Font("Jokerman", 1, 24)); RC1.setForeground(new java.awt.Color(255, 153, 102)); RC1.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(255, 255, 255), 2, true)); jPanel4.add(RC1); RC1.setBounds(260, 270, 200, 40);
Maximizing the Number of Broadcast Operations in Random Geometric Ad Hoc Wireless Networks
Page 47
RP1.setFont(new java.awt.Font("Jokerman", 1, 14)); // NOI18N RP1.setForeground(new java.awt.Color(255, 153, 153)); jPanel4.add(RP1); RP1.setBounds(260, 100, 200, 28);
jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Images/submit1.jpg"))); // NOI18N jLabel1.setText("jLabel1"); jLabel1.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { jLabel1MouseClicked(evt); } }); jPanel1.add(jLabel1); jLabel1.setBounds(350, 560, 170, 140);
jLabel2.setBackground(new java.awt.Color(102, 102, 102)); jLabel2.setFont(new java.awt.Font("Script MT Bold", 1, 24)); jLabel2.setForeground(new java.awt.Color(0, 255, 255));
Maximizing the Number of Broadcast Operations in Random Geometric Ad Hoc Wireless Networks
Page 48
jLabel3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Images/images_1.jpg"))); // NOI18N jLabel3.setText("jLabel3"); jLabel3.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { jLabel3MouseClicked(evt); } }); jPanel1.add(jLabel3); jLabel3.setBounds(530, 530, 210, 210);
jLabel4.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Images/exit_1.JPG"))); // NOI18N jLabel4.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { jLabel4MouseClicked(evt); } }); jPanel1.add(jLabel4); jLabel4.setBounds(760, 530, 210, 200);
Page 49
layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addContainerGap() .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, 1004, Short.MAX_VALUE) .addContainerGap()) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 773, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) );
private void jLabel1MouseClicked(java.awt.event.MouseEvent evt) {//GENFIRST:event_jLabel1MouseClicked // TODO add your handling code here:
register(); }//GEN-LAST:event_jLabel1MouseClicked
Maximizing the Number of Broadcast Operations in Random Geometric Ad Hoc Wireless Networks
Page 50
private void jLabel3MouseClicked(java.awt.event.MouseEvent evt) {//GENFIRST:event_jLabel3MouseClicked // TODO add your handling code here: RT1.setText(null); RT4.setText(null); RP1.setText(null); RP2.setText(null); RC1.setText(null); }//GEN-LAST:event_jLabel3MouseClicked
private void jLabel4MouseClicked(java.awt.event.MouseEvent evt) {//GENFIRST:event_jLabel4MouseClicked // TODO add your handling code here: System.exit(0); }//GEN-LAST:event_jLabel4MouseClicked
/** * @param args the command line arguments */ public static void main(String args[]) { java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new ClientRegister().setVisible(true); } }); }
Maximizing the Number of Broadcast Operations in Random Geometric Ad Hoc Wireless Networks
Page 51
// Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JTextField RC1; private javax.swing.JPasswordField RP1; private javax.swing.JPasswordField RP2; private static javax.swing.JTextField RT1; private javax.swing.JTextField RT4; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel2; private javax.swing.JLabel jLabel3; private javax.swing.JLabel jLabel4; private javax.swing.JPanel jPanel1; private javax.swing.JPanel jPanel4; private javax.swing.JLabel password1; private javax.swing.JLabel password2; private javax.swing.JLabel password3; private javax.swing.JLabel password4; private javax.swing.JLabel username1; private javax.swing.JLabel username4; // End of variables declaration//GEN-END:variables
Page 52
int i=0; if(RT1.getText().equals("")) { JOptionPane.showMessageDialog(rootPane, "Please enter the User name"); } else if(RT4.getText().equals("")) { JOptionPane.showMessageDialog(rootPane, "Please enter the Address"); } else if(RP1.getText().equals("")) { JOptionPane.showMessageDialog(rootPane, "Please enter the Password"); } else if(RP2.getText().equals("")) { JOptionPane.showMessageDialog(rootPane, "Please enter the ReType Password"); } else if(RC1.getText().equals("")) { JOptionPane.showMessageDialog(rootPane, "Please Select the Gender Details"); } else { if(RP1.getText().equals(RP2.getText())) {
Maximizing the Number of Broadcast Operations in Random Geometric Ad Hoc Wireless Networks
Page 53
i=insertClient(RT1.getText(),RP1.getText(),RP2.getText(),RC1.getText(),RT4.getText());
if(i!=0) { JOptionPane.showMessageDialog(rootPane, "Data Inserted Successfully"); LOGIN.main(null); this.dispose(); } else { JOptionPane.showMessageDialog(rootPane, "Please Check The DataBase Connectivity"); } } else
private int insertClient(String Name,String Pass,String Rpass,String Gender,String Address) { int i=0; try
Maximizing the Number of Broadcast Operations in Random Geometric Ad Hoc Wireless Networks
Page 54
{ ps1=Dbconnect.Db().connect().prepareStatement("insert into Login1 values(?,?,?,?,?)"); ps1.setString(1,Name); ps1.setString(2, Pass); ps1.setString(3, Rpass); ps1.setString(4, Gender); ps1.setString(5, Address); i=ps1.executeUpdate(); } catch(Exception e) { e.printStackTrace(); } return i;
Server.java
package server;
Maximizing the Number of Broadcast Operations in Random Geometric Ad Hoc Wireless Networks
Page 55
import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.net.ServerSocket; import java.net.Socket; import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.TreeMap; import java.util.logging.Level; import java.util.logging.Logger; import javax.swing.JOptionPane;
jPanel1 = new javax.swing.JPanel(); jPanel3 = new javax.swing.JPanel(); jLabel2 = new javax.swing.JLabel(); txtPath = new javax.swing.JTextField(); jLabel7 = new javax.swing.JLabel();
Maximizing the Number of Broadcast Operations in Random Geometric Ad Hoc Wireless Networks
Page 56
jPanel4 = new javax.swing.JPanel(); jScrollPane1 = new javax.swing.JScrollPane(); txtMessage = new javax.swing.JTextArea(); jLabel9 = new javax.swing.JLabel(); jLabel10 = new javax.swing.JLabel(); jPanel6 = new javax.swing.JPanel(); list1 = new java.awt.List(); jLabel1 = new javax.swing.JLabel(); jPanel5 = new javax.swing.JPanel(); jLabel3 = new javax.swing.JLabel(); txtEnergy = new javax.swing.JTextField(); jLabel4 = new javax.swing.JLabel(); txtAddress = new javax.swing.JTextField(); jLabel5 = new javax.swing.JLabel(); txtPort = new javax.swing.JTextField(); jLabel8 = new javax.swing.JLabel(); jPanel7 = new javax.swing.JPanel(); jLabel6 = new javax.swing.JLabel(); txtNeedEnergy = new javax.swing.JTextField(); jLabel11 = new javax.swing.JLabel();
Page 57
javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Algerian", 1, 24), new java.awt.Color(153, 153, 153))); // NOI18N jPanel3.setLayout(null);
jLabel2.setFont(new java.awt.Font("Times New Roman", 1, 18)); jLabel2.setForeground(new java.awt.Color(102, 255, 255)); jLabel2.setText("SELECT YOUR FILE"); jPanel3.add(jLabel2); jLabel2.setBounds(40, 50, 180, 40);
txtPath.setBackground(new java.awt.Color(204, 204, 204)); txtPath.setEditable(false); txtPath.setFont(new java.awt.Font("Times New Roman", 1, 14)); txtPath.setForeground(new java.awt.Color(255, 255, 255)); txtPath.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { txtPathActionPerformed(evt); } }); jPanel3.add(txtPath); txtPath.setBounds(250, 50, 339, 30);
jLabel7.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Browse.jpg"))); // NOI18N jLabel7.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { jLabel7MouseClicked(evt); } }); jPanel3.add(jLabel7); jLabel7.setBounds(620, 20, 130, 100);
Maximizing the Number of Broadcast Operations in Random Geometric Ad Hoc Wireless Networks
Page 58
jPanel4.setBackground(new java.awt.Color(0, 0, 0)); jPanel4.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "MESSAGE", javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Algerian", 1, 24), new java.awt.Color(153, 153, 153))); // NOI18N jPanel4.setLayout(null);
txtMessage.setBackground(new java.awt.Color(153, 153, 153)); txtMessage.setColumns(20); txtMessage.setFont(new java.awt.Font("Bodoni MT Black", 1, 14)); txtMessage.setRows(5); jScrollPane1.setViewportView(txtMessage);
jLabel9.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/se.jpg"))); // NOI18N jLabel9.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { jLabel9MouseClicked(evt); } }); jPanel4.add(jLabel9); jLabel9.setBounds(320, 300, 127, 120);
Maximizing the Number of Broadcast Operations in Random Geometric Ad Hoc Wireless Networks
Page 59
jLabel10.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/clear.jpg"))); // NOI18N jLabel10.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { jLabel10MouseClicked(evt); } }); jPanel4.add(jLabel10); jLabel10.setBounds(130, 300, 120, 116);
jPanel6.setBackground(new java.awt.Color(0, 0, 0)); jPanel6.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "AVAILABLE NODE", javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Algerian", 1, 18), new java.awt.Color(153, 153, 153))); // NOI18N jPanel6.setLayout(null);
list1.setBackground(new java.awt.Color(153, 153, 153)); list1.setFont(new java.awt.Font("Bodoni MT Black", 1, 18)); jPanel6.add(list1); list1.setBounds(20, 40, 240, 380);
Page 60
jPanel5.setBackground(new java.awt.Color(0, 0, 0)); jPanel5.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "FIND ENERGY EFFICIENT NODE", javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Algerian", 1, 18), new java.awt.Color(153, 153, 153))); // NOI18N jPanel5.setLayout(null);
jLabel3.setFont(new java.awt.Font("Bodoni MT Black", 1, 14)); jLabel3.setForeground(new java.awt.Color(51, 255, 255)); jLabel3.setText("Node Energy"); jPanel5.add(jLabel3); jLabel3.setBounds(20, 80, 110, 40);
txtEnergy.setBackground(new java.awt.Color(153, 153, 153)); txtEnergy.setFont(new java.awt.Font("Bodoni MT Black", 1, 12)); txtEnergy.setForeground(new java.awt.Color(255, 255, 255)); jPanel5.add(txtEnergy); txtEnergy.setBounds(150, 90, 120, 30);
jLabel4.setFont(new java.awt.Font("Bodoni MT Black", 1, 14)); jLabel4.setForeground(new java.awt.Color(51, 255, 255)); jLabel4.setText("IP Address"); jPanel5.add(jLabel4); jLabel4.setBounds(30, 150, 100, 30);
Page 61
jLabel5.setFont(new java.awt.Font("Bodoni MT Black", 1, 14)); jLabel5.setForeground(new java.awt.Color(51, 255, 255)); jLabel5.setText("Port Number"); jPanel5.add(jLabel5); jLabel5.setBounds(20, 210, 110, 30);
txtPort.setBackground(new java.awt.Color(153, 153, 153)); txtPort.setFont(new java.awt.Font("Bodoni MT Black", 1, 12)); txtPort.setForeground(new java.awt.Color(255, 255, 255)); jPanel5.add(txtPort); txtPort.setBounds(150, 210, 120, 30);
jLabel8.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/scedu.jpg"))); // NOI18N jLabel8.setText("jLabel8"); jLabel8.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { jLabel8MouseClicked(evt); } }); jPanel5.add(jLabel8); jLabel8.setBounds(110, 270, 100, 100);
Page 62
jPanel7.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "FIND ENERGY", javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Algerian", 1, 18), new java.awt.Color(153, 153, 153))); // NOI18N jPanel7.setLayout(null);
jLabel6.setFont(new java.awt.Font("Bodoni MT Black", 1, 14)); jLabel6.setForeground(new java.awt.Color(102, 255, 255)); jLabel6.setText("Needed Energy"); jPanel7.add(jLabel6); jLabel6.setBounds(20, 50, 130, 30);
txtNeedEnergy.setBackground(new java.awt.Color(153, 153, 153)); txtNeedEnergy.setFont(new java.awt.Font("Bodoni MT Black", 1, 12)); txtNeedEnergy.setForeground(new java.awt.Color(255, 255, 255)); jPanel7.add(txtNeedEnergy); txtNeedEnergy.setBounds(170, 50, 110, 30);
jLabel11.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/find.jpg"))); // NOI18N jLabel11.setText("jLabel11"); jLabel11.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { jLabel11MouseClicked(evt); } }); jPanel7.add(jLabel11); jLabel11.setBounds(90, 100, 120, 100);
Page 63
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 1203, javax.swing.GroupLayout.PREFERRED_SIZE) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 687, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) );
private void jLabel7MouseClicked(java.awt.event.MouseEvent evt) {//GENFIRST:event_jLabel7MouseClicked // TODO add your handling code here: browseFile(); }//GEN-LAST:event_jLabel7MouseClicked
Maximizing the Number of Broadcast Operations in Random Geometric Ad Hoc Wireless Networks
Page 64
private void jLabel9MouseClicked(java.awt.event.MouseEvent evt) {//GENFIRST:event_jLabel9MouseClicked // TODO add your handling code here: sendMessage(); }//GEN-LAST:event_jLabel9MouseClicked
private void jLabel10MouseClicked(java.awt.event.MouseEvent evt) {//GENFIRST:event_jLabel10MouseClicked // TODO add your handling code here: txtMessage.setText(""); }//GEN-LAST:event_jLabel10MouseClicked
private void jLabel8MouseClicked(java.awt.event.MouseEvent evt) {//GENFIRST:event_jLabel8MouseClicked // TODO add your handling code here: findEnergyEfficientNode(); }//GEN-LAST:event_jLabel8MouseClicked
private void jLabel11MouseClicked(java.awt.event.MouseEvent evt) {//GENFIRST:event_jLabel11MouseClicked // TODO add your handling code here: txtNeedEnergy.setText("" + txtMessage.getText().trim().length()); }//GEN-LAST:event_jLabel11MouseClicked
}
Maximizing the Number of Broadcast Operations in Random Geometric Ad Hoc Wireless Networks
Page 65
public void run() { Server s = new Server(); s.setVisible(true); s.start(); } }); } // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel10; private javax.swing.JLabel jLabel11; private javax.swing.JLabel jLabel2; private javax.swing.JLabel jLabel3; private javax.swing.JLabel jLabel4; private javax.swing.JLabel jLabel5; private javax.swing.JLabel jLabel6; private javax.swing.JLabel jLabel7; private javax.swing.JLabel jLabel8; private javax.swing.JLabel jLabel9; private javax.swing.JPanel jPanel1; private javax.swing.JPanel jPanel3; private javax.swing.JPanel jPanel4; private javax.swing.JPanel jPanel5; private javax.swing.JPanel jPanel6; private javax.swing.JPanel jPanel7; private javax.swing.JScrollPane jScrollPane1; private java.awt.List list1;
Maximizing the Number of Broadcast Operations in Random Geometric Ad Hoc Wireless Networks
Page 66
private javax.swing.JTextField txtAddress; private javax.swing.JTextField txtEnergy; private javax.swing.JTextArea txtMessage; private javax.swing.JTextField txtNeedEnergy; private javax.swing.JTextField txtPath; private javax.swing.JTextField txtPort; // End of variables declaration//GEN-END:variables ServerSocket server; Socket socket; Thread t; TreeMap<Integer, String> tm = new TreeMap<Integer, String>(); Map<Integer,String> regClients = new HashMap<Integer, String>(); List scheduleList;
private void start() { try { server = new ServerSocket(100); System.out.println("*-*-*-*-*-*-* Server is Running on the port 100 *-*-*-*-*-*-*"); t = new Thread(this); t.start(); } catch (IOException e) { e.printStackTrace(); }
Page 67
ObjectInputStream ois = new ObjectInputStream(socket.getInputStream()); java.util.List list = (java.util.List) ois.readObject(); System.out.println(list); System.out.println(list.get(0)); String key = (String) list.get(0);
int needEnergy = Integer.parseInt(txtNeedEnergy.getText().trim()); java.util.Set set = tm.entrySet();//entrySet used for iterate map Iterator it = set.iterator();
Maximizing the Number of Broadcast Operations in Random Geometric Ad Hoc Wireless Networks
Page 68
while (it.hasNext()) { Map.Entry me = (Map.Entry) it.next(); int port = ((Integer) me.getKey()).intValue(); String address = (String) me.getValue(); try { Socket soc = new Socket(address, port); ObjectOutputStream oos = new ObjectOutputStream(soc.getOutputStream()); java.util.List l = new ArrayList(); l.add("energy"); oos.writeObject(l); System.out.println("Data sent"); ObjectInputStream ois = new ObjectInputStream(soc.getInputStream()); Integer i = (Integer) ois.readObject(); NodeInfo ni = new NodeInfo(); ni.setAddress(address); ni.setEnergy(i.intValue()); ni.setPort(port);
Page 69
for (int i = 0; nodeInfo[i] != null; i++) { for (int j = 0; nodeInfo[j] != null; j++) { if (nodeInfo[i].compare(nodeInfo[j]) > max) { NodeInfo temp1 = nodeInfo[i]; nodeInfo[i] = nodeInfo[j]; nodeInfo[j] = temp1; } } }
scheduleList = new ArrayList(); int start = 0, end = 0; for (int i = 0; nodeInfo[i] != null; i++) {
Page 70
int cEnergy = nodeInfo[i].getEnergy(); if (cEnergy >= needEnergy) { end = needEnergy; Schedule sche = new Schedule(); sche.setAddress(nodeInfo[i].getAddress()); sche.setPort(nodeInfo[i].getPort()); System.out.println("Start : " + start); System.out.println("End : " + end); String message = (txtMessage.getText()).substring(start, (start + needEnergy)); sche.setMessage(message); scheduleList.add(sche); break;
} else {
needEnergy = needEnergy - cEnergy; end = cEnergy; Schedule sche = new Schedule(); sche.setAddress(nodeInfo[i].getAddress()); sche.setPort(nodeInfo[i].getPort()); String message = (txtMessage.getText()).substring(start, (start + needEnergy)); sche.setMessage(message); scheduleList.add(sche); start = end; } }
Page 71
FileDialog fd = new FileDialog(this); fd.show(); File f = new File(fd.getDirectory() + fd.getFile()); txtPath.setText(fd.getDirectory() + fd.getFile()); try { FileInputStream fis = new FileInputStream(f); byte buffer[] = new byte[fis.available()]; fis.read(buffer); String message = new String(buffer); txtMessage.setText(message); } catch (IOException e) { e.printStackTrace();
} }
private void getNodeInfo(java.util.List list) { String address = (String) list.get(1); Integer i = (Integer) list.get(2);
Maximizing the Number of Broadcast Operations in Random Geometric Ad Hoc Wireless Networks
Page 72
int reqEnergy = Integer.parseInt(txtNeedEnergy.getText().trim()); if(maxEnergy < reqEnergy){ JOptionPane.showMessageDialog(rootPane, "Energy is not enough to send whole msg\n Need to change another Node"); }
if (count != 0) { break; // JOptionPane.showMessageDialog(rootPane, "Energy is not enough to send whole msg\n Need to change another Node");
Page 73
txtPort.setText("" + s.getPort());
li.add(s.getMessage()); try { Socket soc = new Socket(s.getAddress(), s.getPort()); ObjectOutputStream oos = new ObjectOutputStream(soc.getOutputStream()); oos.writeObject(li); } catch (IOException e) { e.printStackTrace(); } try { Thread.sleep(11500); } catch (InterruptedException ex) { Logger.getLogger(Server.class.getName()).log(Level.SEVERE, null, ex); } }
count++; } }
private void getClientInfo(List list) { String address = (String) list.get(1); Integer clientPort = (Integer) list.get(2); regClients.put(clientPort, address);
int maxEnergy = 0; }
Maximizing the Number of Broadcast Operations in Random Geometric Ad Hoc Wireless Networks
Page 74
Client.java
package client;
import DBPackage.Dbconnect; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.net.InetAddress; import java.net.ServerSocket; import java.net.Socket; import java.util.ArrayList; import javax.swing.JOptionPane;
@SuppressWarnings("unchecked")
Maximizing the Number of Broadcast Operations in Random Geometric Ad Hoc Wireless Networks
Page 75
jProgressBar1 = new javax.swing.JProgressBar(); jPanel1 = new javax.swing.JPanel(); jButton1 = new javax.swing.JButton(); jPanel2 = new javax.swing.JPanel(); jScrollPane1 = new javax.swing.JScrollPane(); txtMessage = new javax.swing.JTextArea(); jPanel3 = new javax.swing.JPanel(); jScrollPane2 = new javax.swing.JScrollPane(); jTextArea1 = new javax.swing.JTextArea(); jLabel1 = new javax.swing.JLabel();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); setMinimumSize(new java.awt.Dimension(500, 400)); addWindowListener(new java.awt.event.WindowAdapter() { public void windowClosing(java.awt.event.WindowEvent evt) { formWindowClosing(evt); } });
Page 76
jPanel2.setBackground(new java.awt.Color(0, 0, 0)); jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "MESSAGE", javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Algerian", 1, 18), new java.awt.Color(153, 153, 153))); // NOI18N jPanel2.setLayout(null);
txtMessage.setBackground(new java.awt.Color(153, 153, 153)); txtMessage.setColumns(20); txtMessage.setRows(5); txtMessage.setMinimumSize(new java.awt.Dimension(400, 350)); jScrollPane1.setViewportView(txtMessage);
jPanel3.setBackground(new java.awt.Color(0, 0, 0)); jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "PACKETS", javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Algerian", 1, 18), new java.awt.Color(153, 153, 153))); // NOI18N jPanel3.setLayout(null);
Page 77
jLabel1.setFont(new java.awt.Font("Algerian", 1, 24)); // NOI18N jLabel1.setForeground(new java.awt.Color(51, 255, 255)); jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); jPanel1.add(jLabel1); jLabel1.setBounds(280, 30, 290, 40);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 880, javax.swing.GroupLayout.PREFERRED_SIZE) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 500, javax.swing.GroupLayout.PREFERRED_SIZE) );
Page 78
private void formWindowClosing(java.awt.event.WindowEvent evt) {//GENFIRST:event_formWindowClosing // TODO add your handling code here: Dbconnect.Db().deleteVal(username); }//GEN-LAST:event_formWindowClosing
} }); } // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton jButton1; private javax.swing.JLabel jLabel1; private javax.swing.JPanel jPanel1; private javax.swing.JPanel jPanel2; private javax.swing.JPanel jPanel3;
Maximizing the Number of Broadcast Operations in Random Geometric Ad Hoc Wireless Networks
Page 79
private javax.swing.JProgressBar jProgressBar1; private javax.swing.JScrollPane jScrollPane1; private javax.swing.JScrollPane jScrollPane2; private javax.swing.JTextArea jTextArea1; private javax.swing.JTextArea txtMessage; // End of variables declaration//GEN-END:variables Thread t; String message = ""; ServerSocket server; Socket socket; String serverIP = "localhost"; int port; int clientPort; int count = 1; static String username;
private void getInput() { username = JOptionPane.showInputDialog("Enter UserName"); port = Integer.parseInt(JOptionPane.showInputDialog("Enter Client Port Number"));
clientInformation();
setTitle(username); jLabel1.setText(username); }
private void start() { try { server = new ServerSocket(port); t = new Thread(this); t.start();
Maximizing the Number of Broadcast Operations in Random Geometric Ad Hoc Wireless Networks
Page 80
try { System.out.println("Waiting "); socket = server.accept(); ObjectInputStream ois = new ObjectInputStream(socket.getInputStream()); String msg = (String) ois.readObject(); message = message + msg; for (int i = 0; i <= msg.length(); i++) { jTextArea1.append("Packet- " + count + " Received\n"); count++; } System.out.println("****");
try {
Maximizing the Number of Broadcast Operations in Random Geometric Ad Hoc Wireless Networks
Page 81
Socket soc = new Socket(serverIP, 100); java.util.List list = new ArrayList(); list.add("client"); list.add(InetAddress.getLocalHost().getHostAddress()); list.add(port); ObjectOutputStream oos = new ObjectOutputStream(soc.getOutputStream()); oos.writeObject(list); } catch (IOException e) { e.printStackTrace(); } }
NodeA.java
package node;
import java.net.ServerSocket; import java.net.Socket; import java.io.IOException; import java.io.ObjectOutputStream; import java.io.ObjectInputStream; import java.net.InetAddress; import java.util.ArrayList; import java.util.List; import javax.swing.JOptionPane;
Maximizing the Number of Broadcast Operations in Random Geometric Ad Hoc Wireless Networks
Page 82
jPanel1 = new javax.swing.JPanel(); jPanel2 = new javax.swing.JPanel(); jProgressBar1 = new javax.swing.JProgressBar(); jPanel4 = new javax.swing.JPanel(); jScrollPane1 = new javax.swing.JScrollPane(); txtStatus = new javax.swing.JTextArea(); jLabel2 = new javax.swing.JLabel();
Maximizing the Number of Broadcast Operations in Random Geometric Ad Hoc Wireless Networks
Page 83
jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.cre ateMatteBorder(3, 3, 3, 3, new java.awt.Color(153, 153, 153)), "BATTERY CHARGE", javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Algerian", 1, 18), new java.awt.Color(153, 153, 153))); // NOI18N jPanel2.setLayout(null);
jProgressBar1.setBackground(new java.awt.Color(255, 51, 255)); jProgressBar1.setForeground(new java.awt.Color(153, 153, 153)); jPanel2.add(jProgressBar1); jProgressBar1.setBounds(30, 60, 250, 30);
jPanel4.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.cre ateMatteBorder(3, 3, 3, 3, new java.awt.Color(153, 153, 153)), "NODE STATUS", javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Algerian", 1, 18), new java.awt.Color(153, 153, 153))); // NOI18N
Page 84
javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4); jPanel4.setLayout(jPanel4Layout); jPanel4Layout.setHorizontalGroup( jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel4Layout.createSequentialGroup() .addContainerGap() .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 636, Short.MAX_VALUE) .addContainerGap()) ); jPanel4Layout.setVerticalGroup( jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel4Layout.createSequentialGroup() .addContainerGap() .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 273, Short.MAX_VALUE) .addContainerGap()) );
Page 85
jLabel2.setFont(new java.awt.Font("Algerian", 1, 48)); jLabel2.setForeground(new java.awt.Color(204, 204, 255)); jLabel2.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); jLabel2.setText("BROADCASTING NODE"); jPanel1.add(jLabel2); jLabel2.setBounds(50, 30, 660, 55);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 855, javax.swing.GroupLayout.PREFERRED_SIZE) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, 590, Short.MAX_VALUE) );
Maximizing the Number of Broadcast Operations in Random Geometric Ad Hoc Wireless Networks
Page 86
} }); } // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JLabel jLabel2; private javax.swing.JPanel jPanel1; private javax.swing.JPanel jPanel2; private javax.swing.JPanel jPanel4; public static javax.swing.JProgressBar jProgressBar1; private javax.swing.JScrollPane jScrollPane1;
Maximizing the Number of Broadcast Operations in Random Geometric Ad Hoc Wireless Networks
Page 87
private javax.swing.JTextArea txtStatus; // End of variables declaration//GEN-END:variables Thread t; ServerSocket server; Socket socket; String serverIP; int port; String nodeName; String clientIP; int clientPort;
private void getInput(){ serverIP=JOptionPane.showInputDialog("Enter Server IP"); nodeName=JOptionPane.showInputDialog("Please Enter Node Name..."); port=Integer.parseInt(JOptionPane.showInputDialog("Enter Node Port Number")); nodeEnergy = Integer.parseInt(JOptionPane.showInputDialog("Enter Node Energy")); setTitle(nodeName); } private void start() { try { server = new ServerSocket(port);
Page 88
txtStatus.append("\t\t*-*-*-*-*-*-*-*-*-*-*-*\n"); txtStatus.append("Node Running on the Port No "+port); informServer("on"); t = new Thread(this); t.start(); } catch (IOException e) { e.printStackTrace(); }
try { socket = server.accept(); ObjectInputStream ois = new ObjectInputStream(socket.getInputStream()); java.util.List list = (java.util.List) ois.readObject(); System.out.println(list); String key = (String) list.get(0); if ("energy".equals(key)) { processEnergy(); } if("message".equalsIgnoreCase(key)) { getMessage(list);
Maximizing the Number of Broadcast Operations in Random Geometric Ad Hoc Wireless Networks
Page 89
try { System.out.println("*-*-*-*-*-* Energy Request from the Server *-*-*-*-*-*-*-*"); txtStatus.append("Energy Request from the Server.....\n");
Page 90
oos.writeObject(nodeEnergy);
private void informServer(String state) { if ("on".equals(state)) { try { Socket soc = new Socket(serverIP, 100); java.util.List list = new ArrayList(); list.add("on"); list.add(InetAddress.getLocalHost().getHostAddress()); list.add(port); ObjectOutputStream oos = new ObjectOutputStream(soc.getOutputStream()); oos.writeObject(list); txtStatus.append("Node information send to Server.....\n"); } catch (IOException e) { e.printStackTrace(); } } }
Maximizing the Number of Broadcast Operations in Random Geometric Ad Hoc Wireless Networks
Page 91
try{ String clientIP=(String)li.get(1); int clientPort= (Integer)li.get(2); Socket soc=new Socket(clientIP,clientPort); ObjectOutputStream oos = new ObjectOutputStream(soc.getOutputStream());
int j=1; for (int i = currentValue; i >= 0; i--) { jProgressBar1.setValue(i); txtStatus.append("Packet-"+(j++)+" Received \n"); Thread.sleep(300); packet--; if(packet==-1){ break;
Maximizing the Number of Broadcast Operations in Random Geometric Ad Hoc Wireless Networks
Page 92
Maximizing the Number of Broadcast Operations in Random Geometric Ad Hoc Wireless Networks
Page 93
CHAPTER 7
SNAPSHOTS
7.2.1 LOGIN PAGE
Purpose: checking user credential.. Description: user can login by giving their username and password here.
Maximizing the Number of Broadcast Operations in Random Geometric Ad Hoc Wireless Networks
Page 94
Description: we use this to get the correct username and password from the user.
Maximizing the Number of Broadcast Operations in Random Geometric Ad Hoc Wireless Networks
Page 95
Description: During the process of submitting the registration form, user submits his basic identification information and also general information.
Maximizing the Number of Broadcast Operations in Random Geometric Ad Hoc Wireless Networks
Page 96
Description: user can get register by giving the following information by the registration page.
Maximizing the Number of Broadcast Operations in Random Geometric Ad Hoc Wireless Networks
Page 97
Description: here server can send message to the client same time gets all the information about all pivot node and from here we can broadcast and schedule for sending the message.
Maximizing the Number of Broadcast Operations in Random Geometric Ad Hoc Wireless Networks
Page 98
Description: server can choose the correct file which server has to send to the client.
Maximizing the Number of Broadcast Operations in Random Geometric Ad Hoc Wireless Networks
Page 99
CHAPTER 8
SOFTWARE TESTING
8.1 GENERAL
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.
Page 100
basic tests at component level and test a specific business process, application, and/or system configuration. Unit tests ensure that each unique path of a business process performs accurately to the documented specifications and contains clearly defined inputs and expected results.
Maximizing the Number of Broadcast Operations in Random Geometric Ad Hoc Wireless Networks
Page 101
Acceptance testing for Data Synchronization: The Acknowledgements will be received by the Sender Node after the Packets are received by the Destination Node The Route add operation is done only when there is a Route request in need The Status of Nodes information is done automatically in the Cache Updation process
Any project can be divided into units that can be further performed for detailed processing. Then a testing strategy for each of this unit is carried out. Unit testing helps to identity the possible bugs in the individual component, so the component that has bugs can be identified and can be rectified from errors.
Maximizing the Number of Broadcast Operations in Random Geometric Ad Hoc Wireless Networks
Page 102
REFERENCES:-
[1] A. Ephremides, G.D. Nguyen, and J.E. Wieselthier, On the Construction of Energy-Efficient Broadcast and Multicast Trees in Wireless Networks, Proc. IEEE INFOCOM, pp. 585-594, 2000. [2] I. Kang and R. Poovendran, Maximizing Network Lifetime of Wireless Broadcast Ad Hoc Networks, J. ACM Mobile Networks and Applications, vol. 10, no. 6, pp. 879-896, 2005. [3] C. Ambuehl, An Optimal Bound for the MST Algorithm to Compute Energy Efficient Broadcast Trees in Wireless Networks, Proc. Intl Colloquium Automata, Languages and Programming (ICALP 05), pp. 1139-1150, 2005. [4] G. Calinescu, X.Y. Li, O. Frieder, and P.J. Wan, Minimum-Energy Broadcast Routing in Static Ad Hoc Wireless Networks, Proc. IEEE INFOCOM, pp. 1162-1171, Apr. 2001. [5] G. Calinescu, S. Kapoor, A. Olshevsky, and A. Zelikovsky, Network Lifetime and Power Assignment in Ad Hoc Wireless Networks, Proc. European Symp. Algorithms (ESA 03), pp. 114-126, 2003
Maximizing the Number of Broadcast Operations in Random Geometric Ad Hoc Wireless Networks
Page 103