Professional Documents
Culture Documents
Abstract
Virtual Controller: This program allows any computer to control other PCs remotely. Project aims at administering a remote computer using network communication. The remote computer acts as client and the controlling computer acts as a server. Any number of clients can be connected to the server. The core function of client is sending a screen shot of the clients desktop at a predefined amount of time. For each client a new frame is generated and the screen shot is displayed at the sever side. The clients control is communicated in the form of mouse movement and key strokes. Program Features:
View remote desktop Mouse movement control Mouse buttons control Keyboard control
Virtual Controller
1. INTRODUCTION
1.1 Purpose
Administration in computer organization is a modern professional responsible for the maintenance of computer hardware and software that comprises a computer network. This normally includes the deployment, configuration, maintenance and monitoring of active Employee function. A related role is that of the network specialist, or network analyst, who concentrates on network design and security. Network administrators are responsible for making sure computer hardware and the network infrastructure itself is maintained properly for an IT organization. They are deeply involved in the rolling out new software installs, and as well as employee tasks what actually they are doing in the time of job. But there is a problem to maintain all networks with one administrator. So our virtual controller program allows any computer to control other PCs remotely. Project aims at administering a remote computer using network communication. The remote computer acts as client and the controlling computer acts as a server. Any number of clients can be connected to the server. The core function of client is sending a screen shot of the clients desktop at a predefined amount of time. For each client a new frame is generated and the screen shot is displayed at the sever side. The clients control is communicated in the form of mouse movement and key strokes.
1.2 Scope
Virtual Controller provides some very useful and general important functions for the administrator to maintain the clients function or tasks in computer network and, in this application, reduce the burden on administrator work and saving the time for all levels of network. This the client side, its core function is sending a screen shot of the client's desktop every predefined amount of time. Also it receives server commands such as "move the mouse command", and then executes the command at the client's PC. Any [2] SRTIST(I.T Dept)
Virtual Controller
number of clients can be connected to the server. The core function of client is sending a screen shot of the clients desktop at a predefined amount of time.
Virtual Controller
connections and per each connected client, a new frame appears showing the current client screen. When you move the mouse over the frame, this results in moving the mouse at the client side. The same happens when you right/left click mouse button or type a key while the frame is in focus. Client side, its core function is sending a screen shot of the client's desktop every predefined amount of time. Also it receives server commands such as "move the mouse command", and then executes the command at the client's PC.
Virtual Controller
2. MODULE DESCRIPTION
3.1 Modules:
Develop Remote Server Develop Remote Client.
3.1.1. Remote Server This is the server part which waits for clients connections and per each connected client, a new frame appears showing the current client screen. When you move the mouse over the frame, this results in moving the mouse at the client side. The same happens when you right/left click mouse button or type a key while the frame is in focus.
3.1.2. Remote Client This the client side, its core function is sending a screen shot of the client's desktop every predefined amount of time. Also it receives server commands such as "move the mouse command", and then executes the command at the client's PC.
Virtual Controller
Virtual Controller
4. FEASIBILITY STUDY
4.1 Feasibility Study:
The next step in analysis is to verify the feasibility of the proposed system. All projects are feasible given unlimited resources and infinite time. But in reality both resources and time are scarce. Project should confirm to time bounce and should be optimal in there consumption of resources. The development of computer-based system is likely to be played by Scarcity of resources and difficulty in completion dates. Feasibility study is the measure of how beneficial or practical information system will be to an organization. Further developer would like to finalize the software and hardware requirements to develop the proposed system. The objective of Feasibility Study is to evaluate the relevant factors involved in the problem statement, considers preliminary alternative solutions weakness and advantages, and recommended a feasible solution to the problem statement. A feasibility study is an evaluation of a proposal designed to determine the difficulty in carrying out a designated task. Generally, a feasibility study precedes technical development and project implementation. The most important phase in a project development is judging whether the project will be feasible or not. A project developed which is not feasible will serve no purpose. Feasibility has applied to virtual controller pertains to the following areas: Technical feasibility Operational feasibility Economical feasibility
Virtual Controller
As we are developing this virtual controller Application on Java 2 platform edition which is an open source and free of cost. Once we started developing this application in Java 2 platform edition then they is no need of purchasing any special software or application software for support. Java it self provides all necessary functionalities and resources for developing virtual controller Application. For Example like developing GUI can be developed by AWT or Swing Framework which is much available in Java.
4.1.2 Operational Feasibility To determine the operational feasibility of the system we should take into consideration the awareness level of the users. Users who are using this virtual controller Application dont require much knowledge of how to use. Just Users should have basic concept of what is virtual controller? Every thing will be understood by user once he sees the application. 4.1.3 Economic Feasibility To decide whether a project is economically feasible, or not we have to consider various factors as: Cost benefit analysis Long-term returns Maintenance costs
Virtual Controller
5. DESIGN OBJECTIVES
Design is the first step in moving from problem domain to the solution domain. Design is essentially the bridge between requirements specification and the final solution. The goal of design process is to produce a model or representation of a system, which can be used later to build that system. The produced model is called the Design of the System. It is a plan for a solution for the system.
Virtual Controller
5.1.1 Goals of UML: 1. It offers the users to express visual modeling language and ready to use. 2. To extend the core concepts, various extensibility and specialization mechanisms are provided. 3. Development processes and programming language which are in particular are made to be independent by the UML design. 4. Necessary understanding of the language is provided formally. 5. Development concepts like components, frameworks, collaborations and patterns. 6. The market of the Object-Oriented tools growth must be encouraged.
5.1.2 UML DIAGRAMS: Class Diagram: Class diagrams are widely used to describe the types of objects in a system and their relationships. Class diagrams model class structure and contents using design elements such as classes, packages and objects. Class diagrams describe three different perspectives when designing a system, conceptual, specification, and implementation. These perspectives become evident as the diagram is created and help solidify the design. Class diagram tell about the list of classes with their attributes and methods which are used in each and every module. Use Case Diagram: Here user is the main heart of our application and we are providing so many options to maintain administration functions, for the need to add port number and ip address for the seeing client system, similarly client also give the port number and ip address .but client
Virtual Controller
does not connect the server just giving information to the server. If the ip addresses are validate then only streaming will continue. Interaction Diagram An Interaction diagram shows an interaction, consisting of a set of objects and their relationships, including the messages that may be dispatched among them. Interaction diagrams are used for modeling the dynamic aspects of the system. A sequence diagram is an interaction diagram that emphasizes the time ordering of the messages. Graphically, a sequence diagram is a table that shows objects arranged alongs the X-axis and messages, ordered in increasing time, along the Y-axis and messages, ordered in increasing time, along the Y-axis.
Sequence Diagram:
Sequence diagrams demonstrates the sequential flow of software architecture used in this application .Sequence diagrams document the interactions between classes to achieve a result, such as a use case. Because UML is designed for object oriented programming, this communications between classes are known as messages. The sequence diagrams lists diagrams lists objects horizontally, and time vertically, and models these messages over time. Activity Diagram An Activity Diagram is essentially a flow chart showing flow of control from activity to activity. They are used to model the dynamic aspects of as system .They can also be used to model the flow of an object as it moves from state to state at different points in the flow of control. An activity is an ongoing non-atomic execution with in a state machine. Activities ultimately result in some action, which is made up of executable atomic computations that result in a change of state of distinguishes a use case diagram from all other kinds of diagrams is its particular content. [11] SRTIST(I.T Dept)
Virtual Controller
State Chart Diagram A state chart diagram shows a state machine .State chart diagrams are used to model the dynamic aspects of the system. For the most part this involves modeling the behavior of the reactive objects. A reactive object is one whose behavior is best characterized by its response to events dispatched from outside its context. A reactive object has a clear lifeline whose current behavior is affected by its past. Class Diagram:
Virtual Controller
Virtual Controller
Virtual Controller
Sequence Diagram for Server:
Virtual Controller
Virtual Controller
Virtual Controller
Virtual Controller
Component diagram:
[19] SRTIST(I.T Dept)
Virtual Controller
Deployment diagram:
[20] SRTIST(I.T Dept)
Virtual Controller
Virtual Controller
c) Implementation Phase: The implementation phase of software development involves translation of design specifications source code and debugging, documentation and unit testing of the source code. [22] SRTIST(I.T Dept)
Virtual Controller
d) Testing Phase: It involves two kinds of testing: i) In integration testing the individual program units or programs are integrated and tested. ii) Acceptance Testing involves planning and execution of various types of tests in order to demonstrate that the implemented software satisfies the stated requirements.
Java Overview
Java is a powerful but lean object-oriented programming language. It has generated a lot of excitement because it makes it possible to program for Internet by creating Applets which are programs that can be embedded in web page. The context of an applet can be an animation with sound, an interactive game or a ticker tape. With constantly updated stock prices, applets can be just little decorations to liven up web page, or they can be serious applications like Word processor or Spreadsheet. But Java is more than a programming language for writing Applets. It is being used more and more for writing standalone applications as well. It is becoming so popular that many people believe it will become standard language for both general purpose and Internet programming. There are many buzzwords associated with Java, but because of its spectacular growth in popularity, a new buzzword has appeared ubiquitous. Indeed, all indications are that it will soon be everywhere.
Virtual Controller
Java builds on the strength of C++. It has taken the best features of C++ and discarded the more problematic and error prone parts. To this lean core, it has added garbage collection (automatic memory management), multithreading (the capacity for one program to do more than one thing at a time), security capabilities. This result is that Java is simple, elegant, and powerful and easy-to-use. Java is actually a platform consisting of 3 components: Java Programming Language Java Library of Classes and Interfaces Java Virtual Machine
The following sections will say more about these components. Java is portable: One of the biggest advantages Java offers is that it is portable. An application written in Java will run on all the major platforms. Any computer with a Javabased browser can run the applications or Applets written in the Java-ProgrammingLanguage. A programmer no longer has to write one program to run on a Macintosh, another program to run on a Windows-machine still another to run on a UNIX-machine and so on. In other words, with Java developers write their programs only once. The Virtual Machine is what gives Java is cross platform capabilities. Rather being compiled into machine language, which is different for each OSs and computer architecture, Java code is compiled into Byte codes. With other Languages, the program code is compiled into a language that the computer can understand. The problem is that other computers with different machine instruction set cannot understand that language. Java code on the other hand is compiled into Byte-Code rather than a machine language. This byte codes go to the JVM, which executes them directly or translates them into the language that is understood by the machine running it. In summary, these means that with the JDBC API extending Java, a programmer writing Java code can access all the major RDBMS on any platform that supports the JVM.
Virtual Controller
Java is Object Oriented: The Java programming language is OBJECT-ORIENTED, which makes program design focus on what you are dealing with, rather than on how your are going to do something. This makes it more useful for programming in sophisticated projects, because one can break the things into understandable components. A big benefit is that these components can then be reused. Object-Oriented Languages use the paradigm of classes. In
simplest term, a class includes both the data and the functions to operate on data. You can create an instance of a class, also called an object, which will have all the data members and functionality of its class. Because of this, you can think of a class as being like template, with each object being a specific instance of a particular type of class.
The class paradigm allows one to encapsulate data so that specific data values are those using the data cannot see the function implementation. Encapsulation makes it possible to make the changes in code without breaking other programs that use that code. If for example, the implementation of a function is changed, the change is invisible to any programmer who invokes that function, and does not affect his/her program, except hopefully to improve it.Java includes inheritance, or the ability to derive new classes from existing classes. The derived class, is also called as Sub-Class, inherits all the data in the functions of the existing class.
Java Development Environment: To code, edit, debug and test the java programs, one needs to have a java development environment. At the minimum this will consists of a java compiler, interpreter and applet viewer where applets can be tested. Suns java development kit (JDK) latest version is 2.2 can be freely downloaded from the Internet. Java compiler is available on DOS, Win95, WINNT, Solaris and MAC etc.
Virtual Controller
7.CODE
7.1 REMOTE SERVER: 7.1.1 Serverinitiator:
package remoteserver; import java.awt.BorderLayout; import java.io.IOException; import java.net.ServerSocket; import java.net.Socket; import javax.swing.JDesktopPane; import javax.swing.JFrame; import javax.swing.JOptionPane; /** * This is the entry class of the server */ public class ServerInitiator { //Main server frame private JFrame frame = new JFrame(); //JDesktopPane represents the main container that will contain all //connected clients' screens private JDesktopPane desktop = new JDesktopPane(); public static void main(String args[]){ String port = JOptionPane.showInputDialog("Please enter listening port"); new ServerInitiator().initialize(Integer.parseInt(port)); } public void initialize(int port){ try { ServerSocket sc = new ServerSocket(port); //Show Server GUI drawGUI(); //Listen to server port and accept clients connections while(true){ Socket client = sc.accept(); System.out.println("New client Connected to the server"); //Per each client create a ClientHandler new ClientHandler(client,desktop); } } catch (IOException ex) { ex.printStackTrace();
Virtual Controller
} } /* * Draws the main server GUI */ public void drawGUI(){ frame.add(desktop,BorderLayout.CENTER); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //Show the frame in a maximized state frame.setExtendedState(frame.getExtendedState()|JFrame.MAXIMIZED_BOTH); frame.setVisible(true); } }
Virtual Controller
System.out.println("yScale: " + yScale); System.out.println("Mouse Moved"); writer.println(EnumCommands.MOVE_MOUSE.getAbbrev()); writer.println((int)(e.getX() * xScale)); writer.println((int)(e.getY() * yScale)); writer.flush(); } //this is not implemented public void mouseClicked(MouseEvent e) { } public void mousePressed(MouseEvent e) { System.out.println("Mouse Pressed"); writer.println(EnumCommands.PRESS_MOUSE.getAbbrev()); int button = e.getButton(); int xButton = 16; if (button == 3) { xButton = 4; } writer.println(xButton); writer.flush(); } public void mouseReleased(MouseEvent e) { System.out.println("Mouse Released"); writer.println(EnumCommands.RELEASE_MOUSE.getAbbrev()); int button = e.getButton(); int xButton = 16; if (button == 3) { xButton = 4; } writer.println(xButton); writer.flush(); } //not implemented public void mouseEntered(MouseEvent e) { } //not implemented public void mouseExited(MouseEvent e) { } //not implemented public void keyTyped(KeyEvent e) { }
Virtual Controller
public void keyPressed(KeyEvent e) { System.out.println("Key Pressed"); writer.println(EnumCommands.PRESS_KEY.getAbbrev()); writer.println(e.getKeyCode()); writer.flush(); } public void keyReleased(KeyEvent e) { System.out.println("Mouse Released"); writer.println(EnumCommands.RELEASE_KEY.getAbbrev()); writer.println(e.getKeyCode()); writer.flush(); } }
Virtual Controller
public void run(){ //used to represent client screen size Rectangle clientScreenDim = null; //Used to read screenshots and client screen dimension ObjectInputStream ois = null; //start drawing GUI drawGUI(); try{ //Read client screen dimension ois = new ObjectInputStream(cSocket.getInputStream()); clientScreenDim =(Rectangle) ois.readObject(); }catch(IOException ex){ ex.printStackTrace(); }catch(ClassNotFoundException ex){ ex.printStackTrace(); } //Start recieveing screenshots new ClientScreenReciever(ois,cPanel); //Start sending events to the client new ClientCommandsSender(cSocket,cPanel,clientScreenDim); } }
Virtual Controller
GraphicsDevice gDev=gEnv.getDefaultScreenDevice(); //Get screen dimensions Dimension dim = Toolkit.getDefaultToolkit().getScreenSize(); rectangle = new Rectangle(dim); //Prepare Robot object robot = new Robot(gDev); //draw client gui drawGUI(); //ScreenSpyer sends screenshots of the client screen new ScreenSpyer(socket,robot,rectangle); //ServerDelegate recieves server commands and execute them new ServerDelegate(socket,robot); } catch (UnknownHostException ex) { ex.printStackTrace(); } catch (IOException ex) { ex.printStackTrace(); } catch (AWTException ex) { ex.printStackTrace(); } } private void drawGUI() { JFrame frame = new JFrame("Remote Admin"); JButton button= new JButton("Terminate"); frame.setBounds(100,100,150,150); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.add(button); button.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { System.exit(0); } } ); frame.setVisible(false); } }
Virtual Controller
* does not implement Serializable interface */ ImageIcon imageIcon = new ImageIcon(image); //Send captured screen to the server try { System.out.println("before sending image"); oos.writeObject(imageIcon); oos.reset(); //Clear ObjectOutputStream cache System.out.println("New screenshot sent"); } catch (IOException ex) { ex.printStackTrace(); } //wait for 100ms to reduce network traffic try{ Thread.sleep(100); }catch(InterruptedException e){ e.printStackTrace(); } } } }
Virtual Controller
case -5: robot.mouseMove(scanner.nextInt(), scanner.nextInt()); break; } } } catch (IOException ex) { ex.printStackTrace(); } } }
Virtual Controller
8.TESTING
7.1 Software Testing
Software testing is a critical element of software quality assurance and represents the ultimate review of specification, design and code generation.
Testing is a process of executing a program with the intent of finding an error. A good test case is one that has a high probability of finding an as yet undiscovered error The software developed has been tested successfully using the following testing strategies and any errors that are encountered are corrected and again the part of the program or the procedure or function is put to testing until all the errors are removed. A successful test is one that uncovers undiscovered error. Note that the result of the system testing will prove that the system is working correctly. It will give confidence to system designer, users of the system and prevent frustration during implementation process etc.
Virtual Controller
Virtual Controller
the testing interfaces between the modules. In the generic code integration testing is done mainly on table creation module and insertion module. Validation Testing This testing concentrates on confirming that the software is error-free in all respects. All the specified validations are verified and the software is subjected to hardcore testing. It also aims at determining the degree of deviation that exists in the software designed from the specification; they are listed out and are corrected. System Testing This testing is a series of different tests whose primary computer-based system. This involves: Implementing the system in a simulated production environment and testing it. Introducing errors and testing for error handling. goal is to exercise the
TEST CASE 2: The IP address of server should be entered correctly at the clients end. Otherwise error message is displayed.
Virtual Controller
Screen 1:
Virtual Controller
Virtual Controller
9. REQUIRED PACKAGES
import java.awt.AWTException; import java.awt.Dimension; import java.awt.GraphicsDevice; import java.awt.GraphicsEnvironment; import java.awt.Rectangle; import java.awt.Robot; import java.awt.Toolkit; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.io.IOException; import java.net.Socket; import java.net.UnknownHostException; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JOptionPane;
When user run server application it should ask listening port number:
String port = JOptionPane.showInputDialog("Please enter listening port"); new ServerInitiator().initialize(Integer.parseInt(port)); . . . public void initialize(int port){ [48] SRTIST(I.T Dept)
Virtual Controller
try { ServerSocket sc = new ServerSocket(port); //Show Server GUI drawGUI(); //Listen to server port and accept clients connections while(true){ Socket client = sc.accept(); System.out.println("New client Connected to the server"); //Per each client create a ClientHandler new ClientHandler(client,desktop); } } catch (IOException ex) { ex.printStackTrace(); } }
Virtual Controller
public void drawGUI(){ interFrame.setLayout(new BorderLayout()); interFrame.getContentPane().add(cPanel,BorderLayout.CENTER); interFrame.setSize(100,100); desktop.add(interFrame); try { //Initially show the internal frame maximized interFrame.setMaximum(true); } catch (PropertyVetoException ex) { ex.printStackTrace(); } //this allows to handle KeyListener events cPanel.setFocusable(true); interFrame.setVisible(true); } public void run(){ //used to represent client screen size Rectangle clientScreenDim = null; //Used to read screenshots and client screen dimension ObjectInputStream ois = null; //start drawing GUI drawGUI(); try{ //Read client screen dimension ois = new ObjectInputStream(cSocket.getInputStream()); clientScreenDim =(Rectangle) ois.readObject(); }catch(IOException ex){ [50] SRTIST(I.T Dept)
Virtual Controller
ex.printStackTrace(); }catch(ClassNotFoundException ex){ ex.printStackTrace(); } //Start recieveing screenshots new ClientScreenReciever(ois,cPanel); //Start sending events to the client new ClientCommandsSender(cSocket,cPanel,clientScreenDim); } ////eg:ClientCommandSenderClass public void mouseDragged(MouseEvent e) { } public void mouseMoved(MouseEvent e) { double xScale = clientScreenDim.getWidth()/cPanel.getWidth(); System.out.println("xScale: " + xScale); double yScale = clientScreenDim.getHeight()/cPanel.getHeight(); System.out.println("yScale: " + yScale); System.out.println("Mouse Moved"); writer.println(EnumCommands.MOVE_MOUSE.getAbbrev()); writer.println((int)(e.getX() * xScale)); writer.println((int)(e.getY() * yScale)); writer.flush(); } ///Eg:client Screen Receiver class while(continueLoop){ //Recieve client screenshot and resize it to the current panel size ImageIcon imageIcon = (ImageIcon) cObjectInputStream.readObject(); System.out.println("New image recieved"); [51] SRTIST(I.T Dept)
Virtual Controller
Image image = imageIcon.getImage(); image = image.getScaledInstance(cPanel.getWidth(),cPanel.getHeight() ,Image.SCALE_FAST); //Draw the recieved screenshot Graphics graphics = cPanel.getGraphics(); graphics.drawImage(image, 0, 0, cPanel.getWidth(),cPanel.getHeight(),cPanel);
Virtual Controller
10.CONCLUSION
Virtual Controller provides some very useful and general important functions in the administration tasks, in this application; The remote computer acts as client and the controlling computer acts as a server. Any number of clients can be connected to the server. The modern virtual controller achieves in terms of the existing system problems, in generally administrators are server part which waits for clients connections and per each connected client, a new frame appears showing the current client screen. When you move the mouse over the frame, these results in moving the mouse at the client side.
Virtual Controller
11. BIBILIOGRAPHY
1. the JDK1.4 tutorial Greg Travis 2. Complete Reference Java, 2nd Edition Herbert Schlitz 3. Core Java Foundation Class Kim Topley, 4. Java Network Programming OReilly 5. JAVA how to program DEITEL & DEITEL 6. The Unified Modeling Language User Guide: GRADY BOOCH, JAMES RUMBAUGH, IVAR JACOBSON 7. Accessibility and the Swing Set, Mark Andrews, The Swing Connection, Sun Microsystems, 1999. http://java.sun.com/products/jfc/tsc/articles/accessibility/index.html 8. Coming Swing API Changes for Java 2 SDK, Standard Edition, v. 1.4, Connection, Sun Microsystems, 2001. The Swing http://java.sun.com/products/jfc/tsc/articles/merlin/index.html 9. Component Orientation in Swing, Ralph Karr 10. The Swing Connection, Sun Microsystems,1999. http://java.sun.com/products/jfc/tsc/articles/bidi/index.html 11. Core Java Foundation Classes (Core Series), Kim Topley, Prentice Hall, 1998.