sim: change directory structure
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
ifdef DIR
|
||||
result_dir = $(DIR)
|
||||
else
|
||||
DIR := $(shell date '+%m_%d__%H_%M_%S')
|
||||
result_dir := result_$(DIR)
|
||||
endif
|
||||
|
||||
trials := 10
|
||||
packets := 50
|
||||
min_snr := -2
|
||||
max_snr := 25
|
||||
snr_steps := 1
|
||||
interval := 100
|
||||
|
||||
# logfile name: loop_(trials)_(npackets)_(snr)_(encoding)_interval
|
||||
LOGFILES=$(shell /bin/bash -c "echo $(result_dir)/loop_{1..$(trials)}_$(packets)_{$(min_snr)..$(max_snr)..$(snr_steps)}.0_{0..7}_$(interval).log")
|
||||
PCAPFILES=$(shell /bin/bash -c "echo $(result_dir)/ofdm_{1..$(trials)}_$(packets)_{$(min_snr)..$(max_snr)..$(snr_steps)}.0_{0..7}_$(interval).pcap")
|
||||
|
||||
all: $(result_dir)/plot.png
|
||||
|
||||
# Will parse logfiles and create a plot
|
||||
$(result_dir)/plot.png: $(LOGFILES)
|
||||
./parse.py $(result_dir) $(trials)
|
||||
|
||||
%.pcap:
|
||||
@echo $@
|
||||
$(eval PARAMS=$(shell python -c "print \"$@\".split(\"/\")[1]"))
|
||||
@echo PARAMS=$(PARAMS)
|
||||
$(eval TRIAL=$(shell python -c "print \"$(PARAMS)\".split(\"_\")[1]"))
|
||||
$(eval NPKTS=$(shell python -c "print \"$(PARAMS)\".split(\"_\")[2]"))
|
||||
$(eval SNR=$(shell python -c "print \"$(PARAMS)\".split(\"_\")[3]"))
|
||||
$(eval ENC=$(shell python -c "print \"$(PARAMS)\".split(\"_\")[4]"))
|
||||
$(eval INTVL=$(shell python -c "print \"$(PARAMS)\".split(\"_\")[5][:-5]"))
|
||||
@echo TRIAL=$(TRIAL)
|
||||
@echo NPKTS=$(NPKTS)
|
||||
@echo SNR=$(SNR)
|
||||
@echo ENC=$(ENC)
|
||||
@echo INTVL=$(INTVL)
|
||||
$(shell mkdir -p $(result_dir))
|
||||
./wifi_loopback_noGUI.py -t $(TRIAL) -n $(NPKTS) -c 1 -s $(SNR) -o 0 -e $(ENC) -i $(INTVL) -r $(result_dir)
|
||||
sleep 1
|
||||
|
||||
%.log: $(PCAPFILES)
|
||||
@echo $@
|
||||
$(eval PARAMS=$(shell python -c "print \"$@\".split(\"/\")[1]"))
|
||||
@echo PARAMS=$(PARAMS)
|
||||
$(eval TRIAL=$(shell python -c "print \"$(PARAMS)\".split(\"_\")[1]"))
|
||||
$(eval NPKTS=$(shell python -c "print \"$(PARAMS)\".split(\"_\")[2]"))
|
||||
$(eval SNR=$(shell python -c "print \"$(PARAMS)\".split(\"_\")[3]"))
|
||||
$(eval ENC=$(shell python -c "print \"$(PARAMS)\".split(\"_\")[4]"))
|
||||
$(eval INTVL=$(shell python -c "print \"$(PARAMS)\".split(\"_\")[5][:-4]"))
|
||||
@echo TRIAL=$(TRIAL)
|
||||
@echo NPKTS=$(NPKTS)
|
||||
@echo SNR=$(SNR)
|
||||
@echo ENC=$(ENC)
|
||||
@echo INTVL=$(INTVL)
|
||||
tshark -r $(result_dir)/ofdm_$(TRIAL)_$(NPKTS)_$(SNR)_$(ENC)_$(INTVL).pcap > $@
|
||||
Executable
+78
@@ -0,0 +1,78 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
import glob, os, re, sys
|
||||
import numpy as np
|
||||
import matplotlib.pyplot as plt
|
||||
import scipy as sp
|
||||
import scipy.stats as ss
|
||||
|
||||
log_info = []
|
||||
table = {}
|
||||
|
||||
enc_table = ["BPSK 1/2", "BPSK 3/4", "QPSK 1/2",
|
||||
"QPSK 3/4", "16QAM 1/2", "16QAM 3/4",
|
||||
"64QAM 2/3", "64QAM 3/4"]
|
||||
|
||||
path = sys.argv[1]
|
||||
ntrials = int(sys.argv[2])
|
||||
|
||||
snr_list = []
|
||||
|
||||
def mean_confidence_interval(data, confidence=0.95):
|
||||
a = 1.0 * np.array(data)
|
||||
n = len(a)
|
||||
m, se = np.mean(a), ss.sem(a)
|
||||
h = se * ss.t._ppf((1 + confidence)/2., n-1)
|
||||
return m, h
|
||||
|
||||
|
||||
for filename in glob.glob(os.path.join(path, "*.log")):
|
||||
params = filename.split("/")[1].split("_")
|
||||
print params
|
||||
|
||||
try:
|
||||
trial = int(params[1])
|
||||
npkts = int(params[2])
|
||||
snr = float(params[3])
|
||||
encode = int(params[4])
|
||||
except AssertionError:
|
||||
print "Log filename parse failed; exiting!"
|
||||
sys.exit()
|
||||
|
||||
pdrate = sum(1 for line in open(filename))/float(npkts)
|
||||
|
||||
if snr not in snr_list:
|
||||
snr_list.append(snr)
|
||||
|
||||
if encode not in table:
|
||||
table[encode] = {}
|
||||
if snr not in table[encode]:
|
||||
table[encode][snr] = []
|
||||
table[encode][snr].append(pdrate)
|
||||
|
||||
snr_list.sort()
|
||||
|
||||
for enc in sorted(table.keys()): # sort so legend labels are in order
|
||||
# Check first that we got all datapoints for each trial
|
||||
for snr in table[enc].keys():
|
||||
try:
|
||||
assert len(table[enc][snr]) == ntrials
|
||||
except AssertionError:
|
||||
print "You don't have enough datapoints; exiting!"
|
||||
sys.exit()
|
||||
|
||||
y = [mean_confidence_interval(table[enc][snr]) for snr in snr_list]
|
||||
|
||||
# print enc_table[enc], snr_list, y
|
||||
plt.errorbar(snr_list, [m for m,h in y],
|
||||
yerr=[h for m,h in y],
|
||||
marker='o',
|
||||
label="%s" % enc_table[enc])
|
||||
|
||||
plt.ylabel("PDR")
|
||||
plt.xlabel("SNR")
|
||||
plt.title("Delivery rate vs. SNR for different encoding schemes")
|
||||
plt.legend(loc="upper left")
|
||||
plt.savefig(os.path.join(path,"plot.png"))
|
||||
plt.show()
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user