Skip to content

Commit b731ddc

Browse files
authored
Merge branch 'main' into dev
2 parents 13c5cdf + e4132b1 commit b731ddc

File tree

6 files changed

+41
-36
lines changed

6 files changed

+41
-36
lines changed

live_capture.py

Lines changed: 22 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
#----------------------------------------------------------------------------
44
# Created By : Bryson Schiel - @schielb (GitHub)
55
# Created Date: Feb 1, 2023
6-
# Latest Update: Feb 15, 2023
7-
# version ='1.0'
6+
# Latest Update: May 25, 2023
7+
# version ='1.1'
88
# ---------------------------------------------------------------------------
99
"""
1010
A python file to iteratively test different attenuation values on
@@ -19,7 +19,7 @@
1919
from threading import Event, Thread
2020
import time
2121
import os
22-
from datetime import date
22+
from datetime import datetime
2323
import matplotlib.pyplot as plt
2424

2525
def call_repeatedly(interval, func, *args):
@@ -81,37 +81,38 @@ def uniquify(path):
8181

8282
return path
8383

84+
cap_folder_name = "Packet_Captures/" + datetime.now().strftime("%b-%d-%H:%M:%S")
85+
res_folder_name = "Results/" + datetime.now().strftime("%b-%d-%H:%M:%S")
86+
87+
#See if we need to create a new folder and csv file for today for today
88+
for newpath in [cap_folder_name, res_folder_name]:
89+
if not os.path.exists(newpath):
90+
os.makedirs(newpath)
91+
92+
###############################################################################
93+
# At this point, folders have been set up, now we will gather the attenuations.
94+
###############################################################################
8495
for attenuation in yaml_data["attenuations"]:
8596
# Clear the data and declare the start of the trial
8697
clear_data()
8798
print("\x1B[32mSetting up trial on attenuation value\x1B[35m %d\x1B[32m db for\x1B[35m %d\x1B[32m seconds...\x1B[37m"
8899
% (attenuation, yaml_data["trial_length"]))
89100

90-
cap_folder_name = "Packet_Captures/" + date.today().strftime("%b-%d")
91-
res_folder_name = "Results/" + date.today().strftime("%b-%d")
92-
93-
#See if we need to create a new folder and csv file for today for today
94-
for newpath in [cap_folder_name, res_folder_name]:
95-
if not os.path.exists(newpath):
96-
os.makedirs(newpath)
97-
98101
cap_file_name = uniquify(cap_folder_name + "/attenuation_%d.pcap" % attenuation)
99102

100103
cap = pyshark.LiveCapture(interface=yaml_data["wireshark_interface"],
101104
bpf_filter="udp and not src host %s" % yaml_data['host_ip'],
102105
output_file=cap_file_name)
103106

104-
105107

106108
# Go through and set all the attenuation values we need
107109
for tx_port in yaml_data["static_mesh_ports"]:
108110
for rsu in rsus.keys():
109111
rx_port = rsus[rsu]["mesh_port"]
110-
partial_att = rsus[rsu]["att_offset"]
112+
partial_att = rsus[rsu]["static_att"]
111113
diff_att = attenuation - partial_att
112114
diff_att = round(diff_att * 4) / 4 # needs a multiple of 0.25
113115

114-
#print('dbg: mesh.set_att(%s, %s, %f)' % (tx_port, rx_port, diff_att))
115116
mesh.set_att(tx_port, rx_port, diff_att)
116117

117118
time.sleep(10) # Delay to allow new setup to settle
@@ -130,31 +131,22 @@ def uniquify(path):
130131
pass
131132
finally:
132133
end_timer()
133-
#timer.cancel()
134134
print()
135135
print("\x1B[32mEnding trial for\x1B[35m %d\x1B[32m db\x1B[37m" % attenuation, end="\n")
136136

137137
print("Saving data from trial...")
138-
# Save the results in their own files
139-
res_folder_name = "Results/" + date.today().strftime("%b-%d")
140-
141-
#See if we need to create a new folder and csv file for today for today
142-
if not os.path.exists(res_folder_name):
143-
os.makedirs(res_folder_name)
138+
144139

140+
# Save the results in their own files
145141
cap.close()
146142
for rsu in rsus:
147143

148-
149144
total_time_gap = yaml_data["trial_length"]
150145
num_packets = data[rsu]
151146

152147
estimated_num_spaced = int(total_time_gap * 10)
153148
percent_reception = float(float(num_packets) / float(estimated_num_spaced))
154149

155-
156-
157-
158150
summaries_file_name = '%s/summaries_%s.txt' % (res_folder_name, rsu)
159151

160152
print("Saving %s data in %s" % (rsu, summaries_file_name))
@@ -173,10 +165,9 @@ def uniquify(path):
173165
# At this point, all attenuations have been gathered, and we are ready to display the results.
174166
##############################################################################################
175167

176-
folder_name = "Results/" + date.today().strftime("%b-%d")
177-
168+
# Display each individual RSU's performance
178169
for rsu in rsus:
179-
file_name = folder_name + "/summaries_%s.txt" % rsu
170+
file_name = res_folder_name + "/summaries_%s.txt" % rsu
180171

181172
values = []
182173

@@ -213,9 +204,10 @@ def uniquify(path):
213204
plt.ylim(-4, 104)
214205
plt.axhline(y=90, color='red', linestyle='--', label='Critical Safety Limit: 90%')
215206
plt.show()
216-
plt.savefig(folder_name + '/Attenuations-%s.png' % rsu)
207+
plt.savefig(res_folder_name + '/Attenuations-%s.png' % rsu)
217208
plt.clf()
218209

210+
# Display all performances on a single graph for comparison
219211
for rsu in rsus:
220212
plt.plot(data['att'], data[rsu]['rate'], label=rsu, marker = 'o')
221213

@@ -225,7 +217,7 @@ def uniquify(path):
225217
plt.title("Reception Rate per Attenuation (All RSU Comparison)")
226218
plt.axhline(y=90, color='red', linestyle='--', label='Critical Safety Limit: 90%')
227219
plt.legend()
228-
plt.savefig(folder_name + '/Comparison-Attenuations.png')
220+
plt.savefig(res_folder_name + '/Comparison-Attenuations.png')
229221
plt.show()
230222
plt.clf()
231223

resources/Indoor_Setup.png

29.7 KB
Loading

resources/build.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
#----------------------------------------------------------------------------
44
# Created By : Bryson Schiel - @schielb (GitHub)
55
# Created Date: Feb 6, 2023
6-
# Latest Update: Feb 15, 2023
7-
# version ='1.0'
6+
# Latest Update: May 22, 2023
7+
# version ='1.1'
88
# ---------------------------------------------------------------------------
99
"""
1010
Python file to setup initial files that aren't included due to the
@@ -25,7 +25,7 @@
2525
"# src_port: <src port at RSU>\n" \
2626
"# dst_port: <destination port at host>\n" \
2727
"# mesh_port: <A-F single character on mesh ports>\n" \
28-
"# att_offset: <attenuation offset for RSU (float value)>\n" \
28+
"# static_att: <attenuation offset for RSU (float value)>\n" \
2929
"#\n" \
3030
"# An example has already been provided for you below...\n\n" \
3131
"################### META PARAMETERS ###################\n" \
@@ -40,7 +40,7 @@
4040
"\n" \
4141
"# List of total attenuation values to test\n" \
4242
"# An example list from our lab experiment is [90, 100, 105, 107, 109, 111, 113, 115]\n" \
43-
"# IMPORTANT!!! Make sure that these are all higher than any 'att_offset' in your RSUs!!!\n" \
43+
"# IMPORTANT!!! Make sure that these are all higher than any 'static_att' in your RSUs!!!\n" \
4444
"attenuations: [90, 100, 105, 107, 109, 111, 113, 115]\n" \
4545
"\n" \
4646
"# Time length of a trial in seconds (integer)\n" \
@@ -53,10 +53,9 @@
5353
"rsus:\n" \
5454
" rsu_1:\n" \
5555
" ip: 192.168.0.1\n" \
56-
" src_port: 8080\n" \
5756
" dst_port: 8081\n" \
5857
" mesh_port: B\n" \
59-
" att_offset: 50.0"
58+
" static_att: 50.0"
6059

6160
with open('cv2x.yml', 'w') as rsu_yaml:
6261
rsu_yaml.write(yaml_string)

resources/clear_mesh.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,5 @@
4545
for port2 in port2s:
4646
if port1 != port2:
4747
mesh.set_att(port1, port2, att_to_set)
48+
49+

resources/mesh_class.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,18 @@ def __init__(self, address):
8181
"""
8282
self.address = address
8383

84+
ports = channels["AB"]
85+
block = ports[0]
86+
channel = ports[1]
87+
88+
http = urllib3.PoolManager()
89+
response = http.request(
90+
'GET', f"http://{self.address}/:0{block}:CHAN:{channel}:ATT?")
91+
92+
if response.status != 200:
93+
raise ValueError('Device at %s is not a viable mesh attenuator.' % address)
94+
95+
8496
def set_att(self, port1: str, port2: str, atten: float):
8597
"""
8698
set_att:

resources/wireshark_rsu_data.png

6.45 KB
Loading

0 commit comments

Comments
 (0)