Download as pdf or txt
Download as pdf or txt
You are on page 1of 87

H. J.

THIM TRUST'S
THEEM COLLEGE OF ENGINEERING
DEPARTMENT OF INFORMATION TECHNOLOGY ENGINEERING

INSTITUTE VISION & MISSION


Vision
To become a Centre of Excellence in Technical and Professional Education.

Mission
To commit ourselves for the high Standards of Technical and Professional Education
with student centered teaching learning process to nurture responsible technocrats
and professionals.

DEPARTMENT VISION & MISSION

Vision
To become a center of excellence in the Information technology discipline and to
create technically capable and intellectual IT professionals.

Mission
1. To nurture an effective teaching-learning process to provide in-depth knowledge of
principles and its applications pertaining to Information technology and
interdisciplinary areas leading to new technology.

2. To provide an environment for students and faculty for continuous learning to


explore, apply and transfer knowledge to meet global challenges.

3. To inculcate creative thinking through innovative group work exercises by


providing industry and department interactions during consultancy and sponsored
research which enhances the entrepreneur skills, employability and research
capabilities.

1 | MC Lab, Class: TE COMP, Theem COE


ENGINEERING PROGRAMME OUTCOMES (POS)

P001: Engineering knowledge: Apply the knowledge of mathematics, science, engineering


fundamentals, and an engineering specialization to the solution of complex engineering
problems.
PO02: Problem analysis: Identify, formulate, review research literature, and analyze
complex engineering problems reaching substantiated conclusions using first principles of
mathematics, natural sciences, and engineering sciences.
PO03: Design/development of solutions: Design solutions for complex engineering
problems and design system components or processes that meet the specified needs with
appropriate consideration for the public health and safety, and the cultural, societal, and
environmental considerations.
PO04: Conduct investigations of complex problems: Use research-based knowledge and
research methods including design of experiments, analysis and interpretation of data, and
synthesis of the information to provide valid conclusions.
PO05: Modern tool usage: Create, select, and apply appropriate techniques, resources, and
modern engineering and IT tools including prediction and modeling to complex engineering
activities with an understanding of the limitations.
PO06: The Engineer and society: Apply reasoning informed by the contextual knowledge
to assess societal, health, safety, legal and cultural issues and the consequent responsibilities
relevant to the professional engineering practice.
PO07: Environment and sustainability: Understand the impact of the professional
engineering solutions in societal and environmental contexts, and demonstrate the
knowledge of, and need for sustainable development.
PO08: Ethics: Apply ethical principles and commit to professional ethics and
responsibilities and norms of the engineering practice.
PO09: Individual and team work: Function effectively as an individual, and as a member
or leader in diverse teams, and in multidisciplinary settings.
PO10: Communication: Communicate effectively on complex engineering activities with
the engineering community and with society at large, such as, being able to comprehend and
write effective reports and design documentation, make effective presentations, and give
and receive clear instructions.
PO11: Project management and finance: Demonstrate knowledge and understanding of
the engineering and management principles and apply these to one's own work, as a member
and leader in a team, to manage projects and in multidisciplinary environments.
PO12: Life-long learning: Recognize the need for, and have the preparation and ability to
engage in independent and life-long learning in the broadest context of technological change

2 | MC Lab, Class: TE COMP, Theem COE


H. J. THIM TRUST’S
THEEM COLLEGE OF ENGINEERING
Chillar Road, Boisar(E). Dist: Palghar

CERTIFICATE

This is to certify that Mr /Miss_________________________________


_______ of COMP Class TE Roll No:___ Exam Seat No:_____________
has performed the experiment mentioned above in the premises of the
institution during the year 2022-2023 and has successfully completed all
the practical’s in the subject of Mobile Computing as prescribed by the
university of Mumbai.

Practical In-charge Head of Department

Date: Date:

External Examiner Principal

Date: Date:

3 | MC Lab, Class: TE COMP, Theem COE


INDEX
Sr. Page
Name of Experiment Date Remark
No No

Implement a Bluetooth network with


01 application as transfer of a file from
one device to another

To implement a basic function of Code


02
Division Multiple Access (CDMA)

Implement of GSM security algorithm


03
(A3/A5/A8)

Study of security tools (like, Kismet,


04
Netstumbler)

Develop an application that uses GUI


05
components.

Write an application that draws basic


06
graphical primitive on the screen.

Develop an application that makes use


07
of database.

Develop a native application that uses


08
GPS location information.

4 | MC Lab, Class: TE COMP, Theem COE


Implement an application that create an
09
alert upon receiving a message.

10 Implementation of calculator.

5 | MC Lab, Class: TE COMP, Theem COE


H.J. Thim Trust's
Theem College of Engineering,
BoisarChilhar Road, Boisar (E), Tal - Palghar

ACADEMIC YEAR: 2022-23 CLASS: TE COMP SEM: VI

NAME:

ROLL NO: BATCH:

SUBJECT: MC LAB

EXPERIMENT NO: 01

DATE OF PERFORMANCE: / /

DATE OF SUBMISSION: / /

PARAMETER C P A Total Sign. With Date


MARKS
OBTAINED

MAX.MARKS 4 4 2 10

6 | MC Lab, Class: TE COMP, Theem COE


Experiment No: 01
Title: Implement a Bluetooth network with application as transfer of a file from one device
to another.

Date of Performance: Date of Submission:

What is Bluetooth?

Bluetooth is a wireless radio technology that allows many different devices to connect to each other and
work together. It was originally invented as an affordable wireless alternative to wired keyboards,
headphones, speakers, and other peripherals. Now, many kinds of devices use Bluetooth, including cell
phones, stereos, health monitors, and safety trackers. Almost any wireless device you encounter might
use Bluetooth technology.

Bluetooth is named after Danish king Harold Bluetooth. The Bluetooth logo is a combination of the two
Norse runes for Harold Bluetooth's initials.

Transfer Bluetooth data

After you have successfully connected to a Bluetooth device, each one has a connected Bluetooth
Socket. You can now share information between devices. Using the Bluetooth Socket, the general
procedure to transfer data is as follows:

1. Get the Input Stream and Output Stream that handle transmissions through the socket using get
Input Stream() and get Output Stream(), respectively.
2. Read and write data to the streams using read(byte[]) and write(byte[]).

There are, of course, implementation details to consider. In particular, you should use a dedicated thread
for reading from the stream and writing to it. This is important because both
the read(byte[]) and write(byte[]) methods are blocking calls. The read(byte[]) method blocks until
there is something to read from the stream. The write(byte[]) method doesn't usually block, but it can
block for flow control if the remote device isn't calling read(byte[]) quickly enough and the intermediate
buffers become full as a result. So, you should dedicate your main loop in the thread to reading from
the Input Stream. You can use a separate public method in the thread to initiate writes to the Output
Stream.

After the constructor acquires the necessary streams, the thread waits for data to come through the Input
Stream. When read(byte[]) returns with data from the stream, the data is sent to the main activity using
a member Handler from the parent class. The thread then waits for more bytes to be read from the Input
Stream.
7 | MC Lab, Class: TE COMP, Theem COE
To send outgoing data, you call the thread's write () method from the main activity and pass in the bytes
to be sent. This method calls write (byte []) to send the data to the remote device. If an IO Exception is
thrown when calling write(byte[]), the thread sends a toast to the main activity, explaining to the user
that the device couldn't send the given bytes to the other (connected) device.

The thread's cancel () method allows you to terminate the connection at any time by closing
the Bluetooth Socket. Always call this method when you're done using the Bluetooth connection.

public class MyBluetoothService {

private static final String TAG = "MY_APP_DEBUG_TAG";

private Handler handler; // handler that gets info from Bluetooth service

// Defines several constants used when transmitting messages between the

// service and the UI.

private interface MessageConstants {

public static final int MESSAGE_READ = 0;

public static final int MESSAGE_WRITE = 1;

public static final int MESSAGE_TOAST = 2;

// ... (Add other message types here as needed.)

private class ConnectedThread extends Thread {

private final BluetoothSocket mmSocket;

private final InputStream mmInStream;

private final OutputStream mmOutStream;

private byte[] mmBuffer; // mmBuffer store for the stream

public ConnectedThread(BluetoothSocket socket) {

mmSocket = socket;

8 | MC Lab, Class: TE COMP, Theem COE


InputStream tmpIn = null;

OutputStream tmpOut = null;

// Get the input and output streams; using temp objects because

// member streams are final.

try {

tmpIn = socket.getInputStream();

} catch (IOException e) {

Log.e(TAG, "Error occurred when creating input stream", e);

try {

tmpOut = socket.getOutputStream();

} catch (IOException e) {

Log.e(TAG, "Error occurred when creating output stream", e);

mmInStream = tmpIn;

mmOutStream = tmpOut;

public void run() {

mmBuffer = new byte[1024];

int numBytes; // bytes returned from read()

// Keep listening to the InputStream until an exception occurs.

while (true) {

try {

// Read from the InputStream.

numBytes = mmInStream.read(mmBuffer);

// Send the obtained bytes to the UI activity.


9 | MC Lab, Class: TE COMP, Theem COE
Message readMsg = handler.obtainMessage(

MessageConstants.MESSAGE_READ, numBytes, -1,

mmBuffer);

readMsg.sendToTarget();

} catch (IOException e) {

Log.d(TAG, "Input stream was disconnected", e);

break;

// Call this from the main activity to send data to the remote device.

public void write(byte[] bytes) {

try {

mmOutStream.write(bytes);

// Share the sent message with the UI activity.

Message writtenMsg = handler.obtainMessage(

MessageConstants.MESSAGE_WRITE, -1, -1, mmBuffer);

writtenMsg.sendToTarget();

} catch (IOException e) {

Log.e(TAG, "Error occurred when sending data", e);

// Send a failure message back to the activity.

Message writeErrorMsg =

handler.obtainMessage(MessageConstants.MESSAGE_TOAST);

Bundle bundle = new Bundle();

bundle.putString("toast",

"Couldn't send data to the other device");

writeErrorMsg.setData(bundle);
10 | MC Lab, Class: TE COMP, Theem COE
handler.sendMessage(writeErrorMsg);

// Call this method from the main activity to shut down the connection.

public void cancel() {

try {

mmSocket.close();

} catch (IOException e) {

Log.e(TAG, "Could not close the connect socket", e);

Conclusion:

11 | MC Lab, Class: TE COMP, Theem COE


H.J. Thim Trust's
Theem College of Engineering,
BoisarChilhar Road, Boisar (E), Tal - Palghar

ACADEMIC YEAR: 2022-23 CLASS: TE COMP SEM: VI

NAME:

ROLL NO: BATCH:

SUBJECT: MC LAB

EXPERIMENT NO: 02

DATE OF PERFORMANCE: / /

DATE OF SUBMISSION: / /

PARAMETER C P A Total Sign. With Date


MARKS
OBTAINED

MAX.MARKS 4 4 2 10

12 | MC Lab, Class: TE COMP, Theem COE


Experiment No: 02
Title: To implement a basic function of Code Division Multiple Access (CDMA)
Date of Performance: Date of Submission:

INTRODUCTION:-
CDMA is a channelization protocol for Multiple Access, where information can be sent simultaneously
through several transmitters over a single communication channel.
It is achieved in below steps:
 A signal is generated which extends over a wide bandwidth.
 The code which performs this action is called spreading code.
 Later on, a specific signal can be selected with a given code even in the presence of many other
signals.
It is mainly used in mobile networks like 2G and 3G.
To see how CDMA works, we have to understand orthogonal sequences (also known as chips).
Let N be the number of stations establishing multiple access over a common channel.
1. An orthogonal sequence can be thought of as a 1xN matrix.
Eg: [+1 -1 +1 -1] for N = 4.
2. Scalar multiplication and matrix addition rules follow as usual.
Eg: 3.[+1 -1 +1 -1] = [+3 -3 +3 -3]
Eg: [+1 -1 +1 -1] + [-1 -1 -1 -1] = [0 -2 0 -2]
3. Inner Product: It is evaluated by multiplying two sequences element by element and then adding all
elements of the resulting list.
 Inner Product of a sequence with itself is equal to N
[+1 -1 +1 -1].[+1 -1 +1 -1] = 1 + 1 + 1 + 1 = 4
 Inner Product of two distinct sequences is zero
[+1 -1 +1 -1].[+1 +1 +1 +1] = 1-1+1-1 = 0

Procedure:
1. The station encodes its data bit as follows.
 +1 if bit = 1
 -1 if bit = 0
 no signal(interpreted as 0) if station is idle
2. Each station is assigned a unique orthogonal sequence (code) which is N bit long for N stations
3. Each station does a scalar multiplication of its encoded data bit and code sequence.
4. The resulting sequence is then placed on the channel.
5. Since the channel is common, amplitudes add up and hence resultant channel sequence is sum of
sequences from all channels.
6. If station 1 wants to listen to station 2, it multiplies (inner product) the channel sequence with code of
station S2.
7. The inner product is then divided by N to get data bit transmitted from station 2.
Example: Assume 4 stations S1, S2, S3, S4. We’ll use 4×4 Walsh Table to assign codes to them.
C1 = [+1 +1 +1 +1]
C2 = [+1 -1 +1 -1]
C3 = [+1 +1 -1 -1]
C4 = [+1 -1 -1 +1]

13 | MC Lab, Class: TE COMP, Theem COE


Let their data bits currently be:
D1 = -1
D2 = -1
D3 = 0 (Silent)
D4 = +1

Resultant channel sequence = C1.D1 + C2.D2 + C3.D3 + C4.D4


= [-1 -1 -1 -1] + [-1 +1 -1 +1] + [0 0 0 0]
+ [+1 -1 -1 +1]
= [-1 -1 -3 +1]

Now suppose station 1 wants to listen to station 2.


Inner Product = [-1 -1 -3 +1] x C2
= -1 + 1 - 3 - 1 = -4

Data bit that was sent = -4/4 = -1.

Program:-
// Java code illustrating a simple implementation of CDMA
import java.util.*;
public class CDMA {
private int[][] wtable;
private int[][] copy;
private int[] channel_sequence;
public void setUp(int[] data, int num_stations)
{ wtable = new int[num_stations][num_stations];
copy = new int[num_stations][num_stations];
buildWalshTable(num_stations, 0, num_stations - 1, 0,num_stations - 1, false);
showWalshTable(num_stations);
for (int i = 0; i < num_stations; i++) {
for (int j = 0; j < num_stations; j++) {
// Making a copy of walsh table
// to be used later
copy[i][j] = wtable[i][j];
// each row in table is code for one station.
// So we multiply each row with station data
wtable[i][j] *= data[i];
} }
channel_sequence = new int[num_stations];
for (int i = 0; i < num_stations; i++) {
for (int j = 0; j < num_stations; j++) {
// Adding all sequences to get channel sequence
channel_sequence[i] += wtable[j][i];
} } }
public void listenTo(int sourceStation, int num_stations)
{ int innerProduct = 0;
for (int i = 0; i < num_stations; i++) {
// multiply channel sequence and source station code
innerProduct += copy[sourceStation][i] * channel_sequence[i];
} System.out.println("The data received is: " +(innerProduct / num_stations));
} public int buildWalshTable(int len, int i1, int i2, int j1,int j2, boolean isBar)
{ // len = size of matrix. (i1, j1), (i2, j2) are
// starting and ending indices of wtable.isBar represents whether we want to add simple
entry or complement(southeast submatrix) to wtable.
14 | MC Lab, Class: TE COMP, Theem COE
if (len == 2) {
if (!isBar) {
wtable[i1][j1] = 1;
wtable[i1][j2] = 1;
wtable[i2][j1] = 1;
wtable[i2][j2] = -1;
} else {
wtable[i1][j1] = -1;
wtable[i1][j2] = -1;
wtable[i2][j1] = -1;
wtable[i2][j2] = +1;
} return 0; }
int midi = (i1 + i2) / 2;
int midj = (j1 + j2) / 2;
buildWalshTable(len / 2, i1, midi, j1, midj, isBar);
buildWalshTable(len / 2, i1, midi, midj + 1, j2, isBar);
buildWalshTable(len / 2, midi + 1, i2, j1, midj, isBar);
buildWalshTable(len / 2, midi + 1, i2, midj + 1, j2, !isBar);
return 0; }
public void showWalshTable(int num_stations) {
System.out.print("\n");
for (int i = 0; i < num_stations; i++) {
for (int j = 0; j < num_stations; j++) {
System.out.print(wtable[i][j] + " ");
}System.out.print("\n");
}System.out.println("-------------------------");
System.out.print("\n"); }
// Driver Code
public static void main(String[] args)
{ int num_stations = 4;
int[] data = new int[num_stations];
//data bits corresponding to each station
data[0] = -1;
data[1] = -1;
data[2] = 0;
data[3] = 1;
CDMA channel = new CDMA();
channel.setUp(data, num_stations);
// station you want to listen to
int sourceStation = 3;
channel.listenTo(sourceStation, num_stations);
}}

Output:
1 1 1 1
1 -1 1 -1
1 1 -1 -1
1 -1 -1 1

The data received is: 1


15 | MC Lab, Class: TE COMP, Theem COE
Conclusion:

16 | MC Lab, Class: TE COMP, Theem COE


H.J. Thim Trust's
Theem College of Engineering,
BoisarChilhar Road, Boisar (E), Tal - Palghar

ACADEMIC YEAR: 2022-23 CLASS: TE COMP SEM: VI

NAME:

ROLL NO: BATCH:

SUBJECT: MC LAB

EXPERIMENT NO: 03

DATE OF PERFORMANCE: / /

DATE OF SUBMISSION: / /

PARAMETER C P A Total Sign. With Date


MARKS
OBTAINED

MAX.MARKS 4 4 2 10

17 | MC Lab, Class: TE COMP, Theem COE


Experiment No: 03
Title: Implement of GSM security algorithm (A3/A5/A8).
Date of Performance: Date of Submission:
INTRODUCTION:-
The wireless-radio medium is open to all .Being a wireless network, GSM is also sensitive to
unauthorized use of resources. GSM offers precise security measures some of which maintains privacy and
confidentiality of users’ identity and data while others ensure that only registered users access the network.
This module provides detail discussion of GSM’s Security mechanisms and their implementation. The topics
covered in this module are: · Goals of Security features of GSM · Introduction to principles of security
namely access control, anonymity authentication and encryption · Understanding of Security algorithms and
mechanisms provided by GSM.
Goals of Security features
The security features should be provided two sided i.e. from the Operator Side as well as User Side
Operator Side: From operator’s point of view it should be ensured that operators ·
 Bill the right person ·
 There should be mechanisms to avoid fraud ·
 Services should be protected from
Subscriber side: The security measures need to be more promising and precise on subscribers side. They
should aim at ·
 Maintaining privacy and anonymity of user which means that identification and location of the
subscriber should be concealed ·
 Confidentiality of communication over air should be maintained by providing proper encryption
methods ·
 There should be strong access control mechanisms for devices and SIM card ·
 Only authenticated users should be able to access the network
Rules of GSM Security
The Security features should adhere to the following rules:
1. Should not add much load to voice calls or data communication
2. Should not increase the error rate
3. Should not increase the complexity of system
4. Should not demand for more bandwidth
5. Should be useful and cost efficient

18 | MC Lab, Class: TE COMP, Theem COE


Principles of GSM Security
GSM provides security under following mechanisms: & PU ·
 Access Control to SIM card: This is done by use of Personal Identification Number (PIN) to get
access to the SIM card
 Anonymity: Hiding the identity and location of user. This is done by using a TMSI number ·
 Authentication of subscriber so as to ensure only registered and authorized users have access to
network ·
 Encryption of Data and signal to protect them against interception
Now we see how security measures described in above outlines are implemented by GSM network
Access control SIM Subscriber identity module stores confidential information which can be personal as
well as network specific. It stores the following information: ·
 International Mobile Subscriber Identity (IMSI) number:A globally unique identifier allocated to
each GSM subscriber. It is permanently stored both in the HLR of the user and in the SIM of the user
terminal. Any GSM subscriber can be uniquely identified by its IMSI number. This International
Mobile Subscriber Identity (IMSI) number is composed of theMobile Country Code (MCC, three
digits), the Mobile Network Code (MNC, two digits) and the Mobile Subscriber Identification
Number (MSIN, ten digits). ·
 Subscriber Authentication key (Ki ): 128 bit shared key used for authentication of the subscriber by
the network ·
 A3 and A8 Security algorithms: Algorithms used for authentication and generation of cipher key.
Access Control Mechanisms ·
 PIN (Personal Identification Number): GSM provides provision of protection of SIM card by using a
PIN. The user needs to know the PIN to unlock the SIM card. The SIM card automatically “Lock
Out” after 3 unsuccessful attempts by feeding wrong PIN. ·
 PUK (Personal Unlocking Key): A PIN unblocking key should be entered which is provided by the
user to unlock the SIM which is locked after giving the wrong PIN. If the PUK entered incorrectly a
number of times, (normally 10) the access to inform is refused permanently and SIM becomes
useless.
Anonymity providing Mechanism
To prevent eavesdropping, the identity of the user should be hidden. The identity of user is hidden by use
of TSMI (Temporary Mobile Subscriber Identity) in place of IMSI of the user. When a MS makes initial
contact with the GSM network, an unencrypted subscriber identifier (IMSI) has to be transmitted. The
IMSI is sent only once, then a temporary mobile subscriber identity (TMSI) is assigned (encrypted) and
used in the entire range of the MSC. When the MS moves into the range of another MSC a new TMSI is
assigned. The IMSI is not sent over the radio interface so as to prevent the user from being traced. A TMSI
is used instead of IMSI. It is valid in the area of associated MSC i.e. will be valid only till the user is in
the area of MSC for communication .Outside location area, it is used along with LAI (Location Area
19 | MC Lab, Class: TE COMP, Theem COE
Identification). The TMSI identifies the user along with the location area. The TMSI is updated every time
user moves to a new geographical area. It can contain 4 * 8 bits (4 octets). But all 32 bits as one cannot be
allocated. TMSI is stored in SIM and all 1’s in SIM indicates no TMSI. The VLR must be capable of
correlating an allocated TMSI with IMSI of MS to which it is allocated. At the time of paging, to localize
the mobile phone the TMSI is broadcasted.

Authentication and Encryption


GSM ensures authentication of subscriber before it can use any services of the network. At the same time
privacy of user data and signal should also be maintained by proper encryption mechanisms. Three security
algorithms are documented in GSM specifications for this purpose. They are called A3, A5 and A8. A3 is
authentication algorithm, A8 is ciphering key generating algorithm and A5 is a stream cipher for
encryption of user data transmitted between mobile and base station. The GSM specifications for security
were designed by GSM consortium in secrecy. The consortium used “Security by obscurity” which says
algorithm would be difficult to crack if they are not publicly available. Therefore algorithms were made
available only to hardware and software manufactures and GSM network operators.A3 and A8 are stored
on SIM card and at AUC. A5 is stored on device. A3 and A8 are not that strong therefore the network
providers can use their own algorithms or users can use their own algorithms but the encryption
algorithmA5 is implemented on device and should be identical for all providers. A3 and A8 are symmetric
algorithms using the same key embedded on SIM card.
RAND (128 bit)

Ki (128 bit)
A3

SRES (32 bit)


Figure 1: A3 algorithm
RAND (128 bit)

Ki (128 bit)
A8

KC (64 bit)

Figure 2: A8 algorithm

20 | MC Lab, Class: TE COMP, Theem COE


Both are one way functions which means output can be found if inputs are known but it is impossible to
find inputs if output is known. A3 and A8 use COMP128 which is a keyed hash function.Both are one
way functions which means output can be found if inputs are known but it is impossible to find inputs if
output is known. A3 and A8 use COMP128 which is a keyed hash function.It takes 128 bit key and 128
bit RAND number as input and produces 128 bit output. The first 32 bits of 128 bit form SRES i.e. Signed
response and next 54 bits forms the cipher key which is used for authentication and encryption.

RAND (128
bit)

128 bit Ki COMP128

128 bit output


Figure 3: COMP 128 algorithm
Authentication mechanism
Authentication is performed using following entities and a technique called “Challenge Response”

 A3 Algorithm for Authentication


 128 bit key Kistored at SIM card and AUC
 RAND number auto generated by AUC known as Challenge
Following steps are followed for authentication

1. Mobile station sends IMSI to network


2. Network accepts IMSI and find corresponding Ki which is 128 bit secret key stored on the SIM
card as well as available with the authentication center
3. The AUC generates 128 bit random number RAND and sends to the mobile station. This is called
“challenge”
4. SIM card accepts this challenge and uses the random number and key Ki as input to A3 algorithm.
SIM has a microcontrollerto execute the algorithm A3. It produces 32 bit output called signature
response SRES using Ki and RAND as input
5. Network also calculates output using same inputs i.e. Ki,RAND and algorithm A3.
6. MS sends SRES to network
7. Network matches both SRES, if matched subscriber is authenticated.

The above mentioned steps are described in the activity diagram and block diagram shown in Fig. 4&5

21 | MC Lab, Class: TE COMP, Theem COE


Figure 4: Authentication via Challenge Response

Figure 5: Authentication mechanism

22 | MC Lab, Class: TE COMP, Theem COE


Encryption
The data and signals are encrypted only between mobile station and base station.

Encrypted data

There is no end-to-end encryption


Therefore mechanisms for encryption need to be performed both at base station and mobile station. The
algorithms A5 and A8 are used for encryption.Any encryption algorithm needs a cipher key. This cipher
key is not statically available. It is dynamically generated using A8 algorithm. It takes 128 bit key Ki
and 128 bit RAND to generate 54 bit cipher key. Then 10 zero bits are appended to the key to make it 64
bit. This is done to reduce the key space from 64 bits to 54 bits.
A5 algorithm
A5 is the encryption algorithm. It is a stream cipher. It works on bit-by-bit basis.A5 is stored on hardware
as it has to encrypt and decrypt data during transmission and reception of information, which must be fast
enough.A5 takes 64-bit cipher key and 22 bit function key as input and 114 bit plain text to generate 114-
bit cipher text (Fig.7). The encryption decryption processes are performed both at Base station and Mobile
station.

A5 is not implemented as block cipher


The reason being that bit error rate on the wireless links is high. If there is an error of single bit in the
cipher text it affects an entire clear text frame. In contrast to it, by using a Stream cipher, a single bit error
in the cipher text affects only one single clear text bit. Therefore stream cipher is used for encryption in
GSM.There are many implementation of algorithm. Most common one being A5/0 A5/1 A5/2 A5/3 A5/1
is the strongest one. A5/0 is literally no encryption.

23 | MC Lab, Class: TE COMP, Theem COE


Figure 7: A5 algorithm

Steps followed during encryption


 Network initiates a ciphering mode request command
 Mobile station receives this command
 Network sends RAND number generated to generate the cipher key
 Mobile station uses RAND, Ki and RAND the network also generates Kc and distributes
to BS
 As long as user is authenticated Kc remains same. If authentication is done again, another cipher
key would be generated. During handovers if the mobile station has moved to a different base
station but there is no need to authenticate it again, then the same key can be used by the new
base station. The key would be forwarded to the new base station
 Once the cipher key is generated, it can be used to encrypt the data and signal using A5 algorithm.

24 | MC Lab, Class: TE COMP, Theem COE


GSM security issues
 Securityis not implemented in fixed part
 Encryptionis only between base station and mobile
station Length of Kc (cipher key) is 64 bits which is not sufficient enough
 Authentication is from mobile station to network and vice versa is not possible
 No measures to maintain Integrityis provided
 Ciphering algorithms are not available for public

Conclusion:

25 | MC Lab, Class: TE COMP, Theem COE


H.J. Thim Trust's
Theem College of Engineering,
BoisarChilhar Road, Boisar (E), Tal - Palghar

ACADEMIC YEAR: 2022-23 CLASS: TE COMP SEM: VI

NAME:

ROLL NO: BATCH:

SUBJECT: MC LAB

EXPERIMENT NO: 04

DATE OF PERFORMANCE: / /

DATE OF SUBMISSION: / /

PARAMETER C P A Total Sign. With Date


MARKS
OBTAINED

MAX.MARKS 4 4 2 10

26 | MC Lab, Class: TE COMP, Theem COE


Experiment No: 04
Title: Study of security tools (like, Kismet, Netstumbler).
Date of Performance: Date of Submission:

INTRODUCTION
Wireless networks are more convenient than wired networks and allow you to move from room to
room in your home. Further, with a advancement in wireless hardware, higher throughput and lower latency
support has become possible. But they can also be more vulnerable if not properly secured. If our wireless
network is ’unsecured’ or ‘open’ then an intruder can easily gain access to our internal network resources as
well as to the Internet, all without our consent. Once the intruder has access to our network, he/she can use it
for a variety of operations, such as:
 To steal your Internet bandwidth.
 To perform disruptive or illegal acts.
 To steal your sensitive information.
 Kismet to sniff data management traffics packets from wireless LAN, analyze them to see the
vulnerability of the different detected access points and compare this result with captured
sources using NETSH
 Troubleshoot wireless connections by way of analyzing signal strength to noise ratio of captured
sources.

 Launch Kismet GUI (Kismet_ui.conf) application for real-time visualization and monitoring.

 Open TCP dumps with Wireshark software to examine and analyze management data packets
from captured sources in http files. This is to help me see the possibility of capturing sensitive
password or valuable information and a test of the vulnerability of the network.

 Figure out the meaning, uses and differences between the different file dumps, for example; the
.dump, .csv, .network, .weak and .cisco

 To perform Denial-of-Service (DoS) attacks to make the network unusable by sending out false
requests.
 To infect the network with malicious threats Thus, wireless networking is inherently risky
because we are transmitting information via radio waves.
Data from your wireless network can be intercepted just like signals from our cellular or cordless
phones. Whenever we use a wireless connection, we might want to ensure that our communications and files
are private and protected. If our transmissions are not secure, it may be possible for others to intercept our e-

27 | MC Lab, Class: TE COMP, Theem COE


mails, examine our files and records, and use our network and Internet connection to distribute their own
messages and communications. Hence we need security in wireless network.
Despite advancement in computer firewalls and intrusion detection systems, wired and wireless
networks are experiencing increasing threat to data theft and violations through personal and corporate
computers and networks. The ubiquitous WiFi technology which makes it possible for an intruder to scan for
data in the air, and the use of cryptanalysis versus brute force to lay bare encrypted messages has not made
computer and network security any much easier for network security administrators. In fact the security
problems and solutions of information systems are becoming more and more complicated as new exploit
security tools like Kismet, aironet, wireshark and Netsh (a NetStumbler alternative) are developed. This master
thesis intends to investigate by way of comparison two such versatile security tools which not only has the
propensity to compromise a network through data discovery, but could also serve as a network security
solution. Kismet and NetStumbler are two war-driving tools used very often to gain wireless access through
access points into wireless networks and invariably on to computers. It is a known fact that Kismet and
NetStumbler are two network security tools which work best on two different platforms, Kismet on Linux and
NetStumbler on Windows operating systems respectively. I am proposing to install, configure and launch
Kismet client and Kismet server on my desktop while at the same time using my WRT54GL access point as
a Kismet Drone. The reason for the drone is because my HP laptop dv6653eo Network Interface Card comes
with a Broadcom chipset (BCM4321/ BCM4328 ) which does not support RFMON (Radio Frequency Monitor
Mode) a veritable ingredient for wireless packet sniffing. On the other hand I am comparing the easy
deployment and detection of access point configuration capability of a NetStumbler alternative called NETSH
with Kismet ability to detect, uncloak hidden SSID‟s of access points and capture data packets wirelessly
from management traffics of various access points. Rogue access points by unauthorized users can be a
nightmare; access to wired networks can be secured by securing the cable connection of the switch or hub, but
in wireless networks, wireless data propagated freely through airwaves can be intercepted by any intruder
wishing to compromise a computer network system. It therefore implies that an intruder having sufficient
signal level could either, listen or view management data traffics between users and the wireless network
access points or connect to the access points in cases of poor security defence mechanism not being in place
and actually gaining access into the network. So, it becomes imperative to secure our wireless access points
and infrastructures. This in essence brings to mind access authorization process or authentication, data
encryption and confidentiality. But this is not the goal of the thesis work, neither am I going to look at some
of the features and possible functionalities of Kismet. For example, Kismet can be setup as an Intrusion
Detection System (IDS), It can support Global Positioning System (GPS) for mobile tracking of physical
networks and access points locations, and can even be configured to give a text-tospeech alert during war-
driving sessions. All these would not be delve into in this work. Kismet application is an open source wireless
network analyzer running on Linux, UNIX and Mac OS X, It is not supported by windows OS. Kismet is a
passive sniffer used to detect any wireless 802.11a/b/g protocol complaint networks, even when the network
has a non broadcasting hidden SSID (Secure Service set Identifier). Kismet can discover, log the IP range of
28 | MC Lab, Class: TE COMP, Theem COE
any detected wireless network and report its signal and noise levels. It can sniff all management data packets
from detected networks. Kismet can be used to locate, troubleshoot and optimize signal strength for access
points and clients, as well as detect network intrusions. NetStumbler on the other hand is an active sniffer and
it is not exactly an open source wireless network application. It runs on Windows, especially on Windows XP
and earlier versions. NetStumbler can be used to discover, configure, secure and optimize a network.

KISMET
Kismet is a network detector, packet sniffer, and intrusion detection system for 802.11 wireless LANs. Kismet
will work with any wireless card which supports raw monitoring mode, and can sniff 802.11a, 802.11b,
802.11g, and 802.11n traffic.
The program runs under Linux, FreeBSD, NetBSD, OpenBSD, and Mac OS X. The client can also run on
Microsoft Windows, although, aside from external drones , there’s only one supported wireless hardware
available as packet source. Distributed under the GNU General Public License, Kismet is free software.
A. Working of kismet
Kismet differs from other wireless network detectors in working passively. Namely, without sending any
loggable packets, it is able to detect the presence of both wireless access points and wireless clients, and to
associate them with each other. It is also the most widely used and up to date open source wireless monitoring
tool.Refer fig. 1 to view at explanation of the headings displayed in Kismet.
1. Kismet also includes basic wireless IDS features such as detecting active wireless sniffing programs
including NetStumbler, as well as a number of wireless network attacks.
2. Kismet also features the ability to detect default or ”not configured” networks, probe requests, and
determine what level of wireless encryption is used on a given access point.

Conclusion:

29 | MC Lab, Class: TE COMP, Theem COE


H.J. Thim Trust's
Theem College of Engineering,
BoisarChilhar Road, Boisar (E), Tal - Palghar

ACADEMIC YEAR: 2022-23 CLASS: TE COMP SEM: VI

NAME:

ROLL NO: BATCH:

SUBJECT: MC LAB

EXPERIMENT NO: 05

DATE OF PERFORMANCE: / /

DATE OF SUBMISSION: / /

PARAMETER C P A Total Sign. With Date


MARKS
OBTAINED

MAX.MARKS 4 4 2 10

30 | MC Lab, Class: TE COMP, Theem COE


Experiment No: 05
Title: Develop an application that uses GUI components.
Date of Performance: Date of Submission:

Creating a New project:


 Open Android Stdio and then click on File -> New -> New project.

 Then type the Application name as “ex.no.1″ and click Next.

 Then select the Minimum SDK as shown below and click Next.

31 | MC Lab, Class: TE COMP, Theem COE


 Then select the Empty Activity and click Next.

 Finally click Finish.

32 | MC Lab, Class: TE COMP, Theem COE


 It will take some time to build and load the project.
 After completion it will look as given below.

Designing layout for the Android Application:


 Click on app -> res -> layout -> activity_main.xml.

 Now click on Text as shown below.


33 | MC Lab, Class: TE COMP, Theem COE
 Then delete the code which is there and type the code as given below.
Code for Activity_main.xml:
?
1
<?xml version="1.0" encoding="utf-8"?>
2 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3 android:orientation="vertical"
4 android:layout_width="match_parent"
5 android:layout_height="match_parent">
6
7 <TextView
android:id="@+id/textView"
8 android:layout_width="match_parent"
9 android:layout_height="wrap_content"
10 android:layout_margin="30dp"
11 android:gravity="center"
android:text="Hello World!"
12
android:textSize="25sp"
13 android:textStyle="bold" />
14
15 <Button
16 android:id="@+id/button1"
17 android:layout_width="match_parent"
android:layout_height="wrap_content"
18 android:layout_margin="20dp"
19 android:gravity="center"
20 android:text="Change font size"
21 android:textSize="25sp" />
22 <Button
android:id="@+id/button2"
23 android:layout_width="match_parent"
24 android:layout_height="wrap_content"
25 android:layout_margin="20dp"
26 android:gravity="center"
android:text="Change color"
27 android:textSize="25sp" />
28 </LinearLayout>

 Now click on Design and your application will look as given below.

34 | MC Lab, Class: TE COMP, Theem COE


 So now the designing part is completed.
Java Coding for the Android Application:
 Click on app -> java -> com.example.exno1 -> MainActivity.

 Then delete the code which is there and type the code as given below.
Code for MainActivity.java:
?
package com.example.exno1;
1
2
import android.graphics.Color;
3 import android.support.v7.app.AppCompatActivity;
4 import android.os.Bundle;
5 import android.view.View;
6 import android.widget.Button;
import android.widget.TextView;
7
8 public class MainActivity extends AppCompatActivity
9 {
10 int ch=1;
11 float font=30;
12 @Override
protected void onCreate(Bundle savedInstanceState)
13 {
14 super.onCreate(savedInstanceState);
15 setContentView(R.layout.activity_main);
16 final TextView t= (TextView) findViewById(R.id.textView);
Button b1= (Button) findViewById(R.id.button1);
17 b1.setOnClickListener(new View.OnClickListener() {
18 @Override
35 | MC Lab, Class: TE COMP, Theem COE
19 public void onClick(View v) {
20 t.setTextSize(font);
font = font + 5;
21 if (font == 50)
22 font = 30;
23 }
24 });
Button b2= (Button) findViewById(R.id.button2);
25 b2.setOnClickListener(new View.OnClickListener() {
26 @Override
27 public void onClick(View v) {
28 switch (ch) {
29 case 1:
t.setTextColor(Color.RED);
30 break;
31 case 2:
32 t.setTextColor(Color.GREEN);
33 break;
case 3:
34 t.setTextColor(Color.BLUE);
35 break;
36 case 4:
37 t.setTextColor(Color.CYAN);
38 break;
case 5:
39 t.setTextColor(Color.YELLOW);
40 break;
41 case 6:
42 t.setTextColor(Color.MAGENTA);
43 break;
}
44 ch++;
45 if (ch == 7)
46 ch = 1;
47 }
});
48 }
49 }
50

Output:

36 | MC Lab, Class: TE COMP, Theem COE


Conclusion:

37 | MC Lab, Class: TE COMP, Theem COE


H.J. Thim Trust's
Theem College of Engineering,
BoisarChilhar Road, Boisar (E), Tal - Palghar

ACADEMIC YEAR: 2022-23 CLASS: TE COMP SEM: VI

NAME:

ROLL NO: BATCH:

SUBJECT: MC LAB

EXPERIMENT NO: 06

DATE OF PERFORMANCE: / /

DATE OF SUBMISSION: / /

PARAMETER C P A Total Sign. With Date


MARKS
OBTAINED

MAX.MARKS 4 4 2 10

38 | MC Lab, Class: TE COMP, Theem COE


Experiment No: 06

Title: Write an application that draws basic graphical primitive on the screen.
Date of Performance: Date of Submission:

Creating a New project:


 Open Android Studio and then click on File -> New -> New project.

 Then type the Application name as “ex.no.4″ and click Next.

 Then select the Minimum SDK as shown below and click Next.

39 | MC Lab, Class: TE COMP, Theem COE


 Then select the Empty Activity and click Next.

 Finally click Finish.

40 | MC Lab, Class: TE COMP, Theem COE


 It will take some time to build and load the project.
 After completion it will look as given below.

Designing layout for the Android Application:


 Click on app -> res -> layout -> activity_main.xml.

 Now click on Text as shown below.


41 | MC Lab, Class: TE COMP, Theem COE
 Then delete the code which is there and type the code as given below.
Code for Activity_main.xml:

<?xml version="1.0" encoding="utf-8"?>


<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">

<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/imageView" />
</RelativeLayout>

 Now click on Design and your application will look as given below.

 So now the designing part is completed.


Java Coding for the Android Application:
 Click on app -> java -> com.example.exno4 -> MainActivity.

42 | MC Lab, Class: TE COMP, Theem COE


 Then delete the code which is there and type the code as given below.
Code for MainActivity.java:

package com.example.exno4;

import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.drawable.BitmapDrawable;
import android.os.Bundle;
import android.widget.ImageView;

public class MainActivity extends Activity


{
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

//Creating a Bitmap
Bitmap bg = Bitmap.createBitmap(720, 1280, Bitmap.Config.ARGB_8888);

//Setting the Bitmap as background for the ImageView


ImageView i = (ImageView) findViewById(R.id.imageView);
i.setBackgroundDrawable(new BitmapDrawable(bg));

//Creating the Canvas Object


Canvas canvas = new Canvas(bg);

43 | MC Lab, Class: TE COMP, Theem COE


//Creating the Paint Object and set its color & TextSize
Paint paint = new Paint();
paint.setColor(Color.BLUE);
paint.setTextSize(50);

//To draw a Rectangle


canvas.drawText("Rectangle", 420, 150, paint);
canvas.drawRect(400, 200, 650, 700, paint);

//To draw a Circle


canvas.drawText("Circle", 120, 150, paint);
canvas.drawCircle(200, 350, 150, paint);

//To draw a Square


canvas.drawText("Square", 120, 800, paint);
canvas.drawRect(50, 850, 350, 1150, paint);

//To draw a Line


canvas.drawText("Line", 480, 800, paint);
canvas.drawLine(520, 850, 520, 1150, paint);
}
}

 So now the Coding part is also completed.


 Now run the application to see the output.
Output:

44 | MC Lab, Class: TE COMP, Theem COE


Conclusion:

45 | MC Lab, Class: TE COMP, Theem COE


H.J. Thim Trust's
Theem College of Engineering,
BoisarChilhar Road, Boisar (E), Tal - Palghar

ACADEMIC YEAR: 2022-23 CLASS: TE COMP SEM: VI

NAME:

ROLL NO: BATCH:

SUBJECT:MC LAB

EXPERIMENT NO: 07

DATE OF PERFORMANCE: / /

DATE OF SUBMISSION: / /

PARAMETER C P A Total Sign. With Date


MARKS
OBTAINED

MAX.MARKS 4 4 2 10

46 | MC Lab, Class: TE COMP, Theem COE


Experiment No: 07
Title: Develop an application that makes use of database
Date of Performance: Date of Submission:

Creating a New project:


 Open Android Studio and then click on File -> New -> New project.

 Then type the Application name as “ex.no.5″ and click Next.

 Then select the Minimum SDK as shown below and click Next.

47 | MC Lab, Class: TE COMP, Theem COE


 Then select the Empty Activity and click Next.

 Finally click Finish.

48 | MC Lab, Class: TE COMP, Theem COE


 It will take some time to build and load the project.
 After completion it will look as given below.

Designing layout for the Android Application:


 Click on app -> res -> layout -> activity_main.xml.

 Now click on Text as shown below.


49 | MC Lab, Class: TE COMP, Theem COE
 Then delete the code which is there and type the code as given below.
Code for Activity_main.xml:

<?xml version="1.0" encoding="utf-8"?>


<AbsoluteLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="50dp"
android:layout_y="20dp"
android:text="Student Details"
android:textSize="30sp" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="20dp"
android:layout_y="110dp"
android:text="Enter Rollno:"
android:textSize="20sp" />

<EditText
android:id="@+id/Rollno"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:layout_x="175dp"
android:layout_y="100dp"
android:inputType="number"
android:textSize="20sp" />

50 | MC Lab, Class: TE COMP, Theem COE


<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="20dp"
android:layout_y="160dp"
android:text="Enter Name:"
android:textSize="20sp" />

<EditText
android:id="@+id/Name"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:layout_x="175dp"
android:layout_y="150dp"
android:inputType="text"
android:textSize="20sp" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="20dp"
android:layout_y="210dp"
android:text="Enter Marks:"
android:textSize="20sp" />

<EditText
android:id="@+id/Marks"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:layout_x="175dp"
android:layout_y="200dp"
android:inputType="number"
android:textSize="20sp" />

<Button
android:id="@+id/Insert"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:layout_x="25dp"
android:layout_y="300dp"
android:text="Insert"
android:textSize="30dp" />
51 | MC Lab, Class: TE COMP, Theem COE
<Button
android:id="@+id/Delete"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:layout_x="200dp"
android:layout_y="300dp"
android:text="Delete"
android:textSize="30dp" />

<Button
android:id="@+id/Update"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:layout_x="25dp"
android:layout_y="400dp"
android:text="Update"
android:textSize="30dp" />

<Button
android:id="@+id/View"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:layout_x="200dp"
android:layout_y="400dp"
android:text="View"
android:textSize="30dp" />

<Button
android:id="@+id/ViewAll"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:layout_x="100dp"
android:layout_y="500dp"
android:text="View All"
android:textSize="30dp" />

</AbsoluteLayout>

 Now click on Design and your application will look as given below.

52 | MC Lab, Class: TE COMP, Theem COE


 So now the designing part is completed.
Java Coding for the Android Application:
 Click on app -> java -> com.example.exno5 -> MainActivity.

 Then delete the code which is there and type the code as given below.
Code for MainActivity.java:

package com.example.exno5;

import android.app.Activity;
import android.app.AlertDialog.Builder;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;

public class MainActivity extends Activity implements OnClickListener

53 | MC Lab, Class: TE COMP, Theem COE


{
EditText Rollno,Name,Marks;
Button Insert,Delete,Update,View,ViewAll;
SQLiteDatabase db;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

Rollno=(EditText)findViewById(R.id.Rollno);
Name=(EditText)findViewById(R.id.Name);
Marks=(EditText)findViewById(R.id.Marks);
Insert=(Button)findViewById(R.id.Insert);
Delete=(Button)findViewById(R.id.Delete);
Update=(Button)findViewById(R.id.Update);
View=(Button)findViewById(R.id.View);
ViewAll=(Button)findViewById(R.id.ViewAll);

Insert.setOnClickListener(this);
Delete.setOnClickListener(this);
Update.setOnClickListener(this);
View.setOnClickListener(this);
ViewAll.setOnClickListener(this);

// Creating database and table


db=openOrCreateDatabase("StudentDB", Context.MODE_PRIVATE, null);
db.execSQL("CREATE TABLE IF NOT EXISTS student(rollno VARCHAR,name
VARCHAR,marks VARCHAR);");
}
public void onClick(View view)
{
// Inserting a record to the Student table
if(view==Insert)
{
// Checking for empty fields
if(Rollno.getText().toString().trim().length()==0||
Name.getText().toString().trim().length()==0||
Marks.getText().toString().trim().length()==0)
{
showMessage("Error", "Please enter all values");
54 | MC Lab, Class: TE COMP, Theem COE
return;
}
db.execSQL("INSERT INTO student
VALUES('"+Rollno.getText()+"','"+Name.getText()+
"','"+Marks.getText()+"');");
showMessage("Success", "Record added");
clearText();
}
// Deleting a record from the Student table
if(view==Delete)
{
// Checking for empty roll number
if(Rollno.getText().toString().trim().length()==0)
{
showMessage("Error", "Please enter Rollno");
return;
}
Cursor c=db.rawQuery("SELECT * FROM student WHERE
rollno='"+Rollno.getText()+"'", null);
if(c.moveToFirst())
{
db.execSQL("DELETE FROM student WHERE
rollno='"+Rollno.getText()+"'");
showMessage("Success", "Record Deleted");
}
else
{
showMessage("Error", "Invalid Rollno");
}
clearText();
}
// Updating a record in the Student table
if(view==Update)
{
// Checking for empty roll number
if(Rollno.getText().toString().trim().length()==0)
{
showMessage("Error", "Please enter Rollno");
return;
}
Cursor c=db.rawQuery("SELECT * FROM student WHERE
rollno='"+Rollno.getText()+"'", null);
55 | MC Lab, Class: TE COMP, Theem COE
if(c.moveToFirst()) {
db.execSQL("UPDATE student SET name='" + Name.getText() +
"',marks='" + Marks.getText() +
"' WHERE rollno='"+Rollno.getText()+"'");
showMessage("Success", "Record Modified");
}
else {
showMessage("Error", "Invalid Rollno");
}
clearText();
}
// Display a record from the Student table
if(view==View)
{
// Checking for empty roll number
if(Rollno.getText().toString().trim().length()==0)
{
showMessage("Error", "Please enter Rollno");
return;
}
Cursor c=db.rawQuery("SELECT * FROM student WHERE
rollno='"+Rollno.getText()+"'", null);
if(c.moveToFirst())
{
Name.setText(c.getString(1));
Marks.setText(c.getString(2));
}
else
{
showMessage("Error", "Invalid Rollno");
clearText();
}
}
// Displaying all the records
if(view==ViewAll)
{
Cursor c=db.rawQuery("SELECT * FROM student", null);
if(c.getCount()==0)
{
showMessage("Error", "No records found");
return;
}
56 | MC Lab, Class: TE COMP, Theem COE
StringBuffer buffer=new StringBuffer();
while(c.moveToNext())
{
buffer.append("Rollno: "+c.getString(0)+"\n");
buffer.append("Name: "+c.getString(1)+"\n");
buffer.append("Marks: "+c.getString(2)+"\n\n");
}
showMessage("Student Details", buffer.toString());
}
}
public void showMessage(String title,String message)
{
Builder builder=new Builder(this);
builder.setCancelable(true);
builder.setTitle(title);
builder.setMessage(message);
builder.show();
}
public void clearText()
{
Rollno.setText("");
Name.setText("");
Marks.setText("");
Rollno.requestFocus();
}
}

 So now the Coding part is also completed.


 Now run the application to see the output.
Output:

57 | MC Lab, Class: TE COMP, Theem COE


Conclusion:

58 | MC Lab, Class: TE COMP, Theem COE


59 | MC Lab, Class: TE COMP, Theem COE
H.J. Thim Trust's
Theem College of Engineering,
BoisarChilhar Road, Boisar (E), Tal - Palghar

ACADEMIC YEAR: 2022-23 CLASS: TE COMP SEM: VI

NAME:

ROLL NO: BATCH:

SUBJECT:MC LAB

EXPERIMENT NO: 08

DATE OF PERFORMANCE: / /

DATE OF SUBMISSION: / /

PARAMETER C P A Total Sign. With Date


MARKS
OBTAINED

MAX.MARKS 4 4 2 10

60 | MC Lab, Class: TE COMP, Theem COE


Experiment No: 08
Title: Develop a native application that uses GPS location information.
Date of Performance: Date of Submission:

Creating a New project:


 Open Android Studio and then click on File -> New -> New project.

 Then type the Application name as “ex.no.5″ and click Next.

 Then select the Minimum SDK as shown below and click Next.

61 | MC Lab, Class: TE COMP, Theem COE


 Then select the Empty Activity and click Next.

 Finally click Finish.

62 | MC Lab, Class: TE COMP, Theem COE


 It will take some time to build and load the project.
 After completion it will look as given below.

Designing layout for the Android Application:


 Click on app -> res -> layout -> activity_main.xml.

 Now click on Text as shown below.


63 | MC Lab, Class: TE COMP, Theem COE
 Then delete the code which is there and type the code as given below.
Code for Activity_main.xml:
01
<?xml version="1.0" encoding="utf-8"?>
02
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
03
android:orientation="vertical"
04
android:layout_width="fill_parent"
05 android:layout_height="fill_parent"

06 >

07 <Button

08 android:id="@+id/retrieve_location_button"

android:text="Retrieve Location"
09
android:layout_width="wrap_content"
10
android:layout_height="wrap_content"
11
/>
12
</LinearLayout
13

64 | MC Lab, Class: TE COMP, Theem COE


 Now click on Design and your application will look as given below.

 So now the designing part is completed.


Java Coding for the Android Application:
 Click on app -> java -> com.example.exno5 -> MainActivity.

 Then delete the code which is there and type the code as given below.
Code for MainActivity.java:

 package com.javacodegeeks.android.lbs;

 import android.app.Activity;
 import android.content.Context;
 import android.location.Location;
 import android.location.LocationListener;
 import android.location.LocationManager;
 import android.os.Bundle;
 import android.view.View;
 import android.view.View.OnClickListener;
 import android.widget.Button;
 import android.widget.Toast;

 public class LbsGeocodingActivity extends Activity {

 private static final long MINIMUM_DISTANCE_CHANGE_FOR_UPDATES = 1; // in
Meters
 private static final long MINIMUM_TIME_BETWEEN_UPDATES = 1000; // in
Milliseconds

65 | MC Lab, Class: TE COMP, Theem COE



 protected LocationManager locationManager;

 protected Button retrieveLocationButton;

 @Override
 public void onCreate(Bundle savedInstanceState) {

 super.onCreate(savedInstanceState);
 setContentView(R.layout.main);

 retrieveLocationButton = (Button)
findViewById(R.id.retrieve_location_button);

 locationManager = (LocationManager)
getSystemService(Context.LOCATION_SERVICE);

 locationManager.requestLocationUpdates(
 LocationManager.GPS_PROVIDER,
 MINIMUM_TIME_BETWEEN_UPDATES,
 MINIMUM_DISTANCE_CHANGE_FOR_UPDATES,
 new MyLocationListener()
 );

 retrieveLocationButton.setOnClickListener(new OnClickListener() {
 @Override
 public void onClick(View v) {
 showCurrentLocation();
 }
 });

 }

 protected void showCurrentLocation() {

 Location location =
locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);

 if (location != null) {
 String message = String.format(
 "Current Location \n Longitude: %1$s \n Latitude: %2$s",
 location.getLongitude(), location.getLatitude()
 );
 Toast.makeText(LbsGeocodingActivity.this, message,
 Toast.LENGTH_LONG).show();
 }

 }

 private class MyLocationListener implements LocationListener {

 public void onLocationChanged(Location location) {
 String message = String.format(
 "New Location \n Longitude: %1$s \n Latitude: %2$s",
 location.getLongitude(), location.getLatitude()
 );
 Toast.makeText(LbsGeocodingActivity.this, message,
Toast.LENGTH_LONG).show();
 }

 public void onStatusChanged(String s, int i, Bundle b) {
 Toast.makeText(LbsGeocodingActivity.this, "Provider status changed",
66 | MC Lab, Class: TE COMP, Theem COE
 Toast.LENGTH_LONG).show();
 }

 public void onProviderDisabled(String s) {
 Toast.makeText(LbsGeocodingActivity.this,
 "Provider disabled by the user. GPS turned off",
 Toast.LENGTH_LONG).show();
 }

 public void onProviderEnabled(String s) {
 Toast.makeText(LbsGeocodingActivity.this,
 "Provider enabled by the user. GPS turned on",
 Toast.LENGTH_LONG).show();
 }

 }

 }
 So now the Coding part is also completed.
 Now run the application to see the output.
Output:

67 | MC Lab, Class: TE COMP, Theem COE


Conclusion:

68 | MC Lab, Class: TE COMP, Theem COE


H.J. Thim Trust's
Theem College of Engineering,
BoisarChilhar Road, Boisar (E), Tal - Palghar

ACADEMIC YEAR: 2022-23 CLASS: TE COMP SEM: VI

NAME:

ROLL NO: BATCH:

SUBJECT:MC LAB

EXPERIMENT NO: 09

DATE OF PERFORMANCE: / /

DATE OF SUBMISSION: / /

PARAMETER C P A Total Sign. With Date


MARKS
OBTAINED

MAX.MARKS 4 4 2 10

69 | MC Lab, Class: TE COMP, Theem COE


Experiment No: 09
Title: Implement an application that create an alert upon receiving a message.
Date of Performance: Date of Submission:

Creating a New project:


 Open Android Studio and then click on File -> New -> New project.

 Then type the Application name as “ex.no.10″ and click Next.

 Then select the Minimum SDK as shown below and click Next.

70 | MC Lab, Class: TE COMP, Theem COE


 Then select the Empty Activity and click Next.

 Finally click Finish.

71 | MC Lab, Class: TE COMP, Theem COE


 It will take some time to build and load the project.
 After completion it will look as given below.

Creating Second Activity for the Android Application:


 Click on File -> New -> Activity -> Empty Activity.

 Type the Activity Name as SecondActivity and click Finish button.


72 | MC Lab, Class: TE COMP, Theem COE
 Thus Second Activity For the application is created.
Designing layout for the Android Application:
 Click on app -> res -> layout -> activity_main.xml.

 Now click on Text as shown below.

 Then delete the code which is there and type the code as given below.
Code for Activity_main.xml:

73 | MC Lab, Class: TE COMP, Theem COE


<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="10dp"
android:orientation="vertical">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Message"
android:textSize="30sp" />

<EditText
android:id="@+id/editText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:textSize="30sp" />

<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="30dp"
android:layout_gravity="center"
android:text="Notify"
android:textSize="30sp"/>

</LinearLayout>

 Now click on Design and your application will look as given below.

74 | MC Lab, Class: TE COMP, Theem COE


 So now the designing part is completed.
Java Coding for the Android Application:
 Click on app -> java -> com.example.exno10 -> MainActivity.

 Then delete the code which is there and type the code as given below.
Code for MainActivity.java:

package com.example.exno10;

import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

public class MainActivity extends AppCompatActivity


{

75 | MC Lab, Class: TE COMP, Theem COE


Button notify;
EditText e;
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

notify= (Button) findViewById(R.id.button);


e= (EditText) findViewById(R.id.editText);

notify.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v)
{
Intent intent = new Intent(MainActivity.this,
SecondActivity.class);
PendingIntent pending =
PendingIntent.getActivity(MainActivity.this, 0, intent, 0);
Notification noti = new
Notification.Builder(MainActivity.this).setContentTitle("New
Message").setContentText(e.getText().toString()).setSmallIcon(R.mipmap.ic_launcher)
.setContentIntent(pending).build();
NotificationManager manager = (NotificationManager)
getSystemService(NOTIFICATION_SERVICE);
noti.flags |= Notification.FLAG_AUTO_CANCEL;
manager.notify(0, noti);
}
});
}
}

 So now the Coding part is also completed.


 Now run the application to see the output.
Output:

76 | MC Lab, Class: TE COMP, Theem COE


Conclusion:

77 | MC Lab, Class: TE COMP, Theem COE


H.J. Thim Trust's
Theem College of Engineering,
BoisarChilhar Road, Boisar (E), Tal - Palghar

ACADEMIC YEAR: 2022-23 CLASS: TE COMP SEM: VI

NAME:

ROLL NO: BATCH:

SUBJECT:MC LAB

EXPERIMENT NO: 10

DATE OF PERFORMANCE: / /

DATE OF SUBMISSION: / /

PARAMETER C P A Total Sign. With Date


MARKS
OBTAINED

MAX.MARKS 4 4 2 10

78 | MC Lab, Class: TE COMP, Theem COE


Experiment No: 10
Title: Implementation of calculator.
Date of Performance: Date of Submission:

Creating a New project:


 Open Android Stdio and then click on File -> New -> New project.

 Then type the Application name as “ex.no.3″ and click Next.

 Then select the Minimum SDK as shown below and click Next.

79 | MC Lab, Class: TE COMP, Theem COE


 Then select the Empty Activity and click Next.

 Finally click Finish.

80 | MC Lab, Class: TE COMP, Theem COE


 It will take some time to build and load the project.
 After completion it will look as given below.

Designing layout for the Android Application:


 Click on app -> res -> layout -> activity_main.xml.

 Now click on Text as shown below.


81 | MC Lab, Class: TE COMP, Theem COE
 Then delete the code which is there and type the code as given below.
Code for Activity_main.xml:

<?xml version="1.0" encoding="utf-8"?>


<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="20dp">

<LinearLayout
android:id="@+id/linearLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="20dp">

<EditText
android:id="@+id/editText1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:inputType="numberDecimal"
android:textSize="20sp" />

<EditText
android:id="@+id/editText2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:inputType="numberDecimal"
android:textSize="20sp" />

82 | MC Lab, Class: TE COMP, Theem COE


</LinearLayout>

<LinearLayout
android:id="@+id/linearLayout2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="20dp">

<Button
android:id="@+id/Add"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="+"
android:textSize="30sp"/>

<Button
android:id="@+id/Sub"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="-"
android:textSize="30sp"/>

<Button
android:id="@+id/Mul"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="*"
android:textSize="30sp"/>

<Button
android:id="@+id/Div"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="/"
android:textSize="30sp"/>

</LinearLayout>
83 | MC Lab, Class: TE COMP, Theem COE
<TextView
android:id="@+id/textView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="50dp"
android:text="Answer is"
android:textSize="30sp"
android:gravity="center"/>

</LinearLayout>

 Now click on Design and your application will look as given below.

 So now the designing part is completed.


Java Coding for the Android Application:
 Click on app -> java -> com.example.exno3 -> MainActivity.

 Then delete the code which is there and type the code as given below.
Code for MainActivity.java:

package com.example.devang.exno3;
84 | MC Lab, Class: TE COMP, Theem COE
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.text.TextUtils;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

public class MainActivity extends AppCompatActivity implements OnClickListener


{
//Defining the Views
EditText Num1;
EditText Num2;
Button Add;
Button Sub;
Button Mul;
Button Div;
TextView Result;

@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

//Referring the Views


Num1 = (EditText) findViewById(R.id.editText1);
Num2 = (EditText) findViewById(R.id.editText2);
Add = (Button) findViewById(R.id.Add);
Sub = (Button) findViewById(R.id.Sub);
Mul = (Button) findViewById(R.id.Mul);
Div = (Button) findViewById(R.id.Div);
Result = (TextView) findViewById(R.id.textView);

// set a listener
Add.setOnClickListener(this);
Sub.setOnClickListener(this);
Mul.setOnClickListener(this);
Div.setOnClickListener(this);
}
85 | MC Lab, Class: TE COMP, Theem COE
@Override
public void onClick (View v)
{

float num1 = 0;
float num2 = 0;
float result = 0;
String oper = "";

// check if the fields are empty


if (TextUtils.isEmpty(Num1.getText().toString()) ||
TextUtils.isEmpty(Num2.getText().toString()))
return;

// read EditText and fill variables with numbers


num1 = Float.parseFloat(Num1.getText().toString());
num2 = Float.parseFloat(Num2.getText().toString());

// defines the button that has been clicked and performs the corresponding
operation
// write operation into oper, we will use it later for output
switch (v.getId())
{
case R.id.Add:
oper = "+";
result = num1 + num2;
break;
case R.id.Sub:
oper = "-";
result = num1 - num2;
break;
case R.id.Mul:
oper = "*";
result = num1 * num2;
break;
case R.id.Div:
oper = "/";
result = num1 / num2;
break;
default:
break;
86 | MC Lab, Class: TE COMP, Theem COE
}
// form the output line
Result.setText(num1 + " " + oper + " " + num2 + " = " + result);
}
}

 So now the Coding part is also completed.


 Now run the application to see the output.
Output:

Conclusion:

87 | MC Lab, Class: TE COMP, Theem COE

You might also like