At work we have and end-to-end system that we will route packets through to pop out the other side, and then travel back through to come back where they originated. You can think of this as a normal communications stack.
In order to test throughput, we find ourselves using iperf3 by using two external computers to send traffic to this stack. We find ourselves using three computers total because we haven't been able to solve this route problem, but I feel that there must be some solution we're not seeing as I'm sure this has come up before. Id like to use just one machine if possible.
Where A is an iperf3 client, B consists of multiple programs passing packets off to each other as ethernet packets (Kept as one black box for simplicity) and C is the iperf3 server.
So to recap, I'd like packets to travel from A, to B, to C, and then back to B, and back to A.
To do this using Iperf, I'd have a client at A sending packets to C.
iperf3 -c "C"
And I'd also set up a server at C using
However, without any routing rules at this point these packets will bypass B and go straight between A and C. To stop this from happening, I make a routing rule to say something like "Route all traffic destined to C to B instead".
route add "C" netmask 255.255.255.255 gw "B"
Also, we have to do the same thing on the other side so that the server will not send directly back to A.
route add "A" netmask 255.255.255.255 gw "B"
If you haven't caught it already, this will cause a paradox and cause all traffic destined for both A and C to B. This means when B is done processing and would like to send the data to C, it will instead send to itself because this is what the routing table dictates*. This will also happen in the opposite direction.
Does anyone know a way around this? I'm not sure if it can be done with simple routing, but I don't know much about routing to begin with so maybe there's a trick for this?
*I'm not actually sure if it will keep sending to itself (I don't think it will, even if it does it won't know what to do with it the second time) but this is me trying to say it will not work with this configuration.