First commit
[anna.git] / example / diameter / launcher / data.sh
1 #!/bin/ksh
2
3 # Generates DATA burst sequence for provided order number (1: first, 2: second, etc.)
4 # We will generate a simple scenario with initial, two updates and termination, that is to say: four messages:
5 #  1,2,3,4  5,6,7,8  9,10,11,12   etc.
6 #
7 # Category = ((Number-1) % 4) + 1 = 1 for initial, 2 for first update, 3 for second update and 4 for termination
8 SEQN=$1
9 OFFSET=$((SEQN-1))
10 CAT=$((OFFSET%4 + 1))
11
12 salir () {
13    echo
14    echo $1
15    echo
16    exit
17 }
18
19 check_template () {
20    [[ ! -f $1 ]] && salir "Template file ($1) not found!"
21 }
22
23 parse () {
24    cat $1 | sed 's/__HBH_ETE__/'$HBH_ETE'/g' | sed 's/__SID_SUFFIX__/'$SID_SUFFIX'/' \
25             | sed 's/__MSISDN__/'$MSISDN'/' | sed 's/__NTPTIMESTAMP__/'$NTP'/' \
26             | sed 's/__SID_DI__/'$SID_DI'/' | sed 's/__SID_HIGH__/'$SID_HIGH'/' | sed 's/__SID_LOW__/'$SI_LOW'/'
27 }
28
29
30 [[ "$SEQN" = "" ]] && salir "Use: $0 <sequence number: 1..N>"
31 check_template data-initial.msk
32 check_template data-update1.msk
33 check_template data-update2.msk
34 check_template data-termination.msk
35
36 # Session-Id: '<DiameterIdentity>;<high 32 bits>;<low 32 bits>[;<optional value>="">]'
37 #   <avp name="Session-Id" data="module-2.PTS2-BOG.sandvine.com;1287115741;0;49"/>
38 # We will sequence the otional value with __SID_SUFFIX__, low and high will be constant.
39
40 # Sequence values at templates:
41 # __HBH_ETE__:    1, 3, 5, etc. (hop-by-hop and end-to-end)
42 # __SID_SUFFIX__: It could be MSISDN, but we put OFFSET (0, 1, 2, 3, etc.). It's the Session-Id optional part.
43 # __MSISDN__:     50583211675, 50583211676, 50583211677, etc. Used for User-Name and Subscription-Id-Data 
44 # __NTPTIMESTAMP__: Four values for initial, update1, update2 and termination: 3548171033, 3548171136 (103+), 3548171136(idem), 3548171524(388+)
45 #                   This initial time (aproximately 8 Jun 2012 at 19:00).
46 CUARTO=$((OFFSET/4))
47 HBH_ETE=$((1 + 2*OFFSET))
48 SID_SUFFIX=$CUARTO
49 # Example if you want to fix to two sockets (-sessionIdPartForClientSocketIdSelection must be 'optional'): SID_SUFFIX=$((CUARTO%2))
50 MSISDN=$((50583211675+CUARTO))
51 NTP=$((3548171033+CUARTO))
52
53 # Helpers to guide derivery (fixed at the moment)
54 # __SID_DI__:     Session-Id diameter identity
55 # __SID_HIGH__:   Session-Id high part
56 # __SID_LOW__:    Session-Id low part
57 SID_DI=module-2.PTS2-BOG.sandvine.com
58 SID_HIGH=1287115741
59 SI_LOW=0
60
61 case $CAT in
62    1) parse data-initial.msk
63    ;;
64    2) NTP=$((NTP+103))
65       parse data-update1.msk
66    ;;
67    3) NTP=$((NTP+103))
68       parse data-update2.msk
69    ;;
70    4) NTP=$((NTP+491))
71       parse data-termination.msk
72    ;;
73 esac
74