Network tester simulation protocol stack implementation method and system
By using the user-state protocol stack in the network tester, creating virtual network cards and optimizing routing table management, the problem of sending and receiving messages caused by low efficiency in virtual network cards and routing tables in the existing technology is solved, and efficient protocol simulation and flexibility are achieved network testing.
Patent Information
- Application Number
- CN202411584421.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-07
- Publication Date
- 2025-02-18
AI Technical Summary
When the existing technology performs protocol simulation in network testers, virtual network card creation efficiency is low and cannot meet the needs of large-scale protocol simulation. At the same time, the packet sending and receiving problems and loopback restrictions caused by routing tables cannot be solved.
Using the user-state protocol stack, through the cooperation between management threads, data sending and receiving threads, and protocol stack threads, create virtual network cards and build socket connection and mapping relationship records, and optimize network card queue message processing and routing table management.
It improves the efficiency of virtual network card creation, supports the creation of 65,535 virtual network cards, removes the packet sending and receiving problems and loopback restrictions caused by routing tables, and improves the system's throughput and flexibility.
Smart Images

Figure CN119484664A_ABST
Abstract
Description
Technical Field
[0001] The invention belongs to the field of network testing, relates to a simulation protocol stack implementation technology, and specifically provides a network tester simulation protocol stack implementation method and system. Background Art
[0002] When using a network tester to test network devices such as switches and routers, an important scenario is to simulate a large number of protocol terminals and the devices under test to perform protocol interactions and verify the performance and stability of the devices under test. To do this, it is necessary to run a simulation program on the tester to simulate a large number of simulated devices. These simulated devices need to have different MAC addresses and IP addresses, so that they will be treated as real devices on the devices under test for protocol message interactions.
[0003] In the prior art, a macvlan sub-interface is configured to configure multiple sub-interfaces on a physical network card, so that the simulation program has an independent IP address and MAC address after being bound to the sub-interface, thereby creating multiple macvlan sub-interfaces to simulate multiple virtual devices;
[0004] However, in the prior art, the kernel protocol stack manages network cards in a list manner. Each time a network card is configured, the entire list needs to be traversed to determine whether there is a conflict. Therefore, the efficiency of configuring virtual network cards is very low, and the number of virtual network cards required for 64K large-scale protocol simulation cannot be met.
[0005] At the same time, the virtual network card of the kernel protocol stack uses a public routing table. When the network tester performs protocol simulation, the simulated device often uses the address of the same network segment. In this way, only one route in the routing table to the device under test is effective. If the source address of the protocol simulation is not the address directly connected to the device under test, but a loopback port address, a table lookup error will occur when the simulated message is sent, resulting in the inability to correctly establish a connection;
[0006] Multiple ports on the tester need to perform large-scale protocol simulations simultaneously, and the shared core protocol stack makes resources even more strained.
[0007] The present invention provides a method and system for realizing a network tester simulation protocol stack to solve the above technical problems. Summary of the invention
[0008] The present invention aims to solve at least one of the technical problems existing in the prior art; to this end, the present invention proposes a network tester simulation protocol stack implementation method and system, which are used to solve the specification limitation problem during tester protocol simulation in the prior art, and secondly to solve the message receiving and sending problem caused by the routing table, and the technical problem that the loopback port restriction cannot be used during protocol simulation.
[0009] To achieve the above object, a first aspect of the present invention provides a method for implementing a network tester simulation protocol stack, comprising:
[0010] S100: obtaining a number of simulation threads from a database, importing the simulation threads into and starting a user-mode protocol stack; processing network card queue messages on different CPU cores through configuration information; wherein the user-mode protocol stack includes: a management thread, a number of data receiving and sending threads, and a number of protocol stack threads;
[0011] S200: creating a virtual network card in the user-mode protocol stack, and constructing a socket connection and mapping relationship record between the simulation thread and the protocol stack thread;
[0012] S300: On the user mode protocol stack, start sending or receiving messages of the protocol simulation program to complete the simulation protocol stack network test.
[0013] Preferably, the processing of network card queue messages on a plurality of CPU cores according to the configuration information includes:
[0014] Set configuration information, and start data sending and receiving threads and protocol stack threads according to the configuration information;
[0015] Call K protocol stack threads to run the user-mode protocol stack; pass the message data pointer between the data sending and receiving thread and the protocol stack thread through a lock-free queue;
[0016] The running user-mode protocol stack is: M data receiving and sending threads running on different CPU cores process messages from network card queue 1 to network card queue M based on DPDK technology; wherein the configuration information includes: setting the number of K, setting the number of M, DPDK configuration parameters and protocol stack configuration parameters; the value range of M is 1-4, the value range of K is 2-6; and K≥M.
[0017] It should be noted that the specific values of M and K are set by the staff based on actual work experience.
[0018] The present invention runs M data receiving and sending threads on different CPU cores, which can make full use of the computing resources of a multi-core CPU, realize parallel processing, and improve the throughput of the system; the number of K protocol stack threads and M data receiving and sending threads is set according to configuration information, which can be adjusted according to actual application scenarios and hardware resources to achieve optimal resource configuration; the value ranges of K and M are 2-6 and 1-4 respectively, and K≥M. This configuration method enables the system to be flexibly expanded or reduced according to the number of CPU cores that can actually be provided by the operating environment; by calling K protocol stack threads to run the user-mode protocol stack, a variety of different protocol stacks can be supported, thereby improving the flexibility and scalability of the system.
[0019] Preferably, the step of creating a virtual network card in a user-mode protocol stack includes:
[0020] The user sends a command to create a virtual network card to the management thread through the simulation program; the management thread forwards the command to create the virtual network card to the corresponding protocol stack thread one by one based on the load sharing principle, and establishes a mapping table; wherein the mapping table includes: a mapping table of the network card MAC address and the protocol stack thread data receiving queue, and a mapping table of the IP address and the protocol stack socket command receiving queue;
[0021] The protocol stack thread creates a virtual network card and a corresponding routing table, configures the MAC address and IP address, and records the mapping relationship between the MAC address and the virtual network card to the internal bridge; manages the network card information through the hash table, and creates and configures the virtual network card.
[0022] The present invention distributes commands for creating virtual network cards to different protocol stack threads one by one, so that management threads can achieve load sharing and avoid overloading of a single thread, thereby improving the overall performance and stability of the system; the protocol stack manages network card information through a hash table to provide fast creation and search capabilities, and can quickly create and configure a large number of virtual network cards; the establishment of a mapping table enables the system to efficiently manage and access relevant information of the virtual network cards; through the mapping of MAC addresses and protocol stack thread data receiving queues, as well as the mapping of IP addresses and protocol stack socket command receiving queues, the system can quickly locate and process related network communications.
[0023] Preferably, the step of constructing a socket connection and mapping relationship record between a simulation thread and a protocol stack thread includes:
[0024] S210: The user simulation program starts the simulation thread, and the simulation thread corresponds to the result receiving queue one by one;
[0025] S220: The simulation thread sends a socket connection command to the management thread and carries its own result receiving queue information;
[0026] S230: the management thread obtains the socket command queue of the protocol stack thread according to the IP address bound to the socket and the mapping table of the protocol stack socket command receiving queue, and forwards the socket command to the specified queue;
[0027] S240: the protocol stack thread processes the socket command to establish an internal socket, and records the mapping between the socket ID and the result receiving queue of the simulation thread;
[0028] S250: The protocol stack thread returns the socket ID and its own socket command queue information;
[0029] S260: The simulation program records the mapping relationship between the socket ID and the protocol stack thread command queue.
[0030] The present invention provides each simulation thread with a corresponding result receiving queue, which helps to clearly manage simulation data; at the same time, the protocol stack thread records the mapping between the socket ID and the simulation thread result receiving queue, ensuring that data can be accurately transmitted from the remote service or device to the corresponding simulation thread; the communication between the simulation thread and the management thread and the protocol stack thread is carried out through the queue, which realizes the decoupling between threads, allows the system to process multiple simulation tasks in parallel, and improves the throughput and response speed of the system
[0031] Preferably, the message for starting the protocol simulation program is sent, including:
[0032] S310: The protocol simulation thread sends a socket message sending instruction to the corresponding protocol stack thread;
[0033] S311: The protocol stack thread calls the internal socket function to perform data sending operation;
[0034] S312: The data is encapsulated into a message by the protocol stack and enters the protocol stack thread sending queue;
[0035] S313: multiple data receiving and sending threads, as consumers, sequentially obtain messages from the sending queue of each protocol stack thread and write them into the network card queue.
[0036] The present invention uses a protocol stack thread to encapsulate messages and put them into a sending queue. This design makes the message processing process more efficient because the encapsulation operation and the data sending operation can be performed in parallel; the protocol stack thread can focus on message encapsulation, while the data transceiver thread focuses on obtaining messages from the queue and sending them to the network card; multiple data transceiver threads act as consumers to obtain messages from the sending queue of the protocol stack thread, which helps to optimize the use of system resources.
[0037] Preferably, the receiving of the message for starting the protocol simulation program includes:
[0038] S320: The protocol simulation thread sends a poll command to the protocol stack thread and waits for a response;
[0039] S321: The protocol stack thread adds the read and write events of the FD corresponding to the socket ID;
[0040] S322: When the data receiving and sending thread receives a message, it queries the MAC mapping table according to the destination MAC address of the message to obtain the message receiving queue of the corresponding protocol stack thread, and writes the message into the message receiving queue;
[0041] S323: The internal bridge of the protocol stack thread forwards the message to the corresponding virtual network card according to the destination MAC address;
[0042] S324: The message is processed by the protocol stack and triggers a read event of the socket FD;
[0043] S325: The protocol stack thread processes the FD read event and returns a response message to the poll command of the protocol simulation thread;
[0044] S326: The protocol simulation thread sends a socket read command to read the message content.
[0045] The present invention uses the poll command and the read and write events of the FD, so that the system can efficiently process network communication in an event-driven manner; when data arrives, a corresponding event is triggered, thereby avoiding unnecessary polling and waiting, and improving the response speed and efficiency of the system; the message is forwarded to the corresponding virtual network card through the internal bridge, and the system can support multiple virtual network environments, providing independent network communication channels for different applications or services, which increases the flexibility and scalability of the system; when the message triggers the read event of the socket FD, the protocol stack thread will process the event and return a response message to the poll command of the protocol simulation thread, and this clear response mechanism enables the system to accurately track and process each request and response, thereby ensuring the reliability and consistency of communication.
[0046] The second aspect of the present invention provides a network tester simulation protocol stack implementation system, including: a network simulation module, a virtualized network module, and a message transceiver module;
[0047] Network simulation module: obtains several simulation threads from the database, imports several simulation threads into and starts the user-mode protocol stack; processes network card queue messages on different CPU cores through configuration information; wherein the user-mode protocol stack includes: a management thread, several data sending and receiving threads, and several protocol stack threads;
[0048] Virtualized network module: creates a virtual network card in the user-mode protocol stack, builds the socket connection and mapping relationship record between the simulation thread and the protocol stack thread;
[0049] Message transceiver module: On the user-mode protocol stack, start the protocol simulation program to send or receive messages to complete the simulation protocol stack network test.
[0050] Compared with the prior art, the present invention has the following beneficial effects:
[0051] 1. First, the specification limitation problem during tester protocol simulation was solved, the efficiency of creating virtual network cards was improved, and the number of virtual network cards supported on each physical network card was increased to 65535; secondly, the message sending and receiving problem caused by the routing table was solved, and the restriction that the loopback port could not be used during protocol simulation was lifted; the establishment of the mapping table enables the system to efficiently manage and access the relevant information of the virtual network card; through the mapping of MAC address and protocol stack thread data receiving queue, as well as the mapping of IP address and protocol stack socket command receiving queue, the system can quickly locate and process related network communications.
[0052] 2. The present invention constructs socket connections and mapping relationship records between simulation threads and protocol stack threads, so that the system can flexibly configure and manage different simulation scenarios to meet various testing requirements; the design of the user-mode protocol stack enables the system to support multiple network protocols and communication scenarios; by configuring different protocol stack threads and data sending and receiving threads, the system can simulate various network protocols and communication mechanisms to meet different testing requirements; through network simulation and testing environment, enterprises can reduce the cost and risk of testing in a real network environment; the simulation environment can simulate various possible network failures and abnormal situations, thereby helping testers to discover and solve problems in advance and reduce the failure rate in actual deployment. BRIEF DESCRIPTION OF THE DRAWINGS
[0053] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0054] Figure 1 A schematic diagram of the steps of implementing the simulation protocol stack of the present invention;
[0055] Figure 2 A schematic diagram of a specific process flow for realizing the simulation protocol stack of the present invention;
[0056] Figure 3 A schematic diagram of the message receiving and sending process of the present invention;
[0057] Figure 4 It is a schematic diagram of the relationship between the modules included in the present invention. DETAILED DESCRIPTION
[0058] The technical solution of the present invention will be clearly and completely described below in conjunction with the embodiments. Obviously, the described embodiments are only part of the embodiments of the present invention, rather than all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0059] See also Figure 1 The first aspect of the present invention provides a method for implementing a network tester simulation protocol stack, comprising:
[0060] S100: obtaining a number of simulation threads from a database, importing the simulation threads into and starting a user-mode protocol stack; processing network card queue messages on different CPU cores through configuration information; wherein the user-mode protocol stack includes: a management thread, a number of data receiving and sending threads, and a number of protocol stack threads;
[0061] S200: creating a virtual network card in the user-mode protocol stack, and constructing a socket connection and mapping relationship record between the simulation thread and the protocol stack thread;
[0062] S300: On the user mode protocol stack, start sending or receiving messages of the protocol simulation program to complete the simulation protocol stack network test.
[0063] See also Figure 2 , simulate the specific process of protocol stack implementation, set configuration information, and start data sending and receiving threads and protocol stack threads according to the configuration information;
[0064] Call K protocol stack threads to run the user-mode protocol stack; pass the message data pointer between the data sending and receiving thread and the protocol stack thread through a lock-free queue;
[0065] The user-mode protocol stack is run as follows: M data transceiver threads running on different CPU cores process messages from network card queue 1 to network card queue M based on DPDK technology; wherein the configuration information includes: setting the number of K, setting the number of M, DPDK configuration parameters and protocol stack configuration parameters; the value range of M is 1-4, and the value range of K is 2-6; and K≥M; the user sends a command to create a virtual network card to the management thread through the simulation program; the management thread forwards the command to create the virtual network card to the corresponding protocol stack thread in a one-by-one manner based on the load sharing principle, and establishes a mapping table; wherein the mapping table includes: a mapping table of the network card MAC address and the protocol stack thread data receiving queue, and a mapping table of the IP address and the protocol stack socket command receiving queue;
[0066] The protocol stack thread creates a virtual network card and a corresponding routing table, configures the MAC address and IP address, and records the mapping relationship between the MAC address and the virtual network card to the internal bridge; manages the network card information through the hash table, creates and configures the virtual network card;
[0067] The user simulation program starts the simulation thread and makes the simulation thread correspond to the result receiving queue one by one; the simulation thread sends a socket connection command to the management thread and carries its own result receiving queue information; the management thread obtains the socket command queue of the protocol stack thread according to the IP address bound to the socket and the mapping table of the protocol stack socket command receiving queue, and forwards the socket command to the specified queue; the protocol stack thread processes the socket command to establish an internal socket, and records the mapping of the socket ID and the result receiving queue of the simulation thread; the protocol stack thread returns the socket ID and its own socket command queue information; the simulation program records the mapping relationship between the socket ID and the protocol stack thread command queue.
[0068] For example, a network tester is now tested for a simulated protocol stack. The network tester is currently in a 48-core operating environment, with M configured as 1, K as 2, and the upper-layer application uses 4 cores. Six protocol simulation network cards can be provided externally, and each network card has 7 cores, except for the 6 cores reserved for other system services. Two protocol stack threads are called to run the user-mode protocol stack. The message data pointer is passed between the data transceiver thread and the protocol stack thread through a lock-free queue. In the user-mode protocol stack, a data transceiver thread running on a different CPU core processes the message of the network card queue 1 based on the DPDK technology.
[0069] The protocol stack thread creates a virtual network card and a corresponding routing table, configures the MAC address and IP address, and records the mapping relationship between the MAC address and the virtual network card to the internal bridge; the network card information is managed by the hash table, so that each protocol stack thread can quickly create and configure 65535 virtual network cards.
[0070] It should be noted that the specific allocation process of M and K needs to be tested in a real environment to obtain the performance bottleneck and the number of cores that need to be allocated to each module; a 2-byte value is used when implementing the protocol stack, and the maximum number of virtual network cards created and configured by each protocol stack thread is 65535; when multiple protocol stack threads are configured to run on a physical network card, as long as the computing resources are sufficient, there is no limit to the number of simulated addresses in theory.
[0071] See also Figure 3 , message sending process:
[0072] S310: The protocol simulation thread sends a socket message sending instruction to the corresponding protocol stack thread;
[0073] S311: The protocol stack thread calls the internal socket function to perform data sending operation;
[0074] S312: The data is encapsulated into a message by the protocol stack and enters the protocol stack thread sending queue;
[0075] S313: multiple data receiving and sending threads, as consumers, sequentially obtain messages from the sending queue of each protocol stack thread and write them into the network card queue;
[0076] Message receiving and processing process:
[0077] S320: The protocol simulation thread sends a poll command to the protocol stack thread and waits for a response;
[0078] S321: The protocol stack thread adds the read and write events of the FD corresponding to the socket ID;
[0079] S322: When the data receiving and sending thread receives a message, it queries the MAC mapping table according to the destination MAC address of the message to obtain the message receiving queue of the corresponding protocol stack thread, and writes the message into the message receiving queue;
[0080] S323: The internal bridge of the protocol stack thread forwards the message to the corresponding virtual network card according to the destination MAC address;
[0081] S324: The message is processed by the protocol stack and triggers a read event of the socket FD;
[0082] S325: The protocol stack thread processes the FD read event and returns a response message to the poll command of the protocol simulation thread;
[0083] S326: The protocol simulation thread sends a socket read command to read the message content.
[0084] For example, a network tester is now tested for message reception and transmission processing; the protocol stack simulation test first calls the encapsulated socket function through the protocol simulation thread to send the command to establish the socket to the protocol stack management thread, and the command information contains the local socket message receiving queue information; the protocol stack management thread queries the mapping table from the IP address to the protocol stack thread, and forwards the socket command to the protocol stack thread; the protocol stack thread processes the socket command and records the socket The mapping relationship between the ID and the socket message receiving queue of the protocol simulation thread; the result is written back to the socket message receiving queue of the protocol simulation thread; the protocol simulation thread calls the socket interface to send a message, and the message is written into the protocol stack thread message queue obtained when the socket is created; the protocol stack thread queries its own routing table to write the message into the corresponding virtual network card, enters the sending queue and sends it out; after receiving the message, the message transceiver thread queries the mapping table from the MAC address to the protocol stack thread receiving queue, and writes the message into the corresponding receiving queue; the protocol stack thread reads the message from the receiving queue and forwards the message to the corresponding virtual network card according to the mapping table between the MAC address and the virtual network card; the protocol stack processes the poll message of the protocol simulation thread and writes the content of the received message into the socket message receiving queue of the protocol simulation thread.
[0085] See also Figure 4 , the second aspect of the present invention provides a network tester simulation protocol stack implementation system, including: a network simulation module, a virtualized network module, and a message transceiver module;
[0086] Network simulation module: obtains several simulation threads from the database, imports several simulation threads into and starts the user-mode protocol stack; processes network card queue messages on different CPU cores through configuration information; wherein the user-mode protocol stack includes: a management thread, several data sending and receiving threads, and several protocol stack threads;
[0087] Virtualized network module: creates a virtual network card in the user-mode protocol stack, builds the socket connection and mapping relationship record between the simulation thread and the protocol stack thread;
[0088] Message transceiver module: On the user-mode protocol stack, start the protocol simulation program to send or receive messages to complete the simulation protocol stack network test.
[0089] Part of the data in the above formula is calculated by removing the dimension and taking its numerical value. The formula is a formula closest to the actual situation obtained by software simulation of a large amount of collected data; the preset parameters and preset thresholds in the formula are set by technical personnel in this field according to actual conditions or obtained through simulation of a large amount of data.
[0090] The working principle of the present invention is as follows: a plurality of simulation threads are obtained from a database, and the plurality of simulation threads are imported and started into a user-mode protocol stack; network card queue messages on different CPU cores are processed through configuration information; wherein the user-mode protocol stack includes: a management thread, a plurality of data sending and receiving threads, and a plurality of protocol stack threads; a virtual network card is created in the user-mode protocol stack, and a socket connection and a mapping relationship record between the simulation thread and the protocol stack thread are constructed; on the user-mode protocol stack, a message of a protocol simulation program is started to be sent or received, and a network test of the simulation protocol stack is completed.
[0091] The above embodiments are only used to illustrate the technical method of the present invention rather than to limit it. Although the present invention has been described in detail with reference to the preferred embodiments, those skilled in the art should understand that the technical method of the present invention may be modified or replaced by equivalents without departing from the spirit and scope of the technical method of the present invention.
Claims
1. A method for implementing a network tester simulation protocol stack, characterized in that: include: S100: obtaining a number of simulation threads from a database, importing the several simulation threads into a user-mode protocol stack, and starting the user-mode protocol stack; Setting configuration information, and processing network card queue messages on several CPU cores according to the configuration information; wherein the user state protocol stack includes: a management thread and several data sending and receiving threads, and several protocol stack threads; S200: creating a virtual network card in the user-mode protocol stack, and constructing a socket connection and mapping relationship record between the simulation thread and the protocol stack thread; S300: On the user mode protocol stack, start sending or receiving messages of the protocol simulation program to complete the simulation protocol stack network test.
2. A method for implementing a network tester simulation protocol stack according to claim 1, characterized in that: The processing of network card queue messages on a plurality of CPU cores according to the configuration information includes: Set configuration information, and start data sending and receiving threads and protocol stack threads according to the configuration information; Call K protocol stack threads to run the user-mode protocol stack; pass the message data pointer between the data sending and receiving thread and the protocol stack thread through a lock-free queue; The running user-mode protocol stack is: M data receiving and sending threads running on different CPU cores process messages from network card queue 1 to network card queue M based on DPDK technology; wherein the configuration information includes: setting the number of K, setting the number of M, DPDK configuration parameters and protocol stack configuration parameters; the value range of M is 1-4, the value range of K is 2-6; and K≥M.
3. A method for implementing a network tester simulation protocol stack according to claim 1, characterized in that: The step of creating a virtual network card in a user-mode protocol stack includes: The user sends a command to create a virtual network card to the management thread through the simulation program; the management thread forwards the command to create the virtual network card to the corresponding protocol stack thread one by one based on the load sharing principle, and establishes a mapping table; wherein the mapping table includes: a mapping table of the network card MAC address and the protocol stack thread data receiving queue, and a mapping table of the IP address and the protocol stack socket command receiving queue; The protocol stack thread creates a virtual network card and a corresponding routing table, configures the MAC address and IP address, and records the mapping relationship between the MAC address and the virtual network card to the internal bridge; manages the network card information through the hash table, and creates and configures the virtual network card.
4. A method for implementing a network tester simulation protocol stack according to claim 1, characterized in that: The construction of the socket connection and mapping relationship record between the simulation thread and the protocol stack thread includes: S210: The user simulation program starts the simulation thread, and the simulation thread corresponds to the result receiving queue one by one; S220: The simulation thread sends a socket connection command to the management thread and carries its own result receiving queue information; S230: the management thread obtains the socket command queue of the protocol stack thread according to the IP address bound to the socket and the mapping table of the protocol stack socket command receiving queue, and forwards the socket command to the specified queue; S240: the protocol stack thread processes the socket command to establish an internal socket, and records the mapping between the socket ID and the result receiving queue of the simulation thread; S250: The protocol stack thread returns the socket ID and its own socket command queue information; S260: The simulation program records the mapping relationship between the socket ID and the protocol stack thread command queue.
5. A method for implementing a network tester simulation protocol stack according to claim 1, characterized in that: The message for starting the protocol simulation program is sent, comprising: S310: The protocol simulation thread sends a socket message sending instruction to the corresponding protocol stack thread; S311: The protocol stack thread calls the internal socket function to perform data sending operation; S312: The data is encapsulated into a message by the protocol stack and enters the protocol stack thread sending queue; S313: multiple data receiving and sending threads, as consumers, sequentially obtain messages from the sending queue of each protocol stack thread and write them into the network card queue.
6. A method for implementing a network tester simulation protocol stack according to claim 1, characterized in that: The message for starting the protocol simulation program is received, comprising: S320: The protocol simulation thread sends a poll command to the protocol stack thread and waits for a response; S321: The protocol stack thread adds the read and write events of the FD corresponding to the socket ID; S322: When the data receiving and sending thread receives a message, it queries the MAC mapping table according to the destination MAC address of the message to obtain the message receiving queue of the corresponding protocol stack thread, and writes the message into the message receiving queue; S323: The internal bridge of the protocol stack thread forwards the message to the corresponding virtual network card according to the destination MAC address; S324: The message is processed by the protocol stack and triggers a read event of the socket FD; S325: The protocol stack thread processes the FD read event and returns a response message to the poll command of the protocol simulation thread; S326: The protocol simulation thread sends a socket read command to read the message content.
7. A network tester simulation protocol stack implementation system, applied to a network tester simulation protocol stack implementation method according to any one of claims 1 to 6, characterized in that: include: Network simulation module, virtualized network module, message transceiver module; Network simulation module: obtains several simulation threads from the database, imports several simulation threads into the user-mode protocol stack, and starts them; Process the network card queue messages on different CPU cores through configuration information; the user-mode protocol stack includes: a management thread, several data sending and receiving threads, and several protocol stack threads; Virtualized network module: creates a virtual network card in the user-mode protocol stack, builds the socket connection and mapping relationship record between the simulation thread and the protocol stack thread; Message transceiver module: On the user-mode protocol stack, start the protocol simulation program to send or receive messages to complete the simulation protocol stack network test.
Citation Information
Cited By
Embedded platform ad hoc network equipment communication optimization method and device, equipment and medium
CN121217573A