diff --git a/common/scripts/mesh-11s_nats.sh b/common/scripts/mesh-11s_nats.sh index 82766015c..5344ba6cd 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 @@ -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 "$id0_MESH_VIF" fi echo "$wifidev down.." @@ -393,7 +394,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 +685,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..c92120b05 --- /dev/null +++ b/common/scripts/qos_olsrd_conf.sh @@ -0,0 +1,61 @@ +#!/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" + PID_FILE="/run/olsrd-$INTERFACE.pid" + CONFIG_FILE="/etc/olsrd/$INTERFACE.conf" + + echo "Testing in OLSR" + + cat > "$CONFIG_FILE" <<- EOF + LinkQualityFishEye 0 + + Interface "$INTERFACE" + { + } + + IpVersion 6 + LinkQualityFishEye 0 + LinkQualityAlgorithm "etx_ffeth_nl80211" + + LoadPlugin "/usr/lib/olsrd_arprefresh.so.0.1" + { + } +EOF + + # 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() { + 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/common/tests/functional/Test-throughput.sh b/common/tests/functional/Test-throughput.sh new file mode 100644 index 000000000..b8409b319 --- /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 'iperf3 -s' (e.g. somehost)" + echo + echo "Example:" + echo " $(basename $0) 10 somehost" + echo + echo "The above will run 'iperf3 -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 + + + 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