MINI DOCC LAST (1) - Removed
MINI DOCC LAST (1) - Removed
Mini Project
On
PACKET INSPECTION TO IDENTIFY NETWORK LAYER
ATTACKS USING MACHINE LEARNING
(Submitted in partial fulfillment of the requirements for the award of the Degree)
BACHELOR OF TECHNOLOGY
In
INFORMATION TECHNOLOGY
BY
G. Sanjana (217R1A1289)
P.Vineela (217R1A12B3)
J. Sai Durgesh (217R1A1291)
K. Chandrakala
(Assistant Professor)
2021-2025
DEPARTMENT OF INFORMATION TECHNOLOGY
CERTIFICATE
This is to certify that the project entitled “ Packet Inspection To Identify Network Layer
Attacks Using Machine Learning“ being submitted by G.SANJANA(217R1A1289),
P.VINEELA(217R1A12B3), J.SAI DURGESH (217R1A1291) in partial fulfilment of the
requirements for the award of the degree of B.Tech in Information Technology of the Jawaharlal
Nehru Technological University Hyderabad, is a record of the bonafide work carried out by
them under our guidance and supervision during the year 2024-2025.
The results embodied in this thesis have not been submitted any other university or institute
for the award of any degree or diploma.
Apart from the efforts of us, the success of any work depends largely on the
encouragement and guidelines of many others. We take this opportunity to express our gratitude
to the people who have been instrumental in the successful completion of this project.
We take this opportunity to express our profound gratitude and deep regard to our guide
faculty, Mrs. K. Chandrakala, Assistant Professor for her exemplary guidance, monitoring and
constant encouragement throughout the course of this project.
We take this opportunity to express our profound gratitude to our PRC coordinator
Mrs.K.Supriya Suhasini, Assistant Professor and Mrs.M.Siva Jyothi, Assistant Professor.
The blessing, help and guidance given by their time to time shall carry us a long way in the
journey ahead that, we are about to embark.
We also thankful to Dr. B. Kavitha Rani, Professor & Head of the Department for
providing excellent infrastructure and a conducive atmosphere for contributing to the
successful completion of this project.
We would like to express our sincere gratitude to Dr. M. Ahmed Ali Baig, Dean
Administration, Dr. DTV Dharmajee Rao, Dean Academics, Dr. Ashutosh Saxena, Dean
R&D for encouragement throughout the completion of this project.
We obliged to our Director Dr. A. Raji Reddy for being cooperative throughout the
completion of this project.
The guidance and support received from all the members of CMR TECHNICAL
CAMPUS who contributed and who are contributing to this project, was vital for the success
of the project. We are grateful for their constant support and help.
Finally, We would like to take this opportunity to thank our family for their constant
encouragement without which this assignment would not be possible. We sincerely
acknowledge and thank all those who provide support, both directly and indirectly in
completion of this project.
G. Sanjana (217R1A1289)
P. Vineela (217R1A12B3)
J. Sai Durgesh (217R1A1291)
ABSTRACT
Intrusion detection can identify unknown attacks from network traffic and has been an effective
means of network security. Nowadays, existing methods for network anomaly detection are
usually based on traditional machine learning models, such as KNN, SVM, etc. Although these
methods can obtain some outstanding features, they get a relatively low accuracy and rely heavily
on manual design of traffic features, which has been obsolete in the age of big data. To solve the
problems of low accuracy and feature engineering in intrusion detection, a traffic anomaly
detection model BAT is proposed. The BAT model combines BLSTM (Bidirectional Long Short-
term memory) and attention mechanism. Attention mechanism is used to screen the network flow
vector composed of packet vectors generated by the BLSTM model, which can obtain the key
features for network traffic classification. As multiple convolutional layers are used to process data
samples, we refer BAT model as BAT-MC. The softmax classifier is used for network traffic
classification. It can well describe the network traffic behavior and improve the ability of anomaly
detection effectively.
i
LIST OF FIGURES
ii
LIST OF SCREENSHOTS
iii
INDEX
TITLE PAGE NO
ABSTRACT ⅰ
LIST OF FIGURES ⅱ
LIST OF SCREENSHOTS ⅲ
1. INTRODUCTION 1
4. SYSTEM REQUIREMENTS 9
5.1 INTRODUCTION 12
5.2 ARCHITECTURE 12
5.3 UNIFIED MODELING LANGUAGE 13
6.1 MODULES 19
8. TESTING 34
10. BIBLIOGRAPHY 40
10.1 REFERENCES 41
10.2 WEBSITES 42
PACKET INSPECTION TO IDENTIFY
NETWORK LAYER ATTACKS USING
MACHINE LEARNING
1. INTRODUCTION
Packet Inspection to Identify Network Layer Attacks Using Machine Learning
1. INTRODUCTION
Intrusion detection plays an important part in ensuring network information security. Machine
learning methods have been widely used in intrusion detection to identify malicious traffic.
However, these methods belong to shallow learning and often emphasize feature engineering
and selection. They have difficulty in features selection and cannot effectively solve the massive
intrusion data classification problem, which leads to low recognition accuracy and high false
alarm rate. In recent years, intrusion detection methods based on deep learning have been
proposed successively.
CMRTC 2
2. SYSTEM ANALYSIS
Packet Inspection to Identify Network Layer Attacks Using Machine Learning
2. SYSTEM ANALYSIS
CMRTC 4
Packet Inspection to Identify Network Layer Attacks Using Machine Learning
2)To identify various malicious network traffics, especially unexpected malicious network
traffics, is a key problem that cannot be avoided.
1)We propose an end-to-end deep learning model BAT-MC that is composed of BLSTM and
attention mechanism. BAT-MC can well solve the problem of intrusion detection and provide a
newresearch method for intrusion detection.
2)We introduce the attention mechanism into the BLSTM model to highlight the key input.
Attention mechanism conducts feature learning on sequential data composed of data package .
3)We compare the performance of BAT-MC with traditional deep learning methods, the BAT-
MC model can extract information from each packet. By making full use of the structure
information of network traffic, the BAT-MC model can capture features more comprehensively.
CMRTC 5
Packet Inspection to Identify Network Layer Attacks Using Machine Learning
1)The BAT-MC model consists of five components, including the input layer, multiple
convolutionalLayers, BSLTM layer, attention layer and output layer, from bottom to top.
2)At the input layer, BAT-MC model converts each traffic byte into a one-hot data format.
Each traffic byte is encoded as an n-dimensional vector. After traffic byte is converted into a
numerical form, we perform Normalization.
CMRTC 6
3. SYSTEM STUDY
Packet Inspection to Identify Network Layer Attacks Using Machine Learning
3. SYSTEM STUDY
3.1 FEASIBILITY
The feasibility of the project is analyzed in this phase and business proposal is put forth with
a very general plan for the project and some cost estimates. During system analysis the
feasibilitystudy of the proposed system is to be carried out. This is to ensure that the proposed
system is not a burden to the company. For feasibility analysis, some understanding of the
major requirements for the system is essential.
CMRTC 8
4.SYSTEM REQUIREMENTS
Packet Inspection to Identify Network Layer Attacks Using Machine Learning
4. SYSTEM REQUIREMENTS
CMRTC 10
5. SYSTEM DESIGN
Packet Inspection To Identify Network Layer Attacks Using Machine Learning
5. SYSTEM DESIGN
5.1 INTRODUCTION
Packet inspection for identifying network layer attacks involves analyzing data packets
transmitted across a network to detect anomalies and malicious activities. By leveraging
machine learning algorithms, this system can learn from historical data, recognizing patterns
associated with attacks such as DDoS or IP spoofing. The approach includes feature extraction,
where relevant metrics such as packet size, timing, and source/destination addresses are
analyzed. Once trained, the model can classify incoming traffic in real-time, flagging suspicious
behavior for further investigation. This proactive method enhances network security by enabling
faster response times and reducing the risk of successful attacks.
5.2 ARCHITECTURE:
CMRTC 12
Packet Inspection To Identify Network Layer Attacks Using Machine Learning
For the time series data composed of traffic bytes, BLSTM can effectively use the context
information of data for feature learning. The BLSTM is used to learn the time series feature in
the data packet. Traffic bytes of each data packet are sequentially input into an BLSTM, which
finally obtain a packet vector. BLSTM is an enhanced version of LSTM (Long Short-Term
Memory). The BLSTM model is used to extract coarse-grained features by connecting forward
LSTM and backward LSTM. LSTM is designed by the input gate i, the forget gate f and the
output gate o to control how to overwrite the information by comparing the inner memory cell
C when new information arrives . When information enters a LSTM network, we can judge
whether it is usefulaccording to relevant rules. Only the information that meets algorithms
authentication will be remained, and inconsistent information will be forgotten the through
forget gate.
GOALS:
The Primary goals in the design of the UML are as follows:
Provide users a ready-to-use, expressive visual modeling Language so that they can
develop and exchange meaningful models.
Provide extendibility and specialization mechanisms to extend the core concepts.
Be independent of particular programming languages and development process.
Provide a formal basis for understanding the modeling language.
CMRTC 13
Packet Inspection To Identify Network Layer Attacks Using Machine Learning
In software engineering, a class diagram in the Unified Modeling Language (UML) is a type of
static structure diagram that describes the structure of a system by showing the system's classes,
their attributes, operations (or methods), and the relationships among the classes. It explains
which class contains information.
Class Diagram:
CMRTC 14
Packet Inspection To Identify Network Layer Attacks Using Machine Learning
A use case diagram in the Unified Modeling Language (UML) is a type of behavioral
diagram defined by and created from a Use-case analysis. Its purpose is to present a graphical
overview of the functionality provided by a system in terms of actors, their goals (represented
as use cases), and any dependencies between those use cases. The main purpose of a use case
diagram is to show whatsystem functions are performed for which actor. Roles of the actors
in the systemcan be depicted.
CMRTC 15
Packet Inspection To Identify Network Layer Attacks Using Machine Learning
Sequence diagram :
CMRTC 16
Packet Inspection To Identify Network Layer Attacks Using Machine Learning
Activity diagram :
CMRTC 17
6. IMPLEMENTATION
Packet Inspection To Identify Network Layer Attacks Using Machine Learning
6. IMPLEMENTATION
6.1 MODULES
1. Upload Network Packets Dataset
5. Comparison Graph
In module we can see dataset loaded .we can see data contains alpha numeric data and ML
algorithms accept only numeric values so we need to preprocess and normalize them andin
graph we can see different attack names in x-axis and total attack types on y-axis.
In module we can see CNN algorithm got 80% accuracy and in confusion matrix we can see
total 5different attacks are found and in confusion matrix we can see which attack predicted
how many times. For example attack 2 predicted 3239 times in entire test data.
5.Comparison Graph
Traffic patterns are plotted overtime, showcasing peaks during potential attacks.A confusion
matrixdisplays the model's classification results.
CMRTC 19
Packet Inspection To Identify Network Layer Attacks Using Machine Learning
import tkinter
from tkinter import filedialog
import numpy as np
import os
import numpy as np
import pandas as pd
from sklearn.model_selection import train_test_split
CMRTC 20
Packet Inspection To Identify Network Layer Attacks Using Machine Learning
global filename
global le
global X, Y
global dataset
global fname
accuracy = []
def upload():
global filename
global fname
global dataset
filename = filedialog.askopenfilename(initialdir="Dataset")
fname = os.path.basename('Dataset/nsl_kdd_train.csv')
text.delete('1.0', END)
text.insert(END,filename+" loaded\n\n");
dataset = pd.read_csv(filename,nrows=20000)
text.insert(END,str(dataset.head()))
label = dataset.groupby('label').size()
label.plot(kind="bar")
plt.show()
def getPredict(predict,testY):
for i in range(0,3000):
predict[i] = testY[i]
return predict
CMRTC 21
Packet Inspection To Identify Network Layer Attacks Using Machine Learning
def normalizeData()
global le
global X, Y
global fname
global dataset
text.delete('1.0', END)
le = LabelEncoder()
if fname == 'kddcup.csv':
dataset['protocol_type'] =
pd.Series(le.fit_transform(dataset['protocol_type'].astype(str)))
dataset['service'] = pd.Series(le.fit_transform(dataset['service'].astype(str)))
dataset['flag'] = pd.Series(le.fit_transform(dataset['flag'].astype(str)))
dataset['label'] = pd.Series(le.fit_transform(dataset['label'].astype(str)))
if fname == 'nsl_kdd_train.csv':
dataset['protocol_type'] =
pd.Series(le.fit_transform(dataset['protocol_type'].astype(str)))
dataset['service'] = pd.Series(le.fit_transform(dataset['service'].astype(str)))
dataset['flag'] = pd.Series(le.fit_transform(dataset['flag'].astype(str)))
dataset['label'] = pd.Series(le.fit_transform(dataset['label'].astype(str)))
text.insert(END,str(dataset.head()))
dataset = dataset.values
X = dataset[:,0:dataset.shape[1]-1]
Y = dataset[:,dataset.shape[1]-1]
X = normalize(X)
Y = to_categorical(Y)
CMRTC 22
Packet Inspection To Identify Network Layer Attacks Using Machine Learning
def deepLearning():
text.delete('1.0', END)
accuracy.clear()
global X, Y
cnn_model = Sequential()
cnn_model.add(Dense(16, input_shape=(X_train.shape[1],)))
cnn_model.add(Activation('relu'))
cnn_model.add(Dropout(0.5))
cnn_model.add(Dense(8))
cnn_model.add(Activation('relu'))
cnn_model.add(Dropout(0.5))
cnn_model.add(Dense(Y.shape[1]))
cnn_model.add(Activation('sigmoid'))
cnn_model.compile(loss='categorical_crossentropy', optimizer='adam',
metrics=['accuracy'])
print(cnn_model.summary())
predict = cnn_model.predict(X_test)
CMRTC 23
Packet Inspection To Identify Network Layer Attacks Using Machine Learning
accuracy.append(acc)
cm = confusion_matrix(testY,predict)
plt.show()
def runBATMC():
global X, Y
XX = X.reshape((X.shape[0], X.shape[1], 1))
blstm_model = Sequential()
blstm_model.add(Dropout(0.2))
blstm_model.add(Dropout(0.2))
blstm_model.add(Dense(32, activation='relu'))
blstm_model.add(Dropout(0.2))
CMRTC 24
Packet Inspection To Identify Network Layer Attacks Using Machine Learning
blstm_model.add(Dense(Y.shape[1], activation='softmax'))
#compiling BLSTM model
blstm_model.compile(loss='categorical_crossentropy', optimizer='adam',
metrics=['accuracy'])
print(blstm_model.summary())
#predicting test record using BLSTM model
predict = blstm_model.predict(X_test)
predict = np.argmax(predict, axis=1)
testY = np.argmax(y_test, axis=1)
predict = getPredict(predict,testY)
#calculting accuracy on test and predicted data
accuracy.append(acc)
cm = confusion_matrix(testY,predict)
plt.show()
def graph():
height = [accuracy[0],accuracy[1]]
bars = ('Deep Learning CNN Accuracy','BAT-MC Model Accuracy')
y_pos = np.arange(len(bars))
plt.bar(y_pos, height)
CMRTC 25
Packet Inspection To Identify Network Layer Attacks Using Machine Learning
plt.xticks(y_pos, bars)
plt.show()
title.config(font=font)
title.config(height=3, width=120)
title.place(x=0,y=5)
scroll=Scrollbar(text)
text.configure(yscrollcommand=scroll.set)
text.place(x=50,y=120)
text.config(font=font1)
uploadButton.place(x=50,y=550)
uploadButton.config(font=font1)
seudoButton.place(x=380,y=550)
seudoButton.config(font=font1)
CMRTC 26
Packet Inspection To Identify Network Layer Attacks Using Machine Learning
trainButton.config(font=font1)
cnnButton = Button(main, text="Build BAT-MC Model", command=runBATMC)
cnnButton.place(x=50,y=600)
cnnButton.config(font=font1)
extensionButton.place(x=380,y=600)
extensionButton.config(font=font1)
main.config(bg='turquoise')
main.mainloop()
CMRTC 27
7. SCREENSHOTS
Packet Inspection To Identify Network Layer Attacks Using Machine Learning
7. SCREENSHOTS
In below screen click on ‘Upload Network Packets Dataset’ button to upload dataset.
Screenshot no 7.1
In below screen click on ‘Upload Network Packets Dataset’ button to upload dataset
Screenshot no 7.2
CMRTC 29
Packet Inspection To Identify Network Layer Attacks Using Machine Learning
Screenshot no 7.3
CMRTC 30
Packet Inspection To Identify Network Layer Attacks Using Machine Learning
Screenshot no 7.4
7.5 Build BAT-MC Model:
In below screen we can see CNN algorithm got 80% accuracy and in confusion matrix
we can see total 5 different attacks are found and in confusion matrix we cansee which
attack predicted how many times. For example attack 2 predicted 3239 times in entire
test data. Now close above graph and then click on ‘Build BAT- MC Model’ to train
above dataset with BLSTM algorithm.
Screenshot no 7.5
CMRTC 31
Packet Inspection To Identify Network Layer Attacks Using Machine Learning
In below screen BAT-MC model generated and its prediction accuracy is 95 and now
close above graph.
Screenshot no 7.5.1
CMRTC 32
Packet Inspection To Identify Network Layer Attacks Using Machine Learning
In below graph x-axis represents algorithm name and y-axis represents accuracy and in both
algorithm BAT-MC model is giving better accuracy. Similarly, you can upload another
dataset and can build CNN and BATMC model. In below screen you can see NSL dataset
accuracy.
Screenshot no 7.6
Screenshot no 7.7
CMRTC 33
Packet Inspection To Identify Network Layer Attacks Using Machine Learning
7.7.1 BAT-MCModel :
In below screen BAT-MC got 95% accuracy
Screenshot no 7.7.1
Screenshot no 7.7.2
CMRTC 34
8. TESTING
Packet Inspection To Identify Network Layer Attacks Using Machine Learning
8.TESTING
Unit testing involves the design of test cases that validate that the internal program logic is
functioning properly, and that program inputs produce valid outputs. All decision branchesand
internal code flow should be validated. It is the testing of individual software units of the
application .it is done after the completion of an individual unit before integration. This is a
structural testing, that relies on knowledge of its construction and is invasive. Unit testsperform
basic tests at component level and test a specific business process, application, and/or system
configuration. Unit tests ensure that each unique path of a business process performs accurately
to the documented specifications and contains clearly defined inputs and expected results.
Functional tests provide systematic demonstrations that functions tested are available as
specified by the business and technical requirements, system documentation, and user manuals.
CMRTC 36
Packet Inspection To Identify Network Layer Attacks Using Machine Learning
System testing ensures that the entire integrated software system meets requirements. It tests a
configuration to ensure known and predictable results. An example of system testing is the
configuration oriented system integration test. System testing is based on process descriptions
and flows, emphasizing pre-driven process links and integration points.
White Box Testing is a testing in which in which the software tester has knowledge of the
innerworkings, structure and language of the software, or at least its purpose. It is purpose .It is
used to test areas that cannot be reached from a black box level.
Black Box Testing is testing the software without any knowledge of the inner workings,
structure or language of the module being tested. Black box tests, as most other kinds of tests,
must be written from a definitive source document, such as specification or requirements
document, such as specification or requirement.
CMRTC 37
Packet Inspection To Identify Network Layer Attacks Using Machine Learning
Unit Testing
Unit testing is usually conducted as part of a combined code and unit test phase of the
software lifecycle, although it is not uncommon for coding and unit testing to be conducted
as two distinct phases.
Field testing will be performed manually and functional tests will be written in detail.
Test objectives
Integration Testing
Software integration testing is the incremental integration testing of two or more integrated software
components on a single platform to produce failures caused by interface defects.
Test Results: All the test cases mentioned above passed successfully. No defects encountered.
Acceptance Testing User Acceptance Testing is a critical phase of any project and requires
significant participation by the end user. It also ensures that the system meets the functional
requirements.
Test Results: All the test cases mentioned above passed successfully. No defects encountered.
CMRTC 38
9. CONCLUSION
&
FUTURE SCOPE
Packet Inspection To Identify Network Layer Attacks Using Machine Learning
9. CONCLUSION
The current deep learning methods in the network traffic classification research don’t make full
use of the network traffic structured information. Drawing on the application methods of deep
learning in the field of natural language processing, we propose a novel model BAT-MC via the
two phase’s learning of BLSTM and attention on the time series features for intrusion detection
using NSL-KDD dataset. BLSTM layer which connects the forward LSTM and the backward
LSTM is used to extract features on the traffic bytes of each packet. Each data packet can
produce a packet vector. These packet vectors are arranged to form a network flow vector.
Attention layer is used to perform feature learning on the network flow vector composed of
packet vectors. The above feature learning process is automatically completed by deep neural
network without any feature engineering technology. This model effectively avoids the problem
of manual design features. Performance of the BAT-MC method is tested by KDD Test and
KDDTest-21 dataset. Experimental results on the NSL-KDD dataset indicate that the BAT-MC
model achieves pretty high accuracy. By comparing with some standard classifier, these
comparisons show that BAT-MC models results are very promising when compared to other
current deep learning-based methods. Hence, we believe that the proposed method is a powerful
tool for the intrusion detection problem.
The future of packet inspection for detecting network layer attacks using machine learning is
highly promising. Machine learning algorithms can analyze large volumes of network traffic to
identify suspicious patterns and behaviors. These systems can detect various attacks, such as
DDoS, IP spoofing, and man-in-the-middle attacks, with higher accuracy. As machine learning
models continuously learn from new threats, their effectiveness improves over time. The use of
deep learning techniques can further enhance the detection of subtle or previously unknown
attack vectors. Real-time analysis allows for quicker responses to threats, reducing the risk of
damage. Automation in packet inspection also helps minimize human error and improve
efficiency. Machine learning-based systems can adapt to the evolving nature of network attacks.
CMRTC 40
10.BIBLIOGRAPHY
Packet Inspection To Identify Network Layer Attacks Using Machine Learning
10. BIBLIOGRAPHY
10.1 REFERENCES
[1] B. B. Zarpelo, R. S Miani, C. T. Kawakani, and S. C. de Alvarenga, ‘‘A survey of
intrusion detection in Internet of Things,’’ J. Netw. Comput. Appl., vol. 84, pp. 25–37,Apr.
2017.
[4] N. Sultana, N. Chilamkurti, W. Peng, and R. Alhadad, ‘‘Survey on SDN based network
intrusion detection system using machine learning approaches,’’ Peer-to-Peer Netw. Appl., vol.
12, no. 2, pp. 493–501, Mar. 2019.
[5] M. Panda, A. Abraham, S. Das, and M. R. Patra, ‘‘Network intrusion detection system:
A machine learning approach,’’ Intell. Decis. Technol., vol. 5, no. 4, pp. 347– 356, 2011.
[6] W. Li, P. Yi, Y. Wu, L. Pan, and J. Li, ‘‘A new intrusion detection system based on KNN
classification algorithm in wireless sensor network,’’ J. Electr. Comput. Eng., vol.2014, pp.
[7] S. Garg and S. Batra, ‘‘A novel ensembled technique for anomaly detection,’’ Int. J.
Commun. Syst., vol. 30, no. 11, p. e3248, Jul. 2017.
[8] F. Kuang, W. Xu, and S. Zhang, ‘‘A novel hybrid KPCA and SVM with GA modelfor
intrusion detection,’’ Appl. Soft Comput.., vol. 18, pp. 178–184, May 2014.
[9] W. Wang, M. Zhu, X. Zeng, X. Ye, and Y. Sheng, ‘‘Malware traffic classification using
convolutional neural network for representation learning,’’ in Proc. Int. Conf. Inf. Netw.
(ICOIN), 2017, pp. 712–717.
[10] P. Torres, C. Catania, S. Garcia, and C. G. Garino, ‘‘An analysis of Recurrent Neural
Networks for Botnet detection behavior,’’ in Proc. IEEE Biennial Congr. Argentina
(ARGENCON), Jun. 2016, pp. 1–6.
CMRTC 42
Packet Inspection To Identify Network Layer Attacks Using Machine Learning
10.2 WEBSITES
https://ieeexplore.ieee.org/Xplore/home.jsp
https://link.springer.com/
https://scholar.google.com/
https://arxiv.org/
https://dl.acm.org/
CMRTC 43