For some tests purposes, I am running multiple socket-based applications on one machine and want to simulate "real" network conditions between them. I thought the simplest would be to redirect all traffic between the applications through the router my computer is connected to. Intuitively this should perform more or less like multiple computers connected to the same network, and the network itself should be limited by the capabilities of the router (100Mbps) rather than the local inter-machine socket connections.
My machine (192.168.1.101) is connected directly to a router (192.168.1.2) via the interface
em1. I tried to do it by adding an ip route. The result of my ip route command is:
default via 192.168.1.2 dev em1 proto static metric 1024 192.168.1.0/24 dev em1 proto kernel scope link src 192.168.1.101 192.168.1.101 via 192.168.1.2 dev em1
This however doesn't seem to have any effect, since pinging localhost returns more or less the same results as pinging my machine indirectly (192.168.1.101), that is around 0.040 ms. At the same time, pinging a different machine in my network results in pings around 0.3-0.5ms.
I've tried traceroute, here's what I get:
$traceroute 192.168.1.200 # my other computer traceroute to 192.168.1.200 (192.168.1.200), 30 hops max, 60 byte packets 1 192.168.1.200 (192.168.1.200) 1.005 ms 0.972 ms 0.954 ms $traceroute 192.168.1.101 traceroute to 192.168.1.101 (192.168.1.101), 30 hops max, 60 byte packets 1 localhost.localdomain (192.168.1.101) 0.051 ms 0.014 ms 0.013 ms $traceroute 127.0.0.1 traceroute to 127.0.0.1 (127.0.0.1), 30 hops max, 60 byte packets 1 localhost.localdomain (127.0.0.1) 0.053 ms 0.015 ms 0.013 ms
Am I missing something, or perhaps I'm doing it in a completely wrong way?