Let me share with you the new skills I got today. Come let us start.
First let's talk about the tools we're going to use.
Network Simulator WANem
Introduction to WANem
Since the company needs to simulate the real network environment in some occasions, such as delay, packet loss, jitter, etc., although the TC under Linux can be used to achieve this function, the TC has a command-line interface that is not conducive to configuration, and it is inconvenient to use bridge mode. The shortcomings of remote management, so in the spirit of sharing, I now recommend a network simulation tool - WANem. WANem's full name is WAN emulator, which is an open source wide area network simulator based on TC. Its main functions are as follows:
-
Can be used to simulate WAN in LAN, including bandwidth, delay, packet loss, jitter
-
Advanced functions include: random reset of connections, repeated packets according to probability, packets out of order according to probability and instantaneous disconnection according to probability, random disconnection according to protocol, etc., and can be targeted for different protocols, different hosts, different networks or even different applications to simulate.
Its advantages are as follows:
-
WANem implements all functions on a single NIC device
-
WANem supports booting from the CD, it can be used without installing it to the hard disk, and it can even run on a virtual machine. At this time, the network card of the bridge host can be used, which is very convenient
-
Support fully graphical interface configuration, easy to set
-
Multiple rules can be set, different rules and different users do not interfere with each other, which is convenient for centralized testing environment
-
Only need to adjust the routing table to apply the set rules
Download address: Click to open the link
I just use VMware Workstation to virtualize one. This is very simple and I will not introduce it.
After the virtual is completed, it will look like the following.
Click the tabs in the red box to configure the network settings.
In fact, this is very similar to the operating habits of linux. It can also be modified in the sehll script.
We click on the lower left corner to open the LXTerminal terminal emulator in the lower left corner
Enter exit2shell
Is it similar to linux?
We set him an IP address.
Set IP address: ifconfig eth0 192.168.8.122 netmask 255.255.255.0
This modification will take effect immediately, but will fail after restarting
Next, we need to access the main interface of WANem on the physical machine and configure it.
We enter in the browser: http://192.168.8.122/WANem/
Note that this is strictly case sensitive
WANem configuration
About: about
WANalyer: A WAN learning tool that automatically simulates the network environment by learning the packet loss, delay, and jitter of the target host
Basic Mode: Basic mode, only bandwidth and delay can be set
Advanced Mode: Advanced mode, you can set complex network rules, such as rules based on different interfaces, different hosts, different network segments, and even different applications, etc.
Save/Restore: Backup and restore data
Let's not talk about it, just learn about Advanced Mode and configuration, etc.
The red box is to select the network card
configuration interface
parameter comparison
Delay: delay
Delay time represents the delay timeJitter represents the jitter size Correlation represents the
floating range of the jitter
size IP source subnet: source address mask IP dest address: destination address
IP dest subnet: destination address mask
Apply settings: Apply settings.
Below we only use network latency as an example:
Our purpose was achieved. This is the delay between the local machine and WANem that we realized. Next, we are using WANem as a proxy server.
Network topology diagram:
We just add a proxy between the client and the server, and the proxy is WANem
Next we add a route to the client just fine.
route add 192.168.8.211 mask 255.255.255.255 192.168.8.122
Just add it
Note that the routing must be configured in both directions, and a little knowledge of the network is required here.
192.168.8.211 is the destination IP address
255.255.255.255 subnet mask
192.168.8.122 next hop address
We have achieved the desired effect. Haha isn't it cool.