-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnew.py
29 lines (22 loc) · 861 Bytes
/
new.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import pandas as pd
from statsmodels.tsa.stattools import adfuller
# Load the dataset
data = pd.read_csv("TFTP_mini.csv")
# Select relevant columns for analysis
columns = ["Timestamp", "Total Length of Fwd Packets", "Total Length of Bwd Packets"]
selected_data = data[columns]
# Convert Timestamp column to datetime object
selected_data["Timestamp"] = pd.to_datetime(selected_data["Timestamp"])
# Sort the data by Timestamp
selected_data.sort_values(by="Timestamp", inplace=True)
# Convert Timestamp to Unix timestamps
numeric_time = selected_data["Timestamp"].apply(lambda x: x.timestamp())
# Perform ADF test on the numerical time data
result = adfuller(numeric_time)
p_value = result[1]
threshold = 0.05
print(p_value)
if p_value < threshold:
print("DDoS attack detected.")
else:
print("No DDoS attack detected.")