2025-09-10 10:45:48 -04:00
|
|
|
import json
|
|
|
|
import re
|
|
|
|
|
|
|
|
import matplotlib.pyplot as plt
|
2025-09-17 23:17:52 -04:00
|
|
|
import numpy as np
|
2025-09-10 10:45:48 -04:00
|
|
|
|
|
|
|
|
|
|
|
def plot_rsrp(filename):
|
|
|
|
# Load the JSON file
|
|
|
|
with open(filename, "r") as file:
|
|
|
|
data = json.load(file)
|
|
|
|
|
|
|
|
# Extract distance and RSRP values (convert RSRP values to integers)
|
|
|
|
distances = []
|
|
|
|
rsrp_prx = []
|
|
|
|
rsrp_drx = []
|
|
|
|
rsrp_rx2 = []
|
|
|
|
rsrp_rx3 = []
|
|
|
|
|
|
|
|
for entry in data:
|
|
|
|
try:
|
2025-09-17 23:17:52 -04:00
|
|
|
int(float(entry["distance"]))
|
2025-09-10 10:45:48 -04:00
|
|
|
rsrp_prx.append(
|
|
|
|
-169
|
|
|
|
if int(entry["RSRP PRX"].strip()) == -32768
|
|
|
|
else int(entry.get("RSRP PRX", -169))
|
|
|
|
)
|
|
|
|
rsrp_drx.append(
|
|
|
|
-169
|
|
|
|
if int(entry["RSRP DRX"].strip()) == -32768
|
|
|
|
else int(entry.get("RSRP DRX", -169))
|
|
|
|
)
|
|
|
|
rsrp_rx2.append(
|
|
|
|
-169
|
|
|
|
if int(entry["RSRP RX2"].strip()) == -32768
|
|
|
|
else int(entry.get("RSRP RX2", -169))
|
|
|
|
)
|
|
|
|
rsrp_rx3.append(
|
|
|
|
-169
|
|
|
|
if int(entry["RSRP RX3"].strip()) == -32768
|
|
|
|
else int(entry.get("RSRP RX3", -169))
|
|
|
|
)
|
2025-09-17 23:17:52 -04:00
|
|
|
distances.append(int(float(entry["distance"])))
|
2025-09-10 10:45:48 -04:00
|
|
|
except (ValueError, KeyError):
|
|
|
|
continue
|
|
|
|
|
|
|
|
# Plot the data
|
|
|
|
plt.figure(figsize=(10, 6))
|
|
|
|
plt.plot(distances, rsrp_prx, label="RSRP PRX", marker="o")
|
|
|
|
plt.plot(distances, rsrp_drx, label="RSRP DRX", marker="s")
|
|
|
|
plt.plot(distances, rsrp_rx2, label="RSRP RX2", marker="^")
|
|
|
|
plt.plot(distances, rsrp_rx3, label="RSRP RX3", marker="d")
|
|
|
|
|
|
|
|
plt.title("RSRP vs Distance")
|
|
|
|
plt.xlabel("Distance (m)")
|
|
|
|
plt.ylabel("RSRP (dBm)")
|
|
|
|
plt.legend()
|
|
|
|
plt.grid(True)
|
|
|
|
plt.tight_layout()
|
|
|
|
|
|
|
|
# Show the plot
|
|
|
|
plt.show()
|
|
|
|
|
|
|
|
|
|
|
|
def plot_rsrq(filename):
|
|
|
|
# Load the JSON file
|
|
|
|
with open(filename, "r") as file:
|
|
|
|
data = json.load(file)
|
|
|
|
|
|
|
|
# Extract distance and RSRQ values (convert RSRQ values to integers)
|
|
|
|
distances = []
|
|
|
|
rsrq_prx = []
|
|
|
|
rsrq_drx = []
|
|
|
|
rsrq_rx2 = []
|
|
|
|
rsrq_rx3 = []
|
|
|
|
|
|
|
|
for entry in data:
|
|
|
|
try:
|
2025-09-17 23:17:52 -04:00
|
|
|
int(float(entry["distance"]))
|
2025-09-10 10:45:48 -04:00
|
|
|
rsrq_prx.append(
|
|
|
|
-20
|
|
|
|
if int(entry["RSRQ PRX"].strip()) == -32768
|
|
|
|
else int(entry.get("RSRQ PRX", -20))
|
|
|
|
)
|
|
|
|
rsrq_drx.append(
|
|
|
|
-20
|
|
|
|
if int(entry["RSRQ DRX"].strip()) == -32768
|
|
|
|
else int(entry.get("RSRQ DRX", -20))
|
|
|
|
)
|
|
|
|
rsrq_rx2.append(
|
|
|
|
-20
|
|
|
|
if int(entry["RSRQ RX2"].strip()) == -32768
|
|
|
|
else int(entry.get("RSRQ RX2", -20))
|
|
|
|
)
|
|
|
|
rsrq_rx3.append(
|
|
|
|
-20
|
|
|
|
if int(entry["RSRQ RX3"].strip()) == -32768
|
|
|
|
else int(entry.get("RSRQ RX3", -20))
|
|
|
|
)
|
2025-09-17 23:17:52 -04:00
|
|
|
distances.append(int(float(entry["distance"])))
|
2025-09-10 10:45:48 -04:00
|
|
|
except (ValueError, KeyError):
|
|
|
|
continue
|
|
|
|
|
|
|
|
# Plot the data
|
|
|
|
plt.figure(figsize=(10, 6))
|
|
|
|
plt.plot(distances, rsrq_prx, label="RSRQ PRX", marker="o")
|
|
|
|
plt.plot(distances, rsrq_drx, label="RSRQ DRX", marker="s")
|
|
|
|
plt.plot(distances, rsrq_rx2, label="RSRQ RX2", marker="^")
|
|
|
|
plt.plot(distances, rsrq_rx3, label="RSRQ RX3", marker="d")
|
|
|
|
|
|
|
|
plt.title("RSRQ vs Distance")
|
|
|
|
plt.xlabel("Distance (m)")
|
|
|
|
plt.ylabel("RSRQ (dBm)")
|
|
|
|
plt.legend()
|
|
|
|
plt.grid(True)
|
|
|
|
plt.tight_layout()
|
|
|
|
|
|
|
|
# Show the plot
|
|
|
|
plt.show()
|
|
|
|
|
|
|
|
|
|
|
|
def plot_iperf(filename):
|
|
|
|
# Load the JSON file
|
|
|
|
with open(filename, "r") as file:
|
|
|
|
data = json.load(file)
|
|
|
|
|
|
|
|
distances = []
|
|
|
|
sender = []
|
|
|
|
receiver = []
|
|
|
|
|
|
|
|
for entry in data:
|
|
|
|
try:
|
|
|
|
message = entry["iperf_full"]
|
|
|
|
bitrates = re.findall(r"(\d+\.\d+) Mbits/sec", message)
|
|
|
|
|
|
|
|
sender.append(float(bitrates[-2]))
|
|
|
|
receiver.append(float(bitrates[-1]))
|
|
|
|
distances.append(entry["start_distance"])
|
|
|
|
except (ValueError, KeyError):
|
|
|
|
continue
|
|
|
|
|
|
|
|
# Plot the data
|
|
|
|
plt.figure(figsize=(10, 6))
|
|
|
|
plt.plot(distances, sender, label="Avg Sender Bitrate", marker="o")
|
|
|
|
plt.plot(distances, receiver, label="Avg Receiver Bitrate", marker="s")
|
|
|
|
|
|
|
|
plt.title("IPERF vs Distance")
|
|
|
|
plt.xlabel("Distance (m)")
|
|
|
|
plt.ylabel("Bitrate (Mbits/s)")
|
|
|
|
plt.legend()
|
|
|
|
plt.grid(True)
|
|
|
|
plt.tight_layout()
|
|
|
|
|
|
|
|
# Show the plot
|
|
|
|
plt.show()
|
|
|
|
|
|
|
|
|
|
|
|
def plot_bytes(filename):
|
|
|
|
# Load the JSON file
|
|
|
|
with open(filename, "r") as file:
|
|
|
|
data = json.load(file)
|
|
|
|
|
|
|
|
distances = []
|
|
|
|
uplink = []
|
|
|
|
downlink = []
|
|
|
|
|
|
|
|
for entry in data:
|
|
|
|
try:
|
|
|
|
if (
|
|
|
|
int(entry["uplink (bytes/s)"].strip()) < 1000000
|
|
|
|
and int(entry["downlink (bytes/s)"].strip()) < 1000000
|
|
|
|
):
|
|
|
|
distances.append(entry["distance"])
|
|
|
|
uplink.append(int(entry["uplink (bytes/s)"].strip()))
|
|
|
|
downlink.append(int(entry["downlink (bytes/s)"].strip()))
|
|
|
|
except (ValueError, KeyError):
|
|
|
|
continue
|
|
|
|
|
|
|
|
# Plot the data
|
|
|
|
plt.figure(figsize=(10, 6))
|
|
|
|
plt.plot(distances, downlink, label="Downlink Bitrate", marker="o")
|
|
|
|
plt.plot(distances, uplink, label="Uplink Bitrate", marker="s")
|
|
|
|
|
|
|
|
plt.title("Bitrate vs Distance")
|
|
|
|
plt.xlabel("Distance (m)")
|
|
|
|
plt.ylabel("Bitrate (bytes/s)")
|
|
|
|
plt.legend()
|
|
|
|
plt.grid(True)
|
|
|
|
plt.tight_layout()
|
|
|
|
|
|
|
|
# Show the plot
|
|
|
|
plt.show()
|
|
|
|
|
|
|
|
|
|
|
|
def plot_manual():
|
|
|
|
distances = [0, 100, 200, 300, 400, 500, 600, 700, 800]
|
|
|
|
rsrps = [-56, -82, -90, -93, -100, -105, -105, -116, -150]
|
|
|
|
sender = [0, 6.06, 6.95, 6.37, 6.96, 8.04, 7.30, 0, 0]
|
|
|
|
receiver = [0, 5.20, 6.10, 5.24, 6.08, 6.84, 6.37, 0, 0]
|
|
|
|
|
|
|
|
# Plot the RSRP data
|
|
|
|
plt.figure(figsize=(10, 6))
|
|
|
|
plt.plot(distances, rsrps, label="RSRP", marker="o")
|
|
|
|
|
|
|
|
plt.title("RSRP vs Distance")
|
|
|
|
plt.xlabel("Distance (m)")
|
|
|
|
plt.ylabel("RSRP (dBm)")
|
|
|
|
plt.legend()
|
|
|
|
plt.grid(True)
|
|
|
|
plt.tight_layout()
|
|
|
|
|
|
|
|
# Show the plot
|
|
|
|
plt.show()
|
|
|
|
|
|
|
|
# Plot the iperf data
|
|
|
|
plt.figure(figsize=(10, 6))
|
|
|
|
plt.plot(distances, sender, label="Avg Sender Bitrate", marker="o")
|
|
|
|
plt.plot(distances, receiver, label="Avg Receiver Bitrate", marker="s")
|
|
|
|
|
|
|
|
plt.title("IPERF vs Distance")
|
|
|
|
plt.xlabel("Distance (m)")
|
|
|
|
plt.ylabel("Bitrate (Mbits/s)")
|
|
|
|
plt.legend()
|
|
|
|
plt.grid(True)
|
|
|
|
plt.tight_layout()
|
|
|
|
|
|
|
|
# Show the plot
|
|
|
|
plt.show()
|
|
|
|
|
|
|
|
|
|
|
|
def plot_double_iperf(filename):
|
|
|
|
# Load the JSON file
|
|
|
|
with open(filename, "r") as file:
|
|
|
|
data = json.load(file)
|
|
|
|
|
|
|
|
distances = []
|
|
|
|
sender = []
|
|
|
|
receiver = []
|
|
|
|
reverse_distances = []
|
|
|
|
reverse_sender = []
|
|
|
|
reverse_receiver = []
|
|
|
|
|
|
|
|
for entry in data:
|
|
|
|
if "iperf_full" in entry:
|
|
|
|
if "Reverse mode" in entry["iperf_full"]:
|
|
|
|
try:
|
|
|
|
reverse_sender.append(float(entry["sender_bitrate"]))
|
|
|
|
reverse_receiver.append(float(entry["receiver_bitrate"]))
|
|
|
|
reverse_distances.append(entry["start_distance"])
|
|
|
|
except:
|
|
|
|
message = entry["iperf_full"]
|
|
|
|
bitrates = re.findall(r"(\d+\.\d+) Mbits/sec", message)
|
|
|
|
|
|
|
|
reverse_sender.append(float(bitrates[-2]))
|
|
|
|
reverse_receiver.append(float(bitrates[-1]))
|
|
|
|
reverse_distances.append(entry["start_distance"])
|
|
|
|
else:
|
|
|
|
try:
|
|
|
|
sender.append(float(entry["sender_bitrate"]))
|
|
|
|
receiver.append(float(entry["receiver_bitrate"]))
|
|
|
|
distances.append(entry["start_distance"])
|
|
|
|
except:
|
|
|
|
message = entry["iperf_full"]
|
|
|
|
bitrates = re.findall(r"(\d+\.\d+) Mbits/sec", message)
|
|
|
|
|
|
|
|
sender.append(float(bitrates[-2]))
|
|
|
|
receiver.append(float(bitrates[-1]))
|
|
|
|
distances.append(entry["start_distance"])
|
|
|
|
|
|
|
|
# Plot the data
|
|
|
|
plt.figure(figsize=(10, 6))
|
2025-09-17 23:17:52 -04:00
|
|
|
plt.plot(distances, sender, label="Avg Uplink Sender Bitrate", marker="o", color="red")
|
2025-09-10 10:45:48 -04:00
|
|
|
plt.plot(
|
|
|
|
distances,
|
|
|
|
receiver,
|
2025-09-17 23:17:52 -04:00
|
|
|
label="Avg Uplink Receiver Bitrate",
|
2025-09-10 10:45:48 -04:00
|
|
|
marker="s",
|
|
|
|
color="darkorange",
|
|
|
|
)
|
|
|
|
plt.plot(
|
|
|
|
reverse_distances,
|
|
|
|
reverse_sender,
|
2025-09-17 23:17:52 -04:00
|
|
|
label="Avg Downlink Sender Bitrate",
|
2025-09-10 10:45:48 -04:00
|
|
|
marker="^",
|
|
|
|
color="blue",
|
|
|
|
)
|
|
|
|
plt.plot(
|
|
|
|
reverse_distances,
|
|
|
|
reverse_receiver,
|
2025-09-17 23:17:52 -04:00
|
|
|
label="Avg Downlink Receiver Bitrate",
|
2025-09-10 10:45:48 -04:00
|
|
|
marker="d",
|
|
|
|
color="blueviolet",
|
|
|
|
)
|
|
|
|
|
|
|
|
plt.title("IPERF vs Distance")
|
|
|
|
plt.xlabel("Distance (m)")
|
|
|
|
plt.ylabel("Bitrate (Mbits/s)")
|
|
|
|
plt.legend()
|
|
|
|
plt.grid(True)
|
|
|
|
plt.tight_layout()
|
|
|
|
|
|
|
|
# Show the plot
|
|
|
|
plt.show()
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
2025-09-17 23:17:52 -04:00
|
|
|
filename = '/home/madrigal/repos/range-testing/data/boat_relay_sept_17/test_1758127491_copy.json'
|
2025-09-10 10:45:48 -04:00
|
|
|
|
2025-09-17 23:17:52 -04:00
|
|
|
# plot_double_iperf(filename=filename)
|
|
|
|
plot_rsrp(filename=filename)
|
|
|
|
plot_rsrq(filename=filename)
|