From: Eduardo Ramos Testillano Date: Sat, 28 Mar 2015 03:40:14 +0000 (+0100) Subject: Improvements & fixes X-Git-Tag: REFACTORING_TESTING_LIBRARY~212 X-Git-Url: https://git.teslayout.com/public/public/public/?a=commitdiff_plain;h=7bf36f6cec41494071f07699184d8230ccd8cb41;p=anna.git Improvements & fixes Improved deployment of examples. Default deployment dir depending on type of example. Added a new script to transform a raw pcap into diameter hex content & metadata, ready for launcher encoder. Launcher accepts now hexadecimal content with colons (as rawshark output) --- diff --git a/example/diameter/launcher/DEPLOY.sh b/example/diameter/launcher/DEPLOY.sh index eaec5b3..76ccd8b 100755 --- a/example/diameter/launcher/DEPLOY.sh +++ b/example/diameter/launcher/DEPLOY.sh @@ -8,7 +8,6 @@ MSGDTD=../../../include/anna/diameter/codec/message.dtd DCTDTD=../../../include/anna/diameter/stack/dictionary.dtd BASE_PROT=commands_baseProtocol.xml EXEC=./debug/example_diameter_launcher -DPATH_dflt=$HOME/ADL ############# # FUNCTIONS # @@ -78,14 +77,9 @@ echo "---------------------------------------" echo "Anna Diameter Launcher (ADL) deployment" echo "---------------------------------------" echo -echo "Input deployment path [$DPATH_dflt]:" -read DPATH -[ "$DPATH" = "" ] && DPATH=$DPATH_dflt -[ -d $DPATH ] && _exit "The path '$DPATH' already exists. Remove it before continue..." - echo "Basic checkings ..." [ ! -f $EXEC ] && _exit "Anna Diameter Launcher (ADL) is not linked. Execute 'scons' for 'anna' suite." -[ ! -d $SETUPS_DIR ] && _exit "Diameter stacks not found ($SETUPS_DIR). Perhaps you executed this script out of its parent path." +[ ! -d $SETUPS_DIR ] && _exit "Diameter stacks not found ($SETUPS_DIR)." echo echo "Deploy one of these versions:" @@ -99,15 +93,18 @@ read option [ "$option" = "" ] && option=b case $option in a) - RESOURCES_DIR=resources/advanced + DEPLOYMENTS_DIR=deployments/advanced + DPATH_dflt=$HOME/ADL-advanced ;; b) - RESOURCES_DIR=resources/basic + DEPLOYMENTS_DIR=deployments/basic + DPATH_dflt=$HOME/ADL-basic ;; f) - RESOURCES_DIR=resources/ft-client + DEPLOYMENTS_DIR=deployments/ft-client + DPATH_dflt=$HOME/ADL-ft-client ;; *) @@ -115,13 +112,21 @@ case $option in ;; esac +echo +echo "Input deployment path [$DPATH_dflt]:" +read DPATH +[ "$DPATH" = "" ] && DPATH=$DPATH_dflt +[ -d $DPATH ] && _exit "The path '$DPATH' already exists. Remove it before continue..." + echo "Copying ..." mkdir -p $DPATH mkdir -p $DPATH/stacks mkdir -p $DPATH/DTDs mkdir -p $DPATH/counters +mkdir -p $DPATH/resources cp $EXEC $DPATH/ADL-launcher -cp -rL $RESOURCES_DIR/* $DPATH +cp -rL $DEPLOYMENTS_DIR/* $DPATH +cp resources/* $DPATH/resources cp $SETUPS_DIR/*xml $DPATH/stacks cp $SETUPS_DIR/*sh $DPATH/stacks cp $SETUPS_DIR/readme.txt $DPATH/stacks diff --git a/example/diameter/launcher/deployments/advanced/1.xml b/example/diameter/launcher/deployments/advanced/1.xml new file mode 100644 index 0000000..dcd18b9 --- /dev/null +++ b/example/diameter/launcher/deployments/advanced/1.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/example/diameter/launcher/deployments/advanced/1xml-23.txt b/example/diameter/launcher/deployments/advanced/1xml-23.txt new file mode 100644 index 0000000..c0d8b4c --- /dev/null +++ b/example/diameter/launcher/deployments/advanced/1xml-23.txt @@ -0,0 +1,2 @@ +Encode 1.xml to 2.hex|code|1.xml|2.hex +Decode 2.hex to 3.xml (we will diff 1.xml and 3.xml)|decode|2.hex|3.xml diff --git a/example/diameter/launcher/deployments/advanced/README b/example/diameter/launcher/deployments/advanced/README new file mode 100644 index 0000000..9e0b3b6 --- /dev/null +++ b/example/diameter/launcher/deployments/advanced/README @@ -0,0 +1,25 @@ + +ABOUT CONTENT +------------- +Stacks available at './stacks'. +The launcher uses the configuration given by '.dictionary' which points to a specification list. +Available different setups by mean files named as '.dictionary__'. + +Template for xml messages (message.dtd) and dictionaries (dictionary.dtd) are informative, not +actually required by process. Located at './DTDs'. + +Additional helpers/scripts could be found at './resources' directory. + +STARTING THE PROCESS +-------------------- +Start with 'run.sh'. You could manually edit such script adding parameters as '-trace debug' to +get complete 'launcher.traces'. Execute 'ADL-launcher' without arguments to see a complete +command-line help. + +DEPLOYED SCRIPTS +---------------- +You could get help about installed resources by mean 'help.sh', which launch a help request to +the started ADL-launcher process http interface. All the implemented http operations could be +launched through a script to make easy use. The http client 'curl' is used by default due to +its presence on common linux distributions. + diff --git a/example/diameter/launcher/deployments/advanced/answerXml.sh b/example/diameter/launcher/deployments/advanced/answerXml.sh new file mode 100755 index 0000000..ce4aa40 --- /dev/null +++ b/example/diameter/launcher/deployments/advanced/answerXml.sh @@ -0,0 +1,29 @@ +#!/bin/bash +> curl_log.txt +TRACE="--trace-ascii curl_log.txt" +SERVER=`cat .httpServer` + +echo +echo +echo "Use: $0 [xml_file] [2e]" +echo +echo "Programm 'xml_file' answer to the diameter client or to the server (entity) when" +echo "'2e' parameter is provided. If missing xml file, current programmed answers will" +echo "be shown: '$0' (answers to client), '$0 2e' (answers to server)." +echo +if test "$1" != "" +then + if test "$1" = "2e" + then + operation="answerxml2e" + else + [[ ! -f "$1" ]] && { echo "ERROR: file '$1' not found" ; echo; echo; exit ; } + operation="answerxml|$1" + [[ "$2" = "2e" ]] && operation="answerxml2e|$1" + fi +else + operation="answerxml" +fi +echo +curl -m 1 --data "$operation" $TRACE ${SERVER} + diff --git a/example/diameter/launcher/deployments/advanced/args.txt b/example/diameter/launcher/deployments/advanced/args.txt new file mode 100755 index 0000000..d5f4afb --- /dev/null +++ b/example/diameter/launcher/deployments/advanced/args.txt @@ -0,0 +1,6 @@ +-httpServer `grep -v ^# .httpServer` +-dictionary `grep -v ^# .dictionary` +-diameterServer `grep -v ^# .diameterServer` +-diameterServerSessions `grep -v ^# .diameterServerSessions` +-entity `grep -v ^# .entity` +-entityServerSessions `grep -v ^# .entityServerSessions` diff --git a/example/diameter/launcher/deployments/advanced/batch.sh b/example/diameter/launcher/deployments/advanced/batch.sh new file mode 100755 index 0000000..9699243 --- /dev/null +++ b/example/diameter/launcher/deployments/advanced/batch.sh @@ -0,0 +1,60 @@ +#!/bin/bash +> curl_log.txt +TRACE="--trace-ascii curl_log.txt" +SERVER=`cat .httpServer` + +use () { + + echo "Use: $0 [time between operations: 0 second by default]" + echo + echo " Batch launcher script" + echo " ---------------------" + echo + echo " Test file must contain a operations with this syntax: |||..." + echo " Three operations: code, decode and sendxml:" + echo + echo " code|| i.e.: code|1.xml|2.hex" + echo " decode|| i.e.: decode|2.hex|1.xml-bis" + echo " sendxml| i.e.: sendxml|1.xml" + echo + echo " Test file example:" + echo + echo " $0 1xml-23.txt" + echo + echo " where 1xml-23.txt contains:" + echo " Encode 1.xml to 2.hex|code|1.xml|2.hex" + echo " Decode 2.hex to 3.xml (we will diff 1.xml and 3.xml)|decode|2.hex|3.xml" + echo + echo + echo " Test file could contain any number of operations and could include comments (will be ignored)." + echo + exit +} + +echo +echo +[[ "$1" = "" ]] && use +LAPSE=${2:-0} +echo +echo "Test '$1' is going to be launched:" +echo +cat $1 +echo +echo "Pulse ENTER para lanzar, CTRL+C para abortar..." +read dummy + +while read -r line +do + comment=$(echo $line | grep "^#") + ok= + [[ "$comment" = "" ]] && { [[ "$line" != "" ]] && ok=s ; } + if test "$ok" = "s" + then + echo "Launching $(echo $line | cut -d'|' -f1) ..." + sleep $LAPSE + operation=$(echo $line | cut -d'|' -f2-) + curl -m 1 --data "$operation" $TRACE ${SERVER} + fi + +done < $1 + diff --git a/example/diameter/launcher/deployments/advanced/burst.sh b/example/diameter/launcher/deployments/advanced/burst.sh new file mode 100755 index 0000000..b05b6e0 --- /dev/null +++ b/example/diameter/launcher/deployments/advanced/burst.sh @@ -0,0 +1,184 @@ +#!/bin/bash +> curl_log.txt +TRACE="--trace-ascii curl_log.txt" +SERVER=`cat .httpServer` +burstMargin__dflt=1 + +salir () { + echo + echo $1 + echo + exit +} + +calc () { echo "$1" | bc -l ; } + +entero () { + limpio=$(calc "scale=0;${1}/1") + [[ $limpio != $1 ]] && salir "Invalid value '$1'. Must be integer" +} + +uso () { + + echo "Load tests configuration script" + echo + echo "Use: $0 [action parameters]" + echo + echo " clear:" + echo " Clears all loaded burst messages." + echo + echo " load :" + echo " Loads 'amount' messages for the provided traffic type. For example:" + echo " $0 load 2000 sms" + echo + echo " start [initial launch: default $burstMargin__dflt]:" + echo " Starts the message sending from the begining of the burst list loaded," + echo " with a certain initial load. For example:" + echo " $0 start 200" + echo + echo " push [amount: default $burstMargin__dflt]:" + echo " Launch 'amount' messages as initial load does (non-asynchronous mode)." + echo " It works even if burst launch is stopped. Useful to achieve congestion" + echo " conditions. For example:" + echo " $0 push 300" + echo + echo " pop [amount: default $burstMargin__dflt]:" + echo " Skip send burst messages in order to reduce over-the-air requests." + echo + echo " stop:" + echo " Stops the burst cycle at the current position. It could affect sessions" + echo " on the air (i.e. data contexts). Totally safe for IEC scenaries as SMS." + echo + echo " resume:" + echo " Resume an stopped burst launch from the same point (start will reset" + echo " the work pointer to the first burst list position). This is equivalent" + echo " to one-message-push operation." + echo + echo " repeat [[yes] | no]:" + echo " Restarts the burst launch cycle when finished." + echo + echo " send [amount: default 1]:" + echo " send messages from burst list. The main difference with start/push operations" + echo " is that burst won't be awaken. Externally we could control sending time (no" + echo " request will be sent for answers). When reach the last position, starts again." + echo + echo " sendXS [amount: default -1 (no limit)]:" + echo " send messages from burst list with the TPS provided. User could hot change" + echo " speed by mean 'echo > .tps' at another shell. You can stop the load" + echo " removing that hidden file or using CTRL+C from the shell where you launched" + echo " the burst command. Real tps is dumped on '.real_tps' file during testing." + echo " You could limit the amount of messages sent by mean the second parameter." + echo " No limit is established by default (-1 or negative value)." + echo + echo " goto :" + echo " Updates current burst pointer position." + echo + echo " look :" + echo " Show programmed burst message for order provided." + echo + echo + salir +} + +_curl () { + curl -m 5 --data "$1" $TRACE ${SERVER} +} + +echo +echo +[[ "$1" = "" ]] && uso +case $1 in + clear) _curl "burst|clear" + ;; + load) [[ "$3" = "" ]] && uso + [[ ! -f "${3}.sh" ]] && salir "Burst generation file '${3}.sh' not found!" + entero $2 + if test "$3" = "data" + then + count=$2 + RESTO=$((count%4)) + [[ "$RESTO" != "0" ]] && salir "Data context should load a multiple of 4 (messages generated by data.sh)" + fi + count=1 + while test "$count" -le "$2" + do + ${3}.sh $count > .${3}.xml + echo -n "Loading message ${count}; " + _curl "burst|load|.${3}.xml" + count=$((count+1)) + done + ;; + start) load=$burstMargin__dflt + [[ "$2" != "" ]] && load=$2 + entero $load + _curl "burst|start|$load" + ;; + pop) release=$burstMargin__dflt + [[ "$2" != "" ]] && release=$2 + entero $release + _curl "burst|pop|$release" + ;; + push) [[ "$2" = "" ]] && uso + entero $2 + _curl "burst|push|$2" + ;; + stop) _curl "burst|stop" + ;; + resume) _curl "burst|push|1" + ;; + repeat) repeat=yes + [[ "$2" != "" ]] && repeat=$2 + _curl "burst|repeat|$repeat" + ;; + send) amount=1 + [[ "$2" != "" ]] && amount=$2 + entero $amount + _curl "burst|send|$amount" + ;; + sendXS) [[ "$2" = "" ]] && uso + limit=$3 + [[ "$limit" = "" ]] && limit=-1 + entero $2 + entero $limit + TPS=0 + count=0 + amount=1 + echo $2 > .tps + while test -f .tps + do + [[ "$count" = "$limit" ]] && break + BEFORE_ns=`date +%s%N` + READ_TPS=`cat .tps` + # Hot change could make .tps still unavailable: + [[ "$READ_TPS" = "" ]] && READ_TPS=$TPS + # Volvemos a calcular medias (REAL_TPS) cada 10 segundos o cuando cambia el TPS en caliente: + [[ "$READ_TPS" != "$TPS" ]] && { BEGIN_ns=$BEFORE_ns ; count=0 ; } + [[ $count = $((10*TPS)) ]] && { BEGIN_ns=$BEFORE_ns ; count=0 ; } + TPS=$READ_TPS + [[ "$TPS" = "0" ]] && salir "Test stopped due to 0-tps value read" + # Background: + _curl "burst|send|$amount" & + count=$((count+amount)) + AFTER_ns=`date +%s%N` + # Real tps: + REAL_TPS=$(calc "1000000000 * $count / ($AFTER_ns - $BEGIN_ns)") + echo $REAL_TPS > .real_tps + + COEF=1 + [[ $(calc "$TPS > $REAL_TPS") = "1" ]] && COEF=$(calc "$REAL_TPS / $TPS") + K=$(calc "$COEF ^ 10") + amount=$(calc "scale=0;1/$K") + usleep $(calc "$K * 1000000/$TPS") + done + ;; + goto) [[ "$2" = "" ]] && uso + entero $2 + _curl "burst|goto|$2" + ;; + look) [[ "$2" = "" ]] && uso + entero $2 + _curl "burst|look|$2" + ;; + *) uso +esac + diff --git a/example/diameter/launcher/deployments/advanced/clientSocketManager.sh b/example/diameter/launcher/deployments/advanced/clientSocketManager.sh new file mode 100755 index 0000000..4c801b2 --- /dev/null +++ b/example/diameter/launcher/deployments/advanced/clientSocketManager.sh @@ -0,0 +1,70 @@ +#!/bin/bash +> curl_log.txt +TRACE="--trace-ascii curl_log.txt" +SERVER=`cat .httpServer` +ENTITY=`cat .entity 2>/dev/null` +# If missing following, 1 is assigned (ENTITY_SS_1 is ENTITY_SS - 1) +ENTITY_SS=`cat .entityServerSessions 2>/dev/null` +[[ "$ENTITY_SS" = "" ]] && ENTITY_SS=1 +TARGET=$2 + +use () { + echo + echo + echo "Use: $0 \"[
:]|[socket id]\"" + echo + echo "Hides/shows/query hidden state/query shown state, the socket/s provided." + echo "If missing server (first parameter) all applications sockets will be affected by action." + echo "If missing socket (second parameter) for specific server, all its sockets will be affected by action." + echo + exit +} + +states () { + echo + echo "Select option to switch (0 = quit):" + echo + option=1 + for i in `echo $ENTITY | sed 's/,/ /g'` + do + for j in `seq 0 $ENTITY_SS_1` + do + TARGET="${i}|${j}" + RES=$(curl -m 1 --data "shown|$TARGET" ${SERVER} 2>&1 | tail -1 | grep "true$") + res=hidden + [[ "$RES" != "" ]] && res=shown + echo "${option}. $TARGET ($res)" + action=show + [[ "$RES" != "" ]] && action=hide + echo "curl -m 1 --data \"$action|$TARGET\" ${SERVER}" > .switch_${option} + chmod a+x .switch_${option} + option=$((option+1)) + done + done + echo +} + +if test "$ENTITY" != "" +then + ENTITY_SS_1=$((ENTITY_SS-1)) + while true + do + states + read option + [[ "$option" = "0" ]] && break + .switch_${option} + done + echo + echo "Exiting" + rm .switch_* + exit +else + [[ "$1" = "" ]] && use +fi + +echo +echo +operation="$1|$TARGET" +[[ "$TARGET" = "" ]] && operation="$1" +curl -m 1 --data "$operation" $TRACE ${SERVER} + diff --git a/example/diameter/launcher/deployments/advanced/code.sh b/example/diameter/launcher/deployments/advanced/code.sh new file mode 100755 index 0000000..9ca200c --- /dev/null +++ b/example/diameter/launcher/deployments/advanced/code.sh @@ -0,0 +1,21 @@ +#!/bin/bash +> curl_log.txt +TRACE="--trace-ascii curl_log.txt" +SERVER=`cat .httpServer` + +use () { + + echo "Use: $0 " + echo + echo "Creates '.hex' with encoded result." + echo + exit +} + +echo +[[ "$1" = "" ]] && use +[[ ! -f "$1" ]] && { echo "ERROR: file '$1' not found" ; echo; echo; exit ; } +echo +operation="code|$1|${1}.hex" +curl -m 1 --data "$operation" $TRACE ${SERVER} + diff --git a/example/diameter/launcher/deployments/advanced/collect.sh b/example/diameter/launcher/deployments/advanced/collect.sh new file mode 100755 index 0000000..5fb95ec --- /dev/null +++ b/example/diameter/launcher/deployments/advanced/collect.sh @@ -0,0 +1,6 @@ +#!/bin/bash +> curl_log.txt +TRACE="--trace-ascii curl_log.txt" +SERVER=`cat .httpServer` +curl -m 1 --data "collect" $TRACE ${SERVER} + diff --git a/example/diameter/launcher/deployments/advanced/data-initial.msk b/example/diameter/launcher/deployments/advanced/data-initial.msk new file mode 100644 index 0000000..fa6d324 --- /dev/null +++ b/example/diameter/launcher/deployments/advanced/data-initial.msk @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/example/diameter/launcher/deployments/advanced/data-termination.msk b/example/diameter/launcher/deployments/advanced/data-termination.msk new file mode 100644 index 0000000..f15396f --- /dev/null +++ b/example/diameter/launcher/deployments/advanced/data-termination.msk @@ -0,0 +1,55 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/example/diameter/launcher/deployments/advanced/data-update1.msk b/example/diameter/launcher/deployments/advanced/data-update1.msk new file mode 100644 index 0000000..8883c60 --- /dev/null +++ b/example/diameter/launcher/deployments/advanced/data-update1.msk @@ -0,0 +1,47 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/example/diameter/launcher/deployments/advanced/data-update2.msk b/example/diameter/launcher/deployments/advanced/data-update2.msk new file mode 100644 index 0000000..8784172 --- /dev/null +++ b/example/diameter/launcher/deployments/advanced/data-update2.msk @@ -0,0 +1,53 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/example/diameter/launcher/deployments/advanced/data.sh b/example/diameter/launcher/deployments/advanced/data.sh new file mode 100755 index 0000000..09949ad --- /dev/null +++ b/example/diameter/launcher/deployments/advanced/data.sh @@ -0,0 +1,74 @@ +#!/bin/bash + +# Generates DATA burst sequence for provided order number (1: first, 2: second, etc.) +# We will generate a simple scenario with initial, two updates and termination, that is to say: four messages: +# 1,2,3,4 5,6,7,8 9,10,11,12 etc. +# +# Category = ((Number-1) % 4) + 1 = 1 for initial, 2 for first update, 3 for second update and 4 for termination +SEQN=$1 +OFFSET=$((SEQN-1)) +CAT=$((OFFSET%4 + 1)) + +salir () { + echo + echo $1 + echo + exit +} + +check_template () { + [[ ! -f $1 ]] && salir "Template file ($1) not found!" +} + +parse () { + cat $1 | sed 's/__HBH_ETE__/'$HBH_ETE'/g' | sed 's/__SID_SUFFIX__/'$SID_SUFFIX'/' \ + | sed 's/__MSISDN__/'$MSISDN'/' | sed 's/__NTPTIMESTAMP__/'$NTP'/' \ + | sed 's/__SID_DI__/'$SID_DI'/' | sed 's/__SID_HIGH__/'$SID_HIGH'/' | sed 's/__SID_LOW__/'$SI_LOW'/' +} + + +[[ "$SEQN" = "" ]] && salir "Use: $0 " +check_template data-initial.msk +check_template data-update1.msk +check_template data-update2.msk +check_template data-termination.msk + +# Session-Id: ';;[;="">]' +# +# We will sequence the otional value with __SID_SUFFIX__, low and high will be constant. + +# Sequence values at templates: +# __HBH_ETE__: 1, 3, 5, etc. (hop-by-hop and end-to-end) +# __SID_SUFFIX__: It could be MSISDN, but we put OFFSET (0, 1, 2, 3, etc.). It's the Session-Id optional part. +# __MSISDN__: 50583211675, 50583211676, 50583211677, etc. Used for User-Name and Subscription-Id-Data +# __NTPTIMESTAMP__: Four values for initial, update1, update2 and termination: 3548171033, 3548171136 (103+), 3548171136(idem), 3548171524(388+) +# This initial time (aproximately 8 Jun 2012 at 19:00). +CUARTO=$((OFFSET/4)) +HBH_ETE=$((1 + 2*OFFSET)) +SID_SUFFIX=$CUARTO +# Example if you want to fix to two sockets (-sessionIdPartForClientSocketIdSelection must be 'optional'): SID_SUFFIX=$((CUARTO%2)) +MSISDN=$((50583211675+CUARTO)) +NTP=$((3548171033+CUARTO)) + +# Helpers to guide derivery (fixed at the moment) +# __SID_DI__: Session-Id diameter identity +# __SID_HIGH__: Session-Id high part +# __SID_LOW__: Session-Id low part +SID_DI=module-2.PTS2-BOG.sandvine.com +SID_HIGH=1287115741 +SI_LOW=0 + +case $CAT in + 1) parse data-initial.msk + ;; + 2) NTP=$((NTP+103)) + parse data-update1.msk + ;; + 3) NTP=$((NTP+103)) + parse data-update2.msk + ;; + 4) NTP=$((NTP+491)) + parse data-termination.msk + ;; +esac + diff --git a/example/diameter/launcher/deployments/advanced/decode.sh b/example/diameter/launcher/deployments/advanced/decode.sh new file mode 100755 index 0000000..3924f73 --- /dev/null +++ b/example/diameter/launcher/deployments/advanced/decode.sh @@ -0,0 +1,21 @@ +#!/bin/bash +> curl_log.txt +TRACE="--trace-ascii curl_log.txt" +SERVER=`cat .httpServer` + +use () { + + echo "Use: $0 " + echo + echo "Creates '.xml' with decoded result." + echo + exit +} + +echo +[[ "$1" = "" ]] && use +[[ ! -f "$1" ]] && { echo "ERROR: file '$1' not found" ; echo; echo; exit ; } +echo +operation="decode|$1|${1}.xml" +curl -m 1 --data "$operation" $TRACE ${SERVER} + diff --git a/example/diameter/launcher/deployments/advanced/diameterServerSessions.sh b/example/diameter/launcher/deployments/advanced/diameterServerSessions.sh new file mode 100755 index 0000000..dc72c87 --- /dev/null +++ b/example/diameter/launcher/deployments/advanced/diameterServerSessions.sh @@ -0,0 +1,20 @@ +#!/bin/bash +> curl_log.txt +TRACE="--trace-ascii curl_log.txt" +SERVER=`cat .httpServer` + +use () { + + echo "Use: $0 " + echo + echo "Updates the maximum number of accepted connections over diameter server socket." + echo + exit +} + +echo +[[ "$1" = "" ]] && use +echo +operation="diameterServerSessions|$1" +curl -m 1 --data "$operation" $TRACE ${SERVER} + diff --git a/example/diameter/launcher/deployments/advanced/help.sh b/example/diameter/launcher/deployments/advanced/help.sh new file mode 100755 index 0000000..ebeafff --- /dev/null +++ b/example/diameter/launcher/deployments/advanced/help.sh @@ -0,0 +1,6 @@ +#!/bin/bash +> curl_log.txt +TRACE="--trace-ascii curl_log.txt" +SERVER=`cat .httpServer` +curl -m 1 --data "help" $TRACE ${SERVER} + diff --git a/example/diameter/launcher/deployments/advanced/loadXml.sh b/example/diameter/launcher/deployments/advanced/loadXml.sh new file mode 100755 index 0000000..26749d5 --- /dev/null +++ b/example/diameter/launcher/deployments/advanced/loadXml.sh @@ -0,0 +1,23 @@ +#!/bin/bash +> curl_log.txt +TRACE="--trace-ascii curl_log.txt" +SERVER=`cat .httpServer` + +use () { + + echo "Use: $0 " + echo + echo "Load xml file and show on stdout again." + echo "It is useful to test xml loader and xml viewer, but also for show aliases and," + echo "if '-ignoreFlags' commandline option is missing, for flag coherence checking." + echo + exit +} + +echo +[[ "$1" = "" ]] && use +[[ ! -f "$1" ]] && { echo "ERROR: file '$1' not found" ; echo; echo; exit ; } +echo +operation="loadxml|$1" +curl -m 1 --data "$operation" $TRACE ${SERVER} + diff --git a/example/diameter/launcher/deployments/advanced/pre-start.sh b/example/diameter/launcher/deployments/advanced/pre-start.sh new file mode 100755 index 0000000..49a83ff --- /dev/null +++ b/example/diameter/launcher/deployments/advanced/pre-start.sh @@ -0,0 +1,92 @@ +#!/bin/bash + +# Remove logs: +rm *.log* *.csv 2>/dev/null + +# Server sockets: +httpServer_dflt=`cat .httpServer 2>/dev/null` +diameterServer_dflt=`cat .diameterServer 2>/dev/null` +diameterServerSessions_dflt=`cat .diameterServerSessions 2>/dev/null` + +# Client sockets: +entity_dflt=`cat .entity 2>/dev/null` +entityServerSessions_dflt=`cat .entityServerSessions 2>/dev/null` + +# Stack: +dictionary_dflt=`cat .dictionary 2>/dev/null` + +echo +echo +# If all have values: +if [ "$httpServer_dflt" != "" -a "$diameterServer_dflt" != "" -a "$diameterServerSessions_dflt" != "" -a \ + "$entity_dflt" != "" -a "$entityServerSessions_dflt" != "" -a \ + "$dictionary_dflt" != "" ] +then + echo "Do you wish to answer wizard commandline configuration ? (y/n) [n]:" + read wizard + [ "$wizard" = "" ] && wizard=n + [ "$wizard" = "n" ] && exit +fi + +# DEFAULTS +[ "$httpServer_dflt" = "" ] && httpServer_dflt="localhost:9000" +[ "$diameterServer_dflt" = "" ] && diameterServer_dflt="localhost:3868" +[ "$diameterServerSessions_dflt" = "" ] && diameterServerSessions_dflt=1 +[ "$entity_dflt" = "" ] && entity_dflt="localhost:4000,localhost:4001" +[ "$entityServerSessions_dflt" = "" ] && entityServerSessions_dflt=0 +[ "$dictionary_dflt" = "" ] && dictionary_dflt=dictionary.xml + + +# Wizard +echo "HTTP Management interface address (using i.e. curl tool) as : socket literal [$httpServer_dflt]:" +read httpServer +[ "$httpServer" = "" ] && httpServer=$httpServer_dflt + +echo "Diameter dictionary: you could use '/opt/bin/anna/example_diameter_stackManagement' tool in order to build" +echo " autonomous dictionaries for any kind of application. The key is to concatenate xml contents (ietf, 3gpp," +echo " vendor-specific, etc.). See 'example/diameter/stackManagement/self_ruling_setups.sh' for this." +echo +echo "This launcher can also join them providing a comma-separated list (dictionaries available on ./stack)." +echo "By default, a QoS Application setup is suggested. Input the desired configuration instead, or press ENTER:" +echo +echo " [$dictionary_dflt]:" +read dictionary +[ "$dictionary" = "" ] && dictionary=$dictionary_dflt + +# As server: +echo "Diameter own server available connections (0: diameter server disabled) [$diameterServerSessions_dflt]:" +read diameterServerSessions +[ "$diameterServerSessions" = "" ] && diameterServerSessions=$diameterServerSessions_dflt + +diameterServer= +if test "$diameterServerSessions" != "0" +then + echo "Diameter own server address as : socket literal [$diameterServer_dflt]:" + read diameterServer +fi +[ "$diameterServer" = "" ] && diameterServer=$diameterServer_dflt + +# As client: +echo "Diameter entity server sessions (0: diameter entity disabled) [$entityServerSessions_dflt]:" +read entityServerSessions +[ "$entityServerSessions" = "" ] && entityServerSessions=$entityServerSessions_dflt + +entity= +if test "$entityServerSessions" != "0" +then + echo "Target diameter entity (pipe-separated : socket literal list) ["$entity_dflt"]:" + read entity +fi +[ "$entity" = "" ] && entity="$entity_dflt" + +# Configure: +echo $httpServer > .httpServer +echo $dictionary > .dictionary +echo $diameterServer > .diameterServer +echo $diameterServerSessions > .diameterServerSessions +echo $entity > .entity +echo $entityServerSessions > .entityServerSessions + +echo +echo + diff --git a/example/diameter/launcher/deployments/advanced/sendXml.sh b/example/diameter/launcher/deployments/advanced/sendXml.sh new file mode 100755 index 0000000..d9aaa33 --- /dev/null +++ b/example/diameter/launcher/deployments/advanced/sendXml.sh @@ -0,0 +1,23 @@ +#!/bin/bash +> curl_log.txt +TRACE="--trace-ascii curl_log.txt" +SERVER=`cat .httpServer` + +use () { + + echo "Use: $0 [2c]" + echo + echo "Sends 'xml_file' to the diameter server or to the client when '2c' parameter is provided." + echo + exit +} + +echo +[[ "$1" = "" ]] && use +[[ ! -f "$1" ]] && { echo "ERROR: file '$1' not found" ; echo; echo; exit ; } +echo +operation="sendxml|$1" +[[ "$2" = "2c" ]] && operation="sendxml2c|$1" + +curl -m 1 --data "$operation" $TRACE ${SERVER} + diff --git a/example/diameter/launcher/deployments/advanced/sms.msk b/example/diameter/launcher/deployments/advanced/sms.msk new file mode 100644 index 0000000..7bec3c8 --- /dev/null +++ b/example/diameter/launcher/deployments/advanced/sms.msk @@ -0,0 +1,90 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/example/diameter/launcher/deployments/advanced/sms.sh b/example/diameter/launcher/deployments/advanced/sms.sh new file mode 100755 index 0000000..d0b1e63 --- /dev/null +++ b/example/diameter/launcher/deployments/advanced/sms.sh @@ -0,0 +1,30 @@ +#!/bin/bash + +# Generates SMS burst sequence for provided order number (1: first, 2: second, etc.) +SEQN=$1 + +salir () { + echo + echo $1 + echo + exit +} + +[[ "$SEQN" = "" ]] && salir "Use: $0 " +[[ ! -f sms.msk ]] && salir "Template file (sms.msk) not found!" + +# Sequence values at template sms.msk: +# __HBH_ETE__: 1, 3, 5, etc. (hop-by-hop and end-to-end) +# __SID_LOW__: 1000, 1001, 1002, etc. (Session-Id sequence append) +# __MSISDN__: 5555100000, 5555100001, 5555100002, etc. (First and Third Address-Data) +# __IMSI__: 262075555100000, 262075555100001, 262075555100002, etc. (Second Address-Data) + +OFFSET=$((SEQN-1)) + +HBH_ETE=$((1 + 2*OFFSET)) +SID_LOW=$((1000+OFFSET)) +MSISDN=$((5555100000+OFFSET)) +IMSI=$((262075555100000+OFFSET)) + +cat sms.msk | sed 's/__HBH_ETE__/'$HBH_ETE'/g' | sed 's/__SID_LOW__/'$SID_LOW'/' \ + | sed 's/__MSISDN__/'$MSISDN'/' | sed 's/__IMSI__/'$IMSI'/' diff --git a/example/diameter/launcher/deployments/basic/README b/example/diameter/launcher/deployments/basic/README new file mode 100644 index 0000000..3825064 --- /dev/null +++ b/example/diameter/launcher/deployments/basic/README @@ -0,0 +1,35 @@ +ABOUT CONTENT +------------- +Template for xml messages (message.dtd) and dictionaries (dictionary.dtd) are informative, not +actually required by process. They are located at './DTDs'. Stacks are available at './stacks'. +There are also some stuff (hex/xml examples, etc.) which could be useful. + +Firstly you have to configure this directory in order to choose the type of launcher which will +be preconfigured for your basic needs: client, server, balancer (proxy) and dummy process (this +last is used for code/encode and does not launch any communication interface). + +If you are going to launch different processes, we recommend to clone this whole directory into +another one (call it 'ADL-client', 'ADL-server_2', 'Diameter_proxy', or whatever you want), and +then configure it again. + +Execute './configure.sh' and follow the intructions. You can call this several times, but the +last configuration will be the one which prevails. + +Additional helpers/scripts could be found at './resources' directory. + +STARTING THE PROCESS +-------------------- +After configuring the ADL execution context, a new script has been created: 'run.sh'. +You can manually edit such script adding parameters as '-trace debug' to get complete traces, +or adapt the communication endpoints for your environment. + +Launch the executable process without arguments to see a complete command-line help. +Don't be scared. There are plenty of possibilities but the 'run.sh' script has been prepared +for the type of launcher you wanted. + +OPERATION +--------- +Management interface for lite version is based on SIGUSR2 signal caugh. Use './operation.sh' +script to send any operation to the process. Ask for help with that script to see all the +operations supported. + diff --git a/example/diameter/launcher/deployments/basic/configure.sh b/example/diameter/launcher/deployments/basic/configure.sh new file mode 100755 index 0000000..a5d1515 --- /dev/null +++ b/example/diameter/launcher/deployments/basic/configure.sh @@ -0,0 +1,109 @@ +#!/bin/bash + +############# +# VARIABLES # +############# + +# Diameter dictionary: +STD_DICTIONARY=stacks/avps_etsi.xml,stacks/avps_ietf.xml,stacks/avps_tgpp.xml,stacks/commands_baseProtocol.xml +APP_DICTIONARY=stacks/commands_qosControl.xml +DICTIONARY=$STD_DICTIONARY,$APP_DICTIONARY +# Perhaps the stack is not fully defined: +#KINDNESS=-ignoreErrors +# But we prefer stack to generate Failed-AVP automatically: +KINDNESS= + +# Communication endpoints: +LOCAL_STANDARD_ENDPOINT=localhost:3868 +EXAMPLE_ENTITY_4_BALANCER=192.168.12.11:3868,192.168.12.21:3868 +CONNS=10 + +# General +EXE_BN=ADL-launcher + +# Tracing: +TRACING="-cntDir counters" +# need detailed traces ?: +#TRACING="$TRACING -trace debug" + +############# +# FUNCTIONS # +############# + +_exit () { + echo + echo $1 + echo + exit 1 +} + +# $1: process name +createRunScript () { + + cat << EOF > run.sh +#!/bin/bash +cd \`dirname \$0\` +STARTED=\`pgrep $1 2>/dev/null\` +[ \$? -eq 0 ] && { echo "Already started!"; echo "\$STARTED" ; exit 1 ; } +0> launcher.traces +rm -f counters/* +# Execution line: +./$@ & +echo \$! > .pid +EOF + + chmod a+x run.sh +} + +# $1: input option (c, s, b, d) +# Retuns the type of launcher logical name for the input option +get_tol () { + [ "$1" = "c" ] && echo client + [ "$1" = "s" ] && echo server + [ "$1" = "b" ] && echo balancer + [ "$1" = "d" ] && echo dummy +} + +############# +# EXECUTION # +############# +cd `dirname $0` +SCR_DIR=`pwd` +echo +echo +echo "Configure a (c)lient, (s)erver, (b)alancer or (d)ummy [c]:" +read option +[ "$option" = "" ] && option=c +tol=$(get_tol $option) +[ "$tol" = "" ] && _exit "Option '$option' not implemented !!" + +# Run script: +EXE_LINK=ADL-$tol +ln -sf $EXE_BN $EXE_LINK + +case $tol in + + client) + ENTITY=$LOCAL_STANDARD_ENDPOINT + createRunScript $EXE_LINK -dictionary $DICTIONARY -entity $ENTITY -entityServerSessions $CONNS -diameterServerSessions 0 $KINDNESS $TRACING & + ;; + + server) + SERVER=$LOCAL_STANDARD_ENDPOINT + createRunScript $EXE_LINK -dictionary $DICTIONARY -diameterServer $SERVER -diameterServerSessions $CONNS -entityServerSessions 0 $KINDNESS $TRACING & + ;; + + balancer) + SERVER=$LOCAL_STANDARD_ENDPOINT + ENTITY=$EXAMPLE_ENTITY_4_BALANCER + createRunScript $EXE_LINK -dictionary $DICTIONARY -entity $ENTITY -entityServerSessions $CONNS -diameterServer $SERVER -diameterServerSessions $CONNS -balance $KINDNESS $TRACING & + ;; + + dummy) + createRunScript $EXE_LINK -dictionary $DICTIONARY -entityServerSessions 0 -diameterServerSessions 0 $KINDNESS $TRACING & + ;; + +esac + +echo "Created 'run.sh' script !" +echo diff --git a/example/diameter/launcher/deployments/basic/hex_examples/aar-bad.hex b/example/diameter/launcher/deployments/basic/hex_examples/aar-bad.hex new file mode 100644 index 0000000..7588fa1 --- /dev/null +++ b/example/diameter/launcher/deployments/basic/hex_examples/aar-bad.hex @@ -0,0 +1 @@ +01000150c000010901000014000000000000000000000107400000246f6373333b313333323737343433303b313b31333332373734343330000001024000000c01000014000001084000000c4f435333000001284000000c4f4353330000011b4000000c4f435333000001254000000c4f435333000001f8c000000f000028af3132320000000205c000006c000028af00000206c0000010000028af00000000000001f8c000000f000028af3132320000000204c0000010000028af0000007f00000203c0000010000028af00000085000001ffc0000010000028af00000002000001ca80000010000032db000000000000020fc0000010000028af00000000000001bb40000021000001c24000000c00000000000001bc4000001136323630333730393900000000000008400000133139322e3136382e302e31000000001e400000145741502e4d4f564953544152 diff --git a/example/diameter/launcher/deployments/basic/hex_examples/aar.hex b/example/diameter/launcher/deployments/basic/hex_examples/aar.hex new file mode 100644 index 0000000..9a2aeb9 --- /dev/null +++ b/example/diameter/launcher/deployments/basic/hex_examples/aar.hex @@ -0,0 +1 @@ +01000150c000010901000014000000000000000000000107400000246f6373333b313333323737343433303b313b31333332373734343330000001024000000c01000014000001084000000c4f435333000001284000000c4f4353330000011b4000000c4f435333000001254000000c4f435333000001f8c000000f000028af3132320000000205c000006c000028af00000206c0000010000028af00000000000001f8c000000f000028af3132320000000204c0000010000028af0000007f00000203c0000010000028af00000085000001ffc0000010000028af00000002000001ca80000010000032db000000000000020fc0000010000028af00000000000001bb40000028000001c24000000c00000000000001bc4000001136323630333730393900000000000008400000133139322e3136382e302e31000000001e400000145741502e4d4f564953544152 diff --git a/example/diameter/launcher/deployments/basic/hex_examples/aar2-bad.hex b/example/diameter/launcher/deployments/basic/hex_examples/aar2-bad.hex new file mode 100644 index 0000000..4b5c1ed --- /dev/null +++ b/example/diameter/launcher/deployments/basic/hex_examples/aar2-bad.hex @@ -0,0 +1 @@ +0100017cc000010901000014000000000000000000000107400000246f6373333b313333323737343433303b313b31333332373734343330000001024000000c01000014000001084000000c4f435333000001284000000c4f4353330000011b4000000c4f435333000001254000000c4f435333000001f8c000000f000028af3132320000000205c0000098000028af00000206c0000010000028af0000000000000207c000002c000028af000001fdc0000010000028af00000037000001ffc000000a000028af00000000000001f8c000000f000028af3132320000000204c0000010000028af0000007f00000203c0000010000028af00000085000001ffc0000010000028af00000002000001ca80000010000032db000000000000020fc0000010000028af00000000000001bb40000028000001c24000000c00000000000001bc4000001136323630333730393900000000000008000000133139322e3136382e302e31000000001e000000145741502e4d4f564953544152 diff --git a/example/diameter/launcher/deployments/basic/hex_examples/aar3-bad.hex b/example/diameter/launcher/deployments/basic/hex_examples/aar3-bad.hex new file mode 100644 index 0000000..62f45ba --- /dev/null +++ b/example/diameter/launcher/deployments/basic/hex_examples/aar3-bad.hex @@ -0,0 +1 @@ +0100017cc000010901000014000000000000000000000107400000246f6373333b313333323737343433303b313b31333332373734343330000001024000000c01000014000001084000000c4f435333000001284000000c4f4353330000011b4000000c4f435333000001254000000c4f435333000001f8c000000f000028af3132320000000205c0000098000028af00000206c0000010000028af0000000000000207c000002c000028af000001fdc0000010000028af00000037000001ffc0000010000028af00000010000001f8c000000f000028af3132320000000204c0000010000028af0000007f00000203c0000010000028af00000085000001ffc0000010000028af00000002000001ca80000010000032db000000000000020fc0000010000028af00000000000001bb40000028000001c24000000c00000000000001bc4000001136323630333730393900000000000008000000133139322e3136382e302e31000000001e000000145741502e4d4f564953544152 diff --git a/example/diameter/launcher/deployments/basic/hex_examples/readme.txt b/example/diameter/launcher/deployments/basic/hex_examples/readme.txt new file mode 100644 index 0000000..6b66557 --- /dev/null +++ b/example/diameter/launcher/deployments/basic/hex_examples/readme.txt @@ -0,0 +1,16 @@ +Bad messages: + +aar-bad.hex: comes from ../xml_examples/aar.xml + Consists in a deliberated bad length encoded on grouped Subscription-Id length field (not multiple of 4). + +aar2-bad.hex: comes from ../xml_examples/aar2.xml + Consists in a deliberated bad length encoded on enumerated Flow-Status avp 2-level nested inside Media-Component-Description: + -> Media-Component-Description (grouped) + -> Media-Sub-Component (grouped) + -> Flow-Status (enumerated) + +aar3-bad.hex: comes from ../xml_examples/aar2.xml + Consists in a deliberated bad value (16) encoded on enumerated Flow-Status avp (range 0-15) 2-level nested inside Media-Component-Description: + -> Media-Component-Description (grouped) + -> Media-Sub-Component (grouped) + -> Flow-Status (enumerated) diff --git a/example/diameter/launcher/deployments/basic/hex_examples/tspCCA.hex b/example/diameter/launcher/deployments/basic/hex_examples/tspCCA.hex new file mode 100644 index 0000000..401687a --- /dev/null +++ b/example/diameter/launcher/deployments/basic/hex_examples/tspCCA.hex @@ -0,0 +1 @@ +0100018c4000011001000016ff7f245e9b81ce71000001074000003f63302d31302d37302d3233382d37342d7735703176657067312e766570632e6572696373736f6e2e73653b313430323932373534343b33000000010c4000000c000007d10000010840000019657063322e6570637265616c6d2e636f6d00000000000128400000146570637265616c6d2e636f6d000001026000000c01000016000001a06000000c000000010000019f6000000c00000000000003f8c000002c000028af00000410c0000010000028af004e200000000411c0000010000028af0007d00000000419c0000058000028af00000404c0000010000028af000000060000040ac000003c000028af00000416c0000010000028af000000030000041780000010000028af000000010000041880000010000028af000000000000027480000038000028af0000010a4000000c000028af0000027580000010000028af000000010000027680000010000028af00000003000003ffc0000010000028af00000002000001164000000c00000005 diff --git a/example/diameter/launcher/deployments/basic/hex_examples/tspCCR.hex b/example/diameter/launcher/deployments/basic/hex_examples/tspCCR.hex new file mode 100644 index 0000000..492384a --- /dev/null +++ b/example/diameter/launcher/deployments/basic/hex_examples/tspCCR.hex @@ -0,0 +1 @@ +010002e8c000011001000016ff7f245e9b81ce71000001074000003f63302d31302d37302d3233382d37342d7735703176657067312e766570632e6572696373736f6e2e73653b313430323932373534343b3300000001026000000c01000016000001084000003263302d31302d37302d3233382d37342d7735703176657067312e766570632e6572696373736f6e2e736500000000012840000018766570632e6572696373736f6e2e73650000011b600000146570637265616c6d2e636f6d000001a06000000c000000010000019f6000000c0000000000000017c000000e000028af80010000000001166000000c00000000000001bb60000028000001c26000000c00000000000001bc60000013343637303139343034313800000000086000000c0a46ee6200000403c0000010000028af0000000500000015e000000d000028af060000000000040880000010000028af000003ec000001ca6000002c000001cb2000000c00000000000001cc2000001833353734373330343030363632383030000003f8c000002c000028af0000041080000010000028af08f0d1800000041180000010000028af02faf0800000041980000058000028af00000404c0000010000028af000000090000040ac000003c000028af0000041680000010000028af000000020000041780000010000028af000000010000041880000010000028af0000000000000012e0000011000028af32343039390000000000041a80000012000028af00010a46ee3a000000000016c0000019000028af8242f099006742f0990186a4010000000000001e6000000d7665706731000000000003e8c0000010000028af0000000000000400c0000010000028af00000001000001f5c0000012000028af00010a46ee3a0000000003fec0000020000028af000001f7c0000013000028af34383030303438000000027480000038000028af0000010a4000000c000028af0000027580000010000028af000000010000027680000010000028af00000003 diff --git a/example/diameter/launcher/deployments/basic/operation.sh b/example/diameter/launcher/deployments/basic/operation.sh new file mode 100755 index 0000000..5f3afc0 --- /dev/null +++ b/example/diameter/launcher/deployments/basic/operation.sh @@ -0,0 +1,33 @@ +#!/bin/bash + +############# +# FUNCTIONS # +############# +_exit () { + echo + echo -e $1 + echo + exit 1 +} + +############# +# EXECUTION # +############# +cd `dirname $0` +echo +# Get the PID: +[ ! -f .pid ] && _exit "Can't found '`pwd`/.pid'.\nTry to pgrep your process name and dump pid to that file." +PID=`cat .pid` + +# Send operation: +[ "$1" = "" ] && _exit "Use: $0 ; i.e.: $0 help" +echo $1 > sigusr2.tasks.input +kill -s SIGUSR2 $PID + +sleep 1 +echo +echo +echo "You could see results on '`pwd`/sigusr2.tasks.output' file." +echo +echo + diff --git a/example/diameter/launcher/deployments/basic/xml_examples/aar.xml b/example/diameter/launcher/deployments/basic/xml_examples/aar.xml new file mode 100644 index 0000000..1201655 --- /dev/null +++ b/example/diameter/launcher/deployments/basic/xml_examples/aar.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/example/diameter/launcher/deployments/basic/xml_examples/aar2.xml b/example/diameter/launcher/deployments/basic/xml_examples/aar2.xml new file mode 100644 index 0000000..c163fb4 --- /dev/null +++ b/example/diameter/launcher/deployments/basic/xml_examples/aar2.xml @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/example/diameter/launcher/deployments/basic/xml_examples/ccr.xml b/example/diameter/launcher/deployments/basic/xml_examples/ccr.xml new file mode 100644 index 0000000..46483a2 --- /dev/null +++ b/example/diameter/launcher/deployments/basic/xml_examples/ccr.xml @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/example/diameter/launcher/deployments/ft-client/README b/example/diameter/launcher/deployments/ft-client/README new file mode 100644 index 0000000..7255a7f --- /dev/null +++ b/example/diameter/launcher/deployments/ft-client/README @@ -0,0 +1,29 @@ +ABOUT CONTENT +------------- +Template for xml messages (message.dtd) and dictionaries (dictionary.dtd) are informative, not +actually required by process. They are located at './DTDs'. Stacks are available at './stacks'. +There are also some stuff (hex/xml examples, etc.) which could be useful. + +The directory 'tests' contains resources to create FT test cases. The script 'common.sh' implement +a basic scheduler to launch a request to the server, waits for incoming activity, retrieve the +answer received and match such message with certain criteria. Execute 'case_1.sh' as example. + +An advanced FT test framework involves the use of the ANNA::diameter API in an ad-hoc diameter +client executable (for example we could define an incoming handler in different libraries which +represent different test cases, linking them to a common simple diameter client agent). But with +this simple scripts we could do something valid to start with. + +Additional helpers/scripts could be found at './resources' directory. + +STARTING THE PROCESS +-------------------- +Launch the executable process without arguments to see a complete command-line help. +Don't be scared. There are plenty of possibilities but the 'run.sh' script has been prepared +for the type of launcher you wanted. + +OPERATION +--------- +Management interface for this version is based on SIGUSR2 signal caugh. Use './operation.sh' +script to send any operation to the process. Ask for help with that script to see all the +operations supported. + diff --git a/example/diameter/launcher/deployments/ft-client/args.txt b/example/diameter/launcher/deployments/ft-client/args.txt new file mode 100755 index 0000000..2ee9a85 --- /dev/null +++ b/example/diameter/launcher/deployments/ft-client/args.txt @@ -0,0 +1,4 @@ +-dictionary `grep -v ^# .dictionary` +-entity `grep -v ^# .entity` +-entityServerSessions `grep -v ^# .entityServerSessions` +-splitLog diff --git a/example/diameter/launcher/deployments/ft-client/hex_examples b/example/diameter/launcher/deployments/ft-client/hex_examples new file mode 120000 index 0000000..9eee58b --- /dev/null +++ b/example/diameter/launcher/deployments/ft-client/hex_examples @@ -0,0 +1 @@ +../basic/hex_examples \ No newline at end of file diff --git a/example/diameter/launcher/deployments/ft-client/operation.sh b/example/diameter/launcher/deployments/ft-client/operation.sh new file mode 120000 index 0000000..a61ab5e --- /dev/null +++ b/example/diameter/launcher/deployments/ft-client/operation.sh @@ -0,0 +1 @@ +../basic/operation.sh \ No newline at end of file diff --git a/example/diameter/launcher/deployments/ft-client/pre-start.sh b/example/diameter/launcher/deployments/ft-client/pre-start.sh new file mode 100755 index 0000000..b1863af --- /dev/null +++ b/example/diameter/launcher/deployments/ft-client/pre-start.sh @@ -0,0 +1,63 @@ +#!/bin/bash + +# Remove logs: +rm *.log* *.csv 2>/dev/null + +# Client sockets: +entity_dflt=`cat .entity 2>/dev/null` +entityServerSessions_dflt=`cat .entityServerSessions 2>/dev/null` + +# Stack: +dictionary_dflt=`cat .dictionary 2>/dev/null` + +echo +echo +# If all have values: +if [ "$entity_dflt" != "" -a "$entityServerSessions_dflt" != "" -a "$dictionary_dflt" != "" ] +then + echo "Do you wish to answer wizard commandline configuration ? (y/n) [n]:" + read wizard + [ "$wizard" = "" ] && wizard=n + [ "$wizard" = "n" ] && exit +fi + +# DEFAULTS +#[ "$entity_dflt" = "" ] && entity_dflt="192.168.12.11:3868,192.168.12.21:3868" +[ "$entity_dflt" = "" ] && entity_dflt="localhost:3868" +[ "$entityServerSessions_dflt" = "" ] && entityServerSessions_dflt=10 +[ "$dictionary_dflt" = "" ] && dictionary_dflt=dictionary.xml + + +# Wizard +echo "Diameter dictionary: you could use '/opt/bin/anna/example_diameter_stackManagement' tool in order to build" +echo " autonomous dictionaries for any kind of application. The key is to concatenate xml contents (ietf, 3gpp," +echo " vendor-specific, etc.). See 'example/diameter/stackManagement/self_ruling_setups.sh' for this." +echo +echo "This launcher can also join them providing a comma-separated list (dictionaries available on ./stack)." +echo "By default, a QoS Application setup is suggested. Input the desired configuration instead, or press ENTER:" +echo +echo " [$dictionary_dflt]:" +read dictionary +[ "$dictionary" = "" ] && dictionary=$dictionary_dflt + +# As client: +echo "Diameter entity server sessions (0: diameter entity disabled) [$entityServerSessions_dflt]:" +read entityServerSessions +[ "$entityServerSessions" = "" ] && entityServerSessions=$entityServerSessions_dflt + +entity= +if test "$entityServerSessions" != "0" +then + echo "Target diameter entity (pipe-separated : socket literal list) ["$entity_dflt"]:" + read entity +fi +[ "$entity" = "" ] && entity="$entity_dflt" + +# Configure: +echo $dictionary > .dictionary +echo $entity > .entity +echo $entityServerSessions > .entityServerSessions + +echo +echo + diff --git a/example/diameter/launcher/deployments/ft-client/tests/experiment1/case_1.sh b/example/diameter/launcher/deployments/ft-client/tests/experiment1/case_1.sh new file mode 100755 index 0000000..67dd513 --- /dev/null +++ b/example/diameter/launcher/deployments/ft-client/tests/experiment1/case_1.sh @@ -0,0 +1,47 @@ +#!/bin/bash + +# In this test we will send a incorrect message (AAR) to the server peer: +# Warning | source/diameter/codec/Message.cpp (387) | Internal Avp decoding error (avp code = 443): Avp format error, the avp length is incorrect (must be multiple of 4 on grouped type) +# +# The server shall answer with the FailedAVP and we will check this to validate the test. + +############# +# VARIABLES # +############# +# Paths from the point of view of ADL executable: +REQ1_HEX=./hex_examples/aar-bad.hex + +############# +# FUNCTIONS # +############# + + +############# +# EXECUTION # +############# + +# Goto working directory +cd `dirname $0` + +# Source utils: +source common.sh + +# Clean traffic traces: +rm -f ../../launcher.log* + +# Send incorrect AAR: +send_hex $REQ1_HEX & + +# Monitor activity: +monitor_4_message ../../launcher.log.recvfe 10 + +# Check if message was received: +[ $? -ne 0 ] && test_failed "Missing answer from the server" + +# Check launcher.log.recvfe: +check_pattern "" ../../launcher.log.recvfe +check_pattern "( *)/dev/null + res=${PIPESTATUS[2]} + [ $? -ne 0 ] && _exit "Test failed: miss pattern !!" +} + +test_ok () { + echo + echo $1 + echo "Test OK !" + echo + exit 0 +} + +test_failed () { + echo + echo $1 + echo "Test FAILED !" + echo + exit 1 +} + + +# $1: traffic log to monitor +# $2: timeout (request expiration) in seconds +# Result: cats the message when completed +monitor_4_message () { + 0>$1 + rm -f .msg_received + + [ -z "$2" ] && _exit "ERROR: must provide '$FUNCNAME' timeout (second argument)" + sleep $2 & + local timerPid=$! + + # Monitor for incoming message: + tail -n0 -F --pid=$timerPid $1 | while read line + do + if echo $line | grep "^" >/dev/null; then + echo "Message received" + # stop the timer + kill -13 $timerPid + touch .msg_received + fi + done + + if [ ! -f .msg_received ]; then + echo "Timeout expired" + return 1 + fi + + return 0 +} + +############# +# EXECUTION # +############# + +# Trap sigint signal: +trap sigint_handler SIGINT + diff --git a/example/diameter/launcher/deployments/ft-client/tests/experiment2/ProtocolErrors/BadAARtoServer/aar-bad.hex b/example/diameter/launcher/deployments/ft-client/tests/experiment2/ProtocolErrors/BadAARtoServer/aar-bad.hex new file mode 120000 index 0000000..4c9a36f --- /dev/null +++ b/example/diameter/launcher/deployments/ft-client/tests/experiment2/ProtocolErrors/BadAARtoServer/aar-bad.hex @@ -0,0 +1 @@ +../../../../hex_examples/aar-bad.hex \ No newline at end of file diff --git a/example/diameter/launcher/deployments/ft-client/tests/experiment2/ProtocolErrors/BadAARtoServer/aar2-bad.hex b/example/diameter/launcher/deployments/ft-client/tests/experiment2/ProtocolErrors/BadAARtoServer/aar2-bad.hex new file mode 120000 index 0000000..5a6586d --- /dev/null +++ b/example/diameter/launcher/deployments/ft-client/tests/experiment2/ProtocolErrors/BadAARtoServer/aar2-bad.hex @@ -0,0 +1 @@ +../../../../hex_examples/aar2-bad.hex \ No newline at end of file diff --git a/example/diameter/launcher/deployments/ft-client/tests/experiment2/ProtocolErrors/BadAARtoServer/aar3-bad.hex b/example/diameter/launcher/deployments/ft-client/tests/experiment2/ProtocolErrors/BadAARtoServer/aar3-bad.hex new file mode 120000 index 0000000..6705cc4 --- /dev/null +++ b/example/diameter/launcher/deployments/ft-client/tests/experiment2/ProtocolErrors/BadAARtoServer/aar3-bad.hex @@ -0,0 +1 @@ +../../../../hex_examples/aar3-bad.hex \ No newline at end of file diff --git a/example/diameter/launcher/deployments/ft-client/tests/experiment2/ProtocolErrors/BadAARtoServer/case_1.tc b/example/diameter/launcher/deployments/ft-client/tests/experiment2/ProtocolErrors/BadAARtoServer/case_1.tc new file mode 100644 index 0000000..693bc94 --- /dev/null +++ b/example/diameter/launcher/deployments/ft-client/tests/experiment2/ProtocolErrors/BadAARtoServer/case_1.tc @@ -0,0 +1,11 @@ +# Bad length encoded on grouped Subscription-Id length field (not multiple of 4). + +# Send malformed AAR to the server: +SENDHEX2E aar-bad.hex + +# Wait for message: +WAIT4MESSAGE + +# Check Failed-AVP & Subscription-Id within: +CHECKPATTERN +CHECKPATTERN ( *) Media-Sub-Component -> Flow-Status) + +# Send malformed AAR to the server: +SENDHEX2E aar2-bad.hex + +# Wait for message: +WAIT4MESSAGE + +# Check Failed-AVP & Subscription-Id within: +CHECKPATTERN +CHECKPATTERN ( *) Media-Sub-Component -> Flow-Status) + +# Send malformed AAR to the server: +SENDHEX2E aar3-bad.hex + +# Wait for message: +WAIT4MESSAGE + +# Check Failed-AVP & Subscription-Id within: +CHECKPATTERN +CHECKPATTERN ( *)( *)( *) diff --git a/example/diameter/launcher/deployments/ft-client/tests/experiment2/go.sh b/example/diameter/launcher/deployments/ft-client/tests/experiment2/go.sh new file mode 100755 index 0000000..44bd53f --- /dev/null +++ b/example/diameter/launcher/deployments/ft-client/tests/experiment2/go.sh @@ -0,0 +1,194 @@ +#!/bin/bash + +############# +# VARIABLES # +############# +SCR_DIR=`dirname $0` +tmpdir=$(mktemp -d) +SCR_BN=`basename $0` +OPER_SCR=../../operation.sh +RESULT_LOG=result.log +RECV_LOG=../../launcher.log.recvfe + +############# +# FUNCTIONS # +############# + +sigint_handler () { + _exit "Script interrupted. Cleanup and exit ..." +} + +# $1: message; $2: optional rc (1 by default) +_exit () { + rc=1 + [ -n "$2" ] && rc=$2 + echo + echo -e $1 + echo + rm -rf $tmpdir + exit $rc +} + +# $1: hex formatted file to send to the server +operation_sendxml2e () { + sleep 0.5 + $OPER_SCR "sendxml2e|$1" + return $? +} + +# $1: hex formatted file to send to the server +operation_sendhex2e () { + sleep 0.5 + $OPER_SCR "sendhex2e|$1" + return $? +} + +# $1: file to monitor +# $2: timeout (request expiration) in seconds +# Result: cats the message when completed +wait4message () { + 0>$1 + rm -f .msg_received + + [ -z "$2" ] && _exit "ERROR: must provide '$FUNCNAME' timeout (second argument)" + sleep $2 & + local timerPid=$! + + # Monitor for incoming message: + tail -n0 -F --pid=$timerPid $1 | while read line + do + if echo $line | grep "^" >/dev/null; then + echo "Message received:" + echo + cat $1 + # stop the timer + kill -13 $timerPid + touch .msg_received + fi + done + + if [ ! -f .msg_received ]; then + echo "Timeout expired" + return 1 + fi + + return 0 +} + +# xml content is serialized (removing CR's) to ease the pattern matching: +# $1: pattern; $2: file +check_pattern () { + echo -n "Matching pattern '$1' in file '$2' ... " + cat $2 | tr '\n' ' ' | egrep "$1" >/dev/null + [ $? -ne 0 ] && { echo "ERROR" ; test_failed ; return 1 ; } + echo "OK" + return 0 +} + +# $1: pattern file; $2: file +check_pattern_file () { + echo -n "Matching whole file '$1' in file '$2' ... " + grep -f $1 $2 >/dev/null + [ $? -ne 0 ] && { echo "ERROR" ; test_failed ; return 1 ; } + echo "OK" + return 0 +} + +# Tests result: +test_ok () { + echo "Verdict: $TC Ok" | tee -a $RESULT_LOG +} + +test_failed () { + echo "Verdict: $TC Failed" | tee -a $RESULT_LOG +} + +process_tc () { + local tc_dn=`dirname $TC` + + echo + echo "***** Executing '$TC' ..." + + grep -v ^# $TC > $tmpdir/tc + while read -r line + do + oper=$(echo $line | awk '{ print $1 }') + param1="$(echo $line | cut -d' ' -f2-)" + + case $oper in + SENDXML2E) + operation_sendxml2e $tc_dn/$param1 & + [ $? -ne 0 ] && return 1 + ;; + + SENDHEX2E) + operation_sendhex2e $tc_dn/$param1 & + [ $? -ne 0 ] && return 1 + ;; + + WAIT4MESSAGE) + wait4message $RECV_LOG 5 + [ $? -ne 0 ] && return 1 + ;; + + CHECKPATTERN) + check_pattern "$param1" $RECV_LOG + [ $? -ne 0 ] && return 1 + ;; + + CHECKPATTERNFILE) + check_pattern_file "$param1" $RECV_LOG + [ $? -ne 0 ] && return 1 + ;; + + esac + + done < $tmpdir/tc + + return 0 +} + + +############# +# EXECUTION # +############# + +# Trap sigint: +trap sigint_handler SIGINT + +# Working directory is script dirname: +cd $SCR_DIR + +# Intro: +echo +echo "------------------" +echo "Test cases manager" +echo "------------------" +# Mandatory parameter: +[ -z "$1" ] && _exit "Usage: $SCR_BN " +[ ! -f "$1" -a ! -d "$1" ] && _exit "Invalid file or directory '$1' !!" + +# Gather .tc files to be processed: +[ ! -f $1 ] && echo -e "\nGathering list of test cases from '`readlink -f $1`' ..." +echo +find $1 -name *.tc | xargs -L1 readlink -f | tee -a $tmpdir/tc_list +echo +echo + +echo "Start processing test cases:" +echo "----------------------------" +# Process test cases: +0> $RESULT_LOG +for TC in `cat $tmpdir/tc_list` +do + process_tc + if [ $? -eq 0 ]; then + test_ok + else + test_failed + cat $RECV_LOG + fi +done + +_exit "Done !" 0 + diff --git a/example/diameter/launcher/deployments/ft-client/xml_examples b/example/diameter/launcher/deployments/ft-client/xml_examples new file mode 120000 index 0000000..903e6fe --- /dev/null +++ b/example/diameter/launcher/deployments/ft-client/xml_examples @@ -0,0 +1 @@ +../basic/xml_examples \ No newline at end of file diff --git a/example/diameter/launcher/main.cpp b/example/diameter/launcher/main.cpp index fdb69d3..54fcbdc 100644 --- a/example/diameter/launcher/main.cpp +++ b/example/diameter/launcher/main.cpp @@ -363,6 +363,14 @@ bool Launcher::getDataBlockFromHexFile(const std::string &pathfile, anna::DataBl if(infile.is_open()) { infile >> buffer; std::string hexString(buffer, strlen(buffer)); + // Allow colon separator in hex string: we have to remove them before processing with 'fromHexString': + hexString.erase(std::remove(hexString.begin(), hexString.end(), ':'), hexString.end()); + LOGDEBUG( + std::string msg = "Hex string (remove colons if exists): "; + msg += hexString; + anna::Logger::debug(msg, ANNA_FILE_LOCATION); + ); + anna::functions::fromHexString(hexString, db); // Close file infile.close(); diff --git a/example/diameter/launcher/resources/advanced/1.xml b/example/diameter/launcher/resources/advanced/1.xml deleted file mode 100644 index dcd18b9..0000000 --- a/example/diameter/launcher/resources/advanced/1.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/example/diameter/launcher/resources/advanced/1xml-23.txt b/example/diameter/launcher/resources/advanced/1xml-23.txt deleted file mode 100644 index c0d8b4c..0000000 --- a/example/diameter/launcher/resources/advanced/1xml-23.txt +++ /dev/null @@ -1,2 +0,0 @@ -Encode 1.xml to 2.hex|code|1.xml|2.hex -Decode 2.hex to 3.xml (we will diff 1.xml and 3.xml)|decode|2.hex|3.xml diff --git a/example/diameter/launcher/resources/advanced/README b/example/diameter/launcher/resources/advanced/README deleted file mode 100644 index 52393f8..0000000 --- a/example/diameter/launcher/resources/advanced/README +++ /dev/null @@ -1,23 +0,0 @@ - -ABOUT CONTENT -------------- -Stacks available at './stacks'. -The launcher uses the configuration given by '.dictionary' which points to a specification list. -Available different setups by mean files named as '.dictionary__'. - -Template for xml messages (message.dtd) and dictionaries (dictionary.dtd) are informative, not -actually required by process. Located at './DTDs'. - -STARTING THE PROCESS --------------------- -Start with 'run.sh'. You could manually edit such script adding parameters as '-trace debug' to -get complete 'launcher.traces'. Execute 'ADL-launcher' without arguments to see a complete -command-line help. - -DEPLOYED SCRIPTS ----------------- -You could get help about installed resources by mean 'help.sh', which launch a help request to -the started ADL-launcher process http interface. All the implemented http operations could be -launched through a script to make easy use. The http client 'curl' is used by default due to -its presence on common linux distributions. - diff --git a/example/diameter/launcher/resources/advanced/answerXml.sh b/example/diameter/launcher/resources/advanced/answerXml.sh deleted file mode 100755 index ce4aa40..0000000 --- a/example/diameter/launcher/resources/advanced/answerXml.sh +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/bash -> curl_log.txt -TRACE="--trace-ascii curl_log.txt" -SERVER=`cat .httpServer` - -echo -echo -echo "Use: $0 [xml_file] [2e]" -echo -echo "Programm 'xml_file' answer to the diameter client or to the server (entity) when" -echo "'2e' parameter is provided. If missing xml file, current programmed answers will" -echo "be shown: '$0' (answers to client), '$0 2e' (answers to server)." -echo -if test "$1" != "" -then - if test "$1" = "2e" - then - operation="answerxml2e" - else - [[ ! -f "$1" ]] && { echo "ERROR: file '$1' not found" ; echo; echo; exit ; } - operation="answerxml|$1" - [[ "$2" = "2e" ]] && operation="answerxml2e|$1" - fi -else - operation="answerxml" -fi -echo -curl -m 1 --data "$operation" $TRACE ${SERVER} - diff --git a/example/diameter/launcher/resources/advanced/args.txt b/example/diameter/launcher/resources/advanced/args.txt deleted file mode 100755 index d5f4afb..0000000 --- a/example/diameter/launcher/resources/advanced/args.txt +++ /dev/null @@ -1,6 +0,0 @@ --httpServer `grep -v ^# .httpServer` --dictionary `grep -v ^# .dictionary` --diameterServer `grep -v ^# .diameterServer` --diameterServerSessions `grep -v ^# .diameterServerSessions` --entity `grep -v ^# .entity` --entityServerSessions `grep -v ^# .entityServerSessions` diff --git a/example/diameter/launcher/resources/advanced/batch.sh b/example/diameter/launcher/resources/advanced/batch.sh deleted file mode 100755 index 9699243..0000000 --- a/example/diameter/launcher/resources/advanced/batch.sh +++ /dev/null @@ -1,60 +0,0 @@ -#!/bin/bash -> curl_log.txt -TRACE="--trace-ascii curl_log.txt" -SERVER=`cat .httpServer` - -use () { - - echo "Use: $0 [time between operations: 0 second by default]" - echo - echo " Batch launcher script" - echo " ---------------------" - echo - echo " Test file must contain a operations with this syntax: |||..." - echo " Three operations: code, decode and sendxml:" - echo - echo " code|| i.e.: code|1.xml|2.hex" - echo " decode|| i.e.: decode|2.hex|1.xml-bis" - echo " sendxml| i.e.: sendxml|1.xml" - echo - echo " Test file example:" - echo - echo " $0 1xml-23.txt" - echo - echo " where 1xml-23.txt contains:" - echo " Encode 1.xml to 2.hex|code|1.xml|2.hex" - echo " Decode 2.hex to 3.xml (we will diff 1.xml and 3.xml)|decode|2.hex|3.xml" - echo - echo - echo " Test file could contain any number of operations and could include comments (will be ignored)." - echo - exit -} - -echo -echo -[[ "$1" = "" ]] && use -LAPSE=${2:-0} -echo -echo "Test '$1' is going to be launched:" -echo -cat $1 -echo -echo "Pulse ENTER para lanzar, CTRL+C para abortar..." -read dummy - -while read -r line -do - comment=$(echo $line | grep "^#") - ok= - [[ "$comment" = "" ]] && { [[ "$line" != "" ]] && ok=s ; } - if test "$ok" = "s" - then - echo "Launching $(echo $line | cut -d'|' -f1) ..." - sleep $LAPSE - operation=$(echo $line | cut -d'|' -f2-) - curl -m 1 --data "$operation" $TRACE ${SERVER} - fi - -done < $1 - diff --git a/example/diameter/launcher/resources/advanced/burst.sh b/example/diameter/launcher/resources/advanced/burst.sh deleted file mode 100755 index b05b6e0..0000000 --- a/example/diameter/launcher/resources/advanced/burst.sh +++ /dev/null @@ -1,184 +0,0 @@ -#!/bin/bash -> curl_log.txt -TRACE="--trace-ascii curl_log.txt" -SERVER=`cat .httpServer` -burstMargin__dflt=1 - -salir () { - echo - echo $1 - echo - exit -} - -calc () { echo "$1" | bc -l ; } - -entero () { - limpio=$(calc "scale=0;${1}/1") - [[ $limpio != $1 ]] && salir "Invalid value '$1'. Must be integer" -} - -uso () { - - echo "Load tests configuration script" - echo - echo "Use: $0 [action parameters]" - echo - echo " clear:" - echo " Clears all loaded burst messages." - echo - echo " load :" - echo " Loads 'amount' messages for the provided traffic type. For example:" - echo " $0 load 2000 sms" - echo - echo " start [initial launch: default $burstMargin__dflt]:" - echo " Starts the message sending from the begining of the burst list loaded," - echo " with a certain initial load. For example:" - echo " $0 start 200" - echo - echo " push [amount: default $burstMargin__dflt]:" - echo " Launch 'amount' messages as initial load does (non-asynchronous mode)." - echo " It works even if burst launch is stopped. Useful to achieve congestion" - echo " conditions. For example:" - echo " $0 push 300" - echo - echo " pop [amount: default $burstMargin__dflt]:" - echo " Skip send burst messages in order to reduce over-the-air requests." - echo - echo " stop:" - echo " Stops the burst cycle at the current position. It could affect sessions" - echo " on the air (i.e. data contexts). Totally safe for IEC scenaries as SMS." - echo - echo " resume:" - echo " Resume an stopped burst launch from the same point (start will reset" - echo " the work pointer to the first burst list position). This is equivalent" - echo " to one-message-push operation." - echo - echo " repeat [[yes] | no]:" - echo " Restarts the burst launch cycle when finished." - echo - echo " send [amount: default 1]:" - echo " send messages from burst list. The main difference with start/push operations" - echo " is that burst won't be awaken. Externally we could control sending time (no" - echo " request will be sent for answers). When reach the last position, starts again." - echo - echo " sendXS [amount: default -1 (no limit)]:" - echo " send messages from burst list with the TPS provided. User could hot change" - echo " speed by mean 'echo > .tps' at another shell. You can stop the load" - echo " removing that hidden file or using CTRL+C from the shell where you launched" - echo " the burst command. Real tps is dumped on '.real_tps' file during testing." - echo " You could limit the amount of messages sent by mean the second parameter." - echo " No limit is established by default (-1 or negative value)." - echo - echo " goto :" - echo " Updates current burst pointer position." - echo - echo " look :" - echo " Show programmed burst message for order provided." - echo - echo - salir -} - -_curl () { - curl -m 5 --data "$1" $TRACE ${SERVER} -} - -echo -echo -[[ "$1" = "" ]] && uso -case $1 in - clear) _curl "burst|clear" - ;; - load) [[ "$3" = "" ]] && uso - [[ ! -f "${3}.sh" ]] && salir "Burst generation file '${3}.sh' not found!" - entero $2 - if test "$3" = "data" - then - count=$2 - RESTO=$((count%4)) - [[ "$RESTO" != "0" ]] && salir "Data context should load a multiple of 4 (messages generated by data.sh)" - fi - count=1 - while test "$count" -le "$2" - do - ${3}.sh $count > .${3}.xml - echo -n "Loading message ${count}; " - _curl "burst|load|.${3}.xml" - count=$((count+1)) - done - ;; - start) load=$burstMargin__dflt - [[ "$2" != "" ]] && load=$2 - entero $load - _curl "burst|start|$load" - ;; - pop) release=$burstMargin__dflt - [[ "$2" != "" ]] && release=$2 - entero $release - _curl "burst|pop|$release" - ;; - push) [[ "$2" = "" ]] && uso - entero $2 - _curl "burst|push|$2" - ;; - stop) _curl "burst|stop" - ;; - resume) _curl "burst|push|1" - ;; - repeat) repeat=yes - [[ "$2" != "" ]] && repeat=$2 - _curl "burst|repeat|$repeat" - ;; - send) amount=1 - [[ "$2" != "" ]] && amount=$2 - entero $amount - _curl "burst|send|$amount" - ;; - sendXS) [[ "$2" = "" ]] && uso - limit=$3 - [[ "$limit" = "" ]] && limit=-1 - entero $2 - entero $limit - TPS=0 - count=0 - amount=1 - echo $2 > .tps - while test -f .tps - do - [[ "$count" = "$limit" ]] && break - BEFORE_ns=`date +%s%N` - READ_TPS=`cat .tps` - # Hot change could make .tps still unavailable: - [[ "$READ_TPS" = "" ]] && READ_TPS=$TPS - # Volvemos a calcular medias (REAL_TPS) cada 10 segundos o cuando cambia el TPS en caliente: - [[ "$READ_TPS" != "$TPS" ]] && { BEGIN_ns=$BEFORE_ns ; count=0 ; } - [[ $count = $((10*TPS)) ]] && { BEGIN_ns=$BEFORE_ns ; count=0 ; } - TPS=$READ_TPS - [[ "$TPS" = "0" ]] && salir "Test stopped due to 0-tps value read" - # Background: - _curl "burst|send|$amount" & - count=$((count+amount)) - AFTER_ns=`date +%s%N` - # Real tps: - REAL_TPS=$(calc "1000000000 * $count / ($AFTER_ns - $BEGIN_ns)") - echo $REAL_TPS > .real_tps - - COEF=1 - [[ $(calc "$TPS > $REAL_TPS") = "1" ]] && COEF=$(calc "$REAL_TPS / $TPS") - K=$(calc "$COEF ^ 10") - amount=$(calc "scale=0;1/$K") - usleep $(calc "$K * 1000000/$TPS") - done - ;; - goto) [[ "$2" = "" ]] && uso - entero $2 - _curl "burst|goto|$2" - ;; - look) [[ "$2" = "" ]] && uso - entero $2 - _curl "burst|look|$2" - ;; - *) uso -esac - diff --git a/example/diameter/launcher/resources/advanced/clientSocketManager.sh b/example/diameter/launcher/resources/advanced/clientSocketManager.sh deleted file mode 100755 index 4c801b2..0000000 --- a/example/diameter/launcher/resources/advanced/clientSocketManager.sh +++ /dev/null @@ -1,70 +0,0 @@ -#!/bin/bash -> curl_log.txt -TRACE="--trace-ascii curl_log.txt" -SERVER=`cat .httpServer` -ENTITY=`cat .entity 2>/dev/null` -# If missing following, 1 is assigned (ENTITY_SS_1 is ENTITY_SS - 1) -ENTITY_SS=`cat .entityServerSessions 2>/dev/null` -[[ "$ENTITY_SS" = "" ]] && ENTITY_SS=1 -TARGET=$2 - -use () { - echo - echo - echo "Use: $0 \"[
:]|[socket id]\"" - echo - echo "Hides/shows/query hidden state/query shown state, the socket/s provided." - echo "If missing server (first parameter) all applications sockets will be affected by action." - echo "If missing socket (second parameter) for specific server, all its sockets will be affected by action." - echo - exit -} - -states () { - echo - echo "Select option to switch (0 = quit):" - echo - option=1 - for i in `echo $ENTITY | sed 's/,/ /g'` - do - for j in `seq 0 $ENTITY_SS_1` - do - TARGET="${i}|${j}" - RES=$(curl -m 1 --data "shown|$TARGET" ${SERVER} 2>&1 | tail -1 | grep "true$") - res=hidden - [[ "$RES" != "" ]] && res=shown - echo "${option}. $TARGET ($res)" - action=show - [[ "$RES" != "" ]] && action=hide - echo "curl -m 1 --data \"$action|$TARGET\" ${SERVER}" > .switch_${option} - chmod a+x .switch_${option} - option=$((option+1)) - done - done - echo -} - -if test "$ENTITY" != "" -then - ENTITY_SS_1=$((ENTITY_SS-1)) - while true - do - states - read option - [[ "$option" = "0" ]] && break - .switch_${option} - done - echo - echo "Exiting" - rm .switch_* - exit -else - [[ "$1" = "" ]] && use -fi - -echo -echo -operation="$1|$TARGET" -[[ "$TARGET" = "" ]] && operation="$1" -curl -m 1 --data "$operation" $TRACE ${SERVER} - diff --git a/example/diameter/launcher/resources/advanced/code.sh b/example/diameter/launcher/resources/advanced/code.sh deleted file mode 100755 index 9ca200c..0000000 --- a/example/diameter/launcher/resources/advanced/code.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/bash -> curl_log.txt -TRACE="--trace-ascii curl_log.txt" -SERVER=`cat .httpServer` - -use () { - - echo "Use: $0 " - echo - echo "Creates '.hex' with encoded result." - echo - exit -} - -echo -[[ "$1" = "" ]] && use -[[ ! -f "$1" ]] && { echo "ERROR: file '$1' not found" ; echo; echo; exit ; } -echo -operation="code|$1|${1}.hex" -curl -m 1 --data "$operation" $TRACE ${SERVER} - diff --git a/example/diameter/launcher/resources/advanced/collect.sh b/example/diameter/launcher/resources/advanced/collect.sh deleted file mode 100755 index 5fb95ec..0000000 --- a/example/diameter/launcher/resources/advanced/collect.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/bash -> curl_log.txt -TRACE="--trace-ascii curl_log.txt" -SERVER=`cat .httpServer` -curl -m 1 --data "collect" $TRACE ${SERVER} - diff --git a/example/diameter/launcher/resources/advanced/data-initial.msk b/example/diameter/launcher/resources/advanced/data-initial.msk deleted file mode 100644 index fa6d324..0000000 --- a/example/diameter/launcher/resources/advanced/data-initial.msk +++ /dev/null @@ -1,44 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/example/diameter/launcher/resources/advanced/data-termination.msk b/example/diameter/launcher/resources/advanced/data-termination.msk deleted file mode 100644 index f15396f..0000000 --- a/example/diameter/launcher/resources/advanced/data-termination.msk +++ /dev/null @@ -1,55 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/example/diameter/launcher/resources/advanced/data-update1.msk b/example/diameter/launcher/resources/advanced/data-update1.msk deleted file mode 100644 index 8883c60..0000000 --- a/example/diameter/launcher/resources/advanced/data-update1.msk +++ /dev/null @@ -1,47 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/example/diameter/launcher/resources/advanced/data-update2.msk b/example/diameter/launcher/resources/advanced/data-update2.msk deleted file mode 100644 index 8784172..0000000 --- a/example/diameter/launcher/resources/advanced/data-update2.msk +++ /dev/null @@ -1,53 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/example/diameter/launcher/resources/advanced/data.sh b/example/diameter/launcher/resources/advanced/data.sh deleted file mode 100755 index 09949ad..0000000 --- a/example/diameter/launcher/resources/advanced/data.sh +++ /dev/null @@ -1,74 +0,0 @@ -#!/bin/bash - -# Generates DATA burst sequence for provided order number (1: first, 2: second, etc.) -# We will generate a simple scenario with initial, two updates and termination, that is to say: four messages: -# 1,2,3,4 5,6,7,8 9,10,11,12 etc. -# -# Category = ((Number-1) % 4) + 1 = 1 for initial, 2 for first update, 3 for second update and 4 for termination -SEQN=$1 -OFFSET=$((SEQN-1)) -CAT=$((OFFSET%4 + 1)) - -salir () { - echo - echo $1 - echo - exit -} - -check_template () { - [[ ! -f $1 ]] && salir "Template file ($1) not found!" -} - -parse () { - cat $1 | sed 's/__HBH_ETE__/'$HBH_ETE'/g' | sed 's/__SID_SUFFIX__/'$SID_SUFFIX'/' \ - | sed 's/__MSISDN__/'$MSISDN'/' | sed 's/__NTPTIMESTAMP__/'$NTP'/' \ - | sed 's/__SID_DI__/'$SID_DI'/' | sed 's/__SID_HIGH__/'$SID_HIGH'/' | sed 's/__SID_LOW__/'$SI_LOW'/' -} - - -[[ "$SEQN" = "" ]] && salir "Use: $0 " -check_template data-initial.msk -check_template data-update1.msk -check_template data-update2.msk -check_template data-termination.msk - -# Session-Id: ';;[;="">]' -# -# We will sequence the otional value with __SID_SUFFIX__, low and high will be constant. - -# Sequence values at templates: -# __HBH_ETE__: 1, 3, 5, etc. (hop-by-hop and end-to-end) -# __SID_SUFFIX__: It could be MSISDN, but we put OFFSET (0, 1, 2, 3, etc.). It's the Session-Id optional part. -# __MSISDN__: 50583211675, 50583211676, 50583211677, etc. Used for User-Name and Subscription-Id-Data -# __NTPTIMESTAMP__: Four values for initial, update1, update2 and termination: 3548171033, 3548171136 (103+), 3548171136(idem), 3548171524(388+) -# This initial time (aproximately 8 Jun 2012 at 19:00). -CUARTO=$((OFFSET/4)) -HBH_ETE=$((1 + 2*OFFSET)) -SID_SUFFIX=$CUARTO -# Example if you want to fix to two sockets (-sessionIdPartForClientSocketIdSelection must be 'optional'): SID_SUFFIX=$((CUARTO%2)) -MSISDN=$((50583211675+CUARTO)) -NTP=$((3548171033+CUARTO)) - -# Helpers to guide derivery (fixed at the moment) -# __SID_DI__: Session-Id diameter identity -# __SID_HIGH__: Session-Id high part -# __SID_LOW__: Session-Id low part -SID_DI=module-2.PTS2-BOG.sandvine.com -SID_HIGH=1287115741 -SI_LOW=0 - -case $CAT in - 1) parse data-initial.msk - ;; - 2) NTP=$((NTP+103)) - parse data-update1.msk - ;; - 3) NTP=$((NTP+103)) - parse data-update2.msk - ;; - 4) NTP=$((NTP+491)) - parse data-termination.msk - ;; -esac - diff --git a/example/diameter/launcher/resources/advanced/decode.sh b/example/diameter/launcher/resources/advanced/decode.sh deleted file mode 100755 index 3924f73..0000000 --- a/example/diameter/launcher/resources/advanced/decode.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/bash -> curl_log.txt -TRACE="--trace-ascii curl_log.txt" -SERVER=`cat .httpServer` - -use () { - - echo "Use: $0 " - echo - echo "Creates '.xml' with decoded result." - echo - exit -} - -echo -[[ "$1" = "" ]] && use -[[ ! -f "$1" ]] && { echo "ERROR: file '$1' not found" ; echo; echo; exit ; } -echo -operation="decode|$1|${1}.xml" -curl -m 1 --data "$operation" $TRACE ${SERVER} - diff --git a/example/diameter/launcher/resources/advanced/diameterServerSessions.sh b/example/diameter/launcher/resources/advanced/diameterServerSessions.sh deleted file mode 100755 index dc72c87..0000000 --- a/example/diameter/launcher/resources/advanced/diameterServerSessions.sh +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/bash -> curl_log.txt -TRACE="--trace-ascii curl_log.txt" -SERVER=`cat .httpServer` - -use () { - - echo "Use: $0 " - echo - echo "Updates the maximum number of accepted connections over diameter server socket." - echo - exit -} - -echo -[[ "$1" = "" ]] && use -echo -operation="diameterServerSessions|$1" -curl -m 1 --data "$operation" $TRACE ${SERVER} - diff --git a/example/diameter/launcher/resources/advanced/help.sh b/example/diameter/launcher/resources/advanced/help.sh deleted file mode 100755 index ebeafff..0000000 --- a/example/diameter/launcher/resources/advanced/help.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/bash -> curl_log.txt -TRACE="--trace-ascii curl_log.txt" -SERVER=`cat .httpServer` -curl -m 1 --data "help" $TRACE ${SERVER} - diff --git a/example/diameter/launcher/resources/advanced/loadXml.sh b/example/diameter/launcher/resources/advanced/loadXml.sh deleted file mode 100755 index 26749d5..0000000 --- a/example/diameter/launcher/resources/advanced/loadXml.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/bash -> curl_log.txt -TRACE="--trace-ascii curl_log.txt" -SERVER=`cat .httpServer` - -use () { - - echo "Use: $0 " - echo - echo "Load xml file and show on stdout again." - echo "It is useful to test xml loader and xml viewer, but also for show aliases and," - echo "if '-ignoreFlags' commandline option is missing, for flag coherence checking." - echo - exit -} - -echo -[[ "$1" = "" ]] && use -[[ ! -f "$1" ]] && { echo "ERROR: file '$1' not found" ; echo; echo; exit ; } -echo -operation="loadxml|$1" -curl -m 1 --data "$operation" $TRACE ${SERVER} - diff --git a/example/diameter/launcher/resources/advanced/pre-start.sh b/example/diameter/launcher/resources/advanced/pre-start.sh deleted file mode 100755 index 49a83ff..0000000 --- a/example/diameter/launcher/resources/advanced/pre-start.sh +++ /dev/null @@ -1,92 +0,0 @@ -#!/bin/bash - -# Remove logs: -rm *.log* *.csv 2>/dev/null - -# Server sockets: -httpServer_dflt=`cat .httpServer 2>/dev/null` -diameterServer_dflt=`cat .diameterServer 2>/dev/null` -diameterServerSessions_dflt=`cat .diameterServerSessions 2>/dev/null` - -# Client sockets: -entity_dflt=`cat .entity 2>/dev/null` -entityServerSessions_dflt=`cat .entityServerSessions 2>/dev/null` - -# Stack: -dictionary_dflt=`cat .dictionary 2>/dev/null` - -echo -echo -# If all have values: -if [ "$httpServer_dflt" != "" -a "$diameterServer_dflt" != "" -a "$diameterServerSessions_dflt" != "" -a \ - "$entity_dflt" != "" -a "$entityServerSessions_dflt" != "" -a \ - "$dictionary_dflt" != "" ] -then - echo "Do you wish to answer wizard commandline configuration ? (y/n) [n]:" - read wizard - [ "$wizard" = "" ] && wizard=n - [ "$wizard" = "n" ] && exit -fi - -# DEFAULTS -[ "$httpServer_dflt" = "" ] && httpServer_dflt="localhost:9000" -[ "$diameterServer_dflt" = "" ] && diameterServer_dflt="localhost:3868" -[ "$diameterServerSessions_dflt" = "" ] && diameterServerSessions_dflt=1 -[ "$entity_dflt" = "" ] && entity_dflt="localhost:4000,localhost:4001" -[ "$entityServerSessions_dflt" = "" ] && entityServerSessions_dflt=0 -[ "$dictionary_dflt" = "" ] && dictionary_dflt=dictionary.xml - - -# Wizard -echo "HTTP Management interface address (using i.e. curl tool) as : socket literal [$httpServer_dflt]:" -read httpServer -[ "$httpServer" = "" ] && httpServer=$httpServer_dflt - -echo "Diameter dictionary: you could use '/opt/bin/anna/example_diameter_stackManagement' tool in order to build" -echo " autonomous dictionaries for any kind of application. The key is to concatenate xml contents (ietf, 3gpp," -echo " vendor-specific, etc.). See 'example/diameter/stackManagement/self_ruling_setups.sh' for this." -echo -echo "This launcher can also join them providing a comma-separated list (dictionaries available on ./stack)." -echo "By default, a QoS Application setup is suggested. Input the desired configuration instead, or press ENTER:" -echo -echo " [$dictionary_dflt]:" -read dictionary -[ "$dictionary" = "" ] && dictionary=$dictionary_dflt - -# As server: -echo "Diameter own server available connections (0: diameter server disabled) [$diameterServerSessions_dflt]:" -read diameterServerSessions -[ "$diameterServerSessions" = "" ] && diameterServerSessions=$diameterServerSessions_dflt - -diameterServer= -if test "$diameterServerSessions" != "0" -then - echo "Diameter own server address as : socket literal [$diameterServer_dflt]:" - read diameterServer -fi -[ "$diameterServer" = "" ] && diameterServer=$diameterServer_dflt - -# As client: -echo "Diameter entity server sessions (0: diameter entity disabled) [$entityServerSessions_dflt]:" -read entityServerSessions -[ "$entityServerSessions" = "" ] && entityServerSessions=$entityServerSessions_dflt - -entity= -if test "$entityServerSessions" != "0" -then - echo "Target diameter entity (pipe-separated : socket literal list) ["$entity_dflt"]:" - read entity -fi -[ "$entity" = "" ] && entity="$entity_dflt" - -# Configure: -echo $httpServer > .httpServer -echo $dictionary > .dictionary -echo $diameterServer > .diameterServer -echo $diameterServerSessions > .diameterServerSessions -echo $entity > .entity -echo $entityServerSessions > .entityServerSessions - -echo -echo - diff --git a/example/diameter/launcher/resources/advanced/sendXml.sh b/example/diameter/launcher/resources/advanced/sendXml.sh deleted file mode 100755 index d9aaa33..0000000 --- a/example/diameter/launcher/resources/advanced/sendXml.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/bash -> curl_log.txt -TRACE="--trace-ascii curl_log.txt" -SERVER=`cat .httpServer` - -use () { - - echo "Use: $0 [2c]" - echo - echo "Sends 'xml_file' to the diameter server or to the client when '2c' parameter is provided." - echo - exit -} - -echo -[[ "$1" = "" ]] && use -[[ ! -f "$1" ]] && { echo "ERROR: file '$1' not found" ; echo; echo; exit ; } -echo -operation="sendxml|$1" -[[ "$2" = "2c" ]] && operation="sendxml2c|$1" - -curl -m 1 --data "$operation" $TRACE ${SERVER} - diff --git a/example/diameter/launcher/resources/advanced/sms.msk b/example/diameter/launcher/resources/advanced/sms.msk deleted file mode 100644 index 7bec3c8..0000000 --- a/example/diameter/launcher/resources/advanced/sms.msk +++ /dev/null @@ -1,90 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/example/diameter/launcher/resources/advanced/sms.sh b/example/diameter/launcher/resources/advanced/sms.sh deleted file mode 100755 index d0b1e63..0000000 --- a/example/diameter/launcher/resources/advanced/sms.sh +++ /dev/null @@ -1,30 +0,0 @@ -#!/bin/bash - -# Generates SMS burst sequence for provided order number (1: first, 2: second, etc.) -SEQN=$1 - -salir () { - echo - echo $1 - echo - exit -} - -[[ "$SEQN" = "" ]] && salir "Use: $0 " -[[ ! -f sms.msk ]] && salir "Template file (sms.msk) not found!" - -# Sequence values at template sms.msk: -# __HBH_ETE__: 1, 3, 5, etc. (hop-by-hop and end-to-end) -# __SID_LOW__: 1000, 1001, 1002, etc. (Session-Id sequence append) -# __MSISDN__: 5555100000, 5555100001, 5555100002, etc. (First and Third Address-Data) -# __IMSI__: 262075555100000, 262075555100001, 262075555100002, etc. (Second Address-Data) - -OFFSET=$((SEQN-1)) - -HBH_ETE=$((1 + 2*OFFSET)) -SID_LOW=$((1000+OFFSET)) -MSISDN=$((5555100000+OFFSET)) -IMSI=$((262075555100000+OFFSET)) - -cat sms.msk | sed 's/__HBH_ETE__/'$HBH_ETE'/g' | sed 's/__SID_LOW__/'$SID_LOW'/' \ - | sed 's/__MSISDN__/'$MSISDN'/' | sed 's/__IMSI__/'$IMSI'/' diff --git a/example/diameter/launcher/resources/basic/README b/example/diameter/launcher/resources/basic/README deleted file mode 100644 index dc46f77..0000000 --- a/example/diameter/launcher/resources/basic/README +++ /dev/null @@ -1,33 +0,0 @@ -ABOUT CONTENT -------------- -Template for xml messages (message.dtd) and dictionaries (dictionary.dtd) are informative, not -actually required by process. They are located at './DTDs'. Stacks are available at './stacks'. -There are also some stuff (hex/xml examples, etc.) which could be useful. - -Firstly you have to configure this directory in order to choose the type of launcher which will -be preconfigured for your basic needs: client, server, balancer (proxy) and dummy process (this -last is used for code/encode and does not launch any communication interface). - -If you are going to launch different processes, we recommend to clone this whole directory into -another one (call it 'ADL-client', 'ADL-server_2', 'Diameter_proxy', or whatever you want), and -then configure it again. - -Execute './configure.sh' and follow the intructions. You can call this several times, but the -last configuration will be the one which prevails. - -STARTING THE PROCESS --------------------- -After configuring the ADL execution context, a new script has been created: 'run.sh'. -You can manually edit such script adding parameters as '-trace debug' to get complete traces, -or adapt the communication endpoints for your environment. - -Launch the executable process without arguments to see a complete command-line help. -Don't be scared. There are plenty of possibilities but the 'run.sh' script has been prepared -for the type of launcher you wanted. - -OPERATION ---------- -Management interface for lite version is based on SIGUSR2 signal caugh. Use './operation.sh' -script to send any operation to the process. Ask for help with that script to see all the -operations supported. - diff --git a/example/diameter/launcher/resources/basic/configure.sh b/example/diameter/launcher/resources/basic/configure.sh deleted file mode 100755 index a5d1515..0000000 --- a/example/diameter/launcher/resources/basic/configure.sh +++ /dev/null @@ -1,109 +0,0 @@ -#!/bin/bash - -############# -# VARIABLES # -############# - -# Diameter dictionary: -STD_DICTIONARY=stacks/avps_etsi.xml,stacks/avps_ietf.xml,stacks/avps_tgpp.xml,stacks/commands_baseProtocol.xml -APP_DICTIONARY=stacks/commands_qosControl.xml -DICTIONARY=$STD_DICTIONARY,$APP_DICTIONARY -# Perhaps the stack is not fully defined: -#KINDNESS=-ignoreErrors -# But we prefer stack to generate Failed-AVP automatically: -KINDNESS= - -# Communication endpoints: -LOCAL_STANDARD_ENDPOINT=localhost:3868 -EXAMPLE_ENTITY_4_BALANCER=192.168.12.11:3868,192.168.12.21:3868 -CONNS=10 - -# General -EXE_BN=ADL-launcher - -# Tracing: -TRACING="-cntDir counters" -# need detailed traces ?: -#TRACING="$TRACING -trace debug" - -############# -# FUNCTIONS # -############# - -_exit () { - echo - echo $1 - echo - exit 1 -} - -# $1: process name -createRunScript () { - - cat << EOF > run.sh -#!/bin/bash -cd \`dirname \$0\` -STARTED=\`pgrep $1 2>/dev/null\` -[ \$? -eq 0 ] && { echo "Already started!"; echo "\$STARTED" ; exit 1 ; } -0> launcher.traces -rm -f counters/* -# Execution line: -./$@ & -echo \$! > .pid -EOF - - chmod a+x run.sh -} - -# $1: input option (c, s, b, d) -# Retuns the type of launcher logical name for the input option -get_tol () { - [ "$1" = "c" ] && echo client - [ "$1" = "s" ] && echo server - [ "$1" = "b" ] && echo balancer - [ "$1" = "d" ] && echo dummy -} - -############# -# EXECUTION # -############# -cd `dirname $0` -SCR_DIR=`pwd` -echo -echo -echo "Configure a (c)lient, (s)erver, (b)alancer or (d)ummy [c]:" -read option -[ "$option" = "" ] && option=c -tol=$(get_tol $option) -[ "$tol" = "" ] && _exit "Option '$option' not implemented !!" - -# Run script: -EXE_LINK=ADL-$tol -ln -sf $EXE_BN $EXE_LINK - -case $tol in - - client) - ENTITY=$LOCAL_STANDARD_ENDPOINT - createRunScript $EXE_LINK -dictionary $DICTIONARY -entity $ENTITY -entityServerSessions $CONNS -diameterServerSessions 0 $KINDNESS $TRACING & - ;; - - server) - SERVER=$LOCAL_STANDARD_ENDPOINT - createRunScript $EXE_LINK -dictionary $DICTIONARY -diameterServer $SERVER -diameterServerSessions $CONNS -entityServerSessions 0 $KINDNESS $TRACING & - ;; - - balancer) - SERVER=$LOCAL_STANDARD_ENDPOINT - ENTITY=$EXAMPLE_ENTITY_4_BALANCER - createRunScript $EXE_LINK -dictionary $DICTIONARY -entity $ENTITY -entityServerSessions $CONNS -diameterServer $SERVER -diameterServerSessions $CONNS -balance $KINDNESS $TRACING & - ;; - - dummy) - createRunScript $EXE_LINK -dictionary $DICTIONARY -entityServerSessions 0 -diameterServerSessions 0 $KINDNESS $TRACING & - ;; - -esac - -echo "Created 'run.sh' script !" -echo diff --git a/example/diameter/launcher/resources/basic/hex_examples/aar-bad.hex b/example/diameter/launcher/resources/basic/hex_examples/aar-bad.hex deleted file mode 100644 index 7588fa1..0000000 --- a/example/diameter/launcher/resources/basic/hex_examples/aar-bad.hex +++ /dev/null @@ -1 +0,0 @@ -01000150c000010901000014000000000000000000000107400000246f6373333b313333323737343433303b313b31333332373734343330000001024000000c01000014000001084000000c4f435333000001284000000c4f4353330000011b4000000c4f435333000001254000000c4f435333000001f8c000000f000028af3132320000000205c000006c000028af00000206c0000010000028af00000000000001f8c000000f000028af3132320000000204c0000010000028af0000007f00000203c0000010000028af00000085000001ffc0000010000028af00000002000001ca80000010000032db000000000000020fc0000010000028af00000000000001bb40000021000001c24000000c00000000000001bc4000001136323630333730393900000000000008400000133139322e3136382e302e31000000001e400000145741502e4d4f564953544152 diff --git a/example/diameter/launcher/resources/basic/hex_examples/aar.hex b/example/diameter/launcher/resources/basic/hex_examples/aar.hex deleted file mode 100644 index 9a2aeb9..0000000 --- a/example/diameter/launcher/resources/basic/hex_examples/aar.hex +++ /dev/null @@ -1 +0,0 @@ -01000150c000010901000014000000000000000000000107400000246f6373333b313333323737343433303b313b31333332373734343330000001024000000c01000014000001084000000c4f435333000001284000000c4f4353330000011b4000000c4f435333000001254000000c4f435333000001f8c000000f000028af3132320000000205c000006c000028af00000206c0000010000028af00000000000001f8c000000f000028af3132320000000204c0000010000028af0000007f00000203c0000010000028af00000085000001ffc0000010000028af00000002000001ca80000010000032db000000000000020fc0000010000028af00000000000001bb40000028000001c24000000c00000000000001bc4000001136323630333730393900000000000008400000133139322e3136382e302e31000000001e400000145741502e4d4f564953544152 diff --git a/example/diameter/launcher/resources/basic/hex_examples/aar2-bad.hex b/example/diameter/launcher/resources/basic/hex_examples/aar2-bad.hex deleted file mode 100644 index 4b5c1ed..0000000 --- a/example/diameter/launcher/resources/basic/hex_examples/aar2-bad.hex +++ /dev/null @@ -1 +0,0 @@ -0100017cc000010901000014000000000000000000000107400000246f6373333b313333323737343433303b313b31333332373734343330000001024000000c01000014000001084000000c4f435333000001284000000c4f4353330000011b4000000c4f435333000001254000000c4f435333000001f8c000000f000028af3132320000000205c0000098000028af00000206c0000010000028af0000000000000207c000002c000028af000001fdc0000010000028af00000037000001ffc000000a000028af00000000000001f8c000000f000028af3132320000000204c0000010000028af0000007f00000203c0000010000028af00000085000001ffc0000010000028af00000002000001ca80000010000032db000000000000020fc0000010000028af00000000000001bb40000028000001c24000000c00000000000001bc4000001136323630333730393900000000000008000000133139322e3136382e302e31000000001e000000145741502e4d4f564953544152 diff --git a/example/diameter/launcher/resources/basic/hex_examples/aar3-bad.hex b/example/diameter/launcher/resources/basic/hex_examples/aar3-bad.hex deleted file mode 100644 index 62f45ba..0000000 --- a/example/diameter/launcher/resources/basic/hex_examples/aar3-bad.hex +++ /dev/null @@ -1 +0,0 @@ -0100017cc000010901000014000000000000000000000107400000246f6373333b313333323737343433303b313b31333332373734343330000001024000000c01000014000001084000000c4f435333000001284000000c4f4353330000011b4000000c4f435333000001254000000c4f435333000001f8c000000f000028af3132320000000205c0000098000028af00000206c0000010000028af0000000000000207c000002c000028af000001fdc0000010000028af00000037000001ffc0000010000028af00000010000001f8c000000f000028af3132320000000204c0000010000028af0000007f00000203c0000010000028af00000085000001ffc0000010000028af00000002000001ca80000010000032db000000000000020fc0000010000028af00000000000001bb40000028000001c24000000c00000000000001bc4000001136323630333730393900000000000008000000133139322e3136382e302e31000000001e000000145741502e4d4f564953544152 diff --git a/example/diameter/launcher/resources/basic/hex_examples/readme.txt b/example/diameter/launcher/resources/basic/hex_examples/readme.txt deleted file mode 100644 index 6b66557..0000000 --- a/example/diameter/launcher/resources/basic/hex_examples/readme.txt +++ /dev/null @@ -1,16 +0,0 @@ -Bad messages: - -aar-bad.hex: comes from ../xml_examples/aar.xml - Consists in a deliberated bad length encoded on grouped Subscription-Id length field (not multiple of 4). - -aar2-bad.hex: comes from ../xml_examples/aar2.xml - Consists in a deliberated bad length encoded on enumerated Flow-Status avp 2-level nested inside Media-Component-Description: - -> Media-Component-Description (grouped) - -> Media-Sub-Component (grouped) - -> Flow-Status (enumerated) - -aar3-bad.hex: comes from ../xml_examples/aar2.xml - Consists in a deliberated bad value (16) encoded on enumerated Flow-Status avp (range 0-15) 2-level nested inside Media-Component-Description: - -> Media-Component-Description (grouped) - -> Media-Sub-Component (grouped) - -> Flow-Status (enumerated) diff --git a/example/diameter/launcher/resources/basic/hex_examples/tspCCA.hex b/example/diameter/launcher/resources/basic/hex_examples/tspCCA.hex deleted file mode 100644 index 401687a..0000000 --- a/example/diameter/launcher/resources/basic/hex_examples/tspCCA.hex +++ /dev/null @@ -1 +0,0 @@ -0100018c4000011001000016ff7f245e9b81ce71000001074000003f63302d31302d37302d3233382d37342d7735703176657067312e766570632e6572696373736f6e2e73653b313430323932373534343b33000000010c4000000c000007d10000010840000019657063322e6570637265616c6d2e636f6d00000000000128400000146570637265616c6d2e636f6d000001026000000c01000016000001a06000000c000000010000019f6000000c00000000000003f8c000002c000028af00000410c0000010000028af004e200000000411c0000010000028af0007d00000000419c0000058000028af00000404c0000010000028af000000060000040ac000003c000028af00000416c0000010000028af000000030000041780000010000028af000000010000041880000010000028af000000000000027480000038000028af0000010a4000000c000028af0000027580000010000028af000000010000027680000010000028af00000003000003ffc0000010000028af00000002000001164000000c00000005 diff --git a/example/diameter/launcher/resources/basic/hex_examples/tspCCR.hex b/example/diameter/launcher/resources/basic/hex_examples/tspCCR.hex deleted file mode 100644 index 492384a..0000000 --- a/example/diameter/launcher/resources/basic/hex_examples/tspCCR.hex +++ /dev/null @@ -1 +0,0 @@ -010002e8c000011001000016ff7f245e9b81ce71000001074000003f63302d31302d37302d3233382d37342d7735703176657067312e766570632e6572696373736f6e2e73653b313430323932373534343b3300000001026000000c01000016000001084000003263302d31302d37302d3233382d37342d7735703176657067312e766570632e6572696373736f6e2e736500000000012840000018766570632e6572696373736f6e2e73650000011b600000146570637265616c6d2e636f6d000001a06000000c000000010000019f6000000c0000000000000017c000000e000028af80010000000001166000000c00000000000001bb60000028000001c26000000c00000000000001bc60000013343637303139343034313800000000086000000c0a46ee6200000403c0000010000028af0000000500000015e000000d000028af060000000000040880000010000028af000003ec000001ca6000002c000001cb2000000c00000000000001cc2000001833353734373330343030363632383030000003f8c000002c000028af0000041080000010000028af08f0d1800000041180000010000028af02faf0800000041980000058000028af00000404c0000010000028af000000090000040ac000003c000028af0000041680000010000028af000000020000041780000010000028af000000010000041880000010000028af0000000000000012e0000011000028af32343039390000000000041a80000012000028af00010a46ee3a000000000016c0000019000028af8242f099006742f0990186a4010000000000001e6000000d7665706731000000000003e8c0000010000028af0000000000000400c0000010000028af00000001000001f5c0000012000028af00010a46ee3a0000000003fec0000020000028af000001f7c0000013000028af34383030303438000000027480000038000028af0000010a4000000c000028af0000027580000010000028af000000010000027680000010000028af00000003 diff --git a/example/diameter/launcher/resources/basic/operation.sh b/example/diameter/launcher/resources/basic/operation.sh deleted file mode 100755 index 5f3afc0..0000000 --- a/example/diameter/launcher/resources/basic/operation.sh +++ /dev/null @@ -1,33 +0,0 @@ -#!/bin/bash - -############# -# FUNCTIONS # -############# -_exit () { - echo - echo -e $1 - echo - exit 1 -} - -############# -# EXECUTION # -############# -cd `dirname $0` -echo -# Get the PID: -[ ! -f .pid ] && _exit "Can't found '`pwd`/.pid'.\nTry to pgrep your process name and dump pid to that file." -PID=`cat .pid` - -# Send operation: -[ "$1" = "" ] && _exit "Use: $0 ; i.e.: $0 help" -echo $1 > sigusr2.tasks.input -kill -s SIGUSR2 $PID - -sleep 1 -echo -echo -echo "You could see results on '`pwd`/sigusr2.tasks.output' file." -echo -echo - diff --git a/example/diameter/launcher/resources/basic/xml_examples/aar.xml b/example/diameter/launcher/resources/basic/xml_examples/aar.xml deleted file mode 100644 index 1201655..0000000 --- a/example/diameter/launcher/resources/basic/xml_examples/aar.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/example/diameter/launcher/resources/basic/xml_examples/aar2.xml b/example/diameter/launcher/resources/basic/xml_examples/aar2.xml deleted file mode 100644 index c163fb4..0000000 --- a/example/diameter/launcher/resources/basic/xml_examples/aar2.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/example/diameter/launcher/resources/basic/xml_examples/ccr.xml b/example/diameter/launcher/resources/basic/xml_examples/ccr.xml deleted file mode 100644 index 46483a2..0000000 --- a/example/diameter/launcher/resources/basic/xml_examples/ccr.xml +++ /dev/null @@ -1,44 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/example/diameter/launcher/resources/ft-client/README b/example/diameter/launcher/resources/ft-client/README deleted file mode 100644 index 84e5128..0000000 --- a/example/diameter/launcher/resources/ft-client/README +++ /dev/null @@ -1,27 +0,0 @@ -ABOUT CONTENT -------------- -Template for xml messages (message.dtd) and dictionaries (dictionary.dtd) are informative, not -actually required by process. They are located at './DTDs'. Stacks are available at './stacks'. -There are also some stuff (hex/xml examples, etc.) which could be useful. - -The directory 'tests' contains resources to create FT test cases. The script 'common.sh' implement -a basic scheduler to launch a request to the server, waits for incoming activity, retrieve the -answer received and match such message with certain criteria. Execute 'case_1.sh' as example. - -An advanced FT test framework involves the use of the ANNA::diameter API in an ad-hoc diameter -client executable (for example we could define an incoming handler in different libraries which -represent different test cases, linking them to a common simple diameter client agent). But with -this simple scripts we could do something valid to start with. - -STARTING THE PROCESS --------------------- -Launch the executable process without arguments to see a complete command-line help. -Don't be scared. There are plenty of possibilities but the 'run.sh' script has been prepared -for the type of launcher you wanted. - -OPERATION ---------- -Management interface for this version is based on SIGUSR2 signal caugh. Use './operation.sh' -script to send any operation to the process. Ask for help with that script to see all the -operations supported. - diff --git a/example/diameter/launcher/resources/ft-client/args.txt b/example/diameter/launcher/resources/ft-client/args.txt deleted file mode 100755 index 2ee9a85..0000000 --- a/example/diameter/launcher/resources/ft-client/args.txt +++ /dev/null @@ -1,4 +0,0 @@ --dictionary `grep -v ^# .dictionary` --entity `grep -v ^# .entity` --entityServerSessions `grep -v ^# .entityServerSessions` --splitLog diff --git a/example/diameter/launcher/resources/ft-client/hex_examples b/example/diameter/launcher/resources/ft-client/hex_examples deleted file mode 120000 index 9eee58b..0000000 --- a/example/diameter/launcher/resources/ft-client/hex_examples +++ /dev/null @@ -1 +0,0 @@ -../basic/hex_examples \ No newline at end of file diff --git a/example/diameter/launcher/resources/ft-client/operation.sh b/example/diameter/launcher/resources/ft-client/operation.sh deleted file mode 120000 index a61ab5e..0000000 --- a/example/diameter/launcher/resources/ft-client/operation.sh +++ /dev/null @@ -1 +0,0 @@ -../basic/operation.sh \ No newline at end of file diff --git a/example/diameter/launcher/resources/ft-client/pre-start.sh b/example/diameter/launcher/resources/ft-client/pre-start.sh deleted file mode 100755 index b1863af..0000000 --- a/example/diameter/launcher/resources/ft-client/pre-start.sh +++ /dev/null @@ -1,63 +0,0 @@ -#!/bin/bash - -# Remove logs: -rm *.log* *.csv 2>/dev/null - -# Client sockets: -entity_dflt=`cat .entity 2>/dev/null` -entityServerSessions_dflt=`cat .entityServerSessions 2>/dev/null` - -# Stack: -dictionary_dflt=`cat .dictionary 2>/dev/null` - -echo -echo -# If all have values: -if [ "$entity_dflt" != "" -a "$entityServerSessions_dflt" != "" -a "$dictionary_dflt" != "" ] -then - echo "Do you wish to answer wizard commandline configuration ? (y/n) [n]:" - read wizard - [ "$wizard" = "" ] && wizard=n - [ "$wizard" = "n" ] && exit -fi - -# DEFAULTS -#[ "$entity_dflt" = "" ] && entity_dflt="192.168.12.11:3868,192.168.12.21:3868" -[ "$entity_dflt" = "" ] && entity_dflt="localhost:3868" -[ "$entityServerSessions_dflt" = "" ] && entityServerSessions_dflt=10 -[ "$dictionary_dflt" = "" ] && dictionary_dflt=dictionary.xml - - -# Wizard -echo "Diameter dictionary: you could use '/opt/bin/anna/example_diameter_stackManagement' tool in order to build" -echo " autonomous dictionaries for any kind of application. The key is to concatenate xml contents (ietf, 3gpp," -echo " vendor-specific, etc.). See 'example/diameter/stackManagement/self_ruling_setups.sh' for this." -echo -echo "This launcher can also join them providing a comma-separated list (dictionaries available on ./stack)." -echo "By default, a QoS Application setup is suggested. Input the desired configuration instead, or press ENTER:" -echo -echo " [$dictionary_dflt]:" -read dictionary -[ "$dictionary" = "" ] && dictionary=$dictionary_dflt - -# As client: -echo "Diameter entity server sessions (0: diameter entity disabled) [$entityServerSessions_dflt]:" -read entityServerSessions -[ "$entityServerSessions" = "" ] && entityServerSessions=$entityServerSessions_dflt - -entity= -if test "$entityServerSessions" != "0" -then - echo "Target diameter entity (pipe-separated : socket literal list) ["$entity_dflt"]:" - read entity -fi -[ "$entity" = "" ] && entity="$entity_dflt" - -# Configure: -echo $dictionary > .dictionary -echo $entity > .entity -echo $entityServerSessions > .entityServerSessions - -echo -echo - diff --git a/example/diameter/launcher/resources/ft-client/tests/experiment1/case_1.sh b/example/diameter/launcher/resources/ft-client/tests/experiment1/case_1.sh deleted file mode 100755 index 67dd513..0000000 --- a/example/diameter/launcher/resources/ft-client/tests/experiment1/case_1.sh +++ /dev/null @@ -1,47 +0,0 @@ -#!/bin/bash - -# In this test we will send a incorrect message (AAR) to the server peer: -# Warning | source/diameter/codec/Message.cpp (387) | Internal Avp decoding error (avp code = 443): Avp format error, the avp length is incorrect (must be multiple of 4 on grouped type) -# -# The server shall answer with the FailedAVP and we will check this to validate the test. - -############# -# VARIABLES # -############# -# Paths from the point of view of ADL executable: -REQ1_HEX=./hex_examples/aar-bad.hex - -############# -# FUNCTIONS # -############# - - -############# -# EXECUTION # -############# - -# Goto working directory -cd `dirname $0` - -# Source utils: -source common.sh - -# Clean traffic traces: -rm -f ../../launcher.log* - -# Send incorrect AAR: -send_hex $REQ1_HEX & - -# Monitor activity: -monitor_4_message ../../launcher.log.recvfe 10 - -# Check if message was received: -[ $? -ne 0 ] && test_failed "Missing answer from the server" - -# Check launcher.log.recvfe: -check_pattern "" ../../launcher.log.recvfe -check_pattern "( *)/dev/null - res=${PIPESTATUS[2]} - [ $? -ne 0 ] && _exit "Test failed: miss pattern !!" -} - -test_ok () { - echo - echo $1 - echo "Test OK !" - echo - exit 0 -} - -test_failed () { - echo - echo $1 - echo "Test FAILED !" - echo - exit 1 -} - - -# $1: traffic log to monitor -# $2: timeout (request expiration) in seconds -# Result: cats the message when completed -monitor_4_message () { - 0>$1 - rm -f .msg_received - - [ -z "$2" ] && _exit "ERROR: must provide '$FUNCNAME' timeout (second argument)" - sleep $2 & - local timerPid=$! - - # Monitor for incoming message: - tail -n0 -F --pid=$timerPid $1 | while read line - do - if echo $line | grep "^" >/dev/null; then - echo "Message received" - # stop the timer - kill -13 $timerPid - touch .msg_received - fi - done - - if [ ! -f .msg_received ]; then - echo "Timeout expired" - return 1 - fi - - return 0 -} - -############# -# EXECUTION # -############# - -# Trap sigint signal: -trap sigint_handler SIGINT - diff --git a/example/diameter/launcher/resources/ft-client/tests/experiment2/ProtocolErrors/BadAARtoServer/aar-bad.hex b/example/diameter/launcher/resources/ft-client/tests/experiment2/ProtocolErrors/BadAARtoServer/aar-bad.hex deleted file mode 120000 index 4c9a36f..0000000 --- a/example/diameter/launcher/resources/ft-client/tests/experiment2/ProtocolErrors/BadAARtoServer/aar-bad.hex +++ /dev/null @@ -1 +0,0 @@ -../../../../hex_examples/aar-bad.hex \ No newline at end of file diff --git a/example/diameter/launcher/resources/ft-client/tests/experiment2/ProtocolErrors/BadAARtoServer/aar2-bad.hex b/example/diameter/launcher/resources/ft-client/tests/experiment2/ProtocolErrors/BadAARtoServer/aar2-bad.hex deleted file mode 120000 index 5a6586d..0000000 --- a/example/diameter/launcher/resources/ft-client/tests/experiment2/ProtocolErrors/BadAARtoServer/aar2-bad.hex +++ /dev/null @@ -1 +0,0 @@ -../../../../hex_examples/aar2-bad.hex \ No newline at end of file diff --git a/example/diameter/launcher/resources/ft-client/tests/experiment2/ProtocolErrors/BadAARtoServer/aar3-bad.hex b/example/diameter/launcher/resources/ft-client/tests/experiment2/ProtocolErrors/BadAARtoServer/aar3-bad.hex deleted file mode 120000 index 6705cc4..0000000 --- a/example/diameter/launcher/resources/ft-client/tests/experiment2/ProtocolErrors/BadAARtoServer/aar3-bad.hex +++ /dev/null @@ -1 +0,0 @@ -../../../../hex_examples/aar3-bad.hex \ No newline at end of file diff --git a/example/diameter/launcher/resources/ft-client/tests/experiment2/ProtocolErrors/BadAARtoServer/case_1.tc b/example/diameter/launcher/resources/ft-client/tests/experiment2/ProtocolErrors/BadAARtoServer/case_1.tc deleted file mode 100644 index 693bc94..0000000 --- a/example/diameter/launcher/resources/ft-client/tests/experiment2/ProtocolErrors/BadAARtoServer/case_1.tc +++ /dev/null @@ -1,11 +0,0 @@ -# Bad length encoded on grouped Subscription-Id length field (not multiple of 4). - -# Send malformed AAR to the server: -SENDHEX2E aar-bad.hex - -# Wait for message: -WAIT4MESSAGE - -# Check Failed-AVP & Subscription-Id within: -CHECKPATTERN -CHECKPATTERN ( *) Media-Sub-Component -> Flow-Status) - -# Send malformed AAR to the server: -SENDHEX2E aar2-bad.hex - -# Wait for message: -WAIT4MESSAGE - -# Check Failed-AVP & Subscription-Id within: -CHECKPATTERN -CHECKPATTERN ( *) Media-Sub-Component -> Flow-Status) - -# Send malformed AAR to the server: -SENDHEX2E aar3-bad.hex - -# Wait for message: -WAIT4MESSAGE - -# Check Failed-AVP & Subscription-Id within: -CHECKPATTERN -CHECKPATTERN ( *)( *)( *) diff --git a/example/diameter/launcher/resources/ft-client/tests/experiment2/go.sh b/example/diameter/launcher/resources/ft-client/tests/experiment2/go.sh deleted file mode 100755 index 44bd53f..0000000 --- a/example/diameter/launcher/resources/ft-client/tests/experiment2/go.sh +++ /dev/null @@ -1,194 +0,0 @@ -#!/bin/bash - -############# -# VARIABLES # -############# -SCR_DIR=`dirname $0` -tmpdir=$(mktemp -d) -SCR_BN=`basename $0` -OPER_SCR=../../operation.sh -RESULT_LOG=result.log -RECV_LOG=../../launcher.log.recvfe - -############# -# FUNCTIONS # -############# - -sigint_handler () { - _exit "Script interrupted. Cleanup and exit ..." -} - -# $1: message; $2: optional rc (1 by default) -_exit () { - rc=1 - [ -n "$2" ] && rc=$2 - echo - echo -e $1 - echo - rm -rf $tmpdir - exit $rc -} - -# $1: hex formatted file to send to the server -operation_sendxml2e () { - sleep 0.5 - $OPER_SCR "sendxml2e|$1" - return $? -} - -# $1: hex formatted file to send to the server -operation_sendhex2e () { - sleep 0.5 - $OPER_SCR "sendhex2e|$1" - return $? -} - -# $1: file to monitor -# $2: timeout (request expiration) in seconds -# Result: cats the message when completed -wait4message () { - 0>$1 - rm -f .msg_received - - [ -z "$2" ] && _exit "ERROR: must provide '$FUNCNAME' timeout (second argument)" - sleep $2 & - local timerPid=$! - - # Monitor for incoming message: - tail -n0 -F --pid=$timerPid $1 | while read line - do - if echo $line | grep "^" >/dev/null; then - echo "Message received:" - echo - cat $1 - # stop the timer - kill -13 $timerPid - touch .msg_received - fi - done - - if [ ! -f .msg_received ]; then - echo "Timeout expired" - return 1 - fi - - return 0 -} - -# xml content is serialized (removing CR's) to ease the pattern matching: -# $1: pattern; $2: file -check_pattern () { - echo -n "Matching pattern '$1' in file '$2' ... " - cat $2 | tr '\n' ' ' | egrep "$1" >/dev/null - [ $? -ne 0 ] && { echo "ERROR" ; test_failed ; return 1 ; } - echo "OK" - return 0 -} - -# $1: pattern file; $2: file -check_pattern_file () { - echo -n "Matching whole file '$1' in file '$2' ... " - grep -f $1 $2 >/dev/null - [ $? -ne 0 ] && { echo "ERROR" ; test_failed ; return 1 ; } - echo "OK" - return 0 -} - -# Tests result: -test_ok () { - echo "Verdict: $TC Ok" | tee -a $RESULT_LOG -} - -test_failed () { - echo "Verdict: $TC Failed" | tee -a $RESULT_LOG -} - -process_tc () { - local tc_dn=`dirname $TC` - - echo - echo "***** Executing '$TC' ..." - - grep -v ^# $TC > $tmpdir/tc - while read -r line - do - oper=$(echo $line | awk '{ print $1 }') - param1="$(echo $line | cut -d' ' -f2-)" - - case $oper in - SENDXML2E) - operation_sendxml2e $tc_dn/$param1 & - [ $? -ne 0 ] && return 1 - ;; - - SENDHEX2E) - operation_sendhex2e $tc_dn/$param1 & - [ $? -ne 0 ] && return 1 - ;; - - WAIT4MESSAGE) - wait4message $RECV_LOG 5 - [ $? -ne 0 ] && return 1 - ;; - - CHECKPATTERN) - check_pattern "$param1" $RECV_LOG - [ $? -ne 0 ] && return 1 - ;; - - CHECKPATTERNFILE) - check_pattern_file "$param1" $RECV_LOG - [ $? -ne 0 ] && return 1 - ;; - - esac - - done < $tmpdir/tc - - return 0 -} - - -############# -# EXECUTION # -############# - -# Trap sigint: -trap sigint_handler SIGINT - -# Working directory is script dirname: -cd $SCR_DIR - -# Intro: -echo -echo "------------------" -echo "Test cases manager" -echo "------------------" -# Mandatory parameter: -[ -z "$1" ] && _exit "Usage: $SCR_BN " -[ ! -f "$1" -a ! -d "$1" ] && _exit "Invalid file or directory '$1' !!" - -# Gather .tc files to be processed: -[ ! -f $1 ] && echo -e "\nGathering list of test cases from '`readlink -f $1`' ..." -echo -find $1 -name *.tc | xargs -L1 readlink -f | tee -a $tmpdir/tc_list -echo -echo - -echo "Start processing test cases:" -echo "----------------------------" -# Process test cases: -0> $RESULT_LOG -for TC in `cat $tmpdir/tc_list` -do - process_tc - if [ $? -eq 0 ]; then - test_ok - else - test_failed - cat $RECV_LOG - fi -done - -_exit "Done !" 0 - diff --git a/example/diameter/launcher/resources/ft-client/xml_examples b/example/diameter/launcher/resources/ft-client/xml_examples deleted file mode 120000 index 903e6fe..0000000 --- a/example/diameter/launcher/resources/ft-client/xml_examples +++ /dev/null @@ -1 +0,0 @@ -../basic/xml_examples \ No newline at end of file diff --git a/example/diameter/launcher/resources/pcap2diameterHex.sh b/example/diameter/launcher/resources/pcap2diameterHex.sh new file mode 100755 index 0000000..45dd820 --- /dev/null +++ b/example/diameter/launcher/resources/pcap2diameterHex.sh @@ -0,0 +1,135 @@ +#!/bin/bash + +############# +# VARIABLES # +############# +tmpdir=$(mktemp -d) + +############# +# FUNCTIONS # +############# + +usage () { + echo "Usage: $0 [results_dir]" + echo + echo " pcap_file: pcap formatted file to be processed." + echo " results_dir: directory where results are stored." + echo " By default, pcap file dirname is used." + echo + echo " The utility, dumps the extracted hexadecimal content" + echo " and useful information as timestamps, source and" + echo " destination:" + echo " /.hex" + echo " /.metadata" + echo + _exit +} + +_exit () { + echo + echo -e $1 + echo + + # Cleanup + #rm -rf $tmpdir + + rc=1 + [ -n "$2" ] && rc=$2 + exit $rc +} + +# $1: string; $2: substring +get_str_pos() { + local result=-1 + local str=$1 + local substr="${1%%$2*}" + local pos=${#substr} + local size=${#str} + [ $size -ne $pos ] && result=$pos + echo $result +} + +############# +# EXECUTION # +############# + +echo +echo "============================================" +echo "Diameter buffer extractor from PCAP raw file" +echo "============================================" +echo + +# Usage: +[ "$1" = "" ] && usage + +# Pcap file: +PCAP_FILE=$1 +[ ! -f $PCAP_FILE ] && _exit "Cannot found provided pcap file '$1' !!" + +# Optional result dir: +RESULTS_DIR=`dirname $PCAP_FILE` +[ "$2" != "" ] && RESULTS_DIR=$2 +[ ! -d $RESULTS_DIR ] && _exit "The results directory '$RESULTS_DIR' must exists !!" + +# Get the frames with diameter content (take care about '-2' two-pass option and don't add it, because we need to get reassembled parts in their corresponding frames): +# Fields needed (we won't need diameter.hopbyhopid & diameter.endtoendid to verify diameter message as hint patterns; length management will be enough): +FIELDS="-e frame.number -e frame.time_epoch -e ip.src_host -e ip.dst_host -e tcp.len -e diameter.length -e frame.protocols -e tcp.segment" +tshark -E separator="|" -r $PCAP_FILE -N mntC -Tfields $FIELDS 2>/dev/null | grep -i diameter > $tmpdir/diameter_frames +# Example output: +# /length\ +# frame timestamp src dst TCP DIAM protocol segments +# 1|1427215933.697904000|gt_traf|vcbavipt|432|432|eth:ip:tcp:diameter:diameter:diameter3gpp| +# 3|1427215934.449523000|vcbavipt|gt_traf|292|292|eth:ip:tcp:diameter:diameter:diameter3gpp| +# 5|1427215934.456160000|gt_traf|vcbavipt|1400||eth:ip:tcp:diameter| +# 6|1427215934.456204000|gt_traf|vcbavipt|572|1972|eth:ip:tcp:diameter:diameter:diameter3gpp|5,6 +# 8|1427215935.123559000|vcbavipt|gt_traf|248|248|eth:ip:tcp:diameter:diameter:diameter3gpp| +all_frames=( $(cat $tmpdir/diameter_frames | cut -d\| -f1) ) +needs_join=( $(cat $tmpdir/diameter_frames | cut -d\| -f8) ) +main_frames=( $(cat $tmpdir/diameter_frames | awk -F\| '{ if ($6 != "") print $1 }') ) + +# Reassemble procedure (using frame 1 as example): +# (for non segmented frames, it is enough with tcp or diameter length within the frame content itself) +# 1) Get the TCP length: 432 bytes. 432*2 = 864 characters per byte in hexadecimal string format +# 2) Get the frame length: `wc -c $tmpdir/block.$frame` => 997 +# 3) Get 864 from the tail: `cat $tmpdir/block.$frame | cut -c133 + +# Dump the hex blocks for all the diameter frames: +cat $PCAP_FILE | rawshark -s -r - -d proto:diameter -F data 2>/dev/null > $tmpdir/all_hex_data +for frame in ${all_frames[@]}; do + grep "^$frame " $tmpdir/all_hex_data | cut -d\" -f2 | sed 's/://g' > $tmpdir/block.$frame + frame_info=$(grep "^${frame}|" $tmpdir/diameter_frames) + + # Get the diameter part: + tcp_len=$(echo $frame_info | cut -d\| -f5) + frm_len=$(wc -c $tmpdir/block.$frame | awk '{ print $1 }') + cut_len=$((frm_len-2*tcp_len)) + cat $tmpdir/block.$frame | cut -c${cut_len}- > $RESULTS_DIR/$frame.hex + echo -n "Created $RESULTS_DIR/$frame.hex" + + # Metadata: + ts=$(echo $frame_info | cut -d\| -f2) + date=$(date -d @$ts) + src=$(echo $frame_info | cut -d\| -f3) + dst=$(echo $frame_info | cut -d\| -f4) + echo -e "timestamp=$ts\ndate=$date\nsrc=$src\ndst=$dst" > $RESULTS_DIR/$frame.metadata + echo " and $RESULTS_DIR/$frame.metadata" +done + +# Join frames which need to be reassembled: +for group in ${needs_join[@]}; do + echo "Grouping frames $group ..." + group_array=( $(echo $group | sed 's/,/ /g') ) + for frame in ${group_array[@]}; do + cat $RESULTS_DIR/$frame.hex >> $tmpdir/diam.$group + done + cat $tmpdir/diam.$group | tr -d '\n' > $RESULTS_DIR/$frame.hex +done + +# Delete superfluous metadata: +echo "Deleting superfluous metadata ..." +segments=( $(cat $tmpdir/diameter_frames | awk -F\| '{ if ($6 == "") print $1 }') ) +for s in ${segments[@]}; do rm $RESULTS_DIR/$s.metadata; done + + +_exit "Done!" 0 +