Skip to content

TCP Testing Task

The TCP Testing Task defines a TCP protocol testing task for functional, performance, stability, and custom testing of TCP.

Main Parameter List

Field NameTypeRequiredLength/RangeDefaultDescription
targetenumYes-TCPTask Type Identifier
Fixed value: TCP
namestringYes≤400 chars-Task Unique Identifier
Example: Device Heartbeat Detection
descriptionstringNo≤800 chars-Task Description
Detailed explanation of communication purpose
enabledbooleanYes-trueEnable Status
true: Execute task
false: Skip task
beforeNamestringNo≤400 chars-Preceding Task
Controls execution order
Example: Data Preparation Task
serverobjectYes--Server Configuration
Includes host address and port information
datastringYes≤2MB-Data to Send
Supports raw content or Base64 encoding
Supports variables and functions
Example: @Hex('A0 01 FF')
dataEncodingenumNo-noneData Encoding
none: Raw data
base64: Base64 encoded
gzip_base64: Gzipped then Base64 encoded
settingobjectYes--Connection Settings
Includes timeout, buffer, retry, and other parameters

Note

Multiple SMTP interfaces can be orchestrated simultaneously, but only one SMTP can be enabled for testing at a time.

Complete TCP Configuration Example:

yaml
- target: TCP
  name: Send tcp plain data
  description: Using tcp protocol to send plain data to server
  enabled: true
  server:
    # Server configuration ...
  data: "This is a tcp data content"
  dataEncoding: none
  setting:
    # Request settings ...

Server Configuration (server)

Field NameTypeRequiredLength/RangeDefaultDescription
serverstringYes≤253 chars-Server Address
Supports IPv4/IPv6 addresses or domains
Example: device-gateway.example.com
portintegerYes1-65535-Service Port
Standard port range
Example: 502 (Modbus)
connectTimeoutstringNo1s-24h6sConnection Establishment Timeout
Format: number + unit (e.g., 10s)
Cross-region connections recommend 15-30s
responseTimeoutstringNo1s-24h60sResponse Wait Timeout
Format: number + unit (e.g., 30s)
Large data transfers recommend 120-300s

Server Configuration Example:

yaml
server:
  server: localhost
  port: 8083
  connectTimeout: 6s
  responseTimeout: 60s

Request Settings (setting)

Field NameTypeRequiredLength/RangeDefaultDescription
tcpClientImplClassenumYes--TCP Client Implementation Class
TcpClientImpl: Standard text protocol
BinaryTcpClientImpl: Raw binary protocol
LengthPrefixedBinaryTcpClientImpl: Binary protocol with length prefix
reUseConnectionbooleanNo-trueConnection Reuse
true: Keep connection for reuse
false: Create new connection each time
Recommended for high-frequency requests
closeConnectionbooleanNo-falseClose Connection Immediately
true: Close after sending
false: Keep connection open
Mutually exclusive with reUseConnection
soLingerintegerNo0-65535-Close Delay Time (seconds)
Sets TCP connection's SO_LINGER option
0: Close immediately
>0: Wait for specified seconds
tcpNoDelaybooleanNo-trueDisable Nagle's Algorithm
true: Disable to reduce latency
false: Enable to improve throughput
Recommended for real-time systems
tcpCharsetstringNo≤16 charsUTF-8Character Encoding
Supports standard charset names
Examples: GBK, ISO-8859-1, UTF-16
eolBytebyteNo0-255-End-of-Line Byte
Used for line separators in text protocols
Example: 10 (\n)
eomBytebyteNo0-255-End-of-Message Byte
Used for message termination
Example: 13 (\r)
binaryPrefixLengthintegerNo2 or 4-Length Prefix Bytes
Message length prefix for binary protocols
2: 2 bytes (65535 bytes)
4: 4 bytes (4GB)

Request Settings Example:

yaml
setting:
  tcpClientImplClass: TcpClientImpl
  reUseConnection: true
  closeConnection: false
  soLinger: 100000
  tcpNoDelay: true
  tcpCharset: UTF-8
  eolByte: 10
  eomByte: 13
  binaryPrefixLength: 2

Client Implementation Classes (tcpClientImplClass)





1. TcpClientImpl (Text Protocol Implementation)

Core Features:

  • Suitable for line-based text protocols (e.g., Telnet, SMTP)
  • Uses eolByte parameter to define line terminator (e.g., \n=10)
  • Reads entire connection stream if eolByte is not set
  • Typical applications: Command-line interfaces, log collection

Enterprise Configuration:

yaml
tcpClientImplClass: "TcpClientImpl"
eolByte: 10  # \n newline
2. BinaryTcpClientImpl (Raw Binary Implementation)

Core Features:

  • Suitable for unstructured binary protocols
  • Uses eomByte parameter to define message terminator (e.g., 0x03=ETX)
  • Reads entire connection stream if eomByte is not set
  • Typical applications: Industrial control, device communication

Enterprise Configuration:

yaml
tcpClientImplClass: "BinaryTcpClientImpl"
eomByte: 3  # ETX terminator
3. LengthPrefixedBinaryTcpClientImpl (Length-Prefixed Protocol Implementation)

Core Features:

  • Suitable for binary protocols with length prefixes
  • Specifies prefix length via binaryPrefixLength (2 or 4 bytes)
  • Automatically parses length header and reads exact data amount
  • Typical applications: Financial payments (ISO8583), large data transfers

Enterprise Configuration:

yaml
tcpClientImplClass: "LengthPrefixedBinaryTcpClientImpl"
binaryPrefixLength: 2  # 2-byte length prefix

Script Examples (target)

Complete Parameter Configuration Example

yaml
- target: TCP
  name: Send tcp plain data
  description: Using tcp protocol to send plain data to server
  enabled: true
  server:
    server: localhost
    port: 8083
    connectTimeout: 6s
    responseTimeout: 60s
  data: "This is a tcp data content"
  dataEncoding: none
  setting:
    tcpClientImplClass: TcpClientImpl
    reUseConnection: true
    closeConnection: false
    soLinger: 100000
    tcpNoDelay: true
    tcpCharset: UTF-8
    eolByte: 10
    eomByte: 13
    binaryPrefixLength: 2

Using TcpClientImpl to Send TCP Data

yaml
- target: TCP
  name: Send tcp data using eol byte
  description: Send TCP data using the TcpClientImpl class implementation.
  enabled: true
  server:
    server: localhost
    port: 8083
    connectTimeout: 6s
    responseTimeout: 60s
  data: This is a tcp data content
  dataEncoding: none
  setting:
    tcpClientImplClass: TcpClientImpl
    reUseConnection: true
    closeConnection: false
    tcpNoDelay: true
    tcpCharset: UTF-8
    eolByte: 10

Using BinaryTcpClientImpl to Send TCP Data

yaml
- target: TCP
  name: Send tcp data using eom byte
  description: Send TCP data using the BinaryTcpClientImpl class implementation.
  enabled: true
  server:
    server: localhost
    port: 8083
    connectTimeout: 6s
    responseTimeout: 60s
  data: This is a tcp data content
  dataEncoding: none
  setting:
    tcpClientImplClass: BinaryTcpClientImpl
    reUseConnection: true
    closeConnection: false
    tcpNoDelay: true
    tcpCharset: UTF-8
    eomByte: 13

Using LengthPrefixedBinaryTcpClientImpl to Send TCP Data

yaml
- target: TCP
  name: Send tcp data using length prefixed
  description: Send TCP data using the LengthPrefixedBinaryTcpClientImpl class implementation.
  enabled: true
  server:
    server: localhost
    port: 8083
    connectTimeout: 6s
    responseTimeout: 60s
  data: This is a tcp data content
  dataEncoding: none
  setting:
    tcpClientImplClass: LengthPrefixedBinaryTcpClientImpl
    reUseConnection: true
    closeConnection: false
    tcpNoDelay: true
    tcpCharset: UTF-8
    binaryPrefixLength: 2

Released under the GPL-3.0 License.