1

Im developing a software product that uses networking features like device bonding an multi-homing protocols. As with any protocol development, test-code needs to take latency, package-dropping etc. into account. I am therefore trying to create a virtual network environment in which I can do controllable, reproducible tests.

The two main features I want to test(ie. measure performance, stability etc.):

  • SCTP multihoming associations where the client uses several endpoints.
  • Device bonding of several devices.

As mentioned, I want to be able to do traffic control between the nodes in the network, as well as traffic filtering to simulate legacy NATs etc.

Example test:

This test is supposed to emulate a client with four NICs (wifi, usb, bluetooth, ethernet) communicating over the internet with a single-interface server.

I would like to create a virtual network that emulates this layout. One device emulates a WAN node, and four others represents the clients interfaces. There is a bandwidth limit on 1 Mb/s between the client interfaces and the server interface and a package-loss of 1%.

A bonding device of the four client interfaces is created. A iperf server is bound to the WAN address and a client is bound to the bonding device address and connected to the WAN server.

prinsen
  • 162
  • 8
  • Either I'm misunderstanding something, or you don't know that you can do `ifconfig eth0:1 10.0.0.2; ifconfig eth0:2 10.0.0.3; ifconfig eth0:3 10.0.0.4`. My guess is that I'm misunderstanding; can you clarify? – MadHatter Apr 25 '13 at 12:34
  • I have so far ended up with something similar (I think). I assign multiple mac-addresses to my wireless card using ip link add link DEV address MAC type macvlan. Additionally I assign these interfaces addresses on separate subnets. My next trouble is to route traffic between these interfaces. Say macvlan0 has address 10.0.0.1/24 and macvlan1 has address 10.0.1.1. How would I allow for communication between these addresses? – prinsen Apr 25 '13 at 12:49
  • The question "how do I get a linux box to route" is a bit too big to cover here, so I'm afraid that, now you've clarified, I'm going to vote to close this question. You might want to look into `echo 1 > /proc/sys/net/ipv4/ip_forward`, though. – MadHatter Apr 25 '13 at 13:05
  • I have enabled forwarding and my routes look correct. Pinging one device from the other results in network unreachable. However, this is not my main question. Both mentioned methods still use a physical device. Is it possible to create a completly virtual device. Veth looks interrsting but I cant figure out its exact use – prinsen Apr 25 '13 at 13:14
  • Sorry, pressed send to early, see my edited comment – prinsen Apr 25 '13 at 13:20
  • OK, I'm wicked confused now. You went on to note that you had trouble routing between the virtual interfaces - but if they were completely virtual, and could have no devices attached to them, how would there be any traffic for you to route? I **really** think you need to overhaul this question and be clearer about **what you're trying to do**, while spending less time saying **how you think you might do it**. – MadHatter Apr 25 '13 at 13:24
  • My understanding of linux 'veth' devices is that veth sets up a pair of endpoint devices that work like a tunnel; i.e., packets sent into one endpoint are transmitted out the other endpoint unchanged. This is used in LXC to tie together separate ip namespaces for instance (like the LXC container to the host system.) – Will Dennis Apr 29 '13 at 18:08

1 Answers1

0

Sounds like you want to use something like 'tc' (se http://www.linuxcommand.org/man_pages/tc8.html for more detail) on the various interfaces, using the 'netem' kernel component.

An example would be:

tc qdisc add dev eth1 root handle 1: netem delay 500ms 125ms reorder 3% loss 2%

See http://man.he.net/man8/tc for the manpage on 'tc'.

See http://www.linuxfoundation.org/collaborate/workgroups/networking/netem for info on how to use the netem module with tc.

Will Dennis
  • 304
  • 4
  • 16
  • tc would let me do all traffic control needed. However, I'm struggling with the creation of the virtual interfaces and to set up proper routing between these. What I have done so far is to create a set of virtual interfaces of type macvlan. How do I force traffic to one interface to pass though another one? – prinsen Apr 27 '13 at 09:40
  • Check out this other SF question: http://serverfault.com/questions/332229/how-to-set-up-internal-routing-between-virtual-interfaces-and-real-ethernet-inte <-- not sure if helpful, I have no experience using 'macvlan' int's myself... – Will Dennis Apr 29 '13 at 17:52