////////////////////////////////////////////////////////////////////////////////
// Client: call through a proxy with a codec change by re-INVITE
//
// No counterpart in this directory: it is written for a real PBX or session
// border controller that authenticates (401 for the REGISTER, 407 for the
// INVITE) and records the route.
//
// After the call is up it saves the To-tag, the Record-Route and the remote
// Contact, and uses them for the ACK, the re-INVITE and the BYE. It plays
// 711aLaw.pcap (PCMA), changes to G.729 with the re-INVITE, and plays
// G729.pcap.
//
// 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
//  ---> REGISTER ... <--- 401 ... ---> REGISTER (Authorization) <--- 200
//  ---> INVITE (PCMA) <--- 407 ---> ACK ---> INVITE (Proxy-Authorization)
//  <--- 180 Ringing, 183 Session Progress (optional), 200 OK
//  ---> ACK (Route)
//  ---- play 711aLaw.pcap, pause 15 s
//  ---> INVITE ;retrans (re-INVITE, G.729, Route)
//  <--- 200 OK ;retrans
//  ---> ACK (Route)
//  ---- play G729.pcap, pause 15 s
//  ---> BYE ;retrans (Route)
//  <--- 200 OK
////////////////////////////////////////////////////////////////////////////////

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


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

<----------*
401 Unauthorized

---------->*;retrans
REGISTER sip:[remote_ip]:[remote_port] SIP/2.0
Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
From: <sip:[fromUsername]@[remote_ip]:[remote_port]>;tag=24de4a5dbe4ef
To: <sip:[fromUsername]@[remote_ip]:[remote_port]>
Call-ID: [call_number].[run_tag]@[local_ip]
CSeq: [cseq+1] REGISTER
Max-Forwards: 70
Expires: 3600
Contact: <sip:[fromUsername]@[local_ip]:[local_port];transport=[transport]>
User-Agent: SIPInspector_v_[ver]
Authorization: [authentication username=[authUsername]; password=[authPassword];]
Content-Length: 0


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

---------->;retrans
INVITE sip:[toUsername]@[remote_ip]:[remote_port] SIP/2.0
Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=z9hG4bK[run_tag].[call_number]inv1
From: <sip:[fromUsername]@[local_ip]:[local_port]>;tag=24417923471779367133
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 8 101
a=rtpmap:8 PCMA/8000/1
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-15
a=ptime:20

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

<----------;retrans
407 Proxy Authentication Required

---------->
ACK sip:[toUsername]@[remote_ip]:[remote_port] SIP/2.0
Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=z9hG4bK[run_tag].[call_number]inv1
From: <sip:[fromUsername]@[local_ip]:[local_port]>;tag=24417923471779367133
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


---------->;retrans
INVITE sip:[toUsername]@[remote_ip]:[remote_port];transport=[transport] SIP/2.0
Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
From: <sip:[fromUsername]@[local_ip]:[local_port]>;tag=24417923471779367133
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]
Proxy-Authorization: [authentication username=[authUsername]; password=[authPassword];]
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 8 101
a=rtpmap:8 PCMA/8000/1
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-15
a=ptime:20

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

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

<----------*
183 Session Progress

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

----------
set_Variable=toTag "To:" "tag=*"

----------
set_Variable=recRoute "Record-Route:" "*"

----------
set_Variable=remContact "Contact:" "<*>"

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


----------
cmd_PlayPcap=./pcap/711aLaw.pcap

----------
cmd_Pause=15000

---------->;retrans
INVITE [$remContact] SIP/2.0
Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]ef
From: <sip:[fromUsername]@[local_ip]:[local_port]>;tag=24417923471779367133
To: <sip:[toUsername]@[remote_ip]:[remote_port]>;tag=[$toTag]
Call-ID: [call_number].[run_tag]@[local_ip]
CSeq: [cseq+1] INVITE
Max-Forwards: 70
Route: [$recRoute]
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 843670096 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 18 101
a=rtpmap:18 G729/8000
a=fmtp:18 annexb=no
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-15
a=ptime:20

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

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

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


----------
cmd_PlayPcap=./pcap/G729.pcap

----------
cmd_Pause=15000

---------->;retrans
BYE [$remContact] SIP/2.0
Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]ij
From: <sip:[fromUsername]@[local_ip]:[local_port]>;tag=24417923471779367133
To: <sip:[toUsername]@[remote_ip]:[remote_port]>;tag=[$toTag]
Call-ID: [call_number].[run_tag]@[local_ip]
Route: [$recRoute]
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
