From 348a232c34abec2f213646810d972276859c8188 Mon Sep 17 00:00:00 2001 From: francislin12 Date: Wed, 29 Nov 2023 20:39:31 +0400 Subject: [PATCH 1/4] To enable QoS-OLSR in MS2.0 --- common/scripts/mesh-11s_nats.sh | 7 +- common/scripts/qos_olsrd_conf.sh | 49 +++++++++++++ common/tests/functional/Test-throughput.sh | 80 ++++++++++++++++++++++ 3 files changed, 133 insertions(+), 3 deletions(-) create mode 100755 common/scripts/qos_olsrd_conf.sh create mode 100644 common/tests/functional/Test-throughput.sh diff --git a/common/scripts/mesh-11s_nats.sh b/common/scripts/mesh-11s_nats.sh index 82766015c..90151a90b 100755 --- a/common/scripts/mesh-11s_nats.sh +++ b/common/scripts/mesh-11s_nats.sh @@ -1,5 +1,5 @@ #!/bin/bash - +source ./qos_olsrd_conf.sh is_interface() { # arguments: # $1 = interface name @@ -393,7 +393,8 @@ EOF elif [ "$routing_algo" == "olsr" ]; then ifconfig "$wifidev" "$ipaddr" netmask "$nmask" # Enable debug level as necessary - (olsrd -i "$wifidev" -d 0)& + #(olsrd -i "$wifidev" -d 0)& + start_olsrd "$id0_MESH_VIF" fi #SLAAC immediately after basic setup @@ -683,7 +684,7 @@ main () { bridge_ip=$bridge_ip calculate_network_address "$bridge_ip" "$nmask" fi - if [ $mptcp == "enable" ]; then + if [ "$mptcp" == "enable" ]; then echo "MPTCP enabled" if ! [ -f /var/run/mptcp.conf ]; then echo "SUBFLOWS=0" > /var/run/mptcp.conf diff --git a/common/scripts/qos_olsrd_conf.sh b/common/scripts/qos_olsrd_conf.sh new file mode 100755 index 000000000..67dae070f --- /dev/null +++ b/common/scripts/qos_olsrd_conf.sh @@ -0,0 +1,49 @@ +#!/bin/bash + +get_ipv6_address() { + local interface="$1" + + # Use ifconfig to get the IPv6 address of the specified interface + local ipv6_address=$(ifconfig "$interface" | grep 'inet6' | awk '{print $2}') + + # Print the IPv6 address + echo "IPv6 address of $interface: $ipv6_address" + + +# Example usage +desired_interface=$1 +get_ipv6_address "$desired_interface" +} + + +start_olsrd() +{ + INTERFACE="$1" + echo "testing in olsr" + cat > /etc/olsrd/$INTERFACE.conf <<- EOF + LinkQualityFishEye 0 + + Interface "$INTERFACE" + { + } + + IpVersion 6 + LinkQualityFishEye 0 + LinkQualityAlgorithm "etx_ffeth_nl80211" + + LoadPlugin "/usr/lib/olsrd_arprefresh.so.0.1" + { + } + +EOF + qos-olsrd -i "$INTERFACE" -d 0 -f /etc/olsrd/$INTERFACE.conf + // -p /run/olsrd-$INTERFACE.pid +} + +stop_olsrd() +{ + + // killall olsrd 2>/dev/null +} + + diff --git a/common/tests/functional/Test-throughput.sh b/common/tests/functional/Test-throughput.sh new file mode 100644 index 000000000..3bc0cefee --- /dev/null +++ b/common/tests/functional/Test-throughput.sh @@ -0,0 +1,80 @@ +#!/bin/bash +#Francis +if ! [ -x "$(type -P iperf3)" ]; then + echo "ERROR: script requires iperf3" + echo "For Debian and friends get it with 'apt-get install iperf3'" + echo "If you have it, perhaps you don't have permissions to run it, try 'sudo $(basename $0)'" + exit 1 +fi + +if [ "$#" -ne "2" ]; then + echo "ERROR: script needs four arguments, where:" + echo + echo "1. Number of times to repeat test (e.g. 10)" + echo "2. Host running 'iperf -s' (e.g. somehost)" + echo + echo "Example:" + echo " $(basename $0) 10 somehost" + echo + echo "The above will run 'iperf -c' 10 times on the client and report totals and average." + exit 1 +else + runs=$1 + host=$2 +fi + +log=qos_olsr.txt + +if [ -f "$log" ]; then + echo removing $log + rm $log +fi + +echo "==================================================================" +echo " Results" +echo "==================================================================" +echo " target host .... $host" +echo "------------------------------------------------------------------" + +for run in $(seq 1 $runs); do + iperf3 -c $host -f m >> $log + echo -e " run $run: \t $(awk '/Bitrate/ {getline}; END{print $7, $8}' $log)" +done + + +echo +echo "see $log for details" + +####################################################################### +# Define the file path +file_path=$log + +# Check if the file exists +if [ -f "$file_path" ]; then + # Use grep and awk to extract Bitrate from the receiver line in the file + average_bitrate=$(awk '/receiver/ {sum += $7; count++} END {if (count > 0) print sum/count}' "$file_path") + + # Check if the value was found + if [ -n "$average_bitrate" ]; then + echo "average_bitrate: $average_bitrate Mbits/sec" + else + echo "average_bitrate receiver not found in the file." + fi +else + echo "File not found: $file_path" +fi + + + +######################################################################## +if [ -n "$average_bitrate" ]; then + # Compare the Bitrate value with 25 + if (( $(echo "$average_bitrate > 25" | bc -l) )); then + echo "Average Bitrate receiver: $average_bitrate Mbits/sec - Pass" + else + echo "Bitrate receiver: $average_bitrate Mbits/sec - Fail" + fi +fi + + + From 3bc2a4c6d40f3235e4def76ffb45fa6c152e22be Mon Sep 17 00:00:00 2001 From: francislin12 Date: Fri, 1 Dec 2023 15:26:37 +0400 Subject: [PATCH 2/4] Make some changes based on the comments --- common/scripts/mesh-11s_nats.sh | 3 ++- common/scripts/qos_olsrd_conf.sh | 16 +++++++++++----- common/tests/functional/Test-throughput.sh | 6 +++--- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/common/scripts/mesh-11s_nats.sh b/common/scripts/mesh-11s_nats.sh index 90151a90b..98e7b20a6 100755 --- a/common/scripts/mesh-11s_nats.sh +++ b/common/scripts/mesh-11s_nats.sh @@ -343,7 +343,8 @@ EOF modprobe batman-adv fi elif [ "$routing_algo" == "olsr" ]; then - mesh_kill "[o]lsrd -i $wifidev -d 0" + #mesh_kill "[o]lsrd -i $wifidev -d 0" + stop_olsrd fi echo "$wifidev down.." diff --git a/common/scripts/qos_olsrd_conf.sh b/common/scripts/qos_olsrd_conf.sh index 67dae070f..7dbc65ad5 100755 --- a/common/scripts/qos_olsrd_conf.sh +++ b/common/scripts/qos_olsrd_conf.sh @@ -36,14 +36,20 @@ start_olsrd() } EOF - qos-olsrd -i "$INTERFACE" -d 0 -f /etc/olsrd/$INTERFACE.conf + qos-olsrd -i "$INTERFACE" -d 0 -f "/etc/olsrd/$INTERFACE.conf" // -p /run/olsrd-$INTERFACE.pid } -stop_olsrd() + +stop_olsrd() { - - // killall olsrd 2>/dev/null + pid_file="/run/qos-olsrd.pid" + + if [ -e "$pid_file" ]; then + echo "Stopping daemon using start-stop-daemon" + start-stop-daemon --stop --pidfile "$pid_file" + else + echo "PID file $pid_file not found. Daemon may not be running." + fi } - diff --git a/common/tests/functional/Test-throughput.sh b/common/tests/functional/Test-throughput.sh index 3bc0cefee..b8409b319 100644 --- a/common/tests/functional/Test-throughput.sh +++ b/common/tests/functional/Test-throughput.sh @@ -11,12 +11,12 @@ if [ "$#" -ne "2" ]; then echo "ERROR: script needs four arguments, where:" echo echo "1. Number of times to repeat test (e.g. 10)" - echo "2. Host running 'iperf -s' (e.g. somehost)" + echo "2. Host running 'iperf3 -s' (e.g. somehost)" echo echo "Example:" echo " $(basename $0) 10 somehost" echo - echo "The above will run 'iperf -c' 10 times on the client and report totals and average." + echo "The above will run 'iperf3 -c' 10 times on the client and report totals and average." exit 1 else runs=$1 @@ -47,7 +47,7 @@ echo "see $log for details" ####################################################################### # Define the file path -file_path=$log +file_path="$log" # Check if the file exists if [ -f "$file_path" ]; then From 693d32e1c3832f7120ee228fcaeda7f571a7676b Mon Sep 17 00:00:00 2001 From: francislin12 Date: Thu, 7 Dec 2023 09:04:29 +0400 Subject: [PATCH 3/4] Add start for start-stop-daemon --- common/scripts/qos_olsrd_conf.sh | 60 ++++++++++++++++-------------- modules/utils/docker/entrypoint.sh | 2 +- 2 files changed, 34 insertions(+), 28 deletions(-) diff --git a/common/scripts/qos_olsrd_conf.sh b/common/scripts/qos_olsrd_conf.sh index 7dbc65ad5..c92120b05 100755 --- a/common/scripts/qos_olsrd_conf.sh +++ b/common/scripts/qos_olsrd_conf.sh @@ -16,40 +16,46 @@ get_ipv6_address "$desired_interface" } -start_olsrd() -{ + +start_olsrd() { INTERFACE="$1" - echo "testing in olsr" - cat > /etc/olsrd/$INTERFACE.conf <<- EOF - LinkQualityFishEye 0 + PID_FILE="/run/olsrd-$INTERFACE.pid" + CONFIG_FILE="/etc/olsrd/$INTERFACE.conf" + + echo "Testing in OLSR" + + cat > "$CONFIG_FILE" <<- EOF + LinkQualityFishEye 0 - Interface "$INTERFACE" - { - } + Interface "$INTERFACE" + { + } - IpVersion 6 - LinkQualityFishEye 0 - LinkQualityAlgorithm "etx_ffeth_nl80211" + IpVersion 6 + LinkQualityFishEye 0 + LinkQualityAlgorithm "etx_ffeth_nl80211" - LoadPlugin "/usr/lib/olsrd_arprefresh.so.0.1" - { - } - + LoadPlugin "/usr/lib/olsrd_arprefresh.so.0.1" + { + } EOF - qos-olsrd -i "$INTERFACE" -d 0 -f "/etc/olsrd/$INTERFACE.conf" - // -p /run/olsrd-$INTERFACE.pid -} + # Use start-stop-daemon to start the OLSR daemon + start-stop-daemon --start --background --make-pidfile --pidfile "$PID_FILE" \ + --exec /usr/sbin/qos-olsrd -- -i "$INTERFACE" -d 0 -f "$CONFIG_FILE" +} -stop_olsrd() -{ - pid_file="/run/qos-olsrd.pid" - if [ -e "$pid_file" ]; then - echo "Stopping daemon using start-stop-daemon" - start-stop-daemon --stop --pidfile "$pid_file" - else - echo "PID file $pid_file not found. Daemon may not be running." - fi +stop_olsrd() { + INTERFACE="$1" + PID_FILE="/run/olsrd-$INTERFACE.pid" + + if [ -e "$PID_FILE" ]; then + echo "Stopping OLSR daemon for $INTERFACE using start-stop-daemon" + start-stop-daemon --stop --pidfile "$PID_FILE" + rm -f "$PID_FILE" # Remove the PID file after stopping the daemon + else + echo "PID file $PID_FILE not found. OLSR daemon may not be running." + fi } diff --git a/modules/utils/docker/entrypoint.sh b/modules/utils/docker/entrypoint.sh index 529a44c36..43b24b017 100755 --- a/modules/utils/docker/entrypoint.sh +++ b/modules/utils/docker/entrypoint.sh @@ -17,7 +17,7 @@ MCC_SETTINGS="$MESH_FOLDER/modules/utils/docker/mcc_settings.sh" # script to set MESH_CONF="/opt/mesh.conf" -QOS_OLSR_CONF="$MESH_FOLDER/modules/utils/docker/qos_olsrd_conf.sh" # script to setup qos_olsrd_cochmod +x $BRIDGE_SETTINGS +QOS_OLSR_CONF="$MESH_FOLDER/qos_olsrd_conf.sh" # script to setup qos_olsrd_cochmod +x $BRIDGE_SETTINGS chmod +x $BRIDGE_SETTINGS chmod +x $MCC_SETTINGS chmod +x $QOS_OLSR_CONF From 8ca28418e88800e25e923cccd70b13670f5f1755 Mon Sep 17 00:00:00 2001 From: francislin12 Date: Thu, 7 Dec 2023 10:06:12 +0400 Subject: [PATCH 4/4] Add start for start-stop-daemon --- common/scripts/mesh-11s_nats.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/scripts/mesh-11s_nats.sh b/common/scripts/mesh-11s_nats.sh index 98e7b20a6..5344ba6cd 100755 --- a/common/scripts/mesh-11s_nats.sh +++ b/common/scripts/mesh-11s_nats.sh @@ -344,7 +344,7 @@ EOF fi elif [ "$routing_algo" == "olsr" ]; then #mesh_kill "[o]lsrd -i $wifidev -d 0" - stop_olsrd + stop_olsrd "$id0_MESH_VIF" fi echo "$wifidev down.."