Weak network simulation method and system based on Linux containerization

Through a Linux containerization method, combined with the traffic control tool TC and the network dynamic bandwidth simulation tool Mahimahi, the virtual network container is automatically configured, which solves the efficient simulation problem of multi-dimensional dynamic network loss scenarios and improves simulation efficiency and environmental stability.

CN120281646APending Publication Date: 2025-07-0810TH RES INST OF CETC
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510446909.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-04-10
Publication Date
2025-07-08

Smart Images

  • Figure CN120281646A_ABST
    Figure CN120281646A_ABST
Patent Text Reader

Abstract

The invention discloses a weak network simulation method and system based on Linux containerization, and relates to the field of network communication, and the method comprises the steps: S1, environment configuration: configuring a Linux kernel environment required by weak network simulation and resources required by host simulation; s2, creating a container: creating a virtual network container in a host machine, generating a dynamic bandwidth weak network, and configuring weak network environment parameters in the virtual network container; s3, scene testing: performing weak network connectivity inspection and weak network performance inspection; and S4, weak network simulation: performing weak network simulation by using the checked virtual network container. According to the invention, a stable multi-dimensional dynamic weak network scene can be constructed conveniently and quickly.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of network transmission, and particularly to a weak network simulation method and system based on Linux containerization. Background Art

[0002] Weak network simulation is an important link in the research and development process of data transmission algorithms and transmission strategies. R & D personnel observe and analyze the real-time operation of strategies and algorithms during data transmission by configuring different weak network scenarios, so as to discover the defects existing in the transmission design and optimize the defects.

[0003] In the process of constructing a weak network scenario, R & D personnel usually need to perform a large number of manual operations to execute configuration commands. For a large number of weak network scenario tests, especially for complex dynamic network loss scenarios, the time cost spent on weak network scenario design and configuration is extremely high, affecting the R & D efficiency.

[0004] In the Linux kernel version 2.6 and above, it provides a network simulation function module Netem (Network Emulator), which can be used to simulate complex Internet transmission performance in a local area network environment with good performance. For example: low bandwidth, transmission delay, packet loss, etc. TC is a user tool in the Linux system, full name Traffic Control. TC can be used to control the working mode of the Netem module. The functions that TC can achieve include: simulating delayed transmission, simulating packet loss rate, simulating packet duplication, simulating packet corruption, simulating packet out-of-order, etc. In a dynamic network loss scenario, to improve the execution accuracy, it is necessary to directly call the C interface or implement it through programming, which greatly increases the usage threshold and reduces the usability.

[0005] Mahimahi was developed by Netravali of MIT and proposed at the USENIX conference. The Mahimahi simulator was first used for the recording and replay of HTTP traffic and is currently commonly used for network transmission simulation. Mahimahi is an end-to-end transmission simulator at the packet level, which can simulate the cache change situation of the intermediate bottleneck link, so as to reflect the changes in bandwidth and round-trip delay (RTT). The biggest feature of Mahimahi is that the framework is relatively lightweight, bringing better performance. The design goal of the simulator is not to simulate complex network devices, limited to end-to-end scenarios, does not support dynamic delay and packet loss simulation scenarios, and the simulation process is relatively coarse-grained.

[0006] Specialized network loss meters are powerful, but usually expensive, with a price range from hundreds of thousands to hundreds of thousands. The operation interfaces and functions of devices from different manufacturers vary greatly, the interface is less friendly, there is also a high learning cost, the configuration process is complex and time-consuming, and the cost performance is not high if not pursuing particularly high-precision network loss simulation accuracy. Summary of the Invention

[0007] In view of the above deficiencies in the prior art, the present invention provides a weak network simulation method and system based on Linux containerization, which solves the problems of complex and inefficient design and construction in multi-dimensional dynamic network loss simulation scenarios.

[0008] To achieve the above invention purpose, on the one hand, the technical solution adopted by the present invention is: a weak network simulation method based on Linux containerization, characterized by including:

[0009] S1. Configure the environment: Configure the Linux kernel environment required for weak network simulation and the resources required for host simulation;

[0010] S2. Create a container: Create a virtual network container on the host, generate a dynamic bandwidth weak network, and configure weak network environment parameters in the virtual network container;

[0011] S3. Scene test: Conduct weak network connectivity check and weak network performance check;

[0012] S4. Weak network simulation: Use the virtual network container that has passed the inspection to conduct weak network simulation.

[0013] The beneficial effects of the above further solution are as follows: The traffic control tool is used to simulate delayed transmission, simulate packet loss rate, simulate packet duplication, simulate packet corruption, simulate packet out-of-order, etc.; in the dynamic network loss scenario, to improve the execution accuracy, it is necessary to directly call the C interface or implement it through programming, which greatly increases the usage threshold and reduces the usability; the Python Popen component is used to uniformly set the configuration parameters for weak network transmission. The Python Popen component is used to simultaneously hold two different shell terminals, the container space and the host space. The execution of the command is read by the Popen tool and executed in different target environments, realizing the simulation of the manual simulation environment configuration through a one-key startup script, greatly improving the automation degree of the simulation process and the simulation efficiency.

[0014] Furthermore: In S1, the resources required for host simulation include a traffic control tool, a network dynamic bandwidth simulation tool, a Python Popen component, and a virtual router.

[0015] Furthermore: The weak network environment parameters include bandwidth parameters, delay parameters, and packet loss rate parameters.

[0016] Furthermore: S2 includes:

[0017] S201. Input parameter commands through the traffic control tool;

[0018] S202. Read the file path of the network dynamic bandwidth simulation tool;

[0019] S203. Execute the command of the network dynamic bandwidth simulation tool through the Python Popen component, and allocate a temporary shell space as a virtual network container;

[0020] S204. In the virtual network container, execute the parameter command through the Python Popen component to set the weak network environment parameters.

[0021] Furthermore: When creating a container, 1 or more than 1 container can be instantiated.

[0022] The beneficial effect of the above further solution is: By instantiating multiple containers simultaneously, containerization can effectively isolate the simulation, improve the network loss simulation efficiency, reduce a large number of manual configuration operations, and enhance the automation level of the method.

[0023] Furthermore: S3 includes:

[0024] S301. Input the link tracing path through the traffic control tool;

[0025] S302. Instantiate a container by reading the tracing file according to the link tracing path through the network dynamic bandwidth simulation tool;

[0026] S303. Set the traffic control command within the virtual network container space and configure the virtual network card parameters;

[0027] S304. Send a data stream from the virtual network container to the host, and perform weak network connectivity check and weak network performance check according to the transmission situation of the data stream.

[0028] On the other hand, the present invention also adopts a technical solution: A weak network simulation system based on Linux containerization, the weak network simulation system is implemented based on a host, and the host includes:

[0029] A container creation module, used to create a virtual network container according to the environment and simulation resources;

[0030] A data receiving module, used to receive the data stream sent by the virtual network container;

[0031] A performance check module, used to perform weak network connectivity check and weak network performance check according to the transmission situation of the data stream received by the data receiving module.

[0032] Furthermore: The virtual network container created by the container creation module includes a virtual network card, a data sending device, and a traffic control tool;

[0033] The virtual network card is used to simulate a multi-dimensional dynamic weak network environment according to the network loss rule;

[0034] The data sending device is used to send data streams to the host through a virtual network card;

[0035] The traffic control tool is used to add or modify the network loss rules of the virtual network card.

[0036] The beneficial effects of the present invention are as follows:

[0037] 1. By combining the use of the network dynamic bandwidth simulation tool and the traffic control tool, the problem of constructing a multi-dimensional dynamic weak network based entirely on configuration files, being convenient and stable, is solved;

[0038] 2. By enabling the traffic control tool in the container virtual network card, the simulation data is isolated from the outside, other data packet interferences are excluded, the stability problem of the simulation environment is solved, and the data repeatability is greatly improved;

[0039] 3. By using the Python Popenzu component to hold the container shell space and the shell space of the outer host at the same time, the simulation of the manual simulation environment configuration is realized through a one-key startup script, the automation degree of the simulation process is greatly improved, and the simulation efficiency is improved;

[0040] 4. By containerizing the network loss simulation configuration, it is possible to instantiate multiple network loss containers in the same host space at the same time, realizing single-machine multi-channel parallel simulation;

[0041] 5. Using the containerized method to simulate the weak network channel between the transceiver improves the portability and deployability of the method. Description of the Drawings

[0042] Figure 1 It is a flow chart of a weak network simulation method based on Linux containerization.

[0043] Figure 2 It is a schematic diagram of a weak network transmission simulation system based on Linux containerization. Detailed Embodiments

[0044] The following describes the detailed embodiments of the present invention to facilitate those skilled in the art of the present technology to understand the present invention. However, it should be clear that the present invention is not limited to the scope of the detailed embodiments. For those of ordinary skill in the art of the present technology, as long as various changes are within the spirit and scope of the present invention defined and determined by the appended claims, these changes are obvious, and all inventions created using the concept of the present invention are within the scope of protection.

[0045] As Figure 1 shown, in an embodiment of the present invention, a weak network simulation method based on Linux containerization is provided, including:

[0046] S1. Configure the environment: Configure the Linux kernel environment required for weak network simulation and the resources required for host simulation;

[0047] S2. Create a container: Create a virtual network container on the host, generate a weak network with dynamic bandwidth, and configure weak network environment parameters in the virtual network container;

[0048] S3. Scenario testing: Conduct weak network connectivity checks and weak network performance checks;

[0049] S4. Weak network simulation: Use the virtual network container that has passed the check for weak network simulation.

[0050] Specifically, in S1, the resources required for host simulation include the traffic control tool TC (Traffic Control), the network dynamic bandwidth simulation tool Mahimahi, the Python Popen component, and a virtual router.

[0051] The traffic control tool TC configures network card parameters through shell commands to achieve the effect of simulating weak network scenarios such as dynamic delay and packet loss, and TC can act on both physical network cards and virtual network cards at the same time; the network dynamic bandwidth simulation tool Mahimahi can execute the mm-Link command. Through this command, users can read the pre-written bandwidth trace file to simulate the actual network link bandwidth change situation.

[0052] Since the container created by mm-Link is an independent container environment with a separate shell space, which is different from the original host shell space, but this space can access host files. Pure mm-Link can only simulate weak network bandwidth for link transmission. When combined with the traffic control tool TC of the Linux system and the control command acts on the virtual network card inside the container, delay rules and packet loss rules can be easily added.

[0053] Specifically, the weak network environment parameters include bandwidth parameters, delay parameters, and packet loss rate parameters.

[0054] As an optimization of this embodiment, S2 includes:

[0055] S201. Input parameter commands through the traffic control tool;

[0056] S202. Read the file path of the network dynamic bandwidth simulation tool;

[0057] S203. Execute the command of the network dynamic bandwidth simulation tool through the Python Popen component and allocate a temporary shell space as the virtual network container;

[0058] S204. In the virtual network container, execute the parameter command through the Python Popen component to set the weak network environment parameters.

[0059] Specifically, when creating a container, one or more than one container can be instantiated. When creating a container, it is necessary to check whether the IP Forward of Linux is enabled. When the IP Forward is enabled, execute the mm-Link command through the network dynamic bandwidth simulation tool Mahimahi, and read the bandwidth trace file to create a container.

[0060] As a preference of this embodiment, S3 includes:

[0061] S301. Input the link trace path through the traffic control tool.

[0062] S302. Instantiate the container by reading the trace file according to the link trace path through the network dynamic bandwidth simulation tool.

[0063] S303. Set the traffic control command in the virtual network container space and configure the virtual network card parameters.

[0064] S304. Send the data stream from the virtual network container to the host, and perform weak network connectivity check and weak network performance check according to the transmission situation of the data stream.

[0065] In this embodiment, as a supplement, a preferred step from creating a container, implementing simulation to removing the container is provided, including:

[0066] Step 1: Input the simulation parameters through the traffic control tool TC, including the Link-Trace path and the parameter command.

[0067] Step 2: Start the software and execute the mm-Link command through the network dynamic bandwidth simulation tool Mahimahi.

[0068] Step 3: Read the file path of mm-Link.

[0069] Step 4: Determine whether the path file of mm-Link exists. If it does not exist, an error prompt is thrown. If it exists, go to Step 5.

[0070] Step 5: Execute the mm-Link command through the PythonPopen component and allocate a temporary shell space at the same time.

[0071] Step 6: Determine whether the virtual network card exists and has been configured. If not, an error prompt is thrown. If it exists, go to Step 7.

[0072] Step 7: Use the PythonPopen component to execute the TC command in the process, set parameters such as the connection mode, IP address, latency, and packet loss of the virtual network card, and feedback a successful setting prompt;

[0073] Step 8: Determine whether the feedback prompt is successfully returned. If not, throw an error. If successful, enter the PythonPopen timer setting;

[0074] Step 9: Start the timer and set the duration according to the input parameters set by the PythonPopen component;

[0075] Step 10: Determine whether the timing has ended. If it has ended, enter Step 11. If it has not ended, wait;

[0076] Step 11: Remove the TC configuration and the mm-Link space, and terminate the simulation program.

[0077] The present invention also provides a weak network simulation system based on Linux containerization for implementing the weak network simulation method based on Linux containerization. The system is implemented based on a host computer, and the host computer includes:

[0078] A container creation module for creating a virtual network container according to the environment and simulation resources;

[0079] A data receiving module recver for receiving the data stream sent by the virtual network container;

[0080] A performance inspection module detect for performing weak network connectivity inspection and weak network performance inspection according to the transmission condition of the data stream received by the data receiving module.

[0081] The virtual network container created by the container creation module includes a virtual network card ingress, a data sending device sender, and a traffic control tool TC;

[0082] The virtual network card ingress is used to simulate a multi-dimensional dynamic weak network environment according to the network loss rule;

[0083] The data sending device sender is used to send the data stream to the host computer through the virtual network card;

[0084] The traffic control tool TC is used to add or modify the network loss rule of the virtual network card.

[0085] As Figure 2 shown, in an application of the present invention, it includes a Linux host computer with a kernel version of Linux5.15.0-107-generic x86_64, and the weak network environments are respectively:

[0086] Container Space 1: Bandwidth 12Mbps + Latency 50ms + Packet Loss 10%;

[0087] Container Space 2: Bandwidth 10Mbps + Latency 30ms + Packet Loss 8%;

[0088] Set up the first receiving module recver1 and the second receiving module recver2 in the host machine, which are respectively used to receive the data sent by the first data sending device sender1 and the second data sending device sender2 through the virtual network card. The first performance inspection module detect1 and the second performance inspection module detect2 respectively perform weak network connectivity inspection and weak network performance inspection according to the data streams received by the first receiving module recver1 and the second receiving module recver2, realizing that in the same host machine space, multiple network loss containers are simultaneously enabled, and single-machine multi-channel parallel simulation is carried out.

[0089] Since there is only one external network card ingress in the container, all data packet traffic realizes network loss control through ingress. The connectivity between the virtual network card ingress in the container space and the physical network card (eth0) in the host machine space is based on the IP Forward data forwarding function in the Linux kernel, which supports data interaction between the virtual network card ingress and the physical network card eth0.

[0090] In traditional network simulation tests, the configuration work steps are relatively cumbersome, and shell commands need to be configured in both the host machine space and the container space at the same time, which is extremely error-prone and inconvenient to use. Therefore, in order to further improve the usability of the weak network environment configuration method, this application introduces Python for automatic configuration. In particular, the Popen component is introduced to hold the shell contexts of two different environments (container space and host machine space) at the same time. All commands are read through the Python Popen component and executed in different target shell spaces, realizing the simulation of the manual simulation environment configuration through one-key startup of the script, greatly improving the automation degree of the simulation process and the simulation efficiency.

[0091] The above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them; although the present application has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that they can still modify the technical solutions described in the foregoing embodiments, or perform equivalent replacements for some of the technical features; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present application.

Claims

1. A weak network simulation method based on Linux containerization, characterized in that, Including: S1. Configure the environment: Configure the Linux kernel environment required for weak network simulation and the resources required for host simulation; S2. Create a container: Create a virtual network container on the host, generate a dynamic bandwidth weak network, and configure weak network environment parameters in the virtual network container; S3. Scenario test: Conduct weak network connectivity check and weak network performance check; S4. Weak network simulation: Use the virtual network container that has passed the check for weak network simulation.

2. The weak network emulation method based on Linux containerization according to claim 1, characterized in that In S1, the resources required for host simulation include a traffic control tool, a network dynamic bandwidth simulation tool, a Python Popen component, and a virtual router.

3. The weak network simulation method based on Linux containerization according to claim 2, wherein The weak network environment parameters include bandwidth parameters, delay parameters, and packet loss rate parameters.

4. The weak network simulation method based on Linux containerization according to claim 3, characterized in that S2 Including: S201. Input parameter commands through the traffic control tool; S202. Read the file path of the network dynamic bandwidth simulation tool; S203. Execute the command of the network dynamic bandwidth simulation tool through the Python Popen component and allocate a temporary shell space as the virtual network container; S204. In the virtual network container, execute parameter commands through the Python Popen component to set weak network environment parameters.

5. The weak network simulation method based on Linux containerization according to claim 1, characterized in that When creating a container, 1 or more than 1 container can be instantiated.

6. The weak network simulation method based on Linux containerization according to claim 1, wherein S3 Including: S301. Input the link tracing path through the traffic control tool; S302. Instantiate the container by reading the tracing file according to the link tracing path through the network dynamic bandwidth simulation tool; S303. Set traffic control commands in the virtual network container space and configure virtual network card parameters; S304. Send a data stream from the virtual network container to the host, and conduct weak network connectivity check and weak network performance check according to the transmission situation of the data stream.

7. A weak network simulation system based on Linux containerization, which is used to execute the method described in any one of claims 1-6, and is characterized in that, The weak network simulation system is implemented based on the host, and the host includes: A container creation module, used to create a virtual network container according to the environment and simulation resources; A data receiving module, used to receive the data stream sent by the virtual network container; A performance check module, used to conduct weak network connectivity check and weak network performance check according to the transmission situation of the data stream received by the data receiving module.

8. The weak network simulation system based on Linux containerization according to claim 7, wherein The virtual network container created by the container creation module includes a virtual network card, a data sending device, and a traffic control tool; The virtual network card is used to simulate a multi-dimensional dynamic weak network environment according to the network loss rule; The data sending device is used to send a data stream to the host through the virtual network card; The traffic control tool is used to add or modify the network loss rule of the virtual network card.