tencent cloud

Tencent Cloud Observability Platform

Release Notes and Announcements
Release Notes
Product Introduction
Overview
Strengths
Basic Features
Basic Concepts
Use Cases
Use Limits
Purchase Guide
Tencent Cloud Product Monitoring
Application Performance Management
Mobile App Performance Monitoring
Real User Monitoring
Cloud Automated Testing
Prometheus Monitoring
Grafana
EventBridge
PTS
Quick Start
Monitoring Overview
Instance Group
Tencent Cloud Product Monitoring
Application Performance Management
Real User Monitoring
Cloud Automated Testing
Performance Testing Service
Prometheus Getting Started
Grafana
Dashboard Creation
EventBridge
Alarm Service
Cloud Product Monitoring
Tencent Cloud Service Metrics
Operation Guide
CVM Agents
Cloud Product Monitoring Integration with Grafana
Troubleshooting
Practical Tutorial
Application Performance Management
Product Introduction
Access Guide
Operation Guide
Practical Tutorial
Parameter Information
FAQs
Mobile App Performance Monitoring
Overview
Operation Guide
Access Guide
Practical Tutorial
Tencent Cloud Real User Monitoring
Product Introduction
Operation Guide
Connection Guide
FAQs
Cloud Automated Testing
Product Introduction
Operation Guide
FAQs
Performance Testing Service
Overview
Operation Guide
Practice Tutorial
JavaScript API List
FAQs
Prometheus Monitoring
Product Introduction
Access Guide
Operation Guide
Practical Tutorial
Terraform
FAQs
Grafana
Product Introduction
Operation Guide
Guide on Grafana Common Features
FAQs
Dashboard
Overview
Operation Guide
Alarm Management
Console Operation Guide
Troubleshooting
FAQs
EventBridge
Product Introduction
Operation Guide
Practical Tutorial
FAQs
Report Management
FAQs
General
Alarm Service
Concepts
Monitoring Charts
CVM Agents
Dynamic Alarm Threshold
CM Connection to Grafana
Documentation Guide
Related Agreements
Application Performance Management Service Level Agreement
APM Privacy Policy
APM Data Processing And Security Agreement
RUM Service Level Agreement
Mobile Performance Monitoring Service Level Agreement
Cloud Automated Testing Service Level Agreement
Prometheus Service Level Agreement
TCMG Service Level Agreements
PTS Service Level Agreement
PTS Use Limits
Cloud Monitor Service Level Agreement
API Documentation
History
Introduction
API Category
Making API Requests
Monitoring Data Query APIs
Alarm APIs
Legacy Alert APIs
Notification Template APIs
TMP APIs
Grafana Service APIs
Event Center APIs
TencentCloud Managed Service for Prometheus APIs
Monitoring APIs
Data Types
Error Codes
Glossary

TCP/UDP-based Performance Testing

PDF
포커스 모드
폰트 크기
마지막 업데이트 시간: 2025-03-10 22:14:19

Basic Concept of Socket

Socket is a communication mechanism provided by the operating system for inter-process communication. The operating system provides a set of socket APIs that encapsulate the TCP/IP protocol, allowing processes to use sockets and send and receive network data through these APIs.
When you use socket APIs, the IP address and port of a process form a socket address. The socket addresses of both client and server processes, along with the transport protocol (TCP or UDP), form a socket 5-tuple, which identifies a network communication.

Script Writing

The socket module of the PTS API provides APIs supporting sockets. For details, see pts/socket.
By using these APIs, you can create a socket instance and send or receive TCP/UDP data through this instance.
Basic usage:
1. Create a socket instance.
Create a socket instance by using the new socket.Conn method. The parameters of this method include the protocol name (tcp or udp), service address, and service port.
2. Use the socket instance.
Sending data: Send data by using the send method of the instance. The parameter is binary data, and the return value is the number of bytes sent.
Receiving data: Receive data by using the recv method of the instance. The parameter is the number of bytes received, and the return value is the binary data received.
Closing the connection: Close the connection by using the close method of the instance.
Script example with the TCP protocol used:
// tcp connect to send package
import socket from "pts/socket";
import util from 'pts/util';
import {sleep} from 'pts';

export default function () {
const tcp_socket = new socket.Conn('tcp', '127.0.0.1', 80);
const send_data = `GET /get HTTP/1.1
Host: 127.0.0.1
User-Agent: pts-engine
\\r\\n`;
tcp_socket.send(util.toArrayBuffer(send_data));
const bytes_read = tcp_socket.recv(512);
tcp_socket.close();
console.log(bytes_read);
sleep(1);
}
Script example with the UDP protocol used:
// udp connect to send package
import socket from "pts/socket";
import util from 'pts/util';

export default function main() {
const udp_socket = new socket.Conn('udp', '127.0.0.1', 20001);
const send_data = `test data`;
udp_socket.send(util.toArrayBuffer(send_data));
const bytes_read = udp_socket.recv(1024);
udp_socket.close();
console.log(bytes_read);
}

Script Verification

To verify the script execution results, you can use the PTS debugging feature to quickly verify whether the results meet expectations before the formal performance testing. For more details, see Debug Scenarios.

File Dependency

In the performance testing scenario, you can upload the following types of files to provide status data during the execution of the performance testing task:
Parameter file: It dynamically provides test data in CSV format. That is, when the scenario is executed by each concurrent user (VU), each line of data will be obtained from the parameter file as the test data values for reference by variables in the script. For specific usage, see Using Parameter Files.
Request file: It is required for constructing your request, for example, the file that needs to be uploaded. For specific usage, see Using Request Files.
Protocol file: It is required for request serialization. For specific usage, see Using Protocol Files.

도움말 및 지원

문제 해결에 도움이 되었나요?

피드백