FreeBSD + IPerf send multicast source traffic via specific interface
When generating multicast traffic under FreeBSD, Iperf will send all the traffic via the interface for the default route, even though "-B" switch is used to bind to the source IP of a different interface.
In this senario, I have two interfaces: vlan10 and vlan120. Default route goes out via vlan10 interface, but I need to send multicast traffic out the vlan120 interface.
Code:
[root@thor ~]# route get default
route to: default
destination: default
mask: default
gateway: apollo-vl10.ivorde.ro
interface: vlan10
flags: <UP,GATEWAY,DONE,STATIC>
recvpipe sendpipe ssthresh rtt,msec rttvar hopcount mtu expire
0 0 0 0 0 0 1500 0
[root@thor ~]# route get 239.1.1.1
route to: 239.1.1.1
destination: default
mask: default
gateway: apollo-vl10.ivorde.ro
interface: vlan10
flags: <UP,GATEWAY,DONE,STATIC>
recvpipe sendpipe ssthresh rtt,msec rttvar hopcount mtu expire
0 0 0 0 0 0 1500 0
[root@thor ~]# ifconfig vlan120
vlan120: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
ether 00:07:e9:a5:9b:fa
inet 10.1.120.2 netmask 0xffffff00 broadcast 10.1.120.255
media: Ethernet autoselect (1000baseTX <full-duplex>)
status: active
vlan: 120 parent interface: em0
[root@thor ~]# iperf -c 239.1.1.1 -u -T 64 -i 10 -t 10000 -B 10.1.120.2
On Linux, iperf would send the traffic out via vlan120 interface because of the '-B' argument. Iperf quote:
Quote:
-B, --bind <host>
bind to <host>, an interface or multicast address
In my case, "systat -if 1" shows that the multicast traffic still goes out via the default gateway interface: vlan10:
Code:
vlan10 in 0.108 KB/s 0.195 KB/s 789.687 MB
out 131.372 KB/s 133.568 KB/s 110.491 MB
The hack is to add a route for the multicast group /32 via a gateway in the 10.1.120.0/24 subnet. Without interrupting the iperf multicast stream, I do exactly that and check systat again:
Code:
# route add 239.1.1.1/32 10.1.120.4
add net 239.1.1.1: gateway 10.1.120.4
# systat -if 1
/0 /1 /2 /3 /4 /5 /6 /7 /8 /9 /10
Load Average
Interface Traffic Peak Total
vlan120 in 0.000 KB/s 0.065 KB/s 203.151 KB
out 130.908 KB/s 132.381 KB/s 1.793 GB
vlan10 in 0.196 KB/s 0.309 KB/s 789.706 MB
out 0.387 KB/s 1.551 KB/s 118.021 MB
When the route for the multicast group 239.1.1.1 is added on the subnet where the interface vlan120 is connected, the kernel will chose that interface to send multicast traffic through.
From my tests, I can see that the Iperf behavior on Linux is different in that iperf will choose the interface having the ip address in the "-B" argument.