Simulation of real-world network environment by laboratory testing

Source: Internet
Author: User

Http://jingyan.baidu.com/article/09ea3ede38c295c0aede3926.html

Our projects, may involve a variety of network environment, such as through the home broadband access, through the mobile phone access, these environments compared to our testing time use of the network environment is more complex, how to simulate the current network may appear a variety of network conditions, so that our program, in various environments can be normal operation, Is the problem we need to solve.

Tools/Materials
    • Netem and TC
    • Netem is a network emulation function module provided by Linux 2.6 and above kernel versions. The function module can be used to simulate complex Internet transmission performance in a well-performing LAN, such as low bandwidth, transmission delay, packet loss and so on. Many distributions of Linux with Linux 2.6 (or more) versions of the kernel feature the kernel, such as Fedora, Ubuntu, Redhat, OpenSuse, CentOS, Debian, and more.
    • TC is a tool in a Linux system with the full name traffic control (flow controls). TC can be used to control the operating mode of the Netem, that is, if you want to use Netem, you need at least two conditions, one is the kernel Netem function is included, the other is to have TC.
Method/Step
  1. 1

    Concrete operation

    simulate deferred transfer

     

     # TC  qdisc  add  Dev  eth0  root  netem  delay  100ms

     

    The command eth0 The transmission of the network card is set to delay 100 milliseconds for sending.

    More realistically, the delay value will not be so accurate, there will be some fluctuation, we can use the following conditions to simulate the delay value with volatility:

     

     # tc  qdisc  Add   Dev  eth0  root  netem  delay  100ms  10ms

     

    This command sets the transmission of the eth0 NIC to a delay 100MS±10MS (any value between a.

    Can further enhance the randomness of this fluctuation:

     

     # tc  qdisc  add  Dev  eth0  root  Netem  delay  100ms  10ms  30%

     

    This command sets the transmission of the ETH0 network card to 100ms, while approximately 30% of packets delay ±10ms send.

    Experimental validation: The ping command to validate after setting.

  2. 2

    Analog Network drops:

    # TC Qdisc Add dev eth0 root netem loss 1%

    This command sets the transmission of the eth0 NIC to randomly discard 1% of packets.

    You can also set the success rate of packet loss:

    # TC Qdisc Add dev eth0 root netem loss 1% 30%

    This command sets the transmission of the eth0 NIC to randomly discard 1% of packets, with a success rate of 30%.

    Experimental verification: After Setup, the packet loss rate is analyzed by grasping the package tool.

  3. 3

    Simulate package duplication:

    # TC Qdisc Add dev eth0 root netem duplicate 1%

    This command sets the transmission of the eth0 NIC to randomly generate 1% of duplicate packets.

  4. 4

    Impersonation packet Corruption:

    # TC Qdisc Add dev eth0 root netem corrupt 0.2%

    This command sets the transmission of the eth0 NIC to a randomly generated 0.2% corrupted packet. (kernel version is required at 2.6.16 or more)

  5. 5

    Analog packet Scrambling:

    # TC Qdisc Change dev eth0 root netem delay 10ms reorder 25% 50%

    This command sets the transmission of the eth0 NIC to: 25% of the packets (50% related) are sent immediately, and the other is delayed by 10 seconds.

  6. 6

    In the new version, the following command will also disrupt the order of the packages to some extent:

    # TC Qdisc Add dev eth0 root netem delay 100ms 10ms

Simulation of real-world network environment by laboratory testing

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.