You are on page 1of 33

A PROJECT REPORT

ON
REMOTE MONITORING SYSTEM

Submitted to
ITR,DRDO
In Partial Fulfilment of the Requirement for the Award of

BACHELORS DEGREE IN
COMPUTER ENGINEERING
BY

AKANKHYA BEHERA 114CS0093

UNDER THE GUIDANCE OF


MR. SOURAV KAITY

Integrated Test range


DRDO
Chandipur, Odisha - 756025
2017-2018

in association with

National Institute of Technology


Rourkela
Integrated test range
Defence R&D Organisation(DRDO)
Chandipur, Odisha 756025

CERTIFICATE
This is certify that the project entitled
REMOTE MONITORING SYSTEM
submitted by

AKANKHYA BEHERA 114CS0093

is a record of bonafide work carried out by them, in the partial fulfilment of the
requirement for the award of Degree of Bachelor of Engineering (Computer Engi-
neering) at National Institute of Technology, Rourkela. This work is done during
year 2017-2018, under our guidance.

Date: / /

(Mr. Sourav Kaity) (Mr B.K. Ojha)


Project Guide Project Coordinator

(Mr. H.K. Rath) (Dr. B.K. Das)


Add. Director(CDP) Director
Acknowledgements

I am profoundly grateful to Mr. SOURAV KAITY for his expert guidance and
continuous encouragement throughout to see that this project rights its target since
its commencement to its completion.

I would like to express deepest appreciation towards Dr. B.K. DAS, Director,Integrated
Test Range,Chandipur,for having us here Mr. H.K. RATHA, Additional Director
(CDP) whose invaluable guidance supported us in completing this project.

At last we must express our sincere heartfelt gratitude to all the staff members of
ITR,Chandipur, who helped me directly or indirectly during this course of work.

AKANKHYA BEHERA
ABSTRACT

This is a software that is socket-connection based,connecting one server computer


to multiple client computers provided all the involved systems are connected to the
same LAN or ultimately in the same WAN.The IP address of the computers and the
port it wishes to connect to is all that is required and then we are good to go.The
server can see the desktop of all of its clients at once,control the activities of these
computers as well as record the screen for later perusal. It is very much like the
TeamViewer software with the added perks of catering to not just one but upto 16
clients at once.

This software can be used in classrooms and in labs where the teacher can mon-
itor the students as well as provide them with the required help and support with-
out having to physically go to each student individually. This saves time and en-
ergy.Conferences can be held without actually assembling workers physically.The
boss can regulate his/her workers and can monitor what they are doing and how
much work is being done by whom.The rockets that are launched from test ranges
need constant monitoring and from different angles all at the same time.This pur-
pose is also met by this software.Finally,as this software runs at boot time,it can be
used to play pranks on friends,leaving them bewildered as to how their computers
are behaving like they have a mind of their own.
Contents

1 Introduction 2
1.1 DRDO . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.1.1 About . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.1.2 ITR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3

2 Requirements Analysis 4
2.1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
2.2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
2.3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11

3 System Design:Functionalities and libraries used 13


3.1 Swing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
3.2 Socket Programming . . . . . . . . . . . . . . . . . . . . . . . . . 14
3.3 TCP/IP SOCKET PROGRAMMING . . . . . . . . . . . . . . . . 18
3.4 UDP SOCKET PROGRAMMING . . . . . . . . . . . . . . . . . . 18
3.5 Multithreading . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
3.6 Java ROBOT class . . . . . . . . . . . . . . . . . . . . . . . . . . 21
3.7 Java Properties File . . . . . . . . . . . . . . . . . . . . . . . . . . 22
3.8 JNativeHook jar . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
3.9 java-screen-recorder-master zip . . . . . . . . . . . . . . . . . . . . 23

4 Similar Softwares 24

5 Screenshots of Project 25
5.1 Clients . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
5.2 Server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27

6 Conclusion and Future Scope 28

References 28
Remote Monitoring System

Chapter 1

Introduction

1.1 DRDO

1.1.1 About

DRDO was formed in 1958 from the amalgamation of the then already function-
ing Technical Development Establishment (TDEs) of the Indian Army and the Di-
rectorate of Technical Development Production (DTDP) with the Defence Science
Organisation (DSO). DRDO was then a small organisation with 10 establishments or
laboratories. Over the years, it has grown multi-directionally in terms of the variety
of subject disciplines, number of laboratories, achievements and stature.

Today, DRDO is a network of more than 50 laboratories which are deeply en-
gaged in developing defence technologies covering various disciplines, like aeronau-
tics, armaments, electronics, combat vehicles, engineering systems, instrumentation,
missiles, advanced computing and simulation, special materials, naval systems, life
sciences, training, information systems and agriculture. Presently, the Organisation
is backed by over 5000 scientists and about 25,000 other scientific, technical and
supporting personnel. Several major projects for the development of missiles, arma-
ments, light combat aircrafts, radars, electronic warfare systems etc are on hand and
significant achievements have already been made in several such technologies.

The Defence Research and Development Organisation (DRDO) is an agency of


the Republic of India, charged with the militarys research and development, head-
quartered in New Delhi, India.
Vision

Department of Computer Science Engineering, NIT , Rourkela 1


Remote Monitoring System

Make India prosperous by establishing world class science and technology base
and provide our Defence Services decisive edge by equipping them with internation-
ally competitive systems and solutions.
Mission

1. Design, develop and lead to production state-of-the-art sensors, weapon sys-


tems, platforms and allied equipment for our Defence Services.

2. Provide technological solutions to the Services to optimise combat effective-


ness and to promote well-being of the troops.

3. Develop infrastructure and committed quality manpower and build strong in-
digenous technology base.

1.1.2 ITR

ITR(Integrated Test Range) was set up to provide safe and reliable launch facilities
for performance evaluation of rockets missiles and airborne weapon systems. Start-
ing in 1982 as a project under Integrated Guided Missile Development Programme
(IGMDP), it has been graduated to perfection over the years and has reached the
status of world class test range maiden test launch of intermediate range ballistic
missile, agni AE 01 on 22nd May, 1989 from this test range has put it at a prominent
place in the world map. Since then it has tested more than 1000 missions including
300 major missions of national importance.

All these test are conducted at idea which is 200 km from two major cities of the
country Kolkata in the north and Bhubaneswar in the south. Strategically placed
along the Bay of Bengal it has the advantage of safe corridor for short and medium
range missile systems. The receding sea of Chandipur serves as a God-gifted test-
bed for weapons. The sprawling Chandipur range has an area of about 475 acres
of Technical facilities and about 120 acres of launch complexes. Apart from this it
has several pockets of land mass all along the coast line where a number of high
performance instrumentation systems are deployed for effective real-time capture
and data recording.

Department of Computer Science Engineering, NIT , Rourkela 2


Remote Monitoring System

Chapter 2

Requirements Analysis

2.1

Ubuntu

Ubuntu is a Debian-based Linux operating system for personal computers, tablets


and smartphones, where Ubuntu Touch edition is used; and also runs network servers,
usually with the Ubuntu Server edition, either on physical or virtual servers (such as
on mainframes) or with containers, that is with enterprise-class features; runs on the
most popular architectures, including server-class ARM-based.

Ubuntu is published by Canonical Ltd, who offer commercial support. It is based


on free software and named after the Southern African philosophy of ubuntu (lit-
erally, human-ness), which Canonical Ltd. suggests can be loosely translated as
humanity to others or I am what I am because of who we all are. Since Ubuntu
11.04 Natty Narwhal Ubuntu has used Unity as its default user interface for the
desktop, but following the release of Ubuntu 17.10 it will move to the GNOME 3
desktop instead, as work on Unity ends.Ubuntu is the most popular operating system
running in hosted environments, socalled clouds,as it is the most popular server
Linux distribution.

Development of Ubuntu is led by UK-based Canonical Ltd., a company of South


African entrepreneur Mark Shuttleworth. Canonical generates revenue through the
sale of technical support and other services related to Ubuntu.The Ubuntu project
is publicly committed to the principles of open-source software development; peo-
ple are encouraged to use free software, study how it works, improve upon it, and
distribute it.

Department of Computer Science Engineering, NIT , Rourkela 3


Remote Monitoring System

Features

A default installation of Ubuntu contains a wide range of software that includes


LibreOffice, Firefox, Thunderbird, Transmission, and several lightweight games
such as Sudoku and chess. Many additional software packages are accessible from
the built in Ubuntu Software Center as well as any other APT-based package man-
agement tools. Many additional software packages, such as Evolution, GIMP, Pid-
gin, and Synaptic, that are no longer installed by default, are still accessible in the
repositories, installable with the built in Ubuntu Software Center; or by any other
APT-based package management tool and Snappy.

Ubuntu operates under the GNU General Public License (GPL) and all of the
application software installed by default is free software. In addition, Ubuntu installs
some hardware drivers that are available only in binary format, but such packages
are clearly marked in the restricted component.

Security

Ubuntus goal is to be secure out-of-the box. By default, the users programs


run with low privileges and cannot corrupt the operating system or other users files.
For increased security, the sudo tool is used to assign temporary privileges for per-
forming administrative tasks, which allows the root account to remain locked and
helps prevent inexperienced users from inadvertently making catastrophic system
changes or opening security holes. PolicyKit is also being widely implemented into
the desktop. Most network ports are closed by default to prevent hacking. A built-
in firewall allows end-users who install network servers to control access. A GUI
(GUI for Uncomplicated Firewall) is available to configure it. Ubuntu compiles its
packages using GCC features such as PIE and buffer overflow protection to harden
its software.

Ubuntu also supports full disk encryption as well as encryption of the home and
Private directories

Why Ubuntu is better than Windows?

1. hardware auto configuration - Ubuntu comes with the drivers for most hardware
built-in. Anyone whos installed a generic version of Windows (i.e., not one

Department of Computer Science Engineering, NIT , Rourkela 4


Remote Monitoring System

pre-configured by a PC vendor to work with certain hardware) knows how nice


it is not to have to spend hours hunting around for drivers after installing the
operating system.

2. multiple desktops - virtual desktops are like tabbed web browsingyou dont
realize how extraordinarily useful they are until you try them. There are some
third-party tools to achieve the same functionality in Windows, but in my ex-
perience few of them work well, if at all, in Vista and above.

3. software repositories - being able to install thousands of applications from


Ubuntus repositories in a few clicks is a huge plus. Besides the fact that the
software is free and more secure than .exe packages downloaded from random
websites, its much more convenient to install programs from a centralized lo-
cation.

4. ssh client - this probably only matters to geeks, but having an ssh client built
into the operating system is a major plus for me. There are some decent
ssh clients available for Windows, like Putty, but none are available in Win-
dows out-of-the-box, and even the best of them isnt as functional as the trusty
gnome-terminal.

5. no antivirus - security practices in the Windows world are profoundly contra-


dictory. Many of the same companies that write Windows software also make
millions of dollars selling resource-hogging applications to protect Windows
applications from their security flaws. Ubuntu is by no means immune to mal-
ware, but practically speaking, its as secure as it needs to be for most users
out-of-the-box, without any expensive antivirus scanners added on.

2.2

NetBean

NetBeans is used as the IDE while the project is made using Java Programming
Language.The NetBeans Platform is a framework for simplifying the development
of Java Swing desktop applications. The NetBeans IDE bundle for Java SE contains
what is needed to start developing NetBeans plugins and NetBeans Platform based
applications; no additional SDK is required.

Department of Computer Science Engineering, NIT , Rourkela 5


Remote Monitoring System

Applications can install modules dynamically. Any application can include the
Update Center module to allow users of the application to download digitally signed
upgrades and new features directly into the running application. Reinstalling an up-
grade or a new release does not force users to download the entire application again.
The platform offers reusable services common to desktop applications, allowing de-
velopers to focus on the logic specific to their application.

Among the features of the platform are: User interface management (e.g. menus
and toolbars) User settings management Storage management (saving and loading
any kind of data) Window management Wizard framework (supports step-by-step
dialogs) NetBeans Visual Library Integrated development tools

NetBeans IDE is the official IDE for Java 8. With its editors, code analyzers,
and converters, you can quickly and smoothly upgrade your applications to use new
Java 8 language constructs, such as lambdas, functional operations, and method ref-
erences. Batch analyzers and converters are provided to search through multiple
applications at the same time, matching patterns for conversion to new Java 8 lan-
guage constructs.

With its constantly improving Java Editor, many rich features and an extensive
range of tools, templates and samples, NetBeans IDE sets the standard for develop-
ing with cutting edge technologies out of the box.

An IDE is much more than a text editor. The NetBeans Editor indents lines,
matches words and brackets, and highlights source code syntactically and seman-
tically. It lets you easily refactor code, with a range of handy and powerful tools,
while it also provides code templates, coding tips, and code generators.

The editor supports many languages from Java, C/C++, XML and HTML, to PHP,
Groovy, Javadoc, JavaScript and JSP. Because the editor is extensible, you can plug
in support for many other languages.

Easy Efficient Project Management

Keeping a clear overview of large applications, with thousands of folders and files,
and millions of lines of code, is a daunting task. NetBeans IDE provides different

Department of Computer Science Engineering, NIT , Rourkela 6


Remote Monitoring System

views of your data, from multiple project windows to helpful tools for setting up
your applications and managing them efficiently, letting you drill down into your
data quickly and easily, while giving you versioning tools via Subversion, Mercurial,
and Git integration out of the box.
When new developers join your project, they can understand the structure of
your application because your code is well-organized.

Rapid User Interface Development

Design GUIs for Java SE, HTML5, Java EE, PHP, C/C++, and Java ME applica-
tions quickly and smoothly by using editors and drag-and-drop tools in the IDE.
For Java SE applications, the NetBeans GUI Builder automatically takes care
of correct spacing and alignment, while supporting in-place editing, as well. The
GUI builder is so easy to use and intuitive that it has been used to prototype GUIs
live at customer presentations.

Write Bug Free Code

The cost of buggy code increases the longer it remains unfixed. NetBeans provides
static analysis tools, especially integration with the widely used FindBugs tool, for
identifying and fixing common problems in Java code. In addition, the NetBeans
Debugger lets you place breakpoints in your source code, add field watches, step
through your code, run into methods, take snapshots and monitor execution as it
occurs.

The NetBeans Profiler provides expert assistance for optimizing your applica-
tions speed and memory usage, and makes it easier to build reliable and scalable
Java SE, JavaFX and Java EE applications. NetBeans IDE includes a visual debug-
ger for Java SE applications, letting you debug user interfaces without looking into
source code. Take GUI snapshots of your applications and click on user interface
elements to jump back into the related source code.
The key features that are appreciated by NetBeans users around the world

1. Maven

Department of Computer Science Engineering, NIT , Rourkela 7


Remote Monitoring System

Around the world, a key term that comes up repeatedly in the context of NetBeans
is Maven. The fact that no plugins need to be installed to use Maven and that Maven
projects do not need to be imported, but can simply be opened, is a key feature
appreciated by NetBeans users. Just go to File Open Project and NetBeans will
recognize any folder containing a POM file as a Maven project and then use the
POM file as the NetBeans project definition.

2.Out of the box

Following on from the above, a key feature of NetBeans is the short time dif-
ference between installing it and beginning to create meaningful applications in it.
Despite its significant plugin ecosystem, not much is needed to be installed or con-
figured, since everything is available out of the box as soon as you start it up.

3. Java Editor

The language-aware NetBeans editor detects errors while you type and assists
you with documentation popups and smart code completion all with the speed and
simplicity of your favourite lightweight text editor. Of course, the Java editor in Net-
Beans is much more than a text editor it indents lines, matches words and brackets,
and highlights source code syntactically and semantically.

4. Java EE

NetBeans tools for the Java EE platform are developed in close cooperation with
the Java EE, GlassFish, and WebLogic teams to provide the tightest integration and
easiest possible use of the Java EE specification. Consequently, if you are new to the
Java EE specification and framework, as well as if youre experienced in need to be
productive and focused on your domain logic, using NetBeans IDE is the best way
to quickly learn and become productive in Java EE programming.

5. HTML5, JavaScript, and CSS3

NetBeans is available in a scaled-down distribution that contains tools focused


on web-frontend development only, that is, only for HTML5 and PHP, without any

Department of Computer Science Engineering, NIT , Rourkela 8


Remote Monitoring System

Java tooling. The speed and simplicity of working with the web-frontend distri-
bution of NetBeans IDE lets you significantly accelerate HTML5 web application
development, from creating HTML5 projects, to developing them in editors for
HTML, JavaScript, and CSS, to integration with SASS, LESS, Karma, Grunt, and
the Chrome browser. The integration with Apache Cordova enables deployment of
native packages to iOS and Android, while HTML5 applications can be deployed to
the Chrome browser on iOS and Android, from where applications can be debugged
and profiled live on the device.

6. Internet of Things

Directly from NetBeans, you can create, test, debug, deploy, and profile applica-
tions that will run on the Raspberry Pi, mobile phones, PDAs, set-top boxes, and
other mobile and embedded systems.

7. Profiler

Built into NetBeans and available for free, the NetBeans Profiler provides expert
assistance for optimizing your applications speed and memory usage, while making
it easier to build reliable and scalable Java SE, JavaFX and Java EE applications.

8. Git and Mercurial

Without requiring you to install any plugins, NetBeans automatically lets you
work easily and intuitively with a wide range of popular versioning systems, specif-
ically Git, Mercurial, and Subversion.

9. Configurability

The NetBeans workspace can easily be modified. Customize the buttons in the
toolbar or drag and reposition tabs in the application frame to suit your individual
workflow. Undock tabs and drag them outside the application frame, even onto a
different monitor and change keyboard shortcuts to match your own preferences.

10. Community

Department of Computer Science Engineering, NIT , Rourkela 9


Remote Monitoring System

Join the network of users and developers, writers and designers, bloggers and
translators, who are shaping the future of NetBeans. A lot of documentation and
tutorials, as well as mailing lists and discussion forums, are available for free.

2.3

Java Programming Language

Java is a programming language and a platform. Java is a high level, robust,


secured and object-oriented programming language.

Platform: Any hardware or software environment in which a program runs, is


known as a platform. Since Java has its own runtime environment (JRE) and API, it
is called platform.

According to Sun, 3 billion devices run java. There are many devices where java
is currently used. Some of them are as follows:

1. Desktop Applications such as acrobat reader, media player, antivirus etc.

2. Web Applications such as irctc.co.in, javatpoint.com etc.

3. Enterprise Applications such as banking applications.

4. Mobile

5. Embedded System

6. Smart Card

7. Robotics

8. Games etc

Java, created by Sun Microsystems in the year 1995, was not initially meant for
internet. One of the significant features that made it extremely popular and useful
for internet was its platform independence. The language was suitable for creating
both small components and complex standalone applications. Some of the features
that make Java a powerful programming language are as follows:

Department of Computer Science Engineering, NIT , Rourkela 10


Remote Monitoring System

1. Simplicity- Java is simple in the way that it is just an adaptation of C and


C++ languages. It is attributed with better memory management and additional
features such as garbage collection.

2. Object-Oriented Programming- Object Oriented Programming methodology


simplifies program writing and thus allows the programmers to deal with com-
plex and large programs. This is one of the many features that make Java a
more powerful programming language than many others.

3. Reliability- In Java programming there is a series of checks to ensure that the


programs are completely reliable. Sensing probable problems and detecting
runtime errors ensure that all the programming issues are resolved beforehand.

4. Security- There are a number of features incorporated in Java to make it a se-


cure programming language. For example, when an applet is downloaded from
the internet, Java confines it to the Java execution environment rather than al-
lowing it to access system resources. This is really effective in preventing se-
curity breach.

5. Portability- The internet is a sea where multiple Operating Systems and com-
puters converge. This calls for programs that can run on all types of Operating
Systems. Java allows the creation of portable executable codes, one of the fore-
most requirements for an internet language.

Department of Computer Science Engineering, NIT , Rourkela 11


Remote Monitoring System

Chapter 3

System Design:Functionalities and libraries


used

3.1 Swing

Swing is a set of program components for Java programmers that provide the
ability to create graphical user interface ( GUI ) components, such as buttons and
scroll bars, that are independent of the windowing system for specific operating
system . Swing components are used with the Java Foundation Classes ( JFC ).

Swing Framework contains a large set of components which provide rich function-
alities and allow high level of customization. All these components are lightweight
components. They all are derived from JComponent class. It supports the pluggable
look and feel.

JButton

JButton class provides functionality of a button. JButton class has three constuc-
tors, It allows a button to be created using icon, a string or both. JButton supports
ActionEvent. When a button is pressed an ActionEvent is generated.

JTextField

JTextField is used for taking input of single line of text. It is most widely used
text component. It has three constructors.

JCheckBox

Department of Computer Science Engineering, NIT , Rourkela 12


Remote Monitoring System

JCheckBox class is used to create checkboxes in frame. Following is constructor


for JCheckBox.

Java JPanel

JPanel is a Swings lightweight container which is used to group a set of compo-


nents together. JPanel is a pretty simple component which, normally, does not have
a GUI (except when it is being set an opaque background or has a visual border).

Adding components to the panel:

To add GUI components such as JLabel, JTextField, JButton to the panel, we use
the add() method. There are different versions of the add() method, so which method
to be used is depending on the layout manager of the panel.

3.2 Socket Programming

Client/Server Communication At a basic level, network-based systems consist of a


server , client , and a media for communication. A computer running a program that
makes a request for services is called client machine. A computer running a program
that offers requested services from one or more clients is called server machine. The
media for communication can be wired or wireless network.

Generally, programs running on client machines make requests to a program (of-


ten called as server program) running on a server machine. They involve networking
services provided by the transport layer, which is part of the Internet software stack,
often called TCP/IP (Transport Control Protocol/Internet Protocol) stack. The trans-
port layer comprises two types of protocols, TCP (Transport Control Protocol) and
UDP (User Datagram Protocol).

The most widely used programming interfaces for these protocols are sockets.
TCP is a connection-oriented protocol that provides a reliable flow of data between
two computers. Example applications that use such services are HTTP, FTP, and
Telnet. UDP is a protocol that sends independent packets of data, called datagrams,
from one computer to another with no guarantees about arrival and sequencing. Ex-
ample applications that use such services include Clock server and Ping. The TCP

Department of Computer Science Engineering, NIT , Rourkela 13


Remote Monitoring System

and UDP protocols use ports to map incoming data to a particular process running
on a computer. Port is represented by a positive (16-bit) integer value. Some ports
have been reserved to support common/well known services:

ftp 21/tcp

telnet 23/tcp

smtp 25/tcp

login 513/tcp

http 80/tcp,udp

https 443/tcp,udp

User-level process/services generally use port number value 1024.

Object-oriented Java technologiesSockets, threads, RMI, clustering, Web service-


shave emerged as leading solutions for creating portable, efficient, and maintainable
large and complex Internet applications

Hosts Identification and Service Ports

Every computer on the Internet is identified by a unique, 4-byte IP address .


This is typically written in dotted quad format like 128.250.25.158 where each byte
is an unsigned value between 0 and 255. This representation is clearly not user-
friendly because it does not tell us anything about the content and then it is difficult
to remember. Hence, IP addresses are mapped to names like www.buyya.com or
www.google.com, which are easier to remember. Internet supports name servers
that translate these names to IP addresses. In general, each computer only has one
Internet address. However, computers often need to communicate and provide more
than one type of service or to talk to multiple hosts/computers at a time. For ex-
ample, there may be multiple ftp sessions, web connections, and chat programs all
running at the same time. To distinguish these services, a concept of port s, a logi-
cal access point, represented by a 16-bit integer number is used. That means, each
service offered by a computer is uniquely identified by a port number.

Department of Computer Science Engineering, NIT , Rourkela 14


Remote Monitoring System

Each Internet packet contains both the destination host address and the port num-
ber on that host to which the message/request has to be delivered. The host computer
dispatches the packets it receives to programs by looking at the port numbers spec-
ified within the packets. That is, IP address can be thought of as a house address
when a letter is sent via post/snail mail and port number as the name of a specific
individual to whom the letter has to be delivered.

Sockets and Socket-based Communication

Sockets provide an interface for programming networks at the transport layer.


Network communication using Sockets is very much similar to performing file I/O.
In fact, socket handle is treated like file handle. The streams used in file I/O operation
are also applicable to socket-based I/O. Socket-based communication is independent
of a programming language used for implementing it. That means, a socket program
written in Java language can communicate to a program written in non-Java (say C
or C++) socket program. A server (program) runs on a specific computer and has a
socket that is bound to a specific port. The server listens to the socket for a client to
make a connection request.

If everything goes well, the server accepts the connection. Upon acceptance, the
server gets a new socket bound to a different port. It needs a new socket (con-
sequently a different port number) so that it can continue to listen to the original
socket for connection requests while serving the connected client.

A socket is an endpoint of a two-way communication link between two programs


running on the network. Socket is bound to a port number so that the TCP layer
can identify the application that data is destined to be sent. Java provides a set of
classes, defined in a package called java.net, to enable the rapid development of
network applications. Key classes, interfaces, and exceptions in java.net package
simplifying the complexity involved in creating client and server programs are:

The Classes

ContentHandler

DatagramPacket

DatagramSocket

Department of Computer Science Engineering, NIT , Rourkela 15


Remote Monitoring System

DatagramSocketImpl

HttpURLConnection

InetAddress

MulticastSocket

ServerSocket

Socket

SocketImpl

URL

URLConnection

URLEncoder

URLStreamHandler

The Interfaces
ContentHandlerFactory

FileNameMap

SocketImplFactory

URLStreamHandlerFactory

Exceptions

BindException

ConnectException

MalformedURLException

NoRouteToHostException

ProtocolException

SocketException

UnknownHostException

UnknownServiceException

Department of Computer Science Engineering, NIT , Rourkela 16


Remote Monitoring System

3.3 TCP/IP SOCKET PROGRAMMING

The two key classes from the java.net package used in creation of server and client
programs are:

ServerSocket

Socket

A server program creates a specific type of socket that is used to listen for client
requests (server socket), In the case of a connection request, the program creates
a new socket through which it will exchange data with the client using input and
output streams. The socket abstraction is very similar to the file concept: developers
have to open a socket, perform I/O, and close it.

A simple Server Program in Java The steps for creating a simple server program
are:

Open the Server Socket: ServerSocket server = new ServerSocket( PORT );

Wait for the Client Request: Socket client = server.accept();

Create I/O streams for communicating to the client DataInputStream is = new


DataInputStream(client.getInputStream()); DataOutputStream os = new DataOut-
putStream(client.getOutputStream());

Perform communication with client Receive from client: String line = is.readLine();
Send to client: os.writeBytes(Hello);

Close socket: client.close();

3.4 UDP SOCKET PROGRAMMING

As already said, TCP guarantees the delivery of packets and preserves their order
on destination. Sometimes these features are not required and since they do not come
without performance costs, it would be better to use a lighter transport protocol. This
kind of service is accomplished by the UDP protocol which conveys datagram packet
s. Datagram packets are used to implement a connectionless packet delivery service
supported by the UDP protocol. Each message is transferred from source machine
to destination based on information contained within that packet. That means, each

Department of Computer Science Engineering, NIT , Rourkela 17


Remote Monitoring System

packet needs to have destination address and each packet might be routed differently,
and might arrive in any order. Packet delivery is not guaranteed.

Java supports datagram communication through the following classes:

DatagramPacket

DatagramSocket

The class DatagramPacket contains several constructors that can be used for cre-
ating packet object. One of them is: DatagramPacket(byte[] buf, int length, InetAd-
dress address, int port); This constructor is used for creating a datagram packet for
sending packets of length length to the specified port number on the specified host.
The message to be transmitted is indicated in the first argument.

The key methods of DatagramPacket class are:

byte[] getData() : Returns the data buffer.

int getLength() : Returns the length of the data to be sent or the length of the
data received.

void setData(byte[] buf) : Sets the data buffer for this packet.

void setLength(int length) : Sets the length for this packet.

The class DatagramSocket supports various methods that can be used for trans-
mitting or receiving data a datagram over the network. The two key methods are:
void send(DatagramPacket p) Sends a datagram packet from this socket. void re-
ceive(DatagramPacket p) Receives a datagram packet from this socket. A simple
UDP server program that waits for clients requests and then accepts the message
(datagram) and sends back the same message is given below. Of course, an extended
server program can manipulate clients messages/request and send a new message as
a response.

3.5 Multithreading

A program can be divided into a number of small processes. Each small process
can be addressed as a single thread (a lightweight process). Multithreaded programs
contain two or more threads that can run concurrently. This means that a single

Department of Computer Science Engineering, NIT , Rourkela 18


Remote Monitoring System

program can perform two or more tasks simultaneously. For example, one thread
is writing content on a file at the same time another thread is performing spelling
check.

In Java, the word thread means two different things.

An instance of Thread class.

or, A thread of execution.

An instance of Thread class is just an object, like any other object in java. But a
thread of execution means an individual lightweight process that has its own call
stack. In java each thread has its own call stack.

The main thread

Even if you dont create any thread in your program, a thread called main thread
is still created. Although the main thread is automatically created, you can control it
by obtaining a reference to it by calling currentThread() method.

Two important things to know about main thread are:

It is the thread from which other threads will be produced.

main thread must be always the last thread to finish execution.

Life cycle of a Thread

1. New : A thread begins its life cycle in the new state. It remains in this state
until the start() method is called on it.

2. Runable : After invocation of start() method on new thread, the thread becomes
runable.

3. Running : A method is in running thread if the thread scheduler has selected it.

4. Waiting : A thread is waiting for another thread to perform a task. In this stage
the thread is still alive.

5. Terminated : A thread enter the terminated state when it complete its task.

Department of Computer Science Engineering, NIT , Rourkela 19


Remote Monitoring System

3.6 Java ROBOT class

public class Robot


extends Object

This class is used to generate native system input events for the purposes of test
automation, self-running demos, and other applications where control of the mouse
and keyboard is needed. The primary purpose of Robot is to facilitate automated
testing of Java platform implementations.

Using the class to generate input events differs from posting events to the AWT
event queue or AWT components in that the events are generated in the platforms
native input queue. For example, Robot.mouseMove will actually move the mouse
cursor instead of just generating mouse move events.

Note that some platforms require special privileges or extensions to access low-
level input control. If the current platform configuration does not allow input con-
trol, an AWTException will be thrown when trying to construct Robot objects. For
example, X-Window systems will throw the exception if the XTEST 2.2 standard
extension is not supported (or not enabled) by the X server.

Applications that use Robot for purposes other than self-testing should handle
these error conditions gracefully.

Method Details:

mouseMove

Moves mouse pointer to given screen coordinates.

mousePress

Presses one or more mouse buttons. The mouse buttons should be released using
the mouseRelease method.

mouseRelease

Department of Computer Science Engineering, NIT , Rourkela 20


Remote Monitoring System

Releases one or more mouse buttons.

keyPress

Presses a given key. The key should be released using the keyRelease method.
Key codes that have more than one physical key associated with them (e.g. KeyEvent.VK SHIFT
could mean either the left or right shift key) will map to the left key.

keyRelease

Releases a given key.


Key codes that have more than one physical key associated with them (e.g. KeyEvent.VK SHIFT
could mean either the left or right shift key) will map to the left key

3.7 Java Properties File

.properties is a file extension for files mainly used in Java related technologies to
store the configurable parameters of an application. They can also be used for stor-
ing strings for Internationalization and localization; these are known as Property
Resource Bundles.

Each parameter is stored as a pair of strings, one storing the name of the parameter
(called the key/map), and the other storing the value.
Property files support two formats
1.Text file format In this format, different key, value pairs are separated by newline
character
2.XML format This is standard XML format.

Properties is a file extension for files mainly used in Java related technologies to
store the configurable parameters of an application. Java Properties files are amazing
resources to add information in Java. Generally, these files are used to store static
information in key and value pair. Things that you do not want to hard code in your
Java code goes into properties files. The advantage of using properties file is we
can configure things which are prone to change over a period of time without the
need of changing anything in code. Properties file provide flexibility in terms of
configuration.

Department of Computer Science Engineering, NIT , Rourkela 21


Remote Monitoring System

3.8 JNativeHook jar

JNativeHook is a library to provide global keyboard and mouse listeners for Java.
The library aims to provide a portable and reliable method for delivering keyboard
and mouse events to a Java application that would otherwise be inaccessible. This
will beneficial for any Java application that requires user input without having focus.
The library accomplishes this task by leveraging platform dependent native code to
create a low level hook and deliver native events back to the virtual machine through
Javas native interface.

3.9 java-screen-recorder-master zip

java-screen-recorder provides platform independent screen capture and playback,


producing high quality screen recordings using an internal lossless compression al-
gorithm. The recordings can be played back with the included screen player appli-
cation, or optionally converted to the QT movie format, using the included screen
converter application.

The output video can be post-processed to other formats, using a video conversion
tool such as ffmpeg.

The screen recorder, player and converter tools are all self contained jar files,
requiring only the Java Runtime Environment for execution. These tools operate
independently of any other external software codecs and libraries, to provide true
platform independent video capture.
java-screen-recorder is licensed under the MIT License.

Department of Computer Science Engineering, NIT , Rourkela 22


Remote Monitoring System

Chapter 4

Similar Softwares

1. TeamViewer

2. Join.me

3. Chrome Remote Desktop

4. WebEx Free

5. AMMYY Adminn

6. Mikogo

7. Ultra VNC

8. Splashtop

9. Windows Remote Desktop Connection

Department of Computer Science Engineering, NIT , Rourkela 23


Remote Monitoring System

Chapter 5

Screenshots of Project

5.1 Clients

Department of Computer Science Engineering, NIT , Rourkela 24


Remote Monitoring System

Department of Computer Science Engineering, NIT , Rourkela 25


Remote Monitoring System

5.2 Server

Department of Computer Science Engineering, NIT , Rourkela 26


Remote Monitoring System

Chapter 6

Conclusion and Future Scope

There is a lot of scope for further development and polishing of the software. This
software can only connect those computers that are connected to the same LAN
connection.That is a major drawback. Security is also a primary concern as it is
not encrypted.Functionality like file transfers, collaborations and mobile access are
not available. Chat option has not been deployed in the software. Audio and video
streaming are also met with a disappointing no.

Nevertheless,this software is a light-weight personalized version of remote moni-


toring and collaboration software that is easy to use and no hefty file is needed to be
installed. Also it runs at boot time so we dont need to manually start the software.
Also, the values like the port number and the IP address of the computers need not
be entered again and again, because once entered they are saved.Also, the software
is free yet provides the facilities of the conference version of high-end softwares like
TeamViewer that charge a hefty fees for the same facilities.

Department of Computer Science Engineering, NIT , Rourkela 27


Remote Monitoring System

References

[1] SOCKET PROGRAMMING; LIMI KALITA

[2] Java Networking; https://www.tutorialspoint.com/java/java_


networking.htm

[3] Java Socket Programming Examples; http://cs.lmu.edu/ray/notes/


javanetexamples/

[4] Java Socket Programming; https://www.javatpoint.com/


socket-programming

[5] How to take screenshot programmatically in


Java; http://www.javatechblog.com/java/
how-to-take-screenshot-programmatically-in-java/

[6] Multithreading; https://stackoverflow.com/questions/28669172/


how-to-send-multiple-images-from-client-to-server-through-java-sockets

[7] Java send screenshot over socket; https://stackoverflow.com/


questions/41251869/java-send-screenshot-over-socket

[8] Oracle.com; https://docs.oracle.com/javase/tutorial/uiswing/


events/mouselistener.html

[9] Java MouseListener Interface; https://www.javatpoint.com/


java-mouselistener

[10] Screen Recorder; https://github.com/yrom/ScreenRecorder/


blob/master/app/src/main/java/net/yrom/screenrecorder/
ScreenRecorder.java

Department of Computer Science Engineering, NIT , Rourkela 28

You might also like