Chain type end-to-end dynamic network loss simulation method, device and system based on Mahimahi
By transforming Mahimahi's nested space into a chain serial design, combining veth pair and iptable configuration, the problem of insufficient ease of use and stability of existing network loss simulators is solved, and efficient network loss simulation in the implementation environment is achieved, reducing costs and improving flexibility.
Patent Information
- Application Number
- CN202510528407.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-25
- Publication Date
- 2025-08-08
AI Technical Summary
Existing network loss simulators are difficult to fully consider in terms of ease of use, versatility and stability, especially in dynamic network loss scenarios, resulting in high learning costs and low research efficiency.
By transforming the nested space of Mahimahi into a chain serial design, using veth pair to connect different network loss spaces, and guiding real data packets through iptable configuration, combining routing rules to perform end-to-end network loss simulation, supporting multi-dimensional network space simulation.
It achieves improvements in ease of use, versatility and stability, reduces equipment costs, improves simulation flexibility and adaptability, and enables network loss control of real data links in the implementation environment.
Smart Images

Figure CN120455409A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of network loss simulation, and more specifically, to a Mahimahi-based chained end-to-end dynamic network loss simulation method, device, and system. Background Art
[0002] Network loss simulation typically involves users setting parameters for network impairments. Network loss tools then simulate different network performance scenarios based on these parameters. By precisely adding timed and quantitative transmission losses to transmission links, network performance becomes more controllable and reproducible.
[0003] With the development of the internet, the types of data services carried by networks have expanded dramatically. Emerging business models and scenarios, such as live streaming, online conferencing, remote desktops, and cloud gaming, continue to emerge, placing higher demands on network transmission performance and strategies. Transmission optimization based on different scenarios and services has become a hot topic in the industry. Various new code control algorithms, congestion control algorithms, and queue management algorithms optimize the transmission process from different perspectives, aiming to provide better quality of service and user experience. In this process, network link emulators have become important verification and testing tools. Their simulation accuracy, operational performance, flexibility, and ease of use have significantly impacted the efficiency of the R&D and verification of new transmission mechanisms.
[0004] However, the increasing complexity of transmission optimization research places higher demands on simulator systems. Existing transmission simulator solutions often fail to meet all research needs, and most lack usability, leading to increased learning costs and reduced research efficiency. The following is a brief introduction to common network loss simulators—Linux TC, NS-3, Mahimahi, and dedicated network loss meters—analyzing their strengths and weaknesses and addressing challenges currently facing network transmission link simulators.
[0005] 1) Linux TC Component: Linux TC is a component of the Linux kernel, and its open-source nature allows for flexible user modification. However, kernel source code is often difficult to learn, and functional implementations vary significantly between kernel versions, leading to compatibility issues. While the combination of TC and iptables can cover most static network speed scenarios, in dynamic network loss scenarios, relying on shell scripts to glue TC commands together often results in low call accuracy due to timeliness issues. Improving execution accuracy requires direct calls to the C interface or programming, which significantly increases the barrier to entry and reduces ease of use.
[0006] 2) NS-3: NS-3 is an open-source, extensible, event-based network simulator primarily designed for research and teaching in the field of networking. Its most notable feature is its exceptionally high simulation accuracy, enabling realistic end-to-end simulations of UDP and TCP interactions with near-native kernel network stack accuracy. At the link level, it supports various link protocols, including Wi-Fi and Ethernet. While NS-3's design emphasizes simulator realism and meticulous network simulation, its complexity and high learning curve make it difficult to use.
[0007] 3) Dedicated network loss testers: Dedicated network loss testers are typically expensive, ranging from hundreds of thousands to several million yuan. The user interfaces and functionality of these devices vary significantly between manufacturers, leading to a high learning curve. They are also less user-friendly, especially when batch network loss testing is required. The configuration process is complex and time-consuming, and automation needs to be improved.
[0008] 4) Mahimahi: Mahimahi was originally used for recording and replaying HTTP traffic. It also provides lightweight end-to-end network loss simulation, capable of simulating changes in bandwidth, cache, and latency across end-to-end links. However, Mahimahi can only run on a single machine and cannot be connected to real devices for simulation.
[0009] In summary, the loss simulators commonly used in the industry currently have difficulty in fully addressing ease of use, versatility, and stability. Therefore, the solution of this application is proposed. Summary of the Invention
[0010] The purpose of the present invention is to overcome the shortcomings of the existing technology and provide a chain-type end-to-end dynamic network loss simulation method, device and system based on Mahimahi, which solves the problem that the loss simulators commonly used in the industry are difficult to fully consider in terms of ease of use, versatility and stability. By creating a network loss space through Mahimahi and a network space through the host, the original data is connected with the real device through this simulation scenario in combination with chain design and routing rules, completing the lightweight end-to-end network loss simulation function, and improving the versatility and adaptability of the method.
[0011] The object of the present invention is achieved through the following solutions:
[0012] A Mahimahi-based chained end-to-end dynamic network loss simulation method includes the following steps:
[0013] S1: Create a network space and a network space inside the host. Enable ip_forward for each network space and create a veth pair to connect the host, network space, and network space.
[0014] S2, adds a new routing table to configure the forwarding path of the data;
[0015] S3, repeating steps S1 to S2 to achieve multi-dimensional network space simulation.
[0016] Furthermore, after step S3, the method further includes the following steps:
[0017] S4, inject the original data packet at the sending device, start the network loss test, and receive the test data at the receiving device.
[0018] Furthermore, after step S4, the method further includes the following steps:
[0019] S5, after the simulation is completed, close the network loss space and network space, remove the veth pair, and remove the virtual link.
[0020] Furthermore, in step S1, the creation of the network loss space and the network space specifically includes: using Mahimahi to create an anonymous network loss space, and using netns to create a custom network space.
[0021] Furthermore, in step S1, creating a veth pair to connect the host, the network loss space, and the network space specifically includes:
[0022] The nested spatial arrangement design of Mahimahi is transformed into a chain serial design. Different network loss NSs are connected in series through vethpair. By setting the iptable configuration method, the real data packets entering the physical network port of the host device are guided through the bandwidth, latency, and packet loss space in turn, achieving the function of controlling network loss simulation at the packet level.
[0023] Furthermore, a network loss space is created inside the host, and different network loss spaces run independently of each other without interfering with each other.
[0024] Furthermore, in step S2, the newly added routing table configures the forwarding path of the data, specifically including: configuring the newly added routing table to concatenate the network loss space and the network space to control the forwarding path of the data.
[0025] Furthermore, the forwarding path of the control data specifically includes:
[0026] After creating the network space in the host machine, transfer the controlled data packets from the network loss space to the host space, configure the veth pair and routing table of the network loss space and network space, and establish a forwarding link.
[0027] Furthermore, in step S3, the multi-dimensional network space simulation is implemented, specifically including: after creating a multi-dimensional network loss simulation scenario, using Mahimahi to read the trace configuration file to implement dynamic network loss simulation.
[0028] A computer device comprises a processor and a memory, wherein a computer program is stored in the memory, and when the computer program is loaded by the processor, any of the above methods is executed.
[0029] An electronic system comprises the device described above.
[0030] The beneficial effects of the present invention include:
[0031] Compared with the network loss simulation environment of the original Mahimahi nested platoon, the method of the present invention can be used in a real installation environment to control the network loss of a real data link, and has also been greatly improved in terms of ease of use, versatility and stability.
[0032] The method of the present invention transforms the nested spatial arrangement design of Mahimahi into a chain serial design. Different network losses NS are connected in series through veth pairs. By setting the configuration mode of iptable, the real data packets entering the physical network port of the host device are guided to pass through the bandwidth, delay, packet loss space in turn, and reach the function of controlling the network loss simulation at the packet level.
[0033] The method of the present invention adopts a chain-like approach to perform end-to-end dynamic network loss simulation, thereby improving portability and deployability and reducing the equipment cost of network loss simulation. BRIEF DESCRIPTION OF THE DRAWINGS
[0034] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. 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 any creative work.
[0035] Figure 1 Schematic diagram of Mahimahi-based chain end-to-end dynamic network loss simulation;
[0036] Figure 2 Schematic diagram of one-dimensional simulation of chained end-to-end dynamic network loss based on Mahimahi;
[0037] Figure 3 Schematic diagram of multi-dimensional simulation of chain end-to-end dynamic network loss based on Mahimahi. DETAILED DESCRIPTION
[0038] All features disclosed in all embodiments in this specification, or steps in all methods or processes implicitly disclosed, except for mutually exclusive features and / or steps, can be combined and / or expanded or replaced in any manner.
[0039] Explanation of terms
[0040] ip-forward is the linux system ip forwarding option;
[0041] Trace is a file that records the timing status of network performance parameters;
[0042] veth pair (Virtual Ethernet Device Pair), a pair of virtual network interfaces created;
[0043] netns and iptable are both Linux components.
[0044] The specific implementation process of the present invention is as follows:
[0045] In response to the technical problems outlined above, the present invention provides a Mahimahi-based, chained, end-to-end dynamic network loss simulation method. By utilizing Linux virtual network components to perform routing transformation on the Mahimahi network loss space, the method aims to achieve a lightweight, easy-to-use, and highly scalable network loss simulation method. This method supports single-machine transmission optimization and network loss environment simulation, while also enabling access to real communication equipment, replacing dedicated network loss meters for device integration testing.
[0046] Mahimahi's original network loss design controlled network loss by creating a new virtual network connection (NS). Multi-dimensional network loss control was achieved through nested NSs. This design made Mahimahi's network loss scenarios difficult to share with real network cards and test on external communication devices. Therefore, the present invention transforms Mahimahi's nested design into a chained one. Different network loss NSs are connected in series via veth pairs. By configuring iptables, test packets entering the Ethernet port are directed sequentially through various network loss spaces, allowing packets to pass through bandwidth, latency, and packet loss thresholds. This achieves packet-level network loss simulation control.
[0047] The method of the present invention provides a lightweight and easy-to-use network loss simulation method. Without losing the accuracy of network simulation, it has all the functions of a professional network loss meter and is implemented in a white box hardware and software combination, thereby reducing the cost of network loss simulation and improving flexibility. The specific advantages are listed below (but not limited to): 1) The method of the present invention effectively integrates the existing mature tools Mahimahi and Linux TC, controls the data flow based on the routing method to achieve multi-dimensional network loss, and has stable operation and strong scalability. 2) The method of the present invention uses open source Linux system and white box computer equipment, which greatly reduces the cost of network loss simulation compared to professional network loss meter equipment. 3) Compared with other open source network loss implementation methods, the method of the present invention can be completed through a simple configuration file in the process of realizing complex network loss scenarios. No programming is required, the learning cost is extremely low, and the ease of use and stability are significantly improved.
[0048] More specifically, as a first aspect of the present invention, Figure 1 As shown, a chain-type end-to-end dynamic network loss simulation method based on Mahimahi is provided, which specifically includes the following steps:
[0049] Step S101: Start simulation. In this step S101, specifically, based on the type of network loss to be simulated, a trace file is written in the network loss format, with the number representing the sending time. The trace file is executed in a loop from top to bottom. Configure a Linux system Intel x86 platform host as the network loss simulation host, and configure multiple physical Ethernet ports. In this embodiment, ens1 is used as the test data packet input port, and ens2 is used as the test data packet output port. The sending device connects to the host through ens1, and the receiving device connects to the host through ens2. The user logs in to the host using SSH and performs subsequent host configuration operations.
[0050] Step S102: Creating a network loss space within the host. Specifically, in step S102, the host executes the mahimahi command, which reads the network loss trace and generates an anonymous network space, which is named the network loss space in the present invention.
[0051] Step S103: Create a network space within the host. Specifically, in step S103, the host executes the netns command to generate the network space ns. At this point, the host has three network spaces: the local host space, the Mahimahi network space, and the network space ns.
[0052] Step S104: Enable ip_forward for each network space. In this step S104, specifically, a shell command is executed in the network loss space to create a veth pair component, and the veth peer is placed in the ns1 space through the link set instruction (e.g., the present invention names the veth pair as v1, v2, v1 is placed in the network loss space, and v2 is placed in the ns1 space). A veth pair component is created in the ns1 space, and the veth peer is placed in the host space (e.g., the present invention names the ns1 space component as v3, v4, and places v4 in the host space). Set the IP address of the network port (e.g., the IP address of v1 is ip_v1) so that ip_v1 and ip_v2 are in the same network segment, and ip_v3 and ip_v4 are in the same network segment.
[0053] Step S105: Create a veth pair to connect the host, the network space, and the network space. In this step S105, specifically, the executed mahimahi command creates an ingress virtual network card in the network space and simultaneously creates a virtual network card in the host space to connect the host, the network space, and the network space through a veth pair.
[0054] Step S106: Add a new routing table to configure the forwarding path of the test data.
[0055] Step S107: Repeat steps S101 to S106 to implement multi-dimensional network space simulation. In this step S107, specifically, mm-link, mm-delay, and mm-loss are executed to generate three network loss spaces, namely bandwidth, delay, and packet loss, to implement multi-dimensional network space simulation.
[0056] Step S108: inject the original data packet at the transmitting device to start the network loss test, receive the test data packet at the receiving device, and evaluate this Mahimahi-based chained end-to-end dynamic network loss environment simulation method.
[0057] Step S109: close the network loss space and the network space, remove the veth pair, and remove the virtual link.
[0058] Step S110: End the simulation.
[0059] In other embodiments of the present invention, based on the above concept, a one-dimensional simulation method of end-to-end dynamic network loss based on Mahimahi chain is provided, such as Figure 2 As shown, the following steps are included:
[0060] Step S201: The originating device packages the original data packet and sends it to the host machine;
[0061] Step S202: The host receives data from the ens1 network card, processes and packages it, and transmits it to the link-nic. The link-nic and ingress form a veth pair.
[0062] Step S203: In the mm-link space, data from the ingress network card is received and transmitted to v1. v1 and v2 in the network space ns form a veth pair.
[0063] Step S204: Network space ns receives data from v2 and packages it and sends it to v3. v3 and v4 in the host machine form a veth pair.
[0064] Step S205: The host receives the data from v4 and packages it for transmission to the ens2 network card;
[0065] Step S206: The host sends the data packet to the receiving device via the ens2 network card;
[0066] In other embodiments of the present invention, based on the above concept, a multi-dimensional simulation method of end-to-end dynamic network loss based on Mahimahi chain is provided, such as Figure 3 As shown, the following steps are included:
[0067] Step S301: The sending end packages the original data packet and transmits the data packet to the network loss space through the host network card;
[0068] Step S302: Create mm-link using the mahimahi command line to create bandwidth loss space and network space, connect the loss space and network space, and connect the bandwidth loss space and latency loss space through veth pairs, establish routing rules and routing tables, and create transmission links.
[0069] Step S303: Create mm-delay through the mahimahi command line to create a delay and network loss space and a network space, connect the network loss space and the network space, and connect the delay and network loss space and the packet loss and network loss space through a veth pair, establish routing rules and routing tables to create a transmission link;
[0070] Step S304: Create mm-loss through the mahimahi command line to create a packet loss space and a network space, connect the network space and the network space through a veth pair, connect the packet loss space and the host network card, establish routing rules and routing tables to create a transmission link;
[0071] Step S305: The packet loss network transmits the data to the receiving end.
[0072] As a second aspect of the present invention, a computer device is provided, comprising a processor and a memory, wherein a computer program is stored in the memory, and when the computer program is loaded by the processor, the method described in the above embodiment is executed.
[0073] As a third aspect of the present invention, an electronic system is provided, comprising the apparatus as described in the above embodiments.
[0074] It should be noted that in the device embodiment of the present invention, the bandwidth network loss space, delay network loss space, and packet loss network loss space can be set to bandwidth 12Mbps + delay 30ms + packet loss 8%, respectively. The embodiment needs to include a Linux host. The original data packet of the sending device is transmitted to the chained bandwidth, delay, and packet loss space through the Linux host, and is transmitted to the receiving device through the link established by the veth pair and the routing table.
[0075] The units involved in the embodiments of the present invention may be implemented in software or hardware, and the units described may also be provided in a processor. In some cases, the names of these units do not limit the units themselves.
[0076] According to one aspect of an embodiment of the present invention, a computer program product or computer program is provided, comprising computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the methods provided in the various optional implementations described above.
[0077] As another aspect, embodiments of the present invention further provide a computer-readable medium, which may be included in the electronic device described in the above embodiments, or may exist independently and not incorporated into the electronic device. The computer-readable medium carries one or more programs, and when executed by the electronic device, the electronic device implements the methods described in the above embodiments.
Claims
1. A chain-type end-to-end dynamic network loss simulation method based on Mahimahi, characterized in that: The following steps are involved: S1: Create a network space and a network space inside the host. Enable ip_forward for each network space and create a veth pair to connect the host, network space, and network space. S2, adds a new routing table to configure the forwarding path of the data; S3, repeating steps S1 to S2 to achieve multi-dimensional network space simulation.
2. The Mahimahi-based chained end-to-end dynamic network loss simulation method according to claim 1 is characterized in that: After step S3, the method further includes the following steps: S4, inject the original data packet at the sending device, start the network loss test, and receive the test data at the receiving device.
3. The Mahimahi-based chained end-to-end dynamic network loss simulation method according to claim 2, characterized in that: After step S4, the method further includes the following steps: S5, after the simulation is completed, close the network loss space and network space, remove the veth pair, and remove the virtual link.
4. The Mahimahi-based chained end-to-end dynamic network loss simulation method according to claim 1, characterized in that: In step S1, the creation of the network loss space and the network space specifically includes: using Mahimahi to create an anonymous network loss space, and using netns to create a custom network space.
5. The Mahimahi-based chained end-to-end dynamic network loss simulation method according to claim 1, characterized in that: In step S1, creating a veth pair to connect the host, the network loss space, and the network space specifically includes: The nested spatial arrangement design of Mahimahi is transformed into a chain serial design. Different network loss NSs are connected in series through veth pairs. By setting the iptable configuration method, the real data packets entering the physical network port of the host device are guided through the bandwidth, latency, and packet loss space in turn, achieving the function of controlling network loss simulation at the packet level.
6. The Mahimahi-based chained end-to-end dynamic network loss simulation method according to claim 1, characterized in that: Create network loss spaces inside the host, and different network loss spaces run independently without interfering with each other.
7. The Mahimahi-based chained end-to-end dynamic network loss simulation method according to claim 1, characterized in that: In step S2, the newly added routing table configures the forwarding path of the data, specifically including: configuring the newly added routing table to concatenate the network loss space and the network space, and controlling the forwarding path of the data.
8. The Mahimahi-based chained end-to-end dynamic network loss simulation method according to claim 7, characterized in that: The forwarding path of the control data specifically includes: After creating the network space in the host machine, transfer the controlled data packets from the network loss space to the host space, configure the veth pair and routing table of the network loss space and network space, and establish a forwarding link.
9. The Mahimahi-based chained end-to-end dynamic network loss simulation method according to claim 8, characterized in that: In step S3, the multi-dimensional network space simulation is implemented, specifically including: after creating a multi-dimensional network loss simulation scenario, using Mahimahi to read the trace configuration file to implement dynamic network loss simulation.
10. A computer device, characterized in that: The method comprises a processor and a memory, wherein a computer program is stored in the memory, and when the computer program is loaded by the processor, the method according to any one of claims 1 to 9 is executed.
11. An electronic system, characterized in that: Comprising the device according to claim 10.