I'm trying to simulate a network on a single machine.

I have multiple nodes that communicate through tcp sockets.

I tried to create one dummy interface for each node like this:

ip link add name int1 type dummy 
ip address add dev int1
ifconfig int1 up

All nodes can bind the respective addresses and communicate without problems. However, I also want to add delay and limit the bandwidth of each interface to simulate real world conditions.

I used tc add delay to the interface like this:

tc qdisc add dev int1 root netem delay 200ms

But there was no increase in execution times as I was expecting.

My questions are:

  1. Can i do traffic shaping on dummy interfaces? If not what is the best way to simulate a network on a single machine

  2. I also noted that pings to the created interfaces land on loopback and not on the actual interface. Why?

  • There are tools out there to simulate network traffic, but it's some decades ago that I worked with them. One option could be to have a proxy run to channel one port to another with a given delay and/or data rate – Philippos May 29 '19 at 14:50
  • That could be a solution, but i also want to simulate bandwidth. Calculate bandwidth at a proxy would be rather complex, and i would like to be able to use a native, faster solution to the problem. – Joao P May 29 '19 at 15:01
  • I've not tried it but mininet.org says Mininet creates a realistic virtual network, running real kernel, switch and application code, on a single machine (VM, cloud or native). – meuh May 29 '19 at 18:03
  • 1
    dummy devices don't work this way. Use network namespaces (google), or one of the many ready-made tools that use network namespaces to simulate a network. With tc you can also simulate bandwidth, again ready-made tools already integrate this. – dirkt May 30 '19 at 11:23
  • Thanks, i ended up using network namespaces and tc. – Joao P Jun 3 '19 at 13:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.