Simulation
Simulation
import socket
import time
import numpy as np
def generate_iv():
def encrypt_message(message):
iv = generate_iv()
def decrypt_message(encrypted_message):
iv = encrypted_message[:12]
ciphertext = encrypted_message[12:-16]
tag = encrypted_message[-16:]
try:
return decrypted_data.decode()
except ValueError:
# Satellite (Server)
def satellite():
try:
server.listen(1)
except OSError as e:
return
data = conn.recv(1024)
if data:
command = decrypt_message(data)
telemetry_data = []
encrypted_telemetry = encrypt_message(telemetry)
conn.sendall(encrypted_telemetry)
telemetry_data.append((battery, temp))
conn.close()
server.close()
return telemetry_data
def ground_station():
try:
except OSError as e:
return
encrypted_command = encrypt_message(command)
client.sendall(encrypted_command)
temp_data = []
for _ in range(10):
data = client.recv(1024)
telemetry = decrypt_message(data)
battery_data.append(battery)
temp_data.append(temp)
client.close()
time_points = np.arange(len(battery_data))
plt.figure(figsize=(10, 5))
plt.subplot(1, 2, 1)
plt.subplot(1, 2, 2)
plt.xlabel('Time Step')
plt.ylabel('Temperature (°C)')
plt.tight_layout()
plt.show()
if __name__ == "__main__":
telemetry_data = satellite()
plot_telemetry(battery_data, temp_data)