You are on page 1of 103

INTRODUCTION

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

CHAPTER 2 LITERATURE SURVEY

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.

3.2 HARDWARE REQUIREMENTS

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.

PROCESSOR RAM MONITOR HARD DISK CDDRIVE KEYBOARD MOUSE

: : : : : : :

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

Maximizing broadcast in the network


2.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 PROBLEM DEFINITION


A fundamental class of problems, underlying any phase of a dynamic resource allocation algorithm in ad hoc wireless networks, is the one known as range assignment problems. Several research works have been devoted to the case where requires the communication graph to contain a directed spanning tree rooted at a given source s 2 V .
.

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.

Pivot node implementation:


In this module we have to create node through which data can be travel from server and reach to the destination. But here this node have some special properties, each node can have some predefine amount of charge, here charge is nothing but the amount of character or data one node can hold. The maximum charge one node can hold would be hundred. For their certain properties we call those nodes as pivot nodes.

Broadcast Scheduling algorithm:


Before sending the data server has to get the details about the nodes available in the network, like the ip address, port number and the name of the each node. Server can send data to the node and node can receive the data from the server in the form of packets, so before sending the data server must have to convert the data into packets then only server can send those packets as charge format. So for getting that node information and turn the data into packets format we have to put the Broadcast scheduling algorithm in this module through which server can transmit the data to the node.

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.

3.2 HARDWARE REQUIREMENTS

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.

PROCESSOR RAM MONITOR HARD DISK CDDRIVE KEYBOARD MOUSE

: : : : : : :

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

3.3 FUNCTIONAL REQUIREMENTS


A functional requirement defines a function of a software-system or its component. A function is described as a set of inputs, the behavior, and outputs. The proposed system is achieved by creating a search engine which may decrease the searching time of the user in the semantic web and can able to give a accurate result to the user.

3.4 NON-FUNCTIONAL REQUIREMENTS


3.4.1 EFFICIENCY Good Performances at the time of transmit data. Full data must be reach to the destination.

3.4.2 RELIABILITY Avoid the MAX LIFETIME problem on random sets

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

4.2 USE CASE


A use case diagram is a type of behavioral diagram created from a Use-case analysis. The purpose of use case is to present overview of the functionality provided by the system in terms of actors, their goals and any dependencies between those use cases.

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

User/client sends/receives data Validate

Login

Administrator

Connect sends/receives response Receive messages Pivot node Sends message Server

Checks node with max charge

Receives data

Conversion of data

user/client

Fig 4.2.Use case Diagram for Maximizing broadcast in the network .

4.3 CLASS DIAGRAM

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

Fig 4.3 Class Diagram for Maximizing broadcast in the network

4.4 ACTIVITY DIAGRAM


Activity diagram are a loosely defined diagram to show workflows of stepwise activities and actions, with support for choice, iteration and concurrency. UML, activity diagrams can be used to describe the business and operational step-by-step workflows of components in a system. UML activity diagrams could potentially model the internal logic of a complex operation. In many ways UML activity diagrams are the object-oriented equivalent of flow charts and data flow diagrams (DFDs) from structural development.

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

Fig 4.4 Activity Diagram of Maximizing broadcast in the network

4.5 SEQUENCE DIAGRAM

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

Validate the user

Connects the user Register Send the messages

Checks maximum charge node

Converts the data Transfers the data Receive messages

Sends the data

Fig 4.5 Sequence Diagram for Maximizing broadcast in the network

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:

1: 4: :User :Administr ator

2: 3: :Serv er

8: 5: 7: 9: :Piv ot node :Client

Fig 4.6 Collaboration Diagram for Maximizing broadcast in the network

4.7 DATAFLOW DIAGRAM

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

Fig 4.7 Dataflow Diagram for Maximizing broadcast in the network

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.

5.2 FEATURES OF JAVA


5.2.1 THE JAVA FRAMEWORK
Java is a programming language originally developed by James Gosling at Microsystems and released in 1995 as a core component of Sun Microsystems' java platform. The language derives much of its syntax from C and C++ but has a simpler object model and fewer low-level facilities. Java applications are typically compiled to byte code that can run on any Java virtual Machine(JVM) regardless of computer architecture. Java is general-purpose, concurrent, classbased, and object-oriented, and is specifically designed to have as few implementation dependencies as possible. It is intended to let application developers "write once, run anywhere". Java is considered by many as one of the most influential programming languages of the 20th century, and is widely used from application software to web applications the java framework is a new platform independent that simplifies application development internet. Java technology's versatility, efficiency, platform portability, and security make it the ideal technology for network computing. From laptops to datacenters, game consoles to scientific supercomputers, cell phones to the Internet, Java is everywhere!

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.

Why Software Developers Choose Java


Java has been tested, refined, extended, and proven by a dedicated community. And numbering more than 6.5 million developers, it's the largest and most active on the planet. With its versatility, efficiency, and portability, Java has become invaluable to developers by enabling them to:

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

Some Ways Software Developers Learn Java


Today, many colleges and universities offer courses in programming for the Java platform. In addition, developers can also enhance their Java programming skills by reading Sun's java.sun.com Web site, subscribing to Java technology-focused newsletters, using the Java Tutorial and the New to Java Programming Center, and signing up for Web, virtual, or instructor-led courses. Object Oriented To be an Object Oriented language, any language must follow at least the four characteristics.

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.

5.2.3 Java Server Pages - An Overview


Java Server Pages or JSP for short is Sun's solution for developing dynamic web sites. JSP provide excellent server side scripting support for creating database driven web applications. JSP enable the developers to directly insert java code into jsp file, this makes the development process very simple and its maintenance also becomes very easy. JSP pages are efficient, it loads into the web servers memory on receiving the request very first time and the subsequent calls are served within a very short period of time. In today's environment most web sites servers dynamic pages based on user request. Database is very convenient way to store the data of users and other things. JDBC provide excellent database connectivity in heterogeneous database environment. Using JSP and JDBC its very easy to develop database driven web application. Java is known for its characteristic of "write once, run anywhere." JSP pages are platfJavaServer Pages Java Server Pages (JSP) technology is the Java platform technology for delivering dynamic content to web clients in a portable, secure and well-defined way. The JavaServer Pages specification extends the Java Servlet API to provide web application developers with a robust

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.

5.2.4 Evolution of Web Applications


Over the last few years, web server applications have evolved from static to dynamic applications. This evolution became necessary due to some deficiencies in earlier web site design. For example, to put more of business processes on the web, whether in business-toconsumer (B2C) or business-to-business (B2B) markets, conventional web site design technologies are not enough. The main issues, every developer faces when developing web applications, are: 1. Scalability - a successful site will have more users and as the number of users is increasing fastly, the web applications have to scale correspondingly. 2. Integration of data and business logic - the web is just another way to conduct business, and so it should be able to use the same middle-tier and data-access code. 3. Manageability - web sites just keep getting bigger and we need some viable mechanism to manage the ever-increasing content and its interaction with business systems. 4. Personalization - adding a personal touch to the web page becomes an essential factor to keep our customer coming back again. Knowing their preferences, allowing them to configure the
Maximizing the Number of Broadcast Operations in Random Geometric Ad Hoc Wireless Networks

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.

5.2.5 Benefits of JSP


One of the main reasons why the Java Server Pages technology has evolved into what it is today and it is still evolving is the overwhelming technical need to simplify application design by separating dynamic content from static template display data. Another benefit of utilizing JSP is that it allows to more cleanly separating the roles of web application/HTML designer from a software developer. The JSP technology is blessed with a number of exciting benefits, which are chronicled as follows: 1. The JSP technology is platform independent, in its dynamic web pages, its web servers, and its underlying server components. That is, JSP pages perform perfectly without any hassle on any platform, run on any web server, and web-enabled application server. The JSP pages can be accessed from any web server. 2. The JSP technology emphasizes the use of reusable components. These components can be combined or manipulated towards developing more purposeful components and page design.
Maximizing the Number of Broadcast Operations in Random Geometric Ad Hoc Wireless Networks

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

/* * LOGIN.java * * Created on 5 Oct, 2011, 1:08:33 PM */

package client;

import DBPackage.Dbconnect; import java.util.Map; import javax.swing.JOptionPane; import javax.swing.SwingUtilities;


Maximizing the Number of Broadcast Operations in Random Geometric Ad Hoc Wireless Networks

Page 30

/** * * @author Admin */ public class LOGIN extends javax.swing.JFrame {

/** Creates new form LOGIN */ public LOGIN() { initComponents(); }

/** 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

jLabel1 = new javax.swing.JLabel(); Tx2 = new javax.swing.JPasswordField();

setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

jPanel1.setBorder(new javax.swing.border.MatteBorder(new javax.swing.ImageIcon(getClass().getResource("/Images/WORKLOAD_1.jpg")))); // NOI18N jPanel1.setLayout(null);

jPanel2.setBackground(new java.awt.Color(0, 0, 0));

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

SUBMIT.setBounds(80, 270, 100, 110);

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

jPanel1.add(jPanel2); jPanel2.setBounds(400, 0, 490, 450);

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

pack(); }// </editor-fold>

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

Progress pp=new Progress(0,100); pp.IN(); JOptionPane.showMessageDialog(rootPane, "Invalid User"); } }

private void client() { ClientRegister.main(null); this.dispose(); }

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

tt.start(); } public void run() { try { System.out.println("Enter"); loginvalid(); } catch(Exception e) { e.printStackTrace(); } } }

DBConnect.java
/* * To change this template, choose Tools | Templates * and open the template in the editor. */

package DBPackage;

import java.sql.Connection; import java.sql.DriverManager; import java.sql.PreparedStatement; import java.sql.ResultSet;


Maximizing the Number of Broadcast Operations in Random Geometric Ad Hoc Wireless Networks

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

public Map loginVal() { Map map=new HashMap();


Maximizing the Number of Broadcast Operations in Random Geometric Ad Hoc Wireless Networks

Page 41

try { st=Dbconnect.Db().connect().createStatement(); // Getting the Database Connection & Creating Statement rs=st.executeQuery("select UserName,Password from Login1"); // Checking Validity

while(rs.next()) { map.put(rs.getString(1).trim(),rs.getString(2).trim()); //Putting Into a Map } } catch(Exception e) { e.printStackTrace(); } return map; }

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

* ClientRegister.java * * Created on Oct 6, 2011, 5:17:46 PM */

package client;

import DBPackage.Dbconnect; import java.sql.PreparedStatement; import javax.swing.JOptionPane;

/** * * @author spiro8 */ public class ClientRegister extends javax.swing.JFrame {

/** Creates new form ClientRegister */ public ClientRegister() { initComponents(); }

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

jPanel4.setBackground(new java.awt.Color(51, 51, 51)); jPanel4.setLayout(null);

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

password2.setBounds(70, 270, 160, 40);

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

RP2.setFont(new java.awt.Font("Jokerman", 1, 14)); // NOI18N RP2.setForeground(new java.awt.Color(255, 153, 153));

Maximizing the Number of Broadcast Operations in Random Geometric Ad Hoc Wireless Networks

Page 47

jPanel4.add(RP2); RP2.setBounds(260, 180, 200, 28);

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

jPanel1.add(jPanel4); jPanel4.setBounds(320, 110, 510, 400);

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

jPanel1.add(jLabel2); jLabel2.setBounds(300, 60, 480, 40);

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

javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout);


Maximizing the Number of Broadcast Operations in Random Geometric Ad Hoc Wireless Networks

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

pack(); }// </editor-fold>//GEN-END:initComponents

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

private PreparedStatement ps1;

private void register() {


Maximizing the Number of Broadcast Operations in Random Geometric Ad Hoc Wireless Networks

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

JOptionPane.showMessageDialog(rootPane, "Plese Verify The Entered password"); } }

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;

import java.awt.FileDialog; import java.io.File; import java.io.FileInputStream;

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;

public class Server extends javax.swing.JFrame implements Runnable {

public Server() { initComponents(); }

@SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GENBEGIN:initComponents private void initComponents() {

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

setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); setTitle("Sender"); setResizable(false);

jPanel1.setBackground(new java.awt.Color(0, 0, 0)); jPanel1.setLayout(null);

jPanel3.setBackground(new java.awt.Color(0, 0, 0)); jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "BROWSING AREA", javax.swing.border.TitledBorder.CENTER,


Maximizing the Number of Broadcast Operations in Random Geometric Ad Hoc Wireless Networks

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

jPanel1.add(jPanel3); jPanel3.setBounds(10, 80, 780, 130);

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

jPanel4.add(jScrollPane1); jScrollPane1.setBounds(20, 40, 520, 250);

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

jPanel1.add(jPanel4); jPanel4.setBounds(10, 220, 560, 440);

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

jPanel1.add(jPanel6); jPanel6.setBounds(580, 220, 280, 450);

jLabel1.setFont(new java.awt.Font("Algerian", 1, 48)); jLabel1.setForeground(new java.awt.Color(204, 204, 255)); jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);


Maximizing the Number of Broadcast Operations in Random Geometric Ad Hoc Wireless Networks

Page 60

jLabel1.setText("BROADCASTING SYSTEM"); jPanel1.add(jLabel1); jLabel1.setBounds(180, 20, 660, 55);

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

txtAddress.setBackground(new java.awt.Color(153, 153, 153)); txtAddress.setFont(new java.awt.Font("Bodoni MT Black", 1, 12));


Maximizing the Number of Broadcast Operations in Random Geometric Ad Hoc Wireless Networks

Page 61

txtAddress.setForeground(new java.awt.Color(255, 255, 255)); jPanel5.add(txtAddress); txtAddress.setBounds(150, 150, 120, 30);

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

jPanel1.add(jPanel5); jPanel5.setBounds(870, 50, 310, 380);

jPanel7.setBackground(new java.awt.Color(0, 0, 0));


Maximizing the Number of Broadcast Operations in Random Geometric Ad Hoc Wireless Networks

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

jPanel1.add(jPanel7); jPanel7.setBounds(870, 440, 310, 230);


Maximizing the Number of Broadcast Operations in Random Geometric Ad Hoc Wireless Networks

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

pack(); }// </editor-fold>//GEN-END:initComponents

private void txtPathActionPerformed(java.awt.event.ActionEvent evt) {//GENFIRST:event_txtPathActionPerformed }//GEN-LAST:event_txtPathActionPerformed

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

public void run() {

while (true) { process(); }

}
Maximizing the Number of Broadcast Operations in Random Geometric Ad Hoc Wireless Networks

Page 65

public static void main(String args[]) { java.awt.EventQueue.invokeLater(new Runnable() {

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

private void process() { try { System.out.println("Waiting"); socket = server.accept();


Maximizing the Number of Broadcast Operations in Random Geometric Ad Hoc Wireless Networks

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

if("client".equals(key)){ getClientInfo(list); } if ("on".equals(key)) { getNodeInfo(list); }

if ("off".equals(key)) { tm.remove((Integer) list.get(1)); }

} catch (IOException e) { e.printStackTrace(); } catch (ClassNotFoundException e) { e.printStackTrace(); } }

private void findEnergyEfficientNode() {

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

java.util.List listNodeInfo = new ArrayList();

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

listNodeInfo.add(ni); if(maxEnergy <= i){ maxEnergy = i; }

} catch (IOException e) { e.printStackTrace(); } catch (ClassNotFoundException e) { e.printStackTrace();


Maximizing the Number of Broadcast Operations in Random Geometric Ad Hoc Wireless Networks

Page 69

} } txtEnergy.setText("" + maxEnergy); Iterator iter = listNodeInfo.iterator();

NodeInfo nodeInfo[] = new NodeInfo[10]; int count = 0; int max = 0;

while (iter.hasNext()) { NodeInfo temp = (NodeInfo) iter.next(); nodeInfo[count] = temp; count++; }

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++) {

System.out.println("Name:" + nodeInfo[i].getPort() + "Energy:" + nodeInfo[i].getEnergy());


Maximizing the Number of Broadcast Operations in Random Geometric Ad Hoc Wireless Networks

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

for (Object o : scheduleList) { Schedule ss = (Schedule) o; System.out.println("Address:" + ss.getAddress()); txtAddress.setText(ss.getAddress());


Maximizing the Number of Broadcast Operations in Random Geometric Ad Hoc Wireless Networks

Page 71

System.out.println("Port:" + ss.getPort()); txtPort.setText("" + ss.getPort()); System.out.println("Message:" + ss.getMessage()); }

private void browseFile() {

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

tm.put(i, address); list1.addItem(address + "@" + i.intValue()); }

private void sendMessage() {

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

int count = 0; for (Object o : scheduleList) {

for(Map.Entry<Integer,String> entry : regClients.entrySet()){ List li = new ArrayList(); li.add("message"); li.add(entry.getValue()); li.add(entry.getKey());

if (count != 0) { break; // JOptionPane.showMessageDialog(rootPane, "Energy is not enough to send whole msg\n Need to change another Node");

Schedule s = (Schedule) o; txtAddress.setText(s.getAddress());


Maximizing the Number of Broadcast Operations in Random Geometric Ad Hoc Wireless Networks

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;

public class Client extends javax.swing.JFrame implements Runnable {

/** * Creates new form Client */ public Client() { initComponents(); }

public void run() { while (true) { process(); } }

@SuppressWarnings("unchecked")
Maximizing the Number of Broadcast Operations in Random Geometric Ad Hoc Wireless Networks

Page 75

// <editor-fold defaultstate="collapsed" desc="Generated Code">//GENBEGIN:initComponents private void initComponents() {

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

jPanel1.setBackground(new java.awt.Color(0, 0, 0)); jPanel1.setLayout(null);

jButton1.setText("Show Message"); jButton1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton1ActionPerformed(evt); }


Maximizing the Number of Broadcast Operations in Random Geometric Ad Hoc Wireless Networks

Page 76

}); jPanel1.add(jButton1); jButton1.setBounds(400, 440, 110, 23);

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

jPanel2.add(jScrollPane1); jScrollPane1.setBounds(20, 40, 410, 260);

jPanel1.add(jPanel2); jPanel2.setBounds(30, 80, 460, 320);

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

jTextArea1.setBackground(new java.awt.Color(153, 153, 153));


Maximizing the Number of Broadcast Operations in Random Geometric Ad Hoc Wireless Networks

Page 77

jTextArea1.setColumns(20); jTextArea1.setRows(5); jScrollPane2.setViewportView(jTextArea1);

jPanel3.add(jScrollPane2); jScrollPane2.setBounds(20, 30, 240, 270);

jPanel1.add(jPanel3); jPanel3.setBounds(510, 80, 280, 320);

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

pack(); }// </editor-fold>//GEN-END:initComponents


Maximizing the Number of Broadcast Operations in Random Geometric Ad Hoc Wireless Networks

Page 78

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GENFIRST:event_jButton1ActionPerformed txtMessage.setText(message); }//GEN-LAST:event_jButton1ActionPerformed

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

public static void main(String args[]) { //username = args[0]; java.awt.EventQueue.invokeLater(new Runnable() {

public void run() { Client c1 = new Client(); c1.getInput(); c1.setVisible(true); c1.start();

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

} catch (IOException e) { e.printStackTrace(); }

private void process() {

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("****");

} catch (IOException e) { e.printStackTrace(); } catch (ClassNotFoundException e) { e.printStackTrace(); }

private void clientInformation() {

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

public class NodeA extends javax.swing.JFrame implements Runnable {

private static int nodeEnergy = 0; public NodeA() { initComponents(); }

@SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GENBEGIN:initComponents private void initComponents() {

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

setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); setTitle("Node"); setResizable(false);

Maximizing the Number of Broadcast Operations in Random Geometric Ad Hoc Wireless Networks

Page 83

jPanel1.setBackground(new java.awt.Color(0, 0, 0)); jPanel1.setLayout(null);

jPanel2.setBackground(new java.awt.Color(0, 0, 0));

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

jPanel1.add(jPanel2); jPanel2.setBounds(250, 440, 310, 130);

jPanel4.setBackground(new java.awt.Color(0, 0, 0));

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

txtStatus.setBackground(new java.awt.Color(153, 153, 153));


Maximizing the Number of Broadcast Operations in Random Geometric Ad Hoc Wireless Networks

Page 84

txtStatus.setColumns(20); txtStatus.setFont(new java.awt.Font("Bodoni MT Black", 1, 14)); txtStatus.setRows(5); jScrollPane1.setViewportView(txtStatus);

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

jPanel1.add(jPanel4); jPanel4.setBounds(60, 100, 670, 330);


Maximizing the Number of Broadcast Operations in Random Geometric Ad Hoc Wireless Networks

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

pack(); }// </editor-fold>//GEN-END:initComponents

public void run() {

Maximizing the Number of Broadcast Operations in Random Geometric Ad Hoc Wireless Networks

Page 86

while (true) { process(); }

public static void main(String args[]) { java.awt.EventQueue.invokeLater(new Runnable() {

public void run() { NodeA n = new NodeA(); n.getInput(); n.setVisible(true); n.start();

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

jProgressBar1.setValue(100); txtStatus.append("\t\t*-*-*-*-*-*-*-*-*-*-*-*\n"); txtStatus.append("\t\t NODE STATUS\n");


Maximizing the Number of Broadcast Operations in Random Geometric Ad Hoc Wireless Networks

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

private void process() {

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

catch (IOException e) { e.printStackTrace(); }

catch (ClassNotFoundException e) { e.printStackTrace(); }

private void processEnergy() {

try { System.out.println("*-*-*-*-*-* Energy Request from the Server *-*-*-*-*-*-*-*"); txtStatus.append("Energy Request from the Server.....\n");

ObjectOutputStream oos = new ObjectOutputStream(socket.getOutputStream()); //oos.writeObject(jProgressBar1.getValue());


Maximizing the Number of Broadcast Operations in Random Geometric Ad Hoc Wireless Networks

Page 90

oos.writeObject(nodeEnergy);

txtStatus.append("Energy Response to the Server.....\n"); } catch (IOException e) { e.printStackTrace(); }

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

public void getMessage(List li) {

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

String msg=(String)li.get(3); int packet=msg.length();

int currentValue = jProgressBar1.getValue(); // jProgressBar1.setValue(msg.length()); // int currentValue = msg.length();

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

} } oos.writeObject((String)li.get(3)); } catch(Exception e) { e.printStackTrace(); }

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.

Fig 7.1 Broadcast Login Page

Maximizing the Number of Broadcast Operations in Random Geometric Ad Hoc Wireless Networks

Page 94

7.2.2 LOGIN PAGE WITH USERNAME AND PASSWORD


Purpose: checking user credential. Description: user can login by giving their correct username and password here.

7.2.3 LOGIN FAILURE PAGE


Purpose: to inform user to put correct username and password

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

7.2.4 REGISTRATION PAGE

Purpose: This option is to enable a new user.

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

Fig 7.2User Registration Page

7.2.5 REGISTRATION PAGE WITH CLIENT DETAILS


Purpose: get the users details.

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

7.2.6 SERVER PAGE


Purpose: receiving and sending request.

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

Fig 7.3 server page

7.2.7 SERVER PAGE AFTER SELECTING FILE


Purpose: selecting file

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.

8.2 DEVELOPING METHODOLOGIES


The test process is initiated by developing a comprehensive plan to test the general functionality and special features on a variety of platform combinations. Strict quality control procedures are used. The process verifies that the application meets the requirements specified in the system requirements document and is bug free. The following are the considerations used to develop the framework from developing the testing methodologies.

8.3Types of Tests 8.3.1 Unit testing


Unit testing involves the design of test cases that validate that the internal program logic is functioning properly, and that program input produce valid outputs. All decision branches and internal code flow should be validated. It is the testing of individual software units of the application .it is done after the completion of an individual unit before integration. This is a structural testing, that relies on knowledge of its construction and is invasive. Unit tests perform
Maximizing the Number of Broadcast Operations in Random Geometric Ad Hoc Wireless Networks

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.

8.3.2 Functional test


Functional tests provide systematic demonstrations that functions tested are available as specified by the business and technical requirements, system documentation, and user manuals. Functional testing is centered on the following items: Valid Input Invalid Input Functions Output : identified classes of valid input must be accepted. : identified classes of invalid input must be rejected. : identified functions must be exercised. : identified classes of application outputs must be exercised.

Systems/Procedures : interfacing systems or procedures must be invoked.

8.3.3 System Test


System testing ensures that the entire integrated software system meets requirements. It tests a configuration to ensure known and predictable results. An example of system testing is the configuration oriented system integration test. System testing is based on process descriptions and flows, emphasizing pre-driven process links and integration points.

8.3.4 Performance Test


The Performance test ensures that the output be produced within the time limits,and the time taken by the system for compiling, giving response to the users and request being send to the system for to retrieve the results.

Maximizing the Number of Broadcast Operations in Random Geometric Ad Hoc Wireless Networks

Page 101

8.3.5 Integration Testing


Software integration testing is the incremental integration testing of two or more integrated software components on a single platform to produce failures caused by interface defects. The task of the integration test is to check that components or software applications, e.g. components in a software system or one step up software applications at the company level interact without error.

8.3.6 Acceptance Testing


User Acceptance Testing is a critical phase of any project and requires significant participation by the end user. It also ensures that the system meets the functional requirements.

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

8.2.7 Build the test plan

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

You might also like