Kombinasi Metode K-Nearest Neighbor dengan Cosine Similarity untuk Prediksi Serangan Firewall pada Jaringan Komputer

Rahmawan Bagus Trianto, Andri Triyono, Dhika Malita Puspita Arum


The security of the computer network, especially the internet, is very crucial to note. One of the most effective ways to secure a computer network is to use a firewall. However, making a firewall that is still manual will make it difficult for network administrators to secure their computer network. The automatic detection of attacks on the firewall will further enhance the security of the computer network. Prediction or detection of attacks on the firewall automatically and intelligently can use the K-Nearest Neighbor algorithm by measuring the distance of data similarity using Cosine Similarity. The results of this study managed to achieve a high accuracy, which is 99.71%, precision is 74.70% and recall is 74.85% of predicting traffic that goes to the firewall. The results can be used as a standard of accuracy in predicting the traffic leading to the firewall, or even create an additional firewall so that the security of computer networks, especially the user data is saved.


Computer network; Prediction; K-Nearest Neighbor; Firewall; Cosine Similarity

Full Text:



Chen, Z., Zhou, L. J., Li, X. Da, Zhang, J. N., & Huo, W. J. (2020). The Lao text classification method based on KNN. Procedia Computer Science, Vol. 166, hal. 523–528. Elsevier B.V. https://doi.org/10.1016/j.procs.2020.02.053

Chicco, D., & Jurman, G. (2020). Machine learning can predict survival of patients with heart failure from serum creatinine and ejection fraction alone. BMC Medical Informatics and Decision Making, 20(1), 1–16. https://doi.org/10.1186/s12911-020-1023-5

Chiche, A., & Meshesha, M. (2021). Towards a Scalable and Adaptive Learning Approach for Network Intrusion Detection. Journal of Computer Networks and Communications, 2021. https://doi.org/10.1155/2021/8845540

Deolika, A., Kusrini, K., & Luthfi, E. T. (2019). Analisis Pembobotan Kata Pada Klasifikasi Text Mining. Jurnal Teknologi Informasi, 3(2), 179. https://doi.org/10.36294/jurti.v3i2.1077

Dewi, R. F. K., Obert, & Gusmana, R. (2018). Implementasi Metode K-Nearest Neighbor ( KNN ) dalam Pengelompokan Status Ekonomi Warga. Journal of Big Data Analytic and Artificial Intelligence, 4(1), 15–22.

Dhande, L. L., & Patnaik, P. G. K. (2014). Analyzing Sentiment of Movie Review Data using Naive Bayes Neural Classifier. International Journal of Emerging Trends & Technology in Computer Science (IJETTCS), 3(4), 313–320. Diambil dari www.ijettcs.org

Dinata, R. K., Akbar, H., & Hasdyna, N. (2020). Algoritma K-Nearest Neighbor dengan Euclidean Distance dan Manhattan Distance untuk Klasifikasi Transportasi Bus. ILKOM Jurnal Ilmiah, 12(2), 104–111. https://doi.org/10.33096/ilkom.v12i2.539.104-111

Ertam, F., & Kaya, M. (2018). Classification of firewall log files with multiclass support vector machine. 6th International Symposium on Digital Forensic and Security, ISDFS 2018 - Proceeding, 2018-Janua(2), 1–4. https://doi.org/10.1109/ISDFS.2018.8355382

Hassanat, A. B., Abbadi, M. A., Altarawneh, G. A., & Alhasanat, A. A. (2014). Solving the Problem of the K Parameter in the KNN Classifier Using an Ensemble Learning Approach. International Journal of Computer Science and Information Security, 12(8), 33–39. Diambil dari http://arxiv.org/abs/1409.0919

Khosroshahi, A. H., & Shahinzadeh, H. (2016). Security Technology by using Firewall for Smart Grid. Bulletin of Electrical Engineering and Informatics, 5(3), 366–372. https://doi.org/10.11591/eei.v5i3.545

Latifah, K. (2015). Kombinasi Algorithma K-NN dan Manhattan Distance untuk Menentukan Pemenang Lelang. Jurnal Informatika Upgris (JIU), 1, 49–58. Diambil dari https://docplayer.info/34038947-Kombinasi-algorithma-k-nn-dan-manhattan-distance-untuk-menentukan-pemenang-lelang.html

Mujtaba, G., Shuib, L., Idris, N., Hoo, W. L., Raj, R. G., Khowaja, K., … Nweke, H. F. (2019). Clinical text classification research trends: Systematic literature review and open issues. Expert Systems with Applications, 116, 494–520. https://doi.org/10.1016/j.eswa.2018.09.034

Nazari, N., & Mahdavi, M. (2018). A survey on Automatic Text Summarization. Journal of AI and Data Mining, 0(0), 121–135. https://doi.org/10.22044/jadm.2018.6139.1726

Nurdiana, O., Jumadi, J., & Nursantika, D. (2016). Perbandingan Metode Cosine Similarity Dengan Metode Jaccard Similarity Pada Aplikasi Pencarian Terjemah Al-Qur’an Dalam Bahasa Indonesia. Jurnal Online Informatika, 1(1), 59–63. https://doi.org/10.15575/join.v1i1.12

Rivki, Muhammad; Bachtiar, A. M. (2017). Implementasi Algoritma K-Nearest Neighbor Dalam Pengklasifikasian Follower Twitter Yang Menggunakan Bahasa Indonesia. Jurnal Sistem Informasi (Journal of Information System), 13(1), 31–37.

Saleh, A. I., Rabie, A. H., & Abo-Al-Ez, K. M. (2016). A data mining based load forecasting strategy for smart electrical grids. Advanced Engineering Informatics, 30(3), 422–448. https://doi.org/10.1016/j.aei.2016.05.005

Samuel, R., Natan, R., & Syafiqoh, U. (2018). Penerapan Cosine Similarity dan K-Nearest Neighbor ( K-NN ) pada Klasifikasi dan Pencarian Buku. Journal of Big Data Analytic and Artificial Intelligence, 1(1), 9–14.

Sokolova, M., & Lapalme, G. (2009). A systematic analysis of performance measures for classification tasks. Information Processing and Management, 45(4), 427–437. https://doi.org/10.1016/j.ipm.2009.03.002

Wahono, R. S., Herman, N. S., & Ahmad, S. (2014). A comparison framework of classification models for software defect prediction. Advanced Science Letters, 20(10–12), 1945–1950. https://doi.org/10.1166/asl.2014.5640

Wahyono, W., Trisna, I. N. P., Sariwening, S. L., Fajar, M., & Wijayanto, D. (2020). Comparison of distance measurement on k-nearest neighbour in textual data classification. Jurnal Teknologi dan Sistem Komputer, 8(1), 54–58. https://doi.org/10.14710/jtsiskom.8.1.2020.54-58

Wurdianarto, S., Wurdianarto, S. R., Novianto, S., & Rosyidah, U. (2014). Perbandingan Euclidean Distance Dengan Canberra Distance Pada Face Recognition. Techno.Com, 13(1), 31–37. Diambil dari https://publikasi.dinus.ac.id/index.php/technoc/article/view/539

DOI: http://dx.doi.org/10.32493/informatika.v6i4.12680


  • There are currently no refbacks.

Copyright (c) 2022 Rahmawan Bagus Trianto, Andri Triyono, Dhika Malita Puspita Arum

Creative Commons License
This work is licensed under a Creative Commons Attribution-NonCommercial 4.0 International License.

Jurnal Informatika Universitas Pamulang (ISSN: 2541-1004 e-ISSN: 2622-4615)

This work is licensed under a Creative Commons Attribution-NonCommercial 4.0 International (CC BY-NC 4.0) License