320 lines
12 KiB
Python
320 lines
12 KiB
Python
|
import json
|
||
|
import re
|
||
|
|
||
|
import matplotlib.pyplot as plt
|
||
|
|
||
|
|
||
|
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:
|
||
|
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))
|
||
|
)
|
||
|
distances.append(entry["distance"])
|
||
|
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:
|
||
|
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))
|
||
|
)
|
||
|
distances.append(entry["distance"])
|
||
|
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))
|
||
|
plt.plot(distances, sender, label="Avg Sender Bitrate", marker="o", color="red")
|
||
|
plt.plot(
|
||
|
distances,
|
||
|
receiver,
|
||
|
label="Avg Receiver Bitrate",
|
||
|
marker="s",
|
||
|
color="darkorange",
|
||
|
)
|
||
|
plt.plot(
|
||
|
reverse_distances,
|
||
|
reverse_sender,
|
||
|
label="Avg Reverse Sender Bitrate",
|
||
|
marker="^",
|
||
|
color="blue",
|
||
|
)
|
||
|
plt.plot(
|
||
|
reverse_distances,
|
||
|
reverse_receiver,
|
||
|
label="Avg Reverse Receiver Bitrate",
|
||
|
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__":
|
||
|
# print("Connecting to host 10.46.0.1, port 5201\n[ 5] local 192.168.225.83 port 60164 connected to 10.46.0.1 port 5201\n[ ID] Interval Transfer Bitrate Retr Cwnd\n[ 5] 0.00-1.00 sec 361 KBytes 2.95 Mbits/sec 0 43.4 KBytes \n[ 5] 1.00-2.00 sec 329 KBytes 2.70 Mbits/sec 0 56.6 KBytes \n[ 5] 2.00-3.00 sec 782 KBytes 6.41 Mbits/sec 0 89.5 KBytes \n[ 5] 3.00-4.00 sec 379 KBytes 3.11 Mbits/sec 0 107 KBytes \n[ 5] 4.00-5.00 sec 569 KBytes 4.66 Mbits/sec 0 133 KBytes \n[ 5] 5.00-6.00 sec 379 KBytes 3.11 Mbits/sec 0 151 KBytes \n[ 5] 6.00-7.00 sec 632 KBytes 5.18 Mbits/sec 0 182 KBytes \n[ 5] 7.00-8.00 sec 569 KBytes 4.66 Mbits/sec 0 247 KBytes \n[ 5] 8.00-9.00 sec 379 KBytes 3.11 Mbits/sec 0 309 KBytes \n[ 5] 9.00-10.00 sec 442 KBytes 3.62 Mbits/sec 0 432 KBytes \n- - - - - - - - - - - - - - - - - - - - - - - - -\n[ ID] Interval Transfer Bitrate Retr\n[ 5] 0.00-10.00 sec 4.71 MBytes 3.95 Mbits/sec 0 sender\n[ 5] 0.00-10.82 sec 4.31 MBytes 3.34 Mbits/sec receiver\n\niperf Done.\n")
|
||
|
# print("Connecting to host 10.46.0.1, port 5201\n[ 5] local 192.168.225.83 port 44064 connected to 10.46.0.1 port 5201\n[ ID] Interval Transfer Bitrate Retr Cwnd\n[ 5] 0.00-1.00 sec 405 KBytes 3.32 Mbits/sec 0 44.8 KBytes \n[ 5] 1.00-2.00 sec 320 KBytes 2.62 Mbits/sec 0 57.9 KBytes \n[ 5] 2.00-3.00 sec 207 KBytes 1.69 Mbits/sec 0 65.8 KBytes \n[ 5] 3.00-4.00 sec 253 KBytes 2.07 Mbits/sec 0 79.0 KBytes \n[ 5] 4.00-5.00 sec 379 KBytes 3.11 Mbits/sec 0 93.5 KBytes \n[ 5] 5.00-6.00 sec 442 KBytes 3.62 Mbits/sec 0 124 KBytes \n[ 5] 6.00-7.00 sec 442 KBytes 3.62 Mbits/sec 0 176 KBytes \n[ 5] 7.00-8.00 sec 569 KBytes 4.66 Mbits/sec 0 249 KBytes \n[ 5] 8.00-9.00 sec 695 KBytes 5.69 Mbits/sec 0 333 KBytes \n[ 5] 9.00-10.00 sec 442 KBytes 3.62 Mbits/sec 0 433 KBytes \n- - - - - - - - - - - - - - - - - - - - - - - - -\n[ ID] Interval Transfer Bitrate Retr\n[ 5] 0.00-10.00 sec 4.06 MBytes 3.40 Mbits/sec 0 sender\n[ 5] 0.00-11.14 sec 3.48 MBytes 2.62 Mbits/sec receiver\n\niperf Done.\n")
|
||
|
|
||
|
plot_double_iperf(
|
||
|
filename="/home/madrigal/Documents/code/beach_apr4/collection_1743777162.json"
|
||
|
)
|
||
|
plot_rsrp(
|
||
|
filename="/home/madrigal/Documents/code/beach_apr4/collection_1743777162.json"
|
||
|
)
|
||
|
plot_rsrq(
|
||
|
filename="/home/madrigal/Documents/code/beach_apr4/collection_1743777162.json"
|
||
|
)
|
||
|
# plot_double_iperf(filename="/home/madrigal/Documents/code/beach_mar_7/collection_whip_antennas.json")
|
||
|
# plot_iperf(filename='/home/madrigal/Documents/code/collections_beach_jan_29/collection_1738178064.json')
|
||
|
# plot_bytes(filename="/home/madrigal/Documents/code/collections_beach_jan_29/collection_1738178064.json")
|
||
|
# plot_manual()
|