diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index f531f58..d646d71 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -55,21 +55,31 @@ jobs: steps: - name: Checkout uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 - - name: Install wg + - name: Setup + working-directory: xray run: | sudo apt-get update sudo apt-get install -y wireguard - - name: Setup pipenv - working-directory: xray - run: | + sudo apt install -y wireguard-go python -m pip install --upgrade pip pip install pipenv pipenv install - name: Execute xray working-directory: xray - run: pipenv run python run.py --wg native --ascii --save-chart - - name: Upload results + run: | + pipenv run python run.py --wg native --ascii --save-output + pipenv run python run.py --wg wggo --ascii --save-output + pipenv run python run.py --wg neptun --ascii --save-output + - name: Upload graph results uses: actions/upload-artifact@v4 with: name: xray-results path: xray/results/*.png + - name: Results + working-directory: xray/results + run: | + for file in *.txt; do + echo "----- $file -----" + cat "$file" + echo "" + done diff --git a/.gitignore b/.gitignore index 4858f3b..9e8d980 100644 --- a/.gitignore +++ b/.gitignore @@ -4,7 +4,6 @@ **/*.csv **/*.pcap -**/*.png **/*.sk **/*.pk **/__pycache__ diff --git a/xray/.gitignore b/xray/.gitignore index 691c410..fbca225 100644 --- a/xray/.gitignore +++ b/xray/.gitignore @@ -1 +1 @@ -!xray_setup.png +results/ diff --git a/xray/analyze.py b/xray/analyze.py index f419c0c..a710e81 100644 --- a/xray/analyze.py +++ b/xray/analyze.py @@ -8,8 +8,8 @@ import mpl_ascii -def analyze(csv_path, pcap_path, count, test_type, png_path, ascii): - Analyzer(csv_path, pcap_path, count, test_type, png_path, ascii) +def analyze(csv_path, test_path, count, test_type, ascii, save_output): + Analyzer(csv_path, test_path, count, test_type, ascii, save_output) class CsvData: @@ -63,10 +63,10 @@ def __init__(self, pcap_path, test_type): class Analyzer: - def __init__(self, csv_name, pcap_name, count, test_type, png_path, ascii): + def __init__(self, csv_name, test_path, count, test_type, ascii, save_output): self.count = count self.csv_data = CsvData(csv_name) - self.pcap_data = PcapData(pcap_name, test_type) + self.pcap_data = PcapData(test_path + ".pcap", test_type) graphs = [ self.ordering_pie_chart, @@ -86,12 +86,12 @@ def __init__(self, csv_name, pcap_name, count, test_type, png_path, ascii): fn(ax[i, 1]) plt.show() - if png_path: - plt.savefig(png_path) + if save_output: + plt.savefig(test_path + ".png") if ascii: - mpl_ascii.AXES_WIDTH=100 - mpl_ascii.AXES_HEIGHT=40 + mpl_ascii.AXES_WIDTH = 70 + mpl_ascii.AXES_HEIGHT = 25 mpl.use("module://mpl_ascii") graphs = [ self.packet_ordering, @@ -102,12 +102,14 @@ def __init__(self, csv_name, pcap_name, count, test_type, png_path, ascii): rows = len(graphs) fig, ax = plt.subplots(nrows=rows) - # fig.tight_layout(pad=) + fig.tight_layout() for i, fn in enumerate(graphs): fn(ax[i]) plt.show() + if save_output: + plt.savefig(test_path + ".txt") def ordering_pie_chart(self, ax): in_order = count_ordered(self.csv_data.indices, self.count) diff --git a/xray/run.py b/xray/run.py index f8ffc93..363f7fb 100755 --- a/xray/run.py +++ b/xray/run.py @@ -21,12 +21,8 @@ def get_csv_name(wg, test_type, count): return f"results/xray_metrics_{wg.lower()}_{test_type}_{count}.csv" -def get_pcap_name(wg, test_type, count): - return f"results/{WG_IFC_NAME}_{wg.lower()}_{test_type}_{count}.pcap" - - -def get_png_name(wg, test_type, count): - return f"results/{WG_IFC_NAME}_{wg.lower()}_{test_type}_{count}.png" +def get_test_path(wg, test_type, count): + return f"results/{WG_IFC_NAME}_{wg.lower()}_{test_type}_{count}" class Wireguard(Enum): @@ -53,7 +49,7 @@ def setup_wireguard(wg, build_neptun): run_command(f"sudo ip link add dev {WG_IFC_NAME} type wireguard") elif wg == Wireguard.WgGo: wggo = ( - run_command("which wireguard", capture_output=True)[0] + run_command("which wireguard-go", capture_output=True)[0] .strip() .decode("utf-8") ) @@ -108,7 +104,7 @@ def main(): parser.add_argument("--count") parser.add_argument("--nobuild-neptun", action="store_true") parser.add_argument("--nobuild-xray", action="store_true") - parser.add_argument("--save-chart", action="store_true") + parser.add_argument("--save-output", action="store_true") parser.add_argument("--ascii", action="store_true") args = parser.parse_args() @@ -122,18 +118,18 @@ def main(): assert count > 0, f"Count must be at least one, but got {count}" build_neptun = args.nobuild_neptun is False build_xray = args.nobuild_xray is False - png_path = get_png_name(wg.name, test_type, count) if args.save_chart else None Path("results/").mkdir(parents=True, exist_ok=True) try: os.remove(get_csv_name(wg.name, test_type, count)) - os.remove(get_pcap_name(wg.name, test_type, count)) - os.remove(get_png_name(wg.name, test_type, count)) + os.remove(get_test_path(wg.name, test_type, count) + ".pcap") + os.remove(get_test_path(wg.name, test_type, count) + ".png") + os.remove(get_test_path(wg.name, test_type, count) + ".txt") except: # noqa: E722 pass setup_wireguard(wg, build_neptun) - tcpdump = start_tcpdump(get_pcap_name(wg.name, test_type, count)) + tcpdump = start_tcpdump(get_test_path(wg.name, test_type, count) + ".pcap") succeeded = True try: @@ -148,11 +144,11 @@ def main(): if succeeded: analyze( get_csv_name(wg.name, test_type, count), - get_pcap_name(wg.name, test_type, count), + get_test_path(wg.name, test_type, count), count, test_type, - png_path, - args.ascii + args.ascii, + args.save_output )