Updated on 2024-10-21 GMT+08:00

Adding Request Information (Packet)

Packets are data blocks transmitted between HTTP/HTTPS/TCP/UDP/HLS/RTMP/WebSocket/HTTP-FLV/MQTT-based applications. These data blocks start with text metadata that describes the packet content and meaning. The text metadata is followed by optional data. Packets are transmitted among clients, servers, and agents.

Procedure

  1. Log in to the CodeArts PerfTest console and choose PerfTest Projects in the left navigation pane.
  2. Click the name of the desired PerfTest project to go to the details page.
  3. On the Cases tab, select the desired test case in the case list on the left.
  4. On the Case Script tab page, select a case, and click Add Request.
  5. On the Packet tab page, select a protocol type based on the service protocol type. Currently, HTTP, HTTPS, TCP, UDP, HLS, RTMP, WebSocket, MQTT, and HTTP-FLV are supported. Set the basic information according to the following packet parameter tables.

    Table 1 HTTP and HTTPS packet parameters

    Parameter

    Description

    Request mode

    GET, POST, PATCH, PUT, or DELETE.

    Request URL

    URL for sending a request, for example, http://domain name/path, or http://domain name/path?key1=value1&key2=value2.

    Variables can be inserted. For details, see Inserting a Variable.

    Response Timeout (ms)

    Timeout period for waiting for a response from the server when a request is sent. The timeout ranges from 20 ms to 5 min.

    If this parameter is not set, the default response timeout interval (5,000 ms) is used.

    Carried cookie

    NOTE:

    At least one request exists in the case. Set parameters when adding new requests.

    • Obtain automatically: Use the cookie set in the response.
    • Obtain manually: Use the cookie in the header of the current request.

    Automatic Redirection

    Whether to redirect to the redirection address. The function is enabled by default, that is, the redirection address is automatically redirected to.

    Request Parameter

    Set the parameters in the request URL.

    Click Add Request Parameter and set Name and Value. Select Url Encode if necessary. By default, Url Encode is not selected. If Url Encode is selected, URL encoding is performed on the values of request parameters.

    If you do not need to add a request parameter, click Delete to delete it.

    RequestHeader

    Add headers and contents based on the headers to be verified or used by a pressure test server. Headers are not mandatory. Only user-defined headers are transparently transmitted to the pressure test server. For details about Header, see Header Description.

    Click Add Header and set Header and Value. If you do not need to add header information, click Delete to delete the packet header.

    You can click Bulk Edit to edit multiple headers at a time in the text box. You can click Key-Value Edit to return to the key-value pair editing mode.

    NOTE:

    If the request mode is POST or PUT and Header is Content-Type, variables can be inserted, and Value can be one of the three following types:

    • Customize: Enter a value in the text box.
    • application/x-www-form-urlencoded: The request body is a key value pair that can be added. The value is text.
    • multipart/form-data: The request body is a key-value pair that can be added. The value can be text or a file. If the value is a file, the body can be imported.

    Body

    The body of an entity contains a data block consisting of random data. Not all packets contain the body of an entity.

    If global variables have been set or local variables have been set for response extraction, variables can be used in the packet content. During a pressure test, variables in the packet content will be replaced with specified values.

    1. Enter $ in the request content input box.
    2. In the Insert Variable dialog box, set parameters. For details, see Inserting a Variable.
    3. Click Select.
    Table 2 TCP packet parameters

    Parameter

    Description

    IP

    IP address of the tested server to which requests are sent.

    Port Number

    Port number of the tested server to which requests are sent.

    Connection Timeout

    Timeout duration for the server's response after a connection is initiated. The connection timeout value ranges from 20 ms to 60s.

    Response Timeout

    Timeout duration for waiting for the server's response after a connection is established. The response timeout value ranges from 20 ms to 60s.

    Connection Settings

    • Repeated use: When a request response is complete, the connection remains and is used to send and receive the next request response.
    • Close: When a request response is complete, the connection is closed and re-established next time.

    Return Settings

    Used to judge whether a request response has been received.

    • Length of returned data: length of the returned data, in bytes. When a response of this length is received, data receiving is complete.
    • End-of-text character: ending mark of the returned data. When an end-of-text character is received, data receiving is complete.
      NOTE:

      It is recommended that a unique end-of-text character be set. If there are multiple such characters in a response, when the first character is received, the response is considered to have been received. As a result, the received response data is incomplete.

    Content Format

    Select String or Hexadecimal code stream data based on the service request content of the tested server.

    NOTE:

    A hexadecimal code stream can contain only numbers 0–9 and letters a–f. The total number of characters must be an even number.

    If global variables have been set or local variables have been set for response extraction, variables can be used in the packet content. During a pressure test, variables in the packet content will be replaced with specified values.

    1. Enter $ in the request content input box.
    2. In the Insert Variable dialog box, set parameters. For details, see Inserting a Variable.
    3. Click Select.
    Table 3 UDP packet parameters

    Parameter

    Description

    IP

    IP address of the tested server to which requests are sent.

    Port Number

    Port number of the tested server to which requests are sent.

    Return Settings

    Used to judge whether a request response has been received.

    • Length of returned data: length of the returned data, in bytes. When a response of this length is received, data receiving is complete.
    • End-of-text character: ending mark of the returned data. When an end-of-text character is received, data receiving is complete.
      NOTE:

      It is recommended that a unique end-of-text character be set. If there are multiple such characters in a response, when the first character is received, the response is considered to have been received. As a result, the received response data is incomplete.

    Content Format

    Select String or Hexadecimal code stream data based on the service request content of the tested server.

    NOTE:

    A hexadecimal code stream can contain only numbers 0–9 and letters a–f. The total number of characters must be an even number.

    If global variables have been set or local variables have been set for response extraction, variables can be used in the packet content. During a pressure test, variables in the packet content will be replaced with specified values.

    1. Enter $ in the request content input box.
    2. In the Insert Variable dialog box, set parameters. For details, see Inserting a Variable.
    3. Click Select.
    Table 4 HLS packet parameters

    Parameter

    Description

    Streaming media address

    Address of the video source, for example, http://domain name/path.

    Play Duration (s)

    Duration of simulated playback.

    NOTE:

    During case debugging, the playback duration is set to 3 seconds.

    Retry Delay (ms)

    Interval for obtaining new data in live streaming when the video playback source does not have new data.

    Retry Times

    Maximum number of attempts to obtain new data in live streaming when the video playback source does not have new data. If the number of attempts exceeds the maximum, the system determines that the attempt fails.

    Table 5 RTMP packet parameters

    Parameter

    Description

    Request Mode

    • Stream pushing: a process of transmitting onsite video signals to the network.
    • Stream pulling: a process of pulling streaming media video files from a server using a specified address.

    When Request Mode is Stream pushing, set the following parameters.

    Streaming server address

    IP address of the tested streaming media server.

    Port Number

    Listening port number of the tested streaming media server. The default value is 1935 for RTMP.

    App name

    AppName in the stream URL, that is, the path for storing live streaming media files, for example, live.

    Streaming name

    StreamName in the stream URL, which uniquely identifies a live stream, for example, livestream.

    Push duration (s)

    Duration for simulating stream pushing, in seconds.

    Video source address

    OBS address for storing video source files for simulating live stream pushing. Currently, only .flv files are supported. Non-standard H.265-encoded .flv files are not supported.

    When Request Mode is Stream pulling, set the following parameters.

    Streaming server address

    IP address of the tested streaming media server.

    Port Number

    Listening port number of the tested streaming media server. The default value is 1935 for RTMP.

    App name

    AppName in the stream URL, that is, the path for storing live streaming media files, for example, live.

    Streaming name

    StreamName in the stream URL, which uniquely identifies a live stream, for example, livestream.

    Play Duration (s)

    Simulated duration of live stream watching, in seconds.

    Table 6 WebSocket packet parameters

    Parameter

    Description

    Request mode

    Connect: Establish a WebSocket connection with the pressure test website.

    DisConnect: Close the connection to the pressure test website.

    Pong: Send pong to the pressure test website.

    Ping&Pong: Send pong to the pressure test website and expect to return ping.

    Request: Send a request to the pressure test website and receive a response.

    ReadOnly: Only receive information sent by the pressure test website.

    WriteOnly: Only send information to the pressure test website.

    Request connection address

    URL of the WebSocket connection, for example, ws://domain name/path. Encrypted requests are supported, such as wss://domain name/path.

    Connection Timeout (ms)

    Timeout duration for the server's response after a connection is initiated. The connection timeout value ranges from 20 ms to 60s.

    NOTE:

    This parameter needs to be set only when the request mode is Connect.

    Status Code

    Status code for closing a connection. The default value is 1,000. The value range is 0–4,999.

    NOTE:

    This parameter needs to be set only when the request mode is DisConnect.

    Request Type

    Select Text or Binary based on the service request content of the tested server.

    NOTE:
    • Binary indicates hexadecimal.
    • This parameter needs to be set only when the request mode is Request or WriteOnly.

    Bodys

    Enter the packet content of request information based on the specified request type.

    NOTE:
    • This parameter needs to be set only when the request mode is Request or WriteOnly.
    • When the request content is text, you can enter variables. For details, see Inserting a Variable.

    Response Type

    Select Text or Binary based on the service response content of the tested server.

    NOTE:
    • Binary indicates hexadecimal.
    • This parameter needs to be set only when the request mode is Request or ReadOnly.

    Response Timeout (ms)

    Timeout duration for waiting for the server's response after a connection is established. The response timeout value ranges from 20 ms to 60s.

    Request Header

    Add headers and contents based on the headers to be verified or used by a pressure test server. Headers are not mandatory. Only user-defined headers are transparently transmitted to the pressure test server. For details about Header, see Header Description.

    Click Add Header and set Header and Value. If you do not need to add header information, click Delete to delete the packet header.

    You can click Bulk Edit to edit multiple headers at a time in the text box. You can click Key-Value Edit to return to the key-value pair editing mode.

    Table 7 HTTP-FLV packet parameters

    Parameter

    Description

    Streaming media address

    Address of the video source, for example, http://{Video source IP address}:8080/live/stream.flv.

    Play Duration (s)

    Duration of simulated playback.

    NOTE:

    During case debugging, the playback duration is set to 3 seconds.

    Table 8 MQTT packet parameters

    Parameter

    Description

    Request mode

    Connect: Establish an MQTT connection with the pressure test website.

    Publish: Publish a message.

    Subscribe: Subscribe to sent messages.

    DisConnect: Close the MQTT connection with the pressure test website.

    When the request mode is Connect, set the following parameters.

    MQTT Version

    MQTT version. Currently, 3.1 and 3.1.1 are supported.

    Transport Address

    MQTT server address, which supports the TCP, SSL, WebSocket, and WSS protocols.

    NOTE:

    Domain names cannot be bound to MQTT transmission addresses.

    Timeout interval

    Timeout interval for the client to perform operations such as establishing a connection and sending a message.

    Client ID

    MQTT client ID. You can set whether to add a random suffix to the client ID by enabling or disabling Add a random suffix.

    Username

    Username set for the MQTT client. This parameter is sensitive. Set it using global variables in sensitive parameter mode.

    Password

    Password set for the MQTT client. This parameter is sensitive. Set it using global variables in sensitive parameter mode.

    Connection keepalive

    Active heartbeat interval, in seconds.

    Clear Sessions

    • If this option is toggled on, the reserved session information of the last connection will be cleared when a connection is established between the client and the server.
    • If this option is toggled off, the reserved session information of the last connection will not be cleared when a connection is established between the client and the server.

    Add Will

    • You can toggle on this option to add a will. In this way, when the client is disconnected abnormally, the MQTT agent automatically publishes the will message to other subscribers.
      Set the following parameters when adding a will:
      • Theme: topic of the will.
      • Type: Text or Hex. You can also set whether to add a timestamp.
      • Content: content of the will.
      • QoS Level: quality of service (QoS) level, which is used to describe the reliability of message transmission. Send at most once: applicable to real-time data transmission. Send at least once: applicable to applications that require reliability but allow a slight delay. Only once: applicable to applications that require high reliability and allow a long delay.
      • Keep your will: If this option is toggled on, the subscribing client receives the set will message immediately after subscription. If this option is toggled off, the subscribing client receives the will message only after the client that publishes the will message is disconnected unexpectedly.
    • If you toggle off Add Will, no will message will be sent.

    If the request mode is Publish, set the following parameters:

    Theme

    Topic of the message to be published.

    QoS Level

    QoS level, which is used to describe the reliability of message transmission. Send at most once: applicable to real-time data transmission. Send at least once: applicable to applications that require reliability but allow a slight delay. Only once: applicable to applications that require high reliability and allow a long delay.

    Request Type

    Text or Hex. You can also set whether to add a timestamp.

    Request Content

    Detailed content of the request.

    Timeout interval

    Timeout interval for the client to send a message.

    Reserved Message

    • If this option is toggled on, messages published when the client is disconnected are stored on the server.
    • If this option is toggled off, messages published when the client is disconnected are cleared.

    When the request mode is Subscribe, set the following parameters.

    Subscribe to Topic

    Topic of the subscribed message, which must match the topic of the published message.

    QoS Level

    QoS level, which is used to describe the reliability of message transmission. Send at most once: applicable to real-time data transmission. Send at least once: applicable to applications that require reliability but allow a slight delay. Only once: applicable to applications that require high reliability and allow a long delay.

    Response Type

    Text or Hex. You can also set whether to add a timestamp.

    Timeout interval

    Timeout interval of the subscription topic.

    End Condition

    When this condition is met, the subscription ends.

    • Maximum triggering time: The subscription ends when the time reaches the upper limit.
    • Maximum Number of Received Messages Triggered: The subscription ends when the number of received messages reaches the upper limit.

    If the request mode is Disconnect, you do not need to set parameters.

  6. Click Save.

Filling in a Packet

Packets refer to all click operations performed by users on the website interface. The process of sending a packet: A click operation is edited to a code stream complying with protocol specifications and carrying a user's request before the code stream is sent to a third party, leading to a correct or failed response.

Press F12 or use a packet-capturing tool (such as Wireshark) to check how a packet is requested and fill in the packet to be tested according to the actual service.