Commit 880c0629 authored by Jean-Claude BAU's avatar Jean-Claude BAU

Scheduler configuration builders

parent fc11209c
#!/bin/sh
source schedLib.sh
#
# Options
#
STREAMS_PER_PORT=1 # default
LEARNING_PROCESS=1 # default
while getopts "s:l" arg; do
case $arg in
s)
STREAMS_PER_PORT=$OPTARG
;;
l)
LEARNING_PROCESS=0
;;
esac
done
SCHED_NAME="sched_fp_incr_63_s$STREAMS_PER_PORT"
if [ "$LEARNING_PROCESS" -eq "0" ] ; then
SCHED_NAME+="_nl"
fi
OUTPUT=$SCHED_NAME.xsch
rates=( 10 30 50 70 80 85 90 92 95 97 99 100 )
timeLowSec=( 40 20 15 15 15 15 15 15 15 15 15 15 )
timeHighSec=(550 300 120 105 90 75 70 70 70 70 70 70 )
minPacketSize=64
maxPacketSize=1522
packetSizeIncrement=63
packetSizes=`seq $minPacketSize $packetSizeIncrement $maxPacketSize`
packetSizes+=" 1522"
packetLimit=`echo "scale=0; 4000000/${STREAMS_PER_PORT}/1000000*1000000" | bc`
#packetLimit=10
#
# Start generation of the scheduler
#
schedHeader $SCHED_NAME
schedPortStopTraffic true ""
schedPortClearStats true ""
schedStreamEnableStream true ""
# Learning process
if [ "$LEARNING_PROCESS" -eq "1" ] ; then
schedStreamCustom true "" "PS_PACKETLIMIT 10"
schedStreamCustom true "" "PS_PACKETLENGTH FIXED 64 64"
schedStreamSetParameter true "" PS_RATEFRACTION 50.0
schedPortStartTraffic true ""
schedWait 2.0
schedPortStopTraffic true ""
fi
# Synchronize loggoing
schedPortClearStats true ""
schedWait 20.0
#
for packetSize in $packetSizes; do
schedStreamCustom true "" "PS_PACKETLENGTH FIXED $packetSize $packetSize"
for i in "${!rates[@]}"; do
rate=${rates[$i]}
ratePerPort=`echo "scale=2; $rate/$STREAMS_PER_PORT" | bc`
schedStreamSetParameter true "" PS_RATEFRACTION $ratePerPort
pckCount=`echo "scale=0;$packetLimit+($packetSize*100)+$rate" | bc`
schedStreamCustom true "" "PS_PACKETLIMIT $pckCount"
schedPortClearStats true ""
# Wait a little bit for logs
schedWait 6.0
schedPortStartTraffic true ""
# calculate duration
a=`echo "scale=4;(${timeHighSec[$i]}-${timeLowSec[$i]})/($maxPacketSize-$minPacketSize)" | bc`
b=`echo "scale=4;${timeHighSec[$i]}-($a*$maxPacketSize)" | bc`
y=`echo "scale=0;$a*$packetSize+$b" | bc`
schedWait $y
schedPortStopTraffic true ""
done
done
schedFooter
#!/bin/sh
source schedLib.sh
#
# Options
#
STREAMS_PER_PORT=1 # default
while getopts "s:" arg; do
case $arg in
s)
STREAMS_PER_PORT=$OPTARG
;;
esac
done
SCHED_NAME="sched_fp_incr_fixed_s$STREAMS_PER_PORT"
OUTPUT=$SCHED_NAME.xsch
rates=( 50 80 95 100 )
packetSizes="64 65 700 701 1521 1522"
bursTime=300
schedHeader $SCHED_NAME
# Learning process
schedStreamCustom true "" "PS_PACKETLIMIT 10"
schedStreamCustom true "" "PS_PACKETLENGTH FIXED 64 64"
# Synchronize logging
schedPortClearStats true ""
schedWait 20.0
#
schedStreamCustom true "" "PS_PACKETLIMIT 0" # Unlimited duration
for packetSize in $packetSizes; do
schedStreamCustom true "" "PS_PACKETLENGTH FIXED $packetSize $packetSize"
for i in "${!rates[@]}"; do
rate=${rates[$i]}
ratePerPort=`echo "scale=2; $rate/$STREAMS_PER_PORT" | bc`
schedStreamSetParameter true "" PS_RATEFRACTION $ratePerPort
schedPortClearStats true ""
# Wait a little bit for logs
schedWait 6.0
schedPortStartTraffic true ""
schedWait $bursTime
schedPortStopTraffic true ""
done
done
schedFooter
#!/bin/sh
source schedLib.sh
#
# Options
#
STREAMS_PER_PORT=1 # default
while getopts "s:" arg; do
case $arg in
s)
STREAMS_PER_PORT=$OPTARG
;;
esac
done
SCHED_NAME="sched_fp_incr_fixed_imb_s$STREAMS_PER_PORT"
OUTPUT=$SCHED_NAME.xsch
rates=( 50 80 95 100 )
packetSizes=( 64 65 700 701 1521 1522 )
#rates=( 30 40 50 )
#packetSizes=( 64 1522 )
bursTime=300.0
#bursTime=10.0
mainStreams="S-0-0-0-0,S-0-0-1-0"
mainPorts="P-0-0-0-0,P-0-0-0-1"
secondaryStreams="S-0-0-2-0,S-0-0-3-0"
secondaryPorts="P-0-0-0-2,P-0-0-0-3"
function waitTime() {
local duration=$1
schedWait $duration
}
function genLoopInternal() {
local ports=$1
local streams=$2
local packetSize=0
for packetSize in ${packetSizes[@]}; do
schedStreamCustom false $streams "PS_PACKETLENGTH FIXED $packetSize $packetSize"
for i in "${!rates[@]}"; do
local rate=${rates[$i]}
local ratePerPort=`echo "scale=2; $rate/$STREAMS_PER_PORT" | bc`
schedStreamSetParameter false $streams PS_RATEFRACTION $ratePerPort
schedPortClearStats true ""
# Wait a little bit for logs
schedWait 10.0
schedPortStartTraffic true ""
waitTime $bursTime
schedPortStopTraffic true ""
done
done
}
function genLoopMain() {
local ports=$1
local streams=$2
local packetSize=0
local i=0
for packetSize in ${packetSizes[@]}; do
schedStreamCustom false $streams "PS_PACKETLENGTH FIXED $packetSize $packetSize"
for i in "${!rates[@]}"; do
local rate=${rates[$i]}
local ratePerPort=`echo "scale=2; $rate/$STREAMS_PER_PORT" | bc`
schedStreamSetParameter false $streams PS_RATEFRACTION $ratePerPort
genLoopInternal $secondaryPorts $secondaryStreams
done
done
}
schedHeader $SCHED_NAME
# Learning process
schedPortStopTraffic true ""
schedStreamEnableStream true ""
schedStreamCustom true "" "PS_PACKETLIMIT 100"
schedStreamCustom true "" "PS_PACKETLENGTH FIXED 64 64"
schedStreamSetParameter true "" PS_RATEFRACTION 50.0
schedPortStartTraffic true ""
schedWait 2.0
schedPortStopTraffic true ""
# Synchronize logging
schedPortClearStats true ""
schedWait 20.0
schedStreamCustom true "" "PS_PACKETLIMIT 0" # Unlimited duration
genLoopMain $mainPorts $mainStreams
schedFooter
OUTPUT="/dev/stdout"
SCHED_NAME="SchedName"
CHASSIS_ID="b256ebe4-f6f8-4d42-a0bb-bf5e8ceb8b45"
function schedHeader() {
SCHED_NAME=$1
echo "{"
echo "\"Operations\": ["
} > $OUTPUT
function schedFooter() {
echo "],"
echo "\"ParentId\": \"\","
echo "\"DisplayName\": \"$SCHED_NAME\""
echo "}"
} >> $OUTPUT
function getPortTaget() {
local str=$1
local ret="{"
local streamId=0
local moduleId=0
local portId=0
if [ -z "$str" ] ; then echo ""; return 0; fi
if [[ $str =~ ^S ]] ; then
portId=`echo $str| grep -o -e [0-9] | sed '3q;d'`
moduleId=`echo $str| grep -o -e [0-9] | sed '2q;d'`
streamId=`echo $str| grep -o -e [0-9] | sed '4q;d'`
ret+="\"StreamId\": $streamId,"
else
portId=`echo $str| grep -o -e [0-9] | sed '4q;d'`
moduleId=`echo $str| grep -o -e [0-9] | sed '3q;d'`
fi
ret+="\"ChassisId\": \"$CHASSIS_ID\","
ret+="\"ModuleIndex\": $moduleId,"
ret+="\"PortIndex\": $portId"
ret+="}"
echo $ret
}
function getPortTagetList() {
local str=$1
if [ -z "$str" ] ; then echo ""; return 0; fi
declare -a tokens
OLDIFS=$IFS
IFS="," read -r -a tokens <<< "$str"
IFS=$OLDIFS
for tk in ${tokens[@]} ; do
getPortTaget $tk
echo ","
done
}
function schedStreamTemplate() {
local operType="$1"
local operValue="$2"
local displayName="$3"
local allTargets="$4"
local streamTargets="$5"
echo "{"
echo " \"OperType\": \"$operType\","
echo " \"ParamType\": 0,"
if [ -z "$operValue" ] ; then
echo " \"OperValue\": null,"
else
echo " \"OperValue\": \"$operValue\","
fi
local pt=$( getPortTagetList $streamTargets )
echo " \"PortTargetList\": [$pt],"
echo " \"StreamTargetList\": [$pt],"
echo " \"AllTargetsSelected\": $allTargets,"
echo " \"DisplayName\": \"$displayName\","
echo " \"Operations\": [],"
echo " \"ParentId\": \"\""
echo "},"
}
function schedPortTemplate() {
schedStreamTemplate "$1" "$2" "$3" "$4" "$5"
}
function schedPortStopTraffic() {
schedPortTemplate StopTraffic "" "Stop Traffic" "$1" "$2"
} >> $OUTPUT
function schedPortStartTraffic() {
schedPortTemplate StartTraffic "" "Start Traffic" "$1" "$2"
} >> $OUTPUT
function schedPortClearStats() {
schedPortTemplate ClearStats "" "Clear Statistics" "$1" "$2"
} >> $OUTPUT
function schedStreamEnableStream() {
schedStreamTemplate EnableStream "" "Enable Stream" "$1" "$2"
} >> $OUTPUT
function schedStreamCustom() {
schedStreamTemplate CustomStreamCommand "$3" "Enable Stream" "$1" "$2"
} >> $OUTPUT
function schedStreamSetParameter() {
local allTargets=$1
local streamTargets=$2
local streamParameter=$3
local steamParameterValue=$4
echo "{"
echo " \"OperType\": \"SetParamValue\","
echo " \"ParamType\": \"$streamParameter\","
echo " \"OperValue\": $steamParameterValue,"
local pt=$( getPortTagetList $streamTargets )
echo " \"PortTargetList\": [$pt],"
echo " \"StreamTargetList\": [$pt],"
echo " \"AllTargetsSelected\": $allTargets,"
echo " \"DisplayName\": \"Set Parameter Value\","
echo " \"Operations\": [],"
echo " \"ParentId\": \"\""
echo "},"
} >> $OUTPUT
function schedWait() {
local seconds=$1
echo "{"
echo " \"OperType\": \"Wait\","
echo " \"ParamType\": 0,"
echo " \"OperValue\": $seconds,"
echo " \"PortTargetList\": [],"
echo " \"StreamTargetList\": [],"
echo " \"AllTargetsSelected\": true,"
echo " \"DisplayName\": \"Wait Period\","
echo " \"Operations\": [],"
echo " \"ParentId\": \"\""
echo "},"
} >> $OUTPUT
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment