Abstract - WPI
Project Number: CS-EOA-0009
A LOCATION AWARE SECURITY APPLICATION
A Major Qualifying Project Report:
submitted to the Faculty
of the
WORCESTER POLYTECHNIC INSTITUTE
in partial fulfillment of the requirements for the
Degree of Bachelor of Science
by
_________________________________
Andrew J. Bangs
_________________________________
Shaun M. Haerinck
_________________________________
Aubrey J. Klaft
Date: March 3, 2006
Approved:
_________________________________
Professor Emmanuel O. Agu
1. wireless networking
2. security
3. computers
Abstract
Lending out computer hardware provides benefits in productivity, but has always run the risk of material theft. The goal was to create Nooget, a platform independent, software only, indoor laptop security system, where many devices could be tracked from a central location using the 802.11 Wireless Local Area Network standard. It was created in Java, using modules with an object orientated design, and is able to accurately locate a user to within 10 feet.
Acknowledgements
We would like to give special thanks to our advisor, Professor Emmanuel Agu, of the WPI Computer Science department, for his dedication, assistance, and patience throughout this project. His perseverance and determination to succeed helped us realize our potential and aided us in seeing our project reach completion.
We would also like to recognize the WPI employees who assisted our group along the way. In particular, we’d like to thank Chris Salter and all of WPI’s Plant Services employees for donating the campus maps we used in our project. Without these maps, Nooget would not have the visual aspect that is needed to display a client’s location. We’d also like to thank Justin Brooks for answering all the questions we had regarding the ATC laptops. The information he provided allowed us to compare different laptops and gather necessary statistics about the various hardware. Additionally, we would like to thank the entire staffing at the Gordon Library for allowing us to use their facilities to test our applications. The staff was consistently friendly and willing to help when asked. Thank you all for the time you devoted to our project.
Andrew would like to thank his father, Gary, for his support throughout his academic career. The encouragement he’s received has been invaluable, and has given him the persistence to never give up. He would also like to thank his brother, Corey, for providing my drive for competition. Aubrey would like to thank his parents, Walter and Lynne, and his brother Peter for their steadfast love and support throughout his life. He would also like to thank his friends for keeping him sane during a tough year. Shaun would like to personally thank his mother, Nancy, and father, Donald, for their continual encouragement and inspiration. Their leadership and guidance was the stepping stone to his success today. He would also like to thank his sisters, Amber and Christine, and his girlfriend, Rebecca, for always being there when he needed advice. Thank you, everyone, for all you’ve done for us.
Table of Contents
i. Abstract 2
ii. Acknowledgements 3
iii. Table of Contents 5
iv. List of Figures 7
1. Introduction 8
2. Background 10
2.1. Potential Applications 10
3. Research 12
3.1. Delivering REAL-WORLD Ubiquitous Location Systems 12
3.2. NetStumbler 14
3.3. Locus 15
4. Tools 18
4.1. Place Lab 18
4.1.1. What is Place Lab? 18
4.1.2. How Does Place Lab Work? 18
4.1.3. How did Nooget use Place Lab? 19
4.1.4. Why did Nooget use Place Lab over Other Options? 21
4.1.5. What were the Benefits of using Place Lab? 22
4.1.6. What were the Drawbacks of using Place Lab? 24
4.2. Nooget 25
4.2.1. Calibration 26
4.2.2. XML Encryption 28
4.2.3. CalibrationGUI 28
4.2.4. Location Matching 30
4.2.5. Client 31
4.2.6. Server 31
4.2.7. Design 33
4.2.8. Final Product (GUI) 34
5. Results 38
5.1. Tests 38
5.2. Experiments 39
5.3. Signal Strength Tests 41
5.4. Technical Issues 42
5.5. Successful Aspects 43
5.6. Unsuccessful Aspects 44
5.7. Practicality 44
5.8. Expansion of Nooget 45
6. Future Work 47
6.1. GPS 47
6.2. Laptop Location Constraints 47
6.3. Implement Smaller Devices 48
6.4. Campus Map/Zooming 48
6.5. Go To Specific IP Location 49
6.6. Hide Client Program from User 50
7. Conclusion 51
8. Nooget Setup Procedures 52
8.1. Steps to Take When Installing Nooget: 52
8.2. To Run the Server 53
8.3. To Run the Client 53
9. References 54
10. Appendix 55
10.1. Code 55
10.1.1. noogetServer.java 55
10.1.2. noogetProtocol.java 67
10.1.3. noogetMultiServer.java 68
10.1.4. noogetMultiServerThread.java 69
10.1.5. noogetConnection.java 70
10.1.6. noogetClientSocket.java 71
10.1.7. createCalibration.java 73
10.1.8. clientFuncs.java 75
10.1.9. calibrationGUI.java 77
10.1.10. noogetCore\calibration.java 87
10.1.11. noogetXML\noogCoord.java 91
10.1.12. noogetXML\DesEncryptor.java 93
10.1.13. noogetXML\coordList.java 95
10.1.14. noogetXML\beaconList.java 101
10.1.15. noogetXML\Beacon.java 102
List of Figures
Figure 1 - WPI Campus Using Nooget 9
Figure 2 - Nooget's Integration with Place Lab 20
Figure 3 - High Level Flow Diagram 25
Figure 4 - Typical Client Server Relationship 26
Figure 5 - toOurLogString() in BeaconMeasurement.java 27
Figure 6 - toOurLogString() in WiFiReading.java 27
Figure 7 - Calibration Flow Chart 28
Figure 8 - Sample CalibrationGUI Output 29
Figure 9 - Design Structure of a coordList 33
Figure 10 - Design Structure of the XML Format 34
Figure 11 - CalibrationGUI 35
Figure 12 - Find Location Tab of Server GUI 36
Figure 13 - All Connections Tab of Server GUI 37
Figure 14 - WPI Campus Map 38
Figure 15 - Server During Testing 40
Figure 16 - Signal Strength Over Five Hours 41
Figure 17 - Absolute Average Signal Strengths 42
Introduction
The information revolution is one of the most significant events in human history. It has transformed our lives in such a way that a world without the internet or computers can scarcely be imagined. The ever increasing coverage of wireless internet and the ever decreasing cost of computer hardware have led to situations where academic and corporate institutions often make computer wireless hardware available for general use. Unfortunately the very portability and ease of use that make the hardware desirable also makes it a tempting target for theft. There is then a choice to accept the losses, stop lending out hardware, or attempt to control the movements of the hardware somehow.
This MQP will provide an application that can be used by the CCC, ATC, Campus Center, or Library departments of WPI to track the laptops that are rented by students and faculty. The client portion of the software would be installed on each of the laptops that can be borrowed, and upon starting the machine, the client is loaded and begins running. Ideally, the user should be unaware that the client program is running on his laptop, and it should not interfere with the laptop’s operation. While the client is running, the wireless network is queried continuously, and according to the signal strengths of nearby access points, the laptop’s location can be determined. This location is then sent to the server and displayed on screen, to be analyzed by an administrator of whichever department loaned out the laptop. In this manner, Nooget provides a type of security system similar to Lo-Jack, where if a laptop leaves the designated area, reactionary action can be taken before the laptop is lost. Figure 1 displays this scenario for the WPI campus:
[pic]
Figure 1 - WPI Campus Using Nooget
Background
WiFi Location Systems (WFS) are a proven technology. However little research has been done on client-server systems, where objects’ locations are tracked by another machine. There are a plethora of potential uses for such a system. Many organizations, such as governments, corporations, college campuses and many other places, will be able to find a use for such a system.
1 Potential Applications
The primary prospective use is for security. The ability to know the location of computing devices from a central location will help protect personal property. There are many situations where computer equipment is loaned to people, such as in archives and libraries or on college campuses. The computers would be less prone to theft if their location could be carefully monitored. This becomes even more important if sensitive data or important hardware is present on the computer. The theft of a company laptop could be written off, but a corporation would be more concerned with losing company secrets. Similarly, people could be monitored by the equipment they carried. Companies could require employees to carry around a badge or PDA that would transmit their location to a central location. As wireless networks become more and more ubiquitous, WFS could become an important supplement to GPS in location, especially indoors.
Another application for the technology is in management. It could be very useful to know where people are in a wireless-enabled area. For example a police dispatcher might be more efficient if he could tell at a glance where all the patrol cars under his supervision are located. Similarly in a corporate environment, monitoring peoples’ locations could help improve efficiency. Software to navigate warehouses and locate stock could be very useful. Any situations where resources are deployed to locations could benefit from monitoring of those resources.
The WPS technology could be useful for research, as well. Studies in crowd flow could benefit from location sensing wireless systems. Monitoring the locations and paths of people could be of great benefit to traffic control studies. Similarly, one could study flows of fluid through plumbing systems. Any time a location is necessary to research, and GPS is not practical, this type of system may be utilized.
Navigation is another potential use for WFSs. Devices could help people navigate inside buildings and underground, where GPS is less useful. Museums, colleges, and other institutions could also use the technology to provide self-guided tours. Even drivers could benefit, as wireless location finding could be used to navigate roads and highways, especially around cites. The ability for a central location to know where a particular user is could be useful for targeted information, such as traffic information or advertising.
This project is necessary to prove that a client-server type system can work. There are several hurdles to overcome. These include the accuracy of the location sensing, the practicality of using the networking hardware for both location and internet connection and number and density of access points necessary for accurate results. In order to overcome these hurdles, a proof of concept must be produced.
Research
1 Delivering REAL-WORLD Ubiquitous Location Systems
The paper, Delivering REAL-WORLD Ubiquitous, Location Systems [DELIV], stresses the practical aspects of getting location-enhanced applications deployed on existing devices. Over the past two decades, a vast number of research and commercial location systems have been developed with the primary goals of either providing highly accurate location estimates over a small area or lower accuracy location estimates over a larger area.
The most widely known example of this is the Global Positioning Systems (GPS). The GPS network is made up of 21 satellites continually orbiting around the Earth at an altitude of 10,900 nautical miles. These satellites transmit their locations to receivers located within enabled devices. GPS capable devices have the ability to locate an individual within feet under the most optimal conditions. However, the biggest drawback to GPS devices is its poor performance when tracking a device that is indoors. The radio signals sent by GPS satellites are too weak to penetrate the walls of most building, and even dense vegetation. As a result, GPS is widely used in navigation but is not commonly used for any indoor applications.
Another largely popular location tracking service that exists today is provided by the wireless phone companies. Cell phone companies are mandated to track each cell phone user of their company to within 100 meters in order to allow emergency crews to be able to locate an individual in need of assistance. In order to do this, companies have experimented with signal propagation models and augmentation of handsets using GPS chips. The current cellular network is subdivided into multiple hexagonal areas. Each cell is configured to transmit at a channel that does not interfere with its neighboring cells. Since each cell phone company has millions of users, the cell phone industry is an excellent candidate for service deployment.
The third major design for tracking a device uses 802.11 signals to estimate a user’s location. Microsoft Research’s RADAR system showed that estimating location based on nearby 802.11 access points can produce readings that accurate to within 3 meters on standard laptops. They did this by performing calibrations on a 1 meter grid to create a virtual map that contains all the access points that a laptop receives signals from. The system then performs empirical measurements with signal propagation modeling to determine user location.
Place Lab has also tried to expand upon the 802.11 approach to tracking the location of devices. Instead of using recalibrated fingerprints used in the Microsoft Research’s RADAR approach, Place Lab predicts the location of access points by detecting their signal strengths on the device itself. A database is locally cached on the device that compares these signal strengths to the ones read in. If a reading matches a point located in the database, the corresponding map is displayed with the current location. If no signals can be detected from the device, Place Lab will use surrounding Global System for Mobile Communications (GSM) cell towers and fixed Bluetooth devices in order to map the location of the user. Universities, radio hobbyists, Wi-Fi clubs, and interested users are the backbone to the Place Lab network because these users are the ones who add their own calibration points to a central database in order for the database to expand. Larger cities, such as Seattle and Paris, provide the most coverage because of the popularity of war-driving[1] activities in these areas.
Although the 802.11 design for using signal strengths to track the location of a device is very accurate, 802.11 wireless signals have a tendency to vary due to changes in the environment. Such changes are caused by weather, the redecoration of furniture, absorption of wireless signals into humans, and even hardware differences among laptops and other 802.11 enabled devices. Also, the 802.11 system of tracking does not typically work well in less populated areas due to the minimal number of access points but it does thrive in communities with a large number of 802.11 access points, such as university campuses. More details about Place Lab structure will be discussed in section 4.1 of this MQP.
2 NetStumbler
NetStumbler [NETSweb] is an 802.11 software package that allows a user to detect surrounding Wireless Local Area Networks, as well as signal strengths from the access points. The software can be used to find locations of poor coverage in a particular area, detect unauthorized access points located around the device, and discover other networks that may be causing interference with the user’s network. The NetStumbler graphical user interface displays all of the surrounding access points located by the device. The access points list the current signal strength from the given location, whether the access point has filters installed, and how many filters are installed. These filters can include the Wired Equivalent Privacy (WEP) protocol or the Wi-Fi Protected Access (WPA) protocol, depending on the security of the wireless network.
NetStumbler works by sending out probe requests and waits for the responses. These probe requests ask the access points for their MAC address, security protocol, and determines the strengths of the signals returned. If the NetStumbler software loaded on the device has TCP/IP enabled, the device will request a temporary IP address from security administrators who monitor the access point. NetStumbler will then record if an IP address has been returned. Unlike the Place Lab, NetStumbler will disconnect a device from its current network if it believes there is a network with better signal strengths located around the device.
3 Locus
The idea for Nooget was based off a previous MQP entitled Locus [LOCUSweb]. Locus is a platform independent location awareness software package which allows users to locate their position on a map. Similar to both Place Lab and NetStumbler, Locus uses the 802.11b Wireless Local Area Network infrastructure to calculate the current location of the device. Locus is written in Java and uses Scalable Vector Graphics to display locally cached maps of the user’s location.
Instead of using a grid pattern approach seen in Microsoft’s RADAR, where the user calibrates the device for a particular map on a grid and a best match algorithm is used to determine the most probably location, Locus uses proximity in order to determine the location of the device. Proximity is where a device searches for signals being broadcasted from the devices around it. Locus has three modes; “Calibrate”, “Locate”, and “Update”. When set in “Calibrate” mode, the user calibrates the device for the specific point on the map where the device is located and takes a series of calibrations while rotating the direction of the device. This is done in order to ensure that the readings are averaged together from four perpendicular angles, since signal strengths tend to be directional. The (x, y) location of the user is then recorded in a database along with the corresponding combination of signal strengths for access points. After this calibration phase is completed for multiple points, a user is able to test the software.
When the software is in “Locate” or “Update” modes, the device will use the incoming signal strengths received and compare them to the ones stored within a cached tuple of previously calibrated points. As was previously mentioned, Locus uses proximity to find the strengths being given off in a circular radius around the device instead of finding a direct path from the access points. Where the three closest access points overlap is the most probable location of the device. This method of location discovery allows the user to be located in a specific spot which has not been calibrated directly. By averaging the nearest calibrated readings, the user’s position can be more accurately determined. However, this may lead to inaccurate results due to spikes in the signals received which prevent from accurately displaying the correct location. This is discussed further in section 4.1.4.
Locus displays their graphs in Scalable Vector Graphics (SVG) format. In order to do this, Locus relied on Batik. Batik is a Java based toolkit that allows applications to view and manipulate pictures with the .SVG extension. Batik must be installed on the device that is using Locus in order for the map to load properly. This dependency expands the installation size of Locus by two thirds. Although Locus was not designed to be a hidden process, the person using Locus may notice the software’s size. This had to be taken into account when designing Nooget because the client should be hidden to the client. This is done in order to prevent the user from congestion on their mobile device’s desktop.
Tools
1 Place Lab
1 What is Place Lab?
Place Lab [PLACEweb] is open source software that allows notebooks, PDAs, and cell phones to determine their location by using signals received from radio beacons. These radio beacons can be in the form of GSM cell phone towers, Bluetooth devices, or 802.11 access points, which are used exclusively by Nooget. Place Lab software stands apart from other services by allowing its clients to determine their location privately, without the constant interaction of a central monitor. The software is also configured to work both indoors and outdoors, unlike many services such as GPS which only work outdoors.
2 How Does Place Lab Work?
The Place Lab software works by receiving signal strengths from surrounding radio beacons, such as wireless access points, Bluetooth devices, and GSM cell towers. The software is configured to query the hardware of the device it is installed on, retrieve and store the incoming radio beacon information. The information stored can be used to display a cached map of the current location of the device. The software is able to find this map because it stores the MAC addresses and the signal strengths of the radio beacons and triangulates its position based on a lookup table of coordinates. These coordinates are cross referenced with both the Place Lab database and a user created database stored on the device. One of Place Lab’s inherent features is that any user can add their own coordinates to their personal Place Lab database and upload these coordinates to Place Lab’s central database for other users. This is frequently done by groups of war-drivers, who map entire cities for the benefit of others [INTELweb].
3 How did Nooget use Place Lab?
Place Lab comes with a variety of executables that provide useful examples of how to use their software effectively. One of these, the Place Lab Stumbler GUI, was the most useful. This example displayed an interface which read in the signal strengths from the surrounding 802.11 access points and GPS beacons. Nooget was not designed to use GPS. This was mainly due to the target user population being residents of the campus. Since it is unlikely the users would leave campus with the software installed on their laptops, it would be unnecessary to devote the limited development time towards that end. The Place Lab Stumbler GUI example also contained more information than was needed for the project, so the stumbler was stripped down to the bare essentials and were expanded from there. As it turns out, the only information used from the GUI were the signal strengths received from the surrounding access points, the MAC addresses associated with these points, and the time that the individual signal strengths were read.
In order to use the logging functionality of Place Lab, three files were modified to support the logging system. The overall structure of Nooget’s integration with Place Lab is displayed in Figure 2:
[pic]
Figure 2 - Nooget's Integration with Place Lab
The first modified file was BeaconReading.java. It was modified by adding in a function that takes the current signal strength readings and corresponding MAC addresses and stores them in a XML log file. When Nooget’s CalibrationGUI is run, it calls the function to store the signal strengths as well as corresponding x and y values for the current location of the user. In order for Nooget to associate signal strengths from different MAC addresses to maps cached on the server, these x and y values are obtained from an administrator who takes calibrations with a laptop or 802.11 ready device. As a safety precaution, we encrypted the XML file in order to prevent a user from tampering with it. This operation allowed the contents of the XML file to be kept safe but also limited experimental testing. The other two modified Place Lab files pertained to what other information is stored in the log file, as well as what information is displayed to the user who takes the calibration points when CalibrationGUI is run. These two files are BeaconMeasurement.java and WiFiReading.java. The only additions to these files were the created functions .
4 Why did Nooget use Place Lab over Other Options?
After researching our various options, the group decided to use Place Lab as the backbone of our software. It was easier to start the graphical user interface from scratch and work up, rather than to rely on the interfaces of the other options. Originally, it was planned to start with the Locus MQP done by Ali Taheri and Arvinder Singh who were former students of Professor Emmanuel Agu and expanding their work. However, much testing indicated the potential to accomplish more would be achieved by building upon the features of Place Lab that were required. A great deal of the code for this project was created by this group rather than using the existing Place Lab code. Although Place Lab is used to obtain the signal strengths, only a very small fraction of Place Lab code is used beyond this. In fact, instead of using their functions directly, our group chose to create our own functions within the Place Lab files and call these functions instead of the Place Lab functions. This allowed for expandability and the altering of functions without encroaching upon the open source licensing policy. This would not have been possible using the Locus MQP or NetStumbler and so using Place Lab was the best choice.
Another reason Place Lab was chosen over other options, specifically Locus, was because of the inaccuracy of the results during testing. When Locus was obtained, an attempt was made to run the program with our new data. This new data involved taking our own calibrations of Gordon Library on the third floor. The included directions were followed step-by-step and followed through the code. The problem occurred when the newly calibrated points were tested. After many hours of calibration, there were very few points that were accurately depicted on the maps. Further study of the problem led back to the proximity algorithm that Locus is based off of. The algorithm itself only had a success rate of twenty percent when tested. In addition, their method of calibration was very unforgiving. When in calibration mode, any clicks on the map will initiate a calibration at that point. Thus, an errant click, which is very common among users not accustomed to laptops, can have an extremely adverse result to the calibration. Our group considered altering the Locus algorithm but decided it would be easier to come up with our own algorithm for matching. The “best match” algorithm that Nooget is based around allowed its location matching accuracy to rise from twenty percent to approximately eighty-five percent. This was found after testing sixty five readings and having fifty-five of them come back with the correct location. It was here that we agreed that Place Lab was a better option for our software.
5 What were the Benefits of using Place Lab?
Using Place Lab as the backbone of Nooget had many benefits. First, the expandability of PlaceLab also gave the group a sense of freedom from the constraints that would have been present with NetStumbler. One such constraint was that it can only be used with the Windows operating system. The goal of the project was to create software that is capable of monitoring multiple users regardless of location and hardware. This would not have been possible with NetStumbler.
A second benefit of using Place Lab as the backbone of Nooget is that Place Lab was developed by a professional team of programmers. Since this was the case, the hardware’s ability to recognize the software and vise versa was not in question. As a result of bypassing this situation, a great deal of time and frustration in having to dealing with these issues was avoided. This extra time was devoted to coding extra features as well as cleaning up the interface. The extra time gained also allowed the exploration of other options within the MQP that were not apparent at the beginning of the project. For example, the server and client interaction that takes place within Nooget was modified during the time allocated to dealing with hardware issues. These modifications allow the server to accept multiple clients using Java’s multithreading with each client having its own thread and not destroying a thread in use by a separate client. Also, the fact that Place Lab was developed by a professional team of programmers provided a sense of security because Intel has a forum for developers using Place Lab to seek help on. This forum would have provided necessary help if errors had been encountered or question arisen while configuring Place Lab to work with Nooget.
The third and most beneficial point to using Place Lab is that both Place Lab and Nooget are written in Java. This means that code could easily be inserted without any importing issues that may have arisen if Place Lab was written in a different programming language. Since java is a cross platform language, it is also readily available to port our project to Linux; expanding the range of potential users of Nooget without having to implement “fixes” to Place Lab if it were simply a Windows specific software package. It is our hope that Nooget will be fully accepted and put into place around the campus after its completion. If this is the case, it is ideal that as many users as possible can install and use Nooget effectively without having to modify any part of the code themselves. Due to the fact that Place Lab is compatible with Linux, we planned accordingly and developed the code under the assumption that Linux users would also use Nooget.
6 What were the Drawbacks of using Place Lab?
Even though using Place Lab as the backbone of Nooget greatly helped the project’s progress, it did present some issues along the way. One such issue is the package size of the Place Lab software. There are files that Nooget did not need that are contained within the Place Lab software. In fact, only a very small number of these files were used. These contained functions to access the information stored about the signal strength. To address this problem, unused files were stripped out. This process took up some valuable project time because after each file was deleted, Nooget had to be recompiled with the modified version of Place Lab in order to ensure that all of the code works correctly. In order to prevent infringing upon the open source license, we include a copy of the original Place Lab in its unaltered form on the installer CD for Nooget. Although this was not a major issue, we feel that it should be addressed properly.
A second drawback encountered using Place Lab involved the developer forum that had originally been intended to be relied upon on for advice and guidance along the way. Although it was not used heavily, very few responses to our posted questions were received when we did attempt to seek guidance. We even noticed that a few other new developers who were utilizing Place Lab also posted questions with very few responses. This is possibly due to the fact that Place Lab has been at version 2.0 since October of 2004. This means that little work is being done by the primary developers of Place Lab to update their software. Even without the support of the forum, we were able to work around all of the problems we faced throughout the three terms we worked on the project.
2 Nooget
Nooget was designed to be a powerful, easy to use application. It was important that it run smoothly in a controlled environment. However, it was crucial to ensure that communication between the client and server could be maintained, even across different operating systems. Java provides this capability, and requires little customization to get it working. Also, our academic backgrounds have given us an understanding of Java, making our decision much easier.
[pic]
Figure 3 - High Level Flow Diagram
The main structure of Nooget, as described in further detail below, is illustrated in Figure 3. The data from the calibration database (calibrated beforehand) and the signal strengths are fed into the matching algorithm. The algorithm calculates the location, and feeds it across the network, along with various other information, to the server. The server displays the client’s location as well as storing all the client’s information in memory. The server can potentially also do other things with the data, such as keep logs and sound alarms. A typical client server relationship is shown in Figure 4.
[pic]
Figure 4 - Typical Client Server Relationship
1 Calibration
The first step was to receive the signal strength information from Place Lab’s stumbler at an arbitrary location and store that information. Place Lab outputs all the stumbler information through a LogWriter class. Keeping our own code separated from Place Lab’s would cause less confusion, especially for those seeking to extend the software. This is due to Place Lab’s structure: many linked files are necessary to execute one task. Since only the stumbler was needed, and optimizing Place Lab’s code was not a concern, Place Labs files were included and appropriate function calls were made. The format of a log file was changed to a structure that was more easily parsed. It was only necessary to edit two of Place Labs files. These two files were BeaconMeasurement.java and WiFiReading.java. In BeaconMeasurement.java, the following was added:
[pic]
Figure 5 - toOurLogString() in BeaconMeasurement.java
And in WiFiReading.java:
[pic]
Figure 6 - toOurLogString() in WiFiReading.java
The stumbler is called four times, pausing for four seconds between each reading, appending to the text file each time. This file is read from, parsed, and then the average signal strength for each node is computed. This information is associated with the building, floor, and coordinates, then encrypted and stored in a database of calibration points. If no signal strengths were recorded, a message is printed, asking for the calibration for that location to be repeated. In this manner, many calibrations can be done in the same location to prevent variations over time in foot traffic, humidity, and other factors hindering the effectiveness of the location tracking.
2 XML Encryption
At least one level of security would be necessary for Nooget. Out of several vulnerabilities, preventing user tampering of the calibration tables was the most important security procedure to enable. Therefore, any sensitive information is run through a DES encryption process before it is stored. When the calibration list needs to be accessed, the file is decrypted into an XML file immediately before it is used, then immediately deleted. The calibration points are stored in XML because it was both a convenient form in which to store the data, as well as easy to parse and create.
3 CalibrationGUI
Since the calibration will only be done by administrators, all relevant information should be given to them during the calibration. See Figure 7 for an overview of the calibration process.
[pic]
Figure 7 - Calibration Flow Chart
When a device is brought to an area to be calibrated, the user inputs the building and floor and then presses the location button. This brings up the map of the area that is used by the server when displaying the currently connected users. The administrator then locates himself on the map and clicks on his location. A red circle will appear, confirming his location. Refer to Figure 11, in section 4.2.8, to see a sample screenshot of this. When he then clicks the calibrate button, the program will begin its calibration cycle. This is done by gathering four sets of readings, each spaced four seconds apart, averaging them together, reading in the encrypted XML file, and then appending the new calibration point to the file. As the calibration is in progress, the program begins outputting specific information about the calibration point to the console. Each time the signal strengths are polled, each access point is outputted to a line in the console, displaying the time (in milliseconds since the Epoch), the MAC address of the access point, which network the access point is on, and its signal strength. Output from one of the tests of the Calibration GUI is displayed in Figure 8:
[pic]
Figure 8 - Sample CalibrationGUI Output
For the purposes of this application, all access points from networks outside the “WPI-Wireless” network should be excluded, for example the signal strengths received from Bluetooth devices such as printers and mice, or from home networks in buildings adjacent to some residence halls. When all four samples have been received, each MAC address and its average signal strength are displayed, along with the number of times that signal was detected during calibration. Receiving a signal from a WAP four times means that the access point is a reliable access point for the current location. While calibrating, it is important to monitor the strength and frequency of the access points. If a given point returns few access points, another attempt should be made to calibrate that point. However, if the number of access points is consistently low, no further action may be taken at this phase.
4 Location Matching
Once calibration points could be reliably created, the next goal was to match an arbitrary set of signal strengths to the database of calibration points. There were many factors to take into account when writing the algorithm. Should preference be given to calibration points that share more access points, but whose difference of signal strengths are greater? Or should the difference in strengths of shared access points be the deciding factor? Both options were implemented, and closer matches to shared access points yielded empirically better results. However, since most calibration points have between four and six access points, if one calibration point only received information from one or two access points, it would throw off the results. Perhaps the algorithm can be improved by using a weighted average, where each additional access point a calibration point shares with the sample gives it a stronger certainty of being the correct location. Even so, our current implementation returns the correct location accurately more than 80% of the time, which was sufficient.
5 Client
Being able to find locate a device was critical to the development of our tool, but what really would set Nooget apart from Locus and other projects is the ability to transmit that location to a monitoring station. This process is done through several stages. The client program is run on a device such as a laptop. Upon startup, it immediately attempts to connect to the server. If the device is unable to connect to the server, or if the server is not running, the client shuts down, so that the client will not tie up the device’s system resources. The client runs as a command prompt in the device’s taskbar, but ideally it would be entirely hidden from the user’s view. Once connected to the server, the client enters a non-terminating loop. Here, the client reads in two sets of signal strengths, averages them together, determines its location, sends the location to the server, then waits for five seconds. Two sets of signal strengths are read in to reduce ‘random’ locations as a result of a poor set of sample signal strengths. During subsequent executions of the loop, the client checks if its current location is the same as the last location it sent to the server. If the client is in the same location, the server does not need to be updated, so nothing is sent. The server tracks when the last time a client sent a new location was, which allows this information to be used to infer which devices have been turned off or have lost the connection with the server.
6 Server
The server consists of several parts: the MultiServer, the MultiServerThread, and the GUI. The MultiServer opens a ServerSocket on port 4444, and then enters a loop where it accepts every connection from a client. When a connection comes in from a client, the MultiServer starts up a new MultiServerThread, which handles all further communications with that particular client. Each thread that is created from the MultiServer handles all the input from the client as it arrives. The client transmits location and IP information as a string, which is then processed by the MultiServerThread. The thread then propagates this information back to the GUI, by adding the client to the list of connected devices, updating the location of the device, and drawing a dot on the map. The thread is only shut down when the client sends a disconnect command; however, the thread will stay open indefinitely because the client should never be turned off. This may cause memory problems if a server stays running for a long time; however this is a necessary sacrifice due to the protocol as written.
The GUI contains three main parts: the map, the list of all connections, and the console. The map provides a graphical display of the current location of all connected users. When a new user connects, or an existing user updates his position, the map changes to the most relevant building and floor to reflect the new information. Through this map, there’s no way to visually see where every connected device is located. On the connections list, however, all devices that have connected since the server was started are displayed. Devices that have changed position most recently appear at the bottom of this list, along with the last time the server received information from the client. Each row in the connections list is one device, differentiated from others by its IP. The device’s last received location (building, floor, and coordinates) are displayed here, along with its IP and timestamp. The console displays diagnostic information, in case problems arise with the server. For instance, the path for the current map being displayed is output to the console, in case a map may not appear for some reason. The starting and stopping of the server is also output to the console.
7 Design
There are two basic modules which make up the structure for how information is passed within Nooget. These modules are named coordList and beaconList. A coordList is a group of information that is stored within the encrypted coords.xml file. The coordList is a list of all the user calibrated coordinates. The structure of a coordList displayed in Figure 9:
[pic]
Figure 9 - Design Structure of a coordList
As shown in the figure, the information from the XML file is stored into a noogCoord which is then passed along in a coordList in order to pass additional noogCoords when necessary.
The design structure for a beaconList is similar to the structure of a coordList. This is displayed in Figure 10:
[pic]
Figure 10 - Design Structure of the XML Format
A beaconList is made up of Beacons. Each Beacon is made up of a MAC address and signal strength associated with that MAC address. Along with the beaconList, the building, floor, x position, and y position are all stored within a point. This is done to merge all of the relevant information for each calibration together. The primary difference between a beaconList and a coordList is that a beaconList is a list of all the beacons found as a result of a single calibration while a coordList is a group of noogCoords.
8 Final Product (GUI)
The final product of Nooget contains two separate graphical user interfaces. The CalibrationGUI was designed in order to allow an administrator to enter the calibration points that will be compared against during the running of the client program. This GUI has a single tab with three buttons, a map area to display the current map, and four text fields in order to display relevant information about the calibration being taken. Figure 11 is a screenshot of this GUI:
[pic]
Figure 11 - CalibrationGUI
The administrator enters the location they are currently at in the text fields and hits the Location button. The desired map will display. The administrator can then click on the location they are currently standing on the map. A red dot will appear on this spot. He can then click on the Calibrate button in order for the calibrations to begin. As the calibrations are processing, the results are displayed to the text field below the map. At any point, the administrator can clear the screen by clicking on the Clear button.
The second GUI within Nooget is the noogetServer. This GUI is used to display the location of a client who has connected to the server. This GUI has two tabs; one for displaying the location of the connected users and the other for displaying the relevant information pertaining to the clients who were connected. When noogetServer first loads, the Find Locations tab displays a blank map. After the administrator starts the server under the File menu, a user is able to connect to the server. A map of the connected user’s location with a red dot will display where the user is located. Figure 12 displays a single user connected to the server:
[pic]
Figure 12 - Find Location Tab of Server GUI
After a client has connected to the server, the relevant information is passed to the All Connections tab to be displayed. This information includes the IP address, the institution name, the building name, the floor number, the x and y positions, and the last time the client has sent an update. This information is displayed respectively within the text field. Figure 13 displays the All Connection tab with one user connected:
[pic]
Figure 13 - All Connections Tab of Server GUI
Since the All Connections tab is essentially a console of all the activity that has occurred from the connected users, the same IP address may be displayed more than once but with a different time.
Results
1 Tests
Nooget went through a series of testing phases throughout its creation. It was first tested in Founders Hall on the fourth floor. This was done in order to allow for a faster delivery and changes to the code. Since every member of the Nooget team lived there, it was easier to fix a mistake in the code and test without having to travel. A map of the WPI campus with Founders Hall circled in green is shown in Figure 14:
[pic]
Figure 14 - WPI Campus Map
If the changes failed the experiments we gave it, the changes would be looked at again to find where the errors occurred. However, if the changes passed these series of tests, Nooget would then be taken to Gordon Library to be further tested. Specific tests in the Gordon Library include signal strength variation over time, accuracy determination of the matching algorithms, and signal strength comparisons between hardware.
The testing of Nooget is set up into two parts. These are the client and the server. A client for Nooget is any laptop that has the Nooget software installed on it and has an active wireless card running. The client most often tested is a HP ZT1000 B-Series laptop running Windows XP Professional Edition with Service Pack 2. A server is any host machine that can connect to ccc2.wpi.edu using X-Windows to display the GUI. The connection to ccc2.wpi.edu is hard coded into the software, so the user running the server must have the software installed on their toaster account and be connected to ccc2.wpi.edu in order for Nooget to run correctly.
2 Experiments
Testing in Founders usually involved running the server from a host machine. This host machine was typically an AMD Athlon 64 Processor desktop running Windows XP Professional Edition with Service Pack 2. After the server was started, a client would then connect to the server. If the server correctly displayed the location of the first client, a second client would then connect to the server in the same location. If the server displayed both points correctly, one client would move to another location to be tested again.
The clients were then examined to see if the client specific information received by the server was accurate. This information includes IP address, signal strengths, building name, floor number, the x position, the y position, and the last time updated by the client. Figure 15 is a picture of the server displaying the client information received during one of the experiments:
[pic]
Figure 15 - Server During Testing
If both clients passed the tests in Founders Hall, the clients would then be tested in Gordon Library. The Gordon Library testing was similar to the Founders Hall testing. The same experiments that were tested in Founders Hall were tested first. Once these experiments were satisfactory, Nooget was tested on multiple floors to ensure the server could handle multiple maps being displayed.
3 Signal Strength Tests
In order to be practical, the client must be able to properly assess its location.
[pic]
Figure 16 - Signal Strength Over Five Hours
As visible in Figure 16, the signal strength reported by the wireless hardware rarely varies over time. The data was gathered over approximately four hours in the first floor computer lab at Gordon Library. During the collection of data, library business proceeded as usual, providing a realistic experiment. The standard deviations of the data sets were 6.9, 3.4, 1.3 and 2.0 for wireless access points 1-4 respectively. The relatively high deviation of the first point is attributable to the first hour of data, and especially the first few readings, after which the data leveled off. In short, a properly calibrated laptop is able to detect its own location accurately and report it to the server, barring network disconnection. In a security application it is important to retain this level of accuracy and dependability. However reliability is also important in order to reduce or eliminate false positives on security violations.
4 Technical Issues
The main source of difficulty lies with the calibrations.
Figure 17 - Absolute Average Signal Strengths
As shown in Figure 17, the signal strengths vary considerably between different laptops. The readings for each model of laptop are consistent, but between different models of laptop and network hardware, there is a fairly considerable variation. The main conclusion drawn from this is that calibration sets gathered on one laptop may not work properly on another laptop with different hardware. However, there are several mitigating factors that may have caused these conflicting issues. First, one of the models of laptop the software was tested on is several years older than the other model. It may be that improvements in antenna technology over the past few years are the main factor, and a more contemporary set of laptops would show less variance. Second, in the main applications envisioned for the software, the body providing the laptops often would have purchased many of the same models of laptop anyway.
5 Successful Aspects
The testing of Nooget was successful in many aspects. It displayed the capabilities of the software in its current state, as well as, the potential for the software to grow in the future. The testing also provided data to be presented to the Academic Technology Center to give them an understanding of the potentials for such software to be placed on all rented laptops.
The Nooget software successfully displays the location of its clients. Currently, any client that has calibrated points on their machine is able to connect to the server and display their location, as long as the server is running. Multiple clients on the same floor of the same building will be displayed correctly. The server also correctly maintains the incoming client information. A person monitoring the server can switch between the display of the connected client or the connected client’s information.
The data collected during testing is useful to pursue the acceptance of the software. The data accurately displayed the usefulness of such a product. For example, the data collected shows that monitoring multiple laptops at once is a task that can be accomplished in little time. Even in its earliest state, Nooget was fully capable or locating its surrounding wireless access points with extreme accuracy. This is valuable information the Academic Technology Center should consider because it will greatly increase the security of their laptops.
6 Unsuccessful Aspects
The testing of Nooget displayed some unsuccessful aspects of the current software. The first aspect that was unsuccessful was the displaying of multiple clients who are not at the same location. The server will currently accept the last update from any of the servers and display all users on this map. This is due to the underlying design of the server. The server was designed like this originally when dealing with a single client to allow this client to be displayed automatically. Unfortunately, this design was never resolved.
A second unsuccessful aspect of Nooget involves zooming. The original design of the project did not involve the capability to zoom in from a campus map to a specific building. This feature was later attempted to be added but was unsuccessful because the campus map would never display on the Find Location tab of the server. This was mainly due to conflicting Java issues involving the glass pane setup of the GUI. Although the conflicts were later discovered, it was not feasible to correct the problem because that would involve changing the backbone of the entire graphical interface Nooget was coded upon.
7 Practicality
Nooget is practical software for security use, assuming that certain conditions are met. The software is able to accurately gauge the location of the laptop and transmit that location to the server. The server is then able to track the locations of those laptops. However, in order for the client program to be able to properly assess the location of the laptop, certain conditions must be met. Despite this, the tool is a practical security application.
8 Expansion of Nooget
The results also show that the system could even be expanded. As it currently stands, the optimal area to use the software would be a large campus or an office tower. The software could be scaled up to track the laptops in a small city. However past that point, the database of signal strengths will become prohibitively large. Currently, the encrypted database XML file is 200 kilobytes and this only includes calibrations of Gordon Library, Founders Hall, and Fuller Labs. Although the file itself will probably be of reasonable size, it will be very computationally expensive to loop through it and compare the readings.
A drawback to scaling up the software would result in simple logistical difficulties. The current version of the server changes the displayed map every time a client updates. If there are too many users, the software will attempt to update the map too often, resulting in both performance difficulties and difficulty even seeing any of the information. On top of that, it would be monumental effort to calibrate a small city into the database. If a point was placed every 10 feet, there would be 278,784 points in a square mile. It would take a laptop in constant operation several months to calibrate all those points. If only well traveled public areas were included, that number could be cut down significantly.
Unfortunately there are still problems with software being used as a security system. The most significant is the laptop itself. The wireless network card or the client program could simply be disabled by the user. This would prevent the server from receiving updates of the laptop’s location because the server only expects an update when the laptop moves from one location to another. In this case, the server would simply assume the laptop is static. This could be solved by updating the laptop’s location at a set interval even when it is not moving. Then the server could mark the laptop as missing when it does not report.
To prevent the termination of the client software, it would be necessary to hide it from the user. The console could simply be disabled, but this leaves the process exposed in the task manager. Access to the task manger is often controlled by security conscious entities, causing this problem to be reduced. To be completely transparent, ideal tracking software would be built in at the driver level. Even with this software created and installed, it would be very difficult to control users willing to go to such extremes short of searching them when they leave the premises. A user utterly determined to steal a piece of hardware will be able to regardless of software.
Future Work
As with all programs, the potential for expansion is a necessary step that must be addressed. While creating Nooget, we envisioned many ideas that we though would be ideal to add to our project. Due to time constraints, however, we were not able to implement many of these ideas. It is our hope that another group who takes over this project will one day implement these changes, as well as others that they may think of.
1 GPS
The first idea that we thought would be vital to wireless tracking is the use of Global Positioning Systems. With the use of GPS, the administrator who is in charge of calibrating the laptops would not need to add any points that are outdoors but would still receive the coverage as if they had added the outdoor calibrations. This would expand Nooget from being primarily a WPI campus specific software package to potentially a global package that could be used anywhere that has outdoor maps. For instance, if Nooget were to partner with MapQuest or Google Maps, the administrator would be able to track the device to anywhere where there is a map by simply using GPS signals received by the device.
2 Laptop Location Constraints
The idea of correlating GPS with Nooget also spawned additional ideas for our project. We came up with the idea of adding constraints to the campus boundaries and adding alarms to sound at the administrator’s monitoring station. If this ideal were put into place, it would allow administrators to prevent the theft of laptops. When a user reaches a certain boundary, the administrator would hear an alarm and notify security to investigate the situation, preventing laptops from being taken off campus. This addition would allow Nooget to expand from a location aware application to a location aware security application.
3 Implement Smaller Devices
An idea that this group would have implemented ourselves if we had the extra time is the ability to use Nooget on other devices. Currently, the software contains maps which are too large to view on smaller devices such as PDAs. Other than the size of the maps, our software is ideally capable of being modified for use on PDAs because we chose to use Java as our programming language. By converting to PDAs, the use of Nooget would greaten because the user would be able to do things with a PDA that they can not do feasibly with a laptop, i.e. campus tours. A laptop would be too large to carry around during a tour of the campus. However, if a user had Nooget installed on their PDA, they could be able to receive their current location or find the location of another tour group. Additional information about the campus could also display on the screen of the device as the user walked past a particular landmark on campus. These ideas would require additional support for the user to be able to find and display their current location.
4 Campus Map/Zooming
Zooming into a building onto the location of a particular user was going to be a unique feature of our MQP. The conceptual idea for this is simple, but the amount of time devoted to attempting it did not allow our group to fully add in the capabilities to zoom. The first problem we encountered here was that there was no way of loading the campus map into the space where we display the current location of users. To fix this, we added in a button that was supposed to display the campus map in its own tab. The problem we discovered when implementing this was that the glass pane overlay that we use to display the maps did not support a tabbed browser interface on any tab except the first tab. To go around this, our group tried to have the campus map load in the same tab as the current user’s location. This also was not feasible because the glass pane would not support modifying the tab in the manner we would have liked. Unfortunately, our group was close to coming up with a solution that would have allowed us to possibly implement zooming in on a campus map but due to time constraints, we were not able to do so. It is our desire that some group after us will implement zooming by either reworking the displaying capabilities of glass panes or using another means to display the maps all together.
5 Go To Specific IP Location
A search feature that intrigued our group is the ability to search for the location of a client by using their IP address or display specific IP addresses based on the location. Currently, our program takes in the IP address that is passed from the client to the server and this is stored within the database along with the location. This database can easily be expanded to contain additional information about the date and time a user borrowed the laptop, when it is due to be returned, the WPI identification number of the user, the laptop number, and other information that would be useful to have on hand. A handy feature would be able to take the location and display it to a map for individual users. This would allow an administrator to know whether the client is on their way to turn the borrowed laptop back in, for example, without having to charge the user with a late penalty fee. Another use for this feature would be to notify specific users in certain areas that they may experience an interruption in their internet connection if there is a scheduled outage in their area.
6 Hide Client Program from User
The last feature we propose a later group implement to Nooget would be hiding the client program from being seen at any time. Ideally, no user using the client should be able to see what is going on. The process should be hidden in order to both prevent the user from tampering with the software and to clean up the visual area of the desktop. The user should not have to minimize the client every time the software is run. However, our group did not have the time or knowledge to implement this feature. We are leaving it for a later group who takes up their project to decide whether they believe the user should need to view the client or whether they would like the software to be hidden.
Conclusion
The primary goal of this MQP was to create a cross platform software package that would allow a monitor to find the location of a laptop by using only the existing 802.11 Wireless Local Area Network infrastructure. Nooget has been successfully created, which is proof that the concept and architecture can be accomplished. A vast number of applications can be derived from Nooget because of its object oriented and modular design. A number of issues still need to be resolved dealing with the displaying of the clients’ locations; however, the ability to monitor laptops from a central location using WLAN has been demonstrated by this MQP.
Nooget Setup Procedures
1 Steps to Take When Installing Nooget:
1. Drag and drop the “placelab-win32-FULL” folder for the server or the “placelab-win32-LIGHT” for the client to the Desktop or desired location.
2. When the files are finished copying over, install Java if it is not installed on the computer.
• Go to
• Click on "J2SE 5.0" under "Popular Downloads".
• Click on "Download" next to "J2SE 5.0 Documentation".
• Click on the "Accept" radio dialog box.
• Click on "J2SE(TM) Development Kit Documentation 5.0, English".
• Save the file to the Desktop.
• Unzip the files.
3. Install Java onto the Classpath.
(Only type values between the double quotes, do NOT include the double quotes)
• To do this, click on "Start" in the lower left hand corner of the screen.
• Under "Settings", click on "Control Panel".
• Click on the "System" icon.
• Click on the "Advanced" tab.
• Click on the "Environment Variables" button..
• Highlight "PATH" and click the "Edit" button under User variables
(NOTE: If PATH does not exist, click "New" instead of "Edit")
• Edit the "PATH" so it contains "C:\Program Files\Java\jdk1.5.0_02\bin;".
(NOTE: If you install Java to a different directory, you may need to change the directory from the listed above)
• After you have finished editing the PATH, click "OK".
• Click on the "New" button under User variables.
• Type in "CLASSPATH" for the Variable name.
• Type in "." for the Variable value. (a single period)
• Click "OK".
• Exit the "Control Panel".
• Restart your computer.
2 To Run the Server
• Install the “placelab-win32-FULL” folder onto server ccc2.wpi.edu under any user who will be known as the administrator.
• Open up X-Win32 and connect to the administrators account on ccc2.wpi.edu.
• Navigate to the “placelab-win32/bin/” folder.
• Type “java noogetServer” into the command prompt.
(NOTE: At this point, the server should appear but the server has not been started yet)
• Click on “File”.
• Click on “Start Server”.
• Run the client to test.
3 To Run the Client
• Install the “placelab-win32-LIGHT” folder on the Desktop or another location.
• Navigate to the “placelab-win32/bin/” folder.
• Double click runClient.bat.
• Type in “y” and click “Enter”.
• If the client displays “Don't know about host: ccc2.wpi.edu”, then the server is not currently running. Start the server and retry.
• If the client displays “Couldn't get I/O for the connection to: ccc2.wpi.edu.”, then there is no internet connection found. Try “Repairing” the internet connection by going to it within the Control Panel.)
• If neither of these error messages displays, then the client is connected to the server.
References
[ATCweb] WPI Academic Technology Center. Worcester Polytechnic Institute. 18 January 2006.
[BATIKweb] The Batik SVG Toolkit project website. The Apache XML Project.
[DELIV] Borriello, Gaetano, Chalmers, Matthew, LaMarca, Anthony, and Nixon, Paddy. Delivering Real-World Ubiquitous Location Systems. Communications of the ACM. Volume 48, Number 3. March 2005.
[HPweb] The Hewlett-Packard Development Company website.
[INTELweb] LaMarca, Anthony. Place Lab Uses Radio Beacons to Enable Location Awareness. Technology@Intel Magazine. October 2005.
[JAVAweb] The Java API website. A Sun Microsystems Project.
[JAVAweb2] The Java Reference website.
[JAVAweb3] The Java Coffee Break website.
[LOCUSweb] Singh, Arvinder, Taheri, Ali, and Agu, Emmanuel. Locus: Wireless LAN Location Sensing. Worcester Polytechnic Institute Major Qualifying Project.
[NETOPweb] WPI Network Operations website. Worcester Polytechnic Institute. 10 September 2005.
[NETSweb] The NetStumbler project website. The NetStumbler Project.
[PLACEweb] The Place Lab project website. An Intel Corporation Project.
Appendix
1 Code
1 noogetServer.java
import noogetCore.*;
import noogetXML.*;
import java.awt.Color;
import java.awt.Point;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JMenuBar;
import javax.swing.JMenu;
import javax.swing.JTabbedPane;
import javax.swing.JButton;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
import javax.swing.JLabel;
import javax.swing.JMenuItem;
import javax.swing.UIManager;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.JTextArea;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import com.sun.java.swing.plaf.windows.*;
public class noogetServer
{
private static ArrayList connectedClients = new ArrayList();
private static JFrame jNoogetFrame = null; // @jve:decl-index=0:visual-constraint="125,-8"
private static JPanel jNoogetContentPane = null;
private static JMenuBar jNoogetMenuBar = null;
private static JMenu jNoogetFileMenu = null;
private static JMenu jNoogetHelpMenu = null;
private static JTabbedPane jNoogetMainTabbedPane = null;
private static JPanel jTabbedPanePanel = null;
private static JPanel jNoogetPanel = null;
private static JLabel jFindLocationLabel = null;
private static JMenuItem jCloseMenuItem = null;
private static JMenuItem jStartServerMenuItem = null;
private static JMenuItem jStopServerMenuItem = null;
private static JMenuItem jContentsMenuItem = null;
private static JMenuItem jAboutMenuItem = null;
private static JPanel jConnectionsPanel = null;
private static JLabel jMapLabel = null;
private static JLabel jCampusMapLabel = null;
private static JPanel jWPICampusMapPanel = null;
private static JPanel jCampusPanel = null;
private static JTextArea jConnectionsTextArea = null;
private static JLabel jAllConnectionsLabel = null;
private static JLabel jFindUserLabel = null;
private static JLabel jIPAddressLabel = null;
private static JTextField jIPAddressTextField = null;
private static JButton jLoadCampusMapButton = null;
private static JPanel glassPane = new JPanel();
static JLabel label = new JLabel();
static String fileName;
static String inst;
static String build;
static String floor;
static int xtotalpos;
static int ytotalpos;
static int xmappos;
static int ymappos;
static int xoffset;
static int yoffset;
static noogCoord coord = new noogCoord(null, 0, 0, 0);
static noogetMultiServer serv = new noogetMultiServer();
private static boolean glasspanebool = false;
/**
* This method initializes jNoogetFrame
*
* @return javax.swing.JFrame
*/
private static JFrame getJNoogetFrame()
{
if (jNoogetFrame == null)
{
jNoogetFrame = new JFrame();
jNoogetFrame.setSize(1024, 768);
jNoogetFrame.setBackground(new java.awt.Color(250, 250, 250));
jNoogetFrame.setBounds(new java.awt.Rectangle(0, 0, 949, 493));
jNoogetFrame.setTitle("NoogetMQP - Server");
jNoogetFrame.setMinimumSize(new java.awt.Dimension(1024, 768));
jNoogetFrame.setPreferredSize(new java.awt.Dimension(1024, 768));
jNoogetFrame.setJMenuBar(getJNoogetMenuBar());
jNoogetFrame.setContentPane(getJNoogetContentPane());
jNoogetFrame.getContentPane().setLayout(null);
}
return jNoogetFrame;
}
/**
* This method initializes jNoogetContentPane
*
* @return javax.swing.JPanel
*/
private static JPanel getJNoogetContentPane()
{
if (jNoogetContentPane == null)
{
jNoogetContentPane = new JPanel();
jNoogetContentPane.setLayout(null);
jNoogetContentPane.add(getJNoogetMainTabbedPane(), null);
}
return jNoogetContentPane;
}
/**
* This method initializes jNoogetMenuBar
*
* @return javax.swing.JMenuBar
*/
private static JMenuBar getJNoogetMenuBar()
{
if (jNoogetMenuBar == null)
{
jNoogetMenuBar = new JMenuBar();
jNoogetMenuBar.setPreferredSize(new java.awt.Dimension(15, 25));
jNoogetMenuBar.setName("MenuBar");
jNoogetMenuBar.add(getJNoogetFileMenu());
jNoogetMenuBar.add(getJNoogetHelpMenu());
}
return jNoogetMenuBar;
}
/**
* This method initializes jNoogetFileMenu
*
* @return javax.swing.JMenu
*/
private static JMenu getJNoogetFileMenu()
{
if (jNoogetFileMenu == null)
{
jNoogetFileMenu = new JMenu();
jNoogetFileMenu.setBounds(new java.awt.Rectangle(0, 0, 25, 25));
jNoogetFileMenu.setText("File");
jNoogetFileMenu.setPreferredSize(new java.awt.Dimension(35, 25));
jNoogetFileMenu.setName("File");
jNoogetFileMenu.add(getJStartServerMenuItem());
jNoogetFileMenu.add(getJStopServerMenuItem());
jNoogetFileMenu.add(getJCloseMenuItem());
}
return jNoogetFileMenu;
}
/**
* This method initializes jNoogetViewMenu
*
* @return javax.swing.JMenu
*/
private static JMenu getJNoogetHelpMenu()
{
if (jNoogetHelpMenu == null)
{
jNoogetHelpMenu = new JMenu();
jNoogetHelpMenu.setText("Help");
jNoogetHelpMenu.setPreferredSize(new java.awt.Dimension(35, 25));
jNoogetHelpMenu.setName("Help");
jNoogetHelpMenu.add(getJContentsMenuItem());
jNoogetHelpMenu.add(getJAboutMenuItem());
}
return jNoogetHelpMenu;
}
/**
* This method initializes jNoogetMainTabbedPane
*
* @return javax.swing.JTabbedPane
*/
private static JTabbedPane getJNoogetMainTabbedPane()
{
if (jNoogetMainTabbedPane == null)
{
jNoogetMainTabbedPane = new JTabbedPane();
jNoogetMainTabbedPane.setBounds(new java.awt.Rectangle(-2, 0, 1024, 768));
jNoogetMainTabbedPane.setName("Location");
jNoogetMainTabbedPane.addTab("Find Location", null, getJTabbedPanePanel(), "Find Location of Client");
// jNoogetMainTabbedPane.addTab("WPI Campus Map", null, getJWPICampusMapPanel(), "Map of the Campus");
jNoogetMainTabbedPane.addTab("All Connections", null, getJConnectionsPanel(), "Starts the Server");
jNoogetMainTabbedPane.addChangeListener(new javax.swing.event.ChangeListener()
{
public void stateChanged(javax.swing.event.ChangeEvent e)
{
//Get current tab
int sel = jNoogetMainTabbedPane.getSelectedIndex();
if (sel != 0)
{
if (glasspanebool == true)
{
// jNoogetPanel.removeAll();
jNoogetPanel.getRootPane().getLayeredPane().remove(label);
// jNoogetPanel.repaint();
glasspanebool = false;
}
}
else
{
jNoogetPanel.getRootPane().setGlassPane(glassPane);
if (connectedClients.size() > 1) drawDot(coord);
glasspanebool = true;
}
}
});
}
return jNoogetMainTabbedPane;
}
/**
* This method initializes jtestPanel
*
* @return javax.swing.JPanel
*/
private static JPanel getJTabbedPanePanel()
{
if (jTabbedPanePanel == null)
{
if (glasspanebool == true)
{
jNoogetPanel.getRootPane().getGlassPane().setVisible(true);
}
jFindLocationLabel = new JLabel();
jFindLocationLabel.setBounds(new java.awt.Rectangle(9, 36, 160, 45));
jFindLocationLabel.setFont(new java.awt.Font("Dialog", java.awt.Font.BOLD, 14));
jFindLocationLabel.setText("Find Current Location");
jTabbedPanePanel = new JPanel(null);
jTabbedPanePanel.add(getJNoogetPanel(), null);
jTabbedPanePanel.add(jFindLocationLabel, null);
}
return jTabbedPanePanel;
}
/**
* This method initializes jConnectionsPanel
*
* @return javax.swing.JPanel
*/
private static JPanel getJConnectionsPanel()
{
if (jConnectionsPanel == null)
{
if (glasspanebool == true)
{
jNoogetPanel.getRootPane().getGlassPane().setVisible(false);
//glasspanebool = false;
}
jIPAddressLabel = new JLabel();
jIPAddressLabel.setBounds(new java.awt.Rectangle(15, 76, 79, 26));
jIPAddressLabel.setText("IP Address:");
jFindUserLabel = new JLabel();
jFindUserLabel.setBounds(new java.awt.Rectangle(10, 13, 93, 43));
jFindUserLabel.setFont(new java.awt.Font("Dialog", java.awt.Font.BOLD, 14));
jFindUserLabel.setText("Find User");
jAllConnectionsLabel = new JLabel();
jAllConnectionsLabel.setBounds(new java.awt.Rectangle(575, 6, 127, 50));
jAllConnectionsLabel.setFont(new java.awt.Font("Dialog", java.awt.Font.BOLD, 14));
jAllConnectionsLabel.setText("All Connections");
jConnectionsPanel = new JPanel(null);
jConnectionsPanel.add(getJConnectionsTextArea(), null);
jConnectionsPanel.add(jAllConnectionsLabel, null);
jConnectionsPanel.add(jFindUserLabel, null);
jConnectionsPanel.add(jIPAddressLabel, null);
jConnectionsPanel.add(getJIPAddressTextField(), null);
jIPAddressTextField.requestFocus();
}
return jConnectionsPanel;
}
/**
* This method initializes jNoogetPanel
*
* @return javax.swing.JPanel
*/
private static JPanel getJNoogetPanel()
{
if (jNoogetPanel == null)
{
jNoogetPanel = new JPanel();
jNoogetPanel.setBounds(new java.awt.Rectangle(200, 75, 800, 600));
jNoogetPanel.setToolTipText("Displays a map of the current location of the users");
jNoogetPanel.setBackground(java.awt.Color.white);
}
return jNoogetPanel;
}
/**
* This method initializes jNoogetPanel
*
* @return javax.swing.JPanel
*/
private static JPanel getJCampusPanel()
{
if (jCampusPanel == null)
{
jCampusPanel = new JPanel(null);
jCampusPanel.setBounds(new java.awt.Rectangle(265, 75, 800, 600));
jCampusPanel.setToolTipText("Displays a map of the current location of the users");
jCampusPanel.setBackground(java.awt.Color.white);
}
return jCampusPanel;
}
/**
* This method initializes jConnectionsPanel
*
* @return javax.swing.JPanel
*/
private static JPanel getJWPICampusMapPanel()
{
if (jWPICampusMapPanel == null)
{
if (glasspanebool == true)
{
jNoogetPanel.getRootPane().getGlassPane().setVisible(false);
}
jCampusMapLabel = new JLabel();
jCampusMapLabel.setBounds(new java.awt.Rectangle(625, 6, 200, 100));
jCampusMapLabel.setFont(new java.awt.Font("Dialog", java.awt.Font.BOLD, 16));
jCampusMapLabel.setText("WPI Campus Map");
jWPICampusMapPanel = new JPanel(null);
jWPICampusMapPanel.add(jCampusMapLabel, null);
jWPICampusMapPanel.add(getJCampusPanel(), null);
jWPICampusMapPanel.add(getJLoadCampusMapButton(), null);
}
return jWPICampusMapPanel;
}
/**
* This method initializes jStartCalibrationButton
*
* @return javax.swing.JButton
*/
private static JButton getJLoadCampusMapButton()
{
if (jLoadCampusMapButton == null)
{
jLoadCampusMapButton = new JButton();
jLoadCampusMapButton.setPreferredSize(new java.awt.Dimension(80, 25));
jLoadCampusMapButton.setLocation(new java.awt.Point(79, 212));
jLoadCampusMapButton.setSize(new java.awt.Dimension(102, 36));
jLoadCampusMapButton.setSelected(false);
jLoadCampusMapButton.setText("Load");
jLoadCampusMapButton.addActionListener(new java.awt.event.ActionListener()
{
public void actionPerformed(java.awt.event.ActionEvent e)
{
jCampusPanel.removeAll();
jNoogetPanel.getRootPane().getLayeredPane().remove(label);
jCampusPanel.repaint();
fileName = "maps//WPI-Campus-1.png";
System.out.println(fileName);
ImageIcon pic = new ImageIcon(fileName);
JLabel p = new JLabel(pic, JLabel.CENTER);
p.setOpaque(true);
jNoogetFrame.getContentPane().add(p);
jCampusPanel.add(p);
p.repaint();
jNoogetFrame.repaint();
}
});
}
return jLoadCampusMapButton;
}
/**
* This method initializes jCloseMenuItem
*
* @return javax.swing.JMenuItem
*/
private static JMenuItem getJCloseMenuItem()
{
try
{
if (jCloseMenuItem == null)
{
jCloseMenuItem = new JMenuItem();
jCloseMenuItem.setText("Close");
jCloseMenuItem.addActionListener(new java.awt.event.ActionListener()
{
public void actionPerformed(java.awt.event.ActionEvent e)
{
System.exit(0);
}
});
}
}
catch (NullPointerException e)
{
}
return jCloseMenuItem;
}
/**
* This method initializes jStartServerMenuItem
*
* @return javax.swing.JMenuItem
*/
private static JMenuItem getJStartServerMenuItem()
{
try
{
if (jStartServerMenuItem == null)
{
jStartServerMenuItem = new JMenuItem();
jStartServerMenuItem.setText("Start Server");
jStartServerMenuItem.addActionListener(new java.awt.event.ActionListener()
{
public void actionPerformed(java.awt.event.ActionEvent e)
{
try
{
System.out.println("Nooget Server has been started ...");
serv = new noogetMultiServer();
serv.start();
}
catch (Exception ex)
{
}
}
});
}
}
catch (NullPointerException e)
{
}
return jStartServerMenuItem;
}
/**
* This method initializes jStopServerMenuItem
*
* @return javax.swing.JMenuItem
*/
private static JMenuItem getJStopServerMenuItem()
{
try
{
if (jStopServerMenuItem == null)
{
jStopServerMenuItem = new JMenuItem();
jStopServerMenuItem.setText("Stop Server");
jStopServerMenuItem.addActionListener(new java.awt.event.ActionListener()
{
public void actionPerformed(java.awt.event.ActionEvent e)
{
// This stops the socket. It is used in replace of stop() because stop() is depricated.
try
{
serv.stop();
serv.destroy();
}
catch (NoSuchMethodError ex)
{
}
catch (Exception ex)
{
}
System.out.println("Nooget Server has been stopped ...");
}
});
}
}
catch (NullPointerException e)
{
}
return jStopServerMenuItem;
}
/**
* This method initializes jContentsMenuItem
*
* @return javax.swing.JMenuItem
*/
private static JMenuItem getJContentsMenuItem()
{
if (jContentsMenuItem == null)
{
jContentsMenuItem = new JMenuItem();
jContentsMenuItem.setText("Contents");
jContentsMenuItem.addActionListener(new java.awt.event.ActionListener()
{
public void actionPerformed(java.awt.event.ActionEvent e)
{
JOptionPane.showMessageDialog(null, "How To:\n" +
"* Find Location of Client: Click on the Start Server option in the File Menu and\n" +
" the program will query the database for the closest location of the user\n " +
" to a previously calibrated point. This point will be displayed on the map.\n\n" +
"* Start Nooget Server: Click on File, and then Start Server in order to activate\n" +
" the server. While the server is running, a person is able to monitor the\n" +
" position of a client around campus.\n\n" +
"* Stop Nooget Server: Click on Filem and theb Stop Server in order to deactivate\n" +
" the server. While the server is not running, a person is unable to\n" +
" monitor the position of any client around campus.\n\n", "Contents", RMATION_MESSAGE);
}
});
}
return jContentsMenuItem;
}
/**
* This method initializes jAboutMenuItem
*
* @return javax.swing.JMenuItem
*/
private static JMenuItem getJAboutMenuItem()
{
if (jAboutMenuItem == null)
{
jAboutMenuItem = new JMenuItem();
jAboutMenuItem.setText("About");
jAboutMenuItem.setActionCommand("About");
jAboutMenuItem.addActionListener(new java.awt.event.ActionListener()
{
public void actionPerformed(java.awt.event.ActionEvent e)
{
try
{
JOptionPane.showMessageDialog(null, " Nooget V0.1 Copyright 2005\n" +
" Andrew Bangs\n" +
" Shaun Haerinck\n" +
" Aubrey Klaft\n\n" +
" With Special Thanks To:\n" +
" Professor Emmanuel Agu\n" +
" Chris Salter\n" +
" and\n" +
" WPI Plant Services for donating \n" +
" the campus maps", "About", RMATION_MESSAGE);
}
catch (NullPointerException z)
{
}
}
});
}
return jAboutMenuItem;
}
/**
* This method initializes jConnectionsTextArea
*
* @return javax.swing.JTextArea
*/
private static JTextArea getJConnectionsTextArea()
{
if (jConnectionsTextArea == null)
{
jConnectionsTextArea = new JTextArea();
jConnectionsTextArea.setWrapStyleWord(false);
jConnectionsTextArea.setLocation(new java.awt.Point(260, 63));
jConnectionsTextArea.setSize(new java.awt.Dimension(700, 550));
jConnectionsTextArea.setToolTipText("List of All Connected Users");
jConnectionsTextArea.setLineWrap(false);
}
return jConnectionsTextArea;
}
/**
* This method initializes jIPAddressTextField
*
* @return javax.swing.JTextField
*/
private static JTextField getJIPAddressTextField()
{
if (jIPAddressTextField == null)
{
jIPAddressTextField = new JTextField();
jIPAddressTextField.setBounds(new java.awt.Rectangle(92, 80, 145, 18));
jIPAddressTextField.requestFocus();
}
return jIPAddressTextField;
}
public static void drawDot(noogCoord clientCoord)
{
jNoogetPanel.removeAll();
jNoogetPanel.getRootPane().getLayeredPane().remove(label);
jNoogetPanel.repaint();
glasspanebool = true;
// DISPLAY WARNING IF NO MAP
coord = clientCoord;
if (jNoogetPanel.getToolTipText().compareTo("WPI-null-0") == 0) ;
{
inst = "WPI";
build = coord.getBuilding();
floor = "" + coord.getFloor();
fileName = "maps//" + inst + "-" + build + "-" + floor + ".png";
System.out.println(fileName);
jNoogetPanel.setToolTipText(inst + "-" + build + "-" + floor);
ImageIcon pic = new ImageIcon(fileName);
JLabel p = new JLabel(pic, JLabel.CENTER);
p.setOpaque(true);
jNoogetFrame.getContentPane().add(p);
jNoogetPanel.add(p);
p.repaint();
jNoogetFrame.repaint();
p.repaint();
}
System.out.println(coord.getX() + " " + coord.getY() + " in building " + coord.getBuilding() + " on floor " + coord.getFloor());
jNoogetPanel.getRootPane().setGlassPane(glassPane);
int counter = 0;
noogetConnection z;
System.out.println("Size");
System.out.println(connectedClients.size());
while (counter < connectedClients.size())
{
z = (noogetConnection)connectedClients.get(counter);
// System.out.println("LIST OF CONNECTED THINGS");
// System.out.println(jNoogetPanel.getToolTipText());
// System.out.println(z.tag);
if (jNoogetPanel.getToolTipText().compareTo(z.tag) == 0)
{
// System.out.println("+");
label = new JLabel();
label.setBounds(new java.awt.Rectangle(0, 0, 50, 50));
label.setFont(new java.awt.Font("Dialog", java.awt.Font.BOLD, 18));
label.setForeground(Color.RED);
label.setText("O");
label.setLocation(new Point(coord.getX() + 275, coord.getY() + 130));
jNoogetPanel.getRootPane().getLayeredPane().add(label);
jNoogetPanel.getRootPane().getLayeredPane().setLayer(label, 5);
}
counter++;
}
jNoogetPanel.getRootPane().getLayeredPane().repaint();
//**********************************************************************************************
jMapLabel = new JLabel();
jMapLabel.setBounds(new java.awt.Rectangle(0, 0, 400, 50));
jMapLabel.setFont(new java.awt.Font("Dialog", java.awt.Font.BOLD, 16));
jMapLabel.setText(inst + "-" + build + "-" + floor);
jMapLabel.repaint();
if (jMapLabel.getText().compareTo("WPI-null-0") != 0)
{
jMapLabel.setLocation(600, 25);
getJTabbedPanePanel().add(jMapLabel, null);
}
jNoogetPanel.getRootPane().repaint();
jNoogetPanel.repaint();
jNoogetFrame.repaint();
}
public static void addIP(String ipaddr, noogCoord clientCoord)
{
// DISPLAY WARNING IF NO MAP
Date timeofday = new Date();
coord = clientCoord;
inst = "WPI";
build = coord.getBuilding();
floor = "" + coord.getFloor();
jConnectionsTextArea.setFont(new java.awt.Font("Dialog", java.awt.Font.BOLD, 14));
if (ipaddr == "null")
{
}
else
{
jConnectionsTextArea.setText(jConnectionsTextArea.getText() + ipaddr + " " + inst + " " +
build + " " + floor + " (" + coord.getX() + ", " + coord.getY() + ") " + timeofday.getTime() + "\n");
// jConnectionsTextArea.setText(jConnectionsTextArea.getText() + ipaddr + " " + inst + " " +
// build + " " + floor + " (" + coord.getX() + ", " + coord.getY() + ")\n");
}
}
public static void addToConnectionList(noogCoord userCoord, String ipaddr)
{
int counter = 0;
while (counter < connectedClients.size())
{
noogetConnection x = (noogetConnection)connectedClients.get(counter);
if (x.ip == ipaddr)
{
connectedClients.remove(counter);
break;
}
counter++;
}
connectedClients.add(new noogetConnection(userCoord, ipaddr));
System.out.println("ADDED TO LIST");
}
public static void main(String[] args)
{
//Schedule a job for the event-dispatching thread:
//creating and showing this application's GUI.
javax.swing.SwingUtilities.invokeLater(new Runnable()
{
public void run()
{
createAndShowGUI();
}
private void createAndShowGUI()
{
//Make sure we have nice window decorations.
JFrame.setDefaultLookAndFeelDecorated(true);
try
{
//UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
}
catch (ClassNotFoundException e)
{
//e.printStackTrace();
}
catch (InstantiationException e)
{
//e.printStackTrace();
}
catch (IllegalAccessException e)
{
//e.printStackTrace();
}
catch (UnsupportedLookAndFeelException e)
{
//e.printStackTrace();
}
getJNoogetFrame().setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//Create and set up the content pane.
JPanel newContentPane = new JPanel();
newContentPane.setOpaque(true);
getJNoogetFrame().getContentPane().add(newContentPane, null);
//Display the window.
getJNoogetFrame().pack();
getJNoogetFrame().setVisible(true);
}
});
}
}
2 noogetProtocol.java
import .*;
import java.io.*;
import noogetXML.*;
public class noogetProtocol
{
public String processIP(String theInput)
{
int indexOfPipe;
indexOfPipe = theInput.lastIndexOf("|");
return theInput.substring(indexOfPipe + 1, theInput.length());
}
public noogCoord processInput(String theInput)
{
int firstPart, secondPart, thirdPart, fourthPart;
String building = "";
int floor, x, y;
firstPart = theInput.indexOf("|");
secondPart = theInput.indexOf("|", firstPart + 1);
thirdPart = theInput.indexOf("|", secondPart + 1);
fourthPart = theInput.indexOf("|", thirdPart + 1);
System.out.println("theInput = " + theInput);
System.out.println("FirstSecondThirdFourth = " + firstPart + " " + secondPart + " " + thirdPart + " " + fourthPart);
System.out.println("y is being set to: " + theInput.substring(thirdPart + 1, fourthPart));
building = theInput.substring(0, firstPart);
floor = new Integer(theInput.substring(firstPart + 1, secondPart)).intValue();
x = new Integer(theInput.substring(secondPart + 1, thirdPart)).intValue();
y = new Integer(theInput.substring(thirdPart + 1, fourthPart)).intValue();
noogCoord theOutput = new noogCoord(building, floor, x, y);
System.out.println("theInput to processInput is: " + theInput);
return theOutput;
}
}
3 noogetMultiServer.java
import .*;
import java.io.*;
public class noogetMultiServer extends Thread
{
public noogetMultiServer()
{
super("noogetMultiServer");
}
public void run()
{
ServerSocket serverSocket = null;
boolean listening = true;
try
{
serverSocket = new ServerSocket(4444);
}
catch (IOException e)
{
System.err.println("Could not listen on port: 4444.");
System.exit(-1);
}
try
{
while (listening)
{
new noogetMultiServerThread(serverSocket.accept()).start();
}
}
catch (Exception y) { }
try
{
serverSocket.close();
}
catch (Exception z) { }
}
}
4 noogetMultiServerThread.java
import .*;
import java.io.*;
import noogetXML.*;
public class noogetMultiServerThread extends Thread
{
private Socket socket = null;
public noogetMultiServerThread(Socket socket)
{
super("noogetMultiServerThread");
this.socket = socket;
}
public void run()
{
try
{
PrintWriter out = new PrintWriter(socket.getOutputStream(), true);
BufferedReader in = new BufferedReader(
new InputStreamReader(
socket.getInputStream()));
String inputLine, outputLine = "";
String ipaddr;
noogCoord userCoord = new noogCoord(null, 0, 0, 0);
noogetProtocol noogsock = new noogetProtocol();
while ((inputLine = in.readLine()) != null)
{
userCoord = noogsock.processInput(inputLine);
ipaddr = noogsock.processIP(inputLine);
System.out.println("Building: " + userCoord.getBuilding() + ", Floor: " + userCoord.getFloor() + ", (x,y): (" + userCoord.getX() + "," + userCoord.getY() + ").");
noogetServer.addToConnectionList(userCoord, ipaddr);
System.out.println("ADDED TO LIST");
noogetServer.drawDot(userCoord);
noogetServer.addIP(ipaddr, userCoord);
if (outputLine.equals("Bye"))
{
break;
}
}
out.close();
in.close();
socket.close();
}
catch (IOException e)
{
}
}
}
5 noogetConnection.java
import java.util.Date;
import noogetCore.*;
import noogetXML.*;
public class noogetConnection
{
int x;
int y;
String building;
Date time;
String ip;
String tag;
public noogetConnection(int newX, int newY, String newB, String ip2)
{
x = newX;
y = newY;
building = newB;
time = new Date();
ip = ip2;
}
public noogetConnection(noogCoord coord, String ip2)
{
ip = ip2;
x = coord.getX();
y = coord.getY();
building = coord.getBuilding();
time = new Date();
String inst = "WPI";
tag = inst + "-" + building + "-" + coord.getFloor();
}
}
6 noogetClientSocket.java
import java.io.*;
import .*;
import .InetAddress;
import noogetXML.*;
public class noogetClientSocket
{
public static void main(String[] args) throws IOException
{
openSocket();
}
public static void openSocket() throws IOException
{
Socket noogSocket = null;
PrintWriter out = null;
BufferedReader in = null;
noogCoord foundCoord = new noogCoord(null, 0, 0, 0);
noogCoord tempCoord = new noogCoord(null, 0, 0, 0);
InetAddress inet = InetAddress.getLocalHost();
try
{
noogSocket = new Socket("ccc2.wpi.edu", 4444);
out = new PrintWriter(noogSocket.getOutputStream(), true);
in = new BufferedReader(new InputStreamReader(noogSocket.getInputStream()));
}
catch (UnknownHostException e)
{
System.err.println("Don't know about host: ccc2.wpi.edu.");
System.exit(1);
}
catch (IOException e)
{
System.err.println("Couldn't get I/O for the connection to: ccc2.wpi.edu.");
System.exit(1);
}
// BufferedReader stdIn = new BufferedReader(new InputStreamReader(System.in));
// String fromServer;
// String fromUser;
//
// while ((fromServer = in.readLine()) != null) {
// System.out.println("Server: " + fromServer);
// if (fromServer.equals("Bye."))
// break;
//
// fromUser = stdIn.readLine();
// if (fromUser != null) {
// System.out.println("Client: " + fromUser);
// out.println(fromUser);
// }
// }
while (true)
{
// First set tempCoord to the previous foundCoord
// This is done so that an update is only sent when the client changes positions
System.out.println("Start of while loop, foundCoord = ");
foundCoord.print();
System.out.println("Start of while loop, tempCoord = ");
tempCoord.print();
foundCoord.setEqual(tempCoord);
System.out.println("After setEqual, foundCoord = ");
foundCoord.print();
System.out.println("After setEqual, tempCoord = ");
tempCoord.print();
// ------------------------
// Get a couple (or few) readings
// Average them together
// Find the point, based on Calibrations unique to this laptop
// ------------------------
// All of these steps are done in clientFuncs, so we call it
foundCoord = clientFuncs.getPoint();
System.out.println("After foundCoord = clientFuncs.getPoint(), foundCoord = ");
foundCoord.print();
System.out.println("foundCoord.isEqual(tempCoord) returns: ");
System.out.println(foundCoord.isEqual(tempCoord));
System.out.println("-------------------PIE------------------");
System.out.println("getHostAddress = " + inet.getHostAddress());
System.out.println("----------------^^^HostAddress^^^---------");
// Only send an update if the point is new
if (!foundCoord.isEqual(tempCoord))
{
// Send a string to server through socket that's already open
out.println(foundCoord.getBuilding() + "|" + foundCoord.getFloor() + "|" + foundCoord.getX() + "|" + foundCoord.getY() + "|" + inet.getHostAddress());
}
// Wait 5 seconds, then do it again.
try
{
Thread.sleep(5000);
}
catch (InterruptedException e)
{
break;
}
}
out.close();
in.close();
//stdIn.close();
noogSocket.close();
}
}
7 createCalibration.java
import noogetCore.*;
import org.placelab.spotter.*;
import org.placelab.core.*;
import java.io.*;
import java.lang.*;
import noogetXML.*;
public class createCalibration {
public static void main(String[] args) {
doIt(args[0], args[1], args[2], args[3]);
}
public static void doIt(String buildingIn, String floorIn, String xIn, String yIn) {
int counter = 0;
String build = buildingIn;
int floor = new Integer(floorIn.toString()).intValue();
int xpos = new Integer(xIn.toString()).intValue();;
int ypos = new Integer(yIn.toString()).intValue();;
calibration intermediatePoint = new calibration();
calibration finalCalib = new calibration();
noogCoord tempCoord = new noogCoord(null, 0, 0, 0);
coordList fullList = new coordList();
fullList.read("coords.xml");
// Must erase the log before starting a new calibration point.
try{
BufferedWriter out = new BufferedWriter(new FileWriter("log.txt", false));
out.close();
}
catch (IOException e){
}
try {
tempCoord.setBuilding(buildingIn);
tempCoord.setFloor(floor);
tempCoord.setX(xpos);
tempCoord.setY(ypos);
while(counter ................
................
In order to avoid copyright disputes, this page is only a partial summary.
To fulfill the demand for quickly locating and searching documents.
It is intelligent file search solution for home and business.
Related searches
- abstract for chemistry lab report
- experimental biology 2019 abstract submission
- experimental biology abstract deadline
- biology abstract example
- experimental biology 2019 abstract deadli
- experimental biology 2019 abstract deadline
- experimental biology 2019 abstract submi
- chemistry lab report abstract example
- experimental biology abstract submission
- abstract lab report example
- biology lab report abstract example
- abstract report example