Server network card testing method, system and device and medium
By creating network namespaces and virtual network cards in a single server, the problem of high occupancy and low flexibility of server network card bandwidth testing equipment is solved, and efficient and flexible network card bandwidth testing is achieved, which is suitable for a variety of test environments and operating systems.
Patent Information
- Application Number
- CN202510517282.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-23
- Publication Date
- 2025-07-11
AI Technical Summary
The existing server network card bandwidth test method has high equipment occupancy, low flexibility, and cumbersome and costly relying on physical connections, making it difficult to meet the diverse testing needs of complex network environments.
Create multiple network namespaces within a single server, and realize logical isolation and data forwarding by binding physical network cards and creating virtual network cards pairs. Use network traffic testing tools to perform bandwidth testing, record and analyze data packet transmission parameters.
It reduces testing costs, improves testing efficiency and flexibility, supports multiple test modes, reduces physical connection operations, is suitable for various operating systems and network card specifications, improves the accuracy and reliability of testing, and is suitable for enterprises and individuals.
Smart Images

Figure CN120301808A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of computer networks and relates to a server network card testing method, system, device and medium. Background Art
[0002] In the field of server network technology, network card bandwidth testing is a key link for evaluating network performance, optimizing network configuration, and ensuring data transmission efficiency. However, the existing server network card bandwidth testing methods have exposed many limitations in practical applications, and innovative solutions are urgently needed to improve testing efficiency and flexibility.
[0003] Limitations of traditional testing methods:
[0004] (1) High device occupancy and resource waste. Traditional server network card bandwidth testing methods usually rely on at least two servers, one as the sender and the other as the receiver, for data transmission and bandwidth testing through physical connections (such as direct network cable connection or connection through a switch). Each execution will additionally occupy the resources of one server. For data centers or large-scale testing environments, this not only increases the server usage cost but also may lead to tight resource allocation and affect the normal operation of other services.
[0005] (2) Single testing method and poor flexibility. Most existing testing methods are limited to the one-to-one direct connection testing mode and are difficult to meet the diverse testing requirements in complex network environments. See Figure 4 , which is a schematic diagram of the traditional one-to-one network card testing architecture. If one-to-many or many-to-many bandwidth testing is required, additional network topologies need to be configured, such as introducing switches or routers for traffic scheduling, which not only increases the complexity of the testing but also extends the testing cycle and reduces the testing efficiency. See Figure 5 , which is a schematic diagram of the architecture of the connection between the server and the switch in traditional testing.
[0006] (3) Dependence on physical connections and cumbersome operations. Traditional testing methods highly depend on physical connections. Before each test, re-wiring or network environment configuration is required, which not only increases the workload of manual operations but also easily leads to deviations or errors in test results due to misoperations. In addition, the stability of physical connections is easily affected by external environmental factors, further increasing the uncertainty of the testing.
[0007] (4) High testing cost and strong dependence on professional equipment. Although some high-end testing methods can provide accurate bandwidth test data, they rely on specialized network traffic testers (such as Spirent, IXIA, etc.). These devices are expensive, have a high usage threshold, and require professional personnel for operation and maintenance. For regular enterprises or laboratories, the high testing cost and the dependence on professional equipment seriously limit the satisfaction of their daily testing needs.
[0008] Currently, the bandwidth testing of server network cards mainly adopts the testing methods based on network traffic generation tools and the testing methods based on hardware testers. Although the former is widely used, it still requires two servers to be connected, making it difficult to solve the problem of device occupation; although the latter can provide accurate data, it is costly and not suitable for general users.
[0009] (1) The testing method based on network traffic generation tools. This method uses network traffic testing tools such as iperf and netperf to perform TCP or UDP traffic transmission between two servers to measure bandwidth and network performance. However, two servers still need to be directly connected by ports or connected through a switch, and the problem of device occupation cannot be fundamentally solved.
[0010] (2) The testing method based on hardware testers. This method uses special network testers to simulate various network environments and provide accurate bandwidth test data. But as mentioned above, such devices are costly and require professional operation, and are not suitable for general enterprises or laboratories. Summary of the Invention
[0011] The purpose of the present invention is to solve the problems of high device occupation and low testing flexibility in the existing technology during the network card bandwidth testing, and to provide a server network card testing method, system, device and medium.
[0012] To achieve the above purpose, the present invention adopts the following technical solutions:
[0013] A server network card testing method includes the following steps:
[0014] Create namespaces, create multiple network namespaces inside the server, and each namespace is regarded as an independent network environment;
[0015] Bind physical network cards, map the physical network cards of the server to different network namespaces respectively to make them logically isolated from each other;
[0016] Create virtual network card pairs, create one or more pairs of veth virtual network cards between different network namespaces for data traffic transmission, and perform traffic forwarding through bridging or routing;
[0017] Configure network parameters, configure IP addresses respectively within each network namespace, and establish routing rules to enable data traffic to be transmitted between different namespaces;
[0018] Execute bandwidth testing, send large traffic data packets between different network namespaces through a network traffic testing tool, measure the throughput rate of data transmission, and calculate the actual bandwidth performance of the network card;
[0019] Record and analyze data, record the transmission rate, packet loss rate, and latency parameters of data packets during the test, and analyze the performance bottleneck of the physical network card;
[0020] Output a test report: Output a bandwidth test report based on the recorded and analyzed data.
[0021] Create multiple network namespaces inside the server, specifically:
[0022] Use the ip command to create a network namespace, and the basic command format is ip netns add <namespace name>;
[0023] Execute the ip netns add <namespace name> command in sequence to create multiple independent network namespaces in the kernel;
[0024] View the created namespaces, execute the ip netns list command to view all the network namespaces that have been created in the current system. After creating the network namespaces, executing this command will output the list information of the network namespaces.
[0025] Bind the physical network card, map the physical network cards of the server to different network namespaces respectively to make them logically isolated from each other, specifically:
[0026] Execute the mapping command, use the ip link set <network card name> netns <namespace name> command to map the physical network card to the specified network namespace;
[0027] Verify the network card mapping result, execute the ip addr command in the default namespace. If the network card no longer appears, it indicates that it has been successfully moved from the default namespace to their respective target namespaces;
[0028] Use the ip netns exec <namespace name> <command> method to enter the target namespace and view the network card information.
[0029] Create virtual network card pairs, create one or more pairs of veth virtual network cards between different network namespaces, specifically including:
[0030] Create a veth pair: Use the ip command to create a veth pair, and the basic command format is ip link add <veth0 name> type veth peer name <veth1 name>;
[0031] Move the veth network card to the namespace, use the ip link set <network card name> netns <namespace name> command to move the veth network card to the specified namespace.
[0032] Configure network parameters, configure IP addresses respectively within each network namespace, and establish routing rules to enable data traffic to be transmitted between different namespaces. Specifically:
[0033] Configure Internet Protocol addresses for virtual network cards in the network namespace:
[0034] Enter the network namespace and use relevant commands to assign Internet Protocol addresses to virtual network cards;
[0035] Use commands to set the virtual network card to the enabled state. Among them, the command for assigning Internet Protocol addresses is used to specify an address for the network device, and the command for enabling the network device is used to make the network device in a working state;
[0036] Add routing rules in the network namespace:
[0037] Enable data in the network namespace to be transmitted to other network namespaces. Add routing rules pointing to the network where the target network namespace is located in the network namespace and execute commands.
[0038] Perform the bandwidth test. Through a network traffic test tool, send large - volume data packets between different network namespaces, measure the throughput rate of data transmission, and calculate the actual bandwidth performance of the network card. Specifically:
[0039] Start the server of the bandwidth test tool in the network namespace:
[0040] Enter the network namespace and start the server of the bandwidth test tool. This server is used to wait for connection requests from the client and get ready to receive data;
[0041] Start the client of the bandwidth test tool in another network namespace
[0042] Enter another network namespace and start the client of the bandwidth test tool. Among them, the specified parameter is used to clarify that the Internet Protocol address of the server is the Internet Protocol address of the virtual network card in the network namespace. The client sends a large number of data packets to the server to test the network bandwidth;
[0043] After the command is executed on the client, the bandwidth test tool conducts the test and displays the test results on the client and the server respectively;
[0044] Calculate the actual bandwidth performance of the network card. Based on the bandwidth data displayed by the bandwidth test tool, master the data transmission performance between different network namespaces, and improve the accuracy of the test results by conducting multiple tests and calculating the average value.
[0045] Record and analyze data, record the transmission rate, packet loss rate, and latency parameters of data packets during the test, and analyze the performance bottleneck of the physical network card; specifically:
[0046] Data collation, use network performance testing tools to conduct multiple network performance tests, and record the transmission rate, packet loss rate, and latency parameters obtained from each test;
[0047] Data analysis, transmission rate analysis, calculate the average value of the transmission rates of multiple tests, and evaluate the overall bandwidth performance of the network based on this average value; packet loss rate analysis, calculate the average value of the packet loss rates of multiple tests, and judge the stability of the network according to this average value; latency analysis, calculate the average value of the latencies of multiple tests, and evaluate the real-time performance of the network based on this average value;
[0048] Performance bottleneck analysis, obtain the theoretical bandwidth and maximum transmission rate parameters of the physical network card; compare the actual transmission rate obtained from the test with the theoretical bandwidth. If the actual transmission rate is much lower than the theoretical bandwidth, it is determined that there may be a performance bottleneck in the physical network card.
[0049] A server network card testing system, including:
[0050] Namespace creation module, used to create multiple network namespaces inside the server. Each network namespace is regarded as an independent network environment, providing a logical partition for network card isolation and testing;
[0051] Physical network card binding module, used to map the physical network cards of the server to different network namespaces respectively, so that each physical network card is logically isolated from each other;
[0052] Virtual network card creation module, used to create one or more pairs of veth virtual network cards between different network namespaces for data traffic transmission, and perform traffic forwarding through bridging or routing methods to achieve communication between different namespaces;
[0053] Network parameter configuration module, used to configure IP addresses respectively within each network namespace and establish routing rules to ensure that data traffic can be transmitted smoothly between different namespaces, providing a network foundation for bandwidth testing;
[0054] Bandwidth test execution module, used to send large traffic data packets between different network namespaces through network traffic testing tools, measure the throughput rate of data transmission, and thus calculate the actual bandwidth performance of the network card to achieve a quantitative evaluation of the network card bandwidth;
[0055] Data recording and analysis module, used to record the transmission rate, packet loss rate, and latency parameters of data packets during the test, and analyze the performance bottleneck of the physical network card, providing a basis for network card performance optimization;
[0056] A test report output module for outputting a bandwidth test report according to the recorded and analyzed data.
[0057] A device includes a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the steps of the method described in any one of the previous items are implemented.
[0058] A computer-readable storage medium stores a computer program. When the computer program is executed by a processor, the steps of the method described in any one of the previous items are implemented.
[0059] Compared with the prior art, the present invention has the following beneficial effects:
[0060] In the server network card testing method of the present invention, by isolating the network card using network namespaces inside a single server and using virtual network cards to achieve data forwarding to complete the network card bandwidth test, no additional server is required, thus significantly reducing the test cost. At the same time, it avoids the cumbersome process of complex configuration and connection of multiple servers in the traditional method, improving the test efficiency; this method uses network namespaces to map physical network cards to different logically isolated environments, enabling each namespace to independently configure network parameters and conduct bandwidth tests, increasing the flexibility and accuracy of the test. And by recording and analyzing key indicators such as the transmission rate, packet loss rate, and delay parameters of data packets during the test process, it can comprehensively evaluate the performance bottleneck of the physical network card, providing a strong basis for network card performance optimization; in addition, the present invention supports multiple test modes and integration of automation tools, is applicable to multiple industries such as server manufacturing, data center operation and maintenance, and network optimization, has broad application prospects and market demand, and also realizes low-cost and high-efficiency testing of server network cards through innovative technical means, has significant technical advantages and patent protection value, and helps to enhance the competitiveness of enterprises in related fields. BRIEF DESCRIPTION OF THE DRAWINGS
[0061] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the following will briefly introduce the drawings required to be used in the embodiments. It should be understood that the following drawings only show some embodiments of the present invention, and thus should not be regarded as limiting the scope. For those of ordinary skill in the art, other related drawings can be obtained based on these drawings without creative efforts.
[0062] Figure 1 It is a flow chart of the server network card testing method of the present invention;
[0063] Figure 2 It is a topological diagram of the technical architecture of the present invention;
[0064] Figure 3Schematic diagram of the technical architecture of the present invention;
[0065] Figure 4 Schematic wiring diagram of a common server test network card in the prior art;
[0066] Figure 5 Method for connecting a common server test network card to a switch in the prior art. Specific implementation manners
[0067] To make the objectives, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention. Apparently, the described embodiments are some but not all of the embodiments of the present invention. Usually, the components of the embodiments of the present invention described and illustrated herein can be arranged and designed in various different configurations.
[0068] Therefore, the following detailed description of the embodiments of the present invention provided in the drawings is not intended to limit the scope of the claimed present invention, but merely represents selected embodiments of the present invention. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present invention without creative efforts fall within the scope of protection of the present invention.
[0069] It should be noted that like reference numerals and letters denote like items in the following drawings. Therefore, once an item is defined in one drawing, it does not need to be further defined and explained in subsequent drawings.
[0070] The present invention will be further described in detail below with reference to the accompanying drawings:
[0071] See Figure 1 , which is a flowchart of the server network card test method of the present invention, including the following steps:
[0072] Create a namespace. Create multiple network namespaces inside the server, and each namespace is regarded as an independent network environment. Specifically:
[0073] Use the ip command to create a network namespace. The basic command format is ip netns add <namespace name>;
[0074] Execute the ip netns add <namespace name> command in sequence to create multiple independent network namespaces in the kernel;
[0075] View the created namespaces. Execute the ip netns list command to view all the network namespaces that have been created in the current system. After creating the network namespaces, executing this command will output the list information of the network namespaces.
[0076] Bind physical network cards, map the physical network cards of the server to different network namespaces respectively, so that they are logically isolated from each other.
[0077] Specifically:
[0078] Execute the mapping command, and use the command "ip link set <network card name> netns <namespace name>" to map the physical network card to the specified network namespace;
[0079] Verify the network card mapping result. Execute the "ip addr" command in the default namespace. If the network card no longer appears, it indicates that it has been successfully moved from the default namespace to their respective target namespaces;
[0080] Enter the target namespace in the way of "ip netns exec <namespace name> <command>" and view the network card information.
[0081] Create virtual network card pairs, create one or more pairs of veth virtual network cards between different network namespaces for data traffic transmission, and perform traffic forwarding through bridging or routing methods.
[0082] Specifically include:
[0083] Create veth pairs: Use the ip command to create veth pairs. The basic command format is "ip link add <veth0 name> type veth peer name <veth1 name>";
[0084] Move the veth network card to the namespace, and use the command "ip link set <network card name> netns <namespace name>" to move the veth network card to the specified namespace.
[0085] Configure network parameters, configure IP addresses respectively within each network namespace, and establish routing rules so that data traffic can be transmitted between different namespaces.
[0086] Specifically:
[0087] Configure Internet protocol addresses for virtual network cards in the network namespace:
[0088] Enter the network namespace and use relevant commands to assign Internet protocol addresses to virtual network cards;
[0089] Use the command to set the virtual network card to the enabled state. Among them, the command for assigning Internet protocol addresses is used to specify an address for a network device, and the command for enabling a network device is used to make the network device in a working state;
[0090] Add routing rules in the network namespace:
[0091] Enable the data in the network namespace to be transmitted to other network namespaces, add a routing rule in the network namespace pointing to the network where the target network namespace is located, and execute the command.
[0092] Perform a bandwidth test. Through a network traffic test tool, send large traffic data packets between different network namespaces, measure the throughput rate of data transmission, and calculate the actual bandwidth performance of the network card.
[0093] Specifically:
[0094] Start the server of the bandwidth test tool in the network namespace:
[0095] Enter the network namespace and start the server of the bandwidth test tool. This server is used to wait for connection requests from the client and get ready to receive data;
[0096] Start the client of the bandwidth test tool in another network namespace
[0097] Enter another network namespace and start the client of the bandwidth test tool. The specified parameters are used to clarify that the Internet protocol address of the server is the Internet protocol address of the virtual network card in the network namespace. The client sends a large number of data packets to the server to test the network bandwidth;
[0098] After the command is executed on the client, the bandwidth test tool conducts the test and displays the test results on the client and the server respectively;
[0099] Calculate the actual bandwidth performance of the network card. Based on the bandwidth data displayed by the bandwidth test tool, master the data transmission performance between different network namespaces, and improve the accuracy of the test results by conducting multiple tests and calculating the average value.
[0100] Record and analyze data. Record the transmission rate, packet loss rate, and delay parameters of data packets during the test process, and analyze the performance bottleneck of the physical network card.
[0101] Specifically:
[0102] Data collation. Use a network performance test tool to conduct multiple network performance tests, and record the transmission rate, packet loss rate, and delay parameters obtained from each test;
[0103] Data analysis. Transmission rate analysis, calculate the average value of the transmission rates of multiple tests, and evaluate the overall bandwidth performance of the network based on this average value; Packet loss rate analysis, calculate the average value of the packet loss rates of multiple tests, and judge the stability of the network according to this average value; Delay analysis, calculate the average value of the delays of multiple tests, and evaluate the real-time performance of the network based on this average value;
[0104] Performance bottleneck analysis, obtaining the theoretical bandwidth and maximum transmission rate parameters of the physical network card; comparing the actual transmission rate obtained from the test with the theoretical bandwidth. If the actual transmission rate is much lower than the theoretical bandwidth, it is determined that there may be a performance bottleneck in the physical network card.
[0105] Output test report: Output a bandwidth test report based on the recorded and analyzed data.
[0106] An embodiment of the present invention is a server network card test system, including the following modules:
[0107] Namespace creation module, used to create multiple network namespaces inside the server. Each network namespace is regarded as an independent network environment, providing a logical partition for network card isolation and testing.
[0108] Physical network card binding module, used to map the physical network cards of the server to different network namespaces respectively, making each physical network card logically isolated from each other.
[0109] Virtual network card creation module, used to create one or more pairs of veth virtual network cards between different network namespaces for data traffic transmission, and perform traffic forwarding through bridging or routing methods to achieve communication between different namespaces.
[0110] Network parameter configuration module, used to configure IP addresses respectively within each network namespace and establish routing rules to ensure that data traffic can be smoothly transmitted between different namespaces, providing a network foundation for bandwidth testing.
[0111] Bandwidth test execution module, used to send large - volume data packets between different network namespaces through a network traffic test tool, measure the throughput rate of data transmission, thereby calculating the actual bandwidth performance of the network card and realizing a quantitative evaluation of the network card bandwidth.
[0112] Data recording and analysis module, used to record the transmission rate, packet loss rate, and delay parameters of data packets during the test process, and analyze the performance bottleneck of the physical network card, providing a basis for network card performance optimization.
[0113] Test report output module, used to output a bandwidth test report based on the recorded and analyzed data.
[0114] The present invention proposes a method for testing the network card bandwidth based on a single server, using the network namespace (namespace) technology to implement the bandwidth test between multiple network cards within the same server. Compared with the existing methods that rely on two servers or expensive test equipment, the present invention has the following significant advantages:
[0115] 1. Reduced device occupancy, saving server resources
[0116] Traditional server network card bandwidth testing methods require at least two servers to be used as the data sender and receiver respectively for direct port connection testing, while the present invention can complete the testing with only a single server. This can avoid occupying additional server resources, especially in environments such as data centers and laboratories, reduce the server usage cost, and improve the utilization rate of equipment. For scenarios that require large-scale testing, the present invention can reduce equipment requirements and improve testing efficiency.
[0117] 2. Flexibly support multiple testing modes
[0118] Most traditional methods only support one-to-one network card bandwidth testing, while the present invention can support, by adjusting the network namespace:
[0119] One-to-one testing (single network card against single network card)
[0120] One-to-many testing (one network card tests bandwidth with multiple network cards simultaneously)
[0121] Many-to-many testing (bandwidth testing among multiple network cards)
[0122] Ring testing (multiple network cards form a ring connection to simulate a complex network environment)
[0123] These modes can better simulate the actual business environment and meet different testing requirements.
[0124] 3. Simplify physical connection and make operation more convenient
[0125] Traditional methods require manual adjustment of physical network connections, that is, inserting network cables into different network ports for testing. When testing different topological structures, re-wiring is necessary, resulting in cumbersome operation and easy errors. The present invention completes network connection through software, uses network namespaces (namespace) to isolate different network ports, and controls traffic forwarding at the software level, eliminating the need to repeatedly plug and unplug network cables, greatly simplifying the testing process. It is suitable for remote testing and automated testing, reducing human operation intervention and improving the repeatability and stability of testing.
[0126] 4. Reduce testing costs and reduce dependence on expensive testing equipment
[0127] Currently, many enterprises or laboratories rely on expensive professional testing equipment (such as Spirent, IXIA) for network card bandwidth testing. These devices are expensive, complex to use, and require professional technical personnel to operate. The present invention can complete accurate network card bandwidth testing by simply installing software on a single server, avoiding the procurement and maintenance costs of expensive equipment, making the testing more economical and efficient. It is suitable for scenarios such as server factory inspection, operation and maintenance fault troubleshooting, and network device performance testing, with stronger adaptability and higher economy.
[0128] 5. Strong compatibility and wide applicability
[0129] This method can be applied to various server operating systems (such as Linux, Windows Server), support network cards of different specifications such as Gigabit, 10 Gigabit, 25G, 40G, 100G, etc., and has good compatibility.
[0130] 6. High-precision testing and more reliable results
[0131] By directly testing the bandwidth between multiple network cards on the same server, the present invention can minimize external network interference to the greatest extent, ensure the controllability of the test environment, and improve the accuracy of the test. Due to the adoption of independent network namespaces, it can simulate a cross-server environment, guarantee the authenticity of the test results, and avoid the influence of external devices (such as switches, routers) on the accuracy of the test results.
[0132] 7. Support for automated testing and improved efficiency
[0133] Most traditional methods rely on manual operations and require manual intervention during repetitive testing. However, the present invention can batch run multiple network card bandwidth tests through scripts or automated tools, reduce manual intervention, and improve test efficiency. It can be combined with existing DevOps and CI / CD processes to achieve automated deployment of network card testing and is applicable to large-scale server environments.
[0134] 8. Easy to integrate and suitable for enterprises and individuals
[0135] Due to the adoption of a software-level solution, the present invention can be easily integrated into existing server management systems or test platforms without changing the server hardware architecture or adding additional devices. It is applicable to different user groups such as server manufacturers, data center operation and maintenance teams, and research institutions, reducing the technical threshold and enhancing the popularity of testing.
[0136] The present invention provides a method for testing the bandwidth of network cards based on a single server. By modifying the network namespace, direct communication between multiple network cards on the same server can be achieved to perform bandwidth testing without the need for additional test servers or expensive test equipment. This method can support different test modes such as one-to-one, one-to-many, and many-to-many, greatly improving the flexibility and efficiency of testing.
[0137] The core technology of the present invention is to logically separate multiple network cards through the network namespace technology and control the forwarding of data streams through software to perform bandwidth testing. Specifically, the present invention mainly includes the following steps:
[0138] Create multiple network namespaces
[0139] Create multiple network namespaces (abbreviated as ns) inside the server. Each namespace can be regarded as an independent network environment. For example, assume the server has two network cards eth0 and eth1, then two new namespaces ns1 and ns2 can be created and bound to eth0 and eth1 respectively.
[0140] Map physical network cards to different network namespaces
[0141] Use the ip link set netns command to map the network cards to different network namespaces respectively, making them logically isolated from each other. For example, move eth0 to ns1 and move eth1 to ns2, so that eth0 and eth1 cannot communicate directly in the default network space.
[0142] Set up veth (virtual network card) for data forwarding
[0143] Create a pair of veth virtual network cards (veth pair) between ns1 and ns2 for data traffic transmission. For example, create veth0 and veth1, where veth0 is bound to ns1 and veth1 is bound to ns2, and perform traffic forwarding through bridging or routing.
[0144] Configure IP addresses and routing rules
[0145] Configure IP addresses inside ns1 and ns2 respectively, and establish appropriate routing rules so that data traffic can be sent from ns1 (eth0) to ns2 (eth1), thus completing data transmission between network cards. For example, iptables or tc (Traffic Control) can be used for traffic control to ensure that data is transmitted along the predetermined path.
[0146] Conduct bandwidth testing
[0147] Use network traffic testing tools such as iperf and netperf to send large - volume data packets between ns1 and ns2, measure the throughput rate of data transmission, and calculate the actual bandwidth performance of the network cards.
[0148] Analyze the test results
[0149] Record parameters such as the transmission rate, packet loss rate, and latency of data packets, and analyze the performance bottleneck of the network cards. Data packet capture can be combined with traffic monitoring tools (such as Wireshark and tcpdump) to ensure the accuracy and reliability of test data.
[0150] Test process
[0151] 1. Create namespaces ns1 and ns2
[0152] ├──>2. Bind physical network cards eth0 to ns1 and eth1 to ns2
[0153] ├──>3. Create veth0 (connected to ns1) and veth1 (connected to ns2)
[0154] ├──>4. Configure IP addresses and routing rules
[0155] ├──>5. Run iperf for bandwidth testing
[0156] ├──>6. Record test data and analyze results
[0157] └──>7. Output bandwidth test report
[0158] An embodiment of the present invention provides a terminal device. The terminal device of this embodiment includes: a processor, a memory, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the steps in the above-mentioned various method embodiments are implemented. Alternatively, when the processor executes the computer program, the functions of each module / unit in the above-mentioned various device embodiments are implemented.
[0159] The computer program can be divided into one or more modules / units, and the one or more modules / units are stored in the memory and executed by the processor to complete the present invention.
[0160] The device / terminal device can be a computing device such as a desktop computer, a notebook, a palm computer, and a cloud server. The device / terminal device may include, but is not limited to, a processor and a memory.
[0161] The processor may be a Central Processing Unit (CPU), or may also be other general-purpose processors, Digital Signal Processors (DSPs), Application Specific Integrated Circuits (ASICs), Field-Programmable Gate Arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc.
[0162] The memory can be used to store the computer program and / or module. By running or executing the computer program and / or module stored in the memory, and invoking the data stored in the memory, the processor implements various functions of the device / terminal device.
[0163] If the module / unit integrated in the device / terminal device is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on such an understanding, to implement all or part of the processes in the above-described embodiment methods of the present invention, it can also be completed by instructing relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium. When the computer program is executed by the processor, the steps of the above various method embodiments can be implemented. Among them, the computer program includes computer program code, and the computer program code can be in the form of source code, object code, executable file, or some intermediate form, etc. The computer-readable medium can include: any entity or device capable of carrying the computer program code, recording medium, USB flash drive, mobile hard disk, magnetic disk, optical disc, computer memory, read-only memory (ROM), random access memory (RAM), electrical carrier signal, telecommunication signal, and software distribution medium, etc. It should be noted that the content included in the computer-readable medium can be appropriately increased or decreased according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, the computer-readable medium does not include electrical carrier signals and telecommunication signals.
[0164] The above are only the preferred embodiments of the present invention and are not used to limit the present invention. For those skilled in the art, the present invention can have various changes and modifications. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included within the protection scope of the present invention.
Claims
1. A method for testing a server network card, characterized in that, It includes the following steps: Create namespaces, create multiple network namespaces inside the server, and each namespace is regarded as an independent network environment; Bind physical network cards, map the physical network cards of the server to different network namespaces respectively, so that they are logically isolated from each other; Create virtual network card pairs, create one or more pairs of veth virtual network cards between different network namespaces for data traffic transmission, and perform traffic forwarding through bridging or routing methods; Configure network parameters, configure IP addresses respectively within each network namespace, and establish routing rules so that data traffic can be transmitted between different namespaces; Execute bandwidth testing, send large - volume data packets between different network namespaces through a network traffic testing tool, measure the throughput rate of data transmission, and calculate the actual bandwidth performance of the network card; Record and analyze data, record the transmission rate, packet loss rate, and delay parameters of data packets during the test process, and analyze the performance bottleneck of the physical network card; Output a test report: Output a bandwidth test report according to the recorded and analyzed data.
2. The server network card testing method according to claim 1, characterized in that The specific method of creating multiple network namespaces inside the server is as follows: Use the ip command to create a network namespace, and the basic command format is ip netns add <namespace name>; Execute the ip netns add <namespace name> command in sequence to create multiple independent network namespaces in the kernel; View the created namespaces, execute the ip netns list command to view all the network namespaces that have been created in the current system. After creating the network namespaces, executing this command will output the list information of the network namespaces.
3. The server network card testing method according to claim 1, wherein The specific method of binding physical network cards, mapping the physical network cards of the server to different network namespaces so that they are logically isolated from each other is as follows: Execute the mapping command, use the ip link set <network card name> netns <namespace name> command to map the physical network card to the specified network namespace; Verify the network card mapping result, execute the ip addr command in the default namespace. If the network card no longer appears, it indicates that it has been successfully moved from the default namespace to their respective target namespaces; Use the ip netns exec <namespace name> <command> method to enter the target namespace and view the network card information.
4. The server network card testing method according to claim 1, characterized in that, The specific method of creating virtual network card pairs, creating one or more pairs of veth virtual network cards between different network namespaces includes: Create a veth pair: Use the ip command to create a veth pair, and the basic command format is ip link add <veth0 name> type veth peer name <veth1 name>; Move the veth network card to the namespace, use the ip link set <network card name> netns <namespace name> command to move the veth network card to the specified namespace.
5. The server network card testing method according to claim 1, wherein The specific method of configuring network parameters, configuring IP addresses respectively within each network namespace, and establishing routing rules so that data traffic can be transmitted between different namespaces is as follows: Configure the Internet Protocol address for the virtual network card in the network namespace: Enter the network namespace and use relevant commands to assign an Internet Protocol address to the virtual network card; Use the command to set the virtual network card to the enabled state. Among them, the command for assigning the Internet Protocol address is used to specify an address for the network device, and the command for enabling the network device is used to make the network device in the working state; Add routing rules in the network namespace: Enable the data in the network namespace to be transmitted to other network namespaces. Add routing rules pointing to the network where the target network namespace is located in the network namespace and execute the command.
6. The server network card testing method according to claim 1, wherein The execution of the bandwidth test is to send a large amount of data packets between different network namespaces through a network traffic test tool, measure the throughput rate of data transmission, and calculate the actual bandwidth performance of the network card. Specifically: Start the server of the bandwidth test tool in the network namespace: Enter the network namespace and start the server of the bandwidth test tool. This server is used to wait for connection requests from the client and prepare to receive data; Start the client of the bandwidth test tool in another network namespace Enter another network namespace and start the client of the bandwidth test tool. The specified parameter is used to clarify that the Internet Protocol address of the server is the Internet Protocol address of the virtual network card in the network namespace. The client sends a large number of data packets to the server to test the network bandwidth; After the command is executed on the client, the bandwidth test tool performs the test and displays the test results on the client and the server respectively; Calculate the actual bandwidth performance of the network card. Based on the bandwidth data displayed by the bandwidth test tool, master the data transmission performance between different network namespaces, and improve the accuracy of the test results by performing multiple tests and calculating the average value.
7. The server network card testing method according to claim 1, characterized in that The recording and analysis of data record the transmission rate, packet loss rate, and delay parameters of the data packets during the test process, and analyze the performance bottleneck of the physical network card; specifically: Data sorting, use a network performance test tool to perform multiple network performance tests, and record the transmission rate, packet loss rate, and delay parameters obtained from each test; Data analysis, transmission rate analysis, calculate the average value of the transmission rates of multiple tests, and evaluate the overall bandwidth performance of the network based on this average value; packet loss rate analysis, calculate the average value of the packet loss rates of multiple tests, and judge the stability of the network based on this average value; delay analysis, calculate the average value of the delays of multiple tests, and evaluate the real-time performance of the network based on this average value; Performance bottleneck analysis, obtain the theoretical bandwidth and maximum transmission rate parameters of the physical network card; Compare the actual transmission rate obtained from the test with the theoretical bandwidth. If the actual transmission rate is much lower than the theoretical bandwidth, it is determined that there may be a performance bottleneck in the physical network card.
8. A server network card testing system, characterized in that, Including: A namespace creation module for creating multiple network namespaces inside the server. Each network namespace is regarded as an independent network environment, providing a logical partition for network card isolation and testing; A physical network card binding module for mapping the physical network cards of the server to different network namespaces respectively, so that each physical network card is logically isolated from each other; A virtual network card creation module, which is used to create one or more pairs of veth virtual network cards between different network namespaces for data traffic transmission, and perform traffic forwarding through bridging or routing methods to achieve communication between different namespaces; A network parameter configuration module, which is used to configure IP addresses respectively within each network namespace and establish routing rules to ensure that data traffic can be smoothly transmitted between different namespaces, providing a network foundation for bandwidth testing; A bandwidth test execution module, which is used to send large traffic data packets between different network namespaces through a network traffic test tool, measure the throughput rate of data transmission, and thus calculate the actual bandwidth performance of the network card to achieve a quantitative evaluation of the network card bandwidth; A data recording and analysis module, which is used to record the transmission rate, packet loss rate, and delay parameters of data packets during the test process, and analyze the performance bottleneck of the physical network card to provide a basis for network card performance optimization; A test report output module, which is used to output a bandwidth test report based on the recorded and analyzed data.
9. An apparatus, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the steps of the method described in any one of claims 1-7.
10. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by the processor, it implements the steps of the method described in any one of claims 1-7.
Citation Information
Cited By
Server network card performance test method, server, storage medium and program product
CN120567732A
Server network card performance test method, server, storage medium and program product
CN120567732B
Server network card remote test method and device, terminal and storage medium
CN120896878A
Method and system for testing optical module by using server
CN121690361A