PRACK (Outbound)

Introduction

These methods in from TestSipLuaAgent Lua API are used for tests which perform the SIP UAC role for an outbound PRACK transaction, sending an outbound SIP PRACK Request in the context of a previously established outbound SIP INVITE transaction/dialog for which a final INVITE Response has not yet been received.

It is important to be aware that the context supplied to the prack_send_request and prack_expect_response methods must be an outbound INVITE context. I.e. a context created by invite_context and used in a call to invite_send_request.

i.e. The PRACK message does not have its own (non-INVITE) context. It must exist within the context of the ongoing INVITE dialog.

PRACK (Outbound) API

.prack_send_request [Synchronous]

The prack_send_request method sends a TEST-SIP-SEND message to the TestSipApp to request that an outbound SIP PRACK Request is sent to the previously determined remote endpoint IP and port address.

Control will return immediately to the Lua script. There is no wait for any confirmation from the TestSipApp. If there is a problem sending then the TestSipAgent will subsequently send us a TEST-SIP-FAIL message which will be detected if and when any subsequent SIP messaging is performed by the test script.

The method will:

The prack_send_request method takes the following arguments:

Argument Type Description
context Object [Required] An existing outbound INVITE context, as created by invite_context and previously used in a call to invite_send_request.
extra_headers Array of Object An optional list of extra headers.
Each object in the array must have a name and a value.
A header name may appear more than once in this array to support repeated headers in the Request.
.name String The name of the extra header to add to the PRACK Request.
.value String The value of the extra header to add to the PRACK Request.

The prack_send_request method returns nil.

Example of sending SIP PRACK Request after provisional response:

local n2svcd = require "n2.n2svcd"
local utils = require "n2.utils"
local match = require "n2.n2svcd.tester.match"
local manage = require "n2.n2svcd.tester.manage"
local edr_file_agent = require "n2.n2svcd.edr_file_agent"
local tsuo = require "n2.n2svcd.tester.test_sip_agent"

local args = ...

-- Start timer for elapsed checking.
local tv = match.elapsed ()

-- Checkpoint stats for "Logic" and "LHO" apps.
local stats_Logic = match.stats ('Logic')
local stats_LHO = match.stats ('LHO')

-- Static for our call.
local endpoints = tsuo.default_endpoints ({ local_rtp_port = 3668 })
local calling_party = '665566'
local called_party = '400009'

-- Get a SIP outcall context from our helper library.
local context = tsuo.invite_context (endpoints, calling_party, called_party, { prack_supported = true })

-- Construct the SDP
local sdp_offer = tsuo.sdp_offer (context, tsuo.SDP_MEDIA_LINPHONE)

-- Construct and Send INVITE Request.
tsuo.invite_send_request (context, sdp_offer)

-- Expect Trying automatically.
tsuo.invite_expect_response (context, 100, "Trying", { ['User-Agent'] = "N-Squared LHO" })

-- We get 181 Response from at_400x before any hunting begins.
tsuo.invite_expect_response (context, 181, "Call Is Being Forwarded")
tv = match.elapsed ("Proceeding 181 Notification 1 (immediate)", tv, 0.0)

-- PRACK that promptly.
tsuo.prack_send_request (context)
tsuo.prack_expect_response (context, 200, "OK")

.prack_expect_response [Asynchronous]

The prack_expect_response method will request the TestSipLuaAgent to wait until an inbound SIP PRACK Response message is received, in the context of a previously established transaction which belongs to this Lua script instance.

The agent will wait up until the expect_secs configured value for a SIP message to arrive. An error will be raised if no message is received in this time. An error will be raised if the received message is not a SIP Reponse, or if the received SIP message is not a PRACK Response message.

The prack_expect_response method takes the following arguments:

Argument Type Description
context Object [Required] The INVITE context as used in a previous call to prack_send_request.
code Integer [Required] The expected integer code value, e.g. 200.
message String [Required] The expected string message value, e.g. "OK".
extra_headers Array of Object An optional list of extra headers to be tested in the PRACK Response.
Each object in the array must have a name and a value.
If a header is expected to appear more than once, then value may be an Array of String.
.name String The name of the extra header to test for in the PRACK Response.
.value UNDEF or String or Array of String The value of the header to test from the PRACK Response.
The value UNDEF means "test that this header is not present".
A String value means "test" that the first header instance has this value.
An Array of String value means "test that the header exists N times with these values".

This method returns the decoded SIP PRACK Response message, as returned by the “n2.http” utility module.

Example: See the above example for prack_send_request.