通过同一台机器的两个网络接口进行 DITG(ITGSend、ITGRecv)

通过同一台机器的两个网络接口进行 DITG(ITGSend、ITGRecv)

我有一台服务器,需要进行传输基准测试。该服务器有 3 个网络接口(172.16.10.205 用于 SSH,10.0.4.105 用于发送,10.0.8.105 用于接收)

                  to satellite         from satellite
                       /\                   \/
                       /\                   \/
                  |-----------|        |-------------|
                  | Modulator |        | Demodulator |
                  |-----------|        |-------------|
                    10.0.4.244          10.0.8.27
                            \            /
                             \          /
                  (eno7) 10.0.4.105   10.0.8.105 (eno8)
                            |------------|
                            |   Server   |
                            |------------|
                            172.16.10.205 (eno1)

在服务器上我设置了以下规则、路线:

# ip rule
100:    from 10.0.8.105 to 10.0.8.105 lookup 250 
30000:  from all lookup local 
32766:  from all lookup main 
32767:  from all lookup default 
# ip route show table 250
default via 10.0.4.244 dev eno7 
10.0.8.105 via 10.0.4.244 dev eno7

我已经开始ITGSend向调制器发送流:

ITGSend -a 10.0.8.105 -Sda 172.16.10.205 -c 600 -C 20 -t 2000 -poll

ITGRecv从解调器接收流:

ITGRecv -l itgrecv_kkr.log -q 1 -a 10.0.8.105 -i eno8

tcpdump看起来相当不错...

# tcpdump -i eno8 -n
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on eno8, link-type EN10MB (Ethernet), capture size 262144 bytes
10:34:32.538165 ARP, Request who-has 10.0.8.105 tell 10.0.8.27, length 46
10:34:32.538190 ARP, Reply 10.0.8.105 is-at 00:25:90:5d:df:ad, length 28
10:34:32.538276 IP 10.0.8.105.60367 > 10.0.8.105.8999: UDP, length 600
10:34:32.588162 IP 10.0.8.105.60367 > 10.0.8.105.8999: UDP, length 600
10:34:32.637465 IP 10.0.8.105.60367 > 10.0.8.105.8999: UDP, length 600

..但由于某种原因,ITGRecv没有收到数据...

更新:我尝试了第二个用例,以确保传入的数据不按给定的规则处理:

1)我必须创建一个规则,该规则位于local处理本地接口的规则之前(由local=30000 和new-rule=100完成):

ip rule del from all lookup local
ip rule add from all lookup local pref 30000
ip rule add from all fwmark 0x1 lookup 250 pref 100

2)当 MARK 设置为 1 时,此新规则仅将数据包发送到路由表 250。这是通过iptables标记所有发往给定 IP 地址的传出数据包来实现的:

iptables -A OUTPUT -t mangle -p all -d 10.0.8.105 -j MARK --set-mark 1

3)最后一步,我创建一条路由,将所有(标记的)数据包重定向到调制器设备:

ip route add default via 10.0.4.244 dev eno7 table 250

但仍然没有成功——包裹eno8正确到达,但iperf -s没有收到。

答案1

根据ip-sysctl.txt内核会丢弃来自本地接口的数据包。禁用此选项将允许从同一主机的 INTERFACE1 向 INTERFACE2 发送数据包:

accept_local - BOOLEAN
    Accept packets with local source addresses. In combination with
    suitable routing, this can be used to direct packets between two
    local interfaces over the wire and have them accepted properly.
    default FALSE

相关内容