XFL and Python API
get_absolute_time
get_absolute_time ()
Returns time in milliseconds elapsed since 00:00:00 UTC 1 January 1970. Differs from “gettime” API and “gettime” function in XFL Formulas in the following points:
- Time is relative to 00:00:00 UTC 1 January 1970 (instead of the start of the script)
- More precise
- Can be significantly slower on some machines, and should be used judiciously
Callable from:
- XFL
- Python
Arguments
- None
Return Value
- None
encode
encode (data1 [, data2[, …]] [, mode])
Encodes data element–usually a whole message–into a bit string
Callable from:
- XFL
- Python
Arguments
Argument Name | M/O | Value Type | Description |
---|---|---|---|
data | M | PDU | Data to encode |
mode | O | Integer | OR of binary flags. If omitted, the value is 0 |
mode flags
Value | Description |
---|---|
256 | Return encoded data as charStr instead of bitStr |
Return Value
- Encoded packet
Return Type
- Bit string
Python Example:
# Encoding 4 layers together into a binary |
seedrandom
seedrandom ([seed])
Restarts the pseudo-random sequence generated by rand(). The sequence is also implicitly restarted when Packet Studio starts, and in the beginning of XFL execution.
Affects receive() in random mode (see ‘Settings.ReceiveSide.Random mode’ on ‘Vars’ page). This call doesn’t affect language-specific random generation.
Callable from:
- XFL
- Python
Arguments
Argument Name | Type | Value | Description |
---|---|---|---|
seed | O | Int | Seed value. Omit this argument to make a really random seed. Pass 1 to reproduce the sequence that occured before any call to seedrandom. |
Return Value
- None
getdir
getdir ()
Returns the script directory
Callable from:
- XFL
- Python
Arguments
- None
Return Value
- Absolute path to the location of the calling script
Return Type
- Text string
getexamplesdir
getexamplesdir ()
Returns the absolute path to ‘Examples’ folder
Callable from:
- XFL
- Python
Arguments
- None
Return Value
- Absolute path to ‘Examples’ folder
Return Type
- Text string
getworkspacedir
getworkspacedir ()
Returns the script directory
Callable from:
- XFL
- Python
Arguments
- None
Return Value
- Absolute path to ‘Workspace’ folder
Return Type
- Text string
getcommondir
getcommondir ()
Returns the script directory
Callable from:
- XFL
- Python
Arguments
- None
Return Value
- Absolute path to ‘Common’ folder
Return Type
- Text string
rtp_create_session
rtp_create_session (local-host, local-port [, remote-host] [, remote-port] [, flags])
Creates an RTP session
Callable from:
- XFL
- Python
Arguments
Argument Name | Type | Value | Description |
---|---|---|---|
local_host | M | String | Local IP Address |
local_port | M | Integer | Local Port numbe r |
remote_host | O | String | Remote IP Address |
remote_port | O | Integer | Remote Port number |
flags | O | integer | OR of binary flags. If omitted, the value is 0 |
flags values
Value | Description |
---|---|
1 | Allow receiving RTP packets with frames per packet ratio greater than the codec’s default |
Return Value
- New sesson id on success, -1 on failure.
Return Type
- Integer
Python Example:
rtpSessionId = sk.rtp_create_session(SourceIPAddress, SourceRTPPort, remoteIPPort, remoteRTPPort) |
rtp_set_session_remote_addr
rtp_set_session_remote_addr (session-id, remote-host, remote-port)
Sets remote address and port for an RTP session
Callable from:
- XFL
- Python
Arguments
Argument Name | Type | Value | Description |
---|---|---|---|
session-id | M | Integer | RTP session identifier, returned from a ‘rtp_create_session’ call |
remote-host | M | String | Remote IP Address |
remote-port | M | Integer | Remote Port number |
Return Value
- None
rtp_tx_init_srtp
rtp_tx_init_srtp (session-id, cipher-type, cipher-key-len, auth-type, auth-key-len, auth-tag-len, key)
Initialize SRTP in the outgoing direction
Callable from:
- XFL
- Python
Arguments
Argument Name | Type | Value | Description |
---|---|---|---|
session-id | M | Integer | RTP session identifier |
cypher-type | M | Integer | Cypher type |
cypher-key-len | M | Integer | Cypher key length |
auth-type | M | Integer | Authentification type |
auth-key-len | M | Integer | Authentification key length |
auth-tag-len | M | Integer | Authentification tag length |
key | M | Integer | Security key |
cypher_type values
Value | Description |
---|---|
0 | NULL_CIPHER |
1 | AES_128_ICM |
2 | SEAL |
3 | AES_128_CBC |
auth_type values
Value | Description |
---|---|
0 | NULL_AUTH |
1 | UST_TMMHv2 |
2 | UST_AES_128_XMAC |
3 | HMAC_SHA1 |
Return Value
- None
Python Example:
sk.srtp_tx_init_srtp(rtpSessionId, 1, 30, 3, 20, 10, secret) |
rtp_rx_init_srtp
rtp_rx_init_srtp (session-id, cipher-type, cipher-key-len, auth-type, auth-key-len, auth-tag-len, key)
Initialize SRTP in the incoming direction
Callable from:
- XFL
- Python
Arguments
Argument Name | Type | Value | Description |
---|---|---|---|
session-id | M | Integer | RTP session identifier |
cypher-type | M | Integer | Cypher type |
cypher-key_len | M | Integer | Cypher key length |
auth-type | M | Integer | Authentification type |
auth-key-len | M | Integer | Authentification key length |
auth-tag-len | M | Integer | Authentification tag length |
key | M | Integer | Security key |
cypher_type values
Value | Description |
---|---|
0 | NULL_CIPHER |
1 | AES_128_ICM |
2 | SEAL |
3 | AES_128_CBC |
auth_type values
Value | Description |
---|---|
0 | NULL_AUTH |
1 | UST_TMMHv2 |
2 | UST_AES_128_XMAC |
3 | HMAC_SHA1 |
Return Value
- None
Python Example:
sk.srtp_rx_init_srtp(rtpSessionId, 1, 30, 3, 20, 10, secret) |
rtp_terminate_session
rtp_terminate_session (session-id)
Terminates an RTP session
Callable from:
- XFL
- Python
Arguments
Argument Name | Type | Value | Description |
---|---|---|---|
session-id | M | Integer | RTP session id |
Return Value
- None
Python Example:
rtp_terminate_session rtpSessionId |
rtp_tx_set_dscp
rtp_tx_set_dscp (session-id, dscp)
Sets DSCP field in outgoing IP frames
Callable from:
- XFL
- Python
Arguments
Argument Name | Type | Value | Description |
---|---|---|---|
session-id | M | Integer | RTP session id |
dscp | M | Integer | DSCP field value for outgoing IP frames |
dscp values
Value | Description |
---|---|
0 | Best effort |
10 | AF11 |
12 | AF12 |
14 | AF13 |
18 | AF21 |
20 | AF22 |
22 | AF23 |
26 | AF31 |
28 | AF32 |
30 | AF33 |
34 | AF41 |
36 | AF42 |
38 | AF43 |
46 | Expedited forwarding |
Return Value
- None
rtp_tx_setup_iuup
rtp_tx_setup_iuup (session-id [, IuUP-mode-version ], RFCI [, CRC])
Configures IuUP parameters for a transmitting session
Callable from:
- XFL
- Python
Arguments
Argument Name | Type | Value | Description |
---|---|---|---|
session-id | M | Integer | RTP session id |
IuUP-mode-version | O | Integer | IuUP mode version to be used in IuUP signalling. Valid range is 0..15 (versions 1..16 respectively). Default value: 0. |
RFCI | M | Integer | RFCI (RAB sub-Flow Combination Indicator) to be used in outgoing IuUP signalling. Valid range is 0..63. |
CRC | O | Boolean | Whether to use Payload CRC in outgoing IuUP signalling. Default value: true. |
Return Value
- None
rtp_tx_tone
rtp_tx_tone (session-id, encoding, freq, power [, pt ] [, frames-per-packet])
Commences transmission of a tone consisting of one harmonic as an RTP stream
Callable from:
- XFL
- Python
Arguments
Argument Name | Type | Value | Description |
---|---|---|---|
session-id | M | Integer | RTP session id |
encoding | M | Integer | RTP payload encoding |
freq | M | Integer | Frequenct, Hz |
power | M | Integer | Power, dB |
pt | O | Integer | Payload type, in range 0..127. Value used for PT field in RTP packet header. Specify this argument only for dynamic payloads (AMR and AMR-WB). See RFC 3550, 3551 for details. If omitted, static payload type for the encoding is used (or 96 if no static mapping is present). |
frames-per-packet | O | Integer | Frames per packet, in range 1..100. Defines how many speech frames of the codec (specified by ‘encoding’ argument) is placed in a single RTP packet. Default value depends on the codec, see ‘encoding’ description. |
Return Value
- None
Python Example
sk.rtp_tx_tone(rtpSessionId, 1, 440) |
rtp_tx_dtmf
rtp_tx_dtmf (session-id, encoding, digits [, power] [, pt] [, frames-per-packet] [, digit-duration] [, repeats] [, blocking])
Sends DTMF digits over a given RTP session
Callable from:
- XFL
- Python
Arguments
Argument Name | Type | Value | Description |
---|---|---|---|
session-id | M | Integer | RTP session id |
encoding | M | Integer | RTP payload encoding |
digits | M | String | String of DTMF digits. Valid characters are 0..9, * and #. |
power | M | Integer | Power, dB |
pt | O | Integer | Payload type, in range 0..127. Value used for PT field in RTP packet header. Specify this argument only for dynamic payloads (AMR and AMR-WB). See RFC 3550, 3551 for details. If omitted, static payload type for the encoding is used (or 96 if no static mapping is present). |
frames-per-packet | O | Integer | Frames per packet, in range 1..100. Defines how many speech frames of the codec (specified by ‘encoding’ argument) is placed in a single RTP packet. Default value depends on the codec, see ‘encoding’ description. |
digit_duration | O | Integer | Duration of each DTMF digit except last, in milliseconds, if more than one digit specified. 550 milliseconds if omitted. |
repeats | O | Integer | Number of repeats. Repeat once if omitted. |
blocking | O | Boolean | True - wait until all DTMF digits except last are transmitted for ‘digit_duration’ each, then call returns, and the last digit starts and lasts indefinitely until explicitly stopped by another API call. False - call returns immediately and after that all DTMF digits are transmitted for ‘digit_duration’ each. True if omitted. |
Return Value
- None
rtp_tx_silence
rtp_tx_silence (session-id, encoding [, pt ] [, frames-per-packet])
Sends silence over a given session
Callable from:
- XFL
- Python
Arguments
Argument Name | Type | Value | Description |
---|---|---|---|
session-id | M | Integer | RTP session id |
encoding | M | Integer | RTP payload encoding |
pt | O | Integer | Payload type, in range 0..127. Value used for PT field in RTP packet header. Specify this argument only for dynamic payloads (AMR and AMR-WB). See RFC 3550, 3551 for details. If omitted, static payload type for the encoding is used (or 96 if no static mapping is present). |
frames-per-packet | O | Integer | Frames per packet, in range 1..100. Defines how many speech frames of the codec (specified by ‘encoding’ argument) is placed in a single RTP packet. Default value depends on the codec, see ‘encoding’ description. |
Return Value
- None
rtp_tx_wav
rtp_tx_wav (session-id, encoding, file-path [, repeats] [, pt] [, frames-per-packet])
Commences transmission of a waveform from a .wav file as an RTP stream
Callable from:
- XFL
- Python
Arguments
Argument Name | Type | Value | Description |
---|---|---|---|
session-id | M | Integer | RTP session id |
encoding | M | Integer | RTP payload encoding |
file-path | M | String | Absolute path to the .wav file to be transmitted |
repeats | O | Integer | Number of repeats. Play forever if omitted |
pt | O | Integer | Payload type, in range 0..127. Value used for PT field in RTP packet header. Specify this argument only for dynamic payloads (AMR and AMR-WB). See RFC 3550, 3551 for details. If omitted, static payload type for the encoding is used (or 96 if no static mapping is present). |
frames-per-packet | O | Integer | Frames per packet, in range 1..100. Defines how many speech frames of the codec (specified by ‘encoding’ argument) is placed in a single RTP packet. Default value depends on the codec, see ‘encoding’ description. |
Return Value
- None
Python Example
sk.rtp_tx_wav(rtpSessionId, 1, "Examples\\Voice\\digits.wav", 1) |
rtp_tx_encoded
rtp_tx_encoded (session-id, encoding, file-path [, repeats] [, pt] [, frames-per-packet])
Commences transmission of a preencoded file as an RTP stream
Callable from:
- XFL
- Python
Arguments
Argument Name | Type | Value | Description |
---|---|---|---|
session-id | M | Integer | RTP session id |
encoding | M | Integer | RTP payload encoding |
file_path | M | String | Absolute path to the .wav file to be transmitted |
repeats | O | Integer | Number of repeats. Play forever if omitted |
pt | O | Integer | Payload type, in range 0..127. Value used for PT field in RTP packet header. Specify this argument only for dynamic payloads (AMR and AMR-WB). See RFC 3550, 3551 for details. If omitted, static payload type for the encoding is used (or 96 if no static mapping is present). |
frames-per-packet | O | Integer | Frames per packet, in range 1..100. Defines how many speech frames of the codec (specified by ‘encoding’ argument) is placed in a single RTP packet. Default value depends on the codec, see ‘encoding’ description. |
Return Value
- None
Python Example
originalWavPath = sk.getrootdir() + "\\Examples\\Voice\\female.wav" |
rtp_tx_audio
rtp_tx_audio (session-id, encoding [, pt] [, frames-per-packet])
Commences transmission of the PC’s audio input (e.g., microphone)
Callable from:
- XFL
- Python
Arguments
Argument Name | Type | Value | Description |
---|---|---|---|
session-id | M | Integer | RTP session id |
encoding | M | Integer | RTP payload encoding |
pt | O | Integer | Payload type, in range 0..127. Value used for PT field in RTP packet header. Specify this argument only for dynamic payloads (AMR and AMR-WB). See RFC 3550, 3551 for details. If omitted, static payload type for the encoding is used (or 96 if no static mapping is present). |
frames-per-packet | O | Integer | Frames per packet, in range 1..100. Defines how many speech frames of the codec (specified by ‘encoding’ argument) is placed in a single RTP packet. Default value depends on the codec, see ‘encoding’ description. |
Return Value
- None
rtp_tx_get_status
rtp_tx_get_status (session-id)
Retrieves RTP generation process status
Callable from:
- XFL
- Python
Arguments
Argument Name | Type | Value | Description |
---|---|---|---|
session-id | M | Integer | RTP session id |
Return Value
Value | Meaning |
---|---|
-2 | no process started |
-1 | in progress |
0 | error occured |
1 | successfully finished |
Return Type
- Integer
rtp_rx_setup_payload
rtp_rx_setup_payload (session-id, pt, mime [, mode])
Configures encoding to be used to handle incoming RTP packets with the specified dynamic payload type. See RFC 3550, 3551 on payload types.
Callable from:
- XFL
- Python
Arguments
Argument Name | Type | Value | Description |
---|---|---|---|
session-id | M | Integer | RTP session id |
pt | M | Integer | Payload type. Range 0..127. Value used for PT field in RTP packet header. See RFC 3550, 3551 for details. |
mime | M | String | MIME name of the encoding |
mode | O | Integer | Valid only for AMR and AMR-WB |
mime values
Value | Meaning |
---|---|
“AMR” | AMR Codec |
“AMR-WB” | AMR-WB Codec |
mode values
Value | Meaning |
---|---|
0 | bandwidth-efficient mode |
1 | octet-aligned mode |
2 | IuUP mode |
Return Value
- None
rtp_rx_wav
rtp_rx_wav (session-id, file-path [, sampling-frequency])
Commences reception of the waveform from an RTP stream and recording it to a .wav file
Callable from:
- XFL
- Python
Arguments
Argument Name | Type | Value | Description |
---|---|---|---|
session-id | M | Integer | RTP session id |
file-path | M | String | Path to a file to save to |
sampling-frequency | O | Integer | .wav sampling frequency, in kHz. Default value: 8000. |
Return Value
- None
Python Example
originalWavPath = sk.getrootdir() + "\\Examples\\Voice\\female.wav" |
rtp_rx_audio
rtp_rx_audio (session-id)
Commences reception of the waveform and redirecting it to PC’s audio output
Callable from:
- XFL
- Python
Arguments
Argument Name | Type | Value | Description |
---|---|---|---|
session-id | M | Integer | RTP session id |
Return Value
- None
rtp_rx_detect_dtmf
rtp_rx_detect_dtmf (session-id)
Starts DTMF detection on a given RTP session
Callable from:
- XFL
- Python
Arguments
Argument Name | Type | Value | Description |
---|---|---|---|
session-id | M | Integer | RTP session id |
Return Value
- None
rtp_rx_dtmf
rtp_rx_dtmf (session-id)
Receives DTMF digits from given RTP session
Callable from:
- XFL
- Python
Arguments
Argument Name | Type | Value | Description |
---|---|---|---|
session-id | M | Integer | RTP session id |
Return Value
- DTMF digits. Valid characters are ‘0’..’9’, ‘*’ and ‘#’
Return Type
- Text String
rtp_rx_detect_tone
rtp_rx_detect_tone (session-id, freq [, power])
Starts tone detection on a given RTP session
Callable from:
- XFL
- Python
Arguments
Argument Name | Type | Value | Description |
---|---|---|---|
session-id | M | Integer | RTP session id |
freq | M | Integer | Frequency, Hz |
power | O | Integer | Power threshold, dB. (Not yet supported). |
Return Value
- None
rtp_rx_tone
rtp_rx_tone (session-id, freq)
Checks whether a tone was detected on an RTP session
Callable from:
- XFL
- Python
Arguments
Argument Name | Type | Value | Description |
---|---|---|---|
session-id | M | Integer | RTP session id |
freq | M | Integer | Frequency, Hz |
Return Value
- True if the tone was detected, False otherwise.
Return Type
- Boolean
rtp_rx_off
rtp_rx_off (session-id)
Ceases reception on a given rtp session
Callable from:
- XFL
- Python
Arguments
Argument Name | Type | Value | Description |
---|---|---|---|
session-id | M | Integer | RTP session id |
Return Value
- None
Python Example
originalWavPath = sk.getrootdir() + "\\Examples\\Voice\\female.wav" |
rtp_rx_get_jitter
rtp_rx_get_jitter (session-id)
Retrieves the current jitter
Callable from:
- XFL
- Python
Arguments
Argument Name | Type | Value | Description |
---|---|---|---|
session-id | M | Integer | RTP session id |
Return Value
- Jitter in microseconds
Return Type
- Integer
rtp_rx_get_loss
rtp_rx_get_loss (session-id)
Retrieves the current jitter
Callable from:
- XFL
- Python
Arguments
Argument Name | Type | Value | Description |
---|---|---|---|
session-id | M | Integer | RTP session id |
Return Value
- Packet loss in %.
Return Type
- Integer
rtp_rx_get_comulative_loss
rtp_rx_get_comulative_loss (session-id)
Retrieves the cumulative packet loss ratio
Callable from:
- XFL
- Python
Arguments
Argument Name | Type | Value | Description |
---|---|---|---|
session-id | M | Integer | RTP session id |
Return Value
- Packet loss in %
Return Value
- Integer
rtp_tx_data
rtp_tx_data (session-id, pt, data)
Transmits data block within RTP session, e.g. for DTMF or tone events
Callable from:
- XFL
- Python
Arguments
Argument Name | Type | Value | Description |
---|---|---|---|
session-id | M | Integer | RTP session id |
pt | M | Integer | Payload type, in range 0..127. Set a PT field in RTP packet header (RFC 3550-3551). |
data | M | Octet String | Data to send |
Return Value
- None
rtp_tx_off
rtp_tx_off (session-id)
Ceases transmission on a given RTP session
Callable from:
- XFL
- Python
Arguments
Argument Name | Type | Value | Description |
---|---|---|---|
session-id | M | Integer | RTP session id |
Return Value
- None
Python Example
originalWavPath = sk.getrootdir() + "\\Examples\\Voice\\female.wav" |
rtp_set_mirroring_mode
rtp_set_mirroring_mode (session-id, mirroring-mode)
Controls RTP session mirroring mode
Callable from:
- XFL
- Python
Arguments
Argument Name | Type | Value | Description |
---|---|---|---|
session-id | M | Integer | RTP session id |
mirriring-mode | M | Boolean | True - set mirroring mode, False - clear mirroring mode. |
Return Value
- None
rtp_preencode
rtp_preencode (src-file-path, dst-file-path, encoding [, frames-per-packet])
Encodes .wav with the specified audio codec and saves the result to the other file.
Callable from:
- XFL
- Python
Arguments
Argument Name | Type | Value | Description |
---|---|---|---|
_src-file-path | M | String | Path to the file to be encoded |
dst-file-path | M | String | Path to the file to be saved |
encoding | M | Integer | RTP payload encoding |
frames-per-packet | O | Integer | Frames per packet, in range 1..100. Defines how many speech frames of the codec are placed in a single RTP packet. Default value depends on the codec selected. |
Return Value
- None
Python Example
originalWavPath = sk.getrootdir() + "\\Examples\\Voice\\female.wav" |
mos_calc
mos_calc (rxWav, txWav)
Calculates MOS
Callable from:
- XFL
- Python
Arguments
Argument Name | Type | Value | Description |
---|---|---|---|
rxWav | M | String | Path to received the.wav file |
txWav | M | String | Path to the transmitted.wav file |
Return Value
1 - sucess, 0 - failure.
Return Type
- Integer
Python Example
txWav = "examples\\Audio\\Voice\\male.wav" # original |
mos_get_val_int
mos_get_val_int ()
Retrieves the calculated MOS value
Callable from:
- XFL
- Python
Arguments
- None
Return Value
- Calculted MOS multiplied by 100. Range from 0 to 450
Return Type
- Integer
Python Example
txWav = "examples\\Audio\\Voice\\male.wav" # original |
mos_get_delay_ms
mos_get_delay_ms ()
Retrieves the calculated MOS value
Callable from:
- XFL
- Python
Arguments
- None
Return Value
- Delay calculated by MOS calculation process, in milliseconds.
Return Type
- Integer
Python Example
txWav = "examples\\Audio\\Voice\\male.wav" # original |
definevariable
definevariable (id, type [, defVal] [, flags] [, description])
Define a variable
Callable from:
- XFL
- Python
Arguments
Argument Name | Type | Value | Description |
---|---|---|---|
id | M | String | Identifier |
type | M | PDU/field type | Type. Must be one of types in “common” PCO |
defVal | O | String | Digital (Initial) value. String formatted appropriately for |
flags | O | Integer | Bit combination (OR) of flags |
description | O | String | Arbitrary description |
flags values
Value | Description |
---|---|
2 | global (define a global variable) |
16 | overwrite on id clash (if identifier already used, overwrite it with the new Definition) |
32 | fail on id clash (if identifier already used, skip this new definition and return false) |
If omitted the value is 2.
Return Value
- True if variable was successfully defined, False otherwise.
Return Type
Boolen
MD4
MD4 (data)
Calculates MD4 of an octet string
Callable from:
- XFL
- Python
Arguments
Argument Name | Type | Value | Description |
---|---|---|---|
data | M | Octet String | Data to calculate MD4 on |
Return Value
- MD4 value
Return Type
- 16-octet Octet String.
Python Example
data = "Data" |
MD5
MD5 (data)
Calculates MD5 of an octet string
Callable from:
- XFL
- Python
Arguments
Argument Name | Type | Value | Description |
---|---|---|---|
data | M | Octet String | Data to calculate MD5 on |
Return Value
- MD5 value
Return Type
- 16-octet Octet String
Python Example
data = "Data" |
DES_Encrypt
DES_Encrypt (key, data)
Encrypts data using DES
Callable from:
- XFL
- Python
Arguments
Argument Name | Type | Data Type | Description |
---|---|---|---|
key | M | Octet String | 7 Octets |
data | M | Octet String | 8 Octets |
Return Value
- 8-Octet String
Return Type
- Octet String
Python Example
raw_data = "94 74 B8 E8 C7 3B CA 7D" |
DES_Decrypt
DES_Decrypt (key, data)
Decrypt data using DES
Callable from:
- XFL
- Python
Arguments
Argument Name | Type | Data Type | Description |
---|---|---|---|
key | M | Octet String | 7 Octets |
data | M | Octet String | 8 Octets |
Return Value
- 8-Octet String
Return Type
- Octet String
Python Example
key = "A1 B2 C3 D4 E5 F6 57" |
MD5DigestResponse
MD5DigestResponse (alg, nonce, nc, cnonce, user, password, realm, qop, method, uri)
Calculates MD5 Digest Response when SIP called party requires authentication
Callable from:
- XFL
- Python
Arguments
Argument Name | Type | Data Type | Description |
---|---|---|---|
alg | M | String | Algorithm. Possible values are “MD5” and “MD5-sess” |
nonce | M | String | A value of Nonce parameter from a server response |
nc | M | String | A value of nc (NonceCount) parameter from a server response |
cnonce | M | String | A value of CNonce parameter from a server response |
user | M | String | User Name |
password | M | String | Password |
realm | M | String | A value of Realm parameter from a server response |
qip | M | String | A string of tokens indicating “quality of protection” values supported by the a server |
method | M | String | SIP method from the original request |
uri | M | String | A URI from the original response |
Return Value
- MD5 Digest Response
Return Type
- Text String
Python Example
nonce="46f9646f0794e0796d3874ff1a38c497f5200785" |
ModPow
ModPow (base, exp, mod)
Computes (base ^ exp) % mod
Callable from:
- XFL
- Python
Arguments
Argument Name | Type | Data Type | Description |
---|---|---|---|
base | M | Octet String | Base. Octet string representing a big integer, first octet is the most significant. |
exp | M | Octet String | Exponent. Octet string representing a big integer, first octet is the most significant. |
mod | M | Octet String | Modulus. Octet string representing a big integer, first octet is the most significant. |
Return Value
- A big integer, most significant octer first
Return Type
- Octet String
Python Example
g = "02" # MSB first |
SHA1
SHA1 (data)
Calculates SHA1 of data
Callable from:
- XFL
- Python
Arguments
Argument Name | Type | Data Type | Description |
---|---|---|---|
data | M | Octet String | Data for SHA1 hash function |
Return Value
- 20-octet SHA1 hash
Return Type
- Octet String
Python Example
sha1Param = "A1 B2 C3 D4 E5 F6 57 A1 B2 C3 D4 E5 F6 57 A1 B2 C3 D4 E5 F6" |
HMAC
HMAC (algorithm, key, data)
Calculates a hash-based message authentication code (HMAC)
Callable from:
- XFL
- Python
Arguments
Argument Name | Type | Value | Description |
---|---|---|---|
algorithm | M | String | HMAC algorithm |
key | M | Octet String | Key for HMAC algorithm |
data | M | Octet String | Data for HMAC algorithm |
algorithm values
Value |
---|
“hmac-md5” |
“hmac-sha1” |
“hmac-sha1-96” |
“hmac-sha-256” |
“hmac-sha-256-96” |
Return Value
- HMAC
Return Type
- Octet String
MILENAGE_f1
MILENAGE_f1 (k, rand, sqn, amf, op)
Calculates f1 function from the MILENAGE algorithm set (3GPP TS 35.205-208)
Callable from:
- XFL
- Python
Arguments
Argument Name | Type | Value Type | Description |
---|---|---|---|
k | M | Octet String | Subscriber key, 16 octets |
rand | M | Octet String | Random challenge, 16 octets |
sqn | M | Octet String | Sequence number, 6 octets |
amf | M | Octet String | Authentication management field, 2 octets |
op | M | Octet String | Operator Variant Algorithm Configuration Field, 16 octets |
Return Value
- MAC-A, a 8-octet (64-bit) network authentication code
Return Type
- Octet String
MILENAGE_f2345
MILENAGE_f2345 (k, rand, op)
Calculates f2345 function from the MILENAGE algorithm set (3GPP TS 35.205-208)
Callable from:
- XFL
- Python
Arguments
Argument Name | Type | Value Type | Description |
---|---|---|---|
k | M | Octet String | Subscriber key, 16 octets |
rand | M | Octet String | Random challenge, 16 octets |
op | M | Octet String | Operator Variant Algorithm Configuration Field, 16 octets |
Return Value
- RES (Signed Response, 8 octets), CK (Confidentiality Key, 16 octets), IK (Integrity Key, 16 octets), AK (Anonymity Key, 6 octets)
Return Type
- Array of four Octet String
Python Example
k = "01 25 45 74 58 35 43 65 14 21 33 12 54 77 92 ff" |
MILENAGE_f1star
MILENAGE_f1star (k, rand, sqn, amf, op)
Calculates f1* function from the MILENAGE algorithm set (3GPP TS 35.205-208)
Callable from:
- XFL
- Python
Arguments
Argument Name | Type | Value Type | Description |
---|---|---|---|
k | M | Octet String | Subscriber key, 16 octets |
rand | M | Octet String | Random challenge, 16 octets |
sqn | M | Octet String | Sequence number, 6 octets |
amf | M | Octet String | Authentication management field, 2 octets |
op | M | Octet String | Operator Variant Algorithm Configuration Field, 16 octets |
Return Value
- MAC-A, a 8-octet (64-bit) network authentication code
Return Type
- Octet String
MILENAGE_f5star
MILENAGE_f5star (k, rand, op)
Calculates f5* function from the MILENAGE algorithm set (3GPP TS 35.205-208)
Callable from:
- XFL
- Python
Arguments
Argument Name | Type | Value Type | Description |
---|---|---|---|
k | M | Octet String | Subscriber key, 16 octets |
rand | M | Octet String | Random challenge, 16 octets |
op | M | Octet String | Operator Variant Algorithm Configuration Field, 16 octets |
Return Value
- AK, a 6-octet (48-bit) anonymity key
Return Type
- Octet String
TLS_AddTrustFile
TLS_AddTrustFile (src-file-path)
Adds the trusted CAs in order to verify client or server certificates
Callable from:
- XFL
- Python
Arguments
Argument Name | Type | Value Type | Description |
---|---|---|---|
src-file-path | M | String | Absolute path to the X.509 Certificate file |
Return Value
- True if successful, False otherwise
Return Type
- Boolean
TLS_SetupCredentials
TLS_SetupCredentials (cert-file-path, key-file-path)
Sets a certificate/private key pair
Callable from:
- XFL
- Python
Arguments
Argument Name | Type | Value Type | Description |
---|---|---|---|
cert-file-path | M | String | Absolute path to the X.509 Certificate file |
key-file-path | M | String | Absolute path to the X.509 private key file |
Return Value
- True if successful, False otherwise
Return Type
- Boolean
Python API
send
send (pdu [, pdu [, …]])
Send a packet. The arguments are comma separated PDU data structures. The first one is a PDU of the top stack layer, the next one of the layer immedialtely below, etc. Each consecutive PDU is encoded and placed into a payload field of the follow-up PDU. The last argument is either an IP layer PDU or a data harness structure for passing the scripted part of the packet to an independently running transport stack (TCP for example) for further processing.
Callable from: from
- Python
Arguments
Argument Name | Type | Value | Description |
---|---|---|---|
pdu | M | PDU | PDU to be sent |
Return Value
- None
Example:
sk.send(pdu_ISUP, pdu_MTP2, pdu_MTP2_HAL) |
receive
receive ([var-pdu] [, timeout], pdu-type1 [, pdu-type2 [, …]] [, var-extra-pdu1, extra-pco1 [, var-extra-pdu2, extra-pco2 [, …]]])
Receives a packet. Checks every incoming packet for any of the specified PDU types listed (pdu-type1, pdu-type2, …), left to right. For the first PDU type match, stores the corresponding packet data to a variable specified in “var-pdu” argument. If more than one of the listed PDU types is present in the packet, the leftmost one takes priority. If no match is found, the packet is ignored.
To intercept lower layers of the captured packet, one or more pairs of “var-extra-pdu, extra-pco” arguments may be specified. If a PDU of “extra-pco” layer is present in the packet, the PDU data is stored to “var-extra-pdu”. There is no exact PDU type check for “extra-pdu”.
Callable from:
- Python
Arguments
Argument Name | Type | Value | Description |
---|---|---|---|
var-pdu | O | PDU/field | Variable to store the received PDU. This parameter must be initialized using create() API call without arguments. |
timeout | O | Integer | Maximum time to wait for an incoming packet, in milliseconds; infinite if omitted. |
pdu-type | M | PDU/field type | Type of PDU to receive |
var-extra-pdu | O | PDU/field | Variable to store a PDU captured at ‘extra-pco’, if present in the packet. This parameter must be initialized using create() API call without arguments. |
extra-pco | O | PCO | Additional PCO to intercept |
Return Value
- True in case of success, False otherwise
Return Type
- Boolean
Example:
var_SDPorINVITE = sk.create() # var_PDU |
sleep
sleep (timeout)
Delays script execution
Callable from:
- Python
Arguments
Argument Name | Type | Value | Description |
---|---|---|---|
timeout | M | Integer | Time to sleep |
Return Value
- None
Example:
sk.sleep(3000) |
gettime
gettime ()
Time in milliseconds elapsed from the script start
Callable from:
- Python
Arguments
- None
Return Value
- Time in milliseconds elapsed from the script start
Return Type
- Integer
Example:
tStart = sk.gettime() |
run
run (path, [mode] [, arg1 [, arg2 [, …]]])
Start a child script
Callable from:
- Python
Arguments
Argument Name | Type | Value | Description |
---|---|---|---|
path | M | String | Path to the script to run |
mode | O | Integer | Bit combination (OR) of the following flags. If omitted, the mode is equal to 0. |
arg | O | Any | Argument Name to pass to the script. Accessible in the child via ‘Settings.Arguments’ array. |
arg values
Value | Meaning |
---|---|
1 | Asynchronous mode (run() returns immediately and the started child script continues to run; otherwise, run() returns after child script returns; note that parent won’t stop until all asynchronous children are completed, even if the parent’s code is already executed completely) |
2 | Inherit globals (global variables and functions of this script are visible in the child script) |
4 | Separate socket set (send() and receive() in the child script use only IP sockets opened by the child itself, sockets opened in the parent script are not visible; for transceivers other than IP sockets, all incoming packets from emulator(s) are routed to each child separately) |
8 | Don’t preprocess (don’t preprocess (handle #includes etc) non-XFL script and don’t compile XFL scripts; variable values from text includes in XFL script are still updated) |
16 | Don’t update variable values (don’t update variable values from text includes in XFL script) |
Return Value
- A child script return value via stop() call; empty value if the child didn’t return anything.
Return Type
- Integer
Example:
ch = [None] * 3 # array to store children ids |
waitchild
waitchild (child [, timeout] [, mode])
Waits for child script to complete. The child script must be previously run() in asynchronous mode.
Callable from:
- Python
Arguments
Argument Name | Type | Value | Description |
---|---|---|---|
child | M | Integer | Identifier of the child script, returned by asynchronous run() |
timeout | O | Integer | Timeout, in milliseconds; infinite wait if omitted |
mode | O | Integer | Reserved for the future, use 0 |
Return Value
- If the child script returned a value via stop(), then that value; empty value if the child didn’t return anything; -1 if timeout occurs and the child is still running.
Return Type
- Integer
Example
child = sk.run("Demo", 1, "child") # '1' => asynch. mode |
decode
decode (data, raw, type [, method])
Stops script execution
Callable from:
- Python
Arguments
Argument Name | Type | Value | Description |
---|---|---|---|
data | M | PDU/field | Variable to store the decoded data |
raw | M | Octet string | Octet or bit string representing data encoding |
type | M | PDU/field type | Type of data to decode |
method | O | Integer | Decoding method |
Return Value
- True if data was successfully decoded, False otherwise.
Return Type
- Boolean
Example:
inSIP = sk.create(sk.SIP.REGISTER) |
decodeex
decodeex (data, lowerPCO, upperPCO, mode [, pco1 [, pco2 [, …]]])
Decodes multiple PDUs from a string of octets or bits or from a lower PDU.
Callable from:
- Python
Arguments
Argument Name | Type | Value | Description |
---|---|---|---|
data | M | Octet string | Octet or bit string representing data encoding, or the lowest PDU to start decode from |
lowerPCO | M | PCO | Lower PCO of the transformer applicable to ‘data’. Omitted (with no placeholder actual argument) if ‘data’ is a PDU instead of octet/bit string. |
upperPCO | M | PCO | Upper PCO of the transformer applicable to ‘data’. Omitted (with no placeholder actual argument) if ‘data’ is a PDU instead of octet/bit string. |
mode | M | Integer | Bit combination (OR) of flags |
pco | O | PCO | PCOs for decode process directing and ambiguity resolution |
mode values
Value | Meaning |
---|---|
1 | to the top (‘pcos’ argument is used only for ambiguity resolution; decode climbs up as much as possible, independent on ‘pcos’) |
2 | explicit suppresses implicit (if the transformer’s upper PCO is listed in ‘pcos’ explicitly, it leaves no chance for other non-mutex transformers to be applied) |
Return Value
- A multilayer packet
Return Type
- Common.PDU Tree
Example:
# Decoding multiple layers from raw binary, which must result in 4 decoded PDUs (layers) |
create
create (type)
Creates a variable of a given type, typically a packet
Callable from:
- Python
Arguments
Argument Name | Type | Value | Description |
---|---|---|---|
type | M | PDU/field type | Type of data to create. Typically a PDU type. |
Return Value
- A reference to the created variable
Return Type
- PDU/field
gettype
gettype (data)
Returns type of a PDU or another data element
Callable from:
- Python
Arguments
Argument Name | Type | Value | Description |
---|---|---|---|
data | M | PDU/field type | Packet or any other data element created by create(), receive() or decode()/decodeex(). |
Return Value
- Type of data
Return Type
- PDU type
getpco
getpco (data)
Determines PCO of the data type. Yields run-time error if the type is not a packet at any PCO.
Callable from:
- Python
Arguments
Argument Name | Type | Value | Description |
---|---|---|---|
data | M | PDU/field type | PDU type. If a ‘type’ is not a type of a whole PDU, run-time error occurs. |
Return Value
- PCO of the data type
Return Type
- PCO
copy
copy (dst, src)
Creates a copy of a PDU (or any data element - e.g., PDU’s field).
Callable from:
- Python
Arguments
Argument Name | Type | Value | Description |
---|---|---|---|
dst | M | PDU/field | Destination data element. If omitted function returns created element. |
src | M | PDU/field | Source data element |
Return Value
- A PDU
Return Type
- PDU
equal
equal (data1, data2)
Compares data elements - PDUs or their fields. Data elements can be of any complexity. They must be of the same type or, at least, compatible types - e.g., both integers - otherwise run-time error occurs. If you want to compare safely being not sure about type compatibility, first compare types of the data using gettype().
Callable from:
- Python
Arguments
Argument Name | Type | Value | Description |
---|---|---|---|
data1 | M | PDU/field | First data element to compare |
data2 | M | PDU/field | Second data element to compare |
Return Value
- True if data elements are equal, False otherwise.
Return Type
- Boolean
spoil
spoil (data)
Overwrites the data element passed as the argument with a value of ASN.1 ‘ANY’ type. You can then modify that ‘ANY’ and thus substitute any possible encoding for the ‘spoiled’ element. This is useful in negative testing, when invalid from the point of view of the protocol specification packet has to be sent.
Callable from:
- Python
Arguments
Argument Name | Type | Value | Description |
---|---|---|---|
data | M | PDU/field | Data element to overwrite |
Return Value
- None
random
random ()
Pseudo-random number in range 0..1. Independent from language-specific random generation. Pseudo-random sequence can be restarted by seedrandom.
Callable from:
- Python
Arguments
- None
Return Value
- None
print (value1 [, value2 [, …]])
Outputs one or more values to the Output pane
Callable from:
- Python
Arguments
Argument Name | Type | Value | Description |
---|---|---|---|
value | M | Any | Value to output. Can be anything at all, not necessarily protocol data. |
Return Value
- None
sprint
sprint (value1 [, value2 [, …]])
Formats one or more values as a string, identically to print().
Callable from:
- Python
Arguments
Argument Name | Type | Value | Description |
---|---|---|---|
value | M | Any | Value to format. Can be anything at all, not necessarily protocol data. |
Return Value
- A string with formatted data
Return Type
- String
keypressed
keypressed ()
Checks for keyboard input.
Callable from:
- Python
Arguments
- None
Return Value
- True if a key has been pressed.
Return Type
- Boolean
getchar
getchar ()
Gets a character from the keyboard.
Callable from:
- Python
Arguments
- None
Return Value
- A string containing a character from the keyboard. Empty string if no key has been pressed.
Return Type
- String
getchars
getchars ()
Gets all available character from the keyboard.
Callable from:
- Python
Arguments
- None
Return Value
- A string containing the characters from the keyboard. Empty string if no key has been pressed.
Return Type
- String
bindevent
bindevent (functionName)
Creates a handler for the event from a HTML control. Assign it to a HTML event handler.
Callable from:
- Python
Arguments
Argument Name | Type | Value | Description |
---|---|---|---|
functionName | M | String | Name of the function to be used as an event handler |
Return Value
- A wrapper COM object to be used as an event handler.
Example:
ie.Document.getElementById("MyButton").onclick = sk.bindevent("OnMyButtonClick") |
createwindow
createwindow (utl, options [, arguments])
Waits for child script to complete. The child script must be previously run() in asynchronous mode.
Callable from:
- Python
Arguments
Argument Name | Type | Value | Description |
---|---|---|---|
url | M | String | URL of the HTML resource to load. Typically “about:blank” or a file path. |
options | M | String | Window ornaments for the dialog box. This parameter can be a string that contains a combination of values, each separated by a semicolon (;). See the description of the features parameter of the IHTMLWindow2::showModalDialog method of the Window object for detailed information. |
arguments | O | Any | Arbitrary object to access from the HTML script code. |
Return Value
- A reference to a created window object that represents an open window in the browser.
helper
helper (class)
Creates a Packet Studio-defined helper object.
Callable from:
- Python
Arguments
Argument Name | Type | Value | Description |
---|---|---|---|
class | M | String | Class name of helper object. |
Return Value
- A reference to the created object.
getcorecount
getcorecount ()
Get number of CPU cores available.
Callable from:
- Python
Arguments
- None
Return Value
- Number of cores.
Return Value
- Integer
mos_get_val
mos_get_val ()
Returns the calculated MOS value.
Callable from:
- Python
Arguments
- None
Return Value
- MOS value calculated, range from 0 to 4.5
Return Value
- Float
Example:
txWav = "examples\\Audio\\Voice\\male.wav" # original |
mos_get_delay
mos_get_delay ()
Returns the calculated MOS delay.
Callable from:
- Python
Arguments
- None
Return Value
- Delay value calculated, in fractional seconds
Return Value
- Float
Python Example:
txWav = "examples\\Audio\\Voice\\male.wav" # original |
presskey
presskey (char)
Simulates a key pressed.
Callable from:
- Python
Arguments
Argument Name | Type | Value | Description |
---|---|---|---|
char | M | String | Character to simulate |
Return Value
- None
Python Example:
sk.presskey(ch); |