////////////////////////////////////////////////////////////////////////////////
// Client: raises the number of simultaneous calls step by step
//
// No counterpart in this directory: it shapes the load a call generator puts on
// a real system.
//
// At the start of every call [CCnt] (the number of concurrent calls) is looked
// at. If it is a multiple of 31 the call does not call at all: it waits 20
// seconds and raises the allowed number of concurrent calls by 30
// (cmd_Spec=setCC). Otherwise it holds its call for a time that gets shorter as
// the count grows: 132 s up to 31 calls (and it sets the limit to 31 first),
// 109 s above 31, 86 s above 62 and 63 s above 93.
//
// Messages with ;retrans are sent again over UDP until they are answered, and a copy
// of one that comes again is answered as before (RFC 3261; -t1, -t2).
//
// SIP Messages
//  ---> INVITE ;retrans
//  <--- 100 Trying (optional)
//  <--- 180 Ringing
//  <--- 200 OK ;retrans
//  ---> ACK
//  ---- pause (the time chosen above)
//  ---> BYE ;retrans
//  <--- 200 OK
////////////////////////////////////////////////////////////////////////////////

----------
condition=if ([CCnt]%31 == 0) goto 31st_call

----------
condition=if ([CCnt] > 93) goto 90_calls

----------
condition=if ([CCnt] > 62) goto 60_calls

----------
condition=if ([CCnt] > 31) goto 30_calls

----------
label=0_calls

----------
set_Variable=ccalls "-" "=31"

----------
cmd_Spec=setCC([$ccalls])

----------
set_Variable=duration "-" "=132000"

----------
goto=start

----------
label=30_calls

----------
set_Variable=duration "-" "=109000"

----------
goto=start

----------
label=60_calls

----------
set_Variable=duration "-" "=86000"

----------
goto=start

----------
label=90_calls

----------
set_Variable=duration "-" "=63000"

----------
goto=start

----------
label=31st_call

----------
cmd_Pause=20000

----------
set_Variable=tmp "-" "=[CCnt]+30"

----------
cmd_Spec=setCC([$tmp])

----------
goto=end

----------
label=start

---------->;retrans
INVITE sip:[toUsername]@[remote_ip]:[remote_port] SIP/2.0
Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
From: <sip:[fromUsername]@[local_ip]:[local_port]>;tag=[call_number]
To: <sip:[toUsername]@[remote_ip]:[remote_port]>
Call-ID: [call_number].[run_tag]@[local_ip]
CSeq: [cseq+1] INVITE
Max-Forwards: 70
Contact: <sip:[fromUsername]@[local_ip]:[local_port];transport=[transport]>
User-Agent: SIPInspector_v_[ver]
Content-Type: application/sdp
Content-Length: [len]

v=0
o=111 843670094 843670094 IN [IP_ver] [local_ip_sdp]
s=-
c=IN [IP_ver] [local_ip_sdp]
t=0 0
a=sendrecv
m=audio [media_port] RTP/AVP 0 101
a=rtpmap:0 PCMU/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-15
a=ptime:20

<----------*
100 Trying

<----------
180 Ringing

<----------;retrans
200 OK

---------->
ACK sip:[toUsername]@[remote_ip]:[remote_port] SIP/2.0
Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
From: <sip:[fromUsername]@[local_ip]:[local_port]>;tag=[call_number]
To: <sip:[toUsername]@[remote_ip]:[remote_port]>;[peer_tag_param]
Call-ID: [call_number].[run_tag]@[local_ip]
CSeq: [cseq] ACK
Max-Forwards: 70
Contact: <sip:[fromUsername]@[local_ip]:[local_port];transport=[transport]>
User-Agent: SIPInspector_v_[ver]
Content-Length: 0


----------
cmd_Pause=[$duration]

---------->;retrans
BYE sip:[toUsername]@[remote_ip]:[remote_port] SIP/2.0
Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
From: <sip:[fromUsername]@[local_ip]:[local_port]>;tag=[call_number]
To: <sip:[toUsername]@[remote_ip]:[remote_port]>;[peer_tag_param]
Call-ID: [call_number].[run_tag]@[local_ip]
CSeq: [cseq+1] BYE
Max-Forwards: 70
Contact: <sip:[fromUsername]@[local_ip]:[local_port];transport=[transport]>
User-Agent: SIPInspector_v_[ver]
Content-Length: 0


<----------
200 OK

----------
label=end
