Skip to content

Commit

Permalink
Make server files become templates for easy configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
steckhelena committed Jul 13, 2022
1 parent 15a481b commit 2a17bbe
Show file tree
Hide file tree
Showing 8 changed files with 74 additions and 16 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,7 @@ logs
__pycache__/
experiment_results
output/
godash_defaults/hypercorn_goDASHbed_quic.py
godash_defaults/hypercorn_goDASHbed.py
godash_defaults/CaddyFilev2QUIC
godash_defaults/CaddyFilev2TCP
2 changes: 1 addition & 1 deletion example.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@ python3 lab.py \
-d "RazaDatasets/5g/Static/B_2020.02.14_13.21.26.csv" -t5g\
-d "RazaDatasets/5g/Static/B_2020.02.27_18.39.27.csv" -t5g\
--godash-bin "/home/raza/Downloads/goDASH/godash/godash" \
--godash-config-template "/home/raza/Downloads/goDASHbed/config/configure.json" \
--dash-files-root "/home/raza/videofiles" \
--types wsgi
15 changes: 15 additions & 0 deletions fill_templates.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from jinja2 import Template


def fill_template(
template_file: str, output_file: str, dash_root: str, defaults_root: str
):
with open(template_file, "r") as f:
template = Template(f.read())

template_output = template.render(
root_dash_path=dash_root, godash_defaults_path=defaults_root
)

with open(output_file, "w") as f:
f.write(template_output)
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
}

www.godashbed.org:4444 {
tls /home/raza/Downloads/goDASH/godash/http/certs/cert.pem /home/raza/Downloads/goDASH/godash/http/certs/key.pem
tls {{godash_defaults_path}}/cert.pem {{godash_defaults_path}}/key.pem
encode gzip
root * /home/raza/videofiles
root * {{root_dash_path}}
file_server
log {
output file ./output/caddy_access.log
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
www.godashbed.org:443 {
tls /home/raza/Downloads/goDASH/godash/http/certs/cert.pem /home/raza/Downloads/goDASH/godash/http/certs/key.pem
tls {{godash_defaults_path}}/cert.pem {{godash_defaults_path}}/key.pem
encode gzip
root * /home/raza/videofiles
root * {{root_dash_path}}
file_server
log {
output file ./output/caddy_access.log
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@
from os import path

# this defines the root folder containing our DASH dataset
dash_content_path = '/home/raza/videofiles'
dash_content_path = {{root_dash_path}}

# define the config setup for our testbed
config = Config()
config.bind = ["10.0.0.1:443"] # port number to use for HTTPS
config.insecure_bind = ["10.0.0.1:80"] # port number to use for QUIC

# locations for the cert and key
config.certfile = "../goDASH/godash/http/certs/cert.pem"
config.keyfile = "../goDASH/godash/http/certs/key.pem"
config.certfile = "./cert.pem"
config.keyfile = "./key.pem"

# this 'root_path' is needed by QuartTrio to point to the DASH video content folder
app = QuartTrio(__name__, root_path=dash_content_path)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from os import path

# this defines the root folder containing our DASH dataset
dash_content_path = '/home/raza/videofiles'
dash_content_path = {{root_dash_path}}

# define the config setup for our testbed
config = Config()
Expand All @@ -16,8 +16,8 @@
config.insecure_bind = ["10.0.0.1:80"] # port number to use for QUIC

# locations for the cert and key
config.certfile = "../goDASH/godash/http/certs/cert.pem"
config.keyfile = "../goDASH/godash/http/certs/key.pem"
config.certfile = "./cert.pem"
config.keyfile = "./key.pem"

# this 'root_path' is needed by QuartTrio to point to the DASH video content folder
app = QuartTrio(__name__, root_path=dash_content_path)
Expand Down
49 changes: 44 additions & 5 deletions lab.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from mininet.node import Host, Switch

from datasets5G import datasets5G
from fill_templates import fill_template
from normalize_datasets import NormalizedDataset, get_normalized_datasets
from process_results import cleanup_pcap, process_pcap

Expand Down Expand Up @@ -192,10 +193,14 @@ def get_experiment_checkpoint_file_name(experiment_root_folder: str) -> str:
return os.path.join(experiment_root_folder, "checkpoint.txt")


def get_defaults_path() -> pathlib.Path:
return pathlib.Path(__file__).parent.absolute() / "godash_defaults"


# server settings
def server(server: Host, experiment: Experiment):
load_experiment_config(experiment)
parent_dir = pathlib.Path(__file__).parent.absolute() / "godash_defaults"
parent_dir = get_defaults_path()

print(
f"sudo systemctl stop apache2.service && caddy start --config {parent_dir / 'CaddyFilev2QUIC'} --adapter caddyfile"
Expand Down Expand Up @@ -484,14 +489,14 @@ def parse_command_line_options():

parser.add_argument(
"--godash-bin",
help="Path to goDASH executable.",
help="<Required> Path to goDASH executable.",
type=str,
required=True,
)

parser.add_argument(
"--godash-config-template",
default=os.path.join(os.path.dirname(__file__), "configure.json"),
default=(get_defaults_path() / "configure.json").as_posix(),
help="""Path to goDASH configuration template. This will be the base for
the goDASH configuration, the fields 'quic', 'url' 'serveraddr' and
'adapt' will be overwritten for the running experiment. The other fields
Expand All @@ -509,11 +514,19 @@ def parse_command_line_options():
required=True,
)

parser.add_argument(
"--dash-files-root",
default="/var/www/html",
help="""This is the root to the DASH files to be served by the file
server, i.e. the path where the DASH segments are stored, the mpd paths
are relative to this.""",
)

parser.add_argument(
"-d",
"--dataset",
action="append",
help="""<Required> System path, relative or absolute, to the dataset
help="""System path, relative or absolute, to the dataset
which will be used to simulate the network conditions, can be added
multiple times, requires one -t/--dataset-type set for each. E.g.:
`-d a/b.csv -t4g -d b/c.csv -t5g`. If not provided defaults to the
Expand All @@ -524,7 +537,7 @@ def parse_command_line_options():
"-t",
"--dataset-type",
action="append",
help="""<Required> Type of the dataset. E.g.: 5g, 4g, 3g.""",
help="""Type of the dataset. E.g.: 5g, 4g, 3g.""",
)

parser.add_argument(
Expand Down Expand Up @@ -634,6 +647,32 @@ def parse_command_line_options():
with open(get_experiment_checkpoint_file_name(experiment_root)) as f:
done_experiment_hashes = set(f.read().splitlines())

# fill server templates before starting out:
fill_template(
(get_defaults_path() / "CaddyFilev2QUIC.jinja").as_posix(),
(get_defaults_path() / "CaddyFilev2QUIC").as_posix(),
parsed_commands.dash_files_root,
get_defaults_path().as_posix().rstrip("/"),
)
fill_template(
(get_defaults_path() / "CaddyFilev2TCP.jinja").as_posix(),
(get_defaults_path() / "CaddyFilev2TCP").as_posix(),
parsed_commands.dash_files_root,
get_defaults_path().as_posix().rstrip("/"),
)
fill_template(
(get_defaults_path() / "hypercorn_goDASHbed.py.jinja").as_posix(),
(get_defaults_path() / "hypercorn_goDASHbed.py").as_posix(),
parsed_commands.dash_files_root,
get_defaults_path().as_posix().rstrip("/"),
)
fill_template(
(get_defaults_path() / "hypercorn_goDASHbed_quic.py.jinja").as_posix(),
(get_defaults_path() / "hypercorn_goDASHbed_quic.py").as_posix(),
parsed_commands.dash_files_root,
get_defaults_path().as_posix().rstrip("/"),
)

for mpd_path in mpd_paths:
for dataset, mode in zip(normalized_datasets, dataset_modes):
for adaptation_algorithm in algos:
Expand Down

0 comments on commit 2a17bbe

Please sign in to comment.