From dc2e8516555663a9753c16fcfa07983ce6ee394c Mon Sep 17 00:00:00 2001 From: haskal Date: Tue, 10 Mar 2020 23:21:47 -0400 Subject: [PATCH] Create test environment --- .gitignore | 3 ++- .rustup/settings.toml | 4 ++++ Makefile | 8 ++++++++ rust-toolchain | 1 + scripts/create-net-ns.sh | 10 ++++++++++ 5 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 .rustup/settings.toml create mode 100644 rust-toolchain create mode 100755 scripts/create-net-ns.sh diff --git a/.gitignore b/.gitignore index f0fbb80..56e7c6c 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,5 @@ target *~ *\# 3700send -3700recv \ No newline at end of file +3700recv +.netsim diff --git a/.rustup/settings.toml b/.rustup/settings.toml new file mode 100644 index 0000000..1551bc9 --- /dev/null +++ b/.rustup/settings.toml @@ -0,0 +1,4 @@ +profile = "default" +version = "12" + +[overrides] diff --git a/Makefile b/Makefile index 65a1091..a72b931 100644 --- a/Makefile +++ b/Makefile @@ -25,3 +25,11 @@ t: test rustup install nightly rustup install stable touch $@ + +.netsim: + mkdir $@ + curl -Ss https://course.ccs.neu.edu/cs3700sp20/archive/tcp-sim.tgz | tar xzf - -C $@ + sed -i '/.usr.bin.sudo/d' .netsim/netsim + +netsim-shell: .netsim + ./scripts/create-net-ns.sh diff --git a/rust-toolchain b/rust-toolchain new file mode 100644 index 0000000..bf867e0 --- /dev/null +++ b/rust-toolchain @@ -0,0 +1 @@ +nightly diff --git a/scripts/create-net-ns.sh b/scripts/create-net-ns.sh new file mode 100755 index 0000000..b54edea --- /dev/null +++ b/scripts/create-net-ns.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd)" +cd $(dirname $DIR) + +sudo unshare -n capsh --caps="cap_net_admin+eip cap_setpcap,cap_setuid,cap_setgid+ep" --keep=1 \ + --user=$USER --addamb=cap_net_admin \ + -- -c "export PATH=$PWD/.netsim:\$PATH; export HOME=$PWD; /usr/bin/ip link set lo up; netsim; \ + tc qdisc show dev lo; /bin/bash --init-file <(echo unset HISTFILE)" +true