Launcher resources refactoring. New type included: FT testing client.
[anna.git] / example / diameter / launcher / resources / advanced / data.sh
diff --git a/example/diameter/launcher/resources/advanced/data.sh b/example/diameter/launcher/resources/advanced/data.sh
new file mode 100755 (executable)
index 0000000..09949ad
--- /dev/null
@@ -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 <sequence number: 1..N>"
+check_template data-initial.msk
+check_template data-update1.msk
+check_template data-update2.msk
+check_template data-termination.msk
+
+# Session-Id: '<DiameterIdentity>;<high 32 bits>;<low 32 bits>[;<optional value>="">]'
+#   <avp name="Session-Id" data="module-2.PTS2-BOG.sandvine.com;1287115741;0;49"/>
+# 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
+